From 28db979e369ce38b72c0be666344ca557f2fc2dc Mon Sep 17 00:00:00 2001 From: Antonio De Marco Date: Tue, 4 Sep 2018 09:47:06 +0200 Subject: [PATCH 1/2] OPENEUROPA-1161: Add --config-dir option do drupal:site-install command. --- src/Commands/DrupalCommands.php | 5 +++++ src/Tasks/Drush/Drush.php | 25 +++++++++++++++++++++---- tests/fixtures/simulation.yml | 12 ++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/Commands/DrupalCommands.php b/src/Commands/DrupalCommands.php index 74a0a537..ff9c87b2 100644 --- a/src/Commands/DrupalCommands.php +++ b/src/Commands/DrupalCommands.php @@ -124,6 +124,7 @@ public function siteInstall(array $options = [ 'database-port' => InputOption::VALUE_REQUIRED, 'database-name' => InputOption::VALUE_REQUIRED, 'sites-subdir' => InputOption::VALUE_REQUIRED, + 'config-dir' => InputOption::VALUE_OPTIONAL, ]) { if ($options['database-type']) { @@ -149,6 +150,10 @@ public function siteInstall(array $options = [ ->sitesSubdir($options['sites-subdir']) ->siteProfile($options['site-profile']); + if ($options['config-dir']) { + $task->setConfigDir($options['config-dir']); + } + return $this->collectionBuilder()->addTaskList([ $this->sitePreInstall(), $task->siteInstall(), diff --git a/src/Tasks/Drush/Drush.php b/src/Tasks/Drush/Drush.php index 39f0f7e1..d69f9f3f 100644 --- a/src/Tasks/Drush/Drush.php +++ b/src/Tasks/Drush/Drush.php @@ -29,6 +29,7 @@ class Drush extends Exec protected $databasePassword = ''; protected $databaseName = ''; protected $sitesSubdir = ''; + protected $configDir = ''; /** * Build Drush site install command. @@ -47,7 +48,7 @@ public function siteInstall() ]; $dbUrl = http_build_url($dbArray, $dbArray); - return $this->option('-y') + $this->option('-y') ->rawArg("--root=$(pwd)/".$this->root) ->options([ 'site-name' => $this->siteName, @@ -58,9 +59,13 @@ public function siteInstall() 'account-pass' => $this->accountPassword, 'sites-subdir' => $this->sitesSubdir, 'db-url' => $dbUrl, - ], '=') - ->arg('site-install') - ->arg($this->siteProfile); + ], '='); + + if (!empty($this->configDir)) { + $this->option('config-dir', $this->configDir, '='); + } + + return $this->arg('site-install')->arg($this->siteProfile); } /** @@ -254,4 +259,16 @@ public function sitesSubdir($sitesSubdir) return $this; } + + /** + * @param string $configDir + * + * @return Drush + */ + public function setConfigDir($configDir) + { + $this->configDir = $configDir; + + return $this; + } } diff --git a/tests/fixtures/simulation.yml b/tests/fixtures/simulation.yml index 7064e46b..2cfedcf1 100644 --- a/tests/fixtures/simulation.yml +++ b/tests/fixtures/simulation.yml @@ -59,6 +59,18 @@ contains: - "./bin/drush -y --root=$(pwd)/overridden" +- command: 'drupal:site-install --site-name="Test site" --config-dir="../config-dir"' + configuration: + drupal: + database: + name: "drupal" + user: "root" + password: "root" + composer: '' + contains: + - "[Simulator] Running ./vendor/bin/drush -y --root=$(pwd)/build --site-name='Test site' --site-mail=info@example.org --locale=en --account-mail=admin@example.org --account-name=admin --account-pass=admin --sites-subdir=default --db-url='mysql://root:root@127.0.0.1:3306/drupal' --config-dir=../config-dir site-install standard" + + - command: 'changelog:generate' configuration: github: From 1aa3e74c3e65320f2b5601feabec327c67650a3c Mon Sep 17 00:00:00 2001 From: Antonio De Marco Date: Tue, 4 Sep 2018 09:59:23 +0200 Subject: [PATCH 2/2] OPENEUROPA-1161: Make sure config dir can be set in YAML. --- config/commands/drupal.yml | 1 + config/runner.yml | 1 + src/Commands/DrupalCommands.php | 5 +++-- tests/fixtures/simulation.yml | 12 ++++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/config/commands/drupal.yml b/config/commands/drupal.yml index ead2e6c5..4d72932f 100644 --- a/config/commands/drupal.yml +++ b/config/commands/drupal.yml @@ -23,6 +23,7 @@ command: database-user: ${drupal.database.user} database-password: ${drupal.database.password} sites-subdir: ${drupal.site.sites_subdir} + config-dir: ${drupal.site.config_dir} drush-setup: options: config-dir: ${drupal.root}/drush diff --git a/config/runner.yml b/config/runner.yml index e3622d13..9475e9d2 100644 --- a/config/runner.yml +++ b/config/runner.yml @@ -31,6 +31,7 @@ drupal: update: "false" locale: "en" sites_subdir: "default" + config_dir: ~ # Administrator account information. account: diff --git a/src/Commands/DrupalCommands.php b/src/Commands/DrupalCommands.php index ff9c87b2..88e7e29b 100644 --- a/src/Commands/DrupalCommands.php +++ b/src/Commands/DrupalCommands.php @@ -98,6 +98,7 @@ public function validateSiteInstall(CommandData $commandData) * @option database-user Database username. * @option database-password Database password. * @option sites-subdir Sites sub-directory. + * @option config-dir Config export directory. * * @aliases drupal:si,dsi * @@ -124,7 +125,7 @@ public function siteInstall(array $options = [ 'database-port' => InputOption::VALUE_REQUIRED, 'database-name' => InputOption::VALUE_REQUIRED, 'sites-subdir' => InputOption::VALUE_REQUIRED, - 'config-dir' => InputOption::VALUE_OPTIONAL, + 'config-dir' => InputOption::VALUE_REQUIRED, ]) { if ($options['database-type']) { @@ -150,7 +151,7 @@ public function siteInstall(array $options = [ ->sitesSubdir($options['sites-subdir']) ->siteProfile($options['site-profile']); - if ($options['config-dir']) { + if (!empty($options['config-dir'])) { $task->setConfigDir($options['config-dir']); } diff --git a/tests/fixtures/simulation.yml b/tests/fixtures/simulation.yml index 2cfedcf1..e8651cbe 100644 --- a/tests/fixtures/simulation.yml +++ b/tests/fixtures/simulation.yml @@ -70,6 +70,18 @@ contains: - "[Simulator] Running ./vendor/bin/drush -y --root=$(pwd)/build --site-name='Test site' --site-mail=info@example.org --locale=en --account-mail=admin@example.org --account-name=admin --account-pass=admin --sites-subdir=default --db-url='mysql://root:root@127.0.0.1:3306/drupal' --config-dir=../config-dir site-install standard" +- command: 'drupal:site-install --site-name="Test site"' + configuration: + drupal: + site: + config_dir: "../config/sync" + database: + name: "drupal" + user: "root" + password: "root" + composer: '' + contains: + - "[Simulator] Running ./vendor/bin/drush -y --root=$(pwd)/build --site-name='Test site' --site-mail=info@example.org --locale=en --account-mail=admin@example.org --account-name=admin --account-pass=admin --sites-subdir=default --db-url='mysql://root:root@127.0.0.1:3306/drupal' --config-dir=../config/sync site-install standard" - command: 'changelog:generate' configuration: