diff --git a/.editorconfig b/.editorconfig index 686c443c..2b58ad65 100644 --- a/.editorconfig +++ b/.editorconfig @@ -8,10 +8,13 @@ root = true [*] end_of_line = LF indent_style = space -indent_size = 2 +indent_size = 4 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [composer.{json,lock}] indent_size = 4 + +[*.yml] +indent_size = 2 diff --git a/config/runner.yml b/config/runner.yml index efbc48d2..9d380200 100644 --- a/config/runner.yml +++ b/config/runner.yml @@ -37,6 +37,9 @@ drupal: config_dir: ~ existing_config: false settings_override_file: "settings.override.php" + # Setting this to "false" will run "site-install" without the "--db-url" parameter. + # This is useful if the database settings are already set in your settings.php file. + generate_db_url: true # Administrator account information. account: diff --git a/src/Commands/AbstractDrupalCommands.php b/src/Commands/AbstractDrupalCommands.php index 2066e248..e74e4f30 100644 --- a/src/Commands/AbstractDrupalCommands.php +++ b/src/Commands/AbstractDrupalCommands.php @@ -186,6 +186,8 @@ public function siteInstall(array $options = [ ->sitesSubdir($options['sites-subdir']) ->siteProfile($options['site-profile']); + $task->setGenerateDbUrl($this->getConfig()->get('drupal.site.generate_db_url')); + if (!empty($options['existing-config'])) { $task->setExistingConfig($options['existing-config']); } diff --git a/src/Tasks/Drush/Drush.php b/src/Tasks/Drush/Drush.php index eb45332e..447e0d40 100644 --- a/src/Tasks/Drush/Drush.php +++ b/src/Tasks/Drush/Drush.php @@ -30,6 +30,7 @@ class Drush extends Exec protected $databaseName = ''; protected $sitesSubdir = ''; protected $existingConfig = false; + protected $generateDbUrl = true; /** * Build Drush site install command. @@ -38,16 +39,6 @@ class Drush extends Exec */ public function siteInstall() { - $dbArray = [ - 'scheme' => $this->databaseScheme, - 'user' => $this->databaseUser, - 'pass' => $this->databasePassword, - 'host' => $this->databaseHost, - 'port' => $this->databasePort, - 'path' => $this->databaseName, - ]; - $dbUrl = http_build_url($dbArray, $dbArray); - $this->option('-y') ->rawArg("--root=$(pwd)/".$this->root) ->options([ @@ -58,9 +49,22 @@ public function siteInstall() 'account-name' => $this->accountName, 'account-pass' => $this->accountPassword, 'sites-subdir' => $this->sitesSubdir, - 'db-url' => $dbUrl, ], '='); + if ($this->generateDbUrl) { + $dbArray = [ + 'scheme' => $this->databaseScheme, + 'user' => $this->databaseUser, + 'pass' => $this->databasePassword, + 'host' => $this->databaseHost, + 'port' => $this->databasePort, + 'path' => $this->databaseName, + ]; + $dbUrl = http_build_url($dbArray, $dbArray); + + $this->option('db-url', $dbUrl, '='); + } + if (!empty($this->existingConfig)) { $this->option('existing-config'); } @@ -271,4 +275,16 @@ public function setExistingConfig($existingConfig) return $this; } + + /** + * @param bool $generateDbUrl + * + * @return Drush + */ + public function setGenerateDbUrl($generateDbUrl) + { + $this->generateDbUrl = $generateDbUrl; + + return $this; + } } diff --git a/tests/fixtures/simulation.yml b/tests/fixtures/simulation.yml index f046db43..434203e8 100644 --- a/tests/fixtures/simulation.yml +++ b/tests/fixtures/simulation.yml @@ -346,3 +346,13 @@ - "./vendor/bin/drush -y" not_contains: - "--existing-config" + +- command: "drupal:site-install" + configuration: + drupal: + site: + generate_db_url: false + composer: '' + contains: [] + not_contains: + - "--db-url='mysql://127.0.0.1:3306'"