mirror of https://github.com/hauke68/Magallanes
Andrs Montaez
13 years ago
5 changed files with 134 additions and 5 deletions
@ -0,0 +1,50 @@
|
||||
<?php |
||||
class Mage_Task_BuiltIn_Releases_List |
||||
extends Mage_Task_TaskAbstract |
||||
{ |
||||
public function getName() |
||||
{ |
||||
return 'Listing releases [built-in]'; |
||||
} |
||||
|
||||
public function run() |
||||
{ |
||||
if (isset($this->_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 <dark_gray>' . $this->_config['deploy']['host'] . '</dark_gray>'); |
||||
|
||||
$output = ''; |
||||
$result = $this->_runRemoteCommand('ls -1 ' . $releasesDirectory, $output); |
||||
$releases = ($output == '') ? array() : explode(PHP_EOL, $output); |
||||
|
||||
if (count($releases) == 0) { |
||||
Mage_Console::output('<dark_gray>No releases available</dark_gray> ... ', 2); |
||||
} else { |
||||
rsort($releases); |
||||
foreach ($releases as $releaseIndex => $releaseDate) { |
||||
Mage_Console::output('Index: ' . $releaseIndex . ' - <purple>' . $releaseDate . '</purple>', 2); |
||||
} |
||||
} |
||||
|
||||
return $result; |
||||
|
||||
} else { |
||||
return false; |
||||
} |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,49 @@
|
||||
<?php |
||||
class Mage_Task_Releases |
||||
{ |
||||
private $_config = null; |
||||
private $_action = null; |
||||
|
||||
public function setAction($action) |
||||
{ |
||||
$this->_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('<light_purple>Warning!</light_purple> <dark_gray>No hosts defined, unable to get releases.</dark_gray>', 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() |
||||
{ |
||||
|
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue