From 3a033b4514dea2f915676178a91f552a162c716a Mon Sep 17 00:00:00 2001 From: Moritz Baumann Date: Sun, 17 Aug 2014 17:49:58 +0200 Subject: [PATCH 01/13] Fix RsyncTask::excludes(). --- Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php index 2dbdb7d..c4c92ad 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php @@ -111,7 +111,7 @@ class RsyncTask extends BaseStrategyTaskAbstract implements IsReleaseAware { $excludesRsync = ''; foreach ($excludes as $exclude) { - $excludesRsync .= ' --exclude ' . $exclude . ' '; + $excludesRsync .= ' --exclude=' . escapeshellarg($exclude) . ' '; } $excludesRsync = trim($excludesRsync); From 48420c1c2a3f0d3577fe023ad1e8fc947609717d Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Wed, 20 Aug 2014 17:45:30 +0200 Subject: [PATCH 02/13] Rename composer_path into composer_cmd --- Mage/Task/BuiltIn/Composer/ComposerAbstractTask.php | 5 +++-- Mage/Task/BuiltIn/Composer/GenerateAutoloadTask.php | 2 +- Mage/Task/BuiltIn/Composer/InstallTask.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Mage/Task/BuiltIn/Composer/ComposerAbstractTask.php b/Mage/Task/BuiltIn/Composer/ComposerAbstractTask.php index e61c32d..dc9d15f 100644 --- a/Mage/Task/BuiltIn/Composer/ComposerAbstractTask.php +++ b/Mage/Task/BuiltIn/Composer/ComposerAbstractTask.php @@ -19,8 +19,9 @@ use Mage\Task\AbstractTask; */ abstract class ComposerAbstractTask extends AbstractTask { - protected function getComposerPath() + protected function getComposerCmd() { - return $this->getConfig()->general('composer_path', 'php composer.phar'); + + return $this->getConfig()->general('composer_cmd', 'php composer.phar'); } } \ No newline at end of file diff --git a/Mage/Task/BuiltIn/Composer/GenerateAutoloadTask.php b/Mage/Task/BuiltIn/Composer/GenerateAutoloadTask.php index ea1acf4..2fdafea 100644 --- a/Mage/Task/BuiltIn/Composer/GenerateAutoloadTask.php +++ b/Mage/Task/BuiltIn/Composer/GenerateAutoloadTask.php @@ -23,6 +23,6 @@ class GenerateAutoloadTask extends ComposerAbstractTask */ public function run() { - return $this->runCommand($this->getComposerPath() . ' dumpautoload --optimize'); + return $this->runCommand($this->getComposerCmd() . ' dumpautoload --optimize'); } } diff --git a/Mage/Task/BuiltIn/Composer/InstallTask.php b/Mage/Task/BuiltIn/Composer/InstallTask.php index 42c468c..d33ca1c 100644 --- a/Mage/Task/BuiltIn/Composer/InstallTask.php +++ b/Mage/Task/BuiltIn/Composer/InstallTask.php @@ -23,6 +23,6 @@ class InstallTask extends ComposerAbstractTask */ public function run() { - return $this->runCommand($this->getComposerPath() . ' install'); + return $this->runCommand($this->getComposerCmd() . ' install'); } } From 95ffed7e12731bff6d5684290cd7565e20922572 Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Wed, 20 Aug 2014 17:46:44 +0200 Subject: [PATCH 03/13] Add configurable composer_cmd parameter --- Mage/Task/BuiltIn/Composer/ComposerAbstractTask.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Mage/Task/BuiltIn/Composer/ComposerAbstractTask.php b/Mage/Task/BuiltIn/Composer/ComposerAbstractTask.php index dc9d15f..aa31736 100644 --- a/Mage/Task/BuiltIn/Composer/ComposerAbstractTask.php +++ b/Mage/Task/BuiltIn/Composer/ComposerAbstractTask.php @@ -21,7 +21,7 @@ abstract class ComposerAbstractTask extends AbstractTask { protected function getComposerCmd() { - - return $this->getConfig()->general('composer_cmd', 'php composer.phar'); + $composerCmd = $this->getParameter('composer_cmd', 'php composer.phar'); + return $this->getConfig()->general('composer_cmd', $composerCmd); } -} \ No newline at end of file +} From c3204844ea84bcff18fa14ff0f730636abc98aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Mon, 25 Aug 2014 14:05:01 -0300 Subject: [PATCH 04/13] Add possibility for defining the composer_cmd in the global config. --- Mage/Task/BuiltIn/Composer/ComposerAbstractTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/Task/BuiltIn/Composer/ComposerAbstractTask.php b/Mage/Task/BuiltIn/Composer/ComposerAbstractTask.php index aa31736..26fe609 100644 --- a/Mage/Task/BuiltIn/Composer/ComposerAbstractTask.php +++ b/Mage/Task/BuiltIn/Composer/ComposerAbstractTask.php @@ -21,7 +21,7 @@ abstract class ComposerAbstractTask extends AbstractTask { protected function getComposerCmd() { - $composerCmd = $this->getParameter('composer_cmd', 'php composer.phar'); + $composerCmd = $this->getParameter('composer_cmd', $this->getConfig()->general('composer_cmd', 'php composer.phar')); return $this->getConfig()->general('composer_cmd', $composerCmd); } } From d4763da37bffea2faf8c2e6ed0da3822f78c31ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Mon, 25 Aug 2014 14:09:42 -0300 Subject: [PATCH 05/13] Manual merge for PR #108 --- Mage/Task/BuiltIn/Composer/InstallTask.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Mage/Task/BuiltIn/Composer/InstallTask.php b/Mage/Task/BuiltIn/Composer/InstallTask.php index d33ca1c..291ccf8 100644 --- a/Mage/Task/BuiltIn/Composer/InstallTask.php +++ b/Mage/Task/BuiltIn/Composer/InstallTask.php @@ -23,6 +23,7 @@ class InstallTask extends ComposerAbstractTask */ public function run() { - return $this->runCommand($this->getComposerCmd() . ' install'); + $dev = $this->getParameter('dev', true); + return $this->runCommand($this->getComposerCmd() . ' install' . ($dev ? ' --dev' : ' --no-dev')); } } From 9af42046dbcc6449c0cd4f5265f917280a54379a Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Wed, 27 Aug 2014 21:09:59 +0200 Subject: [PATCH 06/13] Add "vendor" to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 458da2e..5dc363a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ .project .buildpath .idea +vendor # OS generated files # // GitHub Recommendation ###################### From 300cc4c56f34925ca8105924743b243898243b8c Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Thu, 28 Aug 2014 21:28:30 +0200 Subject: [PATCH 07/13] Load core classes wit hcomposer autoloader --- bin/mage | 7 +------ composer.json | 5 +++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/mage b/bin/mage index 9f6e436..ea8f612 100755 --- a/bin/mage +++ b/bin/mage @@ -9,8 +9,6 @@ * file that was distributed with this source code. */ -use Mage\Autoload; - date_default_timezone_set('UTC'); $baseDir = dirname(dirname(__FILE__)); @@ -18,10 +16,7 @@ $baseDir = dirname(dirname(__FILE__)); define('MAGALLANES_VERSION', '1.0.1'); define('MAGALLANES_DIRECTORY', $baseDir); -// Preload -require_once $baseDir . '/Mage/Autoload.php'; -$loader = new Autoload(); -spl_autoload_register(array($loader, 'autoLoad')); +require_once __DIR__ . '/../vendor/autoload.php'; // Clean arguments array_shift($argv); diff --git a/composer.json b/composer.json index c533d31..90be3b2 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,11 @@ "require": { "php": ">=5.3" }, + "autoload": { + "psr-4": { + "Mage\\": "./Mage" + } + }, "bin": [ "bin/mage" ] From ea49214e952640d1d712e4ffba908509969033c9 Mon Sep 17 00:00:00 2001 From: Kuba Turek Date: Thu, 28 Aug 2014 21:34:07 +0200 Subject: [PATCH 08/13] Load custom tasks and commands by composer autoload mechanism --- composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 90be3b2..4018174 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,9 @@ }, "autoload": { "psr-4": { - "Mage\\": "./Mage" + "Mage\\": "./Mage", + "Task\\": ".mage/tasks", + "Command\\": ".mage/commands" } }, "bin": [ From 07326efbe2b77ca77e569718ae8c618add359d32 Mon Sep 17 00:00:00 2001 From: Jakub Turek Date: Sun, 7 Sep 2014 10:49:50 +0200 Subject: [PATCH 09/13] Remove old Autoload class --- Mage/Autoload.php | 72 ----------------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 Mage/Autoload.php diff --git a/Mage/Autoload.php b/Mage/Autoload.php deleted file mode 100644 index 474aa0c..0000000 --- a/Mage/Autoload.php +++ /dev/null @@ -1,72 +0,0 @@ - -* -* For the full copyright and license information, please view the LICENSE -* file that was distributed with this source code. -*/ - -namespace Mage; - -/** - * Magallanes custom Autoload for BuiltIn and Userspace Commands and Tasks. - * - * @author Andrés Montañez - */ -class Autoload -{ - /** - * Autoload a Class by it's Class Name - * @param string $className - * @return boolean - */ - public function autoLoad($className) - { - $className = ltrim($className, '/'); - $postfix = '/' . str_replace(array('_', '\\'), '/', $className . '.php'); - - // Change BaseDir according to Namespace - if (strpos($className, 'Task\\') === 0) { - $baseDir = getcwd() . '/.mage/tasks'; - $postfix = substr($postfix, 5); - - } else if (strpos($className, 'Command\\') === 0) { - $baseDir = getcwd() . '/.mage/commands'; - $postfix = substr($postfix, 8); - - } else { - $baseDir = dirname(dirname(__FILE__)); - } - - //Try to load a normal Mage class (or Task). Think that Mage component is compiled to .phar - $classFileWithinPhar = $baseDir . $postfix; - if ($this->isReadable($classFileWithinPhar)) { - /** @noinspection PhpIncludeInspection */ - require_once $classFileWithinPhar; - return true; - } - - //Try to load a custom Task or Class. Notice that the path is absolute to CWD - $classFileOutsidePhar = getcwd() . '/.mage/tasks' . $postfix; - if ($this->isReadable($classFileOutsidePhar)) { - /** @noinspection PhpIncludeInspection */ - require_once $classFileOutsidePhar; - return true; - } - - return false; - } - - /** - * Checks if a file can be read. - * @param string $filePath - * @return boolean - */ - public function isReadable($filePath) - { - return is_readable($filePath); - } - -} From 5809a424a732f7dde55bebddd64b0f06b288f2d5 Mon Sep 17 00:00:00 2001 From: Jakub Turek Date: Sat, 13 Sep 2014 21:24:26 +0200 Subject: [PATCH 10/13] Revert "Remove old Autoload class" This reverts commit 3f3253bbee3493c71e09a3074fd28a9d4485fc6c. --- Mage/Autoload.php | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Mage/Autoload.php diff --git a/Mage/Autoload.php b/Mage/Autoload.php new file mode 100644 index 0000000..474aa0c --- /dev/null +++ b/Mage/Autoload.php @@ -0,0 +1,72 @@ + +* +* For the full copyright and license information, please view the LICENSE +* file that was distributed with this source code. +*/ + +namespace Mage; + +/** + * Magallanes custom Autoload for BuiltIn and Userspace Commands and Tasks. + * + * @author Andrés Montañez + */ +class Autoload +{ + /** + * Autoload a Class by it's Class Name + * @param string $className + * @return boolean + */ + public function autoLoad($className) + { + $className = ltrim($className, '/'); + $postfix = '/' . str_replace(array('_', '\\'), '/', $className . '.php'); + + // Change BaseDir according to Namespace + if (strpos($className, 'Task\\') === 0) { + $baseDir = getcwd() . '/.mage/tasks'; + $postfix = substr($postfix, 5); + + } else if (strpos($className, 'Command\\') === 0) { + $baseDir = getcwd() . '/.mage/commands'; + $postfix = substr($postfix, 8); + + } else { + $baseDir = dirname(dirname(__FILE__)); + } + + //Try to load a normal Mage class (or Task). Think that Mage component is compiled to .phar + $classFileWithinPhar = $baseDir . $postfix; + if ($this->isReadable($classFileWithinPhar)) { + /** @noinspection PhpIncludeInspection */ + require_once $classFileWithinPhar; + return true; + } + + //Try to load a custom Task or Class. Notice that the path is absolute to CWD + $classFileOutsidePhar = getcwd() . '/.mage/tasks' . $postfix; + if ($this->isReadable($classFileOutsidePhar)) { + /** @noinspection PhpIncludeInspection */ + require_once $classFileOutsidePhar; + return true; + } + + return false; + } + + /** + * Checks if a file can be read. + * @param string $filePath + * @return boolean + */ + public function isReadable($filePath) + { + return is_readable($filePath); + } + +} From bc428f466acbc0829bcc21d6ba2c55a4544ff2d9 Mon Sep 17 00:00:00 2001 From: Jakub Turek Date: Sat, 13 Sep 2014 21:29:40 +0200 Subject: [PATCH 11/13] Use default autoloader when composer autoloader has been not initialized --- bin/mage | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/mage b/bin/mage index ea8f612..fcad36f 100755 --- a/bin/mage +++ b/bin/mage @@ -16,7 +16,14 @@ $baseDir = dirname(dirname(__FILE__)); define('MAGALLANES_VERSION', '1.0.1'); define('MAGALLANES_DIRECTORY', $baseDir); -require_once __DIR__ . '/../vendor/autoload.php'; +if (file_exists(__DIR__ . '/../vendor/autoload.php')) { + require_once __DIR__ . '/../vendor/autoload.php'; +} else { + require_once $baseDir . '/Mage/Autoload.php'; + $loader = new \Mage\Autoload(); + spl_autoload_register(array($loader, 'autoLoad')); +} + // Clean arguments array_shift($argv); From d0e8be2dfe165e122c7c2f6deeac2bb99b374d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 13 Sep 2014 16:45:41 -0300 Subject: [PATCH 12/13] Git Remote Cache #123 --- Mage/Command/BuiltIn/DeployCommand.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Mage/Command/BuiltIn/DeployCommand.php b/Mage/Command/BuiltIn/DeployCommand.php index 829a329..d1888b3 100644 --- a/Mage/Command/BuiltIn/DeployCommand.php +++ b/Mage/Command/BuiltIn/DeployCommand.php @@ -35,6 +35,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment const DEPLOY_STRATEGY_RSYNC = 'rsync'; const DEPLOY_STRATEGY_TARGZ = 'targz'; const DEPLOY_STRATEGY_GIT_REBASE = 'git-rebase'; + const DEPLOY_STRATEGY_GIT_REMOTE_CACHE = 'git-remote-cache'; const DEPLOY_STRATEGY_GUESS = 'guess'; const DEFAULT_DEPLOY_STRATEGY = self::DEPLOY_STRATEGY_GUESS; @@ -557,6 +558,10 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment $deployStrategy = 'deployment/strategy/git-rebase'; break; + case self::DEPLOY_STRATEGY_GIT_REMOTE_CACHE: + $deployStrategy = 'deployment/strategy/git-remote-cache'; + break; + case self::DEPLOY_STRATEGY_GUESS: default: if ($this->getConfig()->release('enabled', false) == true) { From a5ff1faccad9c7984165b1d7b3f2ffb61f713335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Monta=C3=B1ez?= Date: Sat, 13 Sep 2014 17:29:45 -0300 Subject: [PATCH 13/13] Prepare for next release. --- bin/mage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/mage b/bin/mage index fcad36f..b668d45 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.1'); +define('MAGALLANES_VERSION', '1.0.2'); define('MAGALLANES_DIRECTORY', $baseDir); if (file_exists(__DIR__ . '/../vendor/autoload.php')) {