New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bowtie/cli

Package Overview
Dependencies
Maintainers
4
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bowtie/cli - npm Package Compare versions

Comparing version 0.1.1 to 0.1.3

.jsdoc.json

4

index.js

@@ -1,1 +0,3 @@

// index.js
// index.js
module.exports = require('./src/bt')
{
"name": "@bowtie/cli",
"version": "0.1.1",
"version": "0.1.3",
"description": "Internal BowTie CLI Tools",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"doc": "jsdoc --configure .jsdoc.json --verbose",
"doc:commit": "npm run doc && git add docs && git commit -m 'Generated Docs'",
"lint": "standard",
"lint:fix": "standard --fix",
"test": "npm run lint && mocha test/**/*.spec.js",
"test:watch": "mocha test/**/*.spec.js --watch",
"preversion": "npm test && npm run doc:commit",
"postversion": "git push --follow-tags"
},

@@ -21,4 +28,10 @@ "preferGlobal": true,

],
"author": "Charlie McClung",
"license": "ISC",
"standard": {
"ignore": [
"docs/*",
"test/*"
]
},
"author": "Bowtie",
"license": "MIT",
"bugs": {

@@ -32,3 +45,12 @@ "url": "https://github.com/bowtie-co/node-bowtie-cli/issues"

"shelljs": "^0.7.8"
},
"devDependencies": {
"chai": "^4.1.2",
"jsdoc": "^3.5.5",
"minami": "^1.2.3",
"mocha": "^5.0.4",
"sinon": "^4.4.6",
"sinon-chai": "^3.0.0",
"standard": "^11.0.1"
}
}

@@ -1,73 +0,79 @@

const http = require('http');
const async = require('async');
const shell = require('shelljs');
const http = require('http')
const async = require('async')
const shell = require('shelljs')
const clean = require('./clean');
module.exports = ({ cli, info, args }) => {
const run = ({ cli, info, args }) => {
if (!info.context.dockerCompose) {
cli.error(`Current directory: '${info.cwd}' has no 'docker-compose.yml' file`);
cli.error(`Current directory: '${info.cwd}' has no 'docker-compose.yml' file`)
}
const times = {};
const times = {}
cli.log('Begin Benchmark');
cli.log('Begin Benchmark')
times.build = {};
times.build = {}
times.build.start = Date.now();
times.build.start = Date.now()
shell.exec('docker-compose build');
shell.exec('docker-compose build')
times.build.end = Date.now();
times.build.end = Date.now()
if (info.context.rails) {
times.reset = {};
times.reset.start = Date.now();
shell.exec('docker-compose run app bundle exec rake db:reset');
times.reset = {}
times.reset.end = Date.now();
times.reset.start = Date.now()
shell.exec('docker-compose run app bundle exec rake db:reset')
times.reset.end = Date.now()
}
times.up = {};
times.up = {}
times.up.start = Date.now();
times.up.start = Date.now()
shell.exec('docker-compose up -d');
shell.exec('docker-compose up -d')
let responseCode;
let responseCode
async.whilst(
() => { return responseCode !== 200; },
() => { return responseCode !== 200 },
(callback) => {
http.get('http://localhost', (res) => {
responseCode = res.statusCode;
responseCode = res.statusCode
callback();
callback()
}).on('error', (e) => {
callback();
});
callback()
})
},
(err) => {
if (err) {
cli.error(err);
cli.error(err)
} else {
times.up.end = Date.now();
times.up.end = Date.now()
let report = 'Benchmark Report:';
let report = 'Benchmark Report:'
Object.keys(times).forEach(partName => {
const partTimes = times[partName];
const partTimes = times[partName]
const duration = (partTimes.end -partTimes.start) / 1000;
const duration = (partTimes.end - partTimes.start) / 1000
report += `\n${partName} time => ${duration}s`;
});
report += `\n${partName} time => ${duration}s`
})
cli.success(report);
cli.success(report)
}
}
);
};
)
}
module.exports = {
run,
description: 'Benchmark docker-compose dev setup times'
// examples: [
// 'bt benchmark stuff'
// ]
}
const dockerCompose = require('./dockerCompose')
module.exports = (opts) => {
const run = (opts) => {
opts.args.unshift('build')
dockerCompose(opts)
dockerCompose.run(opts)
opts.args.shift()
};
}
module.exports = {
run,
description: 'Build docker-compose image(s) for current directory'
// examples: [
// 'bt build stuff'
// ]
}

@@ -1,7 +0,7 @@

const spawn = require('../spawn');
const spawn = require('../spawn')
const dockerCompose = require('./dockerCompose')
module.exports = ({ cli, info, args, env }) => {
const run = ({ cli, info, args, env }) => {
if (!info.context.rails) {
cli.error(`Current directory: '${info.cwd}' is not a Rails project`);
cli.error(`Current directory: '${info.cwd}' is not a Rails project`)
}

@@ -12,3 +12,3 @@

dockerCompose({ cli, info, args })
dockerCompose.run({ cli, info, args })
} else {

@@ -24,2 +24,11 @@ args.unshift('exec')

}
};
}
module.exports = {
run,
description: 'Run command with "bundle exec" prefix',
examples: [
'bt bundleExec rake db:setup',
'bt bundleExec rake db:setup --service my-rails-service'
]
}

@@ -1,23 +0,23 @@

const shell = require('shelljs');
const path = require('path');
const shell = require('shelljs')
const path = require('path')
module.exports = ({ cli, info, args }) => {
let keyword = false;
let response = '';
const run = ({ cli, info, args }) => {
let keyword = false
let response = ''
if (info.context.dockerCompose) {
cli.log(`Current directory: ${info.cwd} is a docker project.`);
keyword = path.basename(info.cwd).replace(/[^0-9a-z]/gi, '');
cli.log(`Clean commands filtering for "${keyword}"`);
cli.log(`Current directory: ${info.cwd} is a docker project.`)
keyword = path.basename(info.cwd).replace(/[^0-9a-z]/gi, '')
cli.log(`Clean commands filtering for "${keyword}"`)
} else {
cli.log(`Current directory: ${info.cwd} is not a docker project.`);
keyword = cli.prompt('Enter a filter for cleanup: (blank for full clean)');
cli.log(`Current directory: ${info.cwd} is not a docker project.`)
keyword = cli.prompt('Enter a filter for cleanup: (blank for full clean)')
if (keyword.trim() === '') {
keyword = false;
keyword = false
}
}
if (!cli.confirm(`Clean with filter: ${keyword ? keyword : '[NO FILTER]'}`)) {
cli.error('Aborted.');
if (!cli.confirm(`Clean with filter: ${keyword || '[NO FILTER]'}`)) {
cli.error('Aborted.')
}

@@ -28,8 +28,8 @@

*/
cli.log('Cleaning: Running docker container(s):');
cli.log('Cleaning: Running docker container(s):')
if (keyword) {
response = shell.exec(`docker ps | grep "${keyword}"`).stdout;
response = shell.exec(`docker ps | grep "${keyword}"`).stdout
} else {
response = shell.exec('docker ps | grep -v "CONTAINER ID"').stdout;
response = shell.exec('docker ps | grep -v "CONTAINER ID"').stdout
}

@@ -39,5 +39,5 @@

if (keyword) {
shell.exec(`docker stop $(docker ps | grep ${keyword} | awk '{ print $1 }')`);
shell.exec(`docker stop $(docker ps | grep ${keyword} | awk '{ print $1 }')`)
} else {
shell.exec('docker stop $(docker ps -q)');
shell.exec('docker stop $(docker ps -q)')
}

@@ -49,8 +49,8 @@ }

*/
cli.log('Cleaning: Stopped docker container(s):');
cli.log('Cleaning: Stopped docker container(s):')
if (keyword) {
response = shell.exec(`docker ps -a | grep "${keyword}"`).stdout;
response = shell.exec(`docker ps -a | grep "${keyword}"`).stdout
} else {
response = shell.exec('docker ps -a | grep -v "CONTAINER ID"').stdout;
response = shell.exec('docker ps -a | grep -v "CONTAINER ID"').stdout
}

@@ -60,5 +60,5 @@

if (keyword) {
shell.exec(`docker rm $(docker ps -a | grep ${keyword} | awk '{ print $1 }')`);
shell.exec(`docker rm $(docker ps -a | grep ${keyword} | awk '{ print $1 }')`)
} else {
shell.exec('docker rm $(docker ps -aq)');
shell.exec('docker rm $(docker ps -aq)')
}

@@ -70,8 +70,8 @@ }

*/
cli.log('Cleaning: Docker image(s)');
cli.log('Cleaning: Docker image(s)')
if (keyword) {
response = shell.exec(`docker images | grep "${keyword}"`).stdout;
response = shell.exec(`docker images | grep "${keyword}"`).stdout
} else {
response = shell.exec('docker images | grep -v "IMAGE ID"').stdout;
response = shell.exec('docker images | grep -v "IMAGE ID"').stdout
}

@@ -81,5 +81,5 @@

if (keyword) {
shell.exec(`docker rmi -f $(docker images | grep ${keyword} | awk '{ print $3 }' | uniq)`);
shell.exec(`docker rmi -f $(docker images | grep ${keyword} | awk '{ print $3 }' | uniq)`)
} else {
shell.exec('docker rmi -f $(docker images -q)');
shell.exec('docker rmi -f $(docker images -q)')
}

@@ -91,8 +91,8 @@ }

*/
cli.log('Cleaning: Docker volume(s):');
cli.log('Cleaning: Docker volume(s):')
if (keyword) {
response = shell.exec(`docker volume ls | grep "${keyword}"`).stdout;
response = shell.exec(`docker volume ls | grep "${keyword}"`).stdout
} else {
response = shell.exec('docker volume ls').stdout;
response = shell.exec('docker volume ls').stdout
}

@@ -102,5 +102,5 @@

if (keyword) {
shell.exec(`docker volume rm $(docker volume ls | grep ${keyword} | awk '{ print $2 }')`);
shell.exec(`docker volume rm $(docker volume ls | grep ${keyword} | awk '{ print $2 }')`)
} else {
shell.exec('docker volume rm $(docker volume ls -q)');
shell.exec('docker volume rm $(docker volume ls -q)')
}

@@ -112,6 +112,6 @@ }

*/
cli.log('Cleaning: Untagged image(s):');
response = shell.exec('docker images | grep "^<none>"').stdout;
cli.log('Cleaning: Untagged image(s):')
response = shell.exec('docker images | grep "^<none>"').stdout
if (response.trim() !== '' && cli.confirm('Remove untagged image(s)?')) {
shell.exec("docker rmi $(docker images | grep '^<none>' | awk '{print $3}')");
shell.exec("docker rmi $(docker images | grep '^<none>' | awk '{print $3}')")
}

@@ -122,7 +122,15 @@

*/
cli.log('Cleaning: Dangling image(s):');
response = shell.exec('docker images -f dangling=true | grep -v "IMAGE ID"').stdout;
cli.log('Cleaning: Dangling image(s):')
response = shell.exec('docker images -f dangling=true | grep -v "IMAGE ID"').stdout
if (response.trim() !== '' && cli.confirm('Remove dangling image(s)?')) {
shell.exec("docker rmi $(docker images -f dangling=true -q)");
shell.exec('docker rmi $(docker images -f dangling=true -q)')
}
};
}
module.exports = {
run,
description: 'Clean docker containers, images, and volumes'
// examples: [
// 'bt benchmark stuff'
// ]
}
const bundleExec = require('./bundleExec')
module.exports = ({ cli, info, args }) => {
const run = ({ cli, info, args }) => {
args.unshift('rails', 'console')
bundleExec({ cli, info, args })
bundleExec.run({ cli, info, args })
args.shift()
args.shift()
};
args.shift()
}
module.exports = {
run,
description: 'Launch rails console within docker-compose'
// examples: [
// 'bt benchmark stuff'
// ]
}

@@ -1,6 +0,6 @@

const spawn = require('../spawn');
const spawn = require('../spawn')
module.exports = ({ cli, info, args, env }) => {
const run = ({ cli, info, args, env }) => {
if (!info.context.dockerCompose) {
cli.error(`Current directory: '${info.cwd}' has no 'docker-compose.yml' file`);
cli.error(`Current directory: '${info.cwd}' has no 'docker-compose.yml' file`)
}

@@ -15,3 +15,11 @@

}
});
};
})
}
module.exports = {
run,
description: 'Run docker-compose'
// examples: [
// 'bt benchmark stuff'
// ]
}

@@ -1,2 +0,2 @@

const fs = require('fs');
const fs = require('fs')
const path = require('path')

@@ -6,4 +6,4 @@

if (fileName.substr(-3) === '.js' && fileName !== 'index.js') {
module.exports[fileName.split('.')[0]] = require(path.join(__dirname, fileName));
module.exports[fileName.split('.')[0]] = require(path.join(__dirname, fileName))
}
});
})
const dockerCompose = require('./dockerCompose')
module.exports = (opts) => {
opts.args.unshift('logs', '-f')
const run = (opts) => {
if (opts.cli.options.tail) {
opts.args.unshift('logs', '-f')
} else {
opts.args.unshift('logs')
}
dockerCompose(opts)
dockerCompose.run(opts)
opts.args.shift()
opts.args.shift()
};
if (opts.cli.options.tail) {
opts.args.shift()
}
}
module.exports = {
run,
description: 'Logs from docker-compose',
examples: [
'bt logs',
'bt logs --tail'
]
}
const bundleExec = require('./bundleExec')
module.exports = (opts) => {
const run = (opts) => {
opts.args.unshift('rake', 'db:migrate')
bundleExec(opts)
bundleExec.run(opts)
opts.args.shift()
opts.args.shift()
};
}
module.exports = {
run,
description: 'Run rails database migration',
examples: [
'bt migrate',
'bt migrate --service my-rails-service'
]
}

@@ -1,7 +0,7 @@

const spawn = require('../spawn');
const spawn = require('../spawn')
const dockerCompose = require('./dockerCompose')
module.exports = ({ cli, info, args, env }) => {
const run = ({ cli, info, args, env }) => {
if (!info.context.node) {
cli.error(`Current directory: '${info.cwd}' is not a Node project`);
cli.error(`Current directory: '${info.cwd}' is not a Node project`)
}

@@ -12,8 +12,8 @@

dockerCompose({ cli, info, args })
dockerCompose.run({ cli, info, args })
opts.args.shift()
opts.args.shift()
opts.args.shift()
opts.args.shift()
args.shift()
args.shift()
args.shift()
args.shift()
} else {

@@ -29,4 +29,12 @@ args.unshift('run')

opts.args.shift()
args.shift()
}
};
}
module.exports = {
run,
description: 'Run npm script (from package.json)'
// examples: [
// 'bt benchmark stuff'
// ]
}
const dockerCompose = require('./dockerCompose')
module.exports = (opts) => {
const run = (opts) => {
opts.args.unshift('ps')
dockerCompose(opts)
dockerCompose.run(opts)
opts.args.shift()
};
}
module.exports = {
run,
description: 'Show running docker-compose containers'
// examples: [
// 'bt benchmark stuff'
// ]
}

@@ -1,13 +0,21 @@

const stop = require('./stop');
const build = require('./build');
const reset = require('./reset');
const stop = require('./stop')
const build = require('./build')
const reset = require('./reset')
module.exports = ({ cli, info, args }) => {
const run = ({ cli, info, args }) => {
if (!info.context.dockerCompose) {
cli.error(`Current directory: '${info.cwd}' has no 'docker-compose.yml' file`);
cli.error(`Current directory: '${info.cwd}' has no 'docker-compose.yml' file`)
}
stop({ cli, info, args })
build({ cli, info, args })
reset({ cli, info, args })
};
stop.run({ cli, info, args })
build.run({ cli, info, args })
reset.run({ cli, info, args })
}
module.exports = {
run,
description: 'Run actions: "stop", "build", and "reset" for complete rebuild'
// examples: [
// 'bt benchmark stuff'
// ]
}
const bundleExec = require('./bundleExec')
module.exports = (opts) => {
const run = (opts) => {
opts.args.unshift('rake', 'db:reset')
bundleExec(opts)
bundleExec.run(opts)
opts.args.shift()
opts.args.shift()
};
}
module.exports = {
run,
description: 'Run rails database reset',
examples: [
'bt reset',
'bt reset --service my-rails-service'
]
}
const bundleExec = require('./bundleExec')
module.exports = (opts) => {
const run = (opts) => {
opts.args.unshift('rake', 'db:rollback')
bundleExec(opts)
bundleExec.run(opts)
opts.args.shift()
opts.args.shift()
};
}
module.exports = {
run,
description: 'Run rails database rollback',
examples: [
'bt rollback',
'bt rollback --service my-rails-service'
]
}
const dockerCompose = require('./dockerCompose')
module.exports = (opts) => {
const run = (opts) => {
opts.args.unshift('run')
dockerCompose(opts)
dockerCompose.run(opts)
opts.args.shift()
};
}
module.exports = {
run,
description: 'Run command within docker-compose service container',
examples: [
'bt run bash',
'bt run rails c --service my-rails-service',
'bt run mysql --service my-mysql-service'
]
}
const dockerCompose = require('./dockerCompose')
module.exports = (opts) => {
const run = (opts) => {
opts.args.unshift('stop')
dockerCompose(opts)
dockerCompose.run(opts)
opts.args.shift()
};
}
module.exports = {
run,
description: 'Stop docker-compose containers'
// examples: [
// 'bt benchmark stuff'
// ]
}
const { bundleExec, npmRun } = require('./')
module.exports = ({ cli, info, args }) => {
const run = ({ cli, info, args }) => {
const env = {

@@ -12,3 +12,3 @@ CI: 'true'

railsArgs.unshift('rake', 'ci')
bundleExec({ cli, info, args: railsArgs, env})
bundleExec.run({ cli, info, args: railsArgs, env })
}

@@ -21,4 +21,12 @@

npmRun({ cli, info, args: nodeArgs, env})
npmRun.run({ cli, info, args: nodeArgs, env })
}
};
}
module.exports = {
run,
description: 'Attempt to run tests in docker, fall back to local'
// examples: [
// 'bt test [italic]{# runs "rake ci" in a rails project}'
// ]
}
const dockerCompose = require('./dockerCompose')
const logs = require('./logs')
module.exports = (opts) => {
const run = (opts) => {
opts.args.unshift('up', '-d')
dockerCompose(opts)
dockerCompose.run(opts)

@@ -12,5 +12,14 @@ opts.args.shift()

if (opts.cli.options.watch) {
if (opts.cli.options.tail) {
logs(opts)
}
};
}
module.exports = {
run,
description: 'Bring up docker-compose services',
examples: [
'bt up',
'bt up --tail'
]
}

@@ -1,4 +0,3 @@

const shell = require('shelljs');
const os = require('os');
const fs = require('fs');
const os = require('os')
const fs = require('fs')

@@ -15,24 +14,24 @@ const info = {

context: {}
};
}
const files = fs.readdirSync(info.cwd);
const files = fs.readdirSync(info.cwd)
files.forEach(file => {
if (/dockerfile/i.test(file)) {
info.context.docker = true;
info.context.docker = true
}
if (/docker-compose\.ya?ml/i.test(file)) {
info.context.dockerCompose = true;
info.context.dockerCompose = true
}
if (/gemfile/i.test(file)) {
info.context.rails = true;
info.context.rails = true
}
if (/package\.json/i.test(file)) {
info.context.node = true;
info.context.node = true
}
});
})
module.exports = info;
module.exports = info

@@ -1,7 +0,7 @@

const spawn = require('child_process').spawnSync;
const spawn = require('child_process').spawnSync
var cleanExit = function() { process.exit() };
var cleanExit = function () { process.exit() }
process.on('SIGINT', cleanExit); // catch ctrl-c
process.on('SIGTERM', cleanExit); // catch kill
process.on('SIGINT', cleanExit) // catch ctrl-c
process.on('SIGTERM', cleanExit) // catch kill

@@ -29,2 +29,2 @@ module.exports = ({ cli, cmd, args, env }) => {

}
};
}

Sorry, the diff of this file is not supported yet

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