diff --git a/Mage/Task/BuiltIn/General/ManuallyTask.php b/Mage/Task/BuiltIn/General/ManuallyTask.php new file mode 100644 index 0000000..aec0279 --- /dev/null +++ b/Mage/Task/BuiltIn/General/ManuallyTask.php @@ -0,0 +1,61 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Mage\Task\BuiltIn\General; + +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 + * - find var/logs -maxdepth 1 -type f -name '*.log' -exec chown apache:apache {} \; + * - 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; + } + +} 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; 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; 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); } }