Comparing version 4.1.0 to 4.1.2
@@ -6,2 +6,14 @@ # 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) | ||
### Bug Fixes | ||
* **security:** use which instead of whereis ([#220](https://github.com/shipitjs/shipit/tree/master/packages/shipit-deploy/issues/220)) ([6f46cad](https://github.com/shipitjs/shipit/tree/master/packages/shipit-deploy/commit/6f46cad)) | ||
* use correct deprecation warning ([#219](https://github.com/shipitjs/shipit/tree/master/packages/shipit-deploy/issues/219)) ([e0c0fa5](https://github.com/shipitjs/shipit/tree/master/packages/shipit-deploy/commit/e0c0fa5)) | ||
<a name="4.1.0"></a> | ||
@@ -8,0 +20,0 @@ # [4.1.0](https://github.com/babel/babel/tree/master/packages/babel-traverse/compare/v4.0.2...v4.1.0) (2018-04-27) |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,8 +6,12 @@ exports.__esModule = true; | ||
var _util = require('./util'); | ||
var _util = require("./util"); | ||
function formatCdCommand({ folder }) { | ||
(0, _util.requireArgs)(['folder'], { folder }, 'cd'); | ||
function formatCdCommand({ | ||
folder | ||
}) { | ||
(0, _util.requireArgs)(['folder'], { | ||
folder | ||
}, 'cd'); | ||
const args = ['cd', folder]; | ||
return (0, _util.joinCommandArgs)(args); | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,8 +6,12 @@ exports.__esModule = true; | ||
var _util = require('./util'); | ||
var _util = require("./util"); | ||
function formatMkdirCommand({ folder }) { | ||
(0, _util.requireArgs)(['folder'], { folder }, 'mkdir'); | ||
function formatMkdirCommand({ | ||
folder | ||
}) { | ||
(0, _util.requireArgs)(['folder'], { | ||
folder | ||
}, 'mkdir'); | ||
const args = ['mkdir', '-p', folder]; | ||
return (0, _util.joinCommandArgs)(args); | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,12 +6,15 @@ exports.__esModule = true; | ||
var _util = require('./util'); | ||
var _util = require("./util"); | ||
var _util2 = require('../util'); | ||
var _util2 = require("../util"); | ||
const SUDO_REGEXP = /sudo\s/; | ||
function formatRawCommand({ asUser, command }) { | ||
function formatRawCommand({ | ||
asUser, | ||
command | ||
}) { | ||
let args = []; | ||
if (asUser) args = [...args, 'sudo', '-u', asUser]; | ||
// Deprecate | ||
if (asUser) args = [...args, 'sudo', '-u', asUser]; // Deprecate | ||
if (asUser && command) { | ||
@@ -21,5 +24,7 @@ if (command.match(SUDO_REGEXP)) { | ||
} | ||
args = [...args, command.replace(SUDO_REGEXP, '')]; | ||
} else if (command) args = [...args, command]; | ||
return (0, _util.joinCommandArgs)(args); | ||
} |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,8 +6,12 @@ exports.__esModule = true; | ||
var _util = require('./util'); | ||
var _util = require("./util"); | ||
function formatRmCommand({ file }) { | ||
(0, _util.requireArgs)(['file'], { file }, 'rm'); | ||
function formatRmCommand({ | ||
file | ||
}) { | ||
(0, _util.requireArgs)(['file'], { | ||
file | ||
}, 'rm'); | ||
const args = ['rm', file]; | ||
return (0, _util.joinCommandArgs)(args); | ||
} |
@@ -1,32 +0,28 @@ | ||
'use strict'; | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.isRsyncSupported = undefined; | ||
exports.isRsyncSupported = isRsyncSupported; | ||
exports.formatRsyncCommand = formatRsyncCommand; | ||
let isRsyncSupported = exports.isRsyncSupported = (() => { | ||
var _ref = _asyncToGenerator(function* () { | ||
return new Promise(function (resolve) { | ||
return (0, _whereis2.default)('rsync', function (err) { | ||
return resolve(!err); | ||
}); | ||
}); | ||
}); | ||
var _which = _interopRequireDefault(require("which")); | ||
return function isRsyncSupported() { | ||
return _ref.apply(this, arguments); | ||
}; | ||
})(); | ||
var _util = require("./util"); | ||
exports.formatRsyncCommand = formatRsyncCommand; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _whereis = require('whereis'); | ||
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 _whereis2 = _interopRequireDefault(_whereis); | ||
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 _util = require('./util'); | ||
function isRsyncSupported() { | ||
return _isRsyncSupported.apply(this, arguments); | ||
} | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _isRsyncSupported() { | ||
_isRsyncSupported = _asyncToGenerator(function* () { | ||
return new Promise(resolve => (0, _which.default)('rsync', err => resolve(!err))); | ||
}); | ||
return _isRsyncSupported.apply(this, arguments); | ||
} | ||
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 formatExcludes(excludes) { | ||
@@ -43,3 +39,6 @@ return excludes.reduce((args, current) => [...args, '--exclude', `"${current}"`], []); | ||
}) { | ||
(0, _util.requireArgs)(['src', 'dest'], { src, dest }, 'rsync'); | ||
(0, _util.requireArgs)(['src', 'dest'], { | ||
src, | ||
dest | ||
}, 'rsync'); | ||
let args = ['rsync', '--archive', '--compress']; | ||
@@ -46,0 +45,0 @@ if (additionalArgs) args = [...args, ...additionalArgs]; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,6 +6,14 @@ exports.__esModule = true; | ||
var _util = require('./util'); | ||
var _util = require("./util"); | ||
function formatScpCommand({ port, key, src, dest }) { | ||
(0, _util.requireArgs)(['src', 'dest'], { src, dest }, 'scp'); | ||
function formatScpCommand({ | ||
port, | ||
key, | ||
src, | ||
dest | ||
}) { | ||
(0, _util.requireArgs)(['src', 'dest'], { | ||
src, | ||
dest | ||
}, 'scp'); | ||
let args = ['scp']; | ||
@@ -12,0 +20,0 @@ if (port) args = [...args, '-P', port]; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,3 +6,3 @@ exports.__esModule = true; | ||
var _util = require('./util'); | ||
var _util = require("./util"); | ||
@@ -24,2 +24,3 @@ function wrapCwd(cwd, command) { | ||
let args = ['ssh']; | ||
if (verbosityLevel) { | ||
@@ -29,10 +30,17 @@ switch (verbosityLevel) { | ||
break; | ||
case 1: | ||
args = [...args, '-v'];break; | ||
args = [...args, '-v']; | ||
break; | ||
case 2: | ||
args = [...args, '-vv'];break; | ||
args = [...args, '-vv']; | ||
break; | ||
default: | ||
args = [...args, '-vvv'];break; | ||
args = [...args, '-vvv']; | ||
break; | ||
} | ||
} | ||
if (tty) args = [...args, '-tt']; | ||
@@ -43,3 +51,2 @@ if (port) args = [...args, '-p', port]; | ||
if (remote) args = [...args, remote]; | ||
const cwdCommand = cwd ? wrapCwd(cwd, command) : command; | ||
@@ -46,0 +53,0 @@ if (command) args = [...args, (0, _util.wrapCommand)(cwdCommand)]; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -6,3 +6,3 @@ exports.__esModule = true; | ||
var _util = require('./util'); | ||
var _util = require("./util"); | ||
@@ -13,8 +13,17 @@ function formatExcludes(excludes) { | ||
function formatTarCommand({ file, archive, excludes, mode }) { | ||
function formatTarCommand({ | ||
file, | ||
archive, | ||
excludes, | ||
mode | ||
}) { | ||
let args = ['tar']; | ||
switch (mode) { | ||
case 'compress': | ||
{ | ||
(0, _util.requireArgs)(['file', 'archive'], { file, archive }, 'tar'); | ||
(0, _util.requireArgs)(['file', 'archive'], { | ||
file, | ||
archive | ||
}, 'tar'); | ||
if (excludes) args = [...args, ...formatExcludes(excludes)]; | ||
@@ -24,5 +33,9 @@ args = [...args, '-czf', archive, file]; | ||
} | ||
case 'extract': | ||
{ | ||
(0, _util.requireArgs)(['archive'], { file, archive }, 'tar'); | ||
(0, _util.requireArgs)(['archive'], { | ||
file, | ||
archive | ||
}, 'tar'); | ||
args = [...args, '--strip-components=1']; | ||
@@ -32,2 +45,3 @@ args = [...args, '-xzf', archive]; | ||
} | ||
default: | ||
@@ -34,0 +48,0 @@ throw new Error(`mode "${mode}" is not valid in "tar" command (valid values: ["extract", "compress"])`); |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -8,2 +8,3 @@ exports.__esModule = true; | ||
exports.requireArgs = requireArgs; | ||
function escapeCommand(command) { | ||
@@ -10,0 +11,0 @@ return command.replace(/"/g, '\\"').replace(/\$/g, '\\$'); |
@@ -1,52 +0,51 @@ | ||
'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; }; | ||
var _path = _interopRequireDefault(require("path")); | ||
var _path = require('path'); | ||
var _streamLineWrapper = _interopRequireDefault(require("stream-line-wrapper")); | ||
var _path2 = _interopRequireDefault(_path); | ||
var _tmp = require("tmp"); | ||
var _streamLineWrapper = require('stream-line-wrapper'); | ||
var _rsync = require("./commands/rsync"); | ||
var _streamLineWrapper2 = _interopRequireDefault(_streamLineWrapper); | ||
var _ssh = require("./commands/ssh"); | ||
var _tmp = require('tmp'); | ||
var _tar = require("./commands/tar"); | ||
var _rsync = require('./commands/rsync'); | ||
var _cd = require("./commands/cd"); | ||
var _ssh = require('./commands/ssh'); | ||
var _mkdir = require("./commands/mkdir"); | ||
var _tar = require('./commands/tar'); | ||
var _scp = require("./commands/scp"); | ||
var _cd = require('./commands/cd'); | ||
var _raw = require("./commands/raw"); | ||
var _mkdir = require('./commands/mkdir'); | ||
var _rm = require("./commands/rm"); | ||
var _scp = require('./commands/scp'); | ||
var _util = require("./commands/util"); | ||
var _raw = require('./commands/raw'); | ||
var _remote = require("./remote"); | ||
var _rm = require('./commands/rm'); | ||
var _util2 = require("./util"); | ||
var _util = require('./commands/util'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _remote = require('./remote'); | ||
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 _util2 = require('./util'); | ||
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; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
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 _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; } | ||
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); }); }; } | ||
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"); }); }; } | ||
const tmpName = (() => { | ||
const tmpName = | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref = _asyncToGenerator(function* (options) { | ||
return new Promise(function (resolve, reject) { | ||
return (0, _tmp.tmpName)(options, function (err, name) { | ||
if (err) reject(err);else resolve(name); | ||
}); | ||
}); | ||
return new Promise((resolve, reject) => (0, _tmp.tmpName)(options, (err, name) => { | ||
if (err) reject(err);else resolve(name); | ||
})); | ||
}); | ||
@@ -57,4 +56,3 @@ | ||
}; | ||
})(); | ||
}(); | ||
/** | ||
@@ -87,2 +85,4 @@ * An ExecResult returned when a command is executed with success. | ||
*/ | ||
class Connection { | ||
@@ -106,3 +106,2 @@ /** | ||
} | ||
/** | ||
@@ -119,11 +118,14 @@ * Run a command remotely using SSH. | ||
*/ | ||
run(command, _ref2 = {}) { | ||
var _this = this; | ||
let ttyOption = _ref2.tty, | ||
cwd = _ref2.cwd, | ||
cmdOptions = _objectWithoutPropertiesLoose(_ref2, ["tty", "cwd"]); | ||
return _asyncToGenerator(function* () { | ||
let ttyOption = _ref2.tty, | ||
cwd = _ref2.cwd, | ||
cmdOptions = _objectWithoutProperties(_ref2, ['tty', 'cwd']); | ||
let tty = ttyOption; | ||
let tty = ttyOption; | ||
if (command.startsWith('sudo') && typeof ttyOption === 'undefined') { | ||
@@ -133,8 +135,13 @@ (0, _util2.deprecateV3)('You should set "tty" option explictly when you use "sudo".'); | ||
} | ||
_this.log('Running "%s" on host "%s".', command, _this.remote.host); | ||
const cmd = _this.buildSSHCommand(command, { tty, cwd }); | ||
const cmd = _this.buildSSHCommand(command, { | ||
tty, | ||
cwd | ||
}); | ||
return _this.runLocally(cmd, cmdOptions); | ||
})(); | ||
} | ||
/** | ||
@@ -155,16 +162,16 @@ * Run a copy command using either rsync or scp. | ||
*/ | ||
copy(src, dest, _ref3 = {}) { | ||
var _this2 = this; | ||
let direction = _ref3.direction, | ||
options = _objectWithoutPropertiesLoose(_ref3, ["direction"]); | ||
return _asyncToGenerator(function* () { | ||
let direction = _ref3.direction, | ||
options = _objectWithoutProperties(_ref3, ['direction']); | ||
(0, _util2.deprecateV3)('"copy" method is deprecated, please use "copyToRemote", "copyFromRemote", "scpCopyToRemote" or "scpCopyFromRemote".'); | ||
(0, _util2.deprecateV5)('"copy" method is deprecated, please use "copyToRemote", "copyFromRemote", "scpCopyToRemote" or "scpCopyFromRemote".'); | ||
if (direction === 'remoteToLocal') return _this2.autoCopyFromRemote(src, dest, options); | ||
return _this2.autoCopyToRemote(src, dest, options); | ||
})(); | ||
} | ||
/** | ||
@@ -183,2 +190,4 @@ * Run a copy from the local to the remote using rsync. | ||
*/ | ||
copyToRemote(src, dest, options) { | ||
@@ -192,3 +201,2 @@ var _this3 = this; | ||
} | ||
/** | ||
@@ -207,2 +215,4 @@ * Run a copy from the remote to the local using rsync. | ||
*/ | ||
copyFromRemote(src, dest, options) { | ||
@@ -216,3 +226,2 @@ var _this4 = this; | ||
} | ||
/** | ||
@@ -231,23 +240,32 @@ * Run a copy from the local to the remote using scp. | ||
*/ | ||
scpCopyToRemote(src, dest, _ref4 = {}) { | ||
var _this5 = this; | ||
let ignores = _ref4.ignores, | ||
cmdOptions = _objectWithoutPropertiesLoose(_ref4, ["ignores"]); | ||
return _asyncToGenerator(function* () { | ||
let ignores = _ref4.ignores, | ||
cmdOptions = _objectWithoutProperties(_ref4, ['ignores']); | ||
const archive = _path.default.basename((yield tmpName({ | ||
postfix: '.tar.gz' | ||
}))); | ||
const archive = _path2.default.basename((yield tmpName({ postfix: '.tar.gz' }))); | ||
const srcDir = _path2.default.dirname(src); | ||
const srcDir = _path.default.dirname(src); | ||
const remoteDest = `${(0, _remote.formatRemote)(_this5.remote)}:${dest}`; | ||
const compress = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ folder: srcDir }), '&&', (0, _tar.formatTarCommand)({ | ||
const compress = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ | ||
folder: srcDir | ||
}), '&&', (0, _tar.formatTarCommand)({ | ||
mode: 'compress', | ||
file: _path2.default.basename(src), | ||
file: _path.default.basename(src), | ||
archive, | ||
excludes: ignores | ||
})]); | ||
const createDestFolder = (0, _mkdir.formatMkdirCommand)({ folder: dest }); | ||
const copy = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ folder: srcDir }), '&&', (0, _scp.formatScpCommand)({ | ||
const createDestFolder = (0, _mkdir.formatMkdirCommand)({ | ||
folder: dest | ||
}); | ||
const copy = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ | ||
folder: srcDir | ||
}), '&&', (0, _scp.formatScpCommand)({ | ||
port: _this5.remote.port, | ||
@@ -258,25 +276,21 @@ key: _this5.options.key, | ||
})]); | ||
const cleanSrc = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ folder: srcDir }), '&&', (0, _rm.formatRmCommand)({ file: archive })]); | ||
const extract = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ folder: dest }), '&&', (0, _tar.formatTarCommand)({ mode: 'extract', archive })]); | ||
const cleanDest = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ folder: dest }), '&&', (0, _rm.formatRmCommand)({ file: archive })]); | ||
return _this5.aggregate([function () { | ||
return _this5.runLocally(compress, cmdOptions); | ||
}, function () { | ||
return _this5.run(createDestFolder, cmdOptions); | ||
}, function () { | ||
return _this5.runLocally(copy, cmdOptions); | ||
}, function () { | ||
return _this5.runLocally(cleanSrc, cmdOptions); | ||
}, function () { | ||
return _this5.run(extract, cmdOptions); | ||
}, function () { | ||
return _this5.run(cleanDest, cmdOptions); | ||
}]); | ||
const cleanSrc = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ | ||
folder: srcDir | ||
}), '&&', (0, _rm.formatRmCommand)({ | ||
file: archive | ||
})]); | ||
const extract = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ | ||
folder: dest | ||
}), '&&', (0, _tar.formatTarCommand)({ | ||
mode: 'extract', | ||
archive | ||
})]); | ||
const cleanDest = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ | ||
folder: dest | ||
}), '&&', (0, _rm.formatRmCommand)({ | ||
file: archive | ||
})]); | ||
return _this5.aggregate([() => _this5.runLocally(compress, cmdOptions), () => _this5.run(createDestFolder, cmdOptions), () => _this5.runLocally(copy, cmdOptions), () => _this5.runLocally(cleanSrc, cmdOptions), () => _this5.run(extract, cmdOptions), () => _this5.run(cleanDest, cmdOptions)]); | ||
})(); | ||
} | ||
/** | ||
@@ -295,23 +309,31 @@ * Run a copy from the remote to the local using scp. | ||
*/ | ||
scpCopyFromRemote(src, dest, _ref5 = {}) { | ||
var _this6 = this; | ||
let ignores = _ref5.ignores, | ||
cmdOptions = _objectWithoutPropertiesLoose(_ref5, ["ignores"]); | ||
return _asyncToGenerator(function* () { | ||
let ignores = _ref5.ignores, | ||
cmdOptions = _objectWithoutProperties(_ref5, ['ignores']); | ||
const archive = _path.default.basename((yield tmpName({ | ||
postfix: '.tar.gz' | ||
}))); | ||
const archive = _path2.default.basename((yield tmpName({ postfix: '.tar.gz' }))); | ||
const srcDir = _path2.default.dirname(src); | ||
const srcArchive = _path2.default.join(srcDir, archive); | ||
const srcDir = _path.default.dirname(src); | ||
const srcArchive = _path.default.join(srcDir, archive); | ||
const remoteSrcArchive = `${(0, _remote.formatRemote)(_this6.remote)}:${srcArchive}`; | ||
const compress = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ folder: srcDir }), '&&', (0, _tar.formatTarCommand)({ | ||
const compress = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ | ||
folder: srcDir | ||
}), '&&', (0, _tar.formatTarCommand)({ | ||
mode: 'compress', | ||
file: _path2.default.basename(src), | ||
file: _path.default.basename(src), | ||
archive, | ||
excludes: ignores | ||
})]); | ||
const createDestFolder = (0, _mkdir.formatMkdirCommand)({ folder: dest }); | ||
const createDestFolder = (0, _mkdir.formatMkdirCommand)({ | ||
folder: dest | ||
}); | ||
const copy = (0, _scp.formatScpCommand)({ | ||
@@ -323,25 +345,21 @@ port: _this6.remote.port, | ||
}); | ||
const cleanSrc = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ folder: srcDir }), '&&', (0, _rm.formatRmCommand)({ file: archive })]); | ||
const extract = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ folder: dest }), '&&', (0, _tar.formatTarCommand)({ mode: 'extract', archive })]); | ||
const cleanDest = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ folder: dest }), '&&', (0, _rm.formatRmCommand)({ file: archive })]); | ||
return _this6.aggregate([function () { | ||
return _this6.run(compress, cmdOptions); | ||
}, function () { | ||
return _this6.runLocally(createDestFolder, cmdOptions); | ||
}, function () { | ||
return _this6.runLocally(copy, cmdOptions); | ||
}, function () { | ||
return _this6.run(cleanSrc, cmdOptions); | ||
}, function () { | ||
return _this6.runLocally(extract, cmdOptions); | ||
}, function () { | ||
return _this6.runLocally(cleanDest, cmdOptions); | ||
}]); | ||
const cleanSrc = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ | ||
folder: srcDir | ||
}), '&&', (0, _rm.formatRmCommand)({ | ||
file: archive | ||
})]); | ||
const extract = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ | ||
folder: dest | ||
}), '&&', (0, _tar.formatTarCommand)({ | ||
mode: 'extract', | ||
archive | ||
})]); | ||
const cleanDest = (0, _util.joinCommandArgs)([(0, _cd.formatCdCommand)({ | ||
folder: dest | ||
}), '&&', (0, _rm.formatRmCommand)({ | ||
file: archive | ||
})]); | ||
return _this6.aggregate([() => _this6.run(compress, cmdOptions), () => _this6.runLocally(createDestFolder, cmdOptions), () => _this6.runLocally(copy, cmdOptions), () => _this6.run(cleanSrc, cmdOptions), () => _this6.runLocally(extract, cmdOptions), () => _this6.runLocally(cleanDest, cmdOptions)]); | ||
})(); | ||
} | ||
/** | ||
@@ -355,2 +373,4 @@ * Build an SSH command. | ||
*/ | ||
buildSSHCommand(command, options) { | ||
@@ -364,6 +384,8 @@ return (0, _ssh.formatSshCommand)(_extends({ | ||
remote: (0, _remote.formatRemote)(this.remote), | ||
command: (0, _raw.formatRawCommand)({ command, asUser: this.options.asUser }) | ||
command: (0, _raw.formatRawCommand)({ | ||
command, | ||
asUser: this.options.asUser | ||
}) | ||
}, options)); | ||
} | ||
/** | ||
@@ -382,10 +404,12 @@ * Abstract method to copy using rsync. | ||
*/ | ||
rsyncCopy(src, dest, _ref6 = {}) { | ||
var _this7 = this; | ||
let rsync = _ref6.rsync, | ||
ignores = _ref6.ignores, | ||
cmdOptions = _objectWithoutPropertiesLoose(_ref6, ["rsync", "ignores"]); | ||
return _asyncToGenerator(function* () { | ||
let rsync = _ref6.rsync, | ||
ignores = _ref6.ignores, | ||
cmdOptions = _objectWithoutProperties(_ref6, ['rsync', 'ignores']); | ||
_this7.log('Copy "%s" to "%s" via rsync', src, dest); | ||
@@ -399,3 +423,2 @@ | ||
}); | ||
const cmd = (0, _rsync.formatRsyncCommand)({ | ||
@@ -408,7 +431,5 @@ src, | ||
}); | ||
return _this7.runLocally(cmd, cmdOptions); | ||
})(); | ||
} | ||
/** | ||
@@ -425,2 +446,4 @@ * Automatic copy to remote method. | ||
*/ | ||
autoCopyToRemote(src, dest, options) { | ||
@@ -435,3 +458,2 @@ var _this8 = this; | ||
} | ||
/** | ||
@@ -448,2 +470,4 @@ * Automatic copy from remote method. | ||
*/ | ||
autoCopyFromRemote(src, dest, options) { | ||
@@ -458,3 +482,2 @@ var _this9 = this; | ||
} | ||
/** | ||
@@ -468,13 +491,12 @@ * Aggregate some exec tasks. | ||
*/ | ||
aggregate(tasks) { | ||
return _asyncToGenerator(function* () { | ||
const results = yield (0, _util2.series)(tasks); | ||
return results.reduce(function (aggregate, result) { | ||
return { | ||
stdout: String(aggregate.stdout) + String(result.stdout), | ||
stderr: String(aggregate.stderr) + String(result.stderr), | ||
children: [...aggregate.children, result.child] | ||
}; | ||
}, { | ||
return results.reduce((aggregate, result) => ({ | ||
stdout: String(aggregate.stdout) + String(result.stdout), | ||
stderr: String(aggregate.stderr) + String(result.stderr), | ||
children: [...aggregate.children, result.child] | ||
}), { | ||
stdout: '', | ||
@@ -486,3 +508,2 @@ stderr: '', | ||
} | ||
/** | ||
@@ -494,6 +515,7 @@ * Log using logger. | ||
*/ | ||
log(...args) { | ||
if (this.options.log) this.options.log(...args); | ||
} | ||
/** | ||
@@ -511,22 +533,28 @@ * Method used to run a command locally. | ||
*/ | ||
runLocally(cmd, _ref7 = {}) { | ||
var _this10 = this; | ||
let stdout = _ref7.stdout, | ||
stderr = _ref7.stderr, | ||
cmdOptions = _objectWithoutPropertiesLoose(_ref7, ["stdout", "stderr"]); | ||
return _asyncToGenerator(function* () { | ||
let stdout = _ref7.stdout, | ||
stderr = _ref7.stderr, | ||
cmdOptions = _objectWithoutProperties(_ref7, ['stdout', 'stderr']); | ||
const stdoutPipe = stdout || _this10.options.stdout; | ||
const stderrPipe = stderr || _this10.options.stderr; | ||
return (0, _util2.exec)(cmd, cmdOptions, function (child) { | ||
if (stdoutPipe) child.stdout.pipe(new _streamLineWrapper2.default({ prefix: `@${_this10.remote.host} ` })).pipe(stdoutPipe); | ||
if (stderrPipe) child.stderr.pipe(new _streamLineWrapper2.default({ prefix: `@${_this10.remote.host}-err ` })).pipe(stderrPipe); | ||
return (0, _util2.exec)(cmd, cmdOptions, child => { | ||
if (stdoutPipe) child.stdout.pipe(new _streamLineWrapper.default({ | ||
prefix: `@${_this10.remote.host} ` | ||
})).pipe(stdoutPipe); | ||
if (stderrPipe) child.stderr.pipe(new _streamLineWrapper.default({ | ||
prefix: `@${_this10.remote.host}-err ` | ||
})).pipe(stderrPipe); | ||
}); | ||
})(); | ||
} | ||
} | ||
exports.default = Connection; | ||
var _default = Connection; | ||
exports.default = _default; |
@@ -1,14 +0,12 @@ | ||
'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 func-names */ | ||
var _Connection = _interopRequireDefault(require("./Connection")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _Connection = require('./Connection'); | ||
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 _Connection2 = _interopRequireDefault(_Connection); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class ConnectionPool { | ||
@@ -24,9 +22,13 @@ /** | ||
this.connections = connections.map(connection => { | ||
if (connection instanceof _Connection2.default) return connection; | ||
return new _Connection2.default(_extends({ remote: connection }, options)); | ||
if (connection instanceof _Connection.default) return connection; | ||
return new _Connection.default(_extends({ | ||
remote: connection | ||
}, options)); | ||
}); | ||
} | ||
} | ||
;['run', 'copy', 'copyToRemote', 'copyFromRemote', 'scpCopyToRemote', 'scpCopyFromRemote'].forEach(method => { | ||
; | ||
['run', 'copy', 'copyToRemote', 'copyFromRemote', 'scpCopyToRemote', 'scpCopyFromRemote'].forEach(method => { | ||
ConnectionPool.prototype[method] = function (...args) { | ||
@@ -36,3 +38,3 @@ return Promise.all(this.connections.map(connection => connection[method](...args))); | ||
}); | ||
exports.default = ConnectionPool; | ||
var _default = ConnectionPool; | ||
exports.default = _default; |
@@ -1,20 +0,16 @@ | ||
'use strict'; | ||
"use strict"; | ||
var _Connection = require('./Connection'); | ||
var _Connection = _interopRequireDefault(require("./Connection")); | ||
var _Connection2 = _interopRequireDefault(_Connection); | ||
var _ConnectionPool = _interopRequireDefault(require("./ConnectionPool")); | ||
var _ConnectionPool = require('./ConnectionPool'); | ||
var _util = require("./util"); | ||
var _ConnectionPool2 = _interopRequireDefault(_ConnectionPool); | ||
var _rsync = require("./commands/rsync"); | ||
var _util = require('./util'); | ||
var _rsync = require('./commands/rsync'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.Connection = _Connection2.default; | ||
exports.ConnectionPool = _ConnectionPool2.default; | ||
exports.Connection = _Connection.default; | ||
exports.ConnectionPool = _ConnectionPool.default; | ||
exports.exec = _util.exec; | ||
exports.isRsyncSupported = _rsync.isRsyncSupported; |
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -7,3 +7,3 @@ exports.__esModule = true; | ||
var _util = require('./util'); | ||
var _util = require("./util"); | ||
@@ -14,3 +14,2 @@ function parseRemote(remote) { | ||
if (remote === '') throw new Error('A remote cannot be an empty string'); | ||
const matches = remote.match(/(([^@:]+)@)?([^@:]+)(:(.+))?/); | ||
@@ -22,5 +21,8 @@ | ||
port = matches[5]; | ||
const options = { | ||
user, | ||
host | ||
}; | ||
if (port) options.port = Number(port); | ||
const options = { user, host }; | ||
if (port) options.port = Number(port); | ||
if (!user) { | ||
@@ -30,10 +32,17 @@ (0, _util.deprecateV3)('Default user "deploy" is deprecated, please specify it explictly.'); | ||
} | ||
return options; | ||
} | ||
return { user: 'deploy', host: remote }; | ||
return { | ||
user: 'deploy', | ||
host: remote | ||
}; | ||
} | ||
function formatRemote({ user, host }) { | ||
function formatRemote({ | ||
user, | ||
host | ||
}) { | ||
return `${user}@${host}`; | ||
} |
@@ -1,20 +0,25 @@ | ||
'use strict'; | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports.exec = exports.series = undefined; | ||
exports.deprecateV3 = deprecateV3; | ||
exports.deprecateV5 = deprecateV5; | ||
exports.exec = exports.series = 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; }; | ||
var _child_process = require("child_process"); | ||
exports.deprecateV3 = deprecateV3; | ||
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 _child_process = require('child_process'); | ||
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 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 _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); }); }; } | ||
/* eslint-disable no-console */ | ||
const series = exports.series = (() => { | ||
const series = | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref = _asyncToGenerator(function* (tasks) { | ||
return new Promise(function (resolve, reject) { | ||
return new Promise((resolve, reject) => { | ||
const tasksCopy = [...tasks]; | ||
const next = function next(results) { | ||
const next = results => { | ||
if (tasksCopy.length === 0) { | ||
@@ -24,7 +29,7 @@ resolve(results); | ||
} | ||
const task = tasksCopy.shift(); | ||
task().then(function (result) { | ||
return next([...results, result]); | ||
}).catch(reject); | ||
task().then(result => next([...results, result])).catch(reject); | ||
}; | ||
next([]); | ||
@@ -37,10 +42,15 @@ }); | ||
}; | ||
})(); | ||
}(); | ||
const DEFAULT_CMD_OPTIONS = { maxBuffer: 1000 * 1024 }; | ||
exports.series = series; | ||
const DEFAULT_CMD_OPTIONS = { | ||
maxBuffer: 1000 * 1024 | ||
}; | ||
const exec = exports.exec = (() => { | ||
const exec = | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref2 = _asyncToGenerator(function* (cmd, options, childModifier) { | ||
return new Promise(function (resolve, reject) { | ||
const child = (0, _child_process.exec)(cmd, _extends({}, DEFAULT_CMD_OPTIONS, options), function (error, stdout, stderr) { | ||
return new Promise((resolve, reject) => { | ||
const child = (0, _child_process.exec)(cmd, _extends({}, DEFAULT_CMD_OPTIONS, options), (error, stdout, stderr) => { | ||
if (error) { | ||
@@ -52,8 +62,12 @@ /* eslint-disable no-param-reassign */ | ||
/* eslint-enable no-param-reassign */ | ||
reject(error); | ||
} else { | ||
resolve({ child, stdout, stderr }); | ||
resolve({ | ||
child, | ||
stdout, | ||
stderr | ||
}); | ||
} | ||
}); | ||
if (childModifier) childModifier(child); | ||
@@ -66,6 +80,12 @@ }); | ||
}; | ||
})(); | ||
}(); | ||
exports.exec = exec; | ||
function deprecateV3(...args) { | ||
console.warn(...args, 'It will break in v3.0.0.'); | ||
} | ||
function deprecateV5(...args) { | ||
console.warn(...args, 'It will break in v5.0.0.'); | ||
} |
{ | ||
"name": "ssh-pool", | ||
"version": "4.1.0", | ||
"version": "4.1.2", | ||
"description": "Run remote commands over a pool of server using SSH.", | ||
"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", | ||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-traverse", | ||
"author": "Bergé Greg <berge.greg@gmail.com>", | ||
"license": "MIT", | ||
"homepage": "https://github.com/shipitjs/shipit", | ||
"keywords": [ | ||
"shipit", | ||
"automation", | ||
"deployment", | ||
"ssh" | ||
], | ||
"scripts": { | ||
"prebuild": "rm -rf lib/", | ||
"build": "babel --config-file ../../babel.config.js -d lib --ignore \"**/*.test.js\" src", | ||
"prepublishOnly": "yarn run build" | ||
}, | ||
"dependencies": { | ||
"stream-line-wrapper": "^0.1.1", | ||
"tmp": "^0.0.33", | ||
"whereis": "^0.4.0" | ||
} | ||
"which": "^1.3.1" | ||
}, | ||
"gitHead": "702242731bd631a3e3237996c92828931dc6302c" | ||
} |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
39714
815
1
+ Addedwhich@^1.3.1
+ Addedisexe@2.0.0(transitive)
+ Addedwhich@1.3.1(transitive)
- Removedwhereis@^0.4.0
- Removedwhereis@0.4.1(transitive)