Skip to content

Commit

Permalink
Make refresh commands runnable inside container for ddev (#205)
Browse files Browse the repository at this point in the history
* Run refresh commands inside container for ddev
* Only implement one local development type because that's all we have.

Resolves: #204
  • Loading branch information
apotek authored Oct 1, 2024
1 parent 62b1703 commit 50021f7
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions src/Robo/Plugin/Commands/DevelopmentModeCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,15 @@ public function databaseRefreshDdev(string $siteName = 'default', array $options
$dbPath = $this->databaseDownload($siteName);
}

$this->io()->section("importing $siteName database.");
$this->say("Importing $dbPath");
$this->taskExec(LocalDevEnvironmentTypes::DDEV->value)
->arg('import-db')
->option('database', $siteName === 'default' ? 'db' : $siteName)
->option('file', $dbPath)
$this->io()->section("refreshing $siteName database.");
$this->say("Dropping existing database for $siteName");
$this->taskExec('drush')
->arg('sql:drop')
->option('uri', $siteName)
->option('yes')
->run();

$this->say("Importing $dbPath");
$this->_exec("zcat '$dbPath' | drush sql:cli --uri=$siteName");
// If a database was downloaded as part of this process, delete it.
if (!$dbPathProvidedByUser) {
$this->deleteDatabase($dbPath);
Expand Down Expand Up @@ -226,6 +227,14 @@ public function drupalLoginLink(
): Result {
$this->io()->section("create login link.");
$uid = $this->getDrupalSiteAdminUid(siteName: $siteDir);
if ($environmentType === 'ddev') {
return $this->taskExec('drush')
->arg("@$siteDir.$environmentType")
->arg('user:login')
->option("--uid=$uid")
->dir("$this->drupalRoot/sites/$siteDir")
->run();
}
return $this->taskExec($environmentType)
->arg('drush')
->arg("@$siteDir.$environmentType")
Expand Down Expand Up @@ -307,16 +316,18 @@ protected function drushDeployWith(
"'drush deploy' command not found. Further work is necessary to support this version of Drush."
);
}
// After drush deploy, re-import the latest configuration. This includes
// the latest configuration_split configuration. Importing this twice
// ensures that the latter command enables and disables modules based
// upon the most up--to-date configuration. More at:
// https://github.com/drush-ops/drush/issues/2449#issuecomment-708655673

// Currently we only have one local environment type:
// LocalDevEnvironmentTypes::DDEV, so no need for other implementations.
return $this->taskExecStack()
->dir("$this->drupalRoot/sites/$siteDir")
->exec("$localEnvironmentType->value drush @$siteDir.$localEnvironmentType->value deploy --yes")
// Import the latest configuration again. This includes the latest
// configuration_split configuration. Importing this twice ensures that
// the latter command enables and disables modules based upon the most up
// to date configuration. Additional information and discussion can be
// found here:
// https://github.com/drush-ops/drush/issues/2449#issuecomment-708655673
->exec("$localEnvironmentType->value drush @$siteDir.$localEnvironmentType->value config:import --yes")
->exec("drush @$siteDir.$localEnvironmentType->value deploy --yes")
->exec("drush @$siteDir.$localEnvironmentType->value config:import --yes")
->run();
}

Expand Down

0 comments on commit 50021f7

Please sign in to comment.