mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	Merge branch 'develop'
This commit is contained in:
		
						commit
						5199a915b6
					
				
							
								
								
									
										6
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -1,9 +1,5 @@
 | 
				
			|||||||
.settings
 | 
					 | 
				
			||||||
.settings/*
 | 
					 | 
				
			||||||
.project
 | 
					 | 
				
			||||||
.buildpath
 | 
					 | 
				
			||||||
.idea
 | 
					 | 
				
			||||||
vendor
 | 
					vendor
 | 
				
			||||||
 | 
					mage.phar
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# OS generated files # // GitHub Recommendation
 | 
					# OS generated files # // GitHub Recommendation
 | 
				
			||||||
######################
 | 
					######################
 | 
				
			||||||
 | 
				
			|||||||
@ -68,7 +68,7 @@ class AddCommand extends AbstractCommand
 | 
				
			|||||||
            throw new Exception('The environment already exists.');
 | 
					            throw new Exception('The environment already exists.');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Console::output('Adding new environment: <dark_gray>' . $environmentName . '</dark_gray>');
 | 
					        Console::output('Adding new environment: <bold>' . $environmentName . '</bold>');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $releasesConfig = 'releases:' . PHP_EOL
 | 
					        $releasesConfig = 'releases:' . PHP_EOL
 | 
				
			||||||
            . '  enabled: true' . PHP_EOL
 | 
					            . '  enabled: true' . PHP_EOL
 | 
				
			||||||
@ -93,10 +93,10 @@ class AddCommand extends AbstractCommand
 | 
				
			|||||||
        $result = file_put_contents($environmentConfigFile, $baseConfig);
 | 
					        $result = file_put_contents($environmentConfigFile, $baseConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($result) {
 | 
					        if ($result) {
 | 
				
			||||||
            Console::output('<light_green>Success!!</light_green> Environment config file for <dark_gray>' . $environmentName . '</dark_gray> created successfully at <blue>' . $environmentConfigFile . '</blue>');
 | 
					            Console::output('<light_green>Success!!</light_green> Environment config file for <bold>' . $environmentName . '</bold> created successfully at <blue>' . $environmentConfigFile . '</blue>');
 | 
				
			||||||
            Console::output('<dark_gray>So please! Review and adjust its configuration.</dark_gray>', 2, 2);
 | 
					            Console::output('<bold>So please! Review and adjust its configuration.</bold>', 2, 2);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            Console::output('<light_red>Error!!</light_red> Unable to create config file for environment called <dark_gray>' . $environmentName . '</dark_gray>', 1, 2);
 | 
					            Console::output('<light_red>Error!!</light_red> Unable to create config file for environment called <bold>' . $environmentName . '</bold>', 1, 2);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -28,7 +28,7 @@ class CompileCommand extends AbstractCommand
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        if (ini_get('phar.readonly')) {
 | 
					        if (ini_get('phar.readonly')) {
 | 
				
			||||||
            Console::output('The <purple>php.ini</purple> variable <light_red>phar.readonly</light_red> must be <yellow>Off</yellow>.', 1, 2);
 | 
					            Console::output('The <purple>php.ini</purple> variable <light_red>phar.readonly</light_red> must be <yellow>Off</yellow>.', 1, 2);
 | 
				
			||||||
            return 300;
 | 
					            return 200;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $compiler = new Compiler;
 | 
					        $compiler = new Compiler;
 | 
				
			||||||
 | 
				
			|||||||
@ -3,6 +3,7 @@
 | 
				
			|||||||
 * This file is part of the Magallanes package.
 | 
					 * This file is part of the Magallanes package.
 | 
				
			||||||
*
 | 
					*
 | 
				
			||||||
* (c) Andrés Montañez <andres@andresmontanez.com>
 | 
					* (c) Andrés Montañez <andres@andresmontanez.com>
 | 
				
			||||||
 | 
					* (c) Alex V Kotelnikov <gudron@gudron.me>
 | 
				
			||||||
*
 | 
					*
 | 
				
			||||||
* For the full copyright and license information, please view the LICENSE
 | 
					* For the full copyright and license information, please view the LICENSE
 | 
				
			||||||
* file that was distributed with this source code.
 | 
					* file that was distributed with this source code.
 | 
				
			||||||
@ -16,6 +17,7 @@ use Mage\Task\Factory;
 | 
				
			|||||||
use Mage\Task\AbstractTask;
 | 
					use Mage\Task\AbstractTask;
 | 
				
			||||||
use Mage\Task\Releases\SkipOnOverride;
 | 
					use Mage\Task\Releases\SkipOnOverride;
 | 
				
			||||||
use Mage\Task\ErrorWithMessageException;
 | 
					use Mage\Task\ErrorWithMessageException;
 | 
				
			||||||
 | 
					use Mage\Task\RollbackException;
 | 
				
			||||||
use Mage\Task\SkipException;
 | 
					use Mage\Task\SkipException;
 | 
				
			||||||
use Mage\Console;
 | 
					use Mage\Console;
 | 
				
			||||||
use Mage\Config;
 | 
					use Mage\Config;
 | 
				
			||||||
@ -109,20 +111,20 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $exitCode = 1000;
 | 
					        $exitCode = 240;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Check if Environment is not Locked
 | 
					        // Check if Environment is not Locked
 | 
				
			||||||
        $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock';
 | 
					        $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock';
 | 
				
			||||||
        if (file_exists($lockFile)) {
 | 
					        if (file_exists($lockFile)) {
 | 
				
			||||||
            Console::output('<red>This environment is locked!</red>', 1, 2);
 | 
					            Console::output('<red>This environment is locked!</red>', 1, 2);
 | 
				
			||||||
            echo file_get_contents($lockFile);
 | 
					            echo file_get_contents($lockFile);
 | 
				
			||||||
            return 1010;
 | 
					            return 231;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Check for running instance and Lock
 | 
					        // Check for running instance and Lock
 | 
				
			||||||
        if (file_exists(getcwd() . '/.mage/~working.lock')) {
 | 
					        if (file_exists(getcwd() . '/.mage/~working.lock')) {
 | 
				
			||||||
            Console::output('<red>There is already an instance of Magallanes running!</red>', 1, 2);
 | 
					            Console::output('<red>There is already an instance of Magallanes running!</red>', 1, 2);
 | 
				
			||||||
            return 1020;
 | 
					            return 230;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            touch(getcwd() . '/.mage/~working.lock');
 | 
					            touch(getcwd() . '/.mage/~working.lock');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -131,21 +133,21 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
        $this->getConfig()->setReleaseId(date('YmdHis'));
 | 
					        $this->getConfig()->setReleaseId(date('YmdHis'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Deploy Summary
 | 
					        // Deploy Summary
 | 
				
			||||||
        Console::output('<dark_gray>Deploy summary</dark_gray>', 1, 1);
 | 
					        Console::output('<bold>Deploy summary</bold>', 1, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Deploy Summary - Environment
 | 
					        // Deploy Summary - Environment
 | 
				
			||||||
        Console::output('<dark_gray>Environment:</dark_gray> <purple>' . $this->getConfig()->getEnvironment() . '</purple>', 2, 1);
 | 
					        Console::output('<bold>Environment:</bold> <purple>' . $this->getConfig()->getEnvironment() . '</purple>', 2, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Deploy Summary - Releases
 | 
					        // Deploy Summary - Releases
 | 
				
			||||||
        if ($this->getConfig()->release('enabled', false)) {
 | 
					        if ($this->getConfig()->release('enabled', false)) {
 | 
				
			||||||
            Console::output('<dark_gray>Release ID:</dark_gray>  <purple>' . $this->getConfig()->getReleaseId() . '</purple>', 2, 1);
 | 
					            Console::output('<bold>Release ID:</bold>  <purple>' . $this->getConfig()->getReleaseId() . '</purple>', 2, 1);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Deploy Summary - SCM
 | 
					        // Deploy Summary - SCM
 | 
				
			||||||
        if ($this->getConfig()->deployment('scm', false)) {
 | 
					        if ($this->getConfig()->deployment('scm', false)) {
 | 
				
			||||||
            $scmConfig = $this->getConfig()->deployment('scm');
 | 
					            $scmConfig = $this->getConfig()->deployment('scm');
 | 
				
			||||||
            if (isset($scmConfig['branch'])) {
 | 
					            if (isset($scmConfig['branch'])) {
 | 
				
			||||||
                Console::output('<dark_gray>SCM Branch:</dark_gray>  <purple>' . $scmConfig['branch'] . '</purple>', 2, 1);
 | 
					                Console::output('<bold>SCM Branch:</bold>  <purple>' . $scmConfig['branch'] . '</purple>', 2, 1);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -160,7 +162,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
        // Check Status
 | 
					        // Check Status
 | 
				
			||||||
        if (self::$failedTasks > 0) {
 | 
					        if (self::$failedTasks > 0) {
 | 
				
			||||||
            self::$deployStatus = self::FAILED;
 | 
					            self::$deployStatus = self::FAILED;
 | 
				
			||||||
            Console::output('A total of <dark_gray>' . self::$failedTasks . '</dark_gray> deployment tasks failed: <red>ABORTING</red>', 1, 2);
 | 
					            Console::output('A total of <bold>' . self::$failedTasks . '</bold> deployment tasks failed: <red>ABORTING</red>', 1, 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            // Run Deployment Tasks
 | 
					            // Run Deployment Tasks
 | 
				
			||||||
@ -169,7 +171,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
            // Check Status
 | 
					            // Check Status
 | 
				
			||||||
            if (self::$failedTasks > 0) {
 | 
					            if (self::$failedTasks > 0) {
 | 
				
			||||||
                self::$deployStatus = self::FAILED;
 | 
					                self::$deployStatus = self::FAILED;
 | 
				
			||||||
                Console::output('A total of <dark_gray>' . self::$failedTasks . '</dark_gray> deployment tasks failed: <red>ABORTING</red>', 1, 2);
 | 
					                Console::output('A total of <bold>' . self::$failedTasks . '</bold> deployment tasks failed: <red>ABORTING</red>', 1, 2);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Run Post-Deployment Tasks
 | 
					            // Run Post-Deployment Tasks
 | 
				
			||||||
@ -179,15 +181,15 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
        // Time Information Hosts
 | 
					        // Time Information Hosts
 | 
				
			||||||
        if ($this->hostsCount > 0) {
 | 
					        if ($this->hostsCount > 0) {
 | 
				
			||||||
            $timeTextHost = $this->transcurredTime($this->endTimeHosts - $this->startTimeHosts);
 | 
					            $timeTextHost = $this->transcurredTime($this->endTimeHosts - $this->startTimeHosts);
 | 
				
			||||||
            Console::output('Time for deployment: <dark_gray>' . $timeTextHost . '</dark_gray>.');
 | 
					            Console::output('Time for deployment: <bold>' . $timeTextHost . '</bold>.');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $timeTextPerHost = $this->transcurredTime(round(($this->endTimeHosts - $this->startTimeHosts) / $this->hostsCount));
 | 
					            $timeTextPerHost = $this->transcurredTime(round(($this->endTimeHosts - $this->startTimeHosts) / $this->hostsCount));
 | 
				
			||||||
            Console::output('Average time per host: <dark_gray>' . $timeTextPerHost . '</dark_gray>.');
 | 
					            Console::output('Average time per host: <bold>' . $timeTextPerHost . '</bold>.');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Time Information General
 | 
					        // Time Information General
 | 
				
			||||||
        $timeText = $this->transcurredTime(time() - $this->startTime);
 | 
					        $timeText = $this->transcurredTime(time() - $this->startTime);
 | 
				
			||||||
        Console::output('Total time: <dark_gray>' . $timeText . '</dark_gray>.', 1, 2);
 | 
					        Console::output('Total time: <bold>' . $timeText . '</bold>.', 1, 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Send Notifications
 | 
					        // Send Notifications
 | 
				
			||||||
        $this->sendNotification(self::$failedTasks > 0 ? false : true);
 | 
					        $this->sendNotification(self::$failedTasks > 0 ? false : true);
 | 
				
			||||||
@ -249,10 +251,10 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (count($tasksToRun) == 0) {
 | 
					        if (count($tasksToRun) == 0) {
 | 
				
			||||||
            Console::output('<dark_gray>No </dark_gray><light_cyan>' . $title . '</light_cyan> <dark_gray>tasks defined.</dark_gray>', 1, 3);
 | 
					            Console::output('<bold>No </bold><light_cyan>' . $title . '</light_cyan> <bold>tasks defined.</bold>', 1, 3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            Console::output('Starting <dark_gray>' . $title . '</dark_gray> tasks:');
 | 
					            Console::output('Starting <bold>' . $title . '</bold> tasks:');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $tasks = 0;
 | 
					            $tasks = 0;
 | 
				
			||||||
            $completedTasks = 0;
 | 
					            $completedTasks = 0;
 | 
				
			||||||
@ -274,7 +276,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
                $tasksColor = 'red';
 | 
					                $tasksColor = 'red';
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Console::output('Finished <dark_gray>' . $title . '</dark_gray> tasks: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . '</' . $tasksColor . '> tasks done.', 1, 3);
 | 
					            Console::output('Finished <bold>' . $title . '</bold> tasks: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . '</' . $tasksColor . '> tasks done.', 1, 3);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -290,7 +292,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
        self::$failedTasks = 0;
 | 
					        self::$failedTasks = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($this->hostsCount == 0) {
 | 
					        if ($this->hostsCount == 0) {
 | 
				
			||||||
            Console::output('<light_purple>Warning!</light_purple> <dark_gray>No hosts defined, skipping deployment tasks.</dark_gray>', 1, 3);
 | 
					            Console::output('<light_purple>Warning!</light_purple> <bold>No hosts defined, skipping deployment tasks.</bold>', 1, 3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $this->startTimeHosts = time();
 | 
					            $this->startTimeHosts = time();
 | 
				
			||||||
@ -311,7 +313,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
                $tasks = 0;
 | 
					                $tasks = 0;
 | 
				
			||||||
                $completedTasks = 0;
 | 
					                $completedTasks = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                Console::output('Deploying to <dark_gray>' . $this->getConfig()->getHost() . '</dark_gray>');
 | 
					                Console::output('Deploying to <bold>' . $this->getConfig()->getHost() . '</bold>');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                $tasksToRun = $this->getConfig()->getTasks();
 | 
					                $tasksToRun = $this->getConfig()->getTasks();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -320,8 +322,8 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
                array_unshift($tasksToRun, $deployStrategy);
 | 
					                array_unshift($tasksToRun, $deployStrategy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (count($tasksToRun) == 0) {
 | 
					                if (count($tasksToRun) == 0) {
 | 
				
			||||||
                    Console::output('<light_purple>Warning!</light_purple> <dark_gray>No </dark_gray><light_cyan>Deployment</light_cyan> <dark_gray>tasks defined.</dark_gray>', 2);
 | 
					                    Console::output('<light_purple>Warning!</light_purple> <bold>No </bold><light_cyan>Deployment</light_cyan> <bold>tasks defined.</bold>', 2);
 | 
				
			||||||
                    Console::output('Deployment to <dark_gray>' . $host . '</dark_gray> skipped!', 1, 3);
 | 
					                    Console::output('Deployment to <bold>' . $host . '</bold> skipped!', 1, 3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    foreach ($tasksToRun as $taskData) {
 | 
					                    foreach ($tasksToRun as $taskData) {
 | 
				
			||||||
@ -341,7 +343,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
                        $tasksColor = 'red';
 | 
					                        $tasksColor = 'red';
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    Console::output('Deployment to <dark_gray>' . $this->getConfig()->getHost() . '</dark_gray> completed: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . '</' . $tasksColor . '> tasks done.', 1, 3);
 | 
					                    Console::output('Deployment to <bold>' . $this->getConfig()->getHost() . '</bold> completed: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . '</' . $tasksColor . '> tasks done.', 1, 3);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Reset Host Config
 | 
					                // Reset Host Config
 | 
				
			||||||
@ -356,9 +358,9 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Releasing
 | 
					            // Releasing
 | 
				
			||||||
            if (self::$deployStatus == self::SUCCEDED && $this->getConfig()->release('enabled', false) == true) {
 | 
					            if (self::$deployStatus == self::SUCCEDED && $this->getConfig()->release('enabled', false) === true) {
 | 
				
			||||||
                // Execute the Releases
 | 
					                // Execute the Releases
 | 
				
			||||||
                Console::output('Starting the <dark_gray>Releasing</dark_gray>');
 | 
					                Console::output('Starting the <bold>Releasing</bold>');
 | 
				
			||||||
                $completedTasks = 0;
 | 
					                $completedTasks = 0;
 | 
				
			||||||
                foreach ($hosts as $hostKey => $host) {
 | 
					                foreach ($hosts as $hostKey => $host) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -382,7 +384,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
                    // Reset Host Config
 | 
					                    // Reset Host Config
 | 
				
			||||||
                    $this->getConfig()->setHostConfig(null);
 | 
					                    $this->getConfig()->setHostConfig(null);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                Console::output('Finished the <dark_gray>Releasing</dark_gray>', 1, 3);
 | 
					                Console::output('Finished the <bold>Releasing</bold>', 1, 3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                // Execute the Post-Release Tasks
 | 
					                // Execute the Post-Release Tasks
 | 
				
			||||||
                foreach ($hosts as $hostKey => $host) {
 | 
					                foreach ($hosts as $hostKey => $host) {
 | 
				
			||||||
@ -403,7 +405,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
                    $completedTasks = 0;
 | 
					                    $completedTasks = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    if (count($tasksToRun) > 0) {
 | 
					                    if (count($tasksToRun) > 0) {
 | 
				
			||||||
                        Console::output('Starting <dark_gray>Post-Release</dark_gray> tasks for <dark_gray>' . $host . '</dark_gray>:');
 | 
					                        Console::output('Starting <bold>Post-Release</bold> tasks for <bold>' . $host . '</bold>:');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        foreach ($tasksToRun as $task) {
 | 
					                        foreach ($tasksToRun as $task) {
 | 
				
			||||||
                            $task = Factory::get($task, $this->getConfig(), false, AbstractTask::STAGE_POST_RELEASE);
 | 
					                            $task = Factory::get($task, $this->getConfig(), false, AbstractTask::STAGE_POST_RELEASE);
 | 
				
			||||||
@ -418,7 +420,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
                        } else {
 | 
					                        } else {
 | 
				
			||||||
                            $tasksColor = 'red';
 | 
					                            $tasksColor = 'red';
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        Console::output('Finished <dark_gray>Post-Release</dark_gray> tasks for <dark_gray>' . $host . '</dark_gray>: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . '</' . $tasksColor . '> tasks done.', 1, 3);
 | 
					                        Console::output('Finished <bold>Post-Release</bold> tasks for <bold>' . $host . '</bold>: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . '</' . $tasksColor . '> tasks done.', 1, 3);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    // Reset Host Config
 | 
					                    // Reset Host Config
 | 
				
			||||||
@ -428,6 +430,28 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected function runRollbackTask(){
 | 
				
			||||||
 | 
					        $this->getConfig()->reload();
 | 
				
			||||||
 | 
					        $hosts = $this->getConfig()->getHosts();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (count($hosts) == 0) {
 | 
				
			||||||
 | 
					            Console::output('<light_purple>Warning!</light_purple> <bold>No hosts defined, unable to get releases.</bold>', 1, 3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $result = true;
 | 
				
			||||||
 | 
					            foreach ($hosts as $host) {
 | 
				
			||||||
 | 
					                $this->getConfig()->setHost($host);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                $this->getConfig()->setReleaseId(-1);
 | 
				
			||||||
 | 
					                $task = Factory::get('releases/rollback', $this->getConfig());
 | 
				
			||||||
 | 
					                $task->init();
 | 
				
			||||||
 | 
					                $result = $task->run() && $result;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            return $result;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Runs a Task
 | 
					     * Runs a Task
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
@ -439,7 +463,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        $task->init();
 | 
					        $task->init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($title == null) {
 | 
					        if ($title === null) {
 | 
				
			||||||
            $title = 'Running <purple>' . $task->getName() . '</purple> ... ';
 | 
					            $title = 'Running <purple>' . $task->getName() . '</purple> ... ';
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        Console::output($title, 2, 0);
 | 
					        Console::output($title, 2, 0);
 | 
				
			||||||
@ -449,11 +473,11 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
            $runTask = false;
 | 
					            $runTask = false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($runTask == true) {
 | 
					        if ($runTask === true) {
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
                $result = $task->run();
 | 
					                $result = $task->run();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if ($result == true) {
 | 
					                if ($result === true) {
 | 
				
			||||||
                    Console::output('<green>OK</green>', 0);
 | 
					                    Console::output('<green>OK</green>', 0);
 | 
				
			||||||
                    $result = true;
 | 
					                    $result = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -461,6 +485,11 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
                    Console::output('<red>FAIL</red>', 0);
 | 
					                    Console::output('<red>FAIL</red>', 0);
 | 
				
			||||||
                    $result = false;
 | 
					                    $result = false;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					            } catch (RollbackException $e) {
 | 
				
			||||||
 | 
					                Console::output('<red>FAIL, Rollback started</red> [Message: ' . $e->getMessage() . ']', 0);
 | 
				
			||||||
 | 
					                $this->runRollbackTask();
 | 
				
			||||||
 | 
					                $result = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            } catch (ErrorWithMessageException $e) {
 | 
					            } catch (ErrorWithMessageException $e) {
 | 
				
			||||||
                Console::output('<red>FAIL</red> [Message: ' . $e->getMessage() . ']', 0);
 | 
					                Console::output('<red>FAIL</red> [Message: ' . $e->getMessage() . ']', 0);
 | 
				
			||||||
                $result = false;
 | 
					                $result = false;
 | 
				
			||||||
@ -564,7 +593,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            case self::DEPLOY_STRATEGY_GUESS:
 | 
					            case self::DEPLOY_STRATEGY_GUESS:
 | 
				
			||||||
            default:
 | 
					            default:
 | 
				
			||||||
                if ($this->getConfig()->release('enabled', false) == true) {
 | 
					                if ($this->getConfig()->release('enabled', false) === true) {
 | 
				
			||||||
                    $deployStrategy = 'deployment/strategy/tar-gz';
 | 
					                    $deployStrategy = 'deployment/strategy/tar-gz';
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    $deployStrategy = 'deployment/strategy/rsync';
 | 
					                    $deployStrategy = 'deployment/strategy/rsync';
 | 
				
			||||||
 | 
				
			|||||||
@ -30,11 +30,11 @@ class InitCommand extends AbstractCommand
 | 
				
			|||||||
        $exitCode = 50;
 | 
					        $exitCode = 50;
 | 
				
			||||||
        $configDir = getcwd() . '/.mage';
 | 
					        $configDir = getcwd() . '/.mage';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Console::output('Initiating managing process for application with <dark_gray>Magallanes</dark_gray>');
 | 
					        Console::output('Initiating managing process for application with <bold>Magallanes</bold>');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Check if there is already a config dir
 | 
					        // Check if there is already a config dir
 | 
				
			||||||
        if (file_exists($configDir)) {
 | 
					        if (file_exists($configDir)) {
 | 
				
			||||||
            Console::output('<light_red>Error!!</light_red> Already exists <dark_gray>.mage</dark_gray> directory.', 1, 2);
 | 
					            Console::output('<light_red>Error!!</light_red> Already exists <bold>.mage</bold> directory.', 1, 2);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $results = array();
 | 
					            $results = array();
 | 
				
			||||||
            $results[] = mkdir($configDir);
 | 
					            $results[] = mkdir($configDir);
 | 
				
			||||||
@ -48,8 +48,8 @@ class InitCommand extends AbstractCommand
 | 
				
			|||||||
            $results[] = file_put_contents($configDir . '/config/general.yml', $this->getGeneralConfig());
 | 
					            $results[] = file_put_contents($configDir . '/config/general.yml', $this->getGeneralConfig());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (!in_array(false, $results)) {
 | 
					            if (!in_array(false, $results)) {
 | 
				
			||||||
                Console::output('<light_green>Success!!</light_green> The configuration for <dark_gray>Magallanes</dark_gray> has been generated at <blue>.mage</blue> directory.');
 | 
					                Console::output('<light_green>Success!!</light_green> The configuration for <bold>Magallanes</bold> has been generated at <blue>.mage</blue> directory.');
 | 
				
			||||||
                Console::output('<dark_gray>Please!! Review and adjust the configuration.</dark_gray>', 2, 2);
 | 
					                Console::output('<bold>Please!! Review and adjust the configuration.</bold>', 2, 2);
 | 
				
			||||||
                $exitCode = 0;
 | 
					                $exitCode = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
 | 
				
			|||||||
@ -27,7 +27,7 @@ class InstallCommand extends AbstractCommand
 | 
				
			|||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $exitCode = 88;
 | 
					        $exitCode = 88;
 | 
				
			||||||
        Console::output('Installing <dark_gray>Magallanes</dark_gray>... ', 1, 0);
 | 
					        Console::output('Installing <bold>Magallanes</bold>... ', 1, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Vars
 | 
					        // Vars
 | 
				
			||||||
        $installDir = $this->getConfig()->getParameter('installDir', '/opt/magallanes');
 | 
					        $installDir = $this->getConfig()->getParameter('installDir', '/opt/magallanes');
 | 
				
			||||||
 | 
				
			|||||||
@ -31,7 +31,7 @@ class ListCommand extends AbstractCommand
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $exitCode = 600;
 | 
					        $exitCode = 221;
 | 
				
			||||||
        $subCommand = $this->getConfig()->getArgument(1);
 | 
					        $subCommand = $this->getConfig()->getArgument(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
@ -56,7 +56,7 @@ class ListCommand extends AbstractCommand
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected function listEnvironments()
 | 
					    protected function listEnvironments()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $exitCode = 600;
 | 
					        $exitCode = 220;
 | 
				
			||||||
        $environments = array();
 | 
					        $environments = array();
 | 
				
			||||||
        $content = scandir(getcwd() . '/.mage/config/environment/');
 | 
					        $content = scandir(getcwd() . '/.mage/config/environment/');
 | 
				
			||||||
        foreach ($content as $file) {
 | 
					        foreach ($content as $file) {
 | 
				
			||||||
@ -67,7 +67,7 @@ class ListCommand extends AbstractCommand
 | 
				
			|||||||
        sort($environments);
 | 
					        sort($environments);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (count($environments) > 0) {
 | 
					        if (count($environments) > 0) {
 | 
				
			||||||
            Console::output('<dark_gray>These are your configured environments:</dark_gray>', 1, 1);
 | 
					            Console::output('<bold>These are your configured environments:</bold>', 1, 1);
 | 
				
			||||||
            foreach ($environments as $environment) {
 | 
					            foreach ($environments as $environment) {
 | 
				
			||||||
                Console::output('* <light_red>' . $environment . '</light_red>', 2, 1);
 | 
					                Console::output('* <light_red>' . $environment . '</light_red>', 2, 1);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -75,7 +75,7 @@ class ListCommand extends AbstractCommand
 | 
				
			|||||||
            $exitCode = 0;
 | 
					            $exitCode = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            Console::output('<dark_gray>You don\'t have any environment configured.</dark_gray>', 1, 2);
 | 
					            Console::output('<bold>You don\'t have any environment configured.</bold>', 1, 2);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $exitCode;
 | 
					        return $exitCode;
 | 
				
			||||||
 | 
				
			|||||||
@ -28,7 +28,7 @@ class ReleasesCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $exitCode = 400;
 | 
					        $exitCode = 100;
 | 
				
			||||||
        $subCommand = $this->getConfig()->getArgument(1);
 | 
					        $subCommand = $this->getConfig()->getArgument(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Run Tasks for Deployment
 | 
					        // Run Tasks for Deployment
 | 
				
			||||||
@ -36,16 +36,25 @@ class ReleasesCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if (count($hosts) == 0) {
 | 
					        if (count($hosts) == 0) {
 | 
				
			||||||
            Console::output(
 | 
					            Console::output(
 | 
				
			||||||
                '<light_purple>Warning!</light_purple> <dark_gray>No hosts defined, unable to get releases.</dark_gray>',
 | 
					                '<light_purple>Warning!</light_purple> <bold>No hosts defined, unable to get releases.</bold>',
 | 
				
			||||||
                1, 3
 | 
					                1, 3
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return 401;
 | 
					            return 101;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $result = true;
 | 
					        $result = true;
 | 
				
			||||||
        foreach ($hosts as $host) {
 | 
					        foreach ($hosts as $hostKey => $host) {
 | 
				
			||||||
 | 
					            // Check if Host has specific configuration
 | 
				
			||||||
 | 
					            $hostConfig = null;
 | 
				
			||||||
 | 
					            if (is_array($host)) {
 | 
				
			||||||
 | 
					                $hostConfig = $host;
 | 
				
			||||||
 | 
					                $host = $hostKey;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Set Host and Host Specific Config
 | 
				
			||||||
            $this->getConfig()->setHost($host);
 | 
					            $this->getConfig()->setHost($host);
 | 
				
			||||||
 | 
					            $this->getConfig()->setHostConfig($hostConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            switch ($subCommand) {
 | 
					            switch ($subCommand) {
 | 
				
			||||||
                case 'list':
 | 
					                case 'list':
 | 
				
			||||||
@ -58,7 +67,7 @@ class ReleasesCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
                    if (!is_numeric($this->getConfig()->getParameter('release', ''))) {
 | 
					                    if (!is_numeric($this->getConfig()->getParameter('release', ''))) {
 | 
				
			||||||
                        Console::output('<red>Missing required releaseid.</red>', 1, 2);
 | 
					                        Console::output('<red>Missing required releaseid.</red>', 1, 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        return 410;
 | 
					                        return 102;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock';
 | 
					                    $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock';
 | 
				
			||||||
@ -66,7 +75,7 @@ class ReleasesCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
                        Console::output('<red>This environment is locked!</red>', 1, 2);
 | 
					                        Console::output('<red>This environment is locked!</red>', 1, 2);
 | 
				
			||||||
                        echo file_get_contents($lockFile);
 | 
					                        echo file_get_contents($lockFile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        return 420;
 | 
					                        return 103;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    $releaseId = $this->getConfig()->getParameter('release', '');
 | 
					                    $releaseId = $this->getConfig()->getParameter('release', '');
 | 
				
			||||||
 | 
				
			|||||||
@ -28,31 +28,40 @@ class RollbackCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $exitCode = 450;
 | 
					        $exitCode = 105;
 | 
				
			||||||
        $releaseId = $this->getConfig()->getArgument(1);
 | 
					        $releaseId = $this->getConfig()->getArgument(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!is_numeric($releaseId)) {
 | 
					        if (!is_numeric($releaseId)) {
 | 
				
			||||||
            Console::output('<red>This release is mandatory.</red>', 1, 2);
 | 
					            Console::output('<red>This release is mandatory.</red>', 1, 2);
 | 
				
			||||||
            return 451;
 | 
					            return 104;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock';
 | 
					        $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock';
 | 
				
			||||||
        if (file_exists($lockFile)) {
 | 
					        if (file_exists($lockFile)) {
 | 
				
			||||||
            Console::output('<red>This environment is locked!</red>', 1, 2);
 | 
					            Console::output('<red>This environment is locked!</red>', 1, 2);
 | 
				
			||||||
            echo file_get_contents($lockFile);
 | 
					            echo file_get_contents($lockFile);
 | 
				
			||||||
            return 20;
 | 
					            return 106;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Run Tasks for Deployment
 | 
					        // Run Tasks for Deployment
 | 
				
			||||||
        $hosts = $this->getConfig()->getHosts();
 | 
					        $hosts = $this->getConfig()->getHosts();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (count($hosts) == 0) {
 | 
					        if (count($hosts) == 0) {
 | 
				
			||||||
            Console::output('<light_purple>Warning!</light_purple> <dark_gray>No hosts defined, unable to get releases.</dark_gray>', 1, 3);
 | 
					            Console::output('<light_purple>Warning!</light_purple> <bold>No hosts defined, unable to get releases.</bold>', 1, 3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $result = true;
 | 
					            $result = true;
 | 
				
			||||||
            foreach ($hosts as $host) {
 | 
					            foreach ($hosts as $hostKey => $host) {
 | 
				
			||||||
 | 
					                // Check if Host has specific configuration
 | 
				
			||||||
 | 
					                $hostConfig = null;
 | 
				
			||||||
 | 
					                if (is_array($host)) {
 | 
				
			||||||
 | 
					                    $hostConfig = $host;
 | 
				
			||||||
 | 
					                    $host = $hostKey;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // Set Host and Host Specific Config
 | 
				
			||||||
                $this->getConfig()->setHost($host);
 | 
					                $this->getConfig()->setHost($host);
 | 
				
			||||||
 | 
					                $this->getConfig()->setHostConfig($hostConfig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                $this->getConfig()->setReleaseId($releaseId);
 | 
					                $this->getConfig()->setReleaseId($releaseId);
 | 
				
			||||||
                $task = Factory::get('releases/rollback', $this->getConfig());
 | 
					                $task = Factory::get('releases/rollback', $this->getConfig());
 | 
				
			||||||
 | 
				
			|||||||
@ -35,7 +35,7 @@ class UpdateCommand extends AbstractCommand
 | 
				
			|||||||
        Console::output('Updating application via ' . $task->getName() . ' ... ', 1, 0);
 | 
					        Console::output('Updating application via ' . $task->getName() . ' ... ', 1, 0);
 | 
				
			||||||
        $result = $task->run();
 | 
					        $result = $task->run();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($result == true) {
 | 
					        if ($result === true) {
 | 
				
			||||||
            Console::output('<green>OK</green>' . PHP_EOL, 0);
 | 
					            Console::output('<green>OK</green>' . PHP_EOL, 0);
 | 
				
			||||||
            $exitCode = 0;
 | 
					            $exitCode = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -45,5 +45,4 @@ class UpdateCommand extends AbstractCommand
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        return $exitCode;
 | 
					        return $exitCode;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -38,8 +38,8 @@ class UpgradeCommand extends AbstractCommand
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $exitCode = 100;
 | 
					        $exitCode = 99;
 | 
				
			||||||
        Console::output('Upgrading <dark_gray>Magallanes</dark_gray> ... ', 1, 0);
 | 
					        Console::output('Upgrading <bold>Magallanes</bold> ... ', 1, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $user = '';
 | 
					        $user = '';
 | 
				
			||||||
        // Check if user is root
 | 
					        // Check if user is root
 | 
				
			||||||
@ -49,7 +49,7 @@ class UpgradeCommand extends AbstractCommand
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if ($user != 'root' && $user != $owner) {
 | 
					        if ($user != 'root' && $user != $owner) {
 | 
				
			||||||
            Console::output('<red>FAIL</red>', 0, 1);
 | 
					            Console::output('<red>FAIL</red>', 0, 1);
 | 
				
			||||||
            Console::output('You need to be the <dark_gray>' . $owner . '</dark_gray> user to perform the upgrade, or <dark_gray>root</dark_gray>.', 2);
 | 
					            Console::output('You need to be the <bold>' . $owner . '</bold> user to perform the upgrade, or <bold>root</bold>.', 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            // Check version
 | 
					            // Check version
 | 
				
			||||||
 | 
				
			|||||||
@ -26,9 +26,8 @@ class VersionCommand extends AbstractCommand
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Console::output('Running <blue>Magallanes</blue> version <dark_gray>' . MAGALLANES_VERSION . '</dark_gray>', 0, 2);
 | 
					        Console::output('Running <blue>Magallanes</blue> version <bold>' . MAGALLANES_VERSION . '</bold>', 0, 2);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -12,7 +12,6 @@ namespace Mage\Command;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
use Mage\Command\AbstractCommand;
 | 
					use Mage\Command\AbstractCommand;
 | 
				
			||||||
use Mage\Config;
 | 
					use Mage\Config;
 | 
				
			||||||
use Mage\Autoload;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
use Exception;
 | 
					use Exception;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,6 @@ namespace Mage;
 | 
				
			|||||||
use Mage\Config\ConfigNotFoundException;
 | 
					use Mage\Config\ConfigNotFoundException;
 | 
				
			||||||
use Mage\Config\RequiredConfigNotFoundException;
 | 
					use Mage\Config\RequiredConfigNotFoundException;
 | 
				
			||||||
use Mage\Console;
 | 
					use Mage\Console;
 | 
				
			||||||
use Mage\Yaml\Exception\RuntimeException;
 | 
					 | 
				
			||||||
use Mage\Yaml\Yaml;
 | 
					use Mage\Yaml\Yaml;
 | 
				
			||||||
use Exception;
 | 
					use Exception;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -121,29 +120,6 @@ class Config
 | 
				
			|||||||
        return $this->parseConfigFile($filePath);
 | 
					        return $this->parseConfigFile($filePath);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Obviously this method is a HACK.  It was refactored from ::loadEnvironment()
 | 
					 | 
				
			||||||
     * TODO Please put it to SCM functionality.
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param array $settings
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @return array
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    protected function updateSCMTempDir(array $settings)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        // Create temporal directory for clone
 | 
					 | 
				
			||||||
        if (isset($settings['deployment']['source']) && is_array($settings['deployment']['source'])) {
 | 
					 | 
				
			||||||
            if (trim($settings['deployment']['source']['temporal']) == '') {
 | 
					 | 
				
			||||||
                $settings['deployment']['source']['temporal'] = sys_get_temp_dir();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            $settings['deployment']['source']['temporal']
 | 
					 | 
				
			||||||
                = rtrim($settings['deployment']['source']['temporal'], '/') . '/' . md5(microtime()) . '/';
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $settings;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Loads the Environment configuration
 | 
					     * Loads the Environment configuration
 | 
				
			||||||
     * @param $filePath string
 | 
					     * @param $filePath string
 | 
				
			||||||
@ -156,9 +132,6 @@ class Config
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $settings = $this->parseConfigFile($filePath);
 | 
					        $settings = $this->parseConfigFile($filePath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //this is a HACK in the old code - no time to remove it now, so I factored it out in own method
 | 
					 | 
				
			||||||
        $settings = $this->updateSCMTempDir($settings);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $settings;
 | 
					        return $settings;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -490,6 +463,11 @@ class Config
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function setSourceTemporal($directory)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $this->environmentConfig['deployment']['source']['temporal'] = $directory;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Returns Releasing Options
 | 
					     * Returns Releasing Options
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
				
			|||||||
@ -26,7 +26,6 @@ use SplFileInfo;
 | 
				
			|||||||
class Console
 | 
					class Console
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * TODO refactor into own static class
 | 
					 | 
				
			||||||
     * @var array
 | 
					     * @var array
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static $paramsNotRequiringEnvironment = array('install' => 'install', 'upgrade' => 'upgrade', 'version' => 'version');
 | 
					    public static $paramsNotRequiringEnvironment = array('install' => 'install', 'upgrade' => 'upgrade', 'version' => 'version');
 | 
				
			||||||
@ -116,11 +115,10 @@ class Console
 | 
				
			|||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                self::output('Starting <blue>Magallanes</blue>', 0, 1);
 | 
					                self::output('Starting <blue>Magallanes</blue>', 0, 1);
 | 
				
			||||||
                self::log("Logging enabled");
 | 
					                self::log("Logging enabled");
 | 
				
			||||||
                self::output('<dark_gray>Logging enabled:</dark_gray> <purple>' . self::getLogFile() . '</purple>', 1, 2);
 | 
					                self::output('<bold>Logging enabled:</bold> <purple>' . self::getLogFile() . '</purple>', 1, 2);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Run Command - Check if there is a Configuration Error
 | 
					        // Run Command - Check if there is a Configuration Error
 | 
				
			||||||
        if ($configError !== false) {
 | 
					        if ($configError !== false) {
 | 
				
			||||||
            self::output('<red>' . $configError . '</red>', 1, 2);
 | 
					            self::output('<red>' . $configError . '</red>', 1, 2);
 | 
				
			||||||
@ -131,12 +129,21 @@ class Console
 | 
				
			|||||||
                $command = Factory::get($commandName, $config);
 | 
					                $command = Factory::get($commandName, $config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if ($command instanceOf RequiresEnvironment) {
 | 
					                if ($command instanceOf RequiresEnvironment) {
 | 
				
			||||||
                    if ($config->getEnvironment() == false) {
 | 
					                    if ($config->getEnvironment() === false) {
 | 
				
			||||||
                        throw new Exception('You must specify an environment for this command.');
 | 
					                        throw new Exception('You must specify an environment for this command.');
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // Run the Command
 | 
				
			||||||
                $exitCode = $command->run();
 | 
					                $exitCode = $command->run();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                // Check for errors
 | 
				
			||||||
 | 
					                if (is_int($exitCode) && $exitCode !== 0) {
 | 
				
			||||||
 | 
					                    throw new Exception('Command execution failed with following exit code: ' . $exitCode, $exitCode);
 | 
				
			||||||
 | 
					                } elseif (is_bool($exitCode) && !$exitCode) {
 | 
				
			||||||
 | 
					                    $exitCode = 1;
 | 
				
			||||||
 | 
					                    throw new Exception('Command execution failed.', $exitCode);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            } catch (Exception $exception) {
 | 
					            } catch (Exception $exception) {
 | 
				
			||||||
                self::output('<red>' . $exception->getMessage() . '</red>', 1, 2);
 | 
					                self::output('<red>' . $exception->getMessage() . '</red>', 1, 2);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -213,7 +220,7 @@ class Console
 | 
				
			|||||||
    public static function log($message)
 | 
					    public static function log($message)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (self::$logEnabled) {
 | 
					        if (self::$logEnabled) {
 | 
				
			||||||
            if (self::$log == null) {
 | 
					            if (self::$log === null) {
 | 
				
			||||||
                self::$logFile = realpath(getcwd() . '/.mage/logs') . '/log-' . date('Ymd-His') . '.log';
 | 
					                self::$logFile = realpath(getcwd() . '/.mage/logs') . '/log-' . date('Ymd-His') . '.log';
 | 
				
			||||||
                self::$log = fopen(self::$logFile, 'w');
 | 
					                self::$log = fopen(self::$logFile, 'w');
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
				
			|||||||
@ -25,7 +25,7 @@ class Colors
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    private static $foregroundColors = array(
 | 
					    private static $foregroundColors = array(
 | 
				
			||||||
        'black' => '0;30',
 | 
					        'black' => '0;30',
 | 
				
			||||||
        'dark_gray' => '1;30',
 | 
					        'bold' => '1',
 | 
				
			||||||
        'blue' => '0;34',
 | 
					        'blue' => '0;34',
 | 
				
			||||||
        'light_blue' => '1;34',
 | 
					        'light_blue' => '1;34',
 | 
				
			||||||
        'green' => '0;32',
 | 
					        'green' => '0;32',
 | 
				
			||||||
 | 
				
			|||||||
@ -84,6 +84,6 @@ class Mailer
 | 
				
			|||||||
            . $attachment . self::EOL
 | 
					            . $attachment . self::EOL
 | 
				
			||||||
            . '--Mage-mixed-' . $boundary . '--' . self::EOL;
 | 
					            . '--Mage-mixed-' . $boundary . '--' . self::EOL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        @mail($this->address, $subject, $message, $headers);
 | 
					        mail($this->address, $subject, $message, $headers);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -181,7 +181,7 @@ abstract class AbstractTask
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected final function runCommandRemote($command, &$output = null, $cdToDirectoryFirst = true)
 | 
					    protected final function runCommandRemote($command, &$output = null, $cdToDirectoryFirst = true)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if ($this->getConfig()->release('enabled', false) == true) {
 | 
					        if ($this->getConfig()->release('enabled', false) === true) {
 | 
				
			||||||
            if ($this instanceOf IsReleaseAware) {
 | 
					            if ($this instanceOf IsReleaseAware) {
 | 
				
			||||||
                $releasesDirectory = '';
 | 
					                $releasesDirectory = '';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -223,7 +223,7 @@ abstract class AbstractTask
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected final function runCommand($command, &$output = null)
 | 
					    protected final function runCommand($command, &$output = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if ($this->getStage() == self::STAGE_DEPLOY) {
 | 
					        if ($this->getStage() == self::STAGE_DEPLOY || $this->getStage() == self::STAGE_POST_RELEASE) {
 | 
				
			||||||
            return $this->runCommandRemote($command, $output);
 | 
					            return $this->runCommandRemote($command, $output);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            return $this->runCommandLocal($command, $output);
 | 
					            return $this->runCommandLocal($command, $output);
 | 
				
			||||||
@ -238,7 +238,7 @@ abstract class AbstractTask
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected function getReleasesAwareCommand($command)
 | 
					    protected function getReleasesAwareCommand($command)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if ($this->getConfig()->release('enabled', false) == true) {
 | 
					        if ($this->getConfig()->release('enabled', false) === true) {
 | 
				
			||||||
            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
					            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $deployToDirectory = $releasesDirectory . '/' . $this->getConfig()->getReleaseId();
 | 
					            $deployToDirectory = $releasesDirectory . '/' . $this->getConfig()->getReleaseId();
 | 
				
			||||||
 | 
				
			|||||||
@ -37,7 +37,7 @@ class ReleaseTask extends AbstractTask implements IsReleaseAware, SkipOnOverride
 | 
				
			|||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $resultFetch = false;
 | 
					        $resultFetch = false;
 | 
				
			||||||
        if ($this->getConfig()->release('enabled', false) == true) {
 | 
					        if ($this->getConfig()->release('enabled', false) === true) {
 | 
				
			||||||
            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
					            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
				
			||||||
            $symlink = $this->getConfig()->release('symlink', 'current');
 | 
					            $symlink = $this->getConfig()->release('symlink', 'current');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -107,7 +107,7 @@ class ReleaseTask extends AbstractTask implements IsReleaseAware, SkipOnOverride
 | 
				
			|||||||
    protected function cleanUpReleases()
 | 
					    protected function cleanUpReleases()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // Count Releases
 | 
					        // Count Releases
 | 
				
			||||||
        if ($this->getConfig()->release('enabled', false) == true) {
 | 
					        if ($this->getConfig()->release('enabled', false) === true) {
 | 
				
			||||||
            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
					            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
				
			||||||
            $symlink = $this->getConfig()->release('symlink', 'current');
 | 
					            $symlink = $this->getConfig()->release('symlink', 'current');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -30,7 +30,7 @@ abstract class BaseStrategyTaskAbstract extends AbstractTask implements IsReleas
 | 
				
			|||||||
        $overrideRelease = $this->getParameter('overrideRelease', false);
 | 
					        $overrideRelease = $this->getParameter('overrideRelease', false);
 | 
				
			||||||
        $symlink = $this->getConfig()->release('symlink', 'current');
 | 
					        $symlink = $this->getConfig()->release('symlink', 'current');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($overrideRelease == true) {
 | 
					        if ($overrideRelease === true) {
 | 
				
			||||||
            $releaseToOverride = false;
 | 
					            $releaseToOverride = false;
 | 
				
			||||||
            $resultFetch = $this->runCommandRemote('ls -ld ' . $symlink . ' | cut -d"/" -f2', $releaseToOverride);
 | 
					            $resultFetch = $this->runCommandRemote('ls -ld ' . $symlink . ' | cut -d"/" -f2', $releaseToOverride);
 | 
				
			||||||
            if ($resultFetch && is_numeric($releaseToOverride)) {
 | 
					            if ($resultFetch && is_numeric($releaseToOverride)) {
 | 
				
			||||||
 | 
				
			|||||||
@ -38,5 +38,4 @@ class DisabledTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        throw new SkipException;
 | 
					        throw new SkipException;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -10,7 +10,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Mage\Task\BuiltIn\Deployment\Strategy;
 | 
					namespace Mage\Task\BuiltIn\Deployment\Strategy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use Mage\Task\AbstractTask;
 | 
					 | 
				
			||||||
use Mage\Task\Releases\IsReleaseAware;
 | 
					use Mage\Task\Releases\IsReleaseAware;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@ -35,20 +34,6 @@ class GitRebaseTask extends BaseStrategyTaskAbstract implements IsReleaseAware
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->checkOverrideRelease();
 | 
					 | 
				
			||||||
        $excludes = $this->getExcludes();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // If we are working with releases
 | 
					 | 
				
			||||||
        $deployToDirectory = $this->getConfig()->deployment('to');
 | 
					 | 
				
			||||||
        if ($this->getConfig()->release('enabled', false) == true) {
 | 
					 | 
				
			||||||
            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $deployToDirectory = rtrim($this->getConfig()->deployment('to'), '/')
 | 
					 | 
				
			||||||
                . '/' . $releasesDirectory
 | 
					 | 
				
			||||||
                . '/' . $this->getConfig()->getReleaseId();
 | 
					 | 
				
			||||||
            $this->runCommandRemote('mkdir -p ' . $releasesDirectory . '/' . $this->getConfig()->getReleaseId());
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $branch = $this->getParameter('branch', 'master');
 | 
					        $branch = $this->getParameter('branch', 'master');
 | 
				
			||||||
        $remote = $this->getParameter('remote', 'origin');
 | 
					        $remote = $this->getParameter('remote', 'origin');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -42,7 +42,7 @@ class GitRemoteCacheTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        $overrideRelease = $this->getParameter('overrideRelease', false);
 | 
					        $overrideRelease = $this->getParameter('overrideRelease', false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($overrideRelease == true) {
 | 
					        if ($overrideRelease === true) {
 | 
				
			||||||
            $releaseToOverride = false;
 | 
					            $releaseToOverride = false;
 | 
				
			||||||
            $resultFetch = $this->runCommandRemote('ls -ld current | cut -d"/" -f2', $releaseToOverride);
 | 
					            $resultFetch = $this->runCommandRemote('ls -ld current | cut -d"/" -f2', $releaseToOverride);
 | 
				
			||||||
            if ($resultFetch && is_numeric($releaseToOverride)) {
 | 
					            if ($resultFetch && is_numeric($releaseToOverride)) {
 | 
				
			||||||
@ -63,7 +63,7 @@ class GitRemoteCacheTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
        $userExcludes = $this->getConfig()->deployment('excludes', array());
 | 
					        $userExcludes = $this->getConfig()->deployment('excludes', array());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $deployToDirectory = $this->getConfig()->deployment('to');
 | 
					        $deployToDirectory = $this->getConfig()->deployment('to');
 | 
				
			||||||
        if ($this->getConfig()->release('enabled', false) == true) {
 | 
					        if ($this->getConfig()->release('enabled', false) === true) {
 | 
				
			||||||
            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
					            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $deployToDirectory = rtrim($this->getConfig()->deployment('to'), '/')
 | 
					            $deployToDirectory = rtrim($this->getConfig()->deployment('to'), '/')
 | 
				
			||||||
@ -97,39 +97,8 @@ class GitRemoteCacheTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
        $command = 'cd ' . $remoteCacheFolder . ' && /usr/bin/env git archive ' . $branch . ' | tar -x -C ' . $deployToDirectory . ' ' . $excludeCmd;
 | 
					        $command = 'cd ' . $remoteCacheFolder . ' && /usr/bin/env git archive ' . $branch . ' | tar -x -C ' . $deployToDirectory . ' ' . $excludeCmd;
 | 
				
			||||||
        $result = $this->runCommandRemote($command) && $result;
 | 
					        $result = $this->runCommandRemote($command) && $result;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Count Releases
 | 
					        if ($result) {
 | 
				
			||||||
        if ($this->getConfig()->release('enabled', false) == true) {
 | 
					            $this->cleanUpReleases();
 | 
				
			||||||
            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
					 | 
				
			||||||
            $symlink = $this->getConfig()->release('symlink', 'current');
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (substr($symlink, 0, 1) == '/') {
 | 
					 | 
				
			||||||
                $releasesDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $maxReleases = $this->getConfig()->release('max', false);
 | 
					 | 
				
			||||||
            if (($maxReleases !== false) && ($maxReleases > 0)) {
 | 
					 | 
				
			||||||
                $releasesList = '';
 | 
					 | 
				
			||||||
                $countReleasesFetch = $this->runCommandRemote('ls -1 ' . $releasesDirectory, $releasesList);
 | 
					 | 
				
			||||||
                $releasesList = trim($releasesList);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if ($countReleasesFetch && $releasesList != '') {
 | 
					 | 
				
			||||||
                    $releasesList = explode(PHP_EOL, $releasesList);
 | 
					 | 
				
			||||||
                    if (count($releasesList) > $maxReleases) {
 | 
					 | 
				
			||||||
                        $releasesToDelete = array_diff($releasesList, array($this->getConfig()->getReleaseId()));
 | 
					 | 
				
			||||||
                        sort($releasesToDelete);
 | 
					 | 
				
			||||||
                        $releasesToDeleteCount = count($releasesToDelete) - $maxReleases;
 | 
					 | 
				
			||||||
                        $releasesToDelete = array_slice($releasesToDelete, 0, $releasesToDeleteCount + 1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                        foreach ($releasesToDelete as $releaseIdToDelete) {
 | 
					 | 
				
			||||||
                            $directoryToDelete = $releasesDirectory . '/' . $releaseIdToDelete;
 | 
					 | 
				
			||||||
                            if ($directoryToDelete != '/') {
 | 
					 | 
				
			||||||
                                $command = 'rm -rf ' . $directoryToDelete;
 | 
					 | 
				
			||||||
                                $result = $result && $this->runCommandRemote($command);
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $result;
 | 
					        return $result;
 | 
				
			||||||
 | 
				
			|||||||
@ -27,8 +27,8 @@ class RsyncTask extends BaseStrategyTaskAbstract implements IsReleaseAware
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function getName()
 | 
					    public function getName()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if ($this->getConfig()->release('enabled', false) == true) {
 | 
					        if ($this->getConfig()->release('enabled', false) === true) {
 | 
				
			||||||
            if ($this->getConfig()->getParameter('overrideRelease', false) == true) {
 | 
					            if ($this->getConfig()->getParameter('overrideRelease', false) === true) {
 | 
				
			||||||
                return 'Deploy via Rsync (with Releases override) [built-in]';
 | 
					                return 'Deploy via Rsync (with Releases override) [built-in]';
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                $rsync_copy = $this->getConfig()->deployment("rsync");
 | 
					                $rsync_copy = $this->getConfig()->deployment("rsync");
 | 
				
			||||||
@ -52,10 +52,11 @@ class RsyncTask extends BaseStrategyTaskAbstract implements IsReleaseAware
 | 
				
			|||||||
        $this->checkOverrideRelease();
 | 
					        $this->checkOverrideRelease();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $excludes = $this->getExcludes();
 | 
					        $excludes = $this->getExcludes();
 | 
				
			||||||
 | 
					        $excludesListFilePath = $this->getConfig()->deployment('excludes_file', '');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // If we are working with releases
 | 
					        // If we are working with releases
 | 
				
			||||||
        $deployToDirectory = $this->getConfig()->deployment('to');
 | 
					        $deployToDirectory = $this->getConfig()->deployment('to');
 | 
				
			||||||
        if ($this->getConfig()->release('enabled', false) == true) {
 | 
					        if ($this->getConfig()->release('enabled', false) === true) {
 | 
				
			||||||
            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
					            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
				
			||||||
            $symlink = $this->getConfig()->release('symlink', 'current');
 | 
					            $symlink = $this->getConfig()->release('symlink', 'current');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -95,6 +96,7 @@ class RsyncTask extends BaseStrategyTaskAbstract implements IsReleaseAware
 | 
				
			|||||||
                 . $strategyFlags . ' '
 | 
					                 . $strategyFlags . ' '
 | 
				
			||||||
                 . '--rsh="ssh ' . $this->getConfig()->getHostIdentityFileOption() . '-p' . $this->getConfig()->getHostPort() . '" '
 | 
					                 . '--rsh="ssh ' . $this->getConfig()->getHostIdentityFileOption() . '-p' . $this->getConfig()->getHostPort() . '" '
 | 
				
			||||||
                 . $this->excludes($excludes) . ' '
 | 
					                 . $this->excludes($excludes) . ' '
 | 
				
			||||||
 | 
					                 . $this->excludesListFile($excludesListFilePath) . ' '
 | 
				
			||||||
                 . $this->getConfig()->deployment('from') . ' '
 | 
					                 . $this->getConfig()->deployment('from') . ' '
 | 
				
			||||||
                 . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ':' . $deployToDirectory;
 | 
					                 . $this->getConfig()->deployment('user') . '@' . $this->getConfig()->getHostName() . ':' . $deployToDirectory;
 | 
				
			||||||
        $result = $this->runCommandLocal($command);
 | 
					        $result = $this->runCommandLocal($command);
 | 
				
			||||||
@ -117,4 +119,18 @@ class RsyncTask extends BaseStrategyTaskAbstract implements IsReleaseAware
 | 
				
			|||||||
        $excludesRsync = trim($excludesRsync);
 | 
					        $excludesRsync = trim($excludesRsync);
 | 
				
			||||||
        return $excludesRsync;
 | 
					        return $excludesRsync;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Generates the Exclude from file for rsync
 | 
				
			||||||
 | 
					     * @param string $excludesFile
 | 
				
			||||||
 | 
					     * @return string
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected function excludesListFile($excludesFile)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $excludesListFileRsync = '';
 | 
				
			||||||
 | 
					        if(!empty($excludesFile) && file_exists($excludesFile) && is_file($excludesFile) && is_readable($excludesFile)) {
 | 
				
			||||||
 | 
					            $excludesListFileRsync = ' --exclude-from=' . $excludesFile;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return $excludesListFileRsync;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace Mage\Task\BuiltIn\Deployment\Strategy;
 | 
					namespace Mage\Task\BuiltIn\Deployment\Strategy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use Mage\Console;
 | 
					 | 
				
			||||||
use Mage\Task\BuiltIn\Deployment\Strategy\BaseStrategyTaskAbstract;
 | 
					use Mage\Task\BuiltIn\Deployment\Strategy\BaseStrategyTaskAbstract;
 | 
				
			||||||
use Mage\Task\Releases\IsReleaseAware;
 | 
					use Mage\Task\Releases\IsReleaseAware;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -27,8 +26,8 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function getName()
 | 
					    public function getName()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if ($this->getConfig()->release('enabled', false) == true) {
 | 
					        if ($this->getConfig()->release('enabled', false) === true) {
 | 
				
			||||||
            if ($this->getConfig()->getParameter('overrideRelease', false) == true) {
 | 
					            if ($this->getConfig()->getParameter('overrideRelease', false) === true) {
 | 
				
			||||||
                return 'Deploy via TarGz (with Releases override) [built-in]';
 | 
					                return 'Deploy via TarGz (with Releases override) [built-in]';
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                return 'Deploy via TarGz (with Releases) [built-in]';
 | 
					                return 'Deploy via TarGz (with Releases) [built-in]';
 | 
				
			||||||
@ -47,10 +46,11 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware
 | 
				
			|||||||
        $this->checkOverrideRelease();
 | 
					        $this->checkOverrideRelease();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $excludes = $this->getExcludes();
 | 
					        $excludes = $this->getExcludes();
 | 
				
			||||||
 | 
					        $excludesListFilePath   = $this->getConfig()->deployment('excludes_file', '');;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // If we are working with releases
 | 
					        // If we are working with releases
 | 
				
			||||||
        $deployToDirectory = $this->getConfig()->deployment('to');
 | 
					        $deployToDirectory = $this->getConfig()->deployment('to');
 | 
				
			||||||
        if ($this->getConfig()->release('enabled', false) == true) {
 | 
					        if ($this->getConfig()->release('enabled', false) === true) {
 | 
				
			||||||
            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
					            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
				
			||||||
            $deployToDirectory = rtrim($this->getConfig()->deployment('to'), '/')
 | 
					            $deployToDirectory = rtrim($this->getConfig()->deployment('to'), '/')
 | 
				
			||||||
                . '/' . $releasesDirectory
 | 
					                . '/' . $releasesDirectory
 | 
				
			||||||
@ -67,6 +67,8 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware
 | 
				
			|||||||
            $excludeCmd .= ' --exclude=' . $excludeFile;
 | 
					            $excludeCmd .= ' --exclude=' . $excludeFile;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $excludeFromFileCmd = $this->excludesListFile($excludesListFilePath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Strategy Flags
 | 
					        // Strategy Flags
 | 
				
			||||||
        $strategyFlags = $this->getConfig()->deployment('strategy_flags', $this->getConfig()->general('strategy_flags', array()));
 | 
					        $strategyFlags = $this->getConfig()->deployment('strategy_flags', $this->getConfig()->general('strategy_flags', array()));
 | 
				
			||||||
        if (isset($strategyFlags['targz']) && isset($strategyFlags['targz']['create'])) {
 | 
					        if (isset($strategyFlags['targz']) && isset($strategyFlags['targz']['create'])) {
 | 
				
			||||||
@ -75,7 +77,7 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware
 | 
				
			|||||||
            $strategyFlags = '';
 | 
					            $strategyFlags = '';
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $command = 'tar cfzh' . $strategyFlags . ' ' . $localTarGz . '.tar.gz ' . $excludeCmd . ' -C ' . $this->getConfig()->deployment('from') . ' .';
 | 
					        $command = 'tar cfzh' . $strategyFlags . ' ' . $localTarGz . '.tar.gz ' . $excludeCmd . $excludeFromFileCmd . ' -C ' . $this->getConfig()->deployment('from') . ' .';
 | 
				
			||||||
        $result = $this->runCommandLocal($command);
 | 
					        $result = $this->runCommandLocal($command);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Strategy Flags
 | 
					        // Strategy Flags
 | 
				
			||||||
@ -113,4 +115,18 @@ class TarGzTask extends BaseStrategyTaskAbstract implements IsReleaseAware
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        return $result;
 | 
					        return $result;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Generates the Exclude from file for rsync
 | 
				
			||||||
 | 
					     * @param string $excludesFile
 | 
				
			||||||
 | 
					     * @return string
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected function excludesListFile($excludesFile)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $excludesListFileRsync = '';
 | 
				
			||||||
 | 
					        if(!empty($excludesFile) && file_exists($excludesFile) && is_file($excludesFile) && is_readable($excludesFile)) {
 | 
				
			||||||
 | 
					            $excludesListFileRsync = ' --exclude-from=' . $excludesFile;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return $excludesListFileRsync;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -8,6 +8,16 @@ use Mage\Task\SkipException;
 | 
				
			|||||||
class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware
 | 
					class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const LINKED_FOLDERS   = 'linked_folders';
 | 
				
			||||||
 | 
					    const LINKED_STRATEGY  = 'linking_strategy';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const ABSOLUTE_LINKING = 'absolute';
 | 
				
			||||||
 | 
					    const RELATIVE_LINKING = 'relative';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public $linkingStrategies = array(
 | 
				
			||||||
 | 
					        self::ABSOLUTE_LINKING,
 | 
				
			||||||
 | 
					        self::RELATIVE_LINKING
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Returns the Title of the Task
 | 
					     * Returns the Title of the Task
 | 
				
			||||||
     * @return string
 | 
					     * @return string
 | 
				
			||||||
@ -26,24 +36,37 @@ class LinkSharedFilesTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $linkedFiles    = $this->getParameter('linked_files', []);
 | 
					        $linkedFiles    = $this->getParameter('linked_files', []);
 | 
				
			||||||
        $linkedFolders = $this->getParameter('linked_folders', []);
 | 
					        $linkedFolders  = $this->getParameter(self::LINKED_FOLDERS, []);
 | 
				
			||||||
 | 
					        $linkingStrategy = $this->getParameter(self::LINKED_STRATEGY, self::ABSOLUTE_LINKING);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $linkedEntities = array_merge($linkedFiles,$linkedFolders);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (sizeof($linkedFiles) == 0 && sizeof($linkedFolders) == 0) {
 | 
					        if (sizeof($linkedFiles) == 0 && sizeof($linkedFolders) == 0) {
 | 
				
			||||||
            throw new SkipException('No files and folders configured for sym-linking.');
 | 
					            throw new SkipException('No files and folders configured for sym-linking.');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $sharedFolderName = $this->getParameter('shared', 'shared');
 | 
					        $sharedFolderName = $this->getParameter('shared', 'shared');
 | 
				
			||||||
        $sharedFolderName = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $sharedFolderName;
 | 
					        $sharedFolderPath = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $sharedFolderName;
 | 
				
			||||||
        $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
					        $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
				
			||||||
        $releasesDirectory = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory;
 | 
					        $releasesDirectoryPath = rtrim($this->getConfig()->deployment('to'), '/') . '/' . $releasesDirectory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $currentCopy = $releasesDirectory . '/' . $this->getConfig()->getReleaseId();
 | 
					        $currentCopy = $releasesDirectoryPath . '/' . $this->getConfig()->getReleaseId();
 | 
				
			||||||
        foreach ($linkedFolders as $folder) {
 | 
					        $relativeDiffPath = str_replace($this->getConfig()->deployment('to'),'',$currentCopy) . '/';
 | 
				
			||||||
            $command = "ln -nfs $sharedFolderName/$folder $currentCopy/$folder";
 | 
					
 | 
				
			||||||
            $this->runCommandRemote($command);
 | 
					        foreach ($linkedEntities as $ePath) {
 | 
				
			||||||
 | 
					            if(is_array($ePath) && in_array($strategy = reset($ePath), $this->linkingStrategies ) ) {
 | 
				
			||||||
 | 
					                $entityPath = key($ePath);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                $strategy = $linkingStrategy;
 | 
				
			||||||
 | 
					                $entityPath = $ePath;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            $sharedEntityLinkedPath = "$sharedFolderPath/$entityPath";
 | 
				
			||||||
        foreach ($linkedFiles as $folder) {
 | 
					            if($strategy==self::RELATIVE_LINKING) {
 | 
				
			||||||
            $command = "ln -nfs $sharedFolderName/$folder $currentCopy/$folder";
 | 
					                $parentFolderPath = dirname($entityPath);
 | 
				
			||||||
 | 
					                $relativePath = $parentFolderPath=='.'?$relativeDiffPath:$relativeDiffPath.$parentFolderPath.'/';
 | 
				
			||||||
 | 
					                $sharedEntityLinkedPath = ltrim(preg_replace('/(\w+\/)/', '../', $relativePath),'/').$sharedFolderName .'/'. $entityPath;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            $command = "ln -nfs $sharedEntityLinkedPath $currentCopy/$entityPath";
 | 
				
			||||||
            $this->runCommandRemote($command);
 | 
					            $this->runCommandRemote($command);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -34,11 +34,11 @@ class ListTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if ($this->getConfig()->release('enabled', false) == true) {
 | 
					        if ($this->getConfig()->release('enabled', false) === true) {
 | 
				
			||||||
            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
					            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
				
			||||||
            $symlink = $this->getConfig()->release('symlink', 'current');
 | 
					            $symlink = $this->getConfig()->release('symlink', 'current');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Console::output('Releases available on <dark_gray>' . $this->getConfig()->getHost() . '</dark_gray>');
 | 
					            Console::output('Releases available on <bold>' . $this->getConfig()->getHost() . '</bold>');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Get Releases
 | 
					            // Get Releases
 | 
				
			||||||
            $output = '';
 | 
					            $output = '';
 | 
				
			||||||
@ -51,7 +51,7 @@ class ListTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
            $currentRelease = trim(array_pop($currentRelease));
 | 
					            $currentRelease = trim(array_pop($currentRelease));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (count($releases) == 0) {
 | 
					            if (count($releases) == 0) {
 | 
				
			||||||
                Console::output('<dark_gray>No releases available</dark_gray> ... ', 2);
 | 
					                Console::output('<bold>No releases available</bold> ... ', 2);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                rsort($releases);
 | 
					                rsort($releases);
 | 
				
			||||||
                $releases = array_slice($releases, 0, 10);
 | 
					                $releases = array_slice($releases, 0, 10);
 | 
				
			||||||
@ -80,8 +80,8 @@ class ListTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                    Console::output(
 | 
					                    Console::output(
 | 
				
			||||||
                        'Release: <purple>' . $release . '</purple> '
 | 
					                        'Release: <purple>' . $release . '</purple> '
 | 
				
			||||||
                        . '- Date: <dark_gray>' . $releaseDate . '</dark_gray> '
 | 
					                        . '- Date: <bold>' . $releaseDate . '</bold> '
 | 
				
			||||||
                        . '- Index: <dark_gray>' . $releaseIndex . '</dark_gray>' . $dateDiff . $isCurrent, 2);
 | 
					                        . '- Index: <bold>' . $releaseIndex . '</bold>' . $dateDiff . $isCurrent, 2);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -146,5 +146,4 @@ class ListTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        return $textDiff;
 | 
					        return $textDiff;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -47,7 +47,7 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if ($this->getConfig()->release('enabled', false) == true) {
 | 
					        if ($this->getConfig()->release('enabled', false) === true) {
 | 
				
			||||||
            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
					            $releasesDirectory = $this->getConfig()->release('directory', 'releases');
 | 
				
			||||||
            $symlink = $this->getConfig()->release('symlink', 'current');
 | 
					            $symlink = $this->getConfig()->release('symlink', 'current');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -56,7 +56,7 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
            $releases = ($output == '') ? array() : explode(PHP_EOL, $output);
 | 
					            $releases = ($output == '') ? array() : explode(PHP_EOL, $output);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (count($releases) == 0) {
 | 
					            if (count($releases) == 0) {
 | 
				
			||||||
                Console::output('Release are not available for <dark_gray>' . $this->getConfig()->getHost() . '</dark_gray> ... <red>FAIL</red>');
 | 
					                Console::output('Release are not available for <bold>' . $this->getConfig()->getHost() . '</bold> ... <red>FAIL</red>');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                rsort($releases);
 | 
					                rsort($releases);
 | 
				
			||||||
@ -81,10 +81,10 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (!$releaseIsAvailable) {
 | 
					                if (!$releaseIsAvailable) {
 | 
				
			||||||
                    Console::output('Release <dark_gray>' . $this->getReleaseId() . '</dark_gray> is invalid or unavailable for <dark_gray>' . $this->getConfig()->getHost() . '</dark_gray> ... <red>FAIL</red>');
 | 
					                    Console::output('Release <bold>' . $this->getReleaseId() . '</bold> is invalid or unavailable for <bold>' . $this->getConfig()->getHost() . '</bold> ... <red>FAIL</red>');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    Console::output('Rollback release on <dark_gray>' . $this->getConfig()->getHost() . '</dark_gray>');
 | 
					                    Console::output('Rollback release on <bold>' . $this->getConfig()->getHost() . '</bold>');
 | 
				
			||||||
                    $rollbackTo = $releasesDirectory . '/' . $releaseId;
 | 
					                    $rollbackTo = $releasesDirectory . '/' . $releaseId;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    // Get Current Release
 | 
					                    // Get Current Release
 | 
				
			||||||
@ -111,7 +111,7 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
                            $tasks++;
 | 
					                            $tasks++;
 | 
				
			||||||
                            $result = $task->run();
 | 
					                            $result = $task->run();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            if ($result == true) {
 | 
					                            if ($result === true) {
 | 
				
			||||||
                                Console::output('<green>OK</green>', 0);
 | 
					                                Console::output('<green>OK</green>', 0);
 | 
				
			||||||
                                $completedTasks++;
 | 
					                                $completedTasks++;
 | 
				
			||||||
                            } else {
 | 
					                            } else {
 | 
				
			||||||
@ -161,7 +161,7 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
                            $tasks++;
 | 
					                            $tasks++;
 | 
				
			||||||
                            $result = $task->run();
 | 
					                            $result = $task->run();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            if ($result == true) {
 | 
					                            if ($result === true) {
 | 
				
			||||||
                                Console::output('<green>OK</green>', 0);
 | 
					                                Console::output('<green>OK</green>', 0);
 | 
				
			||||||
                                $completedTasks++;
 | 
					                                $completedTasks++;
 | 
				
			||||||
                            } else {
 | 
					                            } else {
 | 
				
			||||||
@ -178,7 +178,7 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
                        $tasksColor = 'red';
 | 
					                        $tasksColor = 'red';
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    Console::output('Release rollback on <dark_gray>' . $this->getConfig()->getHost() . '</dark_gray> compted: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . '</' . $tasksColor . '> tasks done.', 1, 3);
 | 
					                    Console::output('Release rollback on <bold>' . $this->getConfig()->getHost() . '</bold> compted: <' . $tasksColor . '>' . $completedTasks . '/' . $tasks . '</' . $tasksColor . '> tasks done.', 1, 3);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -188,5 +188,4 @@ class RollbackTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -53,6 +53,15 @@ class CloneTask extends AbstractTask
 | 
				
			|||||||
                $this->name = 'SCM Clone (GIT) [built-in]';
 | 
					                $this->name = 'SCM Clone (GIT) [built-in]';
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Create temporal directory for clone
 | 
				
			||||||
 | 
					        if (is_array($this->source)) {
 | 
				
			||||||
 | 
					            if (trim($this->source['temporal']) == '') {
 | 
				
			||||||
 | 
					                $this->source['temporal'] = sys_get_temp_dir();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            $this->source['temporal'] = rtrim($this->source['temporal'], '/') . '/' . md5(microtime()) . '/';
 | 
				
			||||||
 | 
					            $this->getConfig()->setSourceTemporal($this->source['temporal']);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										87
									
								
								Mage/Task/BuiltIn/Scm/ForceUpdateTask.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										87
									
								
								Mage/Task/BuiltIn/Scm/ForceUpdateTask.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,87 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * This file is part of the Magallanes package.
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					* (c) Andrés Montañez <andres@andresmontanez.com>
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					* For the full copyright and license information, please view the LICENSE
 | 
				
			||||||
 | 
					* file that was distributed with this source code.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Mage\Task\BuiltIn\Scm;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Mage\Task\AbstractTask;
 | 
				
			||||||
 | 
					use Mage\Task\SkipException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Task for Force Updating a Working Copy
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * 'git fetch' downloads the latest from remote without trying to merge or rebase anything.
 | 
				
			||||||
 | 
					 * 'git reset' resets the master branch to what you just fetched. 
 | 
				
			||||||
 | 
					 * The '--hard' option changes all the files in your working tree to match the files in origin/master,
 | 
				
			||||||
 | 
					 * so if you have any local changes, they will be lost.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Samuel Chiriluta <samuel4x4@gmail.com>
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					class ForceUpdateTask extends AbstractTask
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Name of the Task
 | 
				
			||||||
 | 
					     * @var string
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private $name = 'SCM Force Update [built-in]';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * (non-PHPdoc)
 | 
				
			||||||
 | 
					     * @see \Mage\Task\AbstractTask::getName()
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function getName()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return $this->name;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * (non-PHPdoc)
 | 
				
			||||||
 | 
					     * @see \Mage\Task\AbstractTask::init()
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function init()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        switch ($this->getConfig()->general('scm')) {
 | 
				
			||||||
 | 
					            case 'git':
 | 
				
			||||||
 | 
					                $this->name = 'SCM Force Update (GIT) [built-in]';
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Force Updates the Working Copy
 | 
				
			||||||
 | 
					     * @see \Mage\Task\AbstractTask::run()
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function run()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        switch ($this->getConfig()->general('scm')) {
 | 
				
			||||||
 | 
					            case 'git':
 | 
				
			||||||
 | 
					                $branch = $this->getParameter('branch', 'master');
 | 
				
			||||||
 | 
					                $remote = $this->getParameter('remote', 'origin');
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                $command = 'git fetch ' . $remote . ' ' . $branch;
 | 
				
			||||||
 | 
					                $result = $this->runCommandRemote($command);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                $command = 'git reset --hard ' . $remote . '/' . $branch;
 | 
				
			||||||
 | 
					                $result = $result && $this->runCommandRemote($command);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                $command = 'git pull ' . $remote . ' ' . $branch;
 | 
				
			||||||
 | 
					                $result = $result && $this->runCommandRemote($command);
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            default:
 | 
				
			||||||
 | 
					                throw new SkipException;
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $result = $this->runCommandLocal($command);
 | 
				
			||||||
 | 
					        $this->getConfig()->reload();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $result;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										40
									
								
								Mage/Task/BuiltIn/Symfony2/DoctrineMigrate.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								Mage/Task/BuiltIn/Symfony2/DoctrineMigrate.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					* This file is part of the Magallanes package.
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					* (c) Andrés Montañez <andres@andresmontanez.com>
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					* For the full copyright and license information, please view the LICENSE
 | 
				
			||||||
 | 
					* file that was distributed with this source code.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Mage\Task\BuiltIn\Symfony2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Mage\Task\BuiltIn\Symfony2\SymfonyAbstractTask;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Task for Doctrine migrations
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					class DoctrineMigrate extends SymfonyAbstractTask
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * (non-PHPdoc)
 | 
				
			||||||
 | 
					     * @see \Mage\Task\AbstractTask::getName()
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function getName()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return 'Symfony v2 - Migrate doctrine entities [built-in]';
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Migrates Doctrine entities
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @see \Mage\Task\AbstractTask::run()
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function run()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $env = $this->getParameter('env', 'dev');
 | 
				
			||||||
 | 
					        $command = $this->getAppPath() . ' doctrine:migrations:migrate -n --env=' . $env;
 | 
				
			||||||
 | 
					        return $this->runCommand($command);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -11,7 +11,6 @@
 | 
				
			|||||||
namespace Mage\Task;
 | 
					namespace Mage\Task;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use Mage\Config;
 | 
					use Mage\Config;
 | 
				
			||||||
use Mage\Autoload;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
use Exception;
 | 
					use Exception;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										23
									
								
								Mage/Task/RollbackException.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								Mage/Task/RollbackException.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * This file is part of the Magallanes package.
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					* (c) Alex V Kotelnikov <gudron@gudron.me>
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					* For the full copyright and license information, please view the LICENSE
 | 
				
			||||||
 | 
					* file that was distributed with this source code.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Mage\Task;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Exception;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Exception that indicates that the Task was Failed and rollback needed
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @author Alex V Kotelnikov <gudron@gudron.me>
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					class RollbackException extends Exception
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -655,5 +655,4 @@ class Parser
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        return (0 === strpos($this->currentLine, '- '));
 | 
					        return (0 === strpos($this->currentLine, '- '));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
							
								
								
									
										4
									
								
								bin/mage
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								bin/mage
									
									
									
									
									
								
							@ -13,7 +13,7 @@ date_default_timezone_set('UTC');
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
$baseDir = dirname(dirname(__FILE__));
 | 
					$baseDir = dirname(dirname(__FILE__));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
define('MAGALLANES_VERSION', '1.0.2');
 | 
					define('MAGALLANES_VERSION', '1.0.3');
 | 
				
			||||||
define('MAGALLANES_DIRECTORY', $baseDir);
 | 
					define('MAGALLANES_DIRECTORY', $baseDir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
 | 
					if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
 | 
				
			||||||
@ -32,4 +32,4 @@ array_shift($argv);
 | 
				
			|||||||
$console = new Mage\Console;
 | 
					$console = new Mage\Console;
 | 
				
			||||||
$exitCode = $console->run($argv);
 | 
					$exitCode = $console->run($argv);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exit($exitCode);
 | 
					exit((integer) $exitCode);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										16
									
								
								box.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								box.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,16 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "files": ["LICENSE"],
 | 
				
			||||||
 | 
					    "finder": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "name": "*.php",
 | 
				
			||||||
 | 
					            "exclude": [
 | 
				
			||||||
 | 
					                "docs"
 | 
				
			||||||
 | 
					            ],
 | 
				
			||||||
 | 
					            "in": "Mage"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    "git-version": "git_tag",
 | 
				
			||||||
 | 
					    "main": "bin/mage",
 | 
				
			||||||
 | 
					    "output": "mage.phar",
 | 
				
			||||||
 | 
					    "stub": true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -29,7 +29,6 @@ ioncube:
 | 
				
			|||||||
  checkignorepaths:
 | 
					  checkignorepaths:
 | 
				
			||||||
    - /public/js/*
 | 
					    - /public/js/*
 | 
				
			||||||
    - /public/css/*
 | 
					    - /public/css/*
 | 
				
			||||||
 | 
					 | 
				
			||||||
  projfile: project.prj
 | 
					  projfile: project.prj
 | 
				
			||||||
  project:
 | 
					  project:
 | 
				
			||||||
    replace-target:
 | 
					    replace-target:
 | 
				
			||||||
@ -57,7 +56,6 @@ ioncube:
 | 
				
			|||||||
      - 'Comment 2'
 | 
					      - 'Comment 2'
 | 
				
			||||||
      - "(c) ACTweb 2013"
 | 
					      - "(c) ACTweb 2013"
 | 
				
			||||||
      - "Draft Version"
 | 
					      - "Draft Version"
 | 
				
			||||||
 | 
					 | 
				
			||||||
    loader-event:
 | 
					    loader-event:
 | 
				
			||||||
      - corrupt-file=Corupted files
 | 
					      - corrupt-file=Corupted files
 | 
				
			||||||
      - expired-file=System needs updated
 | 
					      - expired-file=System needs updated
 | 
				
			||||||
@ -2,11 +2,6 @@
 | 
				
			|||||||
deployment:
 | 
					deployment:
 | 
				
			||||||
  user: root
 | 
					  user: root
 | 
				
			||||||
  from: ./
 | 
					  from: ./
 | 
				
			||||||
#  source:
 | 
					 | 
				
			||||||
#    type: git
 | 
					 | 
				
			||||||
#    repository: git://github.com/andres-montanez/Magallanes.git
 | 
					 | 
				
			||||||
#    from: master
 | 
					 | 
				
			||||||
#    temporal: /tmp/myAppClone
 | 
					 | 
				
			||||||
  to: /var/www/vhosts/example.com/www
 | 
					  to: /var/www/vhosts/example.com/www
 | 
				
			||||||
  excludes:
 | 
					  excludes:
 | 
				
			||||||
    - application/data/cache/twig/*
 | 
					    - application/data/cache/twig/*
 | 
				
			||||||
@ -16,25 +11,13 @@ releases:
 | 
				
			|||||||
  symlink: current
 | 
					  symlink: current
 | 
				
			||||||
  directory: releases
 | 
					  directory: releases
 | 
				
			||||||
hosts:
 | 
					hosts:
 | 
				
			||||||
  s01.example.com:22:
 | 
					  - s01.example.com
 | 
				
			||||||
    deployment:
 | 
					  - s02.example.com
 | 
				
			||||||
      user: nobody
 | 
					 | 
				
			||||||
  s02.example.com:
 | 
					 | 
				
			||||||
    deployment:
 | 
					 | 
				
			||||||
      user: toor
 | 
					 | 
				
			||||||
      to: /home/web/public
 | 
					 | 
				
			||||||
    releases:
 | 
					 | 
				
			||||||
      max: 10
 | 
					 | 
				
			||||||
    tasks:
 | 
					 | 
				
			||||||
      on-deploy:
 | 
					 | 
				
			||||||
        - privileges
 | 
					 | 
				
			||||||
  - s03.example.com
 | 
					 | 
				
			||||||
tasks:
 | 
					tasks:
 | 
				
			||||||
  pre-deploy:
 | 
					  pre-deploy:
 | 
				
			||||||
    - scm/update
 | 
					    - scm/update
 | 
				
			||||||
  on-deploy:
 | 
					  on-deploy:
 | 
				
			||||||
#    - symfony2/cache-warmup: {env: prod}
 | 
					    - symfony2/cache-warmup: { env: prod }
 | 
				
			||||||
    - privileges
 | 
					    - privileges
 | 
				
			||||||
    - sampleTask
 | 
					    - sampleTask
 | 
				
			||||||
    - sampleTaskRollbackAware
 | 
					    - sampleTaskRollbackAware
 | 
				
			||||||
  #post-deploy:
 | 
					 | 
				
			||||||
@ -0,0 +1,38 @@
 | 
				
			|||||||
 | 
					#production
 | 
				
			||||||
 | 
					deployment:
 | 
				
			||||||
 | 
					  user: root
 | 
				
			||||||
 | 
					  from: ./
 | 
				
			||||||
 | 
					#  source:
 | 
				
			||||||
 | 
					#    type: git
 | 
				
			||||||
 | 
					#    repository: git://github.com/andres-montanez/Magallanes.git
 | 
				
			||||||
 | 
					#    from: master
 | 
				
			||||||
 | 
					#    temporal: /tmp/myAppClone
 | 
				
			||||||
 | 
					  to: /var/www/vhosts/example.com/www
 | 
				
			||||||
 | 
					  excludes:
 | 
				
			||||||
 | 
					    - application/data/cache/twig/*
 | 
				
			||||||
 | 
					releases:
 | 
				
			||||||
 | 
					  enabled: true
 | 
				
			||||||
 | 
					  max: 5
 | 
				
			||||||
 | 
					  symlink: current
 | 
				
			||||||
 | 
					  directory: releases
 | 
				
			||||||
 | 
					hosts:
 | 
				
			||||||
 | 
					  - s01.example.com
 | 
				
			||||||
 | 
					  - s02.example.com
 | 
				
			||||||
 | 
					#  s02.example.com:
 | 
				
			||||||
 | 
					#    deployment:
 | 
				
			||||||
 | 
					#      user: toor
 | 
				
			||||||
 | 
					#      to: /home/web/public
 | 
				
			||||||
 | 
					#    releases:
 | 
				
			||||||
 | 
					#      max: 10
 | 
				
			||||||
 | 
					#    tasks:
 | 
				
			||||||
 | 
					#      on-deploy:
 | 
				
			||||||
 | 
					#        - privileges
 | 
				
			||||||
 | 
					tasks:
 | 
				
			||||||
 | 
					  pre-deploy:
 | 
				
			||||||
 | 
					    - scm/update
 | 
				
			||||||
 | 
					  on-deploy:
 | 
				
			||||||
 | 
					    - symfony2/cache-warmup: { env: prod }
 | 
				
			||||||
 | 
					    - privileges
 | 
				
			||||||
 | 
					    - sampleTask
 | 
				
			||||||
 | 
					    - sampleTaskRollbackAware
 | 
				
			||||||
 | 
					  #post-deploy:
 | 
				
			||||||
@ -20,3 +20,4 @@ class SampleTaskRollbackAware extends AbstractTask implements RollbackAware
 | 
				
			|||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -18,8 +18,10 @@ class TaskWithParameters extends AbstractTask
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        //throw new Mage_Task_SkipException;
 | 
					        if ($this->getParameter('booleanOption', false)) {
 | 
				
			||||||
        //return false;
 | 
					 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user