From ea4f3445fb16d39bdb878c0617becff0758e4f29 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 21 Jan 2016 17:00:53 +0100 Subject: [PATCH] Deployment commands --- deployment.coffee | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/deployment.coffee b/deployment.coffee index 6c66de5..7b8fec3 100644 --- a/deployment.coffee +++ b/deployment.coffee @@ -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