Deployment commands
This commit is contained in:
parent
ca70506e9f
commit
ea4f3445fb
|
@ -8,10 +8,9 @@
|
||||||
#
|
#
|
||||||
# Notes:
|
# Notes:
|
||||||
#
|
#
|
||||||
|
fs = require 'fs'
|
||||||
|
|
||||||
module.exports = (robot) ->
|
module.exports = (robot) ->
|
||||||
fs = require 'fs'
|
|
||||||
|
|
||||||
robot.hear /deploy +([^\s]+)( +with +([^\s]+))?( +from +branch +([^\s]+))? +to +([^\s]+)( +after (.*))?$/i, (res) ->
|
robot.hear /deploy +([^\s]+)( +with +([^\s]+))?( +from +branch +([^\s]+))? +to +([^\s]+)( +after (.*))?$/i, (res) ->
|
||||||
project = res.match[1]
|
project = res.match[1]
|
||||||
target = res.match[6]
|
target = res.match[6]
|
||||||
|
@ -37,7 +36,7 @@ module.exports = (robot) ->
|
||||||
catch e
|
catch e
|
||||||
|
|
||||||
if pv
|
if pv
|
||||||
deploy directory, pv, commands
|
deploy directory, pv, commands, target, program
|
||||||
else
|
else
|
||||||
res.reply "Not a SVN or GIT repository"
|
res.reply "Not a SVN or GIT repository"
|
||||||
catch e
|
catch e
|
||||||
|
@ -69,13 +68,37 @@ class GitProjectVersionning extends ProjectVersionning
|
||||||
|
|
||||||
commands
|
commands
|
||||||
|
|
||||||
deploy = (directory, projectVersionning, commands) ->
|
deploy = (directory, projectVersionning, commands, target, program) ->
|
||||||
exec = require('sync-exec');
|
exec = require('sync-exec');
|
||||||
commands = projectVersionning.getUpdateCommands().concat(commands)
|
commands = projectVersionning.getUpdateCommands().concat(commands)
|
||||||
|
|
||||||
for command in commands
|
for command in commands
|
||||||
exec command, {cwd: directory}
|
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) ->
|
cleanCommands = (commands) ->
|
||||||
results = []
|
results = []
|
||||||
commands = commands.map Function.prototype.call, String.prototype.trim
|
commands = commands.map Function.prototype.call, String.prototype.trim
|
||||||
|
@ -84,8 +107,7 @@ cleanCommands = (commands) ->
|
||||||
"sf" : "php symfony",
|
"sf" : "php symfony",
|
||||||
"sf2" : "php app/console",
|
"sf2" : "php app/console",
|
||||||
"sf3" : "php bin/console",
|
"sf3" : "php bin/console",
|
||||||
"composer": "composer",
|
"composer": "composer"
|
||||||
"artisan" : "php artisan",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for command in commands
|
for command in commands
|
||||||
|
|
Loading…
Reference in a new issue