diff --git a/.buildpath b/.buildpath
new file mode 100644
index 0000000..8bcb4b5
--- /dev/null
+++ b/.buildpath
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..c8c5e4c
--- /dev/null
+++ b/.project
@@ -0,0 +1,22 @@
+
+
+ Magallanes
+
+
+
+
+
+ org.eclipse.wst.validation.validationbuilder
+
+
+
+
+ org.eclipse.dltk.core.scriptbuilder
+
+
+
+
+
+ org.eclipse.php.core.PHPNature
+
+
diff --git a/.settings/org.eclipse.php.core.prefs b/.settings/org.eclipse.php.core.prefs
new file mode 100644
index 0000000..2d17ecc
--- /dev/null
+++ b/.settings/org.eclipse.php.core.prefs
@@ -0,0 +1,3 @@
+#Mon Nov 21 16:37:20 UYST 2011
+eclipse.preferences.version=1
+include_path=0;/Magallanes
diff --git a/Magallanes/Config.php b/Magallanes/Config.php
deleted file mode 100644
index c39d101..0000000
--- a/Magallanes/Config.php
+++ /dev/null
@@ -1,26 +0,0 @@
-_environment = yaml_parse_file('.mage/environment/' . $environment . '.yaml');
- }
-
- public function loadCSM()
- {
- $this->_csm = yaml_parse_file('.mage/csm.yaml');
- }
-
- public function getEnvironment()
- {
- return $this->_environment;
- }
-
- public function getCSM()
- {
- return $this->_csm;
- }
-}
\ No newline at end of file
diff --git a/Magallanes/Task/CSM/Git.php b/Magallanes/Task/CSM/Git.php
deleted file mode 100644
index 031a1bf..0000000
--- a/Magallanes/Task/CSM/Git.php
+++ /dev/null
@@ -1,16 +0,0 @@
-_url = $url;
- $this->_update();
- }
-
- private function _update()
- {
- Magallanes_Console::output('git pull ' . $this->_url . PHP_EOL);
- }
-}
\ No newline at end of file
diff --git a/Magallanes/Task/Deploy.php b/Magallanes/Task/Deploy.php
deleted file mode 100644
index 19f9682..0000000
--- a/Magallanes/Task/Deploy.php
+++ /dev/null
@@ -1,30 +0,0 @@
-_config = $config;
- $this->_rsync();
- }
-
- private function _rsync()
- {
- $config = $this->_config->getEnvironment();
- $user = $config['user'];
- $to = $config['deploy-to'];
- $from = $config['deploy-from'];
-
- foreach ($config['hosts'] as $host) {
- Magallanes_Console::output(PHP_TAB . 'Deploying to: ' . $host);
- $result = Magallanes_Task_Deploy_Rsync::exec($user, $host, $from, $to);
- if ($result == 0) {
- Magallanes_Console::output(PHP_TAB . 'OK' . PHP_EOL);
- } else {
- Magallanes_Console::output(PHP_TAB . 'FAIL' . PHP_EOL);
- }
- }
-
- }
-}
\ No newline at end of file
diff --git a/Magallanes/Task/Deploy/Rsync.php b/Magallanes/Task/Deploy/Rsync.php
deleted file mode 100644
index b7680e6..0000000
--- a/Magallanes/Task/Deploy/Rsync.php
+++ /dev/null
@@ -1,11 +0,0 @@
-&1 ', $command, $result);
- return $result;
- }
-}
\ No newline at end of file
diff --git a/Magallanes/Task/Update.php b/Magallanes/Task/Update.php
deleted file mode 100644
index 004cb3c..0000000
--- a/Magallanes/Task/Update.php
+++ /dev/null
@@ -1,12 +0,0 @@
-getCSM();
- $csm = new Magallanes_Task_CSM_Git;
- $csm->run($csmConfig['url']);
- }
-}
\ No newline at end of file
diff --git a/Magallanes/Autoload.php b/Mage/Autoload.php
similarity index 89%
rename from Magallanes/Autoload.php
rename to Mage/Autoload.php
index a06a4af..1173232 100644
--- a/Magallanes/Autoload.php
+++ b/Mage/Autoload.php
@@ -1,5 +1,5 @@
_environment = yaml_parse_file('.mage/config/environment/' . $environment . '.yaml');
+ }
+
+ public function loadSCM()
+ {
+ $this->_scm = yaml_parse_file('.mage/config/scm.yaml');
+ }
+
+ public function getEnvironment()
+ {
+ return $this->_environment;
+ }
+
+ public function getSCM()
+ {
+ return $this->_scm;
+ }
+
+ public function getHosts()
+ {
+ $config = $this->getEnvironment();
+ return $config['hosts'];
+ }
+
+ public function getTasks()
+ {
+ $config = $this->getEnvironment();
+ return $config['tasks'];
+ }
+
+ public function getConfig($host)
+ {
+ $taskConfig = array();
+ $taskConfig['deploy'] = $this->getEnvironment();
+ $taskConfig['deploy']['host'] = $host;
+ $taskConfig['scm'] = $this->getSCM();
+
+ unset($taskConfig['deploy']['tasks']);
+ unset($taskConfig['deploy']['hosts']);
+
+ return $taskConfig;
+ }
+}
\ No newline at end of file
diff --git a/Magallanes/Console.php b/Mage/Console.php
similarity index 68%
rename from Magallanes/Console.php
rename to Mage/Console.php
index 6d5e15d..0b65664 100644
--- a/Magallanes/Console.php
+++ b/Mage/Console.php
@@ -1,5 +1,5 @@
&1', $return);
+ $log = ob_get_clean();
+
+ return !$return;
+ }
+
public function run()
{
- $config = new Magallanes_Config;
+ $config = new Mage_Config;
+ $config->loadEnvironment($this->getEnvironment());
+ $config->loadSCM();
switch ($this->getAction()) {
case 'deploy':
- $config->loadEnvironment($this->getEnvironment());
- $task = new Magallanes_Task_Deploy;
+ $task = new Mage_Task_Deploy;
+ $task->run($config);
break;
case 'update';
$config->loadCSM();
- $task = new Magallanes_Task_Update;
+ $task = new Mage_Task_Update;
+ $task->run($config);
break;
}
-
- $task->run($config);
}
}
diff --git a/Magallanes/Console/Colors.php b/Mage/Console/Colors.php
similarity index 98%
rename from Magallanes/Console/Colors.php
rename to Mage/Console/Colors.php
index 3223b73..04d481f 100644
--- a/Magallanes/Console/Colors.php
+++ b/Mage/Console/Colors.php
@@ -1,5 +1,5 @@
_runLocalCommand($command);
+
+ return $result;
+ }
+}
\ No newline at end of file
diff --git a/Mage/Task/BuiltIn/Scm/Update.php b/Mage/Task/BuiltIn/Scm/Update.php
new file mode 100644
index 0000000..ca2a1c9
--- /dev/null
+++ b/Mage/Task/BuiltIn/Scm/Update.php
@@ -0,0 +1,26 @@
+_runLocalCommand($command);
+
+ return $result;
+ }
+}
\ No newline at end of file
diff --git a/Mage/Task/Deploy.php b/Mage/Task/Deploy.php
new file mode 100644
index 0000000..272faf2
--- /dev/null
+++ b/Mage/Task/Deploy.php
@@ -0,0 +1,37 @@
+_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);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Mage/Task/Factory.php b/Mage/Task/Factory.php
new file mode 100644
index 0000000..d37f72d
--- /dev/null
+++ b/Mage/Task/Factory.php
@@ -0,0 +1,16 @@
+setArgs($argv);
$console->parse();
diff --git a/docs/example-config/.mage/config/environment/production.yaml b/docs/example-config/.mage/config/environment/production.yaml
new file mode 100644
index 0000000..485098d
--- /dev/null
+++ b/docs/example-config/.mage/config/environment/production.yaml
@@ -0,0 +1,11 @@
+#production
+user: root
+deploy-from: ./
+deploy-to: /var/www/vhosts/example.com/www
+hosts:
+ - s01.example.com
+ - s02.example.com
+ - s03.example.com
+tasks:
+ - scm/update
+ - deployment/rsync
\ No newline at end of file
diff --git a/docs/example-config/.mage/config/environment/staging.yaml b/docs/example-config/.mage/config/environment/staging.yaml
new file mode 100644
index 0000000..a798aea
--- /dev/null
+++ b/docs/example-config/.mage/config/environment/staging.yaml
@@ -0,0 +1,9 @@
+#staging
+user: stg_example
+deploy-from: application
+deploy-to: /var/www/vhosts/example.com/staging
+hosts:
+ - staging.example.com
+tasks:
+ - scm/update
+ - deployment/rsync
\ No newline at end of file
diff --git a/docs/example-config/.mage/global.yaml b/docs/example-config/.mage/config/global.yaml
similarity index 100%
rename from docs/example-config/.mage/global.yaml
rename to docs/example-config/.mage/config/global.yaml
diff --git a/docs/example-config/.mage/csm.yaml b/docs/example-config/.mage/config/scm.yaml
similarity index 100%
rename from docs/example-config/.mage/csm.yaml
rename to docs/example-config/.mage/config/scm.yaml
diff --git a/docs/example-config/.mage/logs/.gitignore b/docs/example-config/.mage/logs/.gitignore
new file mode 100644
index 0000000..6976a48
--- /dev/null
+++ b/docs/example-config/.mage/logs/.gitignore
@@ -0,0 +1 @@
+log-*
\ No newline at end of file