mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 00:50:18 +01:00 
			
		
		
		
	Tweaks on configs.
Added Init command.
This commit is contained in:
		
							parent
							
								
									6d5e7ef22f
								
							
						
					
					
						commit
						d138de317a
					
				@ -6,14 +6,16 @@ class Mage_Config
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    public function loadEnvironment($environment)
 | 
					    public function loadEnvironment($environment)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if ($environment != '') {
 | 
					        if (($environment != '') && file_exists('.mage/config/environment/' . $environment . '.yaml')) {
 | 
				
			||||||
            $this->_environment = yaml_parse_file('.mage/config/environment/' . $environment . '.yaml');            
 | 
					            $this->_environment = @yaml_parse_file('.mage/config/environment/' . $environment . '.yaml');            
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    public function loadSCM()
 | 
					    public function loadSCM()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->_scm = yaml_parse_file('.mage/config/scm.yaml');
 | 
					        if (file_exists('.mage/config/scm.yaml')) {
 | 
				
			||||||
 | 
					            $this->_scm = @yaml_parse_file('.mage/config/scm.yaml');            
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    public function getEnvironment()
 | 
					    public function getEnvironment()
 | 
				
			||||||
 | 
				
			|||||||
@ -22,6 +22,9 @@ class Mage_Console
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            } else if ($this->_args[0] == 'add') {
 | 
					            } else if ($this->_args[0] == 'add') {
 | 
				
			||||||
                $this->_action = 'add';
 | 
					                $this->_action = 'add';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            } else if ($this->_args[0] == 'init') {
 | 
				
			||||||
 | 
					                $this->_action = 'init';
 | 
				
			||||||
            } 
 | 
					            } 
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        foreach ($this->_args as $argument) {
 | 
					        foreach ($this->_args as $argument) {
 | 
				
			||||||
@ -76,6 +79,11 @@ class Mage_Console
 | 
				
			|||||||
                $task->run($config);
 | 
					                $task->run($config);
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
                
 | 
					                
 | 
				
			||||||
 | 
					            case 'init';
 | 
				
			||||||
 | 
					                $task = new Mage_Task_Init;
 | 
				
			||||||
 | 
					                $task->run();
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
            case 'add';
 | 
					            case 'add';
 | 
				
			||||||
                switch ($this->_args[1]) {
 | 
					                switch ($this->_args[1]) {
 | 
				
			||||||
                    case 'environment':
 | 
					                    case 'environment':
 | 
				
			||||||
 | 
				
			|||||||
@ -10,7 +10,7 @@ class Mage_Task_Add
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        // Check if there is already an environment with the same name
 | 
					        // Check if there is already an environment with the same name
 | 
				
			||||||
        if (file_exists($environmentConfigFile)) {
 | 
					        if (file_exists($environmentConfigFile)) {
 | 
				
			||||||
            Mage_Console::output('<light_red>Error!!</light_red> Already exists an environment called <dark_gray>' . $environmentName . '</dark_gray>');
 | 
					            Mage_Console::output('<light_red>Error!!</light_red> Already exists an environment called <dark_gray>' . $environmentName . '</dark_gray>', 1, 2);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $baseConfig = '#' . $environmentName . PHP_EOL
 | 
					            $baseConfig = '#' . $environmentName . PHP_EOL
 | 
				
			||||||
                        . 'user: dummy' . PHP_EOL
 | 
					                        . 'user: dummy' . PHP_EOL
 | 
				
			||||||
@ -25,13 +25,10 @@ class Mage_Task_Add
 | 
				
			|||||||
            
 | 
					            
 | 
				
			||||||
            if ($result) {
 | 
					            if ($result) {
 | 
				
			||||||
                Mage_Console::output('<light_green>Success!!</light_green> Environment config file for <dark_gray>' . $environmentName . '</dark_gray> created successfully at <blue>' . $environmentConfigFile . '</blue>');
 | 
					                Mage_Console::output('<light_green>Success!!</light_green> Environment config file for <dark_gray>' . $environmentName . '</dark_gray> created successfully at <blue>' . $environmentConfigFile . '</blue>');
 | 
				
			||||||
                Mage_Console::output('<dark_gray>So please! Review and adjust its configuration.</dark_gray>', 2);
 | 
					                Mage_Console::output('<dark_gray>So please! Review and adjust its configuration.</dark_gray>', 2, 2);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                Mage_Console::output('<light_red>Error!!</light_red> Unable to create config file for environment called <dark_gray>' . $environmentName . '</dark_gray>');
 | 
					                Mage_Console::output('<light_red>Error!!</light_red> Unable to create config file for environment called <dark_gray>' . $environmentName . '</dark_gray>', 1, 2);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        Mage_Console::output('');
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
							
								
								
									
										31
									
								
								Mage/Task/Init.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								Mage/Task/Init.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					class Mage_Task_Init
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public function run()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $configDir = '.mage';
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        Mage_Console::output('Initiating managing process for application with <dark_gray>Magallanes</dark_gray>');
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        // Check if there is already a config dir
 | 
				
			||||||
 | 
					        if (file_exists($configDir)) {
 | 
				
			||||||
 | 
					            Mage_Console::output('<light_red>Error!!</light_red> Already exists <dark_gray>.mage</dark_gray> directory.', 1, 2);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $results = array();
 | 
				
			||||||
 | 
					            $results[] = mkdir($configDir);
 | 
				
			||||||
 | 
					            $results[] = mkdir($configDir . '/logs');
 | 
				
			||||||
 | 
					            $results[] = mkdir($configDir . '/tasks');
 | 
				
			||||||
 | 
					            $results[] = mkdir($configDir . '/config');
 | 
				
			||||||
 | 
					            $results[] = mkdir($configDir . '/config/environment');
 | 
				
			||||||
 | 
					            $results[] = file_put_contents($configDir . '/config/global.yaml', '#global settings' . PHP_EOL . PHP_EOL);
 | 
				
			||||||
 | 
					            $results[] = file_put_contents($configDir . '/config/scm.yaml', '#scm settings' . PHP_EOL . PHP_EOL);
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            if (!in_array(false, $results)) {
 | 
				
			||||||
 | 
					                Mage_Console::output('<light_green>Success!!</light_green> The configuration for <dark_gray>Magallanes</dark_gray> has been generated at <blue>.mage</blue> directory.');
 | 
				
			||||||
 | 
					                Mage_Console::output('<dark_gray>Please!! Review and adjust the configuration.</dark_gray>', 2, 2);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                Mage_Console::output('<light_red>Error!!</light_red> Unable to generate the configuration.', 1, 2);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										10
									
								
								bin/mage.php
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								bin/mage.php
									
									
									
									
									
								
							@ -1,14 +1,13 @@
 | 
				
			|||||||
<?php
 | 
					<?php
 | 
				
			||||||
# sudo mage install
 | 
					# sudo mage install
 | 
				
			||||||
# mage init
 | 
					# mage config add host s05.example.com to:[production]
 | 
				
			||||||
 | 
					 | 
				
			||||||
# mage config add environment [production]
 | 
					 | 
				
			||||||
# mage config add host prod_example@s05.example.com:/var/www/vhosts/example.com/www to:[production]
 | 
					 | 
				
			||||||
# mage config git git://github.com/andres-montanez/Zend-Framework-Twig-example-app.git
 | 
					# mage config git git://github.com/andres-montanez/Zend-Framework-Twig-example-app.git
 | 
				
			||||||
# mage config svn svn://example.com/repo
 | 
					# mage config svn svn://example.com/repo
 | 
				
			||||||
 | 
					# mage task:deployment/rsync to:production
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# mage init
 | 
				
			||||||
 | 
					# mage add environment production
 | 
				
			||||||
# mage deploy to:production
 | 
					# mage deploy to:production
 | 
				
			||||||
# mage task:deployment/rsync to:production 
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$baseDir = dirname(dirname(__FILE__));
 | 
					$baseDir = dirname(dirname(__FILE__));
 | 
				
			||||||
@ -24,5 +23,4 @@ $console->parse();
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
$console->run();
 | 
					$console->run();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
Mage_Console::output('Finished <blue>Magallanes</blue>', 0, 2);
 | 
					Mage_Console::output('Finished <blue>Magallanes</blue>', 0, 2);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user