From 3e268d0626fa5d4300c7c5122fd1e6fc2859c417 Mon Sep 17 00:00:00 2001 From: Francesco Abeni Date: Thu, 29 Oct 2015 14:52:04 +0100 Subject: [PATCH 1/2] Add config param for local cms folder --- RoboFile.dist.ini | 3 ++- RoboFile.php | 33 ++++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/RoboFile.dist.ini b/RoboFile.dist.ini index 2980766..8d3a728 100644 --- a/RoboFile.dist.ini +++ b/RoboFile.dist.ini @@ -1 +1,2 @@ -skipClone = true \ No newline at end of file +skipClone = true +cmsPath = /path/to/my/local/website/root \ No newline at end of file diff --git a/RoboFile.php b/RoboFile.php index a104e85..216acce 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -19,6 +19,8 @@ class RoboFile extends \Robo\Tasks private $configuration = array(); + private $cmsPath = ''; + /** * Set the Execute extension for Windows Operating System * @@ -44,6 +46,8 @@ class RoboFile extends \Robo\Tasks { $this->configuration = $this->getConfiguration(); + $this->cmsPath = $this->getCmsPath(); + $this->setExecExtension(); $this->createTestingSite(); @@ -165,18 +169,18 @@ class RoboFile extends \Robo\Tasks public function createTestingSite() { if (!empty($this->configuration->skipClone)) { - $this->say('Reusing Joomla CMS site already present at tests/joomla-cms3'); + $this->say('Reusing Joomla CMS site already present at ' . $this->cmsPath); return; } // Get Joomla Clean Testing sites - if (is_dir('tests/joomla-cms3')) + if (is_dir($this->cmsPath)) { - $this->taskDeleteDir('tests/joomla-cms3')->run(); + $this->taskDeleteDir($this->cmsPath)->run(); } - $this->_exec('git' . $this->extension . ' clone -b staging --single-branch --depth 1 https://github.com/joomla/joomla-cms.git tests/joomla-cms3'); - $this->say('Joomla CMS site created at tests/joomla-cms3'); + $this->_exec('git' . $this->extension . ' clone -b staging --single-branch --depth 1 https://github.com/joomla/joomla-cms.git ' . $this->cmsPath); + $this->say('Joomla CMS site created at ' . $this->cmsPath); } /** @@ -202,6 +206,25 @@ class RoboFile extends \Robo\Tasks return json_decode(json_encode($configuration)); } + /** + * Get the correct CMS root path + * + * @return string + */ + private function getCmsPath() + { + if (empty($this->configuration->cmsPath)) { + return 'tests/joomla-cms3'; + } + + if (!file_exists(dirname($this->configuration->cmsPath))) { + $this->say("Cms path written in local configuration does not exists or is not readable"); + return 'tests/joomla-cms3'; + } + + return $this->configuration->cmsPath; + } + /** * Runs Selenium Standalone Server. * From 08c2f8b641b2ebad62ee51390fe8f8f77c0fc48e Mon Sep 17 00:00:00 2001 From: Francesco Abeni Date: Thu, 29 Oct 2015 16:06:04 +0100 Subject: [PATCH 2/2] Improve dist.ini file and fix CS --- RoboFile.dist.ini | 8 ++++++-- RoboFile.php | 15 ++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/RoboFile.dist.ini b/RoboFile.dist.ini index 8d3a728..615510f 100644 --- a/RoboFile.dist.ini +++ b/RoboFile.dist.ini @@ -1,2 +1,6 @@ -skipClone = true -cmsPath = /path/to/my/local/website/root \ No newline at end of file +; If set to true, the repo will not be cloned from GitHub and the local copy will be reused. +; This setting will be obsolete once we have local Git cache enabled +skipClone = false +; If you want to setup your test website in a different folder, you can do that here. +; You can also set an absolute path, i.e. /path/to/my/cms/folder +cmsPath = tests/joomla-cms3 \ No newline at end of file diff --git a/RoboFile.php b/RoboFile.php index 216acce..48e8daf 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -168,7 +168,8 @@ class RoboFile extends \Robo\Tasks */ public function createTestingSite() { - if (!empty($this->configuration->skipClone)) { + if (!empty($this->configuration->skipClone)) + { $this->say('Reusing Joomla CMS site already present at ' . $this->cmsPath); return; } @@ -192,13 +193,15 @@ class RoboFile extends \Robo\Tasks { $configurationFile = __DIR__ . '/RoboFile.ini'; - if (!file_exists($configurationFile)) { + if (!file_exists($configurationFile)) + { $this->say("No local configuration file"); return null; } $configuration = parse_ini_file($configurationFile); - if ($configuration === false) { + if ($configuration === false) + { $this->say('Local configuration file is empty or wrong (check is it in correct .ini format'); return null; } @@ -213,11 +216,13 @@ class RoboFile extends \Robo\Tasks */ private function getCmsPath() { - if (empty($this->configuration->cmsPath)) { + if (empty($this->configuration->cmsPath)) + { return 'tests/joomla-cms3'; } - if (!file_exists(dirname($this->configuration->cmsPath))) { + if (!file_exists(dirname($this->configuration->cmsPath))) + { $this->say("Cms path written in local configuration does not exists or is not readable"); return 'tests/joomla-cms3'; }