diff --git a/example.robo.yml b/example.robo.yml index 8ca8563..40a709c 100644 --- a/example.robo.yml +++ b/example.robo.yml @@ -1,5 +1,5 @@ project: - version: "2.0" + version: "2.1" sites: default: sync: @@ -11,3 +11,4 @@ project: url: https://srv.storage.com/sync/files.tar.gz develop: admin_username: user@mail.com + config_split: FALSE diff --git a/src/Robo/Plugin/Commands/CommandBase.php b/src/Robo/Plugin/Commands/CommandBase.php index 32c3ffa..7b419d8 100644 --- a/src/Robo/Plugin/Commands/CommandBase.php +++ b/src/Robo/Plugin/Commands/CommandBase.php @@ -16,7 +16,7 @@ */ class CommandBase extends \Robo\Tasks { - const FILE_FORMAT_VERSION = '2.0'; + const FILE_FORMAT_VERSION = '2.1'; /** * Check configuration file consistency. @@ -62,12 +62,11 @@ protected function config($key) { protected function configSite($key, $site = 'default') { $config = Robo::config(); $full = 'project.sites.' . $site . '.' . $key; - if ($value = $config->get($full)) { - return $value; - } else { + $value = $config->get($full); + if ($value === NULL) { $this->yell('Missing configuration key: ' . $full); } - return null; + return $value; } /** diff --git a/src/Robo/Plugin/Commands/SiteCommands.php b/src/Robo/Plugin/Commands/SiteCommands.php index e6fd660..328689f 100644 --- a/src/Robo/Plugin/Commands/SiteCommands.php +++ b/src/Robo/Plugin/Commands/SiteCommands.php @@ -2,8 +2,6 @@ namespace EauDeWeb\Robo\Plugin\Commands; - - use Robo\Robo; use Symfony\Component\Console\Output\NullOutput; @@ -57,6 +55,35 @@ public function siteDevelop($newPassword = 'password') { } } + /** + * Update the local instance: import configuration, update database, rebuild + * cache. + * + * @command site:update + * + * @return null|\Robo\Result + * @throws \EauDeWeb\Robo\InvalidConfigurationException + * @throws \Robo\Exception\TaskException + */ + public function siteUpdate() { + $this->validateConfig(); + $drush = $this->drushExecutable(); + // Allow updatedb to fail once and execute it again after config:import. + $this->taskExec("{$drush} updatedb -y")->run(); + $execStack = $this->taskExecStack()->stopOnFail(TRUE); + $execStack->exec("{$drush} cr"); + if ($this->configSite('develop.config_split') === TRUE) { + $execStack->exec("{$drush} csim -y"); + } + else { + $execStack->exec("{$drush} cim sync -y"); + } + $execStack->exec("{$drush} updatedb -y"); + $execStack->exec("{$drush} entup -y"); + $execStack->exec("{$drush} cr"); + return $execStack->run(); + } + /** * Create new configuration file. *