From c7e1175e114e2b1b0ac3bef6d02e483623c43aff Mon Sep 17 00:00:00 2001 From: woutersioen Date: Wed, 16 Jul 2014 15:52:23 +0200 Subject: [PATCH 1/3] Make file locations work better from global install. --- Mage/Autoload.php | 4 ++-- Mage/Command/BuiltIn/AddCommand.php | 4 ++-- Mage/Command/BuiltIn/DeployCommand.php | 14 +++++++------- Mage/Command/BuiltIn/InitCommand.php | 2 +- Mage/Command/BuiltIn/ListCommand.php | 4 ++-- Mage/Command/BuiltIn/LockCommand.php | 2 +- Mage/Command/BuiltIn/ReleasesCommand.php | 2 +- Mage/Command/BuiltIn/RollbackCommand.php | 2 +- Mage/Command/BuiltIn/UnlockCommand.php | 4 ++-- Mage/Config.php | 12 ++++++------ Mage/Console.php | 14 +++++++------- .../Strategy/BaseStrategyTaskAbstract.php | 2 +- Mage/Task/BuiltIn/Ioncube/EncryptTask.php | 2 +- 13 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Mage/Autoload.php b/Mage/Autoload.php index 78db658..a9bcc2f 100644 --- a/Mage/Autoload.php +++ b/Mage/Autoload.php @@ -46,8 +46,8 @@ class Autoload */ public static function loadUserTask($taskName) { - $classFile = '.mage/tasks/' . ucfirst($taskName) . '.php'; + $classFile = getcwd() . '/.mage/tasks/' . ucfirst($taskName) . '.php'; require_once $classFile; } -} \ No newline at end of file +} diff --git a/Mage/Command/BuiltIn/AddCommand.php b/Mage/Command/BuiltIn/AddCommand.php index cf52483..fd9806e 100644 --- a/Mage/Command/BuiltIn/AddCommand.php +++ b/Mage/Command/BuiltIn/AddCommand.php @@ -62,7 +62,7 @@ class AddCommand extends AbstractCommand 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)) { throw new Exception('The environment already exists.'); @@ -99,4 +99,4 @@ class AddCommand extends AbstractCommand Console::output('Error!! Unable to create config file for environment called ' . $environmentName . '', 1, 2); } } -} \ No newline at end of file +} diff --git a/Mage/Command/BuiltIn/DeployCommand.php b/Mage/Command/BuiltIn/DeployCommand.php index 0d2cb3d..ab7b427 100644 --- a/Mage/Command/BuiltIn/DeployCommand.php +++ b/Mage/Command/BuiltIn/DeployCommand.php @@ -101,7 +101,7 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment public function run() { // Check if Environment is not Locked - $lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock'; + $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock'; if (file_exists($lockFile)) { Console::output('This environment is locked!', 1, 2); echo file_get_contents($lockFile); @@ -109,11 +109,11 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment } // Check for running instance and Lock - if (file_exists('.mage/~working.lock')) { + if (file_exists(getcwd() . '/.mage/~working.lock')) { Console::output('There is already an instance of Magallanes running!', 1, 2); return; } else { - touch('.mage/~working.lock'); + touch(getcwd() . '/.mage/~working.lock'); } // Release ID @@ -182,8 +182,8 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment $this->sendNotification(self::$failedTasks > 0 ? false : true); // Unlock - if (file_exists('.mage/~working.lock')) { - unlink('.mage/~working.lock'); + if (file_exists(getcwd() . '/.mage/~working.lock')) { + unlink(getcwd() . '/.mage/~working.lock'); } } @@ -311,11 +311,11 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment case 'targz': $deployStrategy = 'deployment/strategy/tar-gz'; break; - + case 'git-rebase': $deployStrategy = 'deployment/strategy/git-rebase'; break; - + case 'guess': default: if ($this->getConfig()->release('enabled', false) == true) { diff --git a/Mage/Command/BuiltIn/InitCommand.php b/Mage/Command/BuiltIn/InitCommand.php index c26d912..84f3069 100644 --- a/Mage/Command/BuiltIn/InitCommand.php +++ b/Mage/Command/BuiltIn/InitCommand.php @@ -27,7 +27,7 @@ class InitCommand extends AbstractCommand */ public function run() { - $configDir = '.mage'; + $configDir = getcwd() . '/.mage'; Console::output('Initiating managing process for application with Magallanes'); diff --git a/Mage/Command/BuiltIn/ListCommand.php b/Mage/Command/BuiltIn/ListCommand.php index a43776d..b088eac 100644 --- a/Mage/Command/BuiltIn/ListCommand.php +++ b/Mage/Command/BuiltIn/ListCommand.php @@ -54,7 +54,7 @@ class ListCommand extends AbstractCommand protected function listEnvironments() { $environments = array(); - $content = scandir('.mage/config/environment/'); + $content = scandir(getcwd() . '/.mage/config/environment/'); foreach ($content as $file) { if (strpos($file, '.yml') !== false) { $environments[] = str_replace('.yml', '', $file); @@ -73,4 +73,4 @@ class ListCommand extends AbstractCommand Console::output('You don\'t have any environment configured.', 1, 2); } } -} \ No newline at end of file +} diff --git a/Mage/Command/BuiltIn/LockCommand.php b/Mage/Command/BuiltIn/LockCommand.php index ae33b39..1444762 100644 --- a/Mage/Command/BuiltIn/LockCommand.php +++ b/Mage/Command/BuiltIn/LockCommand.php @@ -39,7 +39,7 @@ class LockCommand extends AbstractCommand implements RequiresEnvironment if ($email) $lockmsg .= '(' . $email . ')'; 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); Console::output('Locked deployment to ' . $this->getConfig()->getEnvironment() . ' environment', 1, 2); diff --git a/Mage/Command/BuiltIn/ReleasesCommand.php b/Mage/Command/BuiltIn/ReleasesCommand.php index b1b4670..293faaf 100644 --- a/Mage/Command/BuiltIn/ReleasesCommand.php +++ b/Mage/Command/BuiltIn/ReleasesCommand.php @@ -34,7 +34,7 @@ class ReleasesCommand extends AbstractCommand implements RequiresEnvironment } $subcommand = $this->getConfig()->getArgument(1); - $lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock'; + $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock'; if (file_exists($lockFile) && ($subcommand == 'rollback')) { Console::output('This environment is locked!', 1, 2); echo file_get_contents($lockFile); diff --git a/Mage/Command/BuiltIn/RollbackCommand.php b/Mage/Command/BuiltIn/RollbackCommand.php index 9f90959..0eb7eff 100644 --- a/Mage/Command/BuiltIn/RollbackCommand.php +++ b/Mage/Command/BuiltIn/RollbackCommand.php @@ -34,7 +34,7 @@ class RollbackCommand extends AbstractCommand implements RequiresEnvironment return false; } - $lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock'; + $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock'; if (file_exists($lockFile) && ($subcommand == 'rollback')) { Console::output('This environment is locked!', 1, 2); echo file_get_contents($lockFile); diff --git a/Mage/Command/BuiltIn/UnlockCommand.php b/Mage/Command/BuiltIn/UnlockCommand.php index 49e2288..d18fc24 100644 --- a/Mage/Command/BuiltIn/UnlockCommand.php +++ b/Mage/Command/BuiltIn/UnlockCommand.php @@ -28,7 +28,7 @@ class UnlockCommand */ public function run() { - $lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock'; + $lockFile = getcwd() . '/.mage/' . $this->getConfig()->getEnvironment() . '.lock'; if (file_exists($lockFile)) { @unlink($lockFile); } @@ -36,4 +36,4 @@ class UnlockCommand Console::output('Unlocked deployment to ' . $this->getConfig()->getEnvironment() . ' environment', 1, 2); } -} \ No newline at end of file +} diff --git a/Mage/Config.php b/Mage/Config.php index fac2e48..1d8bbc0 100644 --- a/Mage/Config.php +++ b/Mage/Config.php @@ -99,8 +99,8 @@ class Config */ protected function loadGeneral() { - if (file_exists('.mage/config/general.yml')) { - $this->config['general'] = Yaml::parse(file_get_contents('.mage/config/general.yml')); + if (file_exists(getcwd() . '/.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() { $environment = $this->getEnvironment(); - if (($environment != false) && file_exists('.mage/config/environment/' . $environment . '.yml')) { - $this->config['environment'] = Yaml::parse(file_get_contents('.mage/config/environment/' . $environment . '.yml')); + if (($environment != false) && file_exists(getcwd() . '/.mage/config/environment/' . $environment . '.yml')) { + $this->config['environment'] = Yaml::parse(file_get_contents(getcwd() . '/.mage/config/environment/' . $environment . '.yml')); // Create temporal directory for clone if (isset($this->config['environment']['deployment']['source']) && is_array($this->config['environment']['deployment']['source'])) { @@ -127,7 +127,7 @@ class Config } 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.'); } @@ -353,7 +353,7 @@ class Config { return $this->deployment('identity-file') ? ('-i ' . $this->deployment('identity-file') . ' ') : ''; } - + /** * Get the current Host * diff --git a/Mage/Console.php b/Mage/Console.php index b629b9e..98517ac 100644 --- a/Mage/Console.php +++ b/Mage/Console.php @@ -72,8 +72,8 @@ class Console register_shutdown_function(function() { // Only Unlock if there was an error if (error_get_last() !== null) { - if (file_exists('.mage/~working.lock')) { - unlink('.mage/~working.lock'); + if (file_exists(getcwd() . '/.mage/~working.lock')) { + unlink(getcwd() . '/.mage/~working.lock'); } } }); @@ -130,8 +130,8 @@ class Console if ($showGrettings) { self::output('Finished Magallanes', 0, 2); - if (file_exists('.mage/~working.lock')) { - unlink('.mage/~working.lock'); + if (file_exists(getcwd() . '/.mage/~working.lock')) { + unlink(getcwd() . '/.mage/~working.lock'); } } @@ -200,7 +200,7 @@ class Console { if (self::$logEnabled) { 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'); } @@ -249,7 +249,7 @@ class Console $maxLogs = $config->general('maxlogs', 30); $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) { $logs[] = $log->getFilename(); } @@ -259,7 +259,7 @@ class Console if (count($logs) > $maxLogs) { $logsToDelete = array_slice($logs, 0, count($logs) - $maxLogs); foreach ($logsToDelete as $logToDeelte) { - unlink('.mage/logs/' . $logToDeelte); + unlink(getcwd() . '/.mage/logs/' . $logToDeelte); } } } diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php b/Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php index f17afbd..9b65e64 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php @@ -50,7 +50,7 @@ abstract class BaseStrategyTaskAbstract extends AbstractTask implements IsReleas $excludes = array( '.git', '.svn', - '.mage', + getcwd() . '/.mage', '.gitignore', '.gitkeep', 'nohup.out' diff --git a/Mage/Task/BuiltIn/Ioncube/EncryptTask.php b/Mage/Task/BuiltIn/Ioncube/EncryptTask.php index 876546e..1a3f5e6 100644 --- a/Mage/Task/BuiltIn/Ioncube/EncryptTask.php +++ b/Mage/Task/BuiltIn/Ioncube/EncryptTask.php @@ -755,7 +755,7 @@ class EncryptTask extends AbstractTask $p ['ignore'] = array ( '.git', '.svn', - '.mage', + getcwd() . '/.mage', '.gitignore', '.gitkeep', 'nohup.out' From f2e01280a54602b947db53b416233a2e85c0eb42 Mon Sep 17 00:00:00 2001 From: woutersioen Date: Wed, 16 Jul 2014 16:32:29 +0200 Subject: [PATCH 2/3] Fix excludes for releases --- .../Deployment/Strategy/BaseStrategyTaskAbstract.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php b/Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php index 9b65e64..746eb5a 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php @@ -48,12 +48,12 @@ abstract class BaseStrategyTaskAbstract extends AbstractTask implements IsReleas protected function getExcludes() { $excludes = array( - '.git', - '.svn', + getcwd() . '/.git', + getcwd() . '/.svn', getcwd() . '/.mage', - '.gitignore', - '.gitkeep', - 'nohup.out' + getcwd() . '/.gitignore', + getcwd() . '/.gitkeep', + getcwd() . '/nohup.out' ); // Look for User Excludes From 26bc4242d1d7cf5f554343d34f82de253463a68a Mon Sep 17 00:00:00 2001 From: woutersioen Date: Wed, 16 Jul 2014 16:35:18 +0200 Subject: [PATCH 3/3] Revert excludes --- .../Deployment/Strategy/BaseStrategyTaskAbstract.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php b/Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php index 746eb5a..f17afbd 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/BaseStrategyTaskAbstract.php @@ -48,12 +48,12 @@ abstract class BaseStrategyTaskAbstract extends AbstractTask implements IsReleas protected function getExcludes() { $excludes = array( - getcwd() . '/.git', - getcwd() . '/.svn', - getcwd() . '/.mage', - getcwd() . '/.gitignore', - getcwd() . '/.gitkeep', - getcwd() . '/nohup.out' + '.git', + '.svn', + '.mage', + '.gitignore', + '.gitkeep', + 'nohup.out' ); // Look for User Excludes