@busy-web/cli
Advanced tools
Comparing version 0.7.0 to 0.7.1
{ | ||
"name": "@busy-web/cli", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "Command line tools to enhance web dev tasks", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -19,2 +19,6 @@ /** | ||
function getRevision() { | ||
return this.cmd(`git log -1 --format=%H`, { hidecmd: true }).then(hash => hash.substr(0, 7)); | ||
} | ||
module.exports = createCommand({ | ||
@@ -24,3 +28,3 @@ name: 'deploy', | ||
alias: 'd', | ||
args: ['<branch>'], | ||
args: ['[branch]', '[tag]'], | ||
@@ -31,3 +35,3 @@ options: [ | ||
run(branch) { | ||
run(branch, tag) { | ||
let cwd = process.cwd(); | ||
@@ -41,18 +45,8 @@ let pkgInfo = require(path.join(cwd + '/package.json')); | ||
let [ build, ] = buildVer.split('.'); | ||
if (branch === 'master') { | ||
build = 'canary'; | ||
} else if (branch !== baseVer || isEmpty(buildVer)) { | ||
return this.resolve("Not a release branch"); | ||
} | ||
return release.call(this, build, true, true, false, branch).then(res => { | ||
let info = getBuildInfo(res); | ||
return prune.call(this, info.version, info.build, 5, true).then(result => { | ||
this.ui.info(result); | ||
return this.cmd(`git log -1 --pretty=oneline`, { hidecmd: true }).then(log => { | ||
let [ hash ] = log.split(' '); | ||
let revision = hash.substr(0, 7); | ||
return this.cmd(`ember deploy ${info.build}`).then(() => { | ||
return this.cmd(`ember deploy:activate --revision ${revision} ${info.build}`).then(() => { | ||
if (!isEmpty(tag)) { | ||
if (/v[0-9]+\.[0-9]+\.[0-9]+$/.test(tag)) { | ||
this.ui.info('Preparing production deploy...'); | ||
return getRevision.call(this).then(revision => { | ||
return this.cmd(`ember deploy production`).then(() => { | ||
return this.cmd(`ember deploy:activate --revision ${revision} production`).then(() => { | ||
return this.resolve('Deploy finished!'); | ||
@@ -62,5 +56,30 @@ }); | ||
}); | ||
} else { | ||
this.resolve('Not a production tag. Skipping deploy'); | ||
} | ||
} else if (!isEmpty(branch)) { | ||
let [ build, ] = buildVer.split('.'); | ||
if (branch === 'master') { | ||
build = 'canary'; | ||
} else if (branch !== baseVer || isEmpty(buildVer)) { | ||
return this.resolve("Not a release branch"); | ||
} | ||
return release.call(this, build, true, true, false, branch).then(res => { | ||
let info = getBuildInfo(res); | ||
return prune.call(this, info.version, info.build, 5, true).then(result => { | ||
this.ui.info(result); | ||
return getRevision.call(this).then(revision => { | ||
return this.cmd(`ember deploy ${info.build}`).then(() => { | ||
return this.cmd(`ember deploy:activate --revision ${revision} ${info.build}`).then(() => { | ||
return this.resolve('Deploy finished!'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} else { | ||
return this.reject('You must provide a tag or a branch'); | ||
} | ||
} | ||
}); |
54242
1382