mirror of
https://github.com/hauke68/Magallanes.git
synced 2026-08-29 10:38:57 +02:00
New reorder of classes and configuration. New instantiation of Tasks.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
class Mage_Task_BuiltIn_Deployment_Rsync
|
||||
extends Mage_Task_TaskAbstract
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'Rsync (built-in)';
|
||||
}
|
||||
|
||||
public function run($config)
|
||||
{
|
||||
$ignores = array(
|
||||
'--exclude .git',
|
||||
'--exclude .svn',
|
||||
'--exclude .mage',
|
||||
'--exclude .gitignore'
|
||||
);
|
||||
|
||||
$command = 'rsync -avz '
|
||||
. implode(' ', $ignores) .' '
|
||||
. $config['deploy']['deploy-from'] . ' '
|
||||
. $config['deploy']['user'] . '@' . $config['deploy']['host'] . ':' . $config['deploy']['deploy-to'];
|
||||
|
||||
$result = $this->_runLocalCommand($command);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
class Mage_Task_BuiltIn_Scm_Update
|
||||
extends Mage_Task_TaskAbstract
|
||||
{
|
||||
public function getName()
|
||||
{
|
||||
return 'SCM Update (built-in)';
|
||||
}
|
||||
|
||||
public function run($config)
|
||||
{
|
||||
switch ($config['scm']['type']) {
|
||||
case 'git':
|
||||
$command = 'git pull';
|
||||
break;
|
||||
|
||||
case 'svn':
|
||||
$command = 'svn update';
|
||||
break;
|
||||
}
|
||||
|
||||
$result = $this->_runLocalCommand($command);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
class Mage_Task_Deploy
|
||||
{
|
||||
private $_config = null;
|
||||
|
||||
public function run(Mage_Config $config)
|
||||
{
|
||||
$this->_config = $config;
|
||||
|
||||
foreach ($config->getHosts() as $host)
|
||||
{
|
||||
$taskConfig = $config->getConfig($host);
|
||||
$tasks = 0;
|
||||
$completedTasks = 0;
|
||||
|
||||
Mage_Console::output(PHP_TAB . 'Deploying to ' . $host . PHP_EOL);
|
||||
|
||||
foreach ($config->getTasks() as $taskName) {
|
||||
$tasks++;
|
||||
$task = Mage_Task_Factory::get($taskName);
|
||||
|
||||
Mage_Console::output(PHP_TAB . PHP_TAB . 'Running ' . $task->getName() . ' ... ');
|
||||
$result = $task->run($taskConfig);
|
||||
|
||||
if ($result == true) {
|
||||
Mage_Console::output(PHP_TAB . 'OK' . PHP_EOL);
|
||||
$completedTasks++;
|
||||
} else {
|
||||
Mage_Console::output(PHP_TAB . 'FAIL' . PHP_EOL);
|
||||
}
|
||||
}
|
||||
|
||||
Mage_Console::output(PHP_TAB . 'Deployment to ' . $host . ' compted: ' . $completedTasks . '/' . $tasks . ' tasks done.' . PHP_EOL . PHP_EOL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
class Mage_Task_Factory
|
||||
{
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param string $taskName
|
||||
* @return Mage_Task_TaskAbstract
|
||||
*/
|
||||
public static function get($taskName)
|
||||
{
|
||||
$taskName = str_replace(' ', '_', ucwords(str_replace('/', ' ', $taskName)));
|
||||
$className = 'Mage_Task_BuiltIn_' . $taskName;
|
||||
return new $className;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
abstract class Mage_Task_TaskAbstract
|
||||
{
|
||||
public abstract function getName();
|
||||
|
||||
public abstract function run($config);
|
||||
|
||||
protected function _runLocalCommand($command)
|
||||
{
|
||||
return Mage_Console::executeCommand($command);
|
||||
}
|
||||
|
||||
protected function _runRemoteCommand($command)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user