From a4548cb04cafb8eb721479da9456982154d0fac2 Mon Sep 17 00:00:00 2001 From: Denis Denisov Date: Wed, 1 Oct 2014 07:49:46 +0300 Subject: [PATCH 01/34] Add a box.json file to build PHAR --- .gitignore | 1 + box.json | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 box.json diff --git a/.gitignore b/.gitignore index 5dc363a2..ba0c30d8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ .buildpath .idea vendor +mage.phar # OS generated files # // GitHub Recommendation ###################### diff --git a/box.json b/box.json new file mode 100644 index 00000000..cc32edb8 --- /dev/null +++ b/box.json @@ -0,0 +1,16 @@ +{ + "files": ["LICENSE"], + "finder": [ + { + "name": "*.php", + "exclude": [ + "docs" + ], + "in": "Mage" + } + ], + "git-version": "git_tag", + "main": "bin/mage", + "output": "mage.phar", + "stub": true +} From e0430cfb68e2f28577b39bad9145022b3c170847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C5=ABnas=20Dronga?= Date: Wed, 8 Oct 2014 15:22:08 +0300 Subject: [PATCH 02/34] built-in task for doctrine migrations --- .../Task/BuiltIn/Symfony2/DoctrineMigrate.php | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Mage/Task/BuiltIn/Symfony2/DoctrineMigrate.php diff --git a/Mage/Task/BuiltIn/Symfony2/DoctrineMigrate.php b/Mage/Task/BuiltIn/Symfony2/DoctrineMigrate.php new file mode 100644 index 00000000..b76633d6 --- /dev/null +++ b/Mage/Task/BuiltIn/Symfony2/DoctrineMigrate.php @@ -0,0 +1,40 @@ + +* +* For the full copyright and license information, please view the LICENSE +* file that was distributed with this source code. +*/ + +namespace Mage\Task\BuiltIn\Symfony2; + +use Mage\Task\BuiltIn\Symfony2\SymfonyAbstractTask; + +/** + * Task for Doctrine migrations + */ +class DoctrineMigrate extends SymfonyAbstractTask +{ + /** + * (non-PHPdoc) + * @see \Mage\Task\AbstractTask::getName() + */ + public function getName() + { + return 'Symfony v2 - Migrate doctrine entities [built-in]'; + } + + /** + * Migrates Doctrine entities + * + * @see \Mage\Task\AbstractTask::run() + */ + public function run() + { + $env = $this->getParameter('env', 'dev'); + $command = $this->getAppPath() . ' doctrine:migrations:migrate -n --env=' . $env; + return $this->runCommand($command); + } +} From dfbe67622d56fba1d5a3d9182e48d09a97bf9c96 Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Fri, 10 Oct 2014 21:04:47 +0200 Subject: [PATCH 03/34] Throw an error in case when command returns code other than 0 --- Mage/Console.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Mage/Console.php b/Mage/Console.php index 11733546..4ba4b3a2 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -120,7 +120,7 @@ public function run($arguments) } } - + $exceptionOccured = false; // Run Command - Check if there is a Configuration Error if ($configError !== false) { self::output('' . $configError . '', 1, 2); @@ -136,7 +136,12 @@ public function run($arguments) } } $exitCode = $command->run(); - + if (is_int($exitCode) && $exitCode !== 0) { + throw new Exception("Command execution failed with following exit code: $exitCode.", $exitCode); + } elseif (is_bool($exitCode) && !$exitCode) { + $exitCode = 1000; + throw new Exception("Command execution failed.", $exitCode); + } } catch (Exception $exception) { self::output('' . $exception->getMessage() . '', 1, 2); } From 0375a80dcf4759a8bcbbe8751056482fa8fb6870 Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Fri, 10 Oct 2014 21:20:21 +0200 Subject: [PATCH 04/34] Fix exit code to 1 due to php exit code that cannot be greater than 254 --- Mage/Console.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/Console.php b/Mage/Console.php index 4ba4b3a2..83ce6cb4 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -139,7 +139,7 @@ public function run($arguments) if (is_int($exitCode) && $exitCode !== 0) { throw new Exception("Command execution failed with following exit code: $exitCode.", $exitCode); } elseif (is_bool($exitCode) && !$exitCode) { - $exitCode = 1000; + $exitCode = 1; throw new Exception("Command execution failed.", $exitCode); } } catch (Exception $exception) { From 7a9495cf44d02f281b06dcfba8b611b27397d737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 12:10:07 -0200 Subject: [PATCH 05/34] Issue #130 --- Mage/Console.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Mage/Console.php b/Mage/Console.php index 83ce6cb4..6f55e8b8 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -135,12 +135,16 @@ public function run($arguments) throw new Exception('You must specify an environment for this command.'); } } + + // Run the Command $exitCode = $command->run(); + + // Check for errors if (is_int($exitCode) && $exitCode !== 0) { - throw new Exception("Command execution failed with following exit code: $exitCode.", $exitCode); + throw new Exception('Command execution failed with following exit code: ' . $exitCode, $exitCode); } elseif (is_bool($exitCode) && !$exitCode) { $exitCode = 1; - throw new Exception("Command execution failed.", $exitCode); + throw new Exception('Command execution failed.', $exitCode); } } catch (Exception $exception) { self::output('' . $exception->getMessage() . '', 1, 2); From b61e7149d0c15d72b654d84c9bca46e92c14f1db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 14:30:29 -0200 Subject: [PATCH 06/34] Yaml tweaks. --- docs/example-config/.mage/config/environment/ioncube.yml | 4 ++-- .../example-config/.mage/config/environment/production.yml | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/docs/example-config/.mage/config/environment/ioncube.yml b/docs/example-config/.mage/config/environment/ioncube.yml index da001d87..e2a0848e 100644 --- a/docs/example-config/.mage/config/environment/ioncube.yml +++ b/docs/example-config/.mage/config/environment/ioncube.yml @@ -27,8 +27,8 @@ ioncube: encoder: ioncube_encoder54 checkencoding: true checkignorepaths: - -/public/js/* - -/public/css/* + - /public/js/* + - /public/css/* projfile: project.prj project: diff --git a/docs/example-config/.mage/config/environment/production.yml b/docs/example-config/.mage/config/environment/production.yml index e785fe0d..e1cbe819 100644 --- a/docs/example-config/.mage/config/environment/production.yml +++ b/docs/example-config/.mage/config/environment/production.yml @@ -16,9 +16,7 @@ releases: symlink: current directory: releases hosts: - s01.example.com:22: - deployment: - user: nobody + - s01.example.com s02.example.com: deployment: user: toor @@ -28,12 +26,11 @@ hosts: tasks: on-deploy: - privileges - - s03.example.com tasks: pre-deploy: - scm/update on-deploy: -# - symfony2/cache-warmup: {env: prod} + - symfony2/cache-warmup: { env: prod } - privileges - sampleTask - sampleTaskRollbackAware From 5d39e46d9e957600b381da2082d7d817d6228449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 14:36:22 -0200 Subject: [PATCH 07/34] Code should not be duplicated --- Mage/Task/BuiltIn/Deployment/ReleaseTask.php | 2 +- .../Strategy/GitRemoteCacheTask.php | 35 ++----------------- 2 files changed, 3 insertions(+), 34 deletions(-) diff --git a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php index bf42643c..e44c5d89 100644 --- a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php +++ b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php @@ -133,7 +133,7 @@ protected function cleanUpReleases() $directoryToDelete = $releasesDirectory . '/' . $releaseIdToDelete; if ($directoryToDelete != '/') { $command = 'rm -rf ' . $directoryToDelete; - $this->runCommandRemote($command); + $result = $result && $this->runCommandRemote($command); } } } diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/GitRemoteCacheTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/GitRemoteCacheTask.php index 43296c3a..fd0869f7 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/GitRemoteCacheTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/GitRemoteCacheTask.php @@ -97,39 +97,8 @@ public function run() $command = 'cd ' . $remoteCacheFolder . ' && /usr/bin/env git archive ' . $branch . ' | tar -x -C ' . $deployToDirectory . ' ' . $excludeCmd; $result = $this->runCommandRemote($command) && $result; - // Count Releases - if ($this->getConfig()->release('enabled', false) == true) { - $releasesDirectory = $this->getConfig()->release('directory', 'releases'); - $symlink = $this->getConfig()->release('symlink', 'current'); - - if (substr($symlink, 0, 1) == '/') { - $releasesDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory; - } - - $maxReleases = $this->getConfig()->release('max', false); - if (($maxReleases !== false) && ($maxReleases > 0)) { - $releasesList = ''; - $countReleasesFetch = $this->runCommandRemote('ls -1 ' . $releasesDirectory, $releasesList); - $releasesList = trim($releasesList); - - if ($countReleasesFetch && $releasesList != '') { - $releasesList = explode(PHP_EOL, $releasesList); - if (count($releasesList) > $maxReleases) { - $releasesToDelete = array_diff($releasesList, array($this->getConfig()->getReleaseId())); - sort($releasesToDelete); - $releasesToDeleteCount = count($releasesToDelete) - $maxReleases; - $releasesToDelete = array_slice($releasesToDelete, 0, $releasesToDeleteCount + 1); - - foreach ($releasesToDelete as $releaseIdToDelete) { - $directoryToDelete = $releasesDirectory . '/' . $releaseIdToDelete; - if ($directoryToDelete != '/') { - $command = 'rm -rf ' . $directoryToDelete; - $result = $result && $this->runCommandRemote($command); - } - } - } - } - } + if ($result) { + $this->cleanUpReleases(); } return $result; From f20091afc6ef42fad883d7ca07f674dcc6dc22dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 14:43:57 -0200 Subject: [PATCH 08/34] Boolean and Null should be compared strictly. --- Mage/Command/BuiltIn/DeployCommand.php | 10 +++++----- Mage/Command/BuiltIn/UpdateCommand.php | 2 +- Mage/Console.php | 4 ++-- Mage/Task/AbstractTask.php | 4 ++-- Mage/Task/BuiltIn/Deployment/ReleaseTask.php | 4 ++-- .../Deployment/Strategy/BaseStrategyTaskAbstract.php | 2 +- .../BuiltIn/Deployment/Strategy/GitRemoteCacheTask.php | 4 ++-- Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php | 6 +++--- Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php | 6 +++--- Mage/Task/BuiltIn/Releases/ListTask.php | 2 +- Mage/Task/BuiltIn/Releases/RollbackTask.php | 6 +++--- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Mage/Command/BuiltIn/DeployCommand.php b/Mage/Command/BuiltIn/DeployCommand.php index d1888b38..3719c49b 100644 --- a/Mage/Command/BuiltIn/DeployCommand.php +++ b/Mage/Command/BuiltIn/DeployCommand.php @@ -356,7 +356,7 @@ protected function runDeploymentTasks() } // Releasing - if (self::$deployStatus == self::SUCCEDED && $this->getConfig()->release('enabled', false) == true) { + if (self::$deployStatus == self::SUCCEDED && $this->getConfig()->release('enabled', false) === true) { // Execute the Releases Console::output('Starting the Releasing'); $completedTasks = 0; @@ -439,7 +439,7 @@ protected function runTask(AbstractTask $task, $title = null) { $task->init(); - if ($title == null) { + if ($title === null) { $title = 'Running ' . $task->getName() . ' ... '; } Console::output($title, 2, 0); @@ -449,11 +449,11 @@ protected function runTask(AbstractTask $task, $title = null) $runTask = false; } - if ($runTask == true) { + if ($runTask === true) { try { $result = $task->run(); - if ($result == true) { + if ($result === true) { Console::output('OK', 0); $result = true; @@ -564,7 +564,7 @@ protected function chooseDeployStrategy() case self::DEPLOY_STRATEGY_GUESS: default: - if ($this->getConfig()->release('enabled', false) == true) { + if ($this->getConfig()->release('enabled', false) === true) { $deployStrategy = 'deployment/strategy/tar-gz'; } else { $deployStrategy = 'deployment/strategy/rsync'; diff --git a/Mage/Command/BuiltIn/UpdateCommand.php b/Mage/Command/BuiltIn/UpdateCommand.php index 9cba1cbb..7fa64613 100644 --- a/Mage/Command/BuiltIn/UpdateCommand.php +++ b/Mage/Command/BuiltIn/UpdateCommand.php @@ -35,7 +35,7 @@ public function run() Console::output('Updating application via ' . $task->getName() . ' ... ', 1, 0); $result = $task->run(); - if ($result == true) { + if ($result === true) { Console::output('OK' . PHP_EOL, 0); $exitCode = 0; diff --git a/Mage/Console.php b/Mage/Console.php index 6f55e8b8..f1d76092 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -131,7 +131,7 @@ public function run($arguments) $command = Factory::get($commandName, $config); if ($command instanceOf RequiresEnvironment) { - if ($config->getEnvironment() == false) { + if ($config->getEnvironment() === false) { throw new Exception('You must specify an environment for this command.'); } } @@ -222,7 +222,7 @@ public static function executeCommand($command, &$output = null) public static function log($message) { if (self::$logEnabled) { - if (self::$log == null) { + if (self::$log === null) { self::$logFile = realpath(getcwd() . '/.mage/logs') . '/log-' . date('Ymd-His') . '.log'; self::$log = fopen(self::$logFile, 'w'); } diff --git a/Mage/Task/AbstractTask.php b/Mage/Task/AbstractTask.php index c61f87d8..bc12f5f9 100644 --- a/Mage/Task/AbstractTask.php +++ b/Mage/Task/AbstractTask.php @@ -181,7 +181,7 @@ protected final function runCommandLocal($command, &$output = null) */ protected final function runCommandRemote($command, &$output = null, $cdToDirectoryFirst = true) { - if ($this->getConfig()->release('enabled', false) == true) { + if ($this->getConfig()->release('enabled', false) === true) { if ($this instanceOf IsReleaseAware) { $releasesDirectory = ''; @@ -238,7 +238,7 @@ protected final function runCommand($command, &$output = null) */ protected function getReleasesAwareCommand($command) { - if ($this->getConfig()->release('enabled', false) == true) { + if ($this->getConfig()->release('enabled', false) === true) { $releasesDirectory = $this->getConfig()->release('directory', 'releases'); $deployToDirectory = $releasesDirectory . '/' . $this->getConfig()->getReleaseId(); diff --git a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php index e44c5d89..ceeab5f3 100644 --- a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php +++ b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php @@ -37,7 +37,7 @@ public function getName() public function run() { $resultFetch = false; - if ($this->getConfig()->release('enabled', false) == true) { + if ($this->getConfig()->release('enabled', false) === true) { $releasesDirectory = $this->getConfig()->release('directory', 'releases'); $symlink = $this->getConfig()->release('symlink', 'current'); @@ -107,7 +107,7 @@ public function run() protected function cleanUpReleases() { // Count Releases - if ($this->getConfig()->release('enabled', false) == true) { + if ($this->getConfig()->release('enabled', false) === true) { $releasesDirectory = $this->getConfig()->release('directory', 'releases'); $symlink = $this->getConfig()->release('symlink', 'current'); diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php b/Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php index 5affe973..9e787c73 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php @@ -30,7 +30,7 @@ protected function checkOverrideRelease() $overrideRelease = $this->getParameter('overrideRelease', false); $symlink = $this->getConfig()->release('symlink', 'current'); - if ($overrideRelease == true) { + if ($overrideRelease === true) { $releaseToOverride = false; $resultFetch = $this->runCommandRemote('ls -ld ' . $symlink . ' | cut -d"/" -f2', $releaseToOverride); if ($resultFetch && is_numeric($releaseToOverride)) { diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/GitRemoteCacheTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/GitRemoteCacheTask.php index fd0869f7..3934e480 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/GitRemoteCacheTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/GitRemoteCacheTask.php @@ -42,7 +42,7 @@ public function run() { $overrideRelease = $this->getParameter('overrideRelease', false); - if ($overrideRelease == true) { + if ($overrideRelease === true) { $releaseToOverride = false; $resultFetch = $this->runCommandRemote('ls -ld current | cut -d"/" -f2', $releaseToOverride); if ($resultFetch && is_numeric($releaseToOverride)) { @@ -63,7 +63,7 @@ public function run() $userExcludes = $this->getConfig()->deployment('excludes', array()); $deployToDirectory = $this->getConfig()->deployment('to'); - if ($this->getConfig()->release('enabled', false) == true) { + if ($this->getConfig()->release('enabled', false) === true) { $releasesDirectory = $this->getConfig()->release('directory', 'releases'); $deployToDirectory = rtrim($this->getConfig()->deployment('to'), '/') diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php index c4c92adf..b7ee1b5d 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php @@ -27,8 +27,8 @@ class RsyncTask extends BaseStrategyTaskAbstract implements IsReleaseAware */ public function getName() { - if ($this->getConfig()->release('enabled', false) == true) { - if ($this->getConfig()->getParameter('overrideRelease', false) == true) { + if ($this->getConfig()->release('enabled', false) === true) { + if ($this->getConfig()->getParameter('overrideRelease', false) === true) { return 'Deploy via Rsync (with Releases override) [built-in]'; } else { $rsync_copy = $this->getConfig()->deployment("rsync"); @@ -55,7 +55,7 @@ public function run() // If we are working with releases $deployToDirectory = $this->getConfig()->deployment('to'); - if ($this->getConfig()->release('enabled', false) == true) { + if ($this->getConfig()->release('enabled', false) === true) { $releasesDirectory = $this->getConfig()->release('directory', 'releases'); $symlink = $this->getConfig()->release('symlink', 'current'); diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php index 2077eb7a..5607a5d2 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php @@ -27,8 +27,8 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware */ public function getName() { - if ($this->getConfig()->release('enabled', false) == true) { - if ($this->getConfig()->getParameter('overrideRelease', false) == true) { + if ($this->getConfig()->release('enabled', false) === true) { + if ($this->getConfig()->getParameter('overrideRelease', false) === true) { return 'Deploy via TarGz (with Releases override) [built-in]'; } else { return 'Deploy via TarGz (with Releases) [built-in]'; @@ -50,7 +50,7 @@ public function run() // If we are working with releases $deployToDirectory = $this->getConfig()->deployment('to'); - if ($this->getConfig()->release('enabled', false) == true) { + if ($this->getConfig()->release('enabled', false) === true) { $releasesDirectory = $this->getConfig()->release('directory', 'releases'); $deployToDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory diff --git a/Mage/Task/BuiltIn/Releases/ListTask.php b/Mage/Task/BuiltIn/Releases/ListTask.php index ef88004b..3d763270 100644 --- a/Mage/Task/BuiltIn/Releases/ListTask.php +++ b/Mage/Task/BuiltIn/Releases/ListTask.php @@ -34,7 +34,7 @@ public function getName() */ public function run() { - if ($this->getConfig()->release('enabled', false) == true) { + if ($this->getConfig()->release('enabled', false) === true) { $releasesDirectory = $this->getConfig()->release('directory', 'releases'); $symlink = $this->getConfig()->release('symlink', 'current'); diff --git a/Mage/Task/BuiltIn/Releases/RollbackTask.php b/Mage/Task/BuiltIn/Releases/RollbackTask.php index 759c0428..eee33c39 100644 --- a/Mage/Task/BuiltIn/Releases/RollbackTask.php +++ b/Mage/Task/BuiltIn/Releases/RollbackTask.php @@ -47,7 +47,7 @@ public function getReleaseId() */ public function run() { - if ($this->getConfig()->release('enabled', false) == true) { + if ($this->getConfig()->release('enabled', false) === true) { $releasesDirectory = $this->getConfig()->release('directory', 'releases'); $symlink = $this->getConfig()->release('symlink', 'current'); @@ -111,7 +111,7 @@ public function run() $tasks++; $result = $task->run(); - if ($result == true) { + if ($result === true) { Console::output('OK', 0); $completedTasks++; } else { @@ -161,7 +161,7 @@ public function run() $tasks++; $result = $task->run(); - if ($result == true) { + if ($result === true) { Console::output('OK', 0); $completedTasks++; } else { From dbcbcb78ed91a7a78166acd77535bc7fb0b1d488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 14:44:48 -0200 Subject: [PATCH 09/34] Remove error suppression. --- Mage/Mailer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/Mailer.php b/Mage/Mailer.php index e0b3443e..fadf48aa 100644 --- a/Mage/Mailer.php +++ b/Mage/Mailer.php @@ -84,6 +84,6 @@ public function send($result) . $attachment . self::EOL . '--Mage-mixed-' . $boundary . '--' . self::EOL; - @mail($this->address, $subject, $message, $headers); + mail($this->address, $subject, $message, $headers); } } \ No newline at end of file From b8c23747f07ca5310ed1f21c12f93af95c160881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 14:53:38 -0200 Subject: [PATCH 10/34] User specific files should not appear in .gitignore --- .gitignore | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.gitignore b/.gitignore index ba0c30d8..69641986 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,3 @@ -.settings -.settings/* -.project -.buildpath -.idea vendor mage.phar From aaf92d5001888dd125f2706ca0861bbd8bb91f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 14:54:45 -0200 Subject: [PATCH 11/34] Commented code should not be commited. --- docs/example-config/.mage/tasks/TaskWithParameters.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/example-config/.mage/tasks/TaskWithParameters.php b/docs/example-config/.mage/tasks/TaskWithParameters.php index bf99deb7..967fcfb0 100644 --- a/docs/example-config/.mage/tasks/TaskWithParameters.php +++ b/docs/example-config/.mage/tasks/TaskWithParameters.php @@ -18,8 +18,10 @@ public function getName() public function run() { - //throw new Mage_Task_SkipException; - //return false; - return true; + if ($this->getParameter('booleanOption', false)) { + return true; + } else { + return false; + } } } \ No newline at end of file From 9653552be76ae4df215f0901d4089c25da2efb19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 15:07:36 -0200 Subject: [PATCH 12/34] Text files should end with a newline character. --- .gitignore | 2 +- LICENSE | 2 +- LICENSE_YAML | 2 +- Mage/Command/AbstractCommand.php | 2 +- Mage/Command/BuiltIn/InstallCommand.php | 2 +- Mage/Command/BuiltIn/UpdateCommand.php | 3 +-- Mage/Command/BuiltIn/VersionCommand.php | 3 +-- Mage/Command/Factory.php | 2 +- Mage/Command/RequiresEnvironment.php | 2 +- Mage/Mailer.php | 2 +- Mage/Task/BuiltIn/Deployment/Strategy/DisabledTask.php | 3 +-- Mage/Task/BuiltIn/Magento/ClearCacheTask.php | 2 +- Mage/Task/BuiltIn/Magento/ClearFullPageCacheTask.php | 2 +- Mage/Task/BuiltIn/Releases/ListTask.php | 3 +-- Mage/Task/BuiltIn/Releases/RollbackTask.php | 3 +-- Mage/Task/BuiltIn/Scm/ChangeBranchTask.php | 2 +- Mage/Task/BuiltIn/Scm/CloneTask.php | 2 +- Mage/Task/BuiltIn/Scm/RemoveCloneTask.php | 2 +- Mage/Task/BuiltIn/Scm/UpdateTask.php | 2 +- Mage/Task/BuiltIn/Symfony2/AsseticDumpTask.php | 2 +- Mage/Task/BuiltIn/Symfony2/AssetsInstallTask.php | 2 +- Mage/Task/BuiltIn/Symfony2/CacheClearTask.php | 2 +- Mage/Task/BuiltIn/Symfony2/SymfonyAbstractTask.php | 2 +- Mage/Task/SkipException.php | 2 +- Mage/Yaml/Dumper.php | 2 +- Mage/Yaml/Escaper.php | 2 +- Mage/Yaml/Exception/DumpException.php | 2 +- Mage/Yaml/Exception/ExceptionInterface.php | 2 +- Mage/Yaml/Exception/ParseException.php | 2 +- Mage/Yaml/Exception/RuntimeException.php | 2 +- Mage/Yaml/Inline.php | 2 +- Mage/Yaml/Parser.php | 3 +-- Mage/Yaml/Unescaper.php | 2 +- Mage/Yaml/Yaml.php | 2 +- docs/example-config/.mage/config/environment/production.yml | 2 +- docs/example-config/.mage/config/general.yml | 2 +- docs/example-config/.mage/logs/.gitignore | 2 +- docs/example-config/.mage/tasks/FailTask.php | 2 +- docs/example-config/.mage/tasks/Privileges.php | 2 +- docs/example-config/.mage/tasks/SampleTaskRollbackAware.php | 2 +- docs/example-config/.mage/tasks/TaskWithParameters.php | 2 +- 41 files changed, 41 insertions(+), 47 deletions(-) diff --git a/.gitignore b/.gitignore index 69641986..a147ed33 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,4 @@ mage.phar .DS_Store* ehthumbs.db Icon? -Thumbs.db \ No newline at end of file +Thumbs.db diff --git a/LICENSE b/LICENSE index ccdd780d..78cd3842 100644 --- a/LICENSE +++ b/LICENSE @@ -24,4 +24,4 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------- The Yaml Library Parser is (c) by Fabien Potencier, and belongs to the Symfony Proyect --------- \ No newline at end of file +-------- diff --git a/LICENSE_YAML b/LICENSE_YAML index 4acdf9df..0b3292cf 100644 --- a/LICENSE_YAML +++ b/LICENSE_YAML @@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff --git a/Mage/Command/AbstractCommand.php b/Mage/Command/AbstractCommand.php index b513517c..3ed5a9db 100644 --- a/Mage/Command/AbstractCommand.php +++ b/Mage/Command/AbstractCommand.php @@ -52,4 +52,4 @@ public function getConfig() { return $this->config; } -} \ No newline at end of file +} diff --git a/Mage/Command/BuiltIn/InstallCommand.php b/Mage/Command/BuiltIn/InstallCommand.php index 47a8411a..932b3c09 100644 --- a/Mage/Command/BuiltIn/InstallCommand.php +++ b/Mage/Command/BuiltIn/InstallCommand.php @@ -122,4 +122,4 @@ protected function recursiveCopy($from, $to) return false; } } -} \ No newline at end of file +} diff --git a/Mage/Command/BuiltIn/UpdateCommand.php b/Mage/Command/BuiltIn/UpdateCommand.php index 7fa64613..14dc75a9 100644 --- a/Mage/Command/BuiltIn/UpdateCommand.php +++ b/Mage/Command/BuiltIn/UpdateCommand.php @@ -45,5 +45,4 @@ public function run() return $exitCode; } - -} \ No newline at end of file +} diff --git a/Mage/Command/BuiltIn/VersionCommand.php b/Mage/Command/BuiltIn/VersionCommand.php index ca591d7d..8437242d 100644 --- a/Mage/Command/BuiltIn/VersionCommand.php +++ b/Mage/Command/BuiltIn/VersionCommand.php @@ -30,5 +30,4 @@ public function run() return 0; } - -} \ No newline at end of file +} diff --git a/Mage/Command/Factory.php b/Mage/Command/Factory.php index 0584046b..83b669ba 100644 --- a/Mage/Command/Factory.php +++ b/Mage/Command/Factory.php @@ -59,4 +59,4 @@ public static function get($commandName, Config $config) return $instance; } -} \ No newline at end of file +} diff --git a/Mage/Command/RequiresEnvironment.php b/Mage/Command/RequiresEnvironment.php index 5ee07710..9a0a56cb 100644 --- a/Mage/Command/RequiresEnvironment.php +++ b/Mage/Command/RequiresEnvironment.php @@ -17,4 +17,4 @@ */ interface RequiresEnvironment { -} \ No newline at end of file +} diff --git a/Mage/Mailer.php b/Mage/Mailer.php index fadf48aa..f2fb33d5 100644 --- a/Mage/Mailer.php +++ b/Mage/Mailer.php @@ -86,4 +86,4 @@ public function send($result) mail($this->address, $subject, $message, $headers); } -} \ No newline at end of file +} diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/DisabledTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/DisabledTask.php index 958faef4..e3255b58 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/DisabledTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/DisabledTask.php @@ -38,5 +38,4 @@ public function run() { throw new SkipException; } - -} \ No newline at end of file +} diff --git a/Mage/Task/BuiltIn/Magento/ClearCacheTask.php b/Mage/Task/BuiltIn/Magento/ClearCacheTask.php index 8a8cf551..7db77809 100644 --- a/Mage/Task/BuiltIn/Magento/ClearCacheTask.php +++ b/Mage/Task/BuiltIn/Magento/ClearCacheTask.php @@ -39,4 +39,4 @@ public function run() return $result; } -} \ No newline at end of file +} diff --git a/Mage/Task/BuiltIn/Magento/ClearFullPageCacheTask.php b/Mage/Task/BuiltIn/Magento/ClearFullPageCacheTask.php index 8dd0b498..17c3d66f 100644 --- a/Mage/Task/BuiltIn/Magento/ClearFullPageCacheTask.php +++ b/Mage/Task/BuiltIn/Magento/ClearFullPageCacheTask.php @@ -39,4 +39,4 @@ public function run() return $result; } -} \ No newline at end of file +} diff --git a/Mage/Task/BuiltIn/Releases/ListTask.php b/Mage/Task/BuiltIn/Releases/ListTask.php index 3d763270..07743516 100644 --- a/Mage/Task/BuiltIn/Releases/ListTask.php +++ b/Mage/Task/BuiltIn/Releases/ListTask.php @@ -146,5 +146,4 @@ protected function dateDiff($releaseDate) return $textDiff; } - -} \ No newline at end of file +} diff --git a/Mage/Task/BuiltIn/Releases/RollbackTask.php b/Mage/Task/BuiltIn/Releases/RollbackTask.php index eee33c39..a8ebb9cd 100644 --- a/Mage/Task/BuiltIn/Releases/RollbackTask.php +++ b/Mage/Task/BuiltIn/Releases/RollbackTask.php @@ -188,5 +188,4 @@ public function run() return false; } } - -} \ No newline at end of file +} diff --git a/Mage/Task/BuiltIn/Scm/ChangeBranchTask.php b/Mage/Task/BuiltIn/Scm/ChangeBranchTask.php index dfb61271..8c5e33fd 100644 --- a/Mage/Task/BuiltIn/Scm/ChangeBranchTask.php +++ b/Mage/Task/BuiltIn/Scm/ChangeBranchTask.php @@ -105,4 +105,4 @@ public function run() return $result; } -} \ No newline at end of file +} diff --git a/Mage/Task/BuiltIn/Scm/CloneTask.php b/Mage/Task/BuiltIn/Scm/CloneTask.php index 7c50b4ac..f30085fa 100644 --- a/Mage/Task/BuiltIn/Scm/CloneTask.php +++ b/Mage/Task/BuiltIn/Scm/CloneTask.php @@ -84,4 +84,4 @@ public function run() return $result; } -} \ No newline at end of file +} diff --git a/Mage/Task/BuiltIn/Scm/RemoveCloneTask.php b/Mage/Task/BuiltIn/Scm/RemoveCloneTask.php index 5084622c..e0c102d7 100644 --- a/Mage/Task/BuiltIn/Scm/RemoveCloneTask.php +++ b/Mage/Task/BuiltIn/Scm/RemoveCloneTask.php @@ -58,4 +58,4 @@ public function run() { return $this->runCommandLocal('rm -rf ' . $this->source['temporal']); } -} \ No newline at end of file +} diff --git a/Mage/Task/BuiltIn/Scm/UpdateTask.php b/Mage/Task/BuiltIn/Scm/UpdateTask.php index e883a2c1..22c496e4 100644 --- a/Mage/Task/BuiltIn/Scm/UpdateTask.php +++ b/Mage/Task/BuiltIn/Scm/UpdateTask.php @@ -69,4 +69,4 @@ public function run() return $result; } -} \ No newline at end of file +} diff --git a/Mage/Task/BuiltIn/Symfony2/AsseticDumpTask.php b/Mage/Task/BuiltIn/Symfony2/AsseticDumpTask.php index 7b086606..7b1c69c8 100644 --- a/Mage/Task/BuiltIn/Symfony2/AsseticDumpTask.php +++ b/Mage/Task/BuiltIn/Symfony2/AsseticDumpTask.php @@ -42,4 +42,4 @@ public function run() return $result; } -} \ No newline at end of file +} diff --git a/Mage/Task/BuiltIn/Symfony2/AssetsInstallTask.php b/Mage/Task/BuiltIn/Symfony2/AssetsInstallTask.php index c53292c5..f7ca9811 100644 --- a/Mage/Task/BuiltIn/Symfony2/AssetsInstallTask.php +++ b/Mage/Task/BuiltIn/Symfony2/AssetsInstallTask.php @@ -49,4 +49,4 @@ public function run() return $result; } -} \ No newline at end of file +} diff --git a/Mage/Task/BuiltIn/Symfony2/CacheClearTask.php b/Mage/Task/BuiltIn/Symfony2/CacheClearTask.php index fff5c24d..44acc465 100644 --- a/Mage/Task/BuiltIn/Symfony2/CacheClearTask.php +++ b/Mage/Task/BuiltIn/Symfony2/CacheClearTask.php @@ -42,4 +42,4 @@ public function run() return $result; } -} \ No newline at end of file +} diff --git a/Mage/Task/BuiltIn/Symfony2/SymfonyAbstractTask.php b/Mage/Task/BuiltIn/Symfony2/SymfonyAbstractTask.php index 4fae2e21..7ac246cd 100644 --- a/Mage/Task/BuiltIn/Symfony2/SymfonyAbstractTask.php +++ b/Mage/Task/BuiltIn/Symfony2/SymfonyAbstractTask.php @@ -29,4 +29,4 @@ protected function getAppPath() return $this->getConfig()->general('symfony_app_path', $defaultAppPath); } -} \ No newline at end of file +} diff --git a/Mage/Task/SkipException.php b/Mage/Task/SkipException.php index e26684a9..66bf4a81 100644 --- a/Mage/Task/SkipException.php +++ b/Mage/Task/SkipException.php @@ -19,4 +19,4 @@ */ class SkipException extends Exception { -} \ No newline at end of file +} diff --git a/Mage/Yaml/Dumper.php b/Mage/Yaml/Dumper.php index 50905135..1a594df8 100644 --- a/Mage/Yaml/Dumper.php +++ b/Mage/Yaml/Dumper.php @@ -72,4 +72,4 @@ public function dump($input, $inline = 0, $indent = 0, $exceptionOnInvalidType = return $output; } -} \ No newline at end of file +} diff --git a/Mage/Yaml/Escaper.php b/Mage/Yaml/Escaper.php index 021b7eab..ad75520f 100644 --- a/Mage/Yaml/Escaper.php +++ b/Mage/Yaml/Escaper.php @@ -86,4 +86,4 @@ public static function escapeWithSingleQuotes($value) { return sprintf("'%s'", str_replace('\'', '\'\'', $value)); } -} \ No newline at end of file +} diff --git a/Mage/Yaml/Exception/DumpException.php b/Mage/Yaml/Exception/DumpException.php index bc3581b3..20ac47c3 100644 --- a/Mage/Yaml/Exception/DumpException.php +++ b/Mage/Yaml/Exception/DumpException.php @@ -22,4 +22,4 @@ */ class DumpException extends RuntimeException { -} \ No newline at end of file +} diff --git a/Mage/Yaml/Exception/ExceptionInterface.php b/Mage/Yaml/Exception/ExceptionInterface.php index fa120007..cc550423 100644 --- a/Mage/Yaml/Exception/ExceptionInterface.php +++ b/Mage/Yaml/Exception/ExceptionInterface.php @@ -20,4 +20,4 @@ */ interface ExceptionInterface { -} \ No newline at end of file +} diff --git a/Mage/Yaml/Exception/ParseException.php b/Mage/Yaml/Exception/ParseException.php index 3c4465b0..6064ce45 100644 --- a/Mage/Yaml/Exception/ParseException.php +++ b/Mage/Yaml/Exception/ParseException.php @@ -147,4 +147,4 @@ private function updateRepr() $this->message .= '.'; } } -} \ No newline at end of file +} diff --git a/Mage/Yaml/Exception/RuntimeException.php b/Mage/Yaml/Exception/RuntimeException.php index 51245bd2..5bbe8a32 100644 --- a/Mage/Yaml/Exception/RuntimeException.php +++ b/Mage/Yaml/Exception/RuntimeException.php @@ -22,4 +22,4 @@ */ class RuntimeException extends \RuntimeException implements ExceptionInterface { -} \ No newline at end of file +} diff --git a/Mage/Yaml/Inline.php b/Mage/Yaml/Inline.php index 2586ddeb..0341f787 100644 --- a/Mage/Yaml/Inline.php +++ b/Mage/Yaml/Inline.php @@ -502,4 +502,4 @@ private static function getTimestampRegex() $~x EOF; } -} \ No newline at end of file +} diff --git a/Mage/Yaml/Parser.php b/Mage/Yaml/Parser.php index fa7007d1..4237dc59 100644 --- a/Mage/Yaml/Parser.php +++ b/Mage/Yaml/Parser.php @@ -655,5 +655,4 @@ private function isStringUnIndentedCollectionItem() { return (0 === strpos($this->currentLine, '- ')); } - -} \ No newline at end of file +} diff --git a/Mage/Yaml/Unescaper.php b/Mage/Yaml/Unescaper.php index fc3bbcf3..e7a25b3e 100644 --- a/Mage/Yaml/Unescaper.php +++ b/Mage/Yaml/Unescaper.php @@ -139,4 +139,4 @@ private static function utf8chr($c) return chr(0xF0 | $c >> 18) . chr(0x80 | $c >> 12 & 0x3F) . chr(0x80 | $c >> 6 & 0x3F) . chr(0x80 | $c & 0x3F); } -} \ No newline at end of file +} diff --git a/Mage/Yaml/Yaml.php b/Mage/Yaml/Yaml.php index a476c602..3845c807 100644 --- a/Mage/Yaml/Yaml.php +++ b/Mage/Yaml/Yaml.php @@ -99,4 +99,4 @@ public static function dump($array, $inline = 2, $indent = 4, $exceptionOnInvali return $yaml->dump($array, $inline, 0, $exceptionOnInvalidType, $objectSupport); } -} \ No newline at end of file +} diff --git a/docs/example-config/.mage/config/environment/production.yml b/docs/example-config/.mage/config/environment/production.yml index e1cbe819..3a668f44 100644 --- a/docs/example-config/.mage/config/environment/production.yml +++ b/docs/example-config/.mage/config/environment/production.yml @@ -34,4 +34,4 @@ tasks: - privileges - sampleTask - sampleTaskRollbackAware - #post-deploy: \ No newline at end of file + #post-deploy: diff --git a/docs/example-config/.mage/config/general.yml b/docs/example-config/.mage/config/general.yml index f601999b..3834ff31 100644 --- a/docs/example-config/.mage/config/general.yml +++ b/docs/example-config/.mage/config/general.yml @@ -5,4 +5,4 @@ notifications: true logging: true scm: type: git - url: git://github.com/andres-montanez/Zend-Framework-Twig-example-app.git \ No newline at end of file + url: git://github.com/andres-montanez/Zend-Framework-Twig-example-app.git diff --git a/docs/example-config/.mage/logs/.gitignore b/docs/example-config/.mage/logs/.gitignore index 6976a484..5592679c 100644 --- a/docs/example-config/.mage/logs/.gitignore +++ b/docs/example-config/.mage/logs/.gitignore @@ -1 +1 @@ -log-* \ No newline at end of file +log-* diff --git a/docs/example-config/.mage/tasks/FailTask.php b/docs/example-config/.mage/tasks/FailTask.php index 91e9c529..641e8878 100644 --- a/docs/example-config/.mage/tasks/FailTask.php +++ b/docs/example-config/.mage/tasks/FailTask.php @@ -14,4 +14,4 @@ public function run() { return false; } -} \ No newline at end of file +} diff --git a/docs/example-config/.mage/tasks/Privileges.php b/docs/example-config/.mage/tasks/Privileges.php index f5d88bde..1092533c 100644 --- a/docs/example-config/.mage/tasks/Privileges.php +++ b/docs/example-config/.mage/tasks/Privileges.php @@ -17,4 +17,4 @@ public function run() return $result; } -} \ No newline at end of file +} diff --git a/docs/example-config/.mage/tasks/SampleTaskRollbackAware.php b/docs/example-config/.mage/tasks/SampleTaskRollbackAware.php index ef02d131..f990e2ce 100644 --- a/docs/example-config/.mage/tasks/SampleTaskRollbackAware.php +++ b/docs/example-config/.mage/tasks/SampleTaskRollbackAware.php @@ -19,4 +19,4 @@ public function run() { return true; } -} \ No newline at end of file +} diff --git a/docs/example-config/.mage/tasks/TaskWithParameters.php b/docs/example-config/.mage/tasks/TaskWithParameters.php index 967fcfb0..003ffef1 100644 --- a/docs/example-config/.mage/tasks/TaskWithParameters.php +++ b/docs/example-config/.mage/tasks/TaskWithParameters.php @@ -24,4 +24,4 @@ public function run() return false; } } -} \ No newline at end of file +} From c630b31bf9dcf73feb7872067bdd6f2bb9d23e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 16:25:36 -0200 Subject: [PATCH 13/34] Yaml tweaks. --- .../.mage/config/environment/production.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/example-config/.mage/config/environment/production.yml b/docs/example-config/.mage/config/environment/production.yml index 3a668f44..538e5172 100644 --- a/docs/example-config/.mage/config/environment/production.yml +++ b/docs/example-config/.mage/config/environment/production.yml @@ -17,15 +17,16 @@ releases: directory: releases hosts: - s01.example.com - s02.example.com: - deployment: - user: toor - to: /home/web/public - releases: - max: 10 - tasks: - on-deploy: - - privileges + - s02.example.com +# s02.example.com: +# deployment: +# user: toor +# to: /home/web/public +# releases: +# max: 10 +# tasks: +# on-deploy: +# - privileges tasks: pre-deploy: - scm/update From 94234cf6d8d526b452f050353702bdf599554b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 17:11:34 -0200 Subject: [PATCH 14/34] Tests --- .../environment/{ioncube.yml => ioncube.yml_} | 0 .../.mage/config/environment/production.yml | 15 -------- .../.mage/config/environment/production.yml_ | 38 +++++++++++++++++++ 3 files changed, 38 insertions(+), 15 deletions(-) rename docs/example-config/.mage/config/environment/{ioncube.yml => ioncube.yml_} (100%) create mode 100644 docs/example-config/.mage/config/environment/production.yml_ diff --git a/docs/example-config/.mage/config/environment/ioncube.yml b/docs/example-config/.mage/config/environment/ioncube.yml_ similarity index 100% rename from docs/example-config/.mage/config/environment/ioncube.yml rename to docs/example-config/.mage/config/environment/ioncube.yml_ diff --git a/docs/example-config/.mage/config/environment/production.yml b/docs/example-config/.mage/config/environment/production.yml index 538e5172..5122d7d6 100644 --- a/docs/example-config/.mage/config/environment/production.yml +++ b/docs/example-config/.mage/config/environment/production.yml @@ -2,11 +2,6 @@ deployment: user: root from: ./ -# source: -# type: git -# repository: git://github.com/andres-montanez/Magallanes.git -# from: master -# temporal: /tmp/myAppClone to: /var/www/vhosts/example.com/www excludes: - application/data/cache/twig/* @@ -18,15 +13,6 @@ releases: hosts: - s01.example.com - s02.example.com -# s02.example.com: -# deployment: -# user: toor -# to: /home/web/public -# releases: -# max: 10 -# tasks: -# on-deploy: -# - privileges tasks: pre-deploy: - scm/update @@ -35,4 +21,3 @@ tasks: - privileges - sampleTask - sampleTaskRollbackAware - #post-deploy: diff --git a/docs/example-config/.mage/config/environment/production.yml_ b/docs/example-config/.mage/config/environment/production.yml_ new file mode 100644 index 00000000..538e5172 --- /dev/null +++ b/docs/example-config/.mage/config/environment/production.yml_ @@ -0,0 +1,38 @@ +#production +deployment: + user: root + from: ./ +# source: +# type: git +# repository: git://github.com/andres-montanez/Magallanes.git +# from: master +# temporal: /tmp/myAppClone + to: /var/www/vhosts/example.com/www + excludes: + - application/data/cache/twig/* +releases: + enabled: true + max: 5 + symlink: current + directory: releases +hosts: + - s01.example.com + - s02.example.com +# s02.example.com: +# deployment: +# user: toor +# to: /home/web/public +# releases: +# max: 10 +# tasks: +# on-deploy: +# - privileges +tasks: + pre-deploy: + - scm/update + on-deploy: + - symfony2/cache-warmup: { env: prod } + - privileges + - sampleTask + - sampleTaskRollbackAware + #post-deploy: From d1fbb9c7db2618bb3eb945447ed42a028cc5c3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 17:14:40 -0200 Subject: [PATCH 15/34] Ioncube Yaml --- .../config/environment/{ioncube.yml_ => ioncube.yml} | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) rename docs/example-config/.mage/config/environment/{ioncube.yml_ => ioncube.yml} (94%) diff --git a/docs/example-config/.mage/config/environment/ioncube.yml_ b/docs/example-config/.mage/config/environment/ioncube.yml similarity index 94% rename from docs/example-config/.mage/config/environment/ioncube.yml_ rename to docs/example-config/.mage/config/environment/ioncube.yml index e2a0848e..9a6037be 100644 --- a/docs/example-config/.mage/config/environment/ioncube.yml_ +++ b/docs/example-config/.mage/config/environment/ioncube.yml @@ -10,11 +10,11 @@ deployment: ioncube: test releases: - enabled: true - symlink: current - directory: releases + enabled: true + symlink: current + directory: releases hosts: - - localhost + - localhost tasks: pre-deploy: - ioncube/encrypt @@ -29,7 +29,6 @@ ioncube: checkignorepaths: - /public/js/* - /public/css/* - projfile: project.prj project: replace-target: @@ -57,7 +56,6 @@ ioncube: - 'Comment 2' - "(c) ACTweb 2013" - "Draft Version" - loader-event: - corrupt-file=Corupted files - expired-file=System needs updated From e40b7d21c9dc069aafacb50a59a9e1451095698f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 17:17:01 -0200 Subject: [PATCH 16/34] Yamls --- .../.mage/config/environment/{ioncube.yml => ioncube.yml.txt} | 0 .../environment/{production.yml_ => production.yml.advanced.txt} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename docs/example-config/.mage/config/environment/{ioncube.yml => ioncube.yml.txt} (100%) rename docs/example-config/.mage/config/environment/{production.yml_ => production.yml.advanced.txt} (100%) diff --git a/docs/example-config/.mage/config/environment/ioncube.yml b/docs/example-config/.mage/config/environment/ioncube.yml.txt similarity index 100% rename from docs/example-config/.mage/config/environment/ioncube.yml rename to docs/example-config/.mage/config/environment/ioncube.yml.txt diff --git a/docs/example-config/.mage/config/environment/production.yml_ b/docs/example-config/.mage/config/environment/production.yml.advanced.txt similarity index 100% rename from docs/example-config/.mage/config/environment/production.yml_ rename to docs/example-config/.mage/config/environment/production.yml.advanced.txt From 2deaa27a2ad433720b2ee2132babd484ddb1ad8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 17:47:07 -0200 Subject: [PATCH 17/34] Tweak clones. --- Mage/Config.php | 31 ++++---------------- Mage/Console.php | 1 - Mage/Task/BuiltIn/Deployment/ReleaseTask.php | 2 +- Mage/Task/BuiltIn/Scm/CloneTask.php | 9 ++++++ 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/Mage/Config.php b/Mage/Config.php index 2991acd4..da1223c5 100644 --- a/Mage/Config.php +++ b/Mage/Config.php @@ -121,29 +121,6 @@ protected function loadGeneral($filePath) return $this->parseConfigFile($filePath); } - - /** - * Obviously this method is a HACK. It was refactored from ::loadEnvironment() - * TODO Please put it to SCM functionality. - * - * @param array $settings - * - * @return array - */ - protected function updateSCMTempDir(array $settings) - { - // Create temporal directory for clone - if (isset($settings['deployment']['source']) && is_array($settings['deployment']['source'])) { - if (trim($settings['deployment']['source']['temporal']) == '') { - $settings['deployment']['source']['temporal'] = sys_get_temp_dir(); - } - $settings['deployment']['source']['temporal'] - = rtrim($settings['deployment']['source']['temporal'], '/') . '/' . md5(microtime()) . '/'; - } - - return $settings; - } - /** * Loads the Environment configuration * @param $filePath string @@ -156,9 +133,6 @@ protected function loadEnvironment($filePath) $settings = $this->parseConfigFile($filePath); - //this is a HACK in the old code - no time to remove it now, so I factored it out in own method - $settings = $this->updateSCMTempDir($settings); - return $settings; } @@ -490,6 +464,11 @@ public function deployment($option, $default = false) } } + public function setSourceTemporal($directory) + { + $this->environmentConfig['deployment']['source']['temporal'] = $directory; + } + /** * Returns Releasing Options * diff --git a/Mage/Console.php b/Mage/Console.php index f1d76092..ea578cc2 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -26,7 +26,6 @@ class Console { /** - * TODO refactor into own static class * @var array */ public static $paramsNotRequiringEnvironment = array('install' => 'install', 'upgrade' => 'upgrade', 'version' => 'version'); diff --git a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php index ceeab5f3..02eeb49d 100644 --- a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php +++ b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php @@ -133,7 +133,7 @@ protected function cleanUpReleases() $directoryToDelete = $releasesDirectory . '/' . $releaseIdToDelete; if ($directoryToDelete != '/') { $command = 'rm -rf ' . $directoryToDelete; - $result = $result && $this->runCommandRemote($command); + $result = $this->runCommandRemote($command); } } } diff --git a/Mage/Task/BuiltIn/Scm/CloneTask.php b/Mage/Task/BuiltIn/Scm/CloneTask.php index f30085fa..c55dd871 100644 --- a/Mage/Task/BuiltIn/Scm/CloneTask.php +++ b/Mage/Task/BuiltIn/Scm/CloneTask.php @@ -53,6 +53,15 @@ public function init() $this->name = 'SCM Clone (GIT) [built-in]'; break; } + + // Create temporal directory for clone + if (is_array($this->source)) { + if (trim($this->source['temporal']) == '') { + $this->source['temporal'] = sys_get_temp_dir(); + } + $this->source['temporal'] = rtrim($this->source['temporal'], '/') . '/' . md5(microtime()) . '/'; + $this->getConfig()->setSourceTemporal($this->source['temporal']); + } } /** From 92b22d52a3603b2b7c8f22b3baadc470ecb3bc36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 17:55:08 -0200 Subject: [PATCH 18/34] Tweak GitRebase and Insight suggestions. --- Mage/Command/Factory.php | 1 - Mage/Config.php | 1 - Mage/Console.php | 1 - .../BuiltIn/Deployment/Strategy/GitRebaseTask.php | 15 --------------- .../BuiltIn/Deployment/Strategy/TarGzTask.php | 1 - Mage/Task/Factory.php | 1 - 6 files changed, 20 deletions(-) diff --git a/Mage/Command/Factory.php b/Mage/Command/Factory.php index 83b669ba..40882397 100644 --- a/Mage/Command/Factory.php +++ b/Mage/Command/Factory.php @@ -12,7 +12,6 @@ use Mage\Command\AbstractCommand; use Mage\Config; -use Mage\Autoload; use Exception; diff --git a/Mage/Config.php b/Mage/Config.php index da1223c5..e839c22c 100644 --- a/Mage/Config.php +++ b/Mage/Config.php @@ -13,7 +13,6 @@ use Mage\Config\ConfigNotFoundException; use Mage\Config\RequiredConfigNotFoundException; use Mage\Console; -use Mage\Yaml\Exception\RuntimeException; use Mage\Yaml\Yaml; use Exception; diff --git a/Mage/Console.php b/Mage/Console.php index ea578cc2..9cb04a0d 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -119,7 +119,6 @@ public function run($arguments) } } - $exceptionOccured = false; // Run Command - Check if there is a Configuration Error if ($configError !== false) { self::output('' . $configError . '', 1, 2); diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/GitRebaseTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/GitRebaseTask.php index a7e47740..b19e06e7 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/GitRebaseTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/GitRebaseTask.php @@ -10,7 +10,6 @@ namespace Mage\Task\BuiltIn\Deployment\Strategy; -use Mage\Task\AbstractTask; use Mage\Task\Releases\IsReleaseAware; /** @@ -35,20 +34,6 @@ public function getName() */ public function run() { - $this->checkOverrideRelease(); - $excludes = $this->getExcludes(); - - // If we are working with releases - $deployToDirectory = $this->getConfig()->deployment('to'); - if ($this->getConfig()->release('enabled', false) == true) { - $releasesDirectory = $this->getConfig()->release('directory', 'releases'); - - $deployToDirectory = rtrim($this->getConfig()->deployment('to'), '/') - . '/' . $releasesDirectory - . '/' . $this->getConfig()->getReleaseId(); - $this->runCommandRemote('mkdir -p ' . $releasesDirectory . '/' . $this->getConfig()->getReleaseId()); - } - $branch = $this->getParameter('branch', 'master'); $remote = $this->getParameter('remote', 'origin'); diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php index 5607a5d2..bea390f5 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php @@ -10,7 +10,6 @@ namespace Mage\Task\BuiltIn\Deployment\Strategy; -use Mage\Console; use Mage\Task\BuiltIn\Deployment\Strategy\BaseStrategyTaskAbstract; use Mage\Task\Releases\IsReleaseAware; diff --git a/Mage/Task/Factory.php b/Mage/Task/Factory.php index fce60505..912026f9 100644 --- a/Mage/Task/Factory.php +++ b/Mage/Task/Factory.php @@ -11,7 +11,6 @@ namespace Mage\Task; use Mage\Config; -use Mage\Autoload; use Exception; From dceb3292119e1d1b440c67ce9d431dbd3afa18e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 17:57:30 -0200 Subject: [PATCH 19/34] Insight tweaks. --- docs/example-config/.mage/tasks/SampleTask.php | 2 +- docs/example-config/.mage/tasks/SampleTaskRollbackAware.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/example-config/.mage/tasks/SampleTask.php b/docs/example-config/.mage/tasks/SampleTask.php index fc9f9a1b..380a4ecf 100644 --- a/docs/example-config/.mage/tasks/SampleTask.php +++ b/docs/example-config/.mage/tasks/SampleTask.php @@ -14,4 +14,4 @@ public function run() { return true; } -} \ No newline at end of file +} diff --git a/docs/example-config/.mage/tasks/SampleTaskRollbackAware.php b/docs/example-config/.mage/tasks/SampleTaskRollbackAware.php index f990e2ce..d9213f4d 100644 --- a/docs/example-config/.mage/tasks/SampleTaskRollbackAware.php +++ b/docs/example-config/.mage/tasks/SampleTaskRollbackAware.php @@ -20,3 +20,4 @@ public function run() return true; } } + From 74087c9dd98ef7c46924e4525dd5f69f306da4f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 18:02:16 -0200 Subject: [PATCH 20/34] Tweak --- Mage/Task/BuiltIn/Deployment/ReleaseTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php index 02eeb49d..84187ad5 100644 --- a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php +++ b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php @@ -133,7 +133,7 @@ protected function cleanUpReleases() $directoryToDelete = $releasesDirectory . '/' . $releaseIdToDelete; if ($directoryToDelete != '/') { $command = 'rm -rf ' . $directoryToDelete; - $result = $this->runCommandRemote($command); + $this->runCommandRemote($command); } } } From 861a823f7ea7b3183b7a7acb8bddabf8944c0d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 11 Oct 2014 21:16:42 -0200 Subject: [PATCH 21/34] Update AbstractTask.php --- Mage/Task/AbstractTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/Task/AbstractTask.php b/Mage/Task/AbstractTask.php index bc12f5f9..663b387c 100644 --- a/Mage/Task/AbstractTask.php +++ b/Mage/Task/AbstractTask.php @@ -223,7 +223,7 @@ protected final function runCommandRemote($command, &$output = null, $cdToDirect */ protected final function runCommand($command, &$output = null) { - if ($this->getStage() == self::STAGE_DEPLOY) { + if ($this->getStage() == self::STAGE_DEPLOY || $this->getStage() == self::STAGE_POST_RELEASE) { return $this->runCommandRemote($command, $output); } else { return $this->runCommandLocal($command, $output); From 308a67359ce675636b88090a78cdbeb8fae19723 Mon Sep 17 00:00:00 2001 From: samuel4x4 Date: Wed, 29 Oct 2014 04:59:58 +0200 Subject: [PATCH 22/34] Add task for force updating a working copy Downloads the latest from remote without trying to merge or rebase anything. Resets the master branch to what you just fetched. Changes all the files in your working tree to match the files in origin/master, so if you have any local changes, they will be lost. --- Mage/Task/BuiltIn/Scm/ForceUpdateTask.php | 87 +++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 Mage/Task/BuiltIn/Scm/ForceUpdateTask.php diff --git a/Mage/Task/BuiltIn/Scm/ForceUpdateTask.php b/Mage/Task/BuiltIn/Scm/ForceUpdateTask.php new file mode 100644 index 00000000..9d68e096 --- /dev/null +++ b/Mage/Task/BuiltIn/Scm/ForceUpdateTask.php @@ -0,0 +1,87 @@ + +* +* For the full copyright and license information, please view the LICENSE +* file that was distributed with this source code. +*/ + +namespace Mage\Task\BuiltIn\Scm; + +use Mage\Task\AbstractTask; +use Mage\Task\SkipException; + +/** + * Task for Force Updating a Working Copy + * + * 'git fetch' downloads the latest from remote without trying to merge or rebase anything. + * 'git reset' resets the master branch to what you just fetched. + * The '--hard' option changes all the files in your working tree to match the files in origin/master, + * so if you have any local changes, they will be lost. + * + * @author Samuel Chiriluta + */ +class ForceUpdateTask extends AbstractTask +{ + /** + * Name of the Task + * @var string + */ + private $name = 'SCM Force Update [built-in]'; + + /** + * (non-PHPdoc) + * @see \Mage\Task\AbstractTask::getName() + */ + public function getName() + { + return $this->name; + } + + /** + * (non-PHPdoc) + * @see \Mage\Task\AbstractTask::init() + */ + public function init() + { + switch ($this->getConfig()->general('scm')) { + case 'git': + $this->name = 'SCM Force Update (GIT) [built-in]'; + break; + } + } + + /** + * Force Updates the Working Copy + * @see \Mage\Task\AbstractTask::run() + */ + public function run() + { + switch ($this->getConfig()->general('scm')) { + case 'git': + $branch = $this->getParameter('branch', 'master'); + $remote = $this->getParameter('remote', 'origin'); + + $command = 'git fetch ' . $remote . ' ' . $branch; + $result = $this->runCommandRemote($command); + + $command = 'git reset --hard ' . $remote . '/' . $branch; + $result = $result && $this->runCommandRemote($command); + + $command = 'git pull ' . $remote . ' ' . $branch; + $result = $result && $this->runCommandRemote($command); + break; + + default: + throw new SkipException; + break; + } + + $result = $this->runCommandLocal($command); + $this->getConfig()->reload(); + + return $result; + } +} From a66478b3abc0463e14c288332cdb3d27ca7bd289 Mon Sep 17 00:00:00 2001 From: Alex V Kotelnikov Date: Wed, 29 Oct 2014 23:16:52 +0400 Subject: [PATCH 23/34] exclude from file added. rebased by upstream --- .../BuiltIn/Deployment/Strategy/RsyncTask.php | 16 ++++++++++++++++ .../BuiltIn/Deployment/Strategy/TarGzTask.php | 19 ++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php index b7ee1b5d..f01d2431 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php @@ -52,6 +52,7 @@ public function run() $this->checkOverrideRelease(); $excludes = $this->getExcludes(); + $excludesListFilePath = $this->getExcludesListFile(); // If we are working with releases $deployToDirectory = $this->getConfig()->deployment('to'); @@ -95,6 +96,7 @@ public function run() . $strategyFlags . ' ' . '--rsh="ssh ' . $this->getConfig()->getHostIdentityFileOption() . '-p' . $this->getConfig()->getHostPort() . '" ' . $this->excludes($excludes) . ' ' + . $this->excludesListFile($excludesListFilePath) . ' ' . $this->getConfig()->deployment('from') . ' ' . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ':' . $deployToDirectory; $result = $this->runCommandLocal($command); @@ -117,4 +119,18 @@ protected function excludes(Array $excludes) $excludesRsync = trim($excludesRsync); return $excludesRsync; } + + /** + * Generates the Exclude from file for rsync + * @param string $excludesFilePath + * @return string + */ + protected function excludesListFile($excludesFilePath) + { + $excludesListFileRsync = ''; + if(!empty($excludesFilePath)) { + $excludesListFileRsync = ' --exclude-from=' . $excludesFilePath; + } + return $excludesListFileRsync; + } } diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php index bea390f5..f5c0031f 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php @@ -46,6 +46,7 @@ public function run() $this->checkOverrideRelease(); $excludes = $this->getExcludes(); + $excludesListFilePath = $this->getExcludesListFile(); // If we are working with releases $deployToDirectory = $this->getConfig()->deployment('to'); @@ -66,6 +67,8 @@ public function run() $excludeCmd .= ' --exclude=' . $excludeFile; } + $excludeFromFileCmd = $this->excludesListFile($excludesListFilePath); + // Strategy Flags $strategyFlags = $this->getConfig()->deployment('strategy_flags', $this->getConfig()->general('strategy_flags', array())); if (isset($strategyFlags['targz']) && isset($strategyFlags['targz']['create'])) { @@ -74,7 +77,7 @@ public function run() $strategyFlags = ''; } - $command = 'tar cfzh' . $strategyFlags . ' ' . $localTarGz . '.tar.gz ' . $excludeCmd . ' -C ' . $this->getConfig()->deployment('from') . ' .'; + $command = 'tar cfzh' . $strategyFlags . ' ' . $localTarGz . '.tar.gz ' . $excludeCmd . $excludeFromFileCmd . ' -C ' . $this->getConfig()->deployment('from') . ' .'; $result = $this->runCommandLocal($command); // Strategy Flags @@ -112,4 +115,18 @@ public function run() return $result; } + + /** + * Generates the Exclude from file for TarGz + * @param string $excludesFilePath + * @return string + */ + protected function excludesListFile($excludesFilePath) + { + $excludesListFileRsync = ''; + if(!empty($excludesFilePath)) { + $excludesListFileRsync = ' --exclude-from=' . $excludesFilePath; + } + return $excludesListFileRsync; + } } From 95f09dc3c9987a8b54532192ace68370b555d315 Mon Sep 17 00:00:00 2001 From: Alex V Kotelnikov Date: Thu, 30 Oct 2014 12:31:05 +0400 Subject: [PATCH 24/34] small fixes @ rsync and targz tasks --- Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php | 2 +- Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php index f01d2431..b8b1dc62 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php @@ -52,7 +52,7 @@ public function run() $this->checkOverrideRelease(); $excludes = $this->getExcludes(); - $excludesListFilePath = $this->getExcludesListFile(); + $excludesListFilePath = $this->getConfig()->deployment('file_containing_excludes', ''); // If we are working with releases $deployToDirectory = $this->getConfig()->deployment('to'); diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php index f5c0031f..7b9dcfe4 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php @@ -46,7 +46,7 @@ public function run() $this->checkOverrideRelease(); $excludes = $this->getExcludes(); - $excludesListFilePath = $this->getExcludesListFile(); + $excludesListFilePath = $this->getConfig()->deployment('file_containing_excludes', '');; // If we are working with releases $deployToDirectory = $this->getConfig()->deployment('to'); From 6f551cabf00e73bd1b6efc91e2ff1357a807715c Mon Sep 17 00:00:00 2001 From: Alex V Kotelnikov Date: Sun, 28 Sep 2014 00:42:15 +0400 Subject: [PATCH 25/34] added relative linking @ Link shared files task --- .../Filesystem/LinkSharedFilesTask.php | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php index 86dc6459..105513cb 100644 --- a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php +++ b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php @@ -8,6 +8,8 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware { + const ABSOLUTE_LINKING = 'absolute'; + const RELATIVE_LINKING = 'relative'; /** * Returns the Title of the Task * @return string @@ -25,28 +27,36 @@ public function getName() */ public function run() { - $linkedFiles = $this->getParameter('linked_files', []); - $linkedFolders = $this->getParameter('linked_folders', []); + $linkedFiles = $this->getParameter('linked_files', []); + $linkedFolders = $this->getParameter('linked_folders', []); + $linkingStrategy = $this->getParameter('linking_stategy', self::ABSOLUTE_LINKING); + + $linkedEntities = array_merge($linkedFiles,$linkedFolders); + if (sizeof($linkedFiles) == 0 && sizeof($linkedFolders) == 0) { throw new SkipException('No files and folders configured for sym-linking.'); } $sharedFolderName = $this->getParameter('shared', 'shared'); - $sharedFolderName = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $sharedFolderName; + $sharedFolderPath = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $sharedFolderName; $releasesDirectory = $this->getConfig()->release('directory', 'releases'); - $releasesDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory; - - $currentCopy = $releasesDirectory . '/' . $this->getConfig()->getReleaseId(); - foreach ($linkedFolders as $folder) { - $command = "ln -nfs $sharedFolderName/$folder $currentCopy/$folder"; - $this->runCommandRemote($command); - } - - foreach ($linkedFiles as $folder) { - $command = "ln -nfs $sharedFolderName/$folder $currentCopy/$folder"; + $releasesDirectoryPath = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory; + + $currentCopy = $releasesDirectoryPath . '/' . $this->getConfig()->getReleaseId(); + if($linkingStrategy==self::RELATIVE_LINKING) + $relativeDiffPath = str_replace($this->getConfig()->deployment('to'),'',$currentCopy) . '/'; + + foreach ($linkedEntities as $entityPath) { + $sharedEntityLinkedPath = "$sharedFolderPath/$entityPath"; + if($linkingStrategy==self::RELATIVE_LINKING) { + $parentFolderPath = dirname($entityPath); + $relativePath = empty($parentFolderPath)?$relativeDiffPath:$relativeDiffPath.$parentFolderPath.'/'; + $sharedEntityLinkedPath = ltrim(preg_replace('/(\w+\/)/', '../', $relativePath),'/').$sharedFolderName .'/'. $entityPath; + } + $command = "ln -nfs $sharedEntityLinkedPath $currentCopy/$entityPath"; $this->runCommandRemote($command); } return true; } -} +} \ No newline at end of file From 0a1457312660bb590bce8b2b874ee44190e223fd Mon Sep 17 00:00:00 2001 From: Alex V Kotelnikov Date: Sun, 28 Sep 2014 16:59:09 +0400 Subject: [PATCH 26/34] relative linking @ Link shared files task. Added exclusion rules to symlinks creation. --- .../Filesystem/LinkSharedFilesTask.php | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php index 105513cb..6ceaa16e 100644 --- a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php +++ b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php @@ -8,8 +8,16 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware { + const LINKED_FOLDERS = 'linked_folders'; + const LINKED_STRATEGY = 'linking_stategy'; + const ABSOLUTE_LINKING = 'absolute'; const RELATIVE_LINKING = 'relative'; + + public $linkingStrategies = array( + self::ABSOLUTE_LINKING, + self::RELATIVE_LINKING + ); /** * Returns the Title of the Task * @return string @@ -28,8 +36,8 @@ public function getName() public function run() { $linkedFiles = $this->getParameter('linked_files', []); - $linkedFolders = $this->getParameter('linked_folders', []); - $linkingStrategy = $this->getParameter('linking_stategy', self::ABSOLUTE_LINKING); + $linkedFolders = $this->getParameter(self::LINKED_FOLDERS, []); + $linkingStrategy = $this->getParameter(self::LINKED_STRATEGY, self::ABSOLUTE_LINKING); $linkedEntities = array_merge($linkedFiles,$linkedFolders); @@ -43,14 +51,19 @@ public function run() $releasesDirectoryPath = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory; $currentCopy = $releasesDirectoryPath . '/' . $this->getConfig()->getReleaseId(); - if($linkingStrategy==self::RELATIVE_LINKING) - $relativeDiffPath = str_replace($this->getConfig()->deployment('to'),'',$currentCopy) . '/'; + $relativeDiffPath = str_replace($this->getConfig()->deployment('to'),'',$currentCopy) . '/'; - foreach ($linkedEntities as $entityPath) { + foreach ($linkedEntities as $ePath) { + if(is_array($ePath) && in_array($strategy = reset($ePath), $this->linkingStrategies ) ) { + $entityPath = key($ePath); + } else { + $strategy = $linkingStrategy; + $entityPath = $ePath; + } $sharedEntityLinkedPath = "$sharedFolderPath/$entityPath"; - if($linkingStrategy==self::RELATIVE_LINKING) { + if($strategy==self::RELATIVE_LINKING) { $parentFolderPath = dirname($entityPath); - $relativePath = empty($parentFolderPath)?$relativeDiffPath:$relativeDiffPath.$parentFolderPath.'/'; + $relativePath = $parentFolderPath=='.'?$relativeDiffPath:$relativeDiffPath.$parentFolderPath.'/'; $sharedEntityLinkedPath = ltrim(preg_replace('/(\w+\/)/', '../', $relativePath),'/').$sharedFolderName .'/'. $entityPath; } $command = "ln -nfs $sharedEntityLinkedPath $currentCopy/$entityPath"; From 50e2d6eeb582ff4f6c8fdf863652cfc7cc0c40fc Mon Sep 17 00:00:00 2001 From: Alex V Kotelnikov Date: Mon, 29 Sep 2014 13:02:20 +0400 Subject: [PATCH 27/34] small fixes @ link shared files task. wrong constant value --- Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php index 6ceaa16e..4ed89a18 100644 --- a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php +++ b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php @@ -9,7 +9,7 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware { const LINKED_FOLDERS = 'linked_folders'; - const LINKED_STRATEGY = 'linking_stategy'; + const LINKED_STRATEGY = 'linking_strategy'; const ABSOLUTE_LINKING = 'absolute'; const RELATIVE_LINKING = 'relative'; From 438a81542e99124e54253810dfa98216a7fd2b91 Mon Sep 17 00:00:00 2001 From: Alex V Kotelnikov Date: Thu, 30 Oct 2014 23:49:01 +0400 Subject: [PATCH 28/34] changes @ deploy command. added rollback exception functionality. --- Mage/Command/BuiltIn/DeployCommand.php | 28 ++++++++++++++++++++++++++ Mage/Task/RollbackException.php | 23 +++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 Mage/Task/RollbackException.php diff --git a/Mage/Command/BuiltIn/DeployCommand.php b/Mage/Command/BuiltIn/DeployCommand.php index 3719c49b..e412d926 100644 --- a/Mage/Command/BuiltIn/DeployCommand.php +++ b/Mage/Command/BuiltIn/DeployCommand.php @@ -3,6 +3,7 @@ * This file is part of the Magallanes package. * * (c) Andrés Montañez +* (c) Alex V Kotelnikov * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. @@ -16,6 +17,7 @@ use Mage\Task\AbstractTask; use Mage\Task\Releases\SkipOnOverride; use Mage\Task\ErrorWithMessageException; +use Mage\Task\RollbackException; use Mage\Task\SkipException; use Mage\Console; use Mage\Config; @@ -428,6 +430,27 @@ protected function runDeploymentTasks() } } + protected function runRollbackTask(){ + $hosts = $this->getConfig()->getHosts(); + + if (count($hosts) == 0) { + Console::output('Warning! No hosts defined, unable to get releases.', 1, 3); + + } else { + $result = true; + foreach ($hosts as $host) { + $this->getConfig()->setHost($host); + + $this->getConfig()->setReleaseId(-1); + $task = Factory::get('releases/rollback', $this->getConfig()); + $task->init(); + $result = $task->run() && $result; + } + return $result; + } + return false; + } + /** * Runs a Task * @@ -461,6 +484,11 @@ protected function runTask(AbstractTask $task, $title = null) Console::output('FAIL', 0); $result = false; } + } catch (RollbackException $e) { + Console::output('FAIL, Rollback started [Message: ' . $e->getMessage() . ']', 0); + $this->runRollbackTask(); + $result = false; + } catch (ErrorWithMessageException $e) { Console::output('FAIL [Message: ' . $e->getMessage() . ']', 0); $result = false; diff --git a/Mage/Task/RollbackException.php b/Mage/Task/RollbackException.php new file mode 100644 index 00000000..d2e56df5 --- /dev/null +++ b/Mage/Task/RollbackException.php @@ -0,0 +1,23 @@ + +* +* For the full copyright and license information, please view the LICENSE +* file that was distributed with this source code. +*/ + +namespace Mage\Task; + +use Exception; + +/** + * Exception that indicates that the Task was Failed and rollback needed + * + * @author Alex V Kotelnikov + */ +class RollbackException extends Exception +{ + +} \ No newline at end of file From b924b922409b6204dd3f691b5ad0342b11831409 Mon Sep 17 00:00:00 2001 From: Alex V Kotelnikov Date: Fri, 31 Oct 2014 00:03:31 +0400 Subject: [PATCH 29/34] added config reload @ after rollback exception --- Mage/Command/BuiltIn/DeployCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Mage/Command/BuiltIn/DeployCommand.php b/Mage/Command/BuiltIn/DeployCommand.php index e412d926..bbff2b64 100644 --- a/Mage/Command/BuiltIn/DeployCommand.php +++ b/Mage/Command/BuiltIn/DeployCommand.php @@ -431,6 +431,7 @@ protected function runDeploymentTasks() } protected function runRollbackTask(){ + $this->getConfig()->reload(); $hosts = $this->getConfig()->getHosts(); if (count($hosts) == 0) { From df632b3fe3c52cf85825c0e1e156201eb39d484e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 1 Nov 2014 18:15:39 -0200 Subject: [PATCH 30/34] Tweak excludes files. --- Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php | 10 +++++----- Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php index b8b1dc62..3555ce03 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php @@ -52,7 +52,7 @@ public function run() $this->checkOverrideRelease(); $excludes = $this->getExcludes(); - $excludesListFilePath = $this->getConfig()->deployment('file_containing_excludes', ''); + $excludesListFilePath = $this->getConfig()->deployment('excludes_file', ''); // If we are working with releases $deployToDirectory = $this->getConfig()->deployment('to'); @@ -122,14 +122,14 @@ protected function excludes(Array $excludes) /** * Generates the Exclude from file for rsync - * @param string $excludesFilePath + * @param string $excludesFile * @return string */ - protected function excludesListFile($excludesFilePath) + protected function excludesListFile($excludesFile) { $excludesListFileRsync = ''; - if(!empty($excludesFilePath)) { - $excludesListFileRsync = ' --exclude-from=' . $excludesFilePath; + if(!empty($excludesFile) && file_exists($excludesFile) && is_file($excludesFile) && is_readable($excludesFile)) { + $excludesListFileRsync = ' --exclude-from=' . $excludesFile; } return $excludesListFileRsync; } diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php index 7b9dcfe4..d45ea17a 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php @@ -46,7 +46,7 @@ public function run() $this->checkOverrideRelease(); $excludes = $this->getExcludes(); - $excludesListFilePath = $this->getConfig()->deployment('file_containing_excludes', '');; + $excludesListFilePath = $this->getConfig()->deployment('excludes_file', '');; // If we are working with releases $deployToDirectory = $this->getConfig()->deployment('to'); @@ -117,15 +117,15 @@ public function run() } /** - * Generates the Exclude from file for TarGz - * @param string $excludesFilePath + * Generates the Exclude from file for rsync + * @param string $excludesFile * @return string */ - protected function excludesListFile($excludesFilePath) + protected function excludesListFile($excludesFile) { $excludesListFileRsync = ''; - if(!empty($excludesFilePath)) { - $excludesListFileRsync = ' --exclude-from=' . $excludesFilePath; + if(!empty($excludesFile) && file_exists($excludesFile) && is_file($excludesFile) && is_readable($excludesFile)) { + $excludesListFileRsync = ' --exclude-from=' . $excludesFile; } return $excludesListFileRsync; } From 8771cf2ab1ce0df8fb310400e208878d30120db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 1 Nov 2014 19:09:25 -0200 Subject: [PATCH 31/34] Fixes #131 --- Mage/Command/BuiltIn/ReleasesCommand.php | 11 ++++++++++- Mage/Command/BuiltIn/RollbackCommand.php | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Mage/Command/BuiltIn/ReleasesCommand.php b/Mage/Command/BuiltIn/ReleasesCommand.php index 28379036..e9f04432 100644 --- a/Mage/Command/BuiltIn/ReleasesCommand.php +++ b/Mage/Command/BuiltIn/ReleasesCommand.php @@ -44,8 +44,17 @@ public function run() } $result = true; - foreach ($hosts as $host) { + foreach ($hosts as $hostKey => $host) { + // Check if Host has specific configuration + $hostConfig = null; + if (is_array($host)) { + $hostConfig = $host; + $host = $hostKey; + } + + // Set Host and Host Specific Config $this->getConfig()->setHost($host); + $this->getConfig()->setHostConfig($hostConfig); switch ($subCommand) { case 'list': diff --git a/Mage/Command/BuiltIn/RollbackCommand.php b/Mage/Command/BuiltIn/RollbackCommand.php index 7a5b85b4..10238690 100644 --- a/Mage/Command/BuiltIn/RollbackCommand.php +++ b/Mage/Command/BuiltIn/RollbackCommand.php @@ -51,8 +51,17 @@ public function run() } else { $result = true; - foreach ($hosts as $host) { + foreach ($hosts as $hostKey => $host) { + // Check if Host has specific configuration + $hostConfig = null; + if (is_array($host)) { + $hostConfig = $host; + $host = $hostKey; + } + + // Set Host and Host Specific Config $this->getConfig()->setHost($host); + $this->getConfig()->setHostConfig($hostConfig); $this->getConfig()->setReleaseId($releaseId); $task = Factory::get('releases/rollback', $this->getConfig()); From 40e8c33846089fd86cd2ac4c7c1b836ad86d05d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 1 Nov 2014 19:19:05 -0200 Subject: [PATCH 32/34] Related to #130 --- Mage/Command/BuiltIn/CompileCommand.php | 2 +- Mage/Command/BuiltIn/DeployCommand.php | 6 +++--- Mage/Command/BuiltIn/ListCommand.php | 4 ++-- Mage/Command/BuiltIn/ReleasesCommand.php | 8 ++++---- Mage/Command/BuiltIn/RollbackCommand.php | 6 +++--- Mage/Command/BuiltIn/UpgradeCommand.php | 2 +- bin/mage | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Mage/Command/BuiltIn/CompileCommand.php b/Mage/Command/BuiltIn/CompileCommand.php index f67e8755..9cd94b66 100644 --- a/Mage/Command/BuiltIn/CompileCommand.php +++ b/Mage/Command/BuiltIn/CompileCommand.php @@ -28,7 +28,7 @@ public function run() { if (ini_get('phar.readonly')) { Console::output('The php.ini variable phar.readonly must be Off.', 1, 2); - return 300; + return 200; } $compiler = new Compiler; diff --git a/Mage/Command/BuiltIn/DeployCommand.php b/Mage/Command/BuiltIn/DeployCommand.php index bbff2b64..8efa11a2 100644 --- a/Mage/Command/BuiltIn/DeployCommand.php +++ b/Mage/Command/BuiltIn/DeployCommand.php @@ -111,20 +111,20 @@ public static function getStatus() */ public function run() { - $exitCode = 1000; + $exitCode = 240; // Check if Environment is not Locked $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock'; if (file_exists($lockFile)) { Console::output('This environment is locked!', 1, 2); echo file_get_contents($lockFile); - return 1010; + return 231; } // Check for running instance and Lock if (file_exists(getcwd() . '/.mage/~working.lock')) { Console::output('There is already an instance of Magallanes running!', 1, 2); - return 1020; + return 230; } else { touch(getcwd() . '/.mage/~working.lock'); } diff --git a/Mage/Command/BuiltIn/ListCommand.php b/Mage/Command/BuiltIn/ListCommand.php index 48e89bf7..8c3561a7 100644 --- a/Mage/Command/BuiltIn/ListCommand.php +++ b/Mage/Command/BuiltIn/ListCommand.php @@ -31,7 +31,7 @@ class ListCommand extends AbstractCommand */ public function run() { - $exitCode = 600; + $exitCode = 221; $subCommand = $this->getConfig()->getArgument(1); try { @@ -56,7 +56,7 @@ public function run() */ protected function listEnvironments() { - $exitCode = 600; + $exitCode = 220; $environments = array(); $content = scandir(getcwd() . '/.mage/config/environment/'); foreach ($content as $file) { diff --git a/Mage/Command/BuiltIn/ReleasesCommand.php b/Mage/Command/BuiltIn/ReleasesCommand.php index e9f04432..be8b502e 100644 --- a/Mage/Command/BuiltIn/ReleasesCommand.php +++ b/Mage/Command/BuiltIn/ReleasesCommand.php @@ -28,7 +28,7 @@ class ReleasesCommand extends AbstractCommand implements RequiresEnvironment */ public function run() { - $exitCode = 400; + $exitCode = 100; $subCommand = $this->getConfig()->getArgument(1); // Run Tasks for Deployment @@ -40,7 +40,7 @@ public function run() 1, 3 ); - return 401; + return 101; } $result = true; @@ -67,7 +67,7 @@ public function run() if (!is_numeric($this->getConfig()->getParameter('release', ''))) { Console::output('Missing required releaseid.', 1, 2); - return 410; + return 102; } $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock'; @@ -75,7 +75,7 @@ public function run() Console::output('This environment is locked!', 1, 2); echo file_get_contents($lockFile); - return 420; + return 103; } $releaseId = $this->getConfig()->getParameter('release', ''); diff --git a/Mage/Command/BuiltIn/RollbackCommand.php b/Mage/Command/BuiltIn/RollbackCommand.php index 10238690..12a8f4e6 100644 --- a/Mage/Command/BuiltIn/RollbackCommand.php +++ b/Mage/Command/BuiltIn/RollbackCommand.php @@ -28,19 +28,19 @@ class RollbackCommand extends AbstractCommand implements RequiresEnvironment */ public function run() { - $exitCode = 450; + $exitCode = 105; $releaseId = $this->getConfig()->getArgument(1); if (!is_numeric($releaseId)) { Console::output('This release is mandatory.', 1, 2); - return 451; + return 104; } $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock'; if (file_exists($lockFile)) { Console::output('This environment is locked!', 1, 2); echo file_get_contents($lockFile); - return 20; + return 106; } // Run Tasks for Deployment diff --git a/Mage/Command/BuiltIn/UpgradeCommand.php b/Mage/Command/BuiltIn/UpgradeCommand.php index 5de6a2d3..7e5aae0d 100644 --- a/Mage/Command/BuiltIn/UpgradeCommand.php +++ b/Mage/Command/BuiltIn/UpgradeCommand.php @@ -38,7 +38,7 @@ class UpgradeCommand extends AbstractCommand */ public function run() { - $exitCode = 100; + $exitCode = 99; Console::output('Upgrading Magallanes ... ', 1, 0); $user = ''; diff --git a/bin/mage b/bin/mage index b668d45a..b5d201eb 100755 --- a/bin/mage +++ b/bin/mage @@ -32,4 +32,4 @@ array_shift($argv); $console = new Mage\Console; $exitCode = $console->run($argv); -exit($exitCode); +exit((integer) $exitCode); From c34fa53af5121c4593565e544138a1c6836f4e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 1 Nov 2014 19:31:04 -0200 Subject: [PATCH 33/34] Fixes #121 --- Mage/Command/BuiltIn/AddCommand.php | 8 ++-- Mage/Command/BuiltIn/DeployCommand.php | 44 ++++++++++----------- Mage/Command/BuiltIn/InitCommand.php | 8 ++-- Mage/Command/BuiltIn/InstallCommand.php | 2 +- Mage/Command/BuiltIn/ListCommand.php | 4 +- Mage/Command/BuiltIn/ReleasesCommand.php | 2 +- Mage/Command/BuiltIn/RollbackCommand.php | 2 +- Mage/Command/BuiltIn/UpgradeCommand.php | 4 +- Mage/Command/BuiltIn/VersionCommand.php | 2 +- Mage/Console.php | 2 +- Mage/Console/Colors.php | 2 +- Mage/Task/BuiltIn/Releases/ListTask.php | 8 ++-- Mage/Task/BuiltIn/Releases/RollbackTask.php | 8 ++-- 13 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Mage/Command/BuiltIn/AddCommand.php b/Mage/Command/BuiltIn/AddCommand.php index fab6f713..d7b1d12a 100644 --- a/Mage/Command/BuiltIn/AddCommand.php +++ b/Mage/Command/BuiltIn/AddCommand.php @@ -68,7 +68,7 @@ protected function addEnvironment() throw new Exception('The environment already exists.'); } - Console::output('Adding new environment: ' . $environmentName . ''); + Console::output('Adding new environment: ' . $environmentName . ''); $releasesConfig = 'releases:' . PHP_EOL . ' enabled: true' . PHP_EOL @@ -93,10 +93,10 @@ protected function addEnvironment() $result = file_put_contents($environmentConfigFile, $baseConfig); if ($result) { - Console::output('Success!! Environment config file for ' . $environmentName . ' created successfully at ' . $environmentConfigFile . ''); - Console::output('So please! Review and adjust its configuration.', 2, 2); + Console::output('Success!! Environment config file for ' . $environmentName . ' created successfully at ' . $environmentConfigFile . ''); + Console::output('So please! Review and adjust its configuration.', 2, 2); } else { - Console::output('Error!! Unable to create config file for environment called ' . $environmentName . '', 1, 2); + Console::output('Error!! Unable to create config file for environment called ' . $environmentName . '', 1, 2); } } } diff --git a/Mage/Command/BuiltIn/DeployCommand.php b/Mage/Command/BuiltIn/DeployCommand.php index 8efa11a2..943a6309 100644 --- a/Mage/Command/BuiltIn/DeployCommand.php +++ b/Mage/Command/BuiltIn/DeployCommand.php @@ -133,21 +133,21 @@ public function run() $this->getConfig()->setReleaseId(date('YmdHis')); // Deploy Summary - Console::output('Deploy summary', 1, 1); + Console::output('Deploy summary', 1, 1); // Deploy Summary - Environment - Console::output('Environment: ' . $this->getConfig()->getEnvironment() . '', 2, 1); + Console::output('Environment: ' . $this->getConfig()->getEnvironment() . '', 2, 1); // Deploy Summary - Releases if ($this->getConfig()->release('enabled', false)) { - Console::output('Release ID: ' . $this->getConfig()->getReleaseId() . '', 2, 1); + Console::output('Release ID: ' . $this->getConfig()->getReleaseId() . '', 2, 1); } // Deploy Summary - SCM if ($this->getConfig()->deployment('scm', false)) { $scmConfig = $this->getConfig()->deployment('scm'); if (isset($scmConfig['branch'])) { - Console::output('SCM Branch: ' . $scmConfig['branch'] . '', 2, 1); + Console::output('SCM Branch: ' . $scmConfig['branch'] . '', 2, 1); } } @@ -162,7 +162,7 @@ public function run() // Check Status if (self::$failedTasks > 0) { self::$deployStatus = self::FAILED; - Console::output('A total of ' . self::$failedTasks . ' deployment tasks failed: ABORTING', 1, 2); + Console::output('A total of ' . self::$failedTasks . ' deployment tasks failed: ABORTING', 1, 2); } else { // Run Deployment Tasks @@ -171,7 +171,7 @@ public function run() // Check Status if (self::$failedTasks > 0) { self::$deployStatus = self::FAILED; - Console::output('A total of ' . self::$failedTasks . ' deployment tasks failed: ABORTING', 1, 2); + Console::output('A total of ' . self::$failedTasks . ' deployment tasks failed: ABORTING', 1, 2); } // Run Post-Deployment Tasks @@ -181,15 +181,15 @@ public function run() // Time Information Hosts if ($this->hostsCount > 0) { $timeTextHost = $this->transcurredTime($this->endTimeHosts - $this->startTimeHosts); - Console::output('Time for deployment: ' . $timeTextHost . '.'); + Console::output('Time for deployment: ' . $timeTextHost . '.'); $timeTextPerHost = $this->transcurredTime(round(($this->endTimeHosts - $this->startTimeHosts) / $this->hostsCount)); - Console::output('Average time per host: ' . $timeTextPerHost . '.'); + Console::output('Average time per host: ' . $timeTextPerHost . '.'); } // Time Information General $timeText = $this->transcurredTime(time() - $this->startTime); - Console::output('Total time: ' . $timeText . '.', 1, 2); + Console::output('Total time: ' . $timeText . '.', 1, 2); // Send Notifications $this->sendNotification(self::$failedTasks > 0 ? false : true); @@ -251,10 +251,10 @@ protected function runNonDeploymentTasks($stage, Config $config, $title) } if (count($tasksToRun) == 0) { - Console::output('No ' . $title . ' tasks defined.', 1, 3); + Console::output('No ' . $title . ' tasks defined.', 1, 3); } else { - Console::output('Starting ' . $title . ' tasks:'); + Console::output('Starting ' . $title . ' tasks:'); $tasks = 0; $completedTasks = 0; @@ -276,7 +276,7 @@ protected function runNonDeploymentTasks($stage, Config $config, $title) $tasksColor = 'red'; } - Console::output('Finished ' . $title . ' tasks: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . ' tasks done.', 1, 3); + Console::output('Finished ' . $title . ' tasks: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . ' tasks done.', 1, 3); } } @@ -292,7 +292,7 @@ protected function runDeploymentTasks() self::$failedTasks = 0; if ($this->hostsCount == 0) { - Console::output('Warning! No hosts defined, skipping deployment tasks.', 1, 3); + Console::output('Warning! No hosts defined, skipping deployment tasks.', 1, 3); } else { $this->startTimeHosts = time(); @@ -313,7 +313,7 @@ protected function runDeploymentTasks() $tasks = 0; $completedTasks = 0; - Console::output('Deploying to ' . $this->getConfig()->getHost() . ''); + Console::output('Deploying to ' . $this->getConfig()->getHost() . ''); $tasksToRun = $this->getConfig()->getTasks(); @@ -322,8 +322,8 @@ protected function runDeploymentTasks() array_unshift($tasksToRun, $deployStrategy); if (count($tasksToRun) == 0) { - Console::output('Warning! No Deployment tasks defined.', 2); - Console::output('Deployment to ' . $host . ' skipped!', 1, 3); + Console::output('Warning! No Deployment tasks defined.', 2); + Console::output('Deployment to ' . $host . ' skipped!', 1, 3); } else { foreach ($tasksToRun as $taskData) { @@ -343,7 +343,7 @@ protected function runDeploymentTasks() $tasksColor = 'red'; } - Console::output('Deployment to ' . $this->getConfig()->getHost() . ' completed: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . ' tasks done.', 1, 3); + Console::output('Deployment to ' . $this->getConfig()->getHost() . ' completed: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . ' tasks done.', 1, 3); } // Reset Host Config @@ -360,7 +360,7 @@ protected function runDeploymentTasks() // Releasing if (self::$deployStatus == self::SUCCEDED && $this->getConfig()->release('enabled', false) === true) { // Execute the Releases - Console::output('Starting the Releasing'); + Console::output('Starting the Releasing'); $completedTasks = 0; foreach ($hosts as $hostKey => $host) { @@ -384,7 +384,7 @@ protected function runDeploymentTasks() // Reset Host Config $this->getConfig()->setHostConfig(null); } - Console::output('Finished the Releasing', 1, 3); + Console::output('Finished the Releasing', 1, 3); // Execute the Post-Release Tasks foreach ($hosts as $hostKey => $host) { @@ -405,7 +405,7 @@ protected function runDeploymentTasks() $completedTasks = 0; if (count($tasksToRun) > 0) { - Console::output('Starting Post-Release tasks for ' . $host . ':'); + Console::output('Starting Post-Release tasks for ' . $host . ':'); foreach ($tasksToRun as $task) { $task = Factory::get($task, $this->getConfig(), false, AbstractTask::STAGE_POST_RELEASE); @@ -420,7 +420,7 @@ protected function runDeploymentTasks() } else { $tasksColor = 'red'; } - Console::output('Finished Post-Release tasks for ' . $host . ': <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . ' tasks done.', 1, 3); + Console::output('Finished Post-Release tasks for ' . $host . ': <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . ' tasks done.', 1, 3); } // Reset Host Config @@ -435,7 +435,7 @@ protected function runRollbackTask(){ $hosts = $this->getConfig()->getHosts(); if (count($hosts) == 0) { - Console::output('Warning! No hosts defined, unable to get releases.', 1, 3); + Console::output('Warning! No hosts defined, unable to get releases.', 1, 3); } else { $result = true; diff --git a/Mage/Command/BuiltIn/InitCommand.php b/Mage/Command/BuiltIn/InitCommand.php index f9963350..90d665f0 100644 --- a/Mage/Command/BuiltIn/InitCommand.php +++ b/Mage/Command/BuiltIn/InitCommand.php @@ -30,11 +30,11 @@ public function run() $exitCode = 50; $configDir = getcwd() . '/.mage'; - Console::output('Initiating managing process for application with Magallanes'); + Console::output('Initiating managing process for application with Magallanes'); // Check if there is already a config dir if (file_exists($configDir)) { - Console::output('Error!! Already exists .mage directory.', 1, 2); + Console::output('Error!! Already exists .mage directory.', 1, 2); } else { $results = array(); $results[] = mkdir($configDir); @@ -48,8 +48,8 @@ public function run() $results[] = file_put_contents($configDir . '/config/general.yml', $this->getGeneralConfig()); if (!in_array(false, $results)) { - Console::output('Success!! The configuration for Magallanes has been generated at .mage directory.'); - Console::output('Please!! Review and adjust the configuration.', 2, 2); + Console::output('Success!! The configuration for Magallanes has been generated at .mage directory.'); + Console::output('Please!! Review and adjust the configuration.', 2, 2); $exitCode = 0; } else { diff --git a/Mage/Command/BuiltIn/InstallCommand.php b/Mage/Command/BuiltIn/InstallCommand.php index 932b3c09..4271d43b 100644 --- a/Mage/Command/BuiltIn/InstallCommand.php +++ b/Mage/Command/BuiltIn/InstallCommand.php @@ -27,7 +27,7 @@ class InstallCommand extends AbstractCommand public function run() { $exitCode = 88; - Console::output('Installing Magallanes... ', 1, 0); + Console::output('Installing Magallanes... ', 1, 0); // Vars $installDir = $this->getConfig()->getParameter('installDir', '/opt/magallanes'); diff --git a/Mage/Command/BuiltIn/ListCommand.php b/Mage/Command/BuiltIn/ListCommand.php index 8c3561a7..0d278628 100644 --- a/Mage/Command/BuiltIn/ListCommand.php +++ b/Mage/Command/BuiltIn/ListCommand.php @@ -67,7 +67,7 @@ protected function listEnvironments() sort($environments); if (count($environments) > 0) { - Console::output('These are your configured environments:', 1, 1); + Console::output('These are your configured environments:', 1, 1); foreach ($environments as $environment) { Console::output('* ' . $environment . '', 2, 1); } @@ -75,7 +75,7 @@ protected function listEnvironments() $exitCode = 0; } else { - Console::output('You don\'t have any environment configured.', 1, 2); + Console::output('You don\'t have any environment configured.', 1, 2); } return $exitCode; diff --git a/Mage/Command/BuiltIn/ReleasesCommand.php b/Mage/Command/BuiltIn/ReleasesCommand.php index be8b502e..3a40439e 100644 --- a/Mage/Command/BuiltIn/ReleasesCommand.php +++ b/Mage/Command/BuiltIn/ReleasesCommand.php @@ -36,7 +36,7 @@ public function run() if (count($hosts) == 0) { Console::output( - 'Warning! No hosts defined, unable to get releases.', + 'Warning! No hosts defined, unable to get releases.', 1, 3 ); diff --git a/Mage/Command/BuiltIn/RollbackCommand.php b/Mage/Command/BuiltIn/RollbackCommand.php index 12a8f4e6..8d85ac80 100644 --- a/Mage/Command/BuiltIn/RollbackCommand.php +++ b/Mage/Command/BuiltIn/RollbackCommand.php @@ -47,7 +47,7 @@ public function run() $hosts = $this->getConfig()->getHosts(); if (count($hosts) == 0) { - Console::output('Warning! No hosts defined, unable to get releases.', 1, 3); + Console::output('Warning! No hosts defined, unable to get releases.', 1, 3); } else { $result = true; diff --git a/Mage/Command/BuiltIn/UpgradeCommand.php b/Mage/Command/BuiltIn/UpgradeCommand.php index 7e5aae0d..94fe6e05 100644 --- a/Mage/Command/BuiltIn/UpgradeCommand.php +++ b/Mage/Command/BuiltIn/UpgradeCommand.php @@ -39,7 +39,7 @@ class UpgradeCommand extends AbstractCommand public function run() { $exitCode = 99; - Console::output('Upgrading Magallanes ... ', 1, 0); + Console::output('Upgrading Magallanes ... ', 1, 0); $user = ''; // Check if user is root @@ -49,7 +49,7 @@ public function run() if ($user != 'root' && $user != $owner) { Console::output('FAIL', 0, 1); - Console::output('You need to be the ' . $owner . ' user to perform the upgrade, or root.', 2); + Console::output('You need to be the ' . $owner . ' user to perform the upgrade, or root.', 2); } else { // Check version diff --git a/Mage/Command/BuiltIn/VersionCommand.php b/Mage/Command/BuiltIn/VersionCommand.php index 8437242d..0c7938c0 100644 --- a/Mage/Command/BuiltIn/VersionCommand.php +++ b/Mage/Command/BuiltIn/VersionCommand.php @@ -26,7 +26,7 @@ class VersionCommand extends AbstractCommand */ public function run() { - Console::output('Running Magallanes version ' . MAGALLANES_VERSION . '', 0, 2); + Console::output('Running Magallanes version ' . MAGALLANES_VERSION . '', 0, 2); return 0; } diff --git a/Mage/Console.php b/Mage/Console.php index 9cb04a0d..b9dd97cd 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -115,7 +115,7 @@ public function run($arguments) } else { self::output('Starting Magallanes', 0, 1); self::log("Logging enabled"); - self::output('Logging enabled: ' . self::getLogFile() . '', 1, 2); + self::output('Logging enabled: ' . self::getLogFile() . '', 1, 2); } } diff --git a/Mage/Console/Colors.php b/Mage/Console/Colors.php index 84bfb622..5ab48bce 100644 --- a/Mage/Console/Colors.php +++ b/Mage/Console/Colors.php @@ -25,7 +25,7 @@ class Colors */ private static $foregroundColors = array( 'black' => '0;30', - 'dark_gray' => '1;30', + 'bold' => '1', 'blue' => '0;34', 'light_blue' => '1;34', 'green' => '0;32', diff --git a/Mage/Task/BuiltIn/Releases/ListTask.php b/Mage/Task/BuiltIn/Releases/ListTask.php index 07743516..ffbd2c48 100644 --- a/Mage/Task/BuiltIn/Releases/ListTask.php +++ b/Mage/Task/BuiltIn/Releases/ListTask.php @@ -38,7 +38,7 @@ public function run() $releasesDirectory = $this->getConfig()->release('directory', 'releases'); $symlink = $this->getConfig()->release('symlink', 'current'); - Console::output('Releases available on ' . $this->getConfig()->getHost() . ''); + Console::output('Releases available on ' . $this->getConfig()->getHost() . ''); // Get Releases $output = ''; @@ -51,7 +51,7 @@ public function run() $currentRelease = trim(array_pop($currentRelease)); if (count($releases) == 0) { - Console::output('No releases available ... ', 2); + Console::output('No releases available ... ', 2); } else { rsort($releases); $releases = array_slice($releases, 0, 10); @@ -80,8 +80,8 @@ public function run() Console::output( 'Release: ' . $release . ' ' - . '- Date: ' . $releaseDate . ' ' - . '- Index: ' . $releaseIndex . '' . $dateDiff . $isCurrent, 2); + . '- Date: ' . $releaseDate . ' ' + . '- Index: ' . $releaseIndex . '' . $dateDiff . $isCurrent, 2); } } diff --git a/Mage/Task/BuiltIn/Releases/RollbackTask.php b/Mage/Task/BuiltIn/Releases/RollbackTask.php index a8ebb9cd..7a437fda 100644 --- a/Mage/Task/BuiltIn/Releases/RollbackTask.php +++ b/Mage/Task/BuiltIn/Releases/RollbackTask.php @@ -56,7 +56,7 @@ public function run() $releases = ($output == '') ? array() : explode(PHP_EOL, $output); if (count($releases) == 0) { - Console::output('Release are not available for ' . $this->getConfig()->getHost() . ' ... FAIL'); + Console::output('Release are not available for ' . $this->getConfig()->getHost() . ' ... FAIL'); } else { rsort($releases); @@ -81,10 +81,10 @@ public function run() } if (!$releaseIsAvailable) { - Console::output('Release ' . $this->getReleaseId() . ' is invalid or unavailable for ' . $this->getConfig()->getHost() . ' ... FAIL'); + Console::output('Release ' . $this->getReleaseId() . ' is invalid or unavailable for ' . $this->getConfig()->getHost() . ' ... FAIL'); } else { - Console::output('Rollback release on ' . $this->getConfig()->getHost() . ''); + Console::output('Rollback release on ' . $this->getConfig()->getHost() . ''); $rollbackTo = $releasesDirectory . '/' . $releaseId; // Get Current Release @@ -178,7 +178,7 @@ public function run() $tasksColor = 'red'; } - Console::output('Release rollback on ' . $this->getConfig()->getHost() . ' compted: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . ' tasks done.', 1, 3); + Console::output('Release rollback on ' . $this->getConfig()->getHost() . ' compted: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . ' tasks done.', 1, 3); } } From 609745ccc4003198129081503c91359db4c5242c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 1 Nov 2014 19:49:04 -0200 Subject: [PATCH 34/34] Prepare for new release. --- bin/mage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/mage b/bin/mage index b5d201eb..728e3aaf 100755 --- a/bin/mage +++ b/bin/mage @@ -13,7 +13,7 @@ date_default_timezone_set('UTC'); $baseDir = dirname(dirname(__FILE__)); -define('MAGALLANES_VERSION', '1.0.2'); +define('MAGALLANES_VERSION', '1.0.3'); define('MAGALLANES_DIRECTORY', $baseDir); if (file_exists(__DIR__ . '/../vendor/autoload.php')) {