Merge pull request #85 from WouterSioen/global-install

Make file locations work better from global install.
This commit is contained in:
Andrés Montañez 2014-07-23 10:38:18 -03:00
commit a26663bec9
12 changed files with 33 additions and 33 deletions

View file

@ -46,8 +46,8 @@ 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;
} }
} }

View file

@ -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.');
@ -99,4 +99,4 @@ class AddCommand extends AbstractCommand
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 <dark_gray>' . $environmentName . '</dark_gray>', 1, 2);
} }
} }
} }

View file

@ -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');
} }
} }
@ -311,11 +311,11 @@ class DeployCommand extends AbstractCommand implements RequiresEnvironment
case 'targz': case 'targz':
$deployStrategy = 'deployment/strategy/tar-gz'; $deployStrategy = 'deployment/strategy/tar-gz';
break; break;
case 'git-rebase': case 'git-rebase':
$deployStrategy = 'deployment/strategy/git-rebase'; $deployStrategy = 'deployment/strategy/git-rebase';
break; break;
case 'guess': case 'guess':
default: default:
if ($this->getConfig()->release('enabled', false) == true) { if ($this->getConfig()->release('enabled', false) == true) {

View file

@ -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>');

View file

@ -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);
@ -73,4 +73,4 @@ class ListCommand extends AbstractCommand
Console::output('<dark_gray>You don\'t have any environment configured.</dark_gray>', 1, 2); Console::output('<dark_gray>You don\'t have any environment configured.</dark_gray>', 1, 2);
} }
} }
} }

View 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);

View file

@ -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);

View file

@ -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);

View file

@ -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);
} }
@ -36,4 +36,4 @@ class UnlockCommand
Console::output('Unlocked deployment to <light_purple>' . $this->getConfig()->getEnvironment() . '</light_purple> environment', 1, 2); Console::output('Unlocked deployment to <light_purple>' . $this->getConfig()->getEnvironment() . '</light_purple> environment', 1, 2);
} }
} }

View file

@ -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.');
} }
@ -353,7 +353,7 @@ class Config
{ {
return $this->deployment('identity-file') ? ('-i ' . $this->deployment('identity-file') . ' ') : ''; return $this->deployment('identity-file') ? ('-i ' . $this->deployment('identity-file') . ' ') : '';
} }
/** /**
* Get the current Host * Get the current Host
* *

View file

@ -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);
} }
} }
} }

View file

@ -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'