Skip to content

Commit

Permalink
Added site:update command
Browse files Browse the repository at this point in the history
  • Loading branch information
tavib47 committed Nov 21, 2018
1 parent 766d7f3 commit 7edb1d5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
3 changes: 2 additions & 1 deletion example.robo.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project:
version: "2.0"
version: "2.1"
sites:
default:
sync:
Expand All @@ -11,3 +11,4 @@ project:
url: https://srv.storage.com/sync/files.tar.gz
develop:
admin_username: user@mail.com
config_split: FALSE
9 changes: 4 additions & 5 deletions src/Robo/Plugin/Commands/CommandBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

/**
Expand Down
31 changes: 29 additions & 2 deletions src/Robo/Plugin/Commands/SiteCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace EauDeWeb\Robo\Plugin\Commands;



use Robo\Robo;
use Symfony\Component\Console\Output\NullOutput;

Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 7edb1d5

Please sign in to comment.