Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make refresh commands runnable inside container for ddev #205

Merged
merged 8 commits into from
Oct 1, 2024
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
apotek marked this conversation as resolved.
Show resolved Hide resolved
// If a database was downloaded as part of this process, delete it.
if (!$dbPathProvidedByUser) {
$this->deleteDatabase($dbPath);
Expand Down Expand Up @@ -234,6 +235,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")
apotek marked this conversation as resolved.
Show resolved Hide resolved
->run();
}
return $this->taskExec($environmentType)
->arg('drush')
->arg("@$siteDir.$environmentType")
Expand Down Expand Up @@ -315,16 +324,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")
apotek marked this conversation as resolved.
Show resolved Hide resolved
->run();
}

Expand Down
Loading