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

shipit-cli

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shipit-cli - npm Package Compare versions

Comparing version 4.1.1 to 4.1.2

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

## [4.1.2](https://github.com/shipitjs/shipit/tree/master/packages/shipit-deploy/compare/v4.1.1...v4.1.2) (2018-11-04)
**Note:** Version bump only for package shipit-cli
<a name="4.1.1"></a>

@@ -8,0 +16,0 @@ ## [4.1.1](https://github.com/shipitjs/shipit/compare/v4.1.0...v4.1.1) (2018-05-30)

148

lib/cli.js

@@ -1,86 +0,22 @@

'use strict';
"use strict";
let asyncInvoke = (() => {
var _ref = _asyncToGenerator(function* (env) {
if (!env.configPath) {
console.error(_chalk2.default.red('shipitfile not found'));
exit(1);
}
var _chalk = _interopRequireDefault(require("chalk"));
var _program$args = _commander2.default.args;
var _interpret = _interopRequireDefault(require("interpret"));
const environment = _program$args[0],
tasks = _program$args.slice(1);
var _v8flags = _interopRequireDefault(require("v8flags"));
const shipit = new _Shipit2.default({ environment });
var _liftoff = _interopRequireDefault(require("liftoff"));
try {
/* eslint-disable global-require, import/no-dynamic-import, import/no-dynamic-require */
const module = require(env.configPath);
/* eslint-enable global-require, import/no-dynamic-import, import/no-dynamic-require */
const initialize = typeof module.default === 'function' ? module.default : module;
yield initialize(shipit);
} catch (error) {
console.error(_chalk2.default.red('Could not load async config'));
throw error;
}
var _commander = _interopRequireDefault(require("commander"));
if (_commander2.default.tasks === true) {
logTasks(shipit);
} else if (_commander2.default.environments === true) {
logEnvironments(shipit);
} else {
// Run the 'default' task if no task is specified
const runTasks = tasks.length === 0 ? ['default'] : tasks;
var _Shipit = _interopRequireDefault(require("./Shipit"));
shipit.initialize();
var _package = _interopRequireDefault(require("../package.json"));
shipit.on('task_err', function () {
return exit(1);
});
shipit.on('task_not_found', function () {
return exit(1);
});
shipit.start(runTasks);
}
});
return function asyncInvoke(_x) {
return _ref.apply(this, arguments);
};
})();
var _chalk = require('chalk');
var _chalk2 = _interopRequireDefault(_chalk);
var _interpret = require('interpret');
var _interpret2 = _interopRequireDefault(_interpret);
var _v8flags = require('v8flags');
var _v8flags2 = _interopRequireDefault(_v8flags);
var _liftoff = require('liftoff');
var _liftoff2 = _interopRequireDefault(_liftoff);
var _commander = require('commander');
var _commander2 = _interopRequireDefault(_commander);
var _Shipit = require('./Shipit');
var _Shipit2 = _interopRequireDefault(_Shipit);
var _package = require('../package.json');
var _package2 = _interopRequireDefault(_package);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } /* eslint-disable no-console */
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

@@ -98,8 +34,8 @@ function exit(code) {

_commander2.default.version(_package2.default.version).allowUnknownOption().usage('<environment> <tasks...>').option('--shipitfile <file>', 'Specify a custom shipitfile to use').option('--require <files...>', 'Script required before launching Shipit').option('--tasks', 'List available tasks').option('--environments', 'List available environments');
_commander.default.version(_package.default.version).allowUnknownOption().usage('<environment> <tasks...>').option('--shipitfile <file>', 'Specify a custom shipitfile to use').option('--require <files...>', 'Script required before launching Shipit').option('--tasks', 'List available tasks').option('--environments', 'List available environments');
_commander2.default.parse(process.argv);
_commander.default.parse(process.argv);
if (!process.argv.slice(2).length) {
_commander2.default.help();
_commander.default.help();
}

@@ -115,2 +51,50 @@

function asyncInvoke(_x) {
return _asyncInvoke.apply(this, arguments);
}
function _asyncInvoke() {
_asyncInvoke = _asyncToGenerator(function* (env) {
if (!env.configPath) {
console.error(_chalk.default.red('shipitfile not found'));
exit(1);
}
const _program$args = _commander.default.args,
environment = _program$args[0],
tasks = _program$args.slice(1);
const shipit = new _Shipit.default({
environment
});
try {
/* eslint-disable global-require, import/no-dynamic-import, import/no-dynamic-require */
const module = require(env.configPath);
/* eslint-enable global-require, import/no-dynamic-import, import/no-dynamic-require */
const initialize = typeof module.default === 'function' ? module.default : module;
yield initialize(shipit);
} catch (error) {
console.error(_chalk.default.red('Could not load async config'));
throw error;
}
if (_commander.default.tasks === true) {
logTasks(shipit);
} else if (_commander.default.environments === true) {
logEnvironments(shipit);
} else {
// Run the 'default' task if no task is specified
const runTasks = tasks.length === 0 ? ['default'] : tasks;
shipit.initialize();
shipit.on('task_err', () => exit(1));
shipit.on('task_not_found', () => exit(1));
shipit.start(runTasks);
}
});
return _asyncInvoke.apply(this, arguments);
}
function invoke(env) {

@@ -124,10 +108,10 @@ asyncInvoke(env).catch(error => {

const cli = new _liftoff2.default({
const cli = new _liftoff.default({
name: 'shipit',
extensions: _interpret2.default.jsVariants,
v8flags: _v8flags2.default
extensions: _interpret.default.jsVariants,
v8flags: _v8flags.default
});
cli.launch({
configPath: _commander2.default.shipitfile,
require: _commander2.default.require
configPath: _commander.default.shipitfile,
require: _commander.default.require
}, invoke);

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

'use strict';
"use strict";
var _Shipit = require('./Shipit');
var _Shipit = _interopRequireDefault(require("./Shipit"));
var _Shipit2 = _interopRequireDefault(_Shipit);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
module.exports = _Shipit2.default;
module.exports = _Shipit.default;

@@ -1,32 +0,26 @@

'use strict';
"use strict";
exports.__esModule = true;
exports.default = void 0;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /* eslint-disable no-console */
var _sshPool = require("ssh-pool");
var _streamLineWrapper = _interopRequireDefault(require("stream-line-wrapper"));
var _sshPool = require('ssh-pool');
var _orchestrator = _interopRequireDefault(require("orchestrator"));
var _streamLineWrapper = require('stream-line-wrapper');
var _chalk = _interopRequireDefault(require("chalk"));
var _streamLineWrapper2 = _interopRequireDefault(_streamLineWrapper);
var _prettyHrtime = _interopRequireDefault(require("pretty-hrtime"));
var _orchestrator = require('orchestrator');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _orchestrator2 = _interopRequireDefault(_orchestrator);
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
var _chalk = require('chalk');
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
var _chalk2 = _interopRequireDefault(_chalk);
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
var _prettyHrtime = require('pretty-hrtime');
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var _prettyHrtime2 = _interopRequireDefault(_prettyHrtime);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
/**

@@ -65,22 +59,21 @@ * An ExecResult returned when a command is executed with success.

return e.message;
}
} // PluginError
// PluginError
if (typeof e.err.showStack === 'boolean') {
return e.err.toString();
}
} // normal error
// normal error
if (e.err.stack) {
return e.err.stack;
}
} // unknown (string, number, etc.)
// unknown (string, number, etc.)
return new Error(String(e.err)).stack;
}
class Shipit extends _orchestrator2.default {
class Shipit extends _orchestrator.default {
constructor(options) {
super();
const defaultOptions = {

@@ -91,3 +84,2 @@ stdout: process.stdout,

};
this.config = {};

@@ -97,10 +89,6 @@ this.globalConfig = {};

this.environment = options.environment;
this.initializeEvents();
if (this.options.stdout === process.stdout) process.stdout.setMaxListeners(100);
if (this.options.stderr === process.stderr) process.stderr.setMaxListeners(100);
}
/**

@@ -111,12 +99,14 @@ * Initialize the `shipit`.

*/
initialize() {
if (!this.globalConfig[this.environment]) throw new Error(`Environment '${this.environment}' not found in config`);
this.emit('init');
return this.initSshPool();
}
/**
* Initialize events.
*/
initializeEvents() {

@@ -126,31 +116,26 @@ this.on('task_start', e => {

if (this.tasks[e.task].fn.toString() === 'function () {}') return;
this.log('\nRunning', `'${_chalk2.default.cyan(e.task)}' task...`);
this.log('\nRunning', `'${_chalk.default.cyan(e.task)}' task...`);
});
this.on('task_stop', e => {
const task = this.tasks[e.task]; // Specific log for noop functions.
this.on('task_stop', e => {
const task = this.tasks[e.task];
// Specific log for noop functions.
if (task.fn.toString() === 'function () {}') {
this.log('Finished', `'${_chalk2.default.cyan(e.task)}'`, _chalk2.default.cyan(`[ ${task.dep.join(', ')} ]`));
this.log('Finished', `'${_chalk.default.cyan(e.task)}'`, _chalk.default.cyan(`[ ${task.dep.join(', ')} ]`));
return;
}
const time = (0, _prettyHrtime2.default)(e.hrDuration);
this.log('Finished', `'${_chalk2.default.cyan(e.task)}'`, 'after', _chalk2.default.magenta(time));
const time = (0, _prettyHrtime.default)(e.hrDuration);
this.log('Finished', `'${_chalk.default.cyan(e.task)}'`, 'after', _chalk.default.magenta(time));
});
this.on('task_err', e => {
const msg = formatError(e);
const time = (0, _prettyHrtime2.default)(e.hrDuration);
this.log(`'${_chalk2.default.cyan(e.task)}'`, _chalk2.default.red('errored after'), _chalk2.default.magenta(time));
const time = (0, _prettyHrtime.default)(e.hrDuration);
this.log(`'${_chalk.default.cyan(e.task)}'`, _chalk.default.red('errored after'), _chalk.default.magenta(time));
this.log(msg);
});
this.on('task_not_found', err => {
this.log(_chalk2.default.red(`Task '${err.task}' is not in your shipitfile`));
this.log(_chalk.default.red(`Task '${err.task}' is not in your shipitfile`));
this.log('Please check the documentation for proper shipitfile formatting');
});
}
/**

@@ -161,5 +146,6 @@ * Initialize SSH connections.

*/
initSshPool() {
if (!this.config.servers) throw new Error('Servers not filled');
const servers = Array.isArray(this.config.servers) ? this.config.servers : [this.config.servers];

@@ -174,6 +160,4 @@

this.pool = new _sshPool.ConnectionPool(servers, options);
return this;
}
/**

@@ -185,2 +169,4 @@ * Initialize shipit configuration.

*/
initConfig(config = {}) {

@@ -191,3 +177,2 @@ this.globalConfig = config;

}
/**

@@ -200,6 +185,8 @@ * Run a command locally.

*/
local(command, _ref = {}) {
let stdout = _ref.stdout,
stderr = _ref.stderr,
cmdOptions = _objectWithoutProperties(_ref, ['stdout', 'stderr']);
cmdOptions = _objectWithoutPropertiesLoose(_ref, ["stdout", "stderr"]);

@@ -209,8 +196,10 @@ this.log('Running "%s" on local.', command);

return (0, _sshPool.exec)(command, cmdOptions, child => {
if (this.options.stdout) child.stdout.pipe(new _streamLineWrapper2.default({ prefix })).pipe(this.options.stdout);
if (this.options.stderr) child.stderr.pipe(new _streamLineWrapper2.default({ prefix })).pipe(this.options.stderr);
if (this.options.stdout) child.stdout.pipe(new _streamLineWrapper.default({
prefix
})).pipe(this.options.stdout);
if (this.options.stderr) child.stderr.pipe(new _streamLineWrapper.default({
prefix
})).pipe(this.options.stderr);
});
}
/**

@@ -223,2 +212,4 @@ * Run a command remotely.

*/
remote(command, options) {

@@ -231,3 +222,2 @@ var _this = this;

}
/**

@@ -241,2 +231,4 @@ * Copy from local to remote or vice versa.

*/
remoteCopy(src, dest, options) {

@@ -250,2 +242,3 @@ var _this2 = this;

};
const copyOptions = _extends({}, defaultOptions, options);

@@ -256,3 +249,2 @@

}
/**

@@ -272,2 +264,4 @@ * Run a copy from the local to the remote using rsync.

*/
copyToRemote(src, dest, options) {

@@ -281,7 +275,8 @@ var _this3 = this;

};
const copyOptions = _extends({}, defaultOptions, options);
return _this3.pool.copyToRemote(src, dest, copyOptions);
})();
}
/**

@@ -300,2 +295,4 @@ * Run a copy from the remote to the local using rsync.

*/
copyFromRemote(src, dest, options) {

@@ -309,7 +306,8 @@ var _this4 = this;

};
const copyOptions = _extends({}, defaultOptions, options);
return _this4.pool.copyFromRemote(src, dest, copyOptions);
})();
}
/**

@@ -320,6 +318,7 @@ * Log.

*/
log(...args) {
this.options.log(...args);
}
/**

@@ -330,2 +329,4 @@ * Create a new blocking task.

*/
blTask(name, ...rest) {

@@ -337,3 +338,2 @@ this.task(name, ...rest);

}
/**

@@ -343,2 +343,4 @@ * Test if we are ready to run a task.

*/
_readyToRunTask(...args) {

@@ -349,7 +351,8 @@ if (Object.keys(this.tasks).some(key => {

})) return false;
return super._readyToRunTask(...args); // eslint-disable-line no-underscore-dangle
}
}
exports.default = Shipit;
var _default = Shipit;
exports.default = _default;
{
"name": "shipit-cli",
"version": "4.1.1",
"version": "4.1.2",
"description": "Universal automation and deployment tool written in JavaScript.",
"engines": {
"node": ">=6"
},
"author": "Greg Bergé <berge.greg@gmail.com>",
"license": "MIT",
"repository": "https://github.com/shipitjs/shipit/tree/master/packages/shipit-deploy",
"main": "lib/index.js",

@@ -13,2 +19,10 @@ "keywords": [

],
"scripts": {
"prebuild": "rm -rf lib/",
"build": "babel --config-file ../../babel.config.js -d lib --ignore \"**/*.test.js\" src",
"prepublishOnly": "yarn run build"
},
"bin": {
"shipit": "./bin/shipit"
},
"dependencies": {

@@ -21,23 +35,7 @@ "chalk": "^2.4.1",

"pretty-hrtime": "^1.0.0",
"ssh-pool": "^4.1.0",
"ssh-pool": "^4.1.2",
"stream-line-wrapper": "^0.1.1",
"v8flags": "^3.1.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"mock-utf8-stream": "^0.1.1"
},
"bin": {
"shipit": "./bin/shipit"
},
"repository": {
"type": "git",
"url": "https://github.com/shipitjs/shipit.git"
},
"author": "Greg Bergé <berge.greg@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/shipitjs/shipit/issues"
},
"homepage": "https://github.com/shipitjs/shipit"
"gitHead": "702242731bd631a3e3237996c92828931dc6302c"
}
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