diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9ec525e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +charset = utf-8 +trim_trailing_whitespace = true + +[*.{json,lock,yml,less,scss,sass}] +indent_size = 2 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 13a647c..389c556 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,13 @@ language: php +notifications: + webhooks: + urls: + - https://webhooks.gitter.im/e/edf0bb825450673efbf5 + on_success: change + on_failure: always + on_start: never + php: - 5.3 - 5.4 diff --git a/Mage/Config.php b/Mage/Config.php index 3f70f6c..18e45c3 100644 --- a/Mage/Config.php +++ b/Mage/Config.php @@ -147,13 +147,25 @@ class Config $configFilePath = getcwd() . '/.mage/config/environment/' . $environment . '.yml'; try { - $this->environmentConfig = $this->loadEnvironment($configFilePath); + $defaults = $this->getDefaultEnvironment(); + $environmentConfig = $this->loadEnvironment($configFilePath); + $this->environmentConfig = array_replace_recursive($defaults, $environmentConfig); } catch (ConfigNotFoundException $e) { throw new RequiredConfigNotFoundException("Not found required config $configFilePath for environment $environment", 0, $e); } } } + /** + * Returns the default environment configuration from general configuration + * + * @return array the default environment configuration + */ + protected function getDefaultEnvironment() { + $defaults = $this->general('defaults', null); + return !empty($defaults) ? $defaults : array(); + } + /** * * @param array $parameters diff --git a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php index 7d6b72d..ae0d04d 100644 --- a/Mage/Task/BuiltIn/Deployment/ReleaseTask.php +++ b/Mage/Task/BuiltIn/Deployment/ReleaseTask.php @@ -110,7 +110,7 @@ class ReleaseTask extends AbstractTask implements IsReleaseAware, SkipOnOverride if ($resultFetch && $userGroup != '') { $command.= " && chown -h {$userGroup} {$tmplink}"; } - $command.= " && mv -fT {$tmplink} {$symlink}"; + $command.= " && rm -rf {$symlink} && mv -f {$tmplink} {$symlink}"; $result = $this->runCommandRemote($command); if ($result) { diff --git a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php index d0ee3d4..29866fa 100644 --- a/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php +++ b/Mage/Task/BuiltIn/Deployment/Strategy/RsyncTask.php @@ -75,10 +75,10 @@ class RsyncTask extends BaseStrategyTaskAbstract implements IsReleaseAware // If copy_tool_rsync, use rsync rather than cp for finer control of what is copied if ($rsync_copy && is_array($rsync_copy) && $rsync_copy['copy'] && $this->runCommandRemote('test -d ' . $releasesDirectory . '/' . $currentRelease)) { if (isset($rsync_copy['copy_tool_rsync'])) { - $this->runCommandRemote("rsync -a {$this->excludes(array_merge($excludes, $rsync_copy['rsync_excludes']))} " + $this->runCommandRemote("rsync -rlptgom {$this->excludes(array_merge($excludes, $rsync_copy['rsync_excludes']))} " . "$releasesDirectory/$currentRelease/ $releasesDirectory/{$this->getConfig()->getReleaseId()}"); } else { - $this->runCommandRemote('cp -R ' . $releasesDirectory . '/' . $currentRelease . ' ' . $releasesDirectory . '/' . $this->getConfig()->getReleaseId()); + $this->runCommandRemote('cp -a ' . $releasesDirectory . '/' . $currentRelease . ' ' . $releasesDirectory . '/' . $this->getConfig()->getReleaseId()); } } else { $this->runCommandRemote('mkdir -p ' . $releasesDirectory . '/' . $this->getConfig()->getReleaseId()); diff --git a/Mage/Task/BuiltIn/Releases/RollbackTask.php b/Mage/Task/BuiltIn/Releases/RollbackTask.php index 9d9fb4b..dca8767 100644 --- a/Mage/Task/BuiltIn/Releases/RollbackTask.php +++ b/Mage/Task/BuiltIn/Releases/RollbackTask.php @@ -140,7 +140,7 @@ class RollbackTask extends AbstractTask implements IsReleaseAware if ($resultFetch && $userGroup) { $command .= " && chown -h {$userGroup} ${tmplink}"; } - $command .= " && mv -T {$tmplink} {$symlink}"; + $command .= " && mv -f {$tmplink} {$symlink}"; $result = $this->runCommandRemote($command); diff --git a/Mage/Task/Factory.php b/Mage/Task/Factory.php index 9384d4c..536e377 100644 --- a/Mage/Task/Factory.php +++ b/Mage/Task/Factory.php @@ -45,13 +45,31 @@ class Factory $taskName = ucwords(str_replace('-', ' ', $taskName)); $taskName = str_replace(' ', '', $taskName); - if (strpos($taskName, '/') === false) { - $className = 'Task\\' . $taskName; - } else { - $className = 'Mage\\Task\\BuiltIn\\' . str_replace(' ', '\\', ucwords(str_replace('/', ' ', $taskName))) . 'Task'; + $patterns = []; + + if (is_array($taskConfig->general('taskPatterns'))) { + $patterns = $taskConfig->general('taskPatterns'); } - if (!class_exists($className)) { + $patterns[] = 'Task\\%s'; + $patterns[] = 'Mage\\Task\\BuiltIn\\%sTask'; + + $className = null; + + $taskClass = trim($taskName, '/\\'); + $taskClass = str_replace(' ', '\\', ucwords(str_replace('/', ' ', $taskClass))); + $taskClass = str_replace(' ', '', ucwords(str_replace('-', ' ', $taskClass))); + + foreach ($patterns as $pattern) { + $possibleClass = sprintf($pattern, $taskClass); + + if (class_exists($possibleClass)) { + $className = $possibleClass; + break; + } + } + + if (!$className) { throw new Exception('Task "' . $taskName . '" not found.'); } diff --git a/README.md b/README.md index 9fe1b3b..20f54f2 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,11 @@ # Magallanes # +This repository is a fork of [andres-montanez/Magallanes](https://github.com/andres-montanez/Magallanes) due to project inactivity. -[![SensioLabsInsight](https://insight.sensiolabs.com/projects/ed0de53a-a12e-459b-9464-34def5907b56/mini.png)](https://insight.sensiolabs.com/projects/ed0de53a-a12e-459b-9464-34def5907b56) -[![Build Status](https://travis-ci.org/andres-montanez/Magallanes.svg?branch=master)](https://travis-ci.org/andres-montanez/Magallanes) -[![Coverage Status](https://coveralls.io/repos/andres-montanez/Magallanes/badge.svg?branch=master)](https://coveralls.io/r/andres-montanez/Magallanes?branch=master) +### Project Status +| Branch | Build Status | Code Coverage | +| ------- |:------------:|:-------------:| +| master | [![Build Status](https://travis-ci.org/cyberhouse/Magallanes.svg?branch=master)](https://travis-ci.org/cyberhouse/Magallanes) | [![Coverage Status](https://coveralls.io/repos/github/cyberhouse/Magallanes/badge.svg?branch=master)](https://coveralls.io/github/cyberhouse/Magallanes?branch=master) | +| 2.0 | [![Build Status](https://travis-ci.org/cyberhouse/Magallanes.svg?branch=2.0)](https://travis-ci.org/cyberhouse/Magallanes) | [![Coverage Status](https://coveralls.io/repos/github/cyberhouse/Magallanes/badge.svg?branch=2.0)](https://coveralls.io/github/cyberhouse/Magallanes?branch=2.0) | ### What's Magallanes? ### Magallanes is a deployment tool for PHP applications; it's quite simple to use and manage. diff --git a/composer.json b/composer.json index 5be1dd8..6042896 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,27 @@ { - "name": "andres-montanez/magallanes", + "name": "cyberhouse/magallanes", "description": "A Deployment Tool for PHP Applications", "homepage": "http://magephp.com", "license": "MIT", "type": "library", + "authors": [ + { + "name": "Andrés Montañez", + "role": "Developer" + }, + { + "name": "Johannes Pichler", + "email": "johannes.pichler@cyberhouse.at", + "homepage": "https://www.cyberhouse.at", + "role": "Developer" + }, + { + "name": "Georg Großberger", + "email": "georg.grossberger@cyberhouse.ats", + "homepage": "https://www.cyberhouse.at", + "role": "Developer" + } + ], "keywords": ["deployment"], "require": { "php": ">=5.4" diff --git a/docs/example-config/.mage/config/general.yml b/docs/example-config/.mage/config/general.yml index c3a9b6d..6ae9298 100644 --- a/docs/example-config/.mage/config/general.yml +++ b/docs/example-config/.mage/config/general.yml @@ -7,3 +7,27 @@ verbose_logging: false scm: type: git url: git://github.com/andres-montanez/Zend-Framework-Twig-example-app.git +defaults: + deployment: + user: root + from: ./ + to: /var/www/vhosts/example.com/www + excludes: + - application/data/cache/twig/* + releases: + enabled: true + max: 5 + symlink: current + directory: releases + hosts: + - s01.example.com + - s02.example.com + tasks: + pre-deploy: + - scm/update + on-deploy: + - symfony2/cache-warmup: { env: prod } + - privileges + - sampleTask + - sampleTaskRollbackAware + verbose_logging: true \ No newline at end of file