diff --git a/composer.json b/composer.json index e8bae9d5..6a5ec702 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ "consolidation/robo": "^4.0", "gitonomy/gitlib": "^1.0", "jakeasmith/http_build_url": "^1.0.1", - "nuvoleweb/robo-config": "^3.0.0" + "nuvoleweb/robo-config": "^3.0.0", + "grasmash/expander": ">=3" }, "require-dev": { "openeuropa/code-review": "2.x-dev", diff --git a/config/commands/drupal.yml b/config/commands/drupal.yml index b70aa52b..89ec8742 100644 --- a/config/commands/drupal.yml +++ b/config/commands/drupal.yml @@ -27,6 +27,8 @@ command: # @deprecated # Should only be used with Drupal 8.5 and lower. Use "existing-config". config-dir: ${drupal.site.config_dir} + enable-update-status-module: ${drupal.install.update_status_module} + enable-update-status-emails: ${drupal.install.update_status_emails} drush-setup: options: config-dir: ${drupal.root}/drush diff --git a/config/runner.yml b/config/runner.yml index a272a691..0bc6073c 100644 --- a/config/runner.yml +++ b/config/runner.yml @@ -40,6 +40,11 @@ drupal: # 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 + install: + # Setting this to "false" will tell the "site-install" command to not enable the update status module. + update_status_module: true + # Setting this to "false" will tell the "site-install" command to disable email notifications about updates. + update_status_emails: true # Administrator account information. account: diff --git a/src/Commands/AbstractDrupalCommands.php b/src/Commands/AbstractDrupalCommands.php index ce95af1b..77982585 100644 --- a/src/Commands/AbstractDrupalCommands.php +++ b/src/Commands/AbstractDrupalCommands.php @@ -113,26 +113,28 @@ public function validateSiteInstall(CommandData $commandData) * * @command drupal:site-install * - * @option root Drupal root. - * @option site-name Site name. - * @option site-mail Site mail. - * @option site-profile Installation profile - * @option site-update Whereas to enable the update module or not. - * @option site-locale Default site locale. - * @option account-name Admin account name. - * @option account-password Admin account password. - * @option account-mail Admin email. - * @option database-type Deprecated, use "database-scheme" - * @option database-scheme Database scheme. - * @option database-host Database host. - * @option database-port Database port. - * @option database-name Database name. - * @option database-user Database username. - * @option database-password Database password. - * @option sites-subdir Sites sub-directory. - * @option config-dir Deprecated, use "existing-config" for Drupal 8.6 and higher. - * @option existing-config Whether existing config should be imported during installation. - * @option skip-permissions-setup Whether to skip making the settings file and folder writable during installation. + * @option root Drupal root. + * @option site-name Site name. + * @option site-mail Site mail. + * @option site-profile Installation profile + * @option site-update Whereas to enable the update module or not. + * @option site-locale Default site locale. + * @option account-name Admin account name. + * @option account-password Admin account password. + * @option account-mail Admin email. + * @option database-type Deprecated, use "database-scheme" + * @option database-scheme Database scheme. + * @option database-host Database host. + * @option database-port Database port. + * @option database-name Database name. + * @option database-user Database username. + * @option database-password Database password. + * @option sites-subdir Sites sub-directory. + * @option config-dir Deprecated, use "existing-config" for Drupal 8.6 and higher. + * @option existing-config Whether existing config should be imported during installation. + * @option skip-permissions-setup Whether to skip making the settings file and folder writable during installation. + * @option enable-update-status-module Check for updates automatically. + * @option enable-update-status-emails Receive email notifications regarding updates. * * @aliases drupal:si,dsi * @@ -162,6 +164,8 @@ public function siteInstall(array $options = [ 'config-dir' => InputOption::VALUE_REQUIRED, 'existing-config' => false, 'skip-permissions-setup' => false, + 'enable-update-status-module' => true, + 'enable-update-status-emails' => true, ]) { if ($options['database-type']) { @@ -174,6 +178,10 @@ public function siteInstall(array $options = [ $options['existing-config'] = true; } + // Pass value as boolean type only. + $options['enable-update-status-module'] = filter_var($options['enable-update-status-module'], FILTER_VALIDATE_BOOLEAN); + $options['enable-update-status-emails'] = filter_var($options['enable-update-status-emails'], FILTER_VALIDATE_BOOLEAN); + $drush = $this->getConfig()->get('runner.bin_dir') . '/drush'; $task = $this->taskDrush($drush) ->root($options['root']) @@ -190,7 +198,9 @@ public function siteInstall(array $options = [ ->databasePort($options['database-port']) ->databaseName($options['database-name']) ->sitesSubdir($options['sites-subdir']) - ->siteProfile($options['site-profile']); + ->siteProfile($options['site-profile']) + ->enableUpdateStatusModuleOnInstall($options['enable-update-status-module']) + ->enableUpdateStatusEmailsOnInstall($options['enable-update-status-emails']); $task->setGenerateDbUrl($this->getConfig()->get('drupal.site.generate_db_url')); diff --git a/src/Tasks/Drush/Drush.php b/src/Tasks/Drush/Drush.php index 46cbc71f..55cbe4e0 100644 --- a/src/Tasks/Drush/Drush.php +++ b/src/Tasks/Drush/Drush.php @@ -31,6 +31,8 @@ class Drush extends Exec protected $sitesSubdir = ''; protected $existingConfig = false; protected $generateDbUrl = true; + protected $updateStatusModule = true; + protected $updateStatusEmails = true; /** * Build Drush site install command. @@ -69,7 +71,11 @@ public function siteInstall() $this->option('existing-config'); } - return $this->arg('site-install')->arg($this->siteProfile); + return $this->arg('site-install') + ->arg($this->siteProfile) + // Adapt values for the installation configuration form parameters. + ->rawArg('install_configure_form.enable_update_status_module=' . ($this->updateStatusModule ? 'true' : 'NULL')) + ->rawArg('install_configure_form.enable_update_status_emails=' . ($this->updateStatusEmails ? 'true' : 'NULL')); } /** @@ -287,4 +293,28 @@ public function setGenerateDbUrl($generateDbUrl) return $this; } + + /** + * @param bool $enable + * + * @return Drush + */ + public function enableUpdateStatusModuleOnInstall($enable) + { + $this->updateStatusModule = $enable; + + return $this; + } + + /** + * @param bool $enable + * + * @return Drush + */ + public function enableUpdateStatusEmailsOnInstall($enable) + { + $this->updateStatusEmails = $enable; + + return $this; + } } diff --git a/tests/fixtures/simulation.yml b/tests/fixtures/simulation.yml index 376cd4a9..ad612bd4 100644 --- a/tests/fixtures/simulation.yml +++ b/tests/fixtures/simulation.yml @@ -8,6 +8,7 @@ composer: '' contains: - "[Simulator] Running ./vendor/bin/drush -y --root=$(pwd)/build --site-name='Site name' --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' site-install standard" + - "site-install standard install_configure_form.enable_update_status_module=true install_configure_form.enable_update_status_emails=true" - command: 'drupal:site-install --site-name="Test site"' configuration: @@ -374,3 +375,111 @@ composer: '' contains: - "./vendor/bin/drush --root=foo" + +- command: 'drupal:site-install --enable-update-status-module=false --enable-update-status-emails=false' + configuration: {} + composer: '' + contains: + - "standard install_configure_form.enable_update_status_module=NULL install_configure_form.enable_update_status_emails=NULL" + +- command: 'drupal:site-install --enable-update-status-module= --enable-update-status-emails=' + configuration: {} + composer: '' + contains: + - "standard install_configure_form.enable_update_status_module=NULL install_configure_form.enable_update_status_emails=NULL" + +- command: 'drupal:site-install --enable-update-status-module=true --enable-update-status-emails=true' + configuration: {} + composer: '' + contains: + - "standard install_configure_form.enable_update_status_module=true install_configure_form.enable_update_status_emails=true" + +- command: 'drupal:site-install' + configuration: + drupal: + install: + update_status_module: false + update_status_emails: ~ + composer: '' + contains: + - "standard install_configure_form.enable_update_status_module=NULL install_configure_form.enable_update_status_emails=true" + +- command: 'drupal:site-install' + configuration: + drupal: + install: + update_status_module: 'false' + update_status_emails: '' + composer: '' + contains: + - "standard install_configure_form.enable_update_status_module=NULL install_configure_form.enable_update_status_emails=NULL" + +- command: 'drupal:site-install' + configuration: + drupal: + install: + update_status_module: "false" + update_status_emails: "" + composer: '' + contains: + - "standard install_configure_form.enable_update_status_module=NULL install_configure_form.enable_update_status_emails=NULL" + +- command: 'drupal:site-install' + configuration: + drupal: + install: + update_status_module: true + update_status_emails: ~ + composer: '' + contains: + - "standard install_configure_form.enable_update_status_module=true install_configure_form.enable_update_status_emails=true" + +- command: 'drupal:site-install' + configuration: + drupal: + install: + update_status_module: 'true' + update_status_emails: '' + composer: '' + contains: + - "standard install_configure_form.enable_update_status_module=true install_configure_form.enable_update_status_emails=NULL" + +- command: 'drupal:site-install' + configuration: + drupal: + install: + update_status_module: "true" + update_status_emails: "" + composer: '' + contains: + - "standard install_configure_form.enable_update_status_module=true install_configure_form.enable_update_status_emails=NULL" + +- command: 'drupal:site-install' + configuration: + drupal: + install: + update_status_module: ~ + update_status_emails: true + composer: '' + contains: + - "standard install_configure_form.enable_update_status_module=true install_configure_form.enable_update_status_emails=true" + +- command: 'drupal:site-install' + configuration: + drupal: + install: + update_status_module: '' + update_status_emails: 'true' + composer: '' + contains: + - "standard install_configure_form.enable_update_status_module=NULL install_configure_form.enable_update_status_emails=true" + +- command: 'drupal:site-install' + configuration: + drupal: + install: + update_status_module: "" + update_status_emails: "true" + composer: '' + contains: + - "standard install_configure_form.enable_update_status_module=NULL install_configure_form.enable_update_status_emails=true"