diff --git a/Mage/Console.php b/Mage/Console.php index 5e9717a..4d313c8 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -153,8 +153,14 @@ class Mage_Console case 'add'; switch ($this->_args[1]) { case 'environment': + if (isset($this->_args[3]) && ($this->_args[3] == '--with-releases')) { + $withRelases = true; + } else { + $withRelases = false; + } + $task = new Mage_Task_Add; - $task->environment($this->_args[2]); + $task->environment($this->_args[2], $withRelases); break; } break; diff --git a/Mage/Task/Add.php b/Mage/Task/Add.php index c0a3469..b066ec6 100644 --- a/Mage/Task/Add.php +++ b/Mage/Task/Add.php @@ -1,7 +1,7 @@ Error!! Already exists an environment called ' . $environmentName . '', 1, 2); } else { + $releasesConfig = 'releases:' . PHP_EOL + . ' enabled: true' . PHP_EOL + . ' symlink: current' . PHP_EOL + . ' directory: releases' . PHP_EOL; + $baseConfig = '#' . $environmentName . PHP_EOL - . 'deployment:' + . 'deployment:' . PHP_EOL . ' user: dummy' . PHP_EOL . ' from: ./' . PHP_EOL . ' to: /var/www/vhosts/example.com/www' . PHP_EOL . ' excludes:' . PHP_EOL + . ($withRelases ? $releasesConfig : '') . 'hosts:' . PHP_EOL . 'tasks:' . ' pre-deploy:' . PHP_EOL diff --git a/docs/example-config/.mage/config/environment/production.yaml b/docs/example-config/.mage/config/environment/production.yaml index 795417e..4f2b8cb 100644 --- a/docs/example-config/.mage/config/environment/production.yaml +++ b/docs/example-config/.mage/config/environment/production.yaml @@ -9,7 +9,6 @@ releases: enabled: true symlink: current directory: releases - tasks: hosts: - s01.example.com - s02.example.com