mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 09:00:18 +01:00 
			
		
		
		
	Make file locations work better from global install.
This commit is contained in:
		
							parent
							
								
									ec29aa37b8
								
							
						
					
					
						commit
						c7e1175e11
					
				@ -46,7 +46,7 @@ class Autoload
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public static function loadUserTask($taskName)
 | 
					    public static function loadUserTask($taskName)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $classFile = '.mage/tasks/' . ucfirst($taskName) . '.php';
 | 
					        $classFile = getcwd() . '/.mage/tasks/' . ucfirst($taskName) . '.php';
 | 
				
			||||||
        require_once $classFile;
 | 
					        require_once $classFile;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -62,7 +62,7 @@ class AddCommand extends AbstractCommand
 | 
				
			|||||||
            throw new Exception('You must specify a name for the environment.');
 | 
					            throw new Exception('You must specify a name for the environment.');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $environmentConfigFile = '.mage/config/environment/' . $environmentName . '.yml';
 | 
					        $environmentConfigFile = getcwd() . '/.mage/config/environment/' . $environmentName . '.yml';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (file_exists($environmentConfigFile)) {
 | 
					        if (file_exists($environmentConfigFile)) {
 | 
				
			||||||
            throw new Exception('The environment already exists.');
 | 
					            throw new Exception('The environment already exists.');
 | 
				
			||||||
 | 
				
			|||||||
@ -101,7 +101,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // Check if Environment is not Locked
 | 
					        // Check if Environment is not Locked
 | 
				
			||||||
    	$lockFile = '.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);
 | 
				
			||||||
@ -109,11 +109,11 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
    	}
 | 
					    	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    	// Check for running instance and Lock
 | 
					    	// Check for running instance and Lock
 | 
				
			||||||
    	if (file_exists('.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;
 | 
					    		return;
 | 
				
			||||||
    	} else {
 | 
					    	} else {
 | 
				
			||||||
    		touch('.mage/~working.lock');
 | 
					    		touch(getcwd() . '/.mage/~working.lock');
 | 
				
			||||||
    	}
 | 
					    	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Release ID
 | 
					        // Release ID
 | 
				
			||||||
@ -182,8 +182,8 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
        $this->sendNotification(self::$failedTasks > 0 ? false : true);
 | 
					        $this->sendNotification(self::$failedTasks > 0 ? false : true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Unlock
 | 
					        // Unlock
 | 
				
			||||||
        if (file_exists('.mage/~working.lock')) {
 | 
					        if (file_exists(getcwd() . '/.mage/~working.lock')) {
 | 
				
			||||||
        	unlink('.mage/~working.lock');
 | 
					        	unlink(getcwd() . '/.mage/~working.lock');
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -27,7 +27,7 @@ class InitCommand extends AbstractCommand
 | 
				
			|||||||
	 */
 | 
						 */
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $configDir = '.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 <dark_gray>Magallanes</dark_gray>');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -54,7 +54,7 @@ class ListCommand extends AbstractCommand
 | 
				
			|||||||
    protected function listEnvironments()
 | 
					    protected function listEnvironments()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    	$environments = array();
 | 
					    	$environments = array();
 | 
				
			||||||
        $content = scandir('.mage/config/environment/');
 | 
					        $content = scandir(getcwd() . '/.mage/config/environment/');
 | 
				
			||||||
        foreach ($content as $file) {
 | 
					        foreach ($content as $file) {
 | 
				
			||||||
            if (strpos($file, '.yml') !== false) {
 | 
					            if (strpos($file, '.yml') !== false) {
 | 
				
			||||||
            	$environments[] = str_replace('.yml', '', $file);
 | 
					            	$environments[] = str_replace('.yml', '', $file);
 | 
				
			||||||
 | 
				
			|||||||
@ -39,7 +39,7 @@ class LockCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
        if ($email) $lockmsg .= '(' . $email . ')';
 | 
					        if ($email) $lockmsg .= '(' . $email . ')';
 | 
				
			||||||
        if ($reason) $lockmsg .= PHP_EOL . $reason . PHP_EOL;
 | 
					        if ($reason) $lockmsg .= PHP_EOL . $reason . PHP_EOL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock';
 | 
					        $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock';
 | 
				
			||||||
        file_put_contents($lockFile, 'Locked environment at date: ' . date('Y-m-d H:i:s') . $lockmsg);
 | 
					        file_put_contents($lockFile, 'Locked environment at date: ' . date('Y-m-d H:i:s') . $lockmsg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Console::output('Locked deployment to <light_purple>' . $this->getConfig()->getEnvironment() . '</light_purple> environment', 1, 2);
 | 
					        Console::output('Locked deployment to <light_purple>' . $this->getConfig()->getEnvironment() . '</light_purple> environment', 1, 2);
 | 
				
			||||||
 | 
				
			|||||||
@ -34,7 +34,7 @@ class ReleasesCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $subcommand = $this->getConfig()->getArgument(1);
 | 
					        $subcommand = $this->getConfig()->getArgument(1);
 | 
				
			||||||
        $lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock';
 | 
					        $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock';
 | 
				
			||||||
        if (file_exists($lockFile) && ($subcommand == 'rollback')) {
 | 
					        if (file_exists($lockFile) && ($subcommand == 'rollback')) {
 | 
				
			||||||
            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);
 | 
				
			||||||
 | 
				
			|||||||
@ -34,7 +34,7 @@ class RollbackCommand extends AbstractCommand implements RequiresEnvironment
 | 
				
			|||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock';
 | 
					        $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock';
 | 
				
			||||||
        if (file_exists($lockFile) && ($subcommand == 'rollback')) {
 | 
					        if (file_exists($lockFile) && ($subcommand == 'rollback')) {
 | 
				
			||||||
            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);
 | 
				
			||||||
 | 
				
			|||||||
@ -28,7 +28,7 @@ class UnlockCommand
 | 
				
			|||||||
	 */
 | 
						 */
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock';
 | 
					        $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock';
 | 
				
			||||||
        if (file_exists($lockFile)) {
 | 
					        if (file_exists($lockFile)) {
 | 
				
			||||||
            @unlink($lockFile);
 | 
					            @unlink($lockFile);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -99,8 +99,8 @@ class Config
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected function loadGeneral()
 | 
					    protected function loadGeneral()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    	if (file_exists('.mage/config/general.yml')) {
 | 
					    	if (file_exists(getcwd() . '/.mage/config/general.yml')) {
 | 
				
			||||||
    		$this->config['general'] = Yaml::parse(file_get_contents('.mage/config/general.yml'));
 | 
					    		$this->config['general'] = Yaml::parse(file_get_contents(getcwd() . '/.mage/config/general.yml'));
 | 
				
			||||||
    	}
 | 
					    	}
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -113,8 +113,8 @@ class Config
 | 
				
			|||||||
    protected function loadEnvironment()
 | 
					    protected function loadEnvironment()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    	$environment = $this->getEnvironment();
 | 
					    	$environment = $this->getEnvironment();
 | 
				
			||||||
    	if (($environment != false) && file_exists('.mage/config/environment/' . $environment . '.yml')) {
 | 
					    	if (($environment != false) && file_exists(getcwd() . '/.mage/config/environment/' . $environment . '.yml')) {
 | 
				
			||||||
    		$this->config['environment'] = Yaml::parse(file_get_contents('.mage/config/environment/' . $environment . '.yml'));
 | 
					    		$this->config['environment'] = Yaml::parse(file_get_contents(getcwd() . '/.mage/config/environment/' . $environment . '.yml'));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    		// Create temporal directory for clone
 | 
					    		// Create temporal directory for clone
 | 
				
			||||||
    		if (isset($this->config['environment']['deployment']['source']) && is_array($this->config['environment']['deployment']['source'])) {
 | 
					    		if (isset($this->config['environment']['deployment']['source']) && is_array($this->config['environment']['deployment']['source'])) {
 | 
				
			||||||
@ -127,7 +127,7 @@ class Config
 | 
				
			|||||||
    		}
 | 
					    		}
 | 
				
			||||||
    		return true;
 | 
					    		return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    	} else if (($environment != '') && !file_exists('.mage/config/environment/' . $environment . '.yml')) {
 | 
					    	} else if (($environment != '') && !file_exists(getcwd() . '/.mage/config/environment/' . $environment . '.yml')) {
 | 
				
			||||||
    		throw new Exception('Environment does not exists.');
 | 
					    		throw new Exception('Environment does not exists.');
 | 
				
			||||||
    	}
 | 
					    	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -72,8 +72,8 @@ class Console
 | 
				
			|||||||
    	register_shutdown_function(function() {
 | 
					    	register_shutdown_function(function() {
 | 
				
			||||||
    		// Only Unlock if there was an error
 | 
					    		// Only Unlock if there was an error
 | 
				
			||||||
            if (error_get_last() !== null) {
 | 
					            if (error_get_last() !== null) {
 | 
				
			||||||
            	if (file_exists('.mage/~working.lock')) {
 | 
					            	if (file_exists(getcwd() . '/.mage/~working.lock')) {
 | 
				
			||||||
            		unlink('.mage/~working.lock');
 | 
					            		unlink(getcwd() . '/.mage/~working.lock');
 | 
				
			||||||
            	}
 | 
					            	}
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
    	});
 | 
					    	});
 | 
				
			||||||
@ -130,8 +130,8 @@ class Console
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if ($showGrettings) {
 | 
					        if ($showGrettings) {
 | 
				
			||||||
            self::output('Finished <blue>Magallanes</blue>', 0, 2);
 | 
					            self::output('Finished <blue>Magallanes</blue>', 0, 2);
 | 
				
			||||||
            if (file_exists('.mage/~working.lock')) {
 | 
					            if (file_exists(getcwd() . '/.mage/~working.lock')) {
 | 
				
			||||||
            	unlink('.mage/~working.lock');
 | 
					            	unlink(getcwd() . '/.mage/~working.lock');
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -200,7 +200,7 @@ class Console
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        if (self::$logEnabled) {
 | 
					        if (self::$logEnabled) {
 | 
				
			||||||
            if (self::$log == null) {
 | 
					            if (self::$log == null) {
 | 
				
			||||||
            	self::$logFile = realpath('.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');
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -249,7 +249,7 @@ class Console
 | 
				
			|||||||
        	$maxLogs = $config->general('maxlogs', 30);
 | 
					        	$maxLogs = $config->general('maxlogs', 30);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        	$logs = array();
 | 
					        	$logs = array();
 | 
				
			||||||
        	foreach (new RecursiveDirectoryIterator('.mage/logs', RecursiveDirectoryIterator::SKIP_DOTS) as $log) {
 | 
					        	foreach (new RecursiveDirectoryIterator(getcwd() . '/.mage/logs', RecursiveDirectoryIterator::SKIP_DOTS) as $log) {
 | 
				
			||||||
        		if (strpos($log->getFilename(), 'log-') === 0) {
 | 
					        		if (strpos($log->getFilename(), 'log-') === 0) {
 | 
				
			||||||
        			$logs[] = $log->getFilename();
 | 
					        			$logs[] = $log->getFilename();
 | 
				
			||||||
        		}
 | 
					        		}
 | 
				
			||||||
@ -259,7 +259,7 @@ class Console
 | 
				
			|||||||
        	if (count($logs) > $maxLogs) {
 | 
					        	if (count($logs) > $maxLogs) {
 | 
				
			||||||
                $logsToDelete = array_slice($logs, 0, count($logs) - $maxLogs);
 | 
					                $logsToDelete = array_slice($logs, 0, count($logs) - $maxLogs);
 | 
				
			||||||
                foreach ($logsToDelete as $logToDeelte) {
 | 
					                foreach ($logsToDelete as $logToDeelte) {
 | 
				
			||||||
                	unlink('.mage/logs/' . $logToDeelte);
 | 
					                	unlink(getcwd() . '/.mage/logs/' . $logToDeelte);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
        	}
 | 
					        	}
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -50,7 +50,7 @@ abstract class BaseStrategyTaskAbstract extends AbstractTask implements IsReleas
 | 
				
			|||||||
        $excludes = array(
 | 
					        $excludes = array(
 | 
				
			||||||
            '.git',
 | 
					            '.git',
 | 
				
			||||||
            '.svn',
 | 
					            '.svn',
 | 
				
			||||||
            '.mage',
 | 
					            getcwd() . '/.mage',
 | 
				
			||||||
            '.gitignore',
 | 
					            '.gitignore',
 | 
				
			||||||
            '.gitkeep',
 | 
					            '.gitkeep',
 | 
				
			||||||
            'nohup.out'
 | 
					            'nohup.out'
 | 
				
			||||||
 | 
				
			|||||||
@ -755,7 +755,7 @@ class EncryptTask extends AbstractTask
 | 
				
			|||||||
		$p ['ignore'] = array (
 | 
							$p ['ignore'] = array (
 | 
				
			||||||
			'.git',
 | 
								'.git',
 | 
				
			||||||
			'.svn',
 | 
								'.svn',
 | 
				
			||||||
			'.mage',
 | 
								getcwd() . '/.mage',
 | 
				
			||||||
			'.gitignore',
 | 
								'.gitignore',
 | 
				
			||||||
			'.gitkeep',
 | 
								'.gitkeep',
 | 
				
			||||||
			'nohup.out'
 | 
								'nohup.out'
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user