From c010fc662e9e7f26d6b7d9815ed5a1ff47e741b5 Mon Sep 17 00:00:00 2001 From: samuel4x4 Date: Sun, 23 Nov 2014 23:03:31 +0200 Subject: [PATCH 1/6] 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 2/6] 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 3/6] 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 4/6] 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 5/6] 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 6/6] 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;