From 5c4a2ad0beb869bb18861969444f18b93b387221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=9A=D0=BE=D0=BB?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 5 Nov 2014 15:08:02 +0300 Subject: [PATCH 01/66] Add .idea to .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index a147ed3..8b80908 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ mage.phar ehthumbs.db Icon? Thumbs.db + +composer.phar +.idea \ No newline at end of file From 642773b5af8f4c249fc33f22af98fcb17c8da8f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=9A=D0=BE=D0=BB?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 5 Nov 2014 15:36:14 +0300 Subject: [PATCH 02/66] PSR-2 style. --- .../Filesystem/LinkSharedFilesTask.php | 48 ++++++++++++++----- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php index 4ed89a1..c0948f2 100644 --- a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php +++ b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php @@ -5,21 +5,44 @@ use Mage\Task\AbstractTask; use Mage\Task\Releases\IsReleaseAware; use Mage\Task\SkipException; +/** + * Class LinkSharedFilesTask + * + * @package Mage\Task\BuiltIn\Filesystem + * @author Andrey Kolchenko + */ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware { - const LINKED_FOLDERS = 'linked_folders'; - const LINKED_STRATEGY = 'linking_strategy'; + /** + * Linked folders parameter name + */ + const LINKED_FOLDERS = 'linked_folders'; + /** + * Linking strategy parameter name + */ + const LINKED_STRATEGY = 'linking_strategy'; + /** + * Absolute linked strategy + */ const ABSOLUTE_LINKING = 'absolute'; + /** + * Relative linked strategy + */ const RELATIVE_LINKING = 'relative'; + /** + * @var array + */ public $linkingStrategies = array( self::ABSOLUTE_LINKING, self::RELATIVE_LINKING ); + /** * Returns the Title of the Task + * * @return string */ public function getName() @@ -35,11 +58,11 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware */ public function run() { - $linkedFiles = $this->getParameter('linked_files', []); - $linkedFolders = $this->getParameter(self::LINKED_FOLDERS, []); + $linkedFiles = $this->getParameter('linked_files', []); + $linkedFolders = $this->getParameter(self::LINKED_FOLDERS, []); $linkingStrategy = $this->getParameter(self::LINKED_STRATEGY, self::ABSOLUTE_LINKING); - $linkedEntities = array_merge($linkedFiles,$linkedFolders); + $linkedEntities = array_merge($linkedFiles, $linkedFolders); if (sizeof($linkedFiles) == 0 && sizeof($linkedFolders) == 0) { throw new SkipException('No files and folders configured for sym-linking.'); @@ -51,20 +74,23 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware $releasesDirectoryPath = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory; $currentCopy = $releasesDirectoryPath . '/' . $this->getConfig()->getReleaseId(); - $relativeDiffPath = str_replace($this->getConfig()->deployment('to'),'',$currentCopy) . '/'; + $relativeDiffPath = str_replace($this->getConfig()->deployment('to'), '', $currentCopy) . '/'; foreach ($linkedEntities as $ePath) { - if(is_array($ePath) && in_array($strategy = reset($ePath), $this->linkingStrategies ) ) { + if (is_array($ePath) && in_array($strategy = reset($ePath), $this->linkingStrategies)) { $entityPath = key($ePath); } else { $strategy = $linkingStrategy; $entityPath = $ePath; } $sharedEntityLinkedPath = "$sharedFolderPath/$entityPath"; - if($strategy==self::RELATIVE_LINKING) { + if ($strategy == self::RELATIVE_LINKING) { $parentFolderPath = dirname($entityPath); - $relativePath = $parentFolderPath=='.'?$relativeDiffPath:$relativeDiffPath.$parentFolderPath.'/'; - $sharedEntityLinkedPath = ltrim(preg_replace('/(\w+\/)/', '../', $relativePath),'/').$sharedFolderName .'/'. $entityPath; + $relativePath = $parentFolderPath == '.' ? $relativeDiffPath : $relativeDiffPath . $parentFolderPath . '/'; + $sharedEntityLinkedPath = ltrim( + preg_replace('/(\w+\/)/', '../', $relativePath), + '/' + ) . $sharedFolderName . '/' . $entityPath; } $command = "ln -nfs $sharedEntityLinkedPath $currentCopy/$entityPath"; $this->runCommandRemote($command); @@ -72,4 +98,4 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware return true; } -} \ No newline at end of file +} From 4c719f5efdfe419ae2daafe9dc3edd5d92cf33d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=9A=D0=BE=D0=BB?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 5 Nov 2014 15:37:07 +0300 Subject: [PATCH 03/66] PHP 5.3 does not support "[]" brackets. --- Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php index c0948f2..16eb289 100644 --- a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php +++ b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php @@ -58,13 +58,13 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware */ public function run() { - $linkedFiles = $this->getParameter('linked_files', []); - $linkedFolders = $this->getParameter(self::LINKED_FOLDERS, []); + $linkedFiles = $this->getParameter('linked_files', array()); + $linkedFolders = $this->getParameter(self::LINKED_FOLDERS, array()); $linkingStrategy = $this->getParameter(self::LINKED_STRATEGY, self::ABSOLUTE_LINKING); $linkedEntities = array_merge($linkedFiles, $linkedFolders); - if (sizeof($linkedFiles) == 0 && sizeof($linkedFolders) == 0) { + if (empty($linkedFiles) && empty($linkedFolders)) { throw new SkipException('No files and folders configured for sym-linking.'); } From d52927fe07b39f756489f86b2f43fce30f0fbf98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=9A=D0=BE=D0=BB?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 5 Nov 2014 16:39:43 +0300 Subject: [PATCH 04/66] Get path and strategy. --- .../Filesystem/LinkSharedFilesTask.php | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php index 16eb289..d457d4d 100644 --- a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php +++ b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php @@ -35,7 +35,7 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware /** * @var array */ - public $linkingStrategies = array( + private static $linkingStrategies = array( self::ABSOLUTE_LINKING, self::RELATIVE_LINKING ); @@ -77,12 +77,7 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware $relativeDiffPath = str_replace($this->getConfig()->deployment('to'), '', $currentCopy) . '/'; foreach ($linkedEntities as $ePath) { - if (is_array($ePath) && in_array($strategy = reset($ePath), $this->linkingStrategies)) { - $entityPath = key($ePath); - } else { - $strategy = $linkingStrategy; - $entityPath = $ePath; - } + list($entityPath, $strategy) = $this->getPath($ePath); $sharedEntityLinkedPath = "$sharedFolderPath/$entityPath"; if ($strategy == self::RELATIVE_LINKING) { $parentFolderPath = dirname($entityPath); @@ -98,4 +93,25 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware return true; } + + /** + * @param array|string $linkedEntity + * + * @return array [$path, $strategy] + */ + private function getPath($linkedEntity) + { + $linkingStrategy = $this->getParameter(self::LINKED_STRATEGY, self::ABSOLUTE_LINKING); + if (is_array($linkedEntity)) { + list($path, $strategy) = each($linkedEntity); + if (!in_array($strategy, self::$linkingStrategies)) { + $strategy = $linkingStrategy; + } + } else { + $strategy = $linkingStrategy; + $path = $linkedEntity; + } + + return [$path, $strategy]; + } } From ce2da4e270f2085ea5e2da9c064ee524635f6f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=9A=D0=BE=D0=BB?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 5 Nov 2014 16:42:13 +0300 Subject: [PATCH 05/66] Getting linked entities. --- .../BuiltIn/Filesystem/LinkSharedFilesTask.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php index d457d4d..2276cca 100644 --- a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php +++ b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php @@ -13,7 +13,10 @@ use Mage\Task\SkipException; */ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware { - + /** + * Linked folders parameter name + */ + const LINKED_FILES = 'linked_files'; /** * Linked folders parameter name */ @@ -58,13 +61,12 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware */ public function run() { - $linkedFiles = $this->getParameter('linked_files', array()); - $linkedFolders = $this->getParameter(self::LINKED_FOLDERS, array()); - $linkingStrategy = $this->getParameter(self::LINKED_STRATEGY, self::ABSOLUTE_LINKING); - - $linkedEntities = array_merge($linkedFiles, $linkedFolders); + $linkedEntities = array_merge( + $this->getParameter(self::LINKED_FILES, array()), + $this->getParameter(self::LINKED_FOLDERS, array()) + ); - if (empty($linkedFiles) && empty($linkedFolders)) { + if (empty($linkedEntities)) { throw new SkipException('No files and folders configured for sym-linking.'); } From 9d309007988a8220dd58d114a37dae88721406eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=9A=D0=BE=D0=BB?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 5 Nov 2014 17:12:49 +0300 Subject: [PATCH 06/66] Add symfony/filesystem to requires block. --- composer.json | 3 ++- composer.lock | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 composer.lock diff --git a/composer.json b/composer.json index 4018174..0063d15 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,8 @@ "type": "library", "keywords": ["deployment"], "require": { - "php": ">=5.3" + "php": ">=5.3", + "symfony/filesystem": ">=2.1.0,<=2.6.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..54108f8 --- /dev/null +++ b/composer.lock @@ -0,0 +1,66 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "e7a3fa9a09b1ab45ed140d6813a94262", + "packages": [ + { + "name": "symfony/filesystem", + "version": "v2.5.6", + "target-dir": "Symfony/Component/Filesystem", + "source": { + "type": "git", + "url": "https://github.com/symfony/Filesystem.git", + "reference": "4e62fab0060a826561c78b665925b37c870c45f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/4e62fab0060a826561c78b665925b37c870c45f5", + "reference": "4e62fab0060a826561c78b665925b37c870c45f5", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Filesystem\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "http://symfony.com", + "time": "2014-09-22 09:14:18" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "platform": { + "php": ">=5.3" + }, + "platform-dev": [] +} From 3a41a860d055bd582949f4fdd2b4322ac6ffb6ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=9A=D0=BE=D0=BB?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 5 Nov 2014 17:16:55 +0300 Subject: [PATCH 07/66] Make target dir before invoking "ln". Fix bug with spaces in path. --- .../Filesystem/LinkSharedFilesTask.php | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php index 2276cca..714b424 100644 --- a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php +++ b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php @@ -4,6 +4,7 @@ namespace Mage\Task\BuiltIn\Filesystem; use Mage\Task\AbstractTask; use Mage\Task\Releases\IsReleaseAware; use Mage\Task\SkipException; +use Symfony\Component\Filesystem\Filesystem; /** * Class LinkSharedFilesTask @@ -70,26 +71,23 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware throw new SkipException('No files and folders configured for sym-linking.'); } - $sharedFolderName = $this->getParameter('shared', 'shared'); - $sharedFolderPath = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $sharedFolderName; - $releasesDirectory = $this->getConfig()->release('directory', 'releases'); - $releasesDirectoryPath = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory; - + $remoteDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/'; + $sharedFolderPath = $remoteDirectory . $this->getParameter('shared', 'shared'); + $releasesDirectoryPath = $remoteDirectory . $this->getConfig()->release('directory', 'releases'); $currentCopy = $releasesDirectoryPath . '/' . $this->getConfig()->getReleaseId(); - $relativeDiffPath = str_replace($this->getConfig()->deployment('to'), '', $currentCopy) . '/'; + $fileSystem = new Filesystem(); foreach ($linkedEntities as $ePath) { list($entityPath, $strategy) = $this->getPath($ePath); - $sharedEntityLinkedPath = "$sharedFolderPath/$entityPath"; - if ($strategy == self::RELATIVE_LINKING) { - $parentFolderPath = dirname($entityPath); - $relativePath = $parentFolderPath == '.' ? $relativeDiffPath : $relativeDiffPath . $parentFolderPath . '/'; - $sharedEntityLinkedPath = ltrim( - preg_replace('/(\w+\/)/', '../', $relativePath), - '/' - ) . $sharedFolderName . '/' . $entityPath; + if ($strategy === self::RELATIVE_LINKING) { + $dirName = dirname($currentCopy . '/' . $entityPath); + $target = $fileSystem->makePathRelative($sharedFolderPath, $dirName) . $entityPath; + } else { + $target = $sharedFolderPath . '/' . $entityPath; } - $command = "ln -nfs $sharedEntityLinkedPath $currentCopy/$entityPath"; + $command = 'mkdir -p ' . escapeshellarg(dirname($target)); + $this->runCommandRemote($command); + $command = 'ln -nfs ' . escapeshellarg($target) . ' ' . escapeshellarg($currentCopy . '/' . $entityPath); $this->runCommandRemote($command); } From 1dc97d77f88f3cdb670544a83aa28ed253a3fe14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=9A=D0=BE=D0=BB?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 5 Nov 2014 17:19:40 +0300 Subject: [PATCH 08/66] Fix email. --- 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 714b424..5d4346f 100644 --- a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php +++ b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php @@ -10,7 +10,7 @@ use Symfony\Component\Filesystem\Filesystem; * Class LinkSharedFilesTask * * @package Mage\Task\BuiltIn\Filesystem - * @author Andrey Kolchenko + * @author Andrey Kolchenko */ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware { From 575632d62bd97a5653a299a38e17991fe937c7ab Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Fri, 31 Oct 2014 20:06:54 +0100 Subject: [PATCH 09/66] Enable configurable verbose logging --- Mage/Console.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Mage/Console.php b/Mage/Console.php index b9dd97c..541ed4a 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -227,6 +227,10 @@ class Console $message = date('Y-m-d H:i:s -- ') . $message; fwrite(self::$log, $message . PHP_EOL); + + if (self::$config->general('verbose_logging', false)) { + echo $message . PHP_EOL; + } } } From 67e00bca59ea8776bfacbb514fd53037d2678711 Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Tue, 11 Nov 2014 20:27:33 +0100 Subject: [PATCH 10/66] Add verbose logging state variable --- Mage/Console.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Mage/Console.php b/Mage/Console.php index 541ed4a..a0819af 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -48,6 +48,12 @@ class Console */ private static $logEnabled = true; + /** + * Enables or disables verbose logging + * @var boolean + */ + private static $verboseLogEnabled = false; + /** * String Buffer for the screen output * @var string @@ -107,6 +113,8 @@ class Console self::$logEnabled = $config->general('logging', false); } + self::$verboseLogEnabled = $config->general('verbose_logging', false); + // Greetings if ($showGreetings) { if (!self::$logEnabled) { @@ -228,7 +236,7 @@ class Console $message = date('Y-m-d H:i:s -- ') . $message; fwrite(self::$log, $message . PHP_EOL); - if (self::$config->general('verbose_logging', false)) { + if (self::$verboseLogEnabled) { echo $message . PHP_EOL; } } From 654753b70fa4d3d7fa07869ff1b13830f3451a8f Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Tue, 11 Nov 2014 20:29:46 +0100 Subject: [PATCH 11/66] Avoid duplicating output when verbose option is turned on --- Mage/Console.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Mage/Console.php b/Mage/Console.php index a0819af..43f7e36 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -181,15 +181,17 @@ class Console { self::log(strip_tags($message)); - self::$screenBuffer .= str_repeat("\t", $tabs) - . strip_tags($message) - . str_repeat(PHP_EOL, $newLine); + if (!self::$verboseLogEnabled) { + self::$screenBuffer .= str_repeat("\t", $tabs) + . strip_tags($message) + . str_repeat(PHP_EOL, $newLine); - $output = str_repeat("\t", $tabs) - . Colors::color($message, self::$config) - . str_repeat(PHP_EOL, $newLine); + $output = str_repeat("\t", $tabs) + . Colors::color($message, self::$config) + . str_repeat(PHP_EOL, $newLine); - echo $output; + echo $output; + } } /** From 0734c7be0a0b8ff0263ead3532ff06a9d085d541 Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Tue, 11 Nov 2014 20:34:50 +0100 Subject: [PATCH 12/66] Check if verbose logging is enabled --- Mage/Console.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Mage/Console.php b/Mage/Console.php index 43f7e36..db378a1 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -113,7 +113,7 @@ class Console self::$logEnabled = $config->general('logging', false); } - self::$verboseLogEnabled = $config->general('verbose_logging', false); + self::$verboseLogEnabled = self::isVerboseLoggingEnabled(); // Greetings if ($showGreetings) { @@ -300,4 +300,13 @@ class Console } } + /** + * Check if verbose logging is enabled + * @return boolean + */ + protected static function isVerboseLoggingEnabled() + { + return self::$config->getParameter('verbose', false) || self::$config->general('verbose_logging'); + } + } From d63d10547128485a10edef603dc80724680f682b Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Tue, 11 Nov 2014 20:38:26 +0100 Subject: [PATCH 13/66] Add ability to set 'verbose_logging' for environment --- Mage/Console.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Mage/Console.php b/Mage/Console.php index db378a1..8dd7940 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -306,7 +306,9 @@ class Console */ protected static function isVerboseLoggingEnabled() { - return self::$config->getParameter('verbose', false) || self::$config->general('verbose_logging'); + return self::$config->getParameter('verbose', false) + || self::$config->general('verbose_logging') + || self::$config->environmentConfig('verbose_logging', false); } } From 9eb61d1d4badf9a3b60b787b7ea8a430eb6e633d Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Tue, 11 Nov 2014 20:40:58 +0100 Subject: [PATCH 14/66] Write down some example of verbose usage option --- docs/commands.txt | 4 +++- docs/example-config/.mage/config/environment/production.yml | 1 + docs/example-config/.mage/config/environment/staging.yml | 1 + docs/example-config/.mage/config/general.yml | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/commands.txt b/docs/commands.txt index b9674b4..178bad2 100644 --- a/docs/commands.txt +++ b/docs/commands.txt @@ -51,9 +51,11 @@ mage releases rollback --release=-3 to:production # Rollback to a specific Release on the Production environment # mage releases rollback --release=20120101172148 to:production +# Output logs by adding verbose option to ANY command +mage deploy to:production --verbose ### List of UPCOMING Commands ### # mage config add host s05.example.com to:[production] # mage config git git://github.com/andres-montanez/Zend-Framework-Twig-example-app.git # mage config svn svn://example.com/repo -# mage task:deployment/rsync to:production \ No newline at end of file +# mage task:deployment/rsync to:production diff --git a/docs/example-config/.mage/config/environment/production.yml b/docs/example-config/.mage/config/environment/production.yml index 5122d7d..97a3fcc 100644 --- a/docs/example-config/.mage/config/environment/production.yml +++ b/docs/example-config/.mage/config/environment/production.yml @@ -21,3 +21,4 @@ tasks: - privileges - sampleTask - sampleTaskRollbackAware +verbose_logging: true diff --git a/docs/example-config/.mage/config/environment/staging.yml b/docs/example-config/.mage/config/environment/staging.yml index 5c1c51d..51f4f06 100644 --- a/docs/example-config/.mage/config/environment/staging.yml +++ b/docs/example-config/.mage/config/environment/staging.yml @@ -29,3 +29,4 @@ tasks: # - sampleTask post-deploy: - sampleTask +verbose_logging: false diff --git a/docs/example-config/.mage/config/general.yml b/docs/example-config/.mage/config/general.yml index 3834ff3..c3a9b6d 100644 --- a/docs/example-config/.mage/config/general.yml +++ b/docs/example-config/.mage/config/general.yml @@ -3,6 +3,7 @@ name: My fantastic App email: andresmontanez@gmail.com notifications: true logging: true +verbose_logging: false scm: type: git url: git://github.com/andres-montanez/Zend-Framework-Twig-example-app.git From 8e603bd0d268d5bd4a0c412e4de8dc6aa20dd5db Mon Sep 17 00:00:00 2001 From: Alex V Kotelnikov Date: Thu, 13 Nov 2014 00:13:19 +0400 Subject: [PATCH 15/66] fixed bug with a env-configuration containing deployment description in hosts section --- Mage/Command/BuiltIn/DeployCommand.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Mage/Command/BuiltIn/DeployCommand.php b/Mage/Command/BuiltIn/DeployCommand.php index 943a630..7ee5235 100644 --- a/Mage/Command/BuiltIn/DeployCommand.php +++ b/Mage/Command/BuiltIn/DeployCommand.php @@ -439,13 +439,22 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment } else { $result = true; - foreach ($hosts as $host) { - $this->getConfig()->setHost($host); + foreach ($hosts as $hostKey => $host) { + $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(-1); + $task = Factory::get('releases/rollback', $this->getConfig()); $task->init(); $result = $task->run() && $result; + } return $result; } From db4b4299c2abac6b09e341f10321899631b6263d Mon Sep 17 00:00:00 2001 From: Alex V Kotelnikov Date: Thu, 13 Nov 2014 02:07:20 +0400 Subject: [PATCH 16/66] added rollback delete default option from yaml configs --- Mage/Task/BuiltIn/Releases/RollbackTask.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Mage/Task/BuiltIn/Releases/RollbackTask.php b/Mage/Task/BuiltIn/Releases/RollbackTask.php index 7a437fd..2d798b1 100644 --- a/Mage/Task/BuiltIn/Releases/RollbackTask.php +++ b/Mage/Task/BuiltIn/Releases/RollbackTask.php @@ -60,7 +60,11 @@ class RollbackTask extends AbstractTask implements IsReleaseAware } else { rsort($releases); - $deleteCurrent = $this->getConfig()->getParameter('deleteCurrent', false); + $deleteCurrent = $this->getConfig()->getParameter('deleteCurrent', + $this->getConfig()->deployment('delete-on-rollback', + $this->getConfig()->general('delete-on-rollback',false) + ) + ); $releaseIsAvailable = false; if ($this->getReleaseId() == '') { From 5eb26748ab182fbd00b8efd26fa55cece4b8dbdb Mon Sep 17 00:00:00 2001 From: Alex V Kotelnikov Date: Thu, 13 Nov 2014 16:40:02 +0400 Subject: [PATCH 17/66] added restriction to run the rollback. small changes at rollback output. --- Mage/Command/BuiltIn/DeployCommand.php | 34 ++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/Mage/Command/BuiltIn/DeployCommand.php b/Mage/Command/BuiltIn/DeployCommand.php index 7ee5235..e4e2a78 100644 --- a/Mage/Command/BuiltIn/DeployCommand.php +++ b/Mage/Command/BuiltIn/DeployCommand.php @@ -59,6 +59,15 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment */ const IN_PROGRESS = 'in_progress'; + /** + * Stage where possible throw Rollback Exception + * @var array + */ + public $acceptedStagesToRollback = array( + AbstractTask::STAGE_POST_RELEASE, + AbstractTask::STAGE_POST_DEPLOY + ); + /** * Time the Deployment has Started * @var integer @@ -430,11 +439,19 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment } } - protected function runRollbackTask(){ + protected function runRollbackTask(AbstractTask $task){ $this->getConfig()->reload(); $hosts = $this->getConfig()->getHosts(); - if (count($hosts) == 0) { + Console::output("",1,2); + Console::output("Starting the rollback",1,1); + + if(!in_array($task->getStage(), $this->acceptedStagesToRollback ) ) { + $stagesString = implode(', ',$this->acceptedStagesToRollback); + Console::output("Warning! Rollback during deployment can be called only at the stages: $stagesString ",1); + Console::output("Rollback: ABORTING",1,3); + + } elseif (count($hosts) == 0) { Console::output('Warning! No hosts defined, unable to get releases.', 1, 3); } else { @@ -451,7 +468,14 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment $this->getConfig()->setHostConfig($hostConfig); $this->getConfig()->setReleaseId(-1); - $task = Factory::get('releases/rollback', $this->getConfig()); + $task = Factory::get(array( + 'name'=>'releases/rollback', + 'parameters' => array('inDeploy'=>true) + ), + $this->getConfig(), + false, + $task->getStage() + ); $task->init(); $result = $task->run() && $result; @@ -495,8 +519,8 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment $result = false; } } catch (RollbackException $e) { - Console::output('FAIL, Rollback started [Message: ' . $e->getMessage() . ']', 0); - $this->runRollbackTask(); + Console::output('FAIL, Rollback catched [Message: ' . $e->getMessage() . ']', 0); + $this->runRollbackTask($task); $result = false; } catch (ErrorWithMessageException $e) { From a632dac80ae827caeb086d54811436dce03db26c Mon Sep 17 00:00:00 2001 From: Alex V Kotelnikov Date: Thu, 13 Nov 2014 16:47:52 +0400 Subject: [PATCH 18/66] added in-deploy flag @ rollback task. --- Mage/Task/BuiltIn/Releases/RollbackTask.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Mage/Task/BuiltIn/Releases/RollbackTask.php b/Mage/Task/BuiltIn/Releases/RollbackTask.php index 2d798b1..1de9831 100644 --- a/Mage/Task/BuiltIn/Releases/RollbackTask.php +++ b/Mage/Task/BuiltIn/Releases/RollbackTask.php @@ -55,6 +55,8 @@ class RollbackTask extends AbstractTask implements IsReleaseAware $result = $this->runCommandRemote('ls -1 ' . $releasesDirectory, $output); $releases = ($output == '') ? array() : explode(PHP_EOL, $output); + $inDeploy = $this->getParameter('inDeploy',false); + if (count($releases) == 0) { Console::output('Release are not available for ' . $this->getConfig()->getHost() . ' ... FAIL'); From c010fc662e9e7f26d6b7d9815ed5a1ff47e741b5 Mon Sep 17 00:00:00 2001 From: samuel4x4 Date: Sun, 23 Nov 2014 23:03:31 +0200 Subject: [PATCH 19/66] Change runCommandRemote() to runCommand() Change runCommandRemote() to runCommand(), you decide if the command is running local or remote depending of the stage you put the scm/force-update task. Remove the last $result = $this->runCommandLocal($command), not necessary. --- Mage/Task/BuiltIn/Scm/ForceUpdateTask.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Mage/Task/BuiltIn/Scm/ForceUpdateTask.php b/Mage/Task/BuiltIn/Scm/ForceUpdateTask.php index 9d68e09..2b1bfe8 100644 --- a/Mage/Task/BuiltIn/Scm/ForceUpdateTask.php +++ b/Mage/Task/BuiltIn/Scm/ForceUpdateTask.php @@ -65,13 +65,13 @@ class ForceUpdateTask extends AbstractTask $remote = $this->getParameter('remote', 'origin'); $command = 'git fetch ' . $remote . ' ' . $branch; - $result = $this->runCommandRemote($command); + $result = $this->runCommand($command); $command = 'git reset --hard ' . $remote . '/' . $branch; - $result = $result && $this->runCommandRemote($command); + $result = $result && $this->runCommand($command); $command = 'git pull ' . $remote . ' ' . $branch; - $result = $result && $this->runCommandRemote($command); + $result = $result && $this->runCommand($command); break; default: @@ -79,7 +79,6 @@ class ForceUpdateTask extends AbstractTask break; } - $result = $this->runCommandLocal($command); $this->getConfig()->reload(); return $result; From 41c3e00f67f4bc3dbc9b8b0b2bb5fa149c544c26 Mon Sep 17 00:00:00 2001 From: samuel4x4 Date: Sun, 23 Nov 2014 23:34:58 +0200 Subject: [PATCH 20/66] Task for running multiple manually commands The purpose of this task is to provide a way to run multiple custom commands for your specific project, before Magallanes will have build-in tasks for your needs. Also maybe you'll just not consider you should create custom tasks for all commands you need (e.g. specific user rights for specific files and directories). --- Mage/Task/BuiltIn/General/ManuallyTask.php | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Mage/Task/BuiltIn/General/ManuallyTask.php diff --git a/Mage/Task/BuiltIn/General/ManuallyTask.php b/Mage/Task/BuiltIn/General/ManuallyTask.php new file mode 100644 index 0000000..71a681d --- /dev/null +++ b/Mage/Task/BuiltIn/General/ManuallyTask.php @@ -0,0 +1,60 @@ + + * + * 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; + +/** + * Task for running multiple custom commands setting them manually + * + * Example of usage: + * + * tasks: + * on-deploy: + * - scm/force-update + * - general/manually: + * - find . -type d -exec chmod 755 {} \; + * - find . -type f -exec chmod 644 {} \; + * - chmod +x bin/console + * - symfony2/cache-clear + * + * @author Samuel Chiriluta + */ +class ManuallyTask extends AbstractTask { + + /** + * (non-PHPdoc) + * @see \Mage\Task\AbstractTask::getName() + */ + public function getName() + { + return 'Manually multiple custom tasks'; + } + + /** + * @see \Mage\Task\AbstractTask::run() + */ + public function run() + { + $result = true; + + $commands = $this->getParameters(); + + foreach ($commands as $command) + { + $result = $result && $this->runCommand($command); + } + + return $result; + } + +} From 94673b4af2e1d8ca2cc4942d3afc521e7e631abc Mon Sep 17 00:00:00 2001 From: samuel4x4 Date: Sun, 23 Nov 2014 23:57:00 +0200 Subject: [PATCH 21/66] manually task one more example for the manually task --- Mage/Task/BuiltIn/General/ManuallyTask.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Mage/Task/BuiltIn/General/ManuallyTask.php b/Mage/Task/BuiltIn/General/ManuallyTask.php index 71a681d..cc3bdf0 100644 --- a/Mage/Task/BuiltIn/General/ManuallyTask.php +++ b/Mage/Task/BuiltIn/General/ManuallyTask.php @@ -25,6 +25,7 @@ use Mage\Task\AbstractTask; * - find . -type d -exec chmod 755 {} \; * - find . -type f -exec chmod 644 {} \; * - chmod +x bin/console + * - find var/logs -maxdepth 1 -type f -name '*.log' -exec chown apache:apache {} \; * - symfony2/cache-clear * * @author Samuel Chiriluta From e9e5ab1d458662423a138819658278b2d7728f75 Mon Sep 17 00:00:00 2001 From: samuel4x4 Date: Mon, 24 Nov 2014 00:44:23 +0200 Subject: [PATCH 22/66] Fix ManuallyTask namespace namespace Mage\Task\BuiltIn\General --- Mage/Task/BuiltIn/General/ManuallyTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/Task/BuiltIn/General/ManuallyTask.php b/Mage/Task/BuiltIn/General/ManuallyTask.php index cc3bdf0..aec0279 100644 --- a/Mage/Task/BuiltIn/General/ManuallyTask.php +++ b/Mage/Task/BuiltIn/General/ManuallyTask.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Mage\Task\BuiltIn\Scm; +namespace Mage\Task\BuiltIn\General; use Mage\Task\AbstractTask; From 5eb771bf301ab25eea59528ffbba192d4f4f5224 Mon Sep 17 00:00:00 2001 From: samuel4x4 Date: Mon, 24 Nov 2014 01:08:52 +0200 Subject: [PATCH 23/66] Rename DoctrineMigrate to DoctrineMigrateTask I hope this is the reason it doesn't works. --- .../Symfony2/{DoctrineMigrate.php => DoctrineMigrateTask.php} | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename Mage/Task/BuiltIn/Symfony2/{DoctrineMigrate.php => DoctrineMigrateTask.php} (93%) diff --git a/Mage/Task/BuiltIn/Symfony2/DoctrineMigrate.php b/Mage/Task/BuiltIn/Symfony2/DoctrineMigrateTask.php similarity index 93% rename from Mage/Task/BuiltIn/Symfony2/DoctrineMigrate.php rename to Mage/Task/BuiltIn/Symfony2/DoctrineMigrateTask.php index b76633d..3a412e9 100644 --- a/Mage/Task/BuiltIn/Symfony2/DoctrineMigrate.php +++ b/Mage/Task/BuiltIn/Symfony2/DoctrineMigrateTask.php @@ -15,7 +15,7 @@ use Mage\Task\BuiltIn\Symfony2\SymfonyAbstractTask; /** * Task for Doctrine migrations */ -class DoctrineMigrate extends SymfonyAbstractTask +class DoctrineMigrateTask extends SymfonyAbstractTask { /** * (non-PHPdoc) @@ -34,7 +34,9 @@ class DoctrineMigrate extends SymfonyAbstractTask public function run() { $env = $this->getParameter('env', 'dev'); + $command = $this->getAppPath() . ' doctrine:migrations:migrate -n --env=' . $env; + return $this->runCommand($command); } } From 4d1048cca68cb8973dcb62cc8ba99e1bee3d7302 Mon Sep 17 00:00:00 2001 From: samuel4x4 Date: Mon, 24 Nov 2014 01:36:08 +0200 Subject: [PATCH 24/66] Add optional parameters for symfony2/cache-clear Add optional parameters for symfony2/cache-clear task like --no-warmup. --- Mage/Task/BuiltIn/Symfony2/CacheClearTask.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Mage/Task/BuiltIn/Symfony2/CacheClearTask.php b/Mage/Task/BuiltIn/Symfony2/CacheClearTask.php index 44acc46..d347138 100644 --- a/Mage/Task/BuiltIn/Symfony2/CacheClearTask.php +++ b/Mage/Task/BuiltIn/Symfony2/CacheClearTask.php @@ -14,8 +14,13 @@ use Mage\Task\BuiltIn\Symfony2\SymfonyAbstractTask; /** * Task for Clearing the Cache + * + * Example of usage: + * symfony2/cache-clear: { env: dev } + * symfony2/cache-clear: { env: dev, optional: --no-warmup } * * @author Andrés Montañez + * @author Samuel Chiriluta */ class CacheClearTask extends SymfonyAbstractTask { @@ -36,8 +41,10 @@ class CacheClearTask extends SymfonyAbstractTask { // Options $env = $this->getParameter('env', 'dev'); + $optional = $this->getParameter('optional', ''); + + $command = $this->getAppPath() . ' cache:clear --env=' . $env . ' ' . $optional; - $command = $this->getAppPath() . ' cache:clear --env=' . $env; $result = $this->runCommand($command); return $result; From b11688ea2b382edd7e2cf4327544707dae1d8f60 Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Thu, 27 Nov 2014 21:56:52 +0100 Subject: [PATCH 25/66] initial phpunit config with test example --- .gitignore | 1 + .travis.yml | 10 + composer.json | 3 + composer.lock | 762 ++++++++++++++++++++++++++ phpunit.xml.dist | 19 + tests/MageTest/Console/ColorsTest.php | 41 ++ 6 files changed, 836 insertions(+) create mode 100644 .travis.yml create mode 100644 composer.lock create mode 100644 phpunit.xml.dist create mode 100644 tests/MageTest/Console/ColorsTest.php diff --git a/.gitignore b/.gitignore index a147ed3..66f4d84 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ mage.phar ehthumbs.db Icon? Thumbs.db +nbproject \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5d2fb0d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: php + +php: + - 5.3 + - 5.4 + - 5.5 + - 5.6 + +install: + - composer install --dev --prefer-source diff --git a/composer.json b/composer.json index 4018174..2183c74 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,9 @@ "require": { "php": ">=5.3" }, + "require-dev": { + "phpunit/phpunit": "4.3.5" + }, "autoload": { "psr-4": { "Mage\\": "./Mage", diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..c1ca3ca --- /dev/null +++ b/composer.lock @@ -0,0 +1,762 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "a19528b890d301384e45c1ed7d221e26", + "packages": [], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119", + "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "2.0.*@ALPHA" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Doctrine\\Instantiator\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2014-10-13 12:58:55" + }, + { + "name": "phpunit/php-code-coverage", + "version": "2.0.11", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/53603b3c995f5aab6b59c8e08c3a663d2cc810b7", + "reference": "53603b3c995f5aab6b59c8e08c3a663d2cc810b7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "~1.0", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4.1" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2014-08-31 06:33:04" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb", + "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "File/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2013-10-10 15:34:57" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "Text/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2014-01-30 17:20:04" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "PHP/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2013-08-02 07:42:54" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "f8d5d08c56de5cfd592b3340424a81733259a876" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/f8d5d08c56de5cfd592b3340424a81733259a876", + "reference": "f8d5d08c56de5cfd592b3340424a81733259a876", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2014-08-31 06:12:13" + }, + { + "name": "phpunit/phpunit", + "version": "4.3.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "2dab9d593997db4abcf58d0daf798eb4e9cecfe1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2dab9d593997db4abcf58d0daf798eb4e9cecfe1", + "reference": "2dab9d593997db4abcf58d0daf798eb4e9cecfe1", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpunit/php-code-coverage": "~2.0", + "phpunit/php-file-iterator": "~1.3.2", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "~1.0.2", + "phpunit/phpunit-mock-objects": "~2.3", + "sebastian/comparator": "~1.0", + "sebastian/diff": "~1.1", + "sebastian/environment": "~1.0", + "sebastian/exporter": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "", + "../../symfony/yaml/" + ], + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "http://www.phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2014-11-11 10:11:09" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "c63d2367247365f688544f0d500af90a11a44c65" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/c63d2367247365f688544f0d500af90a11a44c65", + "reference": "c63d2367247365f688544f0d500af90a11a44c65", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "~1.0,>=1.0.1", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.3" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2014-10-03 05:12:11" + }, + { + "name": "sebastian/comparator", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/e54a01c0da1b87db3c5a3c4c5277ddf331da4aef", + "reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.1", + "sebastian/exporter": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2014-05-11 23:00:21" + }, + { + "name": "sebastian/diff", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "5843509fed39dee4b356a306401e9dd1a931fec7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/5843509fed39dee4b356a306401e9dd1a931fec7", + "reference": "5843509fed39dee4b356a306401e9dd1a931fec7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "http://www.github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2014-08-15 10:29:00" + }, + { + "name": "sebastian/environment", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/0d9bf79554d2a999da194a60416c15cf461eb67d", + "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2014-10-22 06:38:05" + }, + { + "name": "sebastian/exporter", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c7d59948d6e82818e1bdff7cadb6c34710eb7dc0", + "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2014-09-10 00:51:36" + }, + { + "name": "sebastian/version", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43", + "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2014-03-07 15:35:33" + }, + { + "name": "symfony/yaml", + "version": "v2.5.7", + "target-dir": "Symfony/Component/Yaml", + "source": { + "type": "git", + "url": "https://github.com/symfony/Yaml.git", + "reference": "900d38bc8f74a50343ce65dd1c1e9819658ee56b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/900d38bc8f74a50343ce65dd1c1e9819658ee56b", + "reference": "900d38bc8f74a50343ce65dd1c1e9819658ee56b", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Component\\Yaml\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + }, + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Symfony Yaml Component", + "homepage": "http://symfony.com", + "time": "2014-11-20 13:22:25" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "platform": { + "php": ">=5.3" + }, + "platform-dev": [] +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..a5e1c3b --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,19 @@ + + + + tests + + + + + src + + + + diff --git a/tests/MageTest/Console/ColorsTest.php b/tests/MageTest/Console/ColorsTest.php new file mode 100644 index 0000000..81ebee1 --- /dev/null +++ b/tests/MageTest/Console/ColorsTest.php @@ -0,0 +1,41 @@ +getMock('Mage\Config'); + $config->expects($this->once()) + ->method('getParameter') + ->will($this->returnValue(false)); + + $string = 'FooBar'; + + // Method need to be non static in the future + $result = Colors::color($string, $config); + $expected = "\033[0;32mFooBar\033[0m"; + + $this->assertSame($expected, $result); + } + + public function testColorNoColor() + { + $config = $this->getMock('Mage\Config'); + $config->expects($this->once()) + ->method('getParameter') + ->will($this->returnValue(true)); + + $string = 'FooBar'; + + // Method need to be non static in the future + $result = Colors::color($string, $config); + $expected = 'FooBar'; + + $this->assertSame($expected, $result); + } +} From 6e1a4d248d0a94f70cb7bd85d737011929faa3dc Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Sat, 29 Nov 2014 20:54:12 +0100 Subject: [PATCH 26/66] group annotation added --- tests/MageTest/Console/ColorsTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/MageTest/Console/ColorsTest.php b/tests/MageTest/Console/ColorsTest.php index 81ebee1..4e1304a 100644 --- a/tests/MageTest/Console/ColorsTest.php +++ b/tests/MageTest/Console/ColorsTest.php @@ -5,8 +5,14 @@ namespace MageTest\Console; use Mage\Console\Colors; use PHPUnit_Framework_TestCase; +/** + * @group Mage_Console_Colors + */ class ColorsTest extends PHPUnit_Framework_TestCase { + /** + * @group 159 + */ public function testColor() { $config = $this->getMock('Mage\Config'); @@ -23,6 +29,9 @@ class ColorsTest extends PHPUnit_Framework_TestCase $this->assertSame($expected, $result); } + /** + * @group 159 + */ public function testColorNoColor() { $config = $this->getMock('Mage\Config'); From d53b8fd8b8a9fa1a2088746953e753d11169663d Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Sat, 29 Nov 2014 20:56:22 +0100 Subject: [PATCH 27/66] new test added for unknown color names --- tests/MageTest/Console/ColorsTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/MageTest/Console/ColorsTest.php b/tests/MageTest/Console/ColorsTest.php index 4e1304a..2655409 100644 --- a/tests/MageTest/Console/ColorsTest.php +++ b/tests/MageTest/Console/ColorsTest.php @@ -47,4 +47,22 @@ class ColorsTest extends PHPUnit_Framework_TestCase $this->assertSame($expected, $result); } + + /** + * @group 159 + */ + public function testColorUnknownColorName() + { + $config = $this->getMock('Mage\Config'); + $config->expects($this->once()) + ->method('getParameter') + ->will($this->returnValue(false)); + + $string = 'FooBar'; + + // Method need to be non static in the future + $result = Colors::color($string, $config); + + $this->assertSame($string, $result); + } } From 2a8beeb864db194ece21b37ae91a896251e34d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=9A=D0=BE=D0=BB?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Mon, 8 Dec 2014 12:57:26 +0300 Subject: [PATCH 28/66] Remove symfony/filesystem from project depends. --- .../Filesystem/LinkSharedFilesTask.php | 41 +++++++++++++-- composer.json | 3 +- composer.lock | 52 +------------------ 3 files changed, 41 insertions(+), 55 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php index 5d4346f..2682b86 100644 --- a/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php +++ b/Mage/Task/BuiltIn/Filesystem/LinkSharedFilesTask.php @@ -4,7 +4,6 @@ namespace Mage\Task\BuiltIn\Filesystem; use Mage\Task\AbstractTask; use Mage\Task\Releases\IsReleaseAware; use Mage\Task\SkipException; -use Symfony\Component\Filesystem\Filesystem; /** * Class LinkSharedFilesTask @@ -75,13 +74,12 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware $sharedFolderPath = $remoteDirectory . $this->getParameter('shared', 'shared'); $releasesDirectoryPath = $remoteDirectory . $this->getConfig()->release('directory', 'releases'); $currentCopy = $releasesDirectoryPath . '/' . $this->getConfig()->getReleaseId(); - $fileSystem = new Filesystem(); foreach ($linkedEntities as $ePath) { list($entityPath, $strategy) = $this->getPath($ePath); if ($strategy === self::RELATIVE_LINKING) { $dirName = dirname($currentCopy . '/' . $entityPath); - $target = $fileSystem->makePathRelative($sharedFolderPath, $dirName) . $entityPath; + $target = $this->makePathRelative($sharedFolderPath, $dirName) . $entityPath; } else { $target = $sharedFolderPath . '/' . $entityPath; } @@ -94,6 +92,43 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware return true; } + /** + * Given an existing path, convert it to a path relative to a given starting path + * + * @param string $endPath Absolute path of target + * @param string $startPath Absolute path where traversal begins + * + * @return string Path of target relative to starting path + * + * @author Fabien Potencier + * @see https://github.com/symfony/Filesystem/blob/v2.6.1/Filesystem.php#L332 + */ + private function makePathRelative($endPath, $startPath) + { + // Normalize separators on Windows + if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + $endPath = strtr($endPath, '\\', '/'); + $startPath = strtr($startPath, '\\', '/'); + } + // Split the paths into arrays + $startPathArr = explode('/', trim($startPath, '/')); + $endPathArr = explode('/', trim($endPath, '/')); + // Find for which directory the common path stops + $index = 0; + while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) { + $index++; + } + // Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels) + $depth = count($startPathArr) - $index; + // Repeated "../" for each level need to reach the common path + $traverser = str_repeat('../', $depth); + $endPathRemainder = implode('/', array_slice($endPathArr, $index)); + // Construct $endPath from traversing to the common path, then to the remaining $endPath + $relativePath = $traverser . (strlen($endPathRemainder) > 0 ? $endPathRemainder . '/' : ''); + + return (strlen($relativePath) === 0) ? './' : $relativePath; + } + /** * @param array|string $linkedEntity * diff --git a/composer.json b/composer.json index 27ef259..2183c74 100644 --- a/composer.json +++ b/composer.json @@ -6,8 +6,7 @@ "type": "library", "keywords": ["deployment"], "require": { - "php": ">=5.3", - "symfony/filesystem": ">=2.1.0,<=2.6.0" + "php": ">=5.3" }, "require-dev": { "phpunit/phpunit": "4.3.5" diff --git a/composer.lock b/composer.lock index b341b73..bc2e079 100644 --- a/composer.lock +++ b/composer.lock @@ -4,56 +4,8 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "61974b12f91cf9124bfd75a369d20ff8", - "packages": [ - { - "name": "symfony/filesystem", - "version": "v2.6.0", - "target-dir": "Symfony/Component/Filesystem", - "source": { - "type": "git", - "url": "https://github.com/symfony/Filesystem.git", - "reference": "6f7c7e42f20ee200d8ac5d2ec1d2a524138305e0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/6f7c7e42f20ee200d8ac5d2ec1d2a524138305e0", - "reference": "6f7c7e42f20ee200d8ac5d2ec1d2a524138305e0", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Filesystem\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Filesystem Component", - "homepage": "http://symfony.com", - "time": "2014-11-16 17:28:09" - } - ], + "hash": "a19528b890d301384e45c1ed7d221e26", + "packages": [], "packages-dev": [ { "name": "doctrine/instantiator", From d2b7e0e94f9890d66d6841d0942deaa2c5ee00fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Huet?= Date: Sat, 13 Dec 2014 13:58:06 +0100 Subject: [PATCH 29/66] Adds Permissions task. Parameters are : paths, checkPathsExist, owner, group, rights --- .../BuiltIn/Filesystem/PermissionsTask.php | 256 ++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 Mage/Task/BuiltIn/Filesystem/PermissionsTask.php diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php new file mode 100644 index 0000000..ee4a91a --- /dev/null +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php @@ -0,0 +1,256 @@ + + */ +class PermissionsTask extends AbstractTask +{ + /** + * Paths to change of permissions separated by PATH_SEPARATOR. + * + * @var string + */ + private $paths; + + /** + * If set to true, will check existance of given paths on remote host and + * throw SkipException if at least one does not exist. + * + * @var boolean + */ + private $checkPathsExist = true; + + /** + * Owner to set for the given paths (ex : "www-data") + * + * @var string + */ + private $owner; + + /** + * Group to set for the given paths (ex : "www-data") + * + * @var string + */ + private $group; + + /** + * Rights to set for the given paths (ex: "755") + * + * @var string + */ + private $rights; + + /** + * Initialize parameters. + * + * @throws SkipException + */ + public function init() + { + parent::init(); + + if (! is_null($this->getParameter('checkPathsExist'))) { + $this->setCheckPathsExist($this->getParameter('checkPathsExist')); + } + + if (! $this->getParameter('paths')) { + throw new SkipException('Param paths is mandatory'); + } + $this->setPaths(explode(PATH_SEPARATOR, $this->getParameter('paths', ''))); + + if (! is_null($this->getParameter('owner'))) { + $this->setOwner($this->getParameter('owner')); + } + + if (! is_null($this->getParameter('group'))) { + $this->setGroup($this->getParameter('group')); + } + + if (! is_null($this->getParameter('rights'))) { + $this->setRights($this->getParameter('rights')); + } + } + + /** + * @return string + */ + public function getName() + { + return "Change rights / owner / group for paths : " . $this->getPathsForCmd() . " [built-in]"; + } + + /** + * @return boolean + */ + public function run() + { + $command = ''; + + if ($this->paths && $this->owner) { + $command .= 'chown -R ' . $this->owner . ' ' . $this->getPathsForCmd() . ';'; + } + + if ($this->paths && $this->group) { + $command .= 'chgrp -R ' . $this->group . ' ' . $this->getPathsForCmd() . ';'; + } + + if ($this->paths && $this->rights) { + $command .= 'chmod -R ' . $this->rights . ' ' . $this->getPathsForCmd() . ';'; + } + + $result = $this->runCommandRemote($command); + + return $result; + } + + /** + * Transforms paths array to a string separated by 1 space in order to use + * it in a command line. + * + * @return string + */ + protected function getPathsForCmd($paths = null) + { + if (is_null($paths)) { + $paths = $this->paths; + } + + return implode(' ', $paths); + } + + /** + * Set paths. Will check if they exist on remote host depending on + * checkPathsExist flag. + * + * @param array $paths + * @return PermissionsTask + * @throws SkipException + */ + protected function setPaths(array $paths) + { + if ($this->checkPathsExist == true) { + $commands = array(); + foreach ($paths as $path) { + $commands[] = '(([ -f ' . $path . ' ]) || ([ -d ' . $path . ' ]))'; + } + + $command = implode(' && ', $commands); + if (! $this->runCommandRemote($command)) { + throw new SkipException('Make sure all paths given exist on remote host : ' . $this->getPathsForCmd($paths)); + } + } + + $this->paths = $paths; + + return $this; + } + + /** + * @return string + */ + protected function getPaths() + { + return $this->paths; + } + + /** + * Set checkPathsExist. + * + * @param boolean $checkPathsExist + * @return PermissionsTask + */ + protected function setCheckPathsExist($checkPathsExist) + { + $this->checkPathsExist = $checkPathsExist; + + return $this; + } + + /** + * @return boolean + */ + protected function getCheckPathsExist() + { + return $this->checkPathsExist; + } + + /** + * Set owner. + * + * @todo check existance of $owner on remote, might be different ways depending on OS. + * + * @param string $owner + * @return PermissionsTask + */ + protected function setOwner($owner) + { + $this->owner = $owner; + + return $this; + } + + /** + * @return string + */ + protected function getOwner() + { + return $this->owner; + } + + /** + * Set group. + * + * @todo check existance of $group on remote, might be different ways depending on OS. + * + * @param string $group + * @return PermissionsTask + */ + protected function setGroup($group) + { + $this->group = $group; + + return $this; + } + + /** + * @return string + */ + protected function getGroup() + { + return $this->group; + } + + /** + * Set rights. + * + * @todo better way to check if $rights is in a correct format. + * + * @param string $rights + * @return PermissionsTask + */ + protected function setRights($rights) + { + if (strlen($rights) != 3 || !is_numeric($rights) || $rights > 777) { + throw new SkipException('Make sure the rights "' . $rights . '" are in a correct format.'); + } + + $this->rights = $rights; + + return $this; + } + + /** + * @return string + */ + protected function getRights() + { + return $this->rights; + } +} \ No newline at end of file From 8247b15ad009c213e26488825460aaa3aa8f12f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Huet?= Date: Sat, 13 Dec 2014 13:59:57 +0100 Subject: [PATCH 30/66] Adds PermissionsWritableByApache task that extends Permissions task we predefined parameters --- .../PermissionsWritableByApacheTask.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php new file mode 100644 index 0000000..57d45da --- /dev/null +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php @@ -0,0 +1,26 @@ + + */ +class PermissionsWritableByApacheTask extends PermissionsTask +{ + public function init() + { + parent::init(); + + $this->setGroup('www-data') + ->setRights('775'); + } + + /** + * @return string + */ + public function getName() + { + return "Gives write permissions to Apache user for given paths [built-in]"; + } +} \ No newline at end of file From a58dcbe7668dd8ebe7a5b39391d1203cfd96388b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Huet?= Date: Sat, 13 Dec 2014 15:14:43 +0100 Subject: [PATCH 31/66] git local commands should be executed in the deployment:from directory --- Mage/Task/BuiltIn/Scm/ChangeBranchTask.php | 5 +++-- Mage/Task/BuiltIn/Scm/UpdateTask.php | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Mage/Task/BuiltIn/Scm/ChangeBranchTask.php b/Mage/Task/BuiltIn/Scm/ChangeBranchTask.php index 8c5e33f..20859c5 100644 --- a/Mage/Task/BuiltIn/Scm/ChangeBranchTask.php +++ b/Mage/Task/BuiltIn/Scm/ChangeBranchTask.php @@ -63,14 +63,15 @@ class ChangeBranchTask extends AbstractTask */ public function run() { + $preCommand = 'cd ' . $this->getConfig()->deployment('from', './') . '; '; switch ($this->getConfig()->general('scm')) { case 'git': if ($this->getParameter('_changeBranchRevert', false)) { - $command = 'git checkout ' . self::$startingBranch; + $command = $preCommand . 'git checkout ' . self::$startingBranch; $result = $this->runCommandLocal($command); } else { - $command = 'git branch | grep \'*\' | cut -d\' \' -f 2'; + $command = $preCommand . 'git branch | grep \'*\' | cut -d\' \' -f 2'; $currentBranch = 'master'; $result = $this->runCommandLocal($command, $currentBranch); diff --git a/Mage/Task/BuiltIn/Scm/UpdateTask.php b/Mage/Task/BuiltIn/Scm/UpdateTask.php index 22c496e..3347a97 100644 --- a/Mage/Task/BuiltIn/Scm/UpdateTask.php +++ b/Mage/Task/BuiltIn/Scm/UpdateTask.php @@ -54,9 +54,10 @@ class UpdateTask extends AbstractTask */ public function run() { + $command = 'cd ' . $this->getConfig()->deployment('from', './') . '; '; switch ($this->getConfig()->general('scm')) { case 'git': - $command = 'git pull'; + $command .= 'git pull'; break; default: From 9d1e6aba6f996440a137753fda3c56744e03d736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Huet?= Date: Sat, 13 Dec 2014 15:57:33 +0100 Subject: [PATCH 32/66] Allow for changing permissions on local host too depending on the stage --- .../BuiltIn/Filesystem/PermissionsTask.php | 28 +++++++++++++------ .../PermissionsWritableByApacheTask.php | 8 +++++- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php index ee4a91a..ab924af 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php @@ -5,7 +5,14 @@ use Mage\Task\AbstractTask; use Mage\Task\SkipException; /** - * Task for setting permissions on given paths. + * Task for setting permissions on given paths. Change will be done on local or + * remote host depending on the stage of the deployment. + * + * Usage : + * pre-deploy: + * - filesystem/permissions: {paths: /var/www/myapp/app/cache:/var/www/myapp/app/cache, checkPathsExist: true, owner: www-data, group: www-data, rights: 775} + * on-deploy: + * - filesystem/permissions: {paths: app/cache:app/logs, checkPathsExist: true, owner: www-data, group: www-data, rights: 775} * * @author Jérémy Huet */ @@ -14,12 +21,15 @@ class PermissionsTask extends AbstractTask /** * Paths to change of permissions separated by PATH_SEPARATOR. * + * If the stage is on local host you should give full paths. If on remote + * you may give full or relative to the current release directory paths. + * * @var string */ private $paths; /** - * If set to true, will check existance of given paths on remote host and + * If set to true, will check existance of given paths on the host and * throw SkipException if at least one does not exist. * * @var boolean @@ -105,7 +115,7 @@ class PermissionsTask extends AbstractTask $command .= 'chmod -R ' . $this->rights . ' ' . $this->getPathsForCmd() . ';'; } - $result = $this->runCommandRemote($command); + $result = $this->runCommand($command); return $result; } @@ -126,7 +136,7 @@ class PermissionsTask extends AbstractTask } /** - * Set paths. Will check if they exist on remote host depending on + * Set paths. Will check if they exist on the host depending on * checkPathsExist flag. * * @param array $paths @@ -142,8 +152,8 @@ class PermissionsTask extends AbstractTask } $command = implode(' && ', $commands); - if (! $this->runCommandRemote($command)) { - throw new SkipException('Make sure all paths given exist on remote host : ' . $this->getPathsForCmd($paths)); + if (! $this->runCommand($command)) { + throw new SkipException('Make sure all paths given exist on the host : ' . $this->getPathsForCmd($paths)); } } @@ -184,7 +194,7 @@ class PermissionsTask extends AbstractTask /** * Set owner. * - * @todo check existance of $owner on remote, might be different ways depending on OS. + * @todo check existance of $owner on host, might be different ways depending on OS. * * @param string $owner * @return PermissionsTask @@ -207,7 +217,7 @@ class PermissionsTask extends AbstractTask /** * Set group. * - * @todo check existance of $group on remote, might be different ways depending on OS. + * @todo check existance of $group on host, might be different ways depending on OS. * * @param string $group * @return PermissionsTask @@ -253,4 +263,4 @@ class PermissionsTask extends AbstractTask { return $this->rights; } -} \ No newline at end of file +} diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php index 57d45da..c786e5e 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php @@ -4,6 +4,12 @@ namespace Mage\Task\BuiltIn\Filesystem; /** * Task for giving Apache write permissions on given paths. * + * Usage : + * pre-deploy: + * - filesystem/permissions-writable-by-apache: {paths: /var/www/myapp/app/cache:/var/www/myapp/app/cache, checkPathsExist: true} + * on-deploy: + * - filesystem/permissions-writable-by-apache: {paths: app/cache:app/logs, checkPathsExist: true} + * * @author Jérémy Huet */ class PermissionsWritableByApacheTask extends PermissionsTask @@ -23,4 +29,4 @@ class PermissionsWritableByApacheTask extends PermissionsTask { return "Gives write permissions to Apache user for given paths [built-in]"; } -} \ No newline at end of file +} From 89d82b9992281763b59e13ce7638fa2663fcf2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Huet?= Date: Sat, 13 Dec 2014 16:05:13 +0100 Subject: [PATCH 33/66] Changing EOL to Linux LF --- .../BuiltIn/Filesystem/PermissionsTask.php | 532 +++++++++--------- .../PermissionsWritableByApacheTask.php | 64 +-- 2 files changed, 298 insertions(+), 298 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php index ab924af..e04ef91 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php @@ -1,266 +1,266 @@ - - */ -class PermissionsTask extends AbstractTask -{ - /** - * Paths to change of permissions separated by PATH_SEPARATOR. - * - * If the stage is on local host you should give full paths. If on remote - * you may give full or relative to the current release directory paths. - * - * @var string - */ - private $paths; - - /** - * If set to true, will check existance of given paths on the host and - * throw SkipException if at least one does not exist. - * - * @var boolean - */ - private $checkPathsExist = true; - - /** - * Owner to set for the given paths (ex : "www-data") - * - * @var string - */ - private $owner; - - /** - * Group to set for the given paths (ex : "www-data") - * - * @var string - */ - private $group; - - /** - * Rights to set for the given paths (ex: "755") - * - * @var string - */ - private $rights; - - /** - * Initialize parameters. - * - * @throws SkipException - */ - public function init() - { - parent::init(); - - if (! is_null($this->getParameter('checkPathsExist'))) { - $this->setCheckPathsExist($this->getParameter('checkPathsExist')); - } - - if (! $this->getParameter('paths')) { - throw new SkipException('Param paths is mandatory'); - } - $this->setPaths(explode(PATH_SEPARATOR, $this->getParameter('paths', ''))); - - if (! is_null($this->getParameter('owner'))) { - $this->setOwner($this->getParameter('owner')); - } - - if (! is_null($this->getParameter('group'))) { - $this->setGroup($this->getParameter('group')); - } - - if (! is_null($this->getParameter('rights'))) { - $this->setRights($this->getParameter('rights')); - } - } - - /** - * @return string - */ - public function getName() - { - return "Change rights / owner / group for paths : " . $this->getPathsForCmd() . " [built-in]"; - } - - /** - * @return boolean - */ - public function run() - { - $command = ''; - - if ($this->paths && $this->owner) { - $command .= 'chown -R ' . $this->owner . ' ' . $this->getPathsForCmd() . ';'; - } - - if ($this->paths && $this->group) { - $command .= 'chgrp -R ' . $this->group . ' ' . $this->getPathsForCmd() . ';'; - } - - if ($this->paths && $this->rights) { - $command .= 'chmod -R ' . $this->rights . ' ' . $this->getPathsForCmd() . ';'; - } - - $result = $this->runCommand($command); - - return $result; - } - - /** - * Transforms paths array to a string separated by 1 space in order to use - * it in a command line. - * - * @return string - */ - protected function getPathsForCmd($paths = null) - { - if (is_null($paths)) { - $paths = $this->paths; - } - - return implode(' ', $paths); - } - - /** - * Set paths. Will check if they exist on the host depending on - * checkPathsExist flag. - * - * @param array $paths - * @return PermissionsTask - * @throws SkipException - */ - protected function setPaths(array $paths) - { - if ($this->checkPathsExist == true) { - $commands = array(); - foreach ($paths as $path) { - $commands[] = '(([ -f ' . $path . ' ]) || ([ -d ' . $path . ' ]))'; - } - - $command = implode(' && ', $commands); - if (! $this->runCommand($command)) { - throw new SkipException('Make sure all paths given exist on the host : ' . $this->getPathsForCmd($paths)); - } - } - - $this->paths = $paths; - - return $this; - } - - /** - * @return string - */ - protected function getPaths() - { - return $this->paths; - } - - /** - * Set checkPathsExist. - * - * @param boolean $checkPathsExist - * @return PermissionsTask - */ - protected function setCheckPathsExist($checkPathsExist) - { - $this->checkPathsExist = $checkPathsExist; - - return $this; - } - - /** - * @return boolean - */ - protected function getCheckPathsExist() - { - return $this->checkPathsExist; - } - - /** - * Set owner. - * - * @todo check existance of $owner on host, might be different ways depending on OS. - * - * @param string $owner - * @return PermissionsTask - */ - protected function setOwner($owner) - { - $this->owner = $owner; - - return $this; - } - - /** - * @return string - */ - protected function getOwner() - { - return $this->owner; - } - - /** - * Set group. - * - * @todo check existance of $group on host, might be different ways depending on OS. - * - * @param string $group - * @return PermissionsTask - */ - protected function setGroup($group) - { - $this->group = $group; - - return $this; - } - - /** - * @return string - */ - protected function getGroup() - { - return $this->group; - } - - /** - * Set rights. - * - * @todo better way to check if $rights is in a correct format. - * - * @param string $rights - * @return PermissionsTask - */ - protected function setRights($rights) - { - if (strlen($rights) != 3 || !is_numeric($rights) || $rights > 777) { - throw new SkipException('Make sure the rights "' . $rights . '" are in a correct format.'); - } - - $this->rights = $rights; - - return $this; - } - - /** - * @return string - */ - protected function getRights() - { - return $this->rights; - } -} + + */ +class PermissionsTask extends AbstractTask +{ + /** + * Paths to change of permissions separated by PATH_SEPARATOR. + * + * If the stage is on local host you should give full paths. If on remote + * you may give full or relative to the current release directory paths. + * + * @var string + */ + private $paths; + + /** + * If set to true, will check existance of given paths on the host and + * throw SkipException if at least one does not exist. + * + * @var boolean + */ + private $checkPathsExist = true; + + /** + * Owner to set for the given paths (ex : "www-data") + * + * @var string + */ + private $owner; + + /** + * Group to set for the given paths (ex : "www-data") + * + * @var string + */ + private $group; + + /** + * Rights to set for the given paths (ex: "755") + * + * @var string + */ + private $rights; + + /** + * Initialize parameters. + * + * @throws SkipException + */ + public function init() + { + parent::init(); + + if (! is_null($this->getParameter('checkPathsExist'))) { + $this->setCheckPathsExist($this->getParameter('checkPathsExist')); + } + + if (! $this->getParameter('paths')) { + throw new SkipException('Param paths is mandatory'); + } + $this->setPaths(explode(PATH_SEPARATOR, $this->getParameter('paths', ''))); + + if (! is_null($this->getParameter('owner'))) { + $this->setOwner($this->getParameter('owner')); + } + + if (! is_null($this->getParameter('group'))) { + $this->setGroup($this->getParameter('group')); + } + + if (! is_null($this->getParameter('rights'))) { + $this->setRights($this->getParameter('rights')); + } + } + + /** + * @return string + */ + public function getName() + { + return "Change rights / owner / group for paths : " . $this->getPathsForCmd() . " [built-in]"; + } + + /** + * @return boolean + */ + public function run() + { + $command = ''; + + if ($this->paths && $this->owner) { + $command .= 'chown -R ' . $this->owner . ' ' . $this->getPathsForCmd() . ';'; + } + + if ($this->paths && $this->group) { + $command .= 'chgrp -R ' . $this->group . ' ' . $this->getPathsForCmd() . ';'; + } + + if ($this->paths && $this->rights) { + $command .= 'chmod -R ' . $this->rights . ' ' . $this->getPathsForCmd() . ';'; + } + + $result = $this->runCommand($command); + + return $result; + } + + /** + * Transforms paths array to a string separated by 1 space in order to use + * it in a command line. + * + * @return string + */ + protected function getPathsForCmd($paths = null) + { + if (is_null($paths)) { + $paths = $this->paths; + } + + return implode(' ', $paths); + } + + /** + * Set paths. Will check if they exist on the host depending on + * checkPathsExist flag. + * + * @param array $paths + * @return PermissionsTask + * @throws SkipException + */ + protected function setPaths(array $paths) + { + if ($this->checkPathsExist == true) { + $commands = array(); + foreach ($paths as $path) { + $commands[] = '(([ -f ' . $path . ' ]) || ([ -d ' . $path . ' ]))'; + } + + $command = implode(' && ', $commands); + if (! $this->runCommand($command)) { + throw new SkipException('Make sure all paths given exist on the host : ' . $this->getPathsForCmd($paths)); + } + } + + $this->paths = $paths; + + return $this; + } + + /** + * @return string + */ + protected function getPaths() + { + return $this->paths; + } + + /** + * Set checkPathsExist. + * + * @param boolean $checkPathsExist + * @return PermissionsTask + */ + protected function setCheckPathsExist($checkPathsExist) + { + $this->checkPathsExist = $checkPathsExist; + + return $this; + } + + /** + * @return boolean + */ + protected function getCheckPathsExist() + { + return $this->checkPathsExist; + } + + /** + * Set owner. + * + * @todo check existance of $owner on host, might be different ways depending on OS. + * + * @param string $owner + * @return PermissionsTask + */ + protected function setOwner($owner) + { + $this->owner = $owner; + + return $this; + } + + /** + * @return string + */ + protected function getOwner() + { + return $this->owner; + } + + /** + * Set group. + * + * @todo check existance of $group on host, might be different ways depending on OS. + * + * @param string $group + * @return PermissionsTask + */ + protected function setGroup($group) + { + $this->group = $group; + + return $this; + } + + /** + * @return string + */ + protected function getGroup() + { + return $this->group; + } + + /** + * Set rights. + * + * @todo better way to check if $rights is in a correct format. + * + * @param string $rights + * @return PermissionsTask + */ + protected function setRights($rights) + { + if (strlen($rights) != 3 || !is_numeric($rights) || $rights > 777) { + throw new SkipException('Make sure the rights "' . $rights . '" are in a correct format.'); + } + + $this->rights = $rights; + + return $this; + } + + /** + * @return string + */ + protected function getRights() + { + return $this->rights; + } +} diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php index c786e5e..5bb3f7c 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php @@ -1,32 +1,32 @@ - - */ -class PermissionsWritableByApacheTask extends PermissionsTask -{ - public function init() - { - parent::init(); - - $this->setGroup('www-data') - ->setRights('775'); - } - - /** - * @return string - */ - public function getName() - { - return "Gives write permissions to Apache user for given paths [built-in]"; - } -} + + */ +class PermissionsWritableByApacheTask extends PermissionsTask +{ + public function init() + { + parent::init(); + + $this->setGroup('www-data') + ->setRights('775'); + } + + /** + * @return string + */ + public function getName() + { + return "Gives write permissions to Apache user for given paths [built-in]"; + } +} From e449a4529fc52987afb8f2170ac5f0c597ec3b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Huet?= Date: Sat, 13 Dec 2014 16:22:56 +0100 Subject: [PATCH 34/66] Adds a recursive parameter and allows for more chmod possibilities such as +a --- .../BuiltIn/Filesystem/PermissionsTask.php | 51 +++++++++++++++---- .../PermissionsWritableByApacheTask.php | 6 +-- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php index e04ef91..167f1d2 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php @@ -10,9 +10,9 @@ use Mage\Task\SkipException; * * Usage : * pre-deploy: - * - filesystem/permissions: {paths: /var/www/myapp/app/cache:/var/www/myapp/app/cache, checkPathsExist: true, owner: www-data, group: www-data, rights: 775} + * - filesystem/permissions: {paths: /var/www/myapp/app/cache:/var/www/myapp/app/cache, recursive: false, checkPathsExist: true, owner: www-data, group: www-data, rights: 775} * on-deploy: - * - filesystem/permissions: {paths: app/cache:app/logs, checkPathsExist: true, owner: www-data, group: www-data, rights: 775} + * - filesystem/permissions: {paths: app/cache:app/logs, recursive: false, checkPathsExist: true, owner: www-data, group: www-data, rights: 775} * * @author Jérémy Huet */ @@ -57,6 +57,13 @@ class PermissionsTask extends AbstractTask */ private $rights; + /** + * If set to true, will recursively change permissions on given paths. + * + * @var string + */ + private $recursive = false; + /** * Initialize parameters. * @@ -86,6 +93,10 @@ class PermissionsTask extends AbstractTask if (! is_null($this->getParameter('rights'))) { $this->setRights($this->getParameter('rights')); } + + if (! is_null($this->getParameter('recursive'))) { + $this->setRecursive($this->getParameter('recursive')); + } } /** @@ -102,17 +113,18 @@ class PermissionsTask extends AbstractTask public function run() { $command = ''; + $recursive = $this->recursive ? '-R' : ''; if ($this->paths && $this->owner) { - $command .= 'chown -R ' . $this->owner . ' ' . $this->getPathsForCmd() . ';'; + $command .= 'chown '. $recursive .' ' . $this->owner . ' ' . $this->getPathsForCmd() . ';'; } if ($this->paths && $this->group) { - $command .= 'chgrp -R ' . $this->group . ' ' . $this->getPathsForCmd() . ';'; + $command .= 'chgrp '. $recursive .' ' . $this->group . ' ' . $this->getPathsForCmd() . ';'; } if ($this->paths && $this->rights) { - $command .= 'chmod -R ' . $this->rights . ' ' . $this->getPathsForCmd() . ';'; + $command .= 'chmod '. $recursive .' ' . $this->rights . ' ' . $this->getPathsForCmd() . ';'; } $result = $this->runCommand($command); @@ -178,7 +190,7 @@ class PermissionsTask extends AbstractTask */ protected function setCheckPathsExist($checkPathsExist) { - $this->checkPathsExist = $checkPathsExist; + $this->checkPathsExist = (bool) $checkPathsExist; return $this; } @@ -240,17 +252,13 @@ class PermissionsTask extends AbstractTask /** * Set rights. * - * @todo better way to check if $rights is in a correct format. + * @todo check if $rights is in a correct format. * * @param string $rights * @return PermissionsTask */ protected function setRights($rights) { - if (strlen($rights) != 3 || !is_numeric($rights) || $rights > 777) { - throw new SkipException('Make sure the rights "' . $rights . '" are in a correct format.'); - } - $this->rights = $rights; return $this; @@ -263,4 +271,25 @@ class PermissionsTask extends AbstractTask { return $this->rights; } + + /** + * Set recursive. + * + * @param boolean $recursive + * @return PermissionsTask + */ + protected function setRecursive($recursive) + { + $this->recursive = (bool) $recursive; + + return $this; + } + + /** + * @return boolean + */ + protected function getRecursive() + { + return $this->recursive; + } } diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php index 5bb3f7c..defd90e 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php @@ -6,9 +6,9 @@ namespace Mage\Task\BuiltIn\Filesystem; * * Usage : * pre-deploy: - * - filesystem/permissions-writable-by-apache: {paths: /var/www/myapp/app/cache:/var/www/myapp/app/cache, checkPathsExist: true} + * - filesystem/permissions-writable-by-apache: {paths: /var/www/myapp/app/cache:/var/www/myapp/app/cache, recursive: false, checkPathsExist: true} * on-deploy: - * - filesystem/permissions-writable-by-apache: {paths: app/cache:app/logs, checkPathsExist: true} + * - filesystem/permissions-writable-by-apache: {paths: app/cache:app/logs, recursive: false, checkPathsExist: true} * * @author Jérémy Huet */ @@ -19,7 +19,7 @@ class PermissionsWritableByApacheTask extends PermissionsTask parent::init(); $this->setGroup('www-data') - ->setRights('775'); + ->setRights('g+w'); } /** From 979a86992cbc9dcd3ef3674f1c71ff766eca4708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Huet?= Date: Sat, 13 Dec 2014 16:44:47 +0100 Subject: [PATCH 35/66] More generic way to retrieve web server user --- .../PermissionsWritableByApacheTask.php | 32 ----------- .../PermissionsWritableByWebServerTask.php | 54 +++++++++++++++++++ 2 files changed, 54 insertions(+), 32 deletions(-) delete mode 100644 Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php create mode 100644 Mage/Task/BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php deleted file mode 100644 index defd90e..0000000 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByApacheTask.php +++ /dev/null @@ -1,32 +0,0 @@ - - */ -class PermissionsWritableByApacheTask extends PermissionsTask -{ - public function init() - { - parent::init(); - - $this->setGroup('www-data') - ->setRights('g+w'); - } - - /** - * @return string - */ - public function getName() - { - return "Gives write permissions to Apache user for given paths [built-in]"; - } -} diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php new file mode 100644 index 0000000..69ad065 --- /dev/null +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php @@ -0,0 +1,54 @@ + + */ +class PermissionsWritableByWebServerTask extends PermissionsTask +{ + /** + * Set group with web server user and give group write permissions. + */ + public function init() + { + parent::init(); + + $this->setGroup($this->getParameter('group', $this->getWebServerUser())) + ->setRights('g+w'); + } + + /** + * @return string + */ + public function getName() + { + return "Gives write permissions to web server user for given paths [built-in]"; + } + + /** + * Tries to guess the web server user by going thru the running processes. + * + * @return string + * @throws SkipException + */ + protected function getWebServerUser() + { + $this->runCommand("ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1", $webServerUser); + + if (empty($webServerUser)) { + throw new SkipException("Can't guess web server user. Please check if it is running or force it by setting the group parameter"); + } + + return $webServerUser; + } +} From ffdadb45cf480a7522ec2962c847c6a29596629a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Huet?= Date: Mon, 15 Dec 2014 18:50:09 +0100 Subject: [PATCH 36/66] More generic way to handle command line options --- .../BuiltIn/Filesystem/PermissionsTask.php | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php index 167f1d2..981a0de 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php @@ -113,18 +113,17 @@ class PermissionsTask extends AbstractTask public function run() { $command = ''; - $recursive = $this->recursive ? '-R' : ''; if ($this->paths && $this->owner) { - $command .= 'chown '. $recursive .' ' . $this->owner . ' ' . $this->getPathsForCmd() . ';'; + $command .= 'chown '. $this->getOptionsForCmd() .' ' . $this->owner . ' ' . $this->getPathsForCmd() . ';'; } if ($this->paths && $this->group) { - $command .= 'chgrp '. $recursive .' ' . $this->group . ' ' . $this->getPathsForCmd() . ';'; + $command .= 'chgrp '. $this->getOptionsForCmd() .' ' . $this->group . ' ' . $this->getPathsForCmd() . ';'; } if ($this->paths && $this->rights) { - $command .= 'chmod '. $recursive .' ' . $this->rights . ' ' . $this->getPathsForCmd() . ';'; + $command .= 'chmod '. $this->getOptionsForCmd() .' ' . $this->rights . ' ' . $this->getPathsForCmd() . ';'; } $result = $this->runCommand($command); @@ -132,6 +131,27 @@ class PermissionsTask extends AbstractTask return $result; } + /** + * Returns the options for the commands to run. Only supports -R for now. + * + * @return string + */ + protected function getOptionsForCmd() + { + $optionsForCmd = ''; + $options = array( + 'R' => $this->recursive + ); + + foreach($options as $option => $apply) { + if ($apply == true) { + $optionsForCmd .= $option; + } + } + + return $optionsForCmd ? '-' . $optionsForCmd : ''; + } + /** * Transforms paths array to a string separated by 1 space in order to use * it in a command line. From 209c6b9aa319184f973b459b1d4a4d3abc5a4394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Huet?= Date: Mon, 15 Dec 2014 18:50:27 +0100 Subject: [PATCH 37/66] typo --- .../BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php index 69ad065..66ba1d7 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php @@ -8,7 +8,7 @@ use Mage\Task\SkipException; * * Usage : * pre-deploy: - * - filesystem/permissions-writable-by-web-server: {paths: /var/www/myapp/app/cache:/var/www/myapp/app/cache, recursive: false, checkPathsExist: true} + * - filesystem/permissions-writable-by-web-server: {paths: /var/www/myapp/app/cache:/var/www/myapp/app/logs, recursive: false, checkPathsExist: true} * on-deploy: * - filesystem/permissions-writable-by-web-server: {paths: app/cache:app/logs, recursive: false, checkPathsExist: true} * From 42d3d5a8a139c61b1d663e5ab0616ebb9af59f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Huet?= Date: Thu, 18 Dec 2014 17:45:12 +0100 Subject: [PATCH 38/66] Better usage doc + allow to set owner and group by using www-data:www-data syntax + task now fails if at least one command returns error --- .../BuiltIn/Filesystem/PermissionsTask.php | 50 ++++++++++++------- .../PermissionsWritableByWebServerTask.php | 8 ++- 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php index 981a0de..8f1f6f4 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php @@ -11,6 +11,14 @@ use Mage\Task\SkipException; * Usage : * pre-deploy: * - filesystem/permissions: {paths: /var/www/myapp/app/cache:/var/www/myapp/app/cache, recursive: false, checkPathsExist: true, owner: www-data, group: www-data, rights: 775} + * - filesystem/permissions: + * paths: + * - /var/www/myapp/app/cache + * - /var/www/myapp/app/logs + * recursive: false + * checkPathsExist: true + * owner: www-data:www-data + * rights: 775 * on-deploy: * - filesystem/permissions: {paths: app/cache:app/logs, recursive: false, checkPathsExist: true, owner: www-data, group: www-data, rights: 775} * @@ -37,7 +45,8 @@ class PermissionsTask extends AbstractTask private $checkPathsExist = true; /** - * Owner to set for the given paths (ex : "www-data") + * Owner to set for the given paths (ex : "www-data" or "www-data:www-data" + * to set both owner and group at the same time) * * @var string */ @@ -51,7 +60,7 @@ class PermissionsTask extends AbstractTask private $group; /** - * Rights to set for the given paths (ex: "755") + * Rights to set for the given paths (ex: "755" or "g+w") * * @var string */ @@ -80,22 +89,27 @@ class PermissionsTask extends AbstractTask if (! $this->getParameter('paths')) { throw new SkipException('Param paths is mandatory'); } - $this->setPaths(explode(PATH_SEPARATOR, $this->getParameter('paths', ''))); - - if (! is_null($this->getParameter('owner'))) { - $this->setOwner($this->getParameter('owner')); + $this->setPaths(is_array($this->getParameter('paths')) ? $this->getParameter('paths') : explode(PATH_SEPARATOR, $this->getParameter('paths', ''))); + + if (! is_null($owner = $this->getParameter('owner'))) { + if (strpos($owner, ':') !== false) { + $this->setOwner(array_shift(explode(':', $owner))); + $this->setGroup(array_pop(explode(':', $owner))); + } else { + $this->setOwner($owner); + } } - if (! is_null($this->getParameter('group'))) { - $this->setGroup($this->getParameter('group')); + if (! is_null($group = $this->getParameter('group'))) { + $this->setGroup($group); } - if (! is_null($this->getParameter('rights'))) { - $this->setRights($this->getParameter('rights')); + if (! is_null($rights = $this->getParameter('rights'))) { + $this->setRights($rights); } - if (! is_null($this->getParameter('recursive'))) { - $this->setRecursive($this->getParameter('recursive')); + if (! is_null($recursive = $this->getParameter('recursive'))) { + $this->setRecursive($recursive); } } @@ -104,7 +118,7 @@ class PermissionsTask extends AbstractTask */ public function getName() { - return "Change rights / owner / group for paths : " . $this->getPathsForCmd() . " [built-in]"; + return "Changing rights / owner / group for given paths [built-in]"; } /** @@ -112,21 +126,21 @@ class PermissionsTask extends AbstractTask */ public function run() { - $command = ''; + $commands = array(); if ($this->paths && $this->owner) { - $command .= 'chown '. $this->getOptionsForCmd() .' ' . $this->owner . ' ' . $this->getPathsForCmd() . ';'; + $commands []= 'chown '. $this->getOptionsForCmd() .' ' . $this->owner . ' ' . $this->getPathsForCmd(); } if ($this->paths && $this->group) { - $command .= 'chgrp '. $this->getOptionsForCmd() .' ' . $this->group . ' ' . $this->getPathsForCmd() . ';'; + $commands []= 'chgrp '. $this->getOptionsForCmd() .' ' . $this->group . ' ' . $this->getPathsForCmd(); } if ($this->paths && $this->rights) { - $command .= 'chmod '. $this->getOptionsForCmd() .' ' . $this->rights . ' ' . $this->getPathsForCmd() . ';'; + $commands []= 'chmod '. $this->getOptionsForCmd() .' ' . $this->rights . ' ' . $this->getPathsForCmd(); } - $result = $this->runCommand($command); + $result = $this->runCommand(implode(' && ', $commands)); return $result; } diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php index 66ba1d7..ec1fe7d 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php @@ -9,6 +9,12 @@ use Mage\Task\SkipException; * Usage : * pre-deploy: * - filesystem/permissions-writable-by-web-server: {paths: /var/www/myapp/app/cache:/var/www/myapp/app/logs, recursive: false, checkPathsExist: true} + * - filesystem/permissions-writable-by-web-server: + * paths: + * - /var/www/myapp/app/cache + * - /var/www/myapp/app/logs + * recursive: false + * checkPathsExist: true * on-deploy: * - filesystem/permissions-writable-by-web-server: {paths: app/cache:app/logs, recursive: false, checkPathsExist: true} * @@ -32,7 +38,7 @@ class PermissionsWritableByWebServerTask extends PermissionsTask */ public function getName() { - return "Gives write permissions to web server user for given paths [built-in]"; + return "Giving write permissions to web server user for given paths [built-in]"; } /** From fbc50a52bd25d5d9eb2e5d59e2c57cfe93b7ae9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Huet?= Date: Thu, 18 Dec 2014 17:46:13 +0100 Subject: [PATCH 39/66] Adds a task to only have read permission for web server --- ...PermissionsReadableOnlyByWebServerTask.php | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Mage/Task/BuiltIn/Filesystem/PermissionsReadableOnlyByWebServerTask.php diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsReadableOnlyByWebServerTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsReadableOnlyByWebServerTask.php new file mode 100644 index 0000000..d0a04e8 --- /dev/null +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsReadableOnlyByWebServerTask.php @@ -0,0 +1,60 @@ + + */ +class PermissionsReadableOnlyByWebServerTask extends PermissionsTask +{ + /** + * Set group with web server user and give group write permissions. + */ + public function init() + { + parent::init(); + + $this->setGroup($this->getParameter('group', $this->getWebServerUser())) + ->setRights('040'); + } + + /** + * @return string + */ + public function getName() + { + return "Giving read permissions only to web server user for given paths [built-in]"; + } + + /** + * Tries to guess the web server user by going thru the running processes. + * + * @return string + * @throws SkipException + */ + protected function getWebServerUser() + { + $this->runCommand("ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1", $webServerUser); + + if (empty($webServerUser)) { + throw new SkipException("Can't guess web server user. Please check if it is running or force it by setting the group parameter"); + } + + return $webServerUser; + } +} From 5643616e50581dbb29d8ce1b177af56b1c297ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Huet?= Date: Sun, 28 Dec 2014 16:47:59 +0100 Subject: [PATCH 40/66] Only tries to guess web server user if none provided with 'group' parameter --- .../Filesystem/PermissionsReadableOnlyByWebServerTask.php | 2 +- Mage/Task/BuiltIn/Filesystem/PermissionsTask.php | 3 ++- .../BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsReadableOnlyByWebServerTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsReadableOnlyByWebServerTask.php index d0a04e8..375489d 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsReadableOnlyByWebServerTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsReadableOnlyByWebServerTask.php @@ -29,7 +29,7 @@ class PermissionsReadableOnlyByWebServerTask extends PermissionsTask { parent::init(); - $this->setGroup($this->getParameter('group', $this->getWebServerUser())) + $this->setGroup($this->getParameter('group') ? $this->getParameter('group') : $this->getWebServerUser()) ->setRights('040'); } diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php index 8f1f6f4..171770b 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php @@ -27,7 +27,8 @@ use Mage\Task\SkipException; class PermissionsTask extends AbstractTask { /** - * Paths to change of permissions separated by PATH_SEPARATOR. + * Paths to change of permissions in an array or a string separated by + * PATH_SEPARATOR. * * If the stage is on local host you should give full paths. If on remote * you may give full or relative to the current release directory paths. diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php index ec1fe7d..6abaf07 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsWritableByWebServerTask.php @@ -29,7 +29,7 @@ class PermissionsWritableByWebServerTask extends PermissionsTask { parent::init(); - $this->setGroup($this->getParameter('group', $this->getWebServerUser())) + $this->setGroup($this->getParameter('group') ? $this->getParameter('group') : $this->getWebServerUser()) ->setRights('g+w'); } From 70c482358164a61be7f6ef82d7e97ca3a24b5077 Mon Sep 17 00:00:00 2001 From: Alexander Miehe Date: Fri, 9 Jan 2015 14:05:37 +0100 Subject: [PATCH 41/66] Add config option to set ConnectTimeout for ssh connections --- Mage/Config.php | 10 ++++++++++ Mage/Task/AbstractTask.php | 1 + Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Mage/Config.php b/Mage/Config.php index e839c22..dd78593 100644 --- a/Mage/Config.php +++ b/Mage/Config.php @@ -391,6 +391,16 @@ class Config return $this->deployment('identity-file') ? ('-i ' . $this->deployment('identity-file') . ' ') : ''; } + /** + * Get the ConnectTimeout option + * + * @return string + */ + public function getConnectTimeoutOption() + { + return $this->environmentConfig('connect-timeout') ? ('-o ConnectTimeout=' . $this->environmentConfig('connect-timeout') . ' ') : ''; + } + /** * Get the current Host * diff --git a/Mage/Task/AbstractTask.php b/Mage/Task/AbstractTask.php index 663b387..491adfb 100644 --- a/Mage/Task/AbstractTask.php +++ b/Mage/Task/AbstractTask.php @@ -201,6 +201,7 @@ abstract class AbstractTask $localCommand = 'ssh ' . $this->getConfig()->getHostIdentityFileOption() . $needs_tty . ' -p ' . $this->getConfig()->getHostPort() . ' ' . '-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ' + . $this->getConfig()->getConnectTimeoutOption() . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName(); $remoteCommand = str_replace('"', '\"', $command); diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php index d45ea17..9bb1b25 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php @@ -89,7 +89,7 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware } // Copy Tar Gz to Remote Host - $command = 'scp ' . $strategyFlags . ' ' . $this->getConfig()->getHostIdentityFileOption() . '-P ' . $this->getConfig()->getHostPort() . ' ' . $localTarGz . '.tar.gz ' + $command = 'scp ' . $strategyFlags . ' ' . $this->getConfig()->getHostIdentityFileOption() . $this->getConfig()->getConnectTimeoutOption() . '-P ' . $this->getConfig()->getHostPort() . ' ' . $localTarGz . '.tar.gz ' . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ':' . $deployToDirectory; $result = $this->runCommandLocal($command) && $result; From d25d0153560586345b59683ac4b92a3f9aeaa9b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Huet?= Date: Mon, 12 Jan 2015 18:50:32 +0100 Subject: [PATCH 42/66] Rollback directory should include deployment:to config variable --- Mage/Task/BuiltIn/Releases/RollbackTask.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Mage/Task/BuiltIn/Releases/RollbackTask.php b/Mage/Task/BuiltIn/Releases/RollbackTask.php index 1de9831..b4e43d7 100644 --- a/Mage/Task/BuiltIn/Releases/RollbackTask.php +++ b/Mage/Task/BuiltIn/Releases/RollbackTask.php @@ -51,6 +51,10 @@ class RollbackTask extends AbstractTask implements IsReleaseAware $releasesDirectory = $this->getConfig()->release('directory', 'releases'); $symlink = $this->getConfig()->release('symlink', 'current'); + if (substr($symlink, 0, 1) == '/') { + $releasesDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory; + } + $output = ''; $result = $this->runCommandRemote('ls -1 ' . $releasesDirectory, $output); $releases = ($output == '') ? array() : explode(PHP_EOL, $output); From 4cdb95f3beb1aaaa11010b01a92cd5a33d4c0f9d Mon Sep 17 00:00:00 2001 From: Alexander Miehe Date: Mon, 12 Jan 2015 19:50:19 +0100 Subject: [PATCH 43/66] make h option for targz optional, default is set h option --- Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php index 9bb1b25..625bd7b 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php @@ -77,7 +77,10 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware $strategyFlags = ''; } - $command = 'tar cfzh' . $strategyFlags . ' ' . $localTarGz . '.tar.gz ' . $excludeCmd . $excludeFromFileCmd . ' -C ' . $this->getConfig()->deployment('from') . ' .'; + // remove h option only if dump_symlinks is allowed in the release config part + $dumpSymlinks = $this->getConfig()->release('dump_symlinks') ? '' : 'h'; + + $command = 'tar cfz'. $dumpSymlinks . $strategyFlags . ' ' . $localTarGz . '.tar.gz ' . $excludeCmd . $excludeFromFileCmd . ' -C ' . $this->getConfig()->deployment('from') . ' .'; $result = $this->runCommandLocal($command); // Strategy Flags From bbeedffd82f5683918aec5b8f865560f48e88909 Mon Sep 17 00:00:00 2001 From: Stefan Paletta Date: Tue, 13 Jan 2015 17:16:52 +0100 Subject: [PATCH 44/66] make ApplyFaclsTask compatible with default AbstractTask::runCommandRemote()parameter $cdToDirectoryFirst=true --- Mage/Task/BuiltIn/Filesystem/ApplyFaclsTask.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Mage/Task/BuiltIn/Filesystem/ApplyFaclsTask.php b/Mage/Task/BuiltIn/Filesystem/ApplyFaclsTask.php index 03786ce..3f40ee7 100644 --- a/Mage/Task/BuiltIn/Filesystem/ApplyFaclsTask.php +++ b/Mage/Task/BuiltIn/Filesystem/ApplyFaclsTask.php @@ -25,7 +25,6 @@ class ApplyFaclsTask extends AbstractTask implements IsReleaseAware public function run() { $releasesDirectory = $this->getConfig()->release('directory', 'releases'); - $releasesDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory; $currentCopy = $releasesDirectory . '/' . $this->getConfig()->getReleaseId(); From 55a5c0c640f939d0164fbea503467e4102c71709 Mon Sep 17 00:00:00 2001 From: Alexander Miehe Date: Wed, 14 Jan 2015 09:30:52 +0100 Subject: [PATCH 45/66] Fix key name to follow naming convention --- Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php index 625bd7b..ba16246 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php @@ -77,8 +77,8 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware $strategyFlags = ''; } - // remove h option only if dump_symlinks is allowed in the release config part - $dumpSymlinks = $this->getConfig()->release('dump_symlinks') ? '' : 'h'; + // remove h option only if dump-symlinks is allowed in the release config part + $dumpSymlinks = $this->getConfig()->release('dump-symlinks') ? '' : 'h'; $command = 'tar cfz'. $dumpSymlinks . $strategyFlags . ' ' . $localTarGz . '.tar.gz ' . $excludeCmd . $excludeFromFileCmd . ' -C ' . $this->getConfig()->deployment('from') . ' .'; $result = $this->runCommandLocal($command); From 1a81e7000ba347b680972d7d92440a0c74c62e38 Mon Sep 17 00:00:00 2001 From: Alexander Miehe Date: Wed, 14 Jan 2015 11:49:31 +0100 Subject: [PATCH 46/66] Add example config with explanation --- .../production.yml.dump-symlinks.txt | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docs/example-config/.mage/config/environment/production.yml.dump-symlinks.txt diff --git a/docs/example-config/.mage/config/environment/production.yml.dump-symlinks.txt b/docs/example-config/.mage/config/environment/production.yml.dump-symlinks.txt new file mode 100644 index 0000000..1ff2547 --- /dev/null +++ b/docs/example-config/.mage/config/environment/production.yml.dump-symlinks.txt @@ -0,0 +1,43 @@ +#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 +# This option allows to dump the symlink with the TarGz strategy and use the symlink on the deployment host. +# This is useful, if the files the symlink point to only exist on the deployment host and not on the host who runs the mage command. +# The default value is false to keep bc. +# See : http://linux.die.net/man/1/tar -h, --dereference + dump-symlinks: true +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 27bc2b7de097cbb1fe2ee2b5af1b61d6920c2d32 Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Fri, 16 Jan 2015 19:36:25 +0100 Subject: [PATCH 47/66] Add contribution guidelines --- CONTRIBUTING.md | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..826aaf2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,71 @@ +Contributor guidelines for Magallanes +===================================== +Welcome to Magallanes! We are much appreciated you've decided to contribute this project! +Please read the following guidelines to make your and our work easier and cleaner. + +**TL;DR** + +1. Write clean code with no mess left +2. Contribute the docs when adding configurable new feature +3. Push your code into `develop` branch +4. Ensure your code is fully covered by tests + + +---------- + +# Reporting issues +If you have a problem or you've noticed some bug, please feel free to open new issue. However please follow the rules below: +* First, make sure that similar/the same issue doesn't already exist +* If you've already found the solution of the problem you are about to report, plaase feel free to open new pull request. Then follow the rules below in **Developing Magallanes** section. +* If you are able to, include some test cases or steps to reproduce the bug for us to examine the problem to reach the problem origin. + +## Opening pull requests +Pull Request are actually some kind of issues with code, so please keep the rules above in **Reporting issues** section before making the pull requests. +Our code isn't so beautiful, tested and testable as we would like it to be but if you're pushing your code please be sure it meets the requirements from **Organization and code quality** chapter. We want to improve the existing code to facilitate extending it and making fixes quicker. So if you are editing some class and you find it ugly, please do not ignore it. Following [The Boy Scout Rule](http://www.informit.com/articles/article.aspx?p=1235624&seqNum=6) - *Leave the campground cleaner than you found it* - we allcan improve the existing code. + +## Contributing the documentation +Magallanes is made to deploy application quick and with no need to write redudant code. Usage is as simple as writing the configuration for target project in YAML files. In the nearest future we would like to make some Wiki with all available options, tasks and commands. For now, the only "documentation" is examples file in `doc` directory. If the code you are going to include in your pull requests adds or changes config options, please make sure you that you create a new sample in that file. You should also to the same with commands. + +# Developing Magallanes +## Branches +The flow is pretty simple. +In most common cases we work on `develop` branch. It's a branch with the newest changes which sometimes need more testing. All pull requests are opened to be merged into that branch. That keeps us safe to not deploy unsafe code into production - `master` branch. When we decide that every changeset in `develop` is tested manually and works as it's intented, we merge it to master. +If the change you commited is pretty hot and needs to be released ASAP, you are allowed to make a pull request to `master` branch. But it's the only case, please try to avoid it. All pull request that are not made on `develop` will be rejected. +If you want to use develop branch in your code, simple pass `dev-develop` to dependency version in your `composer.json` file: +```json +{ + "require": { + "andres-montanez/magallanes": "dev-develop" + } +} +``` +## Organization and code quality +We use [PSR2](http://www.php-fig.org/psr/psr-2/) as PHP coding standard. +Some of rules we follow that are not included in document above: + +* Variables' and properties' names are camelCased (e.g.: `$thisIsMyVariable`) +* Avoid too long or too short variables' and methods' names, like `$thisIsMyAwesomeVariableAndImProudOfIt` +* Names of your properties/method should be intuitive and self-describing - that means your code should look like a book. Developer who reads the code should immediately know what the variable includes or what the method does. +* Let your methods will be verbs. For boolean methods, prefix it with `is`, `has`, and so on. E.g.: `isConfigurable`, `hasChildren`. +* Be [SOLID](http://en.wikipedia.org/wiki/SOLID_%28object-oriented_design%29) and follow [KISS](http://en.wikipedia.org/wiki/KISS_principle) - let the class be responsible only for its tasks. +* Write testable code and if there's a need - easy extendible. +* Avoid duplications + +The rules above have been set a long time after the project has started. If you notice some violations, plase open new issue or even pull request with fixes, we'll be much appreciated. + +### Tools you can use to ensure your code quality + +1. **PHP-CodeSniffer** +2. **PHP Mess Detector** +3. PHP Copy/Paste Detector +4. PHP Dead Code Detector + +## Testing and quality +We use PHPUnit to test our classes. Now not the whole project is covered with tests but we've been working on it for some time. If you want your code to be merged into Magallanes, we want you to push it with proper tests. We would love to reach and keep at leats 90% of code coverage. In short time we want to configure quality tools to make sure your code is tested properly with minimum coverage. Anyway, try to keep 100% of Code Coverage in your pull requests. +Tests structure follow the same structure as production code with `Test` suffix in class and file name. All tests should go to `tests` directory in project root. So if you've created a class `Mage\Tasks\BuilIn\NewTask` the testing class should be called `MageTest\Tasks\BuiltIn\NewTaskTest`. + +## Configuration +Magallanes configuration is kept in YAML files. Please follow those rules whie adding or changing the configuration: +* Keep 2 spaces indentation in each level +* Multi-word config keys should be joined with dash (`-`), like `my-custom-task` +* If your contribution includes new config key, please be sure that you've documented it in configuration documentation. From 257b7ab03ebce01c32fd70948a1fecdba5afe14a Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Sat, 17 Jan 2015 13:31:51 +0100 Subject: [PATCH 48/66] Correct typo --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 826aaf2..767b314 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,7 +65,7 @@ We use PHPUnit to test our classes. Now not the whole project is covered with te Tests structure follow the same structure as production code with `Test` suffix in class and file name. All tests should go to `tests` directory in project root. So if you've created a class `Mage\Tasks\BuilIn\NewTask` the testing class should be called `MageTest\Tasks\BuiltIn\NewTaskTest`. ## Configuration -Magallanes configuration is kept in YAML files. Please follow those rules whie adding or changing the configuration: +Magallanes configuration is kept in YAML files. Please follow those rules while adding or changing the configuration: * Keep 2 spaces indentation in each level * Multi-word config keys should be joined with dash (`-`), like `my-custom-task` * If your contribution includes new config key, please be sure that you've documented it in configuration documentation. From 4673d266704902f243d77a74c5ac1cd97b8c496b Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Fri, 23 Jan 2015 19:40:23 +0100 Subject: [PATCH 49/66] [#183] Add some instructions about code coverage --- CONTRIBUTING.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 767b314..710c26b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -61,7 +61,15 @@ The rules above have been set a long time after the project has started. If you 4. PHP Dead Code Detector ## Testing and quality -We use PHPUnit to test our classes. Now not the whole project is covered with tests but we've been working on it for some time. If you want your code to be merged into Magallanes, we want you to push it with proper tests. We would love to reach and keep at leats 90% of code coverage. In short time we want to configure quality tools to make sure your code is tested properly with minimum coverage. Anyway, try to keep 100% of Code Coverage in your pull requests. +We use PHPUnit to test our classes. Now not the whole project is covered with tests but we've been working on it for some time. If you want your code to be merged into Magallanes, we want you to push it with proper tests. We would love to reach and keep at least 90% of line code coverage. In short time we want to configure quality tools to make sure your code is tested properly with minimum coverage. Anyway, try to keep 100% of Code Coverage in your pull requests. To run your tests with code coverage report, you can either run it with: +``` +/bin/phpunit --coverage-text +``` +or with more friendly and detailed user graphical representation, into HTML: +``` +/bin/phpunit --coverate-html report +``` +where `report` is the directory where html report files shall be stored. Tests structure follow the same structure as production code with `Test` suffix in class and file name. All tests should go to `tests` directory in project root. So if you've created a class `Mage\Tasks\BuilIn\NewTask` the testing class should be called `MageTest\Tasks\BuiltIn\NewTaskTest`. ## Configuration From 731169595c45a86280d719992cc3bf3a25c34f77 Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Fri, 23 Jan 2015 19:53:08 +0100 Subject: [PATCH 50/66] Add some notes about commit messages --- CONTRIBUTING.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 710c26b..e044b1e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,6 +22,24 @@ If you have a problem or you've noticed some bug, please feel free to open new i ## Opening pull requests Pull Request are actually some kind of issues with code, so please keep the rules above in **Reporting issues** section before making the pull requests. Our code isn't so beautiful, tested and testable as we would like it to be but if you're pushing your code please be sure it meets the requirements from **Organization and code quality** chapter. We want to improve the existing code to facilitate extending it and making fixes quicker. So if you are editing some class and you find it ugly, please do not ignore it. Following [The Boy Scout Rule](http://www.informit.com/articles/article.aspx?p=1235624&seqNum=6) - *Leave the campground cleaner than you found it* - we allcan improve the existing code. +Keep your git commits as atomic as it's possible. It brings better history description only by commit messages and allow us to eventually revert the single commits with no affects. Your commit messages should be also descriptive. The first line of commit should be short, try to limit it up to 50 characters. The messages should be written impreatively, like following: +``` +Add MyCustomTask +``` +If you need to write more about your tasks, please enter the description in next lines. There you can write whatever you want, like why you made this commit and what it consists of. +``` +Add MyCustomTask + +This task has very important role for the project. I found this very useful for all developers. I think the deploy with it should be a lot easier. +``` + +Optionally you can tag your messages in square brackets. It can be issue number or simple flag. Examples: +``` +[#183] Add new CONTRIBUTING document +[FIX] Set correct permissions on deploy stage +[FEATURE] Create new PermissionsTask +``` +Remember of square brackets when adding issue number. If you'd forget adding them, your whole message will be a comment! ## Contributing the documentation Magallanes is made to deploy application quick and with no need to write redudant code. Usage is as simple as writing the configuration for target project in YAML files. In the nearest future we would like to make some Wiki with all available options, tasks and commands. For now, the only "documentation" is examples file in `doc` directory. If the code you are going to include in your pull requests adds or changes config options, please make sure you that you create a new sample in that file. You should also to the same with commands. From dae179acad7d6e3c535f8ea098f4ebc9f9f5e8d2 Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Tue, 2 Dec 2014 19:44:43 +0100 Subject: [PATCH 51/66] Add vendor's bins to bin directory --- .gitignore | 2 ++ composer.json | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 66f4d84..88c7e14 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ vendor mage.phar +bin +!bin/mage # OS generated files # // GitHub Recommendation ###################### diff --git a/composer.json b/composer.json index 2183c74..a3a6868 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,9 @@ "Command\\": ".mage/commands" } }, + "config": { + "bin-dir": "bin" + }, "bin": [ "bin/mage" ] From 86f25b2de63ea769659dce3ce7e598fa88e882d5 Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Tue, 2 Dec 2014 19:53:33 +0100 Subject: [PATCH 52/66] Add 'with' to config class method expectations --- tests/MageTest/Console/ColorsTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/MageTest/Console/ColorsTest.php b/tests/MageTest/Console/ColorsTest.php index 2655409..51cc5bc 100644 --- a/tests/MageTest/Console/ColorsTest.php +++ b/tests/MageTest/Console/ColorsTest.php @@ -18,6 +18,7 @@ class ColorsTest extends PHPUnit_Framework_TestCase $config = $this->getMock('Mage\Config'); $config->expects($this->once()) ->method('getParameter') + ->with('no-color') ->will($this->returnValue(false)); $string = 'FooBar'; @@ -37,6 +38,7 @@ class ColorsTest extends PHPUnit_Framework_TestCase $config = $this->getMock('Mage\Config'); $config->expects($this->once()) ->method('getParameter') + ->with('no-color') ->will($this->returnValue(true)); $string = 'FooBar'; @@ -56,6 +58,7 @@ class ColorsTest extends PHPUnit_Framework_TestCase $config = $this->getMock('Mage\Config'); $config->expects($this->once()) ->method('getParameter') + ->with('no-color') ->will($this->returnValue(false)); $string = 'FooBar'; From 93249ce5e58738aee43af5f578a19bfe95dc2c3b Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Tue, 2 Dec 2014 19:53:43 +0100 Subject: [PATCH 53/66] Add coverage annotations --- tests/MageTest/Console/ColorsTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/MageTest/Console/ColorsTest.php b/tests/MageTest/Console/ColorsTest.php index 51cc5bc..2aaf262 100644 --- a/tests/MageTest/Console/ColorsTest.php +++ b/tests/MageTest/Console/ColorsTest.php @@ -7,11 +7,13 @@ use PHPUnit_Framework_TestCase; /** * @group Mage_Console_Colors + * @coversDefaultClass Mage\Console\Colors */ class ColorsTest extends PHPUnit_Framework_TestCase { /** * @group 159 + * @covers ::color */ public function testColor() { @@ -32,6 +34,7 @@ class ColorsTest extends PHPUnit_Framework_TestCase /** * @group 159 + * @covers ::color */ public function testColorNoColor() { @@ -52,6 +55,7 @@ class ColorsTest extends PHPUnit_Framework_TestCase /** * @group 159 + * @covers ::color */ public function testColorUnknownColorName() { From 8694805eba3c7a13207f4603c33f201d9c013129 Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Tue, 2 Dec 2014 19:55:46 +0100 Subject: [PATCH 54/66] Move colour config parameter to class property --- tests/MageTest/Console/ColorsTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/MageTest/Console/ColorsTest.php b/tests/MageTest/Console/ColorsTest.php index 2aaf262..1830cc7 100644 --- a/tests/MageTest/Console/ColorsTest.php +++ b/tests/MageTest/Console/ColorsTest.php @@ -11,6 +11,7 @@ use PHPUnit_Framework_TestCase; */ class ColorsTest extends PHPUnit_Framework_TestCase { + protected $noColorParameter = "no-color"; /** * @group 159 * @covers ::color @@ -20,7 +21,7 @@ class ColorsTest extends PHPUnit_Framework_TestCase $config = $this->getMock('Mage\Config'); $config->expects($this->once()) ->method('getParameter') - ->with('no-color') + ->with($this->noColorParameter) ->will($this->returnValue(false)); $string = 'FooBar'; @@ -41,7 +42,7 @@ class ColorsTest extends PHPUnit_Framework_TestCase $config = $this->getMock('Mage\Config'); $config->expects($this->once()) ->method('getParameter') - ->with('no-color') + ->with($this->noColorParameter) ->will($this->returnValue(true)); $string = 'FooBar'; @@ -62,7 +63,7 @@ class ColorsTest extends PHPUnit_Framework_TestCase $config = $this->getMock('Mage\Config'); $config->expects($this->once()) ->method('getParameter') - ->with('no-color') + ->with($this->noColorParameter) ->will($this->returnValue(false)); $string = 'FooBar'; From b00509cf8e8a2bdaf93485746fa140cdb65bb95c Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Tue, 2 Dec 2014 19:56:58 +0100 Subject: [PATCH 55/66] Add some colors to phpunit output! :) --- phpunit.xml.dist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a5e1c3b..6fbbd61 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,8 +5,8 @@ backupGlobals="false" verbose="true" strict="true" - colors="false"> - + colors="true"> + tests From 9d9e5e2bea4cbae2667976b2d4c2a96b64e592ed Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Sat, 24 Jan 2015 21:50:31 +0100 Subject: [PATCH 56/66] Update composer.lock due to outer changes --- composer.lock | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index bc2e079..e882f21 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "a19528b890d301384e45c1ed7d221e26", + "hash": "c66ae8cd7e44d614445b273f310d9c34", "packages": [], "packages-dev": [ { @@ -755,6 +755,7 @@ "minimum-stability": "stable", "stability-flags": [], "prefer-stable": false, + "prefer-lowest": false, "platform": { "php": ">=5.3" }, From cc615dda816d8dcc2a657f7460167df23393a2d0 Mon Sep 17 00:00:00 2001 From: Dmitriy Ulyanov Date: Sun, 25 Jan 2015 21:50:00 +0300 Subject: [PATCH 57/66] Ignoring errors while deleting temp files --- .gitignore | 5 ++++- Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 66f4d84..c879e0d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,7 @@ mage.phar ehthumbs.db Icon? Thumbs.db -nbproject \ No newline at end of file + +# IDE generated files +.idea +nbproject diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php index ba16246..2345860 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/TarGzTask.php @@ -109,11 +109,11 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware $result = $this->runCommandRemote($command) && $result; // Delete Tar Gz from Remote Host - $command = $this->getReleasesAwareCommand('rm ' . $remoteTarGz . '.tar.gz'); + $command = $this->getReleasesAwareCommand('rm -f ' . $remoteTarGz . '.tar.gz'); $result = $this->runCommandRemote($command) && $result; // Delete Tar Gz from Local - $command = 'rm ' . $localTarGz . ' ' . $localTarGz . '.tar.gz'; + $command = 'rm -f ' . $localTarGz . ' ' . $localTarGz . '.tar.gz'; $result = $this->runCommandLocal($command) && $result; return $result; From 327625bad714fdc3e3b4a970f96ddff988297f29 Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Tue, 27 Jan 2015 19:47:08 +0100 Subject: [PATCH 58/66] [#183] Change test's description property visibility to private --- tests/MageTest/Console/ColorsTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/MageTest/Console/ColorsTest.php b/tests/MageTest/Console/ColorsTest.php index 1830cc7..5038303 100644 --- a/tests/MageTest/Console/ColorsTest.php +++ b/tests/MageTest/Console/ColorsTest.php @@ -11,7 +11,7 @@ use PHPUnit_Framework_TestCase; */ class ColorsTest extends PHPUnit_Framework_TestCase { - protected $noColorParameter = "no-color"; + private $noColorParameter = "no-color"; /** * @group 159 * @covers ::color From ca6756a6ad10f1459b095567040934929faf35a5 Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Mon, 2 Feb 2015 18:38:32 +0100 Subject: [PATCH 59/66] Add some notes about coverage annotations --- CONTRIBUTING.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e044b1e..5aff929 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -89,6 +89,31 @@ or with more friendly and detailed user graphical representation, into HTML: ``` where `report` is the directory where html report files shall be stored. Tests structure follow the same structure as production code with `Test` suffix in class and file name. All tests should go to `tests` directory in project root. So if you've created a class `Mage\Tasks\BuilIn\NewTask` the testing class should be called `MageTest\Tasks\BuiltIn\NewTaskTest`. +To provide more strict tests, point what the method actually test and omit testing some classes indirectly, remember to add annotations to your tests: + +* **`@coversDefaultClass` class annotations** +This prevent to to write full class name each time you write `@covers` for test method (see next point) +```php + +/** + * @coversDefaultClass Mage\Console\Colors + */ +class ColorsTest extends PHPUnit_Framework_TestCase +{ +``` +* **`@covers` methods annotations** +```php +/** + * @covers ::add + */ +public function testAddOnePlusOne() +{ + // ... +} +``` +**Note:** If you omit `coversDefaultClass` for test class, you need to write full class name in `@covers` annotation. + +**Test class musn't test more than one class and any other classes than class being actually tested** ## Configuration Magallanes configuration is kept in YAML files. Please follow those rules while adding or changing the configuration: From e909a837c8d65fd7870ae92d616dbb6202b54381 Mon Sep 17 00:00:00 2001 From: Claudio Zizza Date: Tue, 3 Feb 2015 23:59:12 +0100 Subject: [PATCH 60/66] Typos and sentences fixed, php-cs-fixer as tool added --- CONTRIBUTING.md | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e044b1e..ba2578f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,13 +1,13 @@ Contributor guidelines for Magallanes ===================================== -Welcome to Magallanes! We are much appreciated you've decided to contribute this project! +Welcome to Magallanes! We are much appreciated you've decided to contribute to this project! Please read the following guidelines to make your and our work easier and cleaner. **TL;DR** 1. Write clean code with no mess left 2. Contribute the docs when adding configurable new feature -3. Push your code into `develop` branch +3. Create your pull request from `develop` branch 4. Ensure your code is fully covered by tests @@ -16,17 +16,17 @@ Please read the following guidelines to make your and our work easier and cleane # Reporting issues If you have a problem or you've noticed some bug, please feel free to open new issue. However please follow the rules below: * First, make sure that similar/the same issue doesn't already exist -* If you've already found the solution of the problem you are about to report, plaase feel free to open new pull request. Then follow the rules below in **Developing Magallanes** section. +* If you've already found the solution of the problem you are about to report, please feel free to open a new pull request. Then follow the rules below in **Developing Magallanes** section. * If you are able to, include some test cases or steps to reproduce the bug for us to examine the problem to reach the problem origin. ## Opening pull requests -Pull Request are actually some kind of issues with code, so please keep the rules above in **Reporting issues** section before making the pull requests. -Our code isn't so beautiful, tested and testable as we would like it to be but if you're pushing your code please be sure it meets the requirements from **Organization and code quality** chapter. We want to improve the existing code to facilitate extending it and making fixes quicker. So if you are editing some class and you find it ugly, please do not ignore it. Following [The Boy Scout Rule](http://www.informit.com/articles/article.aspx?p=1235624&seqNum=6) - *Leave the campground cleaner than you found it* - we allcan improve the existing code. -Keep your git commits as atomic as it's possible. It brings better history description only by commit messages and allow us to eventually revert the single commits with no affects. Your commit messages should be also descriptive. The first line of commit should be short, try to limit it up to 50 characters. The messages should be written impreatively, like following: +Pull Request are actually some kind of issues with code, so please follow the rules above in **Reporting issues** section before making the pull requests. +Our code isn't so beautiful, tested and testable as we would like it to be but if you're pushing your code please be sure it meets the requirements from **Organization and code quality** chapter. We want to improve the existing code to facilitate extending it and making fixes quicker. So if you are editing some class and you find it ugly, please do not ignore it. Following [The Boy Scout Rule](http://www.informit.com/articles/article.aspx?p=1235624&seqNum=6) - *Leave the campground cleaner than you found it* - we all can improve the existing code. +Keep your git commits as atomic as possible. It brings better history description only by commit messages and allow us to eventually revert the single commits with no affects. Your commit messages should be also descriptive. The first line of commit should be short, try to limit it up to 50 characters. The messages should be written imperatively, like following: ``` Add MyCustomTask ``` -If you need to write more about your tasks, please enter the description in next lines. There you can write whatever you want, like why you made this commit and what it consists of. +If you need to write more about your tasks, please enter the description in the next lines. There you can write whatever you want, like why you made this commit and what it consists of. ``` Add MyCustomTask @@ -42,7 +42,7 @@ Optionally you can tag your messages in square brackets. It can be issue number Remember of square brackets when adding issue number. If you'd forget adding them, your whole message will be a comment! ## Contributing the documentation -Magallanes is made to deploy application quick and with no need to write redudant code. Usage is as simple as writing the configuration for target project in YAML files. In the nearest future we would like to make some Wiki with all available options, tasks and commands. For now, the only "documentation" is examples file in `doc` directory. If the code you are going to include in your pull requests adds or changes config options, please make sure you that you create a new sample in that file. You should also to the same with commands. +Magallanes is made to deploy your application quick and with no need to write redudant code. Usage is as simple as writing the configuration for target project in YAML files. In the nearest future we would like to make some Wiki with all available options, tasks and commands. For now, the only "documentation" are example files in `docs` directory. If the code you are going to include in your pull requests adds or changes config options, please make sure that you create a new sample in those files. You should also do the same with commands. # Developing Magallanes ## Branches @@ -59,17 +59,17 @@ If you want to use develop branch in your code, simple pass `dev-develop` to dep ``` ## Organization and code quality We use [PSR2](http://www.php-fig.org/psr/psr-2/) as PHP coding standard. -Some of rules we follow that are not included in document above: +Some of the rules we follow that are not included in document above: * Variables' and properties' names are camelCased (e.g.: `$thisIsMyVariable`) * Avoid too long or too short variables' and methods' names, like `$thisIsMyAwesomeVariableAndImProudOfIt` -* Names of your properties/method should be intuitive and self-describing - that means your code should look like a book. Developer who reads the code should immediately know what the variable includes or what the method does. +* Names of your properties/methods should be intuitive and self-describing - that means your code should look like a book. Developers who read the code should immediately know what a variable includes or what a method does. * Let your methods will be verbs. For boolean methods, prefix it with `is`, `has`, and so on. E.g.: `isConfigurable`, `hasChildren`. * Be [SOLID](http://en.wikipedia.org/wiki/SOLID_%28object-oriented_design%29) and follow [KISS](http://en.wikipedia.org/wiki/KISS_principle) - let the class be responsible only for its tasks. * Write testable code and if there's a need - easy extendible. * Avoid duplications -The rules above have been set a long time after the project has started. If you notice some violations, plase open new issue or even pull request with fixes, we'll be much appreciated. +The rules above have been set a long time after the project has started. If you notice some violations, please open a new issue or even pull request with fixes. It'll be much appreciated. ### Tools you can use to ensure your code quality @@ -77,15 +77,16 @@ The rules above have been set a long time after the project has started. If you 2. **PHP Mess Detector** 3. PHP Copy/Paste Detector 4. PHP Dead Code Detector +5. [PHP Coding Standards Fixer](http://cs.sensiolabs.org) ## Testing and quality -We use PHPUnit to test our classes. Now not the whole project is covered with tests but we've been working on it for some time. If you want your code to be merged into Magallanes, we want you to push it with proper tests. We would love to reach and keep at least 90% of line code coverage. In short time we want to configure quality tools to make sure your code is tested properly with minimum coverage. Anyway, try to keep 100% of Code Coverage in your pull requests. To run your tests with code coverage report, you can either run it with: +We use PHPUnit to test our code. The whole project is not covered with tests right now but we've been working on it for some time. If you want your code to be merged into Magallanes, we want you to push it with proper tests. We would love to reach and keep at least 90% of line code coverage. In short time we want to configure quality tools to make sure your code is tested properly with minimum coverage. Anyway, try to keep 100% of Code Coverage in your pull requests. To run your tests with code coverage report, you can either run it with: ``` -/bin/phpunit --coverage-text +bin/phpunit --coverage-text ``` or with more friendly and detailed user graphical representation, into HTML: ``` -/bin/phpunit --coverate-html report +bin/phpunit --coverate-html report ``` where `report` is the directory where html report files shall be stored. Tests structure follow the same structure as production code with `Test` suffix in class and file name. All tests should go to `tests` directory in project root. So if you've created a class `Mage\Tasks\BuilIn\NewTask` the testing class should be called `MageTest\Tasks\BuiltIn\NewTaskTest`. From 5e84f0ada4c2ab6e15483344f5b4572283cd947c Mon Sep 17 00:00:00 2001 From: Ramunas Date: Sun, 8 Feb 2015 21:19:34 +0200 Subject: [PATCH 61/66] doing permission fix before actual relase, prevents from cases when released code cannot be accessed while chown is working --- Mage/Task/BuiltIn/Deployment/ReleaseTask.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php index e7baf30..4ecf586 100644 --- a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php +++ b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php @@ -74,21 +74,21 @@ class ReleaseTask extends AbstractTask implements IsReleaseAware, SkipOnOverride } } - // Remove symlink if exists; create new symlink and change owners - $tmplink = $currentCopy . '.tmp'; - $command = 'ln -sfn ' . $currentCopy . ' ' . $tmplink - . ' && ' - . 'mv -T ' . $tmplink . ' ' . $symlink; - - if ($resultFetch && $userGroup != '') { - $command .= ' && ' - . 'chown -h ' . $userGroup . ' ' . $symlink + if ($resultFetch && $userGroup != '') { + $command = 'chown -h ' . $userGroup . ' ' . $symlink . ' && ' . 'chown -R ' . $userGroup . ' ' . $currentCopy . ' && ' . 'chown ' . $userGroup . ' ' . $releasesDirectory; + $result = $this->runCommandRemote($command); + if (!$result) { + return $result; + } } + // Remove symlink if exists; create new symlink and change owner + $tmplink = $currentCopy . '.tmp'; + $command = "ln -sfn {$currentCopy} {$tmplink} && mv -fT {$tmplink} {$symlink}"; $result = $this->runCommandRemote($command); if ($result) { From a9c4242675fb5e1ce5759d35ef8307699ae0b195 Mon Sep 17 00:00:00 2001 From: Jakub Turek Date: Thu, 19 Feb 2015 20:31:35 +0100 Subject: [PATCH 62/66] Update composer.lock Composer autoloading update --- composer.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index e882f21..a927b43 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "c66ae8cd7e44d614445b273f310d9c34", + "hash": "7a55b88add493fbc9910519e7e9c3a3b", "packages": [], "packages-dev": [ { From dc18a91cf7bdd2ff4cd4fd98b4bb7682ae8873a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 21 Feb 2015 14:23:24 -0200 Subject: [PATCH 63/66] SensioLabs Insight. --- .../BuiltIn/Filesystem/PermissionsTask.php | 10 +---- Mage/Task/BuiltIn/Ioncube/EncryptTask.php | 6 +-- Mage/Task/BuiltIn/Releases/RollbackTask.php | 2 - .../.mage/tasks/SampleTaskRollbackAware.php | 45 +++++++++---------- 4 files changed, 26 insertions(+), 37 deletions(-) diff --git a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php index 171770b..f5f9505 100644 --- a/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php +++ b/Mage/Task/BuiltIn/Filesystem/PermissionsTask.php @@ -159,7 +159,7 @@ class PermissionsTask extends AbstractTask ); foreach($options as $option => $apply) { - if ($apply == true) { + if ($apply === true) { $optionsForCmd .= $option; } } @@ -192,7 +192,7 @@ class PermissionsTask extends AbstractTask */ protected function setPaths(array $paths) { - if ($this->checkPathsExist == true) { + if ($this->checkPathsExist === true) { $commands = array(); foreach ($paths as $path) { $commands[] = '(([ -f ' . $path . ' ]) || ([ -d ' . $path . ' ]))'; @@ -241,8 +241,6 @@ class PermissionsTask extends AbstractTask /** * Set owner. * - * @todo check existance of $owner on host, might be different ways depending on OS. - * * @param string $owner * @return PermissionsTask */ @@ -264,8 +262,6 @@ class PermissionsTask extends AbstractTask /** * Set group. * - * @todo check existance of $group on host, might be different ways depending on OS. - * * @param string $group * @return PermissionsTask */ @@ -287,8 +283,6 @@ class PermissionsTask extends AbstractTask /** * Set rights. * - * @todo check if $rights is in a correct format. - * * @param string $rights * @return PermissionsTask */ diff --git a/Mage/Task/BuiltIn/Ioncube/EncryptTask.php b/Mage/Task/BuiltIn/Ioncube/EncryptTask.php index f147be8..8565036 100644 --- a/Mage/Task/BuiltIn/Ioncube/EncryptTask.php +++ b/Mage/Task/BuiltIn/Ioncube/EncryptTask.php @@ -33,7 +33,6 @@ use Mage\Task\ErrorWithMessageException; * * Example enviroment.yaml file at end * - * @todo add support for creating license files. * * (c) ActWeb 2013 * (c) Matt Lowe (marl.scot.1@googlemail.com) @@ -202,7 +201,7 @@ class EncryptTask extends AbstractTask /* * Get all our IonCube config options */ - $this->_getAllIonCubeConfigs(); + $this->getAllIonCubeConfigs(); /* * get the source code location */ @@ -279,7 +278,7 @@ class EncryptTask extends AbstractTask * * @return void */ - private function _getAllIonCubeConfigs() + private function getAllIonCubeConfigs() { /* @@ -553,7 +552,6 @@ class EncryptTask extends AbstractTask * D - Default options as stored in script * * more options could be added to make this a bit more flexable - * @todo I'm sure this could be combined into a loop to make it easier and shorter * */ $s = array(); diff --git a/Mage/Task/BuiltIn/Releases/RollbackTask.php b/Mage/Task/BuiltIn/Releases/RollbackTask.php index e52d45d..a881ec6 100644 --- a/Mage/Task/BuiltIn/Releases/RollbackTask.php +++ b/Mage/Task/BuiltIn/Releases/RollbackTask.php @@ -59,8 +59,6 @@ class RollbackTask extends AbstractTask implements IsReleaseAware $result = $this->runCommandRemote('ls -1 ' . $releasesDirectory, $output); $releases = ($output == '') ? array() : explode(PHP_EOL, $output); - $inDeploy = $this->getParameter('inDeploy',false); - if (count($releases) == 0) { Console::output('Release are not available for ' . $this->getConfig()->getHost() . ' ... FAIL'); diff --git a/docs/example-config/.mage/tasks/SampleTaskRollbackAware.php b/docs/example-config/.mage/tasks/SampleTaskRollbackAware.php index d9213f4..c8dadc9 100644 --- a/docs/example-config/.mage/tasks/SampleTaskRollbackAware.php +++ b/docs/example-config/.mage/tasks/SampleTaskRollbackAware.php @@ -1,23 +1,22 @@ -inRollback()) { - return 'A Sample Task aware of rollbacks [in rollback]'; - } else { - return 'A Sample Task aware of rollbacks [not in rollback]'; - } - } - - public function run() - { - return true; - } -} - +inRollback()) { + return 'A Sample Task aware of rollbacks [in rollback]'; + } else { + return 'A Sample Task aware of rollbacks [not in rollback]'; + } + } + + public function run() + { + return true; + } +} From ddbcec4a9c654868731796353f298a566f6799d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 21 Feb 2015 14:28:03 -0200 Subject: [PATCH 64/66] Add SensioLab Insight badge. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 99d584b..cbe221b 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,6 @@ Like this: $ mage deploy to:production ``` - ### What's this sorcery?! ### Easy boy. It's not sorcery, just some *technomagick*! @@ -69,3 +68,5 @@ Enjoy your magic trip with **Magallanes** to the land of the easily deployable a ### "develop" branch ### Please, all pull request now must be on the develop branch. Thanks! + +[![SensioLabsInsight](https://insight.sensiolabs.com/projects/ed0de53a-a12e-459b-9464-34def5907b56/mini.png)](https://insight.sensiolabs.com/projects/ed0de53a-a12e-459b-9464-34def5907b56) From 447cbc4b710192da7db9d0f605477172c8dd4772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 21 Feb 2015 14:28:47 -0200 Subject: [PATCH 65/66] Move badge for better visibility. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cbe221b..4b5cfca 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Magallanes # +[![SensioLabsInsight](https://insight.sensiolabs.com/projects/ed0de53a-a12e-459b-9464-34def5907b56/mini.png)](https://insight.sensiolabs.com/projects/ed0de53a-a12e-459b-9464-34def5907b56) + ### What's Magallanes? ### Magallanes is a deployment tool for PHP applications; it's quite simple to use and manage. It will get your application to a safe harbor. @@ -69,4 +71,3 @@ Enjoy your magic trip with **Magallanes** to the land of the easily deployable a ### "develop" branch ### Please, all pull request now must be on the develop branch. Thanks! -[![SensioLabsInsight](https://insight.sensiolabs.com/projects/ed0de53a-a12e-459b-9464-34def5907b56/mini.png)](https://insight.sensiolabs.com/projects/ed0de53a-a12e-459b-9464-34def5907b56) From fe2c9fb49ea0ba775bcc5ad6fc5e4210f27be896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 21 Feb 2015 14:39:51 -0200 Subject: [PATCH 66/66] Prepare for new version release. --- README.md | 4 ++-- bin/mage | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4b5cfca..064c932 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Simply add the following dependency to your project’s composer.json file: ```js "require-dev": { // ... - "andres-montanez/magallanes": "~1.0.3" + "andres-montanez/magallanes": "~1.0.*" // ... } ``` @@ -37,7 +37,7 @@ $ bin/mage version ### System-wide installation with composer ### ```bash -$ composer global require "andres-montanez/magallanes=~1.0.3" +$ composer global require "andres-montanez/magallanes=~1.0.*" ``` Make sure you have ~/.composer/vendor/bin/ in your path. diff --git a/bin/mage b/bin/mage index 986bafb..80d9b88 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.3'); +define('MAGALLANES_VERSION', '1.0.4'); define('MAGALLANES_DIRECTORY', $baseDir); if (file_exists(__DIR__ . '/../vendor/autoload.php')) { @@ -26,7 +26,6 @@ if (file_exists(__DIR__ . '/../vendor/autoload.php')) { spl_autoload_register(array($loader, 'autoLoad')); } - // Clean arguments array_shift($argv);