mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	Fixes #121
This commit is contained in:
		
							parent
							
								
									40e8c33846
								
							
						
					
					
						commit
						c34fa53af5
					
				@ -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);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -133,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);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -162,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
 | 
				
			||||||
@ -171,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
 | 
				
			||||||
@ -181,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);
 | 
				
			||||||
@ -251,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;
 | 
				
			||||||
@ -276,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);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -292,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();
 | 
				
			||||||
@ -313,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();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -322,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) {
 | 
				
			||||||
@ -343,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
 | 
				
			||||||
@ -360,7 +360,7 @@ 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) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -384,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) {
 | 
				
			||||||
@ -405,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);
 | 
				
			||||||
@ -420,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
 | 
				
			||||||
@ -435,7 +435,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
        $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;
 | 
				
			||||||
 | 
				
			|||||||
@ -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');
 | 
				
			||||||
 | 
				
			|||||||
@ -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;
 | 
				
			||||||
 | 
				
			|||||||
@ -36,7 +36,7 @@ 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
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -47,7 +47,7 @@ class RollbackCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
        $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;
 | 
				
			||||||
 | 
				
			|||||||
@ -39,7 +39,7 @@ class UpgradeCommand extends AbstractCommand
 | 
				
			|||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $exitCode = 99;
 | 
					        $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,7 +26,7 @@ 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;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -115,7 +115,7 @@ 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);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -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',
 | 
				
			||||||
 | 
				
			|||||||
@ -38,7 +38,7 @@ class ListTask extends AbstractTask implements IsReleaseAware
 | 
				
			|||||||
            $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);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -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
 | 
				
			||||||
@ -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);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user