Files
Magallanes/Mage/Command/BuiltIn/Releases.php
T

54 lines
1.8 KiB
PHP
Raw Normal View History

2012-01-01 13:36:41 -02:00
<?php
2013-11-05 14:12:09 -02:00
/*
* This file is part of the Magallanes package.
*
* (c) Andrés Montañez <andres@andresmontanez.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Mage_Command_BuiltIn_Releases
extends Mage_Command_CommandAbstract
implements Mage_Command_RequiresEnvironment
2012-01-01 13:36:41 -02:00
{
2012-01-01 18:10:25 -02:00
private $_release = null;
public function run()
2012-01-01 13:36:41 -02:00
{
$subcommand = $this->getConfig()->getArgument(1);
$lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock';
if (file_exists($lockFile) && ($subcommand == 'rollback')) {
2012-09-19 19:16:52 -03:00
Mage_Console::output('<red>This environment is locked!</red>', 0, 2);
return;
}
2012-01-01 13:36:41 -02:00
// Run Tasks for Deployment
$hosts = $this->getConfig()->getHosts();
2012-01-01 13:36:41 -02:00
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);
2012-01-01 13:36:41 -02:00
} else {
foreach ($hosts as $host) {
$this->getConfig()->setHost($host);
switch ($subcommand) {
2012-01-01 13:36:41 -02:00
case 'list':
$task = Mage_Task_Factory::get('releases/list', $this->getConfig());
2012-01-01 13:36:41 -02:00
$task->init();
$result = $task->run();
break;
case 'rollback':
$releaseId = $this->getConfig()->getParameter('release', '');
$task = Mage_Task_Factory::get('releases/rollback', $this->getConfig());
2012-01-01 18:10:25 -02:00
$task->init();
$task->setRelease($releaseId);
2012-01-01 18:10:25 -02:00
$result = $task->run();
break;
2012-01-01 13:36:41 -02:00
}
}
}
}
}