mirror of https://github.com/hauke68/Magallanes
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.1 KiB
70 lines
2.1 KiB
13 years ago
|
<?php
|
||
11 years ago
|
/*
|
||
|
* 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.
|
||
|
*/
|
||
|
|
||
11 years ago
|
namespace Mage\Command\BuiltIn;
|
||
|
|
||
|
use Mage\Command\AbstractCommand;
|
||
|
use Mage\Command\RequiresEnvironment;
|
||
|
use Mage\Task\Factory;
|
||
|
use Mage\Console;
|
||
|
|
||
|
use Exception;
|
||
|
|
||
|
/**
|
||
|
* Command for Managing the Releases
|
||
|
*
|
||
|
* @author Andrés Montañez <andres@andresmontanez.com>
|
||
|
*/
|
||
|
class ReleasesCommand extends AbstractCommand implements RequiresEnvironment
|
||
13 years ago
|
{
|
||
11 years ago
|
private $release = null;
|
||
13 years ago
|
|
||
11 years ago
|
/**
|
||
|
* List the Releases, Rollback to a Release
|
||
|
* @see \Mage\Command\AbstractCommand::run()
|
||
|
*/
|
||
13 years ago
|
public function run()
|
||
13 years ago
|
{
|
||
13 years ago
|
$subcommand = $this->getConfig()->getArgument(1);
|
||
|
$lockFile = '.mage/' . $this->getConfig()->getEnvironment() . '.lock';
|
||
|
if (file_exists($lockFile) && ($subcommand == 'rollback')) {
|
||
11 years ago
|
Console::output('<red>This environment is locked!</red>', 0, 2);
|
||
13 years ago
|
return;
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
// Run Tasks for Deployment
|
||
13 years ago
|
$hosts = $this->getConfig()->getHosts();
|
||
13 years ago
|
|
||
13 years ago
|
if (count($hosts) == 0) {
|
||
11 years ago
|
Console::output('<light_purple>Warning!</light_purple> <dark_gray>No hosts defined, unable to get releases.</dark_gray>', 1, 3);
|
||
13 years ago
|
|
||
13 years ago
|
} else {
|
||
|
foreach ($hosts as $host) {
|
||
13 years ago
|
$this->getConfig()->setHost($host);
|
||
|
|
||
|
switch ($subcommand) {
|
||
13 years ago
|
case 'list':
|
||
11 years ago
|
$task = Factory::get('releases/list', $this->getConfig());
|
||
13 years ago
|
$task->init();
|
||
|
$result = $task->run();
|
||
|
break;
|
||
13 years ago
|
|
||
13 years ago
|
case 'rollback':
|
||
|
$releaseId = $this->getConfig()->getParameter('release', '');
|
||
11 years ago
|
$task = Factory::get('releases/rollback', $this->getConfig());
|
||
13 years ago
|
$task->init();
|
||
13 years ago
|
$task->setRelease($releaseId);
|
||
13 years ago
|
$result = $task->run();
|
||
|
break;
|
||
13 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|