Comparing version 2.0.2 to 2.1.0
54
index.js
@@ -5,5 +5,7 @@ #!/usr/bin/env node | ||
const get = require('lodash/get') | ||
const yaml = require('js-yaml') | ||
const prompt = require('prompt') | ||
const execSync = require('child_process').execSync | ||
const readFileSync = require('fs').readFileSync | ||
const {readFileSync, writeFileSync} = require('fs') | ||
const pjson = JSON.parse(readFileSync('package.json')) | ||
@@ -27,2 +29,3 @@ | ||
const ecrRepoUrl = readPackageKey('config.ecrRepoUrl') | ||
const deploymentRepoName = readPackageKey('config.deploymentRepoName') | ||
@@ -39,5 +42,13 @@ function exec(cmd, opts={}) { | ||
function getRemoteTag() { | ||
return `${ecrRepoUrl}/${ecrRepoName}:${tagName}` | ||
} | ||
function getLocalTag() { | ||
return `${ecrRepoName}:${tagName}` | ||
} | ||
function buildAndPushDockerImageRemote() { | ||
const remoteTag = `${ecrRepoUrl}/${ecrRepoName}:${tagName}` | ||
const localTag = `${ecrRepoName}:${tagName}` | ||
const remoteTag = getRemoteTag() | ||
const localTag = getLocalTag() | ||
let sshcmd = [ | ||
@@ -55,2 +66,39 @@ `cd ${repoName}`, | ||
function bumpDockerCompose() { | ||
// go into deployment repo | ||
process.chdir(`../${deploymentRepoName}`) | ||
// get latest revision | ||
exec(`git pull`) | ||
// update version of this service | ||
const compose = yaml.safeLoad(readFileSync(`docker-compose.yaml`)) | ||
if (!compose.services.hasOwnProperty(ecrRepoName)) { | ||
console.error(`service \`${ecrRepoName}\` not found in docker-compose`) | ||
process.exit(1) | ||
} | ||
compose.services[ecrRepoName].image = getRemoteTag() | ||
writeFileSync(`docker-compose.yaml`, yaml.safeDump(compose)) | ||
// release | ||
exec(`npm run release`) | ||
} | ||
buildAndPushDockerImageRemote() | ||
prompt.start() | ||
prompt.get({ | ||
properties: { | ||
deploy: { | ||
description: `Do you want to deploy ${getLocalTag()} to ${deploymentRepoName}?`, | ||
required: true, | ||
pattern: /no|yes|true|false|y|n/i, | ||
} | ||
} | ||
}, function(err, {deploy}) { | ||
if (err) | ||
throw err | ||
if (['yes', 'true', 't', 'y'].indexOf(deploy.toLowerCase()) != -1) | ||
bumpDockerCompose() | ||
else | ||
console.log('Skipping deployment.') | ||
}) |
{ | ||
"name": "cpdeploy", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "", | ||
@@ -24,4 +24,6 @@ "main": "index.js", | ||
"dependencies": { | ||
"lodash": "~4.15.0" | ||
"js-yaml": "~3.6.1", | ||
"lodash": "~4.15.0", | ||
"prompt": "~1.0.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5036
87
3
+ Addedjs-yaml@~3.6.1
+ Addedprompt@~1.0.0
+ Addedargparse@1.0.10(transitive)
+ Addedasync@0.9.21.0.0(transitive)
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedcolors@1.0.31.4.0(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedcycle@1.0.3(transitive)
+ Addeddeep-equal@0.2.2(transitive)
+ Addedesprima@2.7.3(transitive)
+ Addedeyes@0.1.8(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedi@0.3.7(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjs-yaml@3.6.1(transitive)
+ Addedminimatch@3.1.2(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedmkdirp@0.5.6(transitive)
+ Addedmute-stream@0.0.8(transitive)
+ Addedncp@1.0.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedpkginfo@0.3.10.4.1(transitive)
+ Addedprompt@1.0.0(transitive)
+ Addedread@1.0.7(transitive)
+ Addedrevalidator@0.1.8(transitive)
+ Addedrimraf@2.7.1(transitive)
+ Addedsprintf-js@1.0.3(transitive)
+ Addedstack-trace@0.0.10(transitive)
+ Addedutile@0.3.0(transitive)
+ Addedwinston@2.1.1(transitive)
+ Addedwrappy@1.0.2(transitive)