Deployment commands

This commit is contained in:
Simon Vieille 2016-01-21 17:00:53 +01:00
parent ca70506e9f
commit ea4f3445fb

View file

@ -8,10 +8,9 @@
#
# Notes:
#
fs = require 'fs'
module.exports = (robot) ->
fs = require 'fs'
robot.hear /deploy +([^\s]+)( +with +([^\s]+))?( +from +branch +([^\s]+))? +to +([^\s]+)( +after (.*))?$/i, (res) ->
project = res.match[1]
target = res.match[6]
@ -37,7 +36,7 @@ module.exports = (robot) ->
catch e
if pv
deploy directory, pv, commands
deploy directory, pv, commands, target, program
else
res.reply "Not a SVN or GIT repository"
catch e
@ -69,13 +68,37 @@ class GitProjectVersionning extends ProjectVersionning
commands
deploy = (directory, projectVersionning, commands) ->
deploy = (directory, projectVersionning, commands, target, program) ->
exec = require('sync-exec');
commands = projectVersionning.getUpdateCommands().concat(commands)
for command in commands
exec command, {cwd: directory}
exec buildDeployCommand(directory, program, target), {cwd: directory}
buildDeployCommand = (directory, program, target) ->
if program == 'mage'
command = 'mage deploy to:' + target
else
interpreter = null
try
fs.statSync directory + '/bin/console'
interpreter = 'php bin/console'
catch e
try
fs.statSync directory + '/app/console'
interpreter = 'php app/console'
catch e
if interpreter != null
command = interpreter + ' project:deploy ' + target + ' --go'
command
cleanCommands = (commands) ->
results = []
commands = commands.map Function.prototype.call, String.prototype.trim
@ -84,8 +107,7 @@ cleanCommands = (commands) ->
"sf" : "php symfony",
"sf2" : "php app/console",
"sf3" : "php bin/console",
"composer": "composer",
"artisan" : "php artisan",
"composer": "composer"
}
for command in commands