diff --git a/Mage/Console.php b/Mage/Console.php
index 8c2c7c3..b472701 100644
--- a/Mage/Console.php
+++ b/Mage/Console.php
@@ -7,6 +7,7 @@ class Mage_Console
private $_environment = null;
private static $_log = null;
private static $_logEnabled = true;
+ private static $_screenBuffer = '';
public function setArgs($args)
{
@@ -19,6 +20,9 @@ class Mage_Console
if ($this->_args[0] == 'deploy') {
$this->_action = 'deploy';
+ } else if ($this->_args[0] == 'releases') {
+ $this->_action = 'releases';
+
} else if ($this->_args[0] == 'update') {
$this->_action = 'update';
@@ -53,6 +57,10 @@ class Mage_Console
{
self::log(strip_tags($message));
+ self::$_screenBuffer .= str_repeat("\t", $tabs)
+ . strip_tags($message)
+ . str_repeat(PHP_EOL, $newLine);
+
$output = str_repeat("\t", $tabs)
. Mage_Console_Colors::color($message)
. str_repeat(PHP_EOL, $newLine);
@@ -60,7 +68,7 @@ class Mage_Console
echo $output;
}
- public static function executeCommand($command)
+ public static function executeCommand($command, &$output = null)
{
self::log('---------------------------------');
self::log('---- Executing: $ ' . $command);
@@ -69,6 +77,10 @@ class Mage_Console
system($command . ' 2>&1', $return);
$log = ob_get_clean();
+ if (!$return) {
+ $output = trim($log);
+ }
+
self::log($log);
self::log('---------------------------------');
@@ -93,6 +105,16 @@ class Mage_Console
$task = new Mage_Task_Deploy;
$task->run($config);
break;
+
+ case 'releases':
+ $task = new Mage_Task_Releases;
+ switch ($this->_args[1]) {
+ case 'list':
+ $task->setAction($this->_args[1]);
+ break;
+ }
+ $task->run($config);
+ break;
case 'update';
$task = new Mage_Task_Update;
diff --git a/Mage/Task/BuiltIn/Releases/List.php b/Mage/Task/BuiltIn/Releases/List.php
new file mode 100644
index 0000000..f0df6b1
--- /dev/null
+++ b/Mage/Task/BuiltIn/Releases/List.php
@@ -0,0 +1,50 @@
+_config['deploy']['releases']['enabled'])) {
+ if ($this->_config['deploy']['releases']['enabled'] == 'true') {
+ if (isset($this->_config['deploy']['releases']['directory'])) {
+ $releasesDirectory = $this->_config['deploy']['releases']['directory'];
+ } else {
+ $releasesDirectory = 'releases';
+ }
+ if (isset($this->_config['deploy']['releases']['symlink'])) {
+ $symlink = $this->_config['deploy']['releases']['symlink'];
+ } else {
+ $symlink = 'current';
+ }
+
+ Mage_Console::output('Releases available on ' . $this->_config['deploy']['host'] . '');
+
+ $output = '';
+ $result = $this->_runRemoteCommand('ls -1 ' . $releasesDirectory, $output);
+ $releases = ($output == '') ? array() : explode(PHP_EOL, $output);
+
+ if (count($releases) == 0) {
+ Mage_Console::output('No releases available ... ', 2);
+ } else {
+ rsort($releases);
+ foreach ($releases as $releaseIndex => $releaseDate) {
+ Mage_Console::output('Index: ' . $releaseIndex . ' - ' . $releaseDate . '', 2);
+ }
+ }
+
+ return $result;
+
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Mage/Task/Releases.php b/Mage/Task/Releases.php
new file mode 100644
index 0000000..af7804c
--- /dev/null
+++ b/Mage/Task/Releases.php
@@ -0,0 +1,49 @@
+_action = $action;
+ return $this;
+ }
+
+ public function getAction()
+ {
+ return $this->_action;
+ }
+
+ public function run(Mage_Config $config)
+ {
+ $this->_config = $config;
+
+ // Run Tasks for Deployment
+ $hosts = $config->getHosts();
+
+ if (count($hosts) == 0) {
+ Mage_Console::output('Warning! No hosts defined, unable to get releases.', 1, 3);
+
+ } else {
+ foreach ($hosts as $host) {
+ $taskConfig = $config->getConfig($host);
+
+ switch ($this->getAction()) {
+ case 'list':
+ $task = Mage_Task_Factory::get('releases/list', $taskConfig);
+ $task->init();
+ $result = $task->run();
+ break;
+ }
+ }
+ }
+
+ }
+
+ private function _listReleases()
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/Mage/Task/TaskAbstract.php b/Mage/Task/TaskAbstract.php
index 80bb478..b142bcc 100644
--- a/Mage/Task/TaskAbstract.php
+++ b/Mage/Task/TaskAbstract.php
@@ -16,18 +16,18 @@ abstract class Mage_Task_TaskAbstract
{
}
- protected final function _runLocalCommand($command)
+ protected final function _runLocalCommand($command, &$output = null)
{
- return Mage_Console::executeCommand($command);
+ return Mage_Console::executeCommand($command, $output);
}
- protected final function _runRemoteCommand($command)
+ protected final function _runRemoteCommand($command, &$output = null)
{
$localCommand = 'ssh '
. $this->_config['deploy']['deployment']['user'] . '@' . $this->_config['deploy']['host'] . ' '
. '"cd ' . $this->_config['deploy']['deployment']['to'] . ' && '
. $command . '"';
- return $this->_runLocalCommand($localCommand);
+ return $this->_runLocalCommand($localCommand, $output);
}
}
\ No newline at end of file
diff --git a/docs/example-config/.mage/config/global.yaml b/docs/example-config/.mage/config/global.yaml
index f17dc38..90934bd 100644
--- a/docs/example-config/.mage/config/global.yaml
+++ b/docs/example-config/.mage/config/global.yaml
@@ -1 +1,9 @@
#global settings
+mail:
+ from: andresmontanez@gmail.com
+ password: xxxxxx
+ smtp: smtp.gmail.com
+ to:
+ - andresmontanez@gmail.com
+ - andres.montanez@zenreworks.com
+