mirror of https://github.com/hauke68/Magallanes
Andrs Montaez
13 years ago
13 changed files with 174 additions and 93 deletions
@ -0,0 +1,7 @@
|
||||
.project |
||||
.buildpath |
||||
.settings |
||||
.settings/* |
||||
.settings/org.eclipse.php.core.prefs |
||||
|
||||
.settings/org.eclipse.php.core.prefs |
@ -1,53 +1,42 @@
|
||||
<?php |
||||
class Mage_Console_Colors { |
||||
private static $foreground_colors = array (); |
||||
private static $background_colors = array (); |
||||
class Mage_Console_Colors |
||||
{ |
||||
private static $foreground_colors = array( |
||||
'black' => '0;30', |
||||
'dark_gray' => '1;30', |
||||
'blue' => '0;34', |
||||
'light_blue' => '1;34', |
||||
'green' => '0;32', |
||||
'light_green' => '1;32', |
||||
'cyan' => '0;36', |
||||
'light_cyan' => '1;36', |
||||
'red' => '0;31', |
||||
'light_red' => '1;31', |
||||
'purple' => '0;35', |
||||
'light_purple' => '1;35', |
||||
'brown' => '0;33', |
||||
'yellow' => '1;33', |
||||
'light_gray' => '0;37', |
||||
'white' => '1;37' |
||||
|
||||
public function __construct() { |
||||
// Set up shell colors |
||||
self::$foreground_colors ['black'] = '0;30'; |
||||
self::$foreground_colors ['dark_gray'] = '1;30'; |
||||
self::$foreground_colors ['blue'] = '0;34'; |
||||
self::$foreground_colors ['light_blue'] = '1;34'; |
||||
self::$foreground_colors ['green'] = '0;32'; |
||||
self::$foreground_colors ['light_green'] = '1;32'; |
||||
self::$foreground_colors ['cyan'] = '0;36'; |
||||
self::$foreground_colors ['light_cyan'] = '1;36'; |
||||
self::$foreground_colors ['red'] = '0;31'; |
||||
self::$foreground_colors ['light_red'] = '1;31'; |
||||
self::$foreground_colors ['purple'] = '0;35'; |
||||
self::$foreground_colors ['light_purple'] = '1;35'; |
||||
self::$foreground_colors ['brown'] = '0;33'; |
||||
self::$foreground_colors ['yellow'] = '1;33'; |
||||
self::$foreground_colors ['light_gray'] = '0;37'; |
||||
self::$foreground_colors ['white'] = '1;37'; |
||||
); |
||||
|
||||
self::$background_colors ['black'] = '40'; |
||||
self::$background_colors ['red'] = '41'; |
||||
self::$background_colors ['green'] = '42'; |
||||
self::$background_colors ['yellow'] = '43'; |
||||
self::$background_colors ['blue'] = '44'; |
||||
self::$background_colors ['magenta'] = '45'; |
||||
self::$background_colors ['cyan'] = '46'; |
||||
self::$background_colors ['light_gray'] = '47'; |
||||
} |
||||
// Returns colored string |
||||
public static function color($string) |
||||
{ |
||||
foreach (self::$foreground_colors as $key => $code) { |
||||
$replaceFrom = array( |
||||
'<' . $key . '>', |
||||
'</' . $key . '>' |
||||
); |
||||
$replaceTo = array( |
||||
"\033[" . $code . 'm', |
||||
"\033[0m" |
||||
); |
||||
|
||||
// Returns colored string |
||||
public static function g($string, $foreground_color = null, $background_color = null) { |
||||
$colored_string = ""; |
||||
$string = str_replace($replaceFrom, $replaceTo, $string); |
||||
} |
||||
|
||||
// Check if given foreground color found |
||||
if (isset ( self::$foreground_colors [$foreground_color] )) { |
||||
$colored_string .= "\033[" . self::$foreground_colors [$foreground_color] . "m"; |
||||
} |
||||
// Check if given background color found |
||||
if (isset ( self::$background_colors [$background_color] )) { |
||||
$colored_string .= "\033[" . self::$background_colors [$background_color] . "m"; |
||||
} |
||||
|
||||
// Add string and end coloring |
||||
$colored_string .= $string . "\033[0m"; |
||||
|
||||
return $colored_string; |
||||
} |
||||
return $string; |
||||
} |
||||
} |
||||
|
@ -1,17 +1,33 @@
|
||||
<?php |
||||
abstract class Mage_Task_TaskAbstract |
||||
{ |
||||
protected $_config = null; |
||||
|
||||
public abstract function getName(); |
||||
|
||||
public abstract function run($config); |
||||
public abstract function run(); |
||||
|
||||
public final function __construct($config) |
||||
{ |
||||
$this->_config = $config; |
||||
} |
||||
|
||||
public function init() |
||||
{ |
||||
} |
||||
|
||||
protected function _runLocalCommand($command) |
||||
protected final function _runLocalCommand($command) |
||||
{ |
||||
return Mage_Console::executeCommand($command); |
||||
} |
||||
|
||||
protected function _runRemoteCommand($command) |
||||
protected final function _runRemoteCommand($command) |
||||
{ |
||||
$localCommand = 'ssh ' |
||||
. $this->_config['deploy']['user'] . '@' . $this->_config['deploy']['host'] . ' ' |
||||
. '"cd ' . $this->_config['deploy']['deploy-to'] . ' && ' |
||||
. $command . '"'; |
||||
|
||||
return $this->_runLocalCommand($localCommand); |
||||
} |
||||
} |
@ -0,0 +1,24 @@
|
||||
<?php |
||||
class Mage_Task_Update |
||||
{ |
||||
private $_config = null; |
||||
|
||||
public function run(Mage_Config $config) |
||||
{ |
||||
$this->_config = $config; |
||||
|
||||
$taskConfig = $config->getConfig(); |
||||
$task = Mage_Task_Factory::get('scm/update', $taskConfig); |
||||
$task->init(); |
||||
|
||||
Mage_Console::output( PHP_TAB . 'Updating application via ' . $task->getName() . ' ... '); |
||||
$result = $task->run(); |
||||
|
||||
if ($result == true) { |
||||
Mage_Console::output(PHP_TAB . 'OK' . PHP_EOL); |
||||
} else { |
||||
Mage_Console::output(PHP_TAB . 'FAIL' . PHP_EOL); |
||||
} |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue