Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cpdeploy

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cpdeploy - npm Package Compare versions

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.')
})

6

package.json
{
"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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc