boom-deploy
Advanced tools
Comparing version 0.2.71 to 0.2.72
@@ -224,2 +224,14 @@ | ||
}); | ||
}); | ||
new Task('test111', function(import_env){ | ||
local('ping viboom.com -c 1'); | ||
ssh('ls -lah'); | ||
sleep(1000); | ||
lazySsh('pwd'); | ||
js('function(){local("ping viboom.com -c 2")}'); | ||
console.log(checkTravisBuild('0f86b077c383e301f12e19d8ad96d41c8a6330d8')); | ||
symlink('.ssh', 'ssh.link'); | ||
console.log('THE END'); | ||
}); | ||
@@ -172,13 +172,14 @@ | ||
var output = ssh('if [ -d {{sharedPath}}/cached-copy ];', | ||
'then cd {{sharedPath}}/cached-copy &&', | ||
'git fetch -q origin &&', | ||
'git fetch --tags -q origin &&', | ||
'git reset -q --hard {{head}} &&', | ||
'git clean -q -d -f &&', | ||
'git submodule update --init', | ||
' then cd {{sharedPath}}/cached-copy &&', | ||
' git remote set-url origin {{cloneUrl}}', | ||
' git fetch -q origin &&', | ||
' git fetch --tags -q origin &&', | ||
' git reset -q --hard {{head}} &&', | ||
' git clean -q -d -f &&', | ||
' git submodule update --init', | ||
'else', | ||
'git clone -q {{cloneUrl}} {{sharedPath}}/cached-copy &&', | ||
'cd {{sharedPath}}/cached-copy &&', | ||
'git checkout -q -b deploy {{head}} &&', | ||
'git submodule update --init', | ||
' git clone -q {{cloneUrl}} {{sharedPath}}/cached-copy &&', | ||
' cd {{sharedPath}}/cached-copy &&', | ||
' git checkout -q -b deploy {{head}} &&', | ||
' git submodule update --init', | ||
'fi'); | ||
@@ -271,10 +272,2 @@ | ||
new Helper(function lazySsh(){ | ||
if (isLocal(get('env'))) { | ||
return local.apply(null, arguments); | ||
} else { | ||
return ssh.apply(null, arguments); | ||
} | ||
}); | ||
new Helper(function denyProduction(env){ | ||
@@ -725,3 +718,3 @@ if (isProduction(env)) { | ||
makeDumpDir(); | ||
rsyncFrom(export_env, '{{cassandraDumpDir}}/' + dumpName + '.tar.gz', '{{cassandraDumpDir}}'); | ||
rsyncDown(export_env, '{{cassandraDumpDir}}/' + dumpName + '.tar.gz', '{{cassandraDumpDir}}'); | ||
lazySsh('tar -xvzf {{cassandraDumpDir}}/' + dumpName + '.tar.gz -C {{cassandraDumpDir}}/' + dumpName); | ||
@@ -739,8 +732,2 @@ lazySsh('tail {{cassandraDumpDir}}/' + dumpName + '/*'); | ||
new Helper(function rsyncFrom(env, from, to){ | ||
var config = getConfig(env); | ||
lazySsh('rsync -av --progress -e \'ssh -p ' + config.port +'\' ' + config.user + '@' + config.server + ':' + from + ' ' + to); | ||
}); | ||
new Helper(function staticCopy(import_env, dir){ | ||
@@ -747,0 +734,0 @@ |
@@ -15,3 +15,3 @@ var _ = require('lodash'); | ||
var scope = require('./scope'); | ||
var fiberWrapper = require('./fiberWrapper'); | ||
var fiber = require('./fiber'); | ||
var spawnProcess = require('./spawnProcess'); | ||
@@ -165,8 +165,8 @@ var exec = require('./exec'); | ||
var wrapper = '__fiberWrapper(' + funcstring + ', __args, __cb)'; | ||
var wrapper = '__fiber.async(' + funcstring + ', __args, __cb)'; | ||
var sandbox = _.assign({ | ||
__fiberWrapper : fiberWrapper, | ||
__args : args, | ||
__cb : callback, | ||
scope : scope | ||
__fiber : fiber, | ||
__args : args, | ||
__cb : callback, | ||
scope : scope | ||
}, scope); | ||
@@ -173,0 +173,0 @@ |
@@ -11,13 +11,12 @@ var _ = require('lodash'); | ||
var config = require('./config'); | ||
var github = require('./github'); | ||
var helpers = require('./helpers'); | ||
var readline = require('./readline'); | ||
var fiber = require('./fiber'); | ||
var $ = require('./stylize'); | ||
var travis = require('./travis'); | ||
var teamcity = require('./teamcity'); | ||
var dimcity = require('./dimcity'); | ||
var github = require('./github'); | ||
var readline = require('./readline'); | ||
var fiberWrapper = require('./fiberWrapper'); | ||
var Future = require('fibers/future'); | ||
var $ = require('./stylize'); | ||
function hidePass(str){ | ||
@@ -49,53 +48,40 @@ str = str.replace(/(\s\-\-password\=)[^\s]+/g, '$1***'); | ||
local: function(){ | ||
return function(){ | ||
var cmd = [].join.call(arguments, '\n'); | ||
cmd = replacer.replace(cmd, config.get()); | ||
var cmd = [].join.call(arguments, '\n'); | ||
cmd = replacer.replace(cmd, config.get()); | ||
logger.info($.bold('Executing: cmd localy') + '\n' + $.lightmagenta(hidePass(cmd))); | ||
logger.info($.bold('Executing: cmd localy') + '\n' + $.lightmagenta(hidePass(cmd))); | ||
var future = new Future; | ||
spawnProcess.local(cmd, function (err, out) { | ||
if (err) future.throw(err); | ||
else future.return(out); | ||
}); | ||
return future | ||
}.apply(scope, arguments).wait() | ||
return fiber.sync(spawnProcess.local.bind(spawnProcess, cmd)); | ||
}, | ||
ssh: function(){ | ||
return function(){ | ||
var args = [].slice.call(arguments); | ||
var options = typeof(args[0]) === 'object' ? _.values(args.shift()) : null; | ||
var cmd = replacer.replace(args.join('\n'), config.get()); | ||
var cmd = [].join.call(arguments, '\n'); | ||
cmd = replacer.replace(cmd, config.get()); | ||
logger.info($.bold('Executing: ssh ' + $.blue(config.get('user') + '@' + config.get('server'))) + '\n' + $.yellow(hidePass(cmd))); | ||
logger.info($.bold('Executing: ssh ' + $.blue(config.get('user') + '@' + config.get('server'))) + '\n' + $.yellow(hidePass(cmd))); | ||
var future = new Future; | ||
spawnProcess.ssh(cmd, function (err, out) { | ||
if (err) future.throw(err); | ||
else future.return(out); | ||
}, options); | ||
return future | ||
}.apply(scope, arguments).wait() | ||
return fiber.sync(spawnProcess.ssh.bind(spawnProcess, cmd)); | ||
}, | ||
lazySsh: function(){ | ||
var env = config.get('env'); | ||
if (config.isLocal(env)) { | ||
return scope.local.apply(null, arguments); | ||
} else { | ||
return scope.ssh.apply(null, arguments); | ||
} | ||
}, | ||
sudo: function(){ | ||
return function(){ | ||
var cmd = [].join.call(arguments, '\n'); | ||
cmd = replacer.replace(cmd, config.get()); | ||
var cmd = [].join.call(arguments, '\n'); | ||
cmd = replacer.replace(cmd, config.get()); | ||
var future = new Future; | ||
logger.info($.bold('Executing: sudo ' + $.blue(config.get('user') + '@' + config.get('server'))) + '\n' + $.yellow(cmd)); | ||
function exec(){ | ||
logger.info($.bold('Executing: sudo ' + $.blue(config.get('user') + '@' + config.get('server'))) + '\n' + $.yellow(cmd)); | ||
spawnProcess.ssh('cat ' + config.sudoPath + ' | sudo -S ' + cmd, function (err, out) { | ||
if (err) future.throw(err); | ||
else future.return(out); | ||
}); | ||
} | ||
return fiber.sync(spawnProcess.ssh.bind(spawnProcess, 'cat ' + config.sudoPath + ' | sudo -S ' + cmd)); | ||
}, | ||
exec(); | ||
return future | ||
}.apply(scope, arguments).wait() | ||
rsyncDown: function(env, from, to){ | ||
var config = scope.getConfig(env); | ||
return scope.lazySsh('rsync -av --progress -e \'ssh -p ' + config.port +'\' ' + config.user + '@' + config.server + ':' + from + ' ' + to); | ||
}, | ||
@@ -105,10 +91,4 @@ | ||
var args = [].slice.call(arguments, 1); | ||
return function(){ | ||
var future = new Future; | ||
boom.executors.task(taskname, args, function(err, res){ | ||
if (err) future.throw(err); | ||
else future.return(res); | ||
}); | ||
return future | ||
}().wait() | ||
return fiber.sync(boom.executors.task.bind(null, taskname, args)); | ||
}, | ||
@@ -118,11 +98,6 @@ | ||
var args = [].slice.call(arguments, 1); | ||
if (config.get('debug')) logger.info($.bold('Executing: js') + '\n' + $.green(funcstring)); | ||
return function(){ | ||
var future = new Future; | ||
boom.executors.js(funcstring, args, function(err, res){ | ||
if (err) future.throw(err); | ||
else future.return(res); | ||
}); | ||
return future | ||
}().wait() | ||
return fiber.sync(boom.executors.js.bind(null, funcstring, args)); | ||
}, | ||
@@ -137,17 +112,12 @@ | ||
sleep: function(ms){ | ||
return function(){ | ||
var future = new Future; | ||
setTimeout(function() { | ||
future.return() | ||
}, ms) | ||
return future; | ||
}().wait() | ||
return fiber.sync(function(cb){ | ||
setTimeout(cb, ms); | ||
}); | ||
}, | ||
checkTravisBuild: function(commit){ | ||
return function(){ | ||
var future = new Future; | ||
return fiber.sync(function(cb){ | ||
console.log('checking TRAVIS-CI build...'); | ||
travis.checkBuild(commit, function(err, build){ | ||
if (err) return future.throw(err); | ||
if (err) return cb(err); | ||
if (config.get('travisDebug') && build) { | ||
@@ -157,11 +127,9 @@ build.state = Math.random() < 0.85 ? (Math.random() < 0.15 ? 'failed' : 'testing') : build.state; | ||
build = new travis.Build(build); | ||
future.return(build); | ||
}) | ||
return future; | ||
}().wait() | ||
cb(null, build); | ||
}); | ||
}); | ||
}, | ||
getSuccessTravisBuild: function(branch){ | ||
return function(){ | ||
var future = new Future; | ||
return fiber.sync(function(cb){ | ||
async.parallel({ | ||
@@ -172,3 +140,3 @@ commits : github.getCommits.bind(github, branch), | ||
if (err) { | ||
return future.throw(err); | ||
return cb(err); | ||
} | ||
@@ -196,17 +164,14 @@ | ||
future.return(lastSucces && lastSucces.build); | ||
cb(null, lastSucces && lastSucces.build); | ||
}) | ||
return future; | ||
}().wait() | ||
}); | ||
}, | ||
checkTeamcityBuild: function(commit){ | ||
return function(){ | ||
var future = new Future; | ||
return fiber.sync(function(cb){ | ||
console.log('checking TEAMCITY-CI build...'); | ||
teamcity.getBuilds(function(err, result){ | ||
if (err) return future.throw(err); | ||
if (err) return cb(err); | ||
if (!result.build) { | ||
return future.return(new teamcity.Build(null)); | ||
return cb(null, new teamcity.Build(null)); | ||
} | ||
@@ -221,36 +186,30 @@ async.map(result.build, function(build, cb){ | ||
}, function(err){ | ||
if (err) return future.throw(err); | ||
if (err) return cb(err); | ||
var build = _.find(result.build, { commit: commit }) || null; | ||
future.return(new teamcity.Build(build)); | ||
cb(null, new teamcity.Build(build)); | ||
}) | ||
}); | ||
return future; | ||
}().wait() | ||
}); | ||
}, | ||
getSuccessTeamcityBuild: function(branch){ | ||
return function(){ | ||
var future = new Future; | ||
return fiber.sync(function(cb){ | ||
teamcity.getSuccessBuilds(function(err, result){ | ||
if (err) return future.throw(err); | ||
if (err) return cb(err); | ||
var lastSuccess = result.build ? result.build.shift() : null; | ||
if (!lastSuccess) { | ||
return future.return(null); | ||
return cb(null, null); | ||
} | ||
teamcity.getBuildById(lastSuccess.id, function(err, buildInfo){ | ||
if (err) return future.throw(err); | ||
if (err) return cb(err); | ||
var commit = buildInfo.revisions ? buildInfo.revisions.revision[0].version : buildInfo.lastChanges.change[0].version; | ||
lastSuccess.commit = commit; | ||
future.return(lastSuccess); | ||
cb(null, lastSuccess); | ||
}); | ||
}); | ||
return future; | ||
}().wait() | ||
}); | ||
}, | ||
checkDimcityBuild: function(commit){ | ||
return function(){ | ||
var future = new Future; | ||
return fiber.sync(function(cb){ | ||
console.log('checking DIMCITY-CI build...'); | ||
@@ -260,73 +219,39 @@ | ||
if (err) { | ||
return future.throw(err); | ||
return cb(err); | ||
} | ||
build = new dimcity.Build(build || null); | ||
future.return(build); | ||
cb(null, build); | ||
}); | ||
return future; | ||
}().wait() | ||
}); | ||
}, | ||
getSuccessDimcityBuild: function(branch){ | ||
return function(){ | ||
var future = new Future; | ||
return fiber.sync(function(cb){ | ||
dimcity.getSuccessBuild(branch, function(err, build){ | ||
if (err) { | ||
return future.throw(err); | ||
return cb(err); | ||
} | ||
future.return(build || null); | ||
cb(null, build || null); | ||
}); | ||
return future; | ||
}().wait() | ||
}); | ||
}, | ||
ask: function(question){ | ||
return function(){ | ||
var future = new Future; | ||
readline.askYesOrNot(question, function(err, res){ | ||
if (err) future.throw(err); | ||
else future.return(res); | ||
}) | ||
return future; | ||
}().wait() | ||
return fiber.sync(readline.askYesOrNot.bind(readline, question)); | ||
}, | ||
read: function(options){ | ||
return function(){ | ||
var future = new Future; | ||
readline.read(options, function(err, res){ | ||
if (err) future.throw(err); | ||
else future.return(res); | ||
}) | ||
return future; | ||
}().wait() | ||
return fiber.sync(readline.read.bind(readline, options)); | ||
}, | ||
symlink: function(to, from){ | ||
return function(){ | ||
var future = new Future; | ||
fiberWrapper(scope.ssh.bind(scope, '[ -e ' + to + ' ] && ln -nfsv ' + to + ' ' + from), [], function(err, res){ | ||
if (err) future.throw(err); | ||
else future.return(res); | ||
}) | ||
return future; | ||
}().wait() | ||
return scope.ssh('[ -e ' + to + ' ] && ln -nfsv ' + to + ' ' + from); | ||
}, | ||
switchEnv: function(env){ | ||
return function(){ | ||
var future = new Future; | ||
config.init(env, function(err, res){ | ||
if (err) future.throw(err); | ||
else future.return(res); | ||
}); | ||
return future; | ||
}().wait() | ||
return fiber.sync(config.init.bind(config, env)); | ||
}, | ||
getConfig: function(env){ | ||
return function(){ | ||
var future = new Future; | ||
return fiber.sync(function(cb){ | ||
var scope = _.assign(_.clone(config), { data: {} }); | ||
@@ -337,7 +262,6 @@ async.series([ | ||
], function(err, res){ | ||
if (err) future.throw(err); | ||
else future.return(res[1]); | ||
if (err) cb(err); | ||
else cb(null, res[1]); | ||
}); | ||
return future; | ||
}().wait() | ||
}); | ||
}, | ||
@@ -365,5 +289,3 @@ | ||
makeDump: function(task, dumpName){ | ||
return function(){ | ||
var future = new Future; | ||
return fiber.sync(function(cb){ | ||
dumpName = replacer.replace(dumpName, config.get()); | ||
@@ -392,13 +314,9 @@ | ||
spawnProcess.local(cmd, function (err, out) { | ||
if (err) future.throw(err); | ||
else future.return(out); | ||
if (err) cb(err); | ||
else cb(null, out); | ||
}); | ||
return future; | ||
}.apply(scope, arguments).wait(); | ||
}); | ||
}, | ||
downloadDump: function(dumpPath){ | ||
return function(){ | ||
var future = new Future; | ||
return fiber.sync(function(cb){ | ||
dumpPath = replacer.replace(dumpPath, config.get()); | ||
@@ -420,8 +338,6 @@ var dumpName = path.basename(dumpPath); | ||
spawnProcess.local(cmd, function (err, out) { | ||
if (err) future.throw(err); | ||
else future.return(out); | ||
if (err) cb(err); | ||
else cb(null, out); | ||
}); | ||
return future; | ||
}.apply(scope, arguments).wait(); | ||
}); | ||
} | ||
@@ -428,0 +344,0 @@ } |
{ | ||
"name": "boom-deploy", | ||
"main": "boom.js", | ||
"version": "0.2.71", | ||
"version": "0.2.72", | ||
"description": "deploy your app", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
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
88947
2471