Skip to content

Commit

Permalink
Refactor taskDrush usage throughout commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
malikkotob committed May 2, 2017
1 parent 8d8b068 commit d143d18
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/Robo/Commands/Acsf/AcsfCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public function acsfDrushInitialize() {
$this->say('Executing initialization command for acsf module.');

$result = $this->taskDrush()
->includePath("{$this->getConfigValue('docroot')}/modules/contrib/acsf/acsf_init")
->alias("")
->drush('acsf-init')
->alias("")
->includePath("{$this->getConfigValue('docroot')}/modules/contrib/acsf/acsf_init")
->run();

$this->say('Please add acsf_init as a dependency for your installation profile to ensure that it remains enabled.');
Expand Down
2 changes: 1 addition & 1 deletion src/Robo/Commands/Blt/DoctorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ protected function executeCommandInDrupalVm($command) {
protected function executeDoctorOnHost($alias) {
$include_dir = $this->getConfigValue('blt.root') . '/drush';
$result = $this->taskDrush()
->drush("blt-doctor")
->alias($alias)
->uri("")
->includePath($include_dir)
->drush("blt-doctor")
->run();

return $result;
Expand Down
2 changes: 1 addition & 1 deletion src/Robo/Commands/Drupal/DrupalCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function ($string) {
->option('account-name', $username, '=')
->option('account-mail', $this->getConfigValue('drupal.account.mail'), '=')
->option('locale', $this->getConfigValue('drupal.locale'), '=')
->option('yes')
->assume(TRUE)
->printOutput(TRUE);

if (!$this->getConfigValue('cm.strategy') == 'features') {
Expand Down
32 changes: 19 additions & 13 deletions src/Robo/Commands/Setup/ConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ public function import() {

$task = $this->taskDrush()
->stopOnFail()
->assume(TRUE)
// Sometimes drush forgets where to find its aliases.
->drush("cc drush --yes")
->drush("pm-enable config --yes")
->drush("cc")->arg('drush')
->drush("pm-enable")->arg('config')
// Rebuild caches in case service definitions have changed.
// @see https://www.drupal.org/node/2826466
->drush("cache-rebuild")
Expand All @@ -47,7 +48,7 @@ public function import() {
// update hook before attempting to import the configuration.
// If a db update relies on updated configuration, you should import the
// necessary configuration file(s) as part of the db update.
->drush("updb --yes");
->drush("updb");

switch ($strategy) {
case 'core-only':
Expand All @@ -71,7 +72,10 @@ public function import() {
// Check for configuration overrides.
if (!$this->getConfigValue('cm.allow-overrides')) {
$this->say("Checking for config overrides...");
$config_overrides = $this->taskDrush()->drush("cex sync -n");
$config_overrides = $this->taskDrush()
->assume(FALSE)
->drush("cex")
->arg('sync');
if (!$config_overrides->run()->wasSuccessful()) {
throw new \Exception("Configuration in the database does not match configuration on disk. You must re-export configuration to capture the changes. This could also indicate a problem with the import process, such as changed field storage for a field with existing content.");
}
Expand All @@ -91,7 +95,7 @@ public function import() {
*/
protected function importCoreOnly($task, $cm_core_key) {
if (file_exists($this->getConfigValue("cm.core.dirs.$cm_core_key.path") . '/core.extension.yml')) {
$task->drush("config-import $cm_core_key --yes");
$task->drush("config-import")->arg($cm_core_key);
}
}

Expand All @@ -107,8 +111,8 @@ protected function importConfigSplit($task) {
// BLT config. Perhaps this should be refactored.
$core_config_file = $this->getConfigValue('docroot') . '/' . $this->getConfigValue('cm.core.dirs.sync.path') . '/core.extension.yml';
if (file_exists($core_config_file)) {
$task->drush("pm-enable config_split --yes");
$task->drush("config-import sync --yes");
$task->drush("pm-enable")->arg('config_split');
$task->drush("config-import")->arg('sync');
}
}

Expand All @@ -119,16 +123,16 @@ protected function importConfigSplit($task) {
* @param $cm_core_key
*/
protected function importFeatures($task, $cm_core_key) {
$task->drush("config-import $cm_core_key --partial --yes");
$task->drush("config-import")->arg($cm_core_key)->option('partial');
if ($this->getConfig()->has('cm.features.bundle"')) {
$task->drush("pm-enable features --yes");
$task->drush("pm-enable")->arg('features');
// Clear drush caches to register features drush commands.
$task->drush("drush cc drush --yes");
$task->drush("cc")->arg('drush');
foreach ($this->getConfigValue('cm.features.bundle') as $bundle) {
$task->drush("features-revert-all --bundle=$bundle --yes");
$task->drush("features-revert-all")->option('bundle', $bundle, '=');
// Revert all features again!
// @see https://www.drupal.org/node/2851532
$task->drush("features-revert-all --bundle=$bundle --yes");
$task->drush("features-revert-all")->option('bundle', $bundle, '=');
}
}
}
Expand All @@ -146,7 +150,9 @@ protected function checkFeaturesOverrides() {
if ($this->getConfig()->has('cm.features.bundle')) {
$task = $this->taskDrush()->stopOnFail();
foreach ($this->getConfigValue('cm.features.bundle') as $bundle) {
$task->drush("fl --bundle='$bundle' --format=json");
$task->drush("fl")
->option('bundle', $bundle, '=')
->option('format', 'json', '=');
$result = $task->printOutput(TRUE)->run();
$output = $result->getOutputData();
$features_overridden = preg_match('/(changed|conflicts|added)( *)$/', $output);
Expand Down
3 changes: 2 additions & 1 deletion src/Robo/Commands/Tests/SecurityUpdatesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class SecurityUpdatesCommand extends BltTasks {
public function testsSecurityUpdates() {
/** @var \Robo\ResultData $result */
$result = $this->taskDrush()
->assume(FALSE)
->assume('')
->uri('')
->drush("-n ups --check-disabled --security-only 2>/dev/null | grep 'SECURITY UPDATE'")
->printOutput(FALSE)
->printMetadata(FALSE)
Expand Down

0 comments on commit d143d18

Please sign in to comment.