From e51ef37c02e87c2027cf4594e7960f814755c071 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Fri, 16 Aug 2024 18:51:45 +1000 Subject: [PATCH] Moved core module dependencies into post-provision script. --- .scaffold/tests/bats/provision.bats | 42 ++++++++++++++--- scripts/custom/provision-10-example.sh | 23 ++++++--- web/modules/custom/ys_core/ys_core.deploy.php | 47 ------------------- web/modules/custom/ys_core/ys_core.info.yml | 11 ----- 4 files changed, 51 insertions(+), 72 deletions(-) diff --git a/.scaffold/tests/bats/provision.bats b/.scaffold/tests/bats/provision.bats index 2bd781a0f..3f0603a35 100644 --- a/.scaffold/tests/bats/provision.bats +++ b/.scaffold/tests/bats/provision.bats @@ -131,7 +131,11 @@ assert_provision_info() { # Custom post-install script. "Running custom post-install script './scripts/custom/provision-10-example.sh'." "@drush -y php:eval \Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();" - "@drush -y pm:install ys_core" + "@drush -y pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect shield stage_file_proxy" + "@drush -y pm:install redis" + "@drush -y pm:install clamav" + "@drush -y pm:install search_api search_api_solr" + "@drush -y pm:install ys_core ys_search" "@drush -y deploy:hook" "Executing example operations in non-production environment." # Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script. @@ -246,7 +250,11 @@ assert_provision_info() { # Custom post-install script. "Running custom post-install script './scripts/custom/provision-10-example.sh'." "@drush -y php:eval \Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();" - "@drush -y pm:install ys_core" + "@drush -y pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect shield stage_file_proxy" + "@drush -y pm:install redis" + "@drush -y pm:install clamav" + "@drush -y pm:install search_api search_api_solr" + "@drush -y pm:install ys_core ys_search" "@drush -y deploy:hook" "Executing example operations in non-production environment." # Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script. @@ -370,7 +378,11 @@ assert_provision_info() { # Custom post-install script. "Running custom post-install script './scripts/custom/provision-10-example.sh'." "@drush -y php:eval \Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();" - "@drush -y pm:install ys_core" + "@drush -y pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect shield stage_file_proxy" + "@drush -y pm:install redis" + "@drush -y pm:install clamav" + "@drush -y pm:install search_api search_api_solr" + "@drush -y pm:install ys_core ys_search" "@drush -y deploy:hook" "Executing example operations in non-production environment." # Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script. @@ -498,7 +510,11 @@ assert_provision_info() { # Custom post-install script. "Running custom post-install script './scripts/custom/provision-10-example.sh'." "@drush -y php:eval \Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();" - "@drush -y pm:install ys_core" + "@drush -y pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect shield stage_file_proxy" + "@drush -y pm:install redis" + "@drush -y pm:install clamav" + "@drush -y pm:install search_api search_api_solr" + "@drush -y pm:install ys_core ys_search" "@drush -y deploy:hook" "Executing example operations in non-production environment." # Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script. @@ -622,7 +638,11 @@ assert_provision_info() { # Custom post-install script. "Running custom post-install script './scripts/custom/provision-10-example.sh'." "@drush -y php:eval \Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();" - "@drush -y pm:install ys_core" + "@drush -y pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect shield stage_file_proxy" + "@drush -y pm:install redis" + "@drush -y pm:install clamav" + "@drush -y pm:install search_api search_api_solr" + "@drush -y pm:install ys_core ys_search" "@drush -y deploy:hook" "Executing example operations in non-production environment." # Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script. @@ -740,7 +760,11 @@ assert_provision_info() { # Custom post-install script. "Running custom post-install script './scripts/custom/provision-10-example.sh'." "@drush -y php:eval \Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();" - "@drush -y pm:install ys_core" + "@drush -y pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect shield stage_file_proxy" + "@drush -y pm:install redis" + "@drush -y pm:install clamav" + "@drush -y pm:install search_api search_api_solr" + "@drush -y pm:install ys_core ys_search" "@drush -y deploy:hook" "Executing example operations in non-production environment." # Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script. @@ -865,7 +889,11 @@ assert_provision_info() { # Custom post-install script. "Running custom post-install script './scripts/custom/provision-10-example.sh'." "@drush -y php:eval \Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();" - "@drush -y pm:install ys_core" + "@drush -y pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect shield stage_file_proxy" + "@drush -y pm:install redis" + "@drush -y pm:install clamav" + "@drush -y pm:install search_api search_api_solr" + "@drush -y pm:install ys_core ys_search" "@drush -y deploy:hook" "Executing example operations in non-production environment." # Assert that DREVOPS_PROVISION_OVERRIDE_DB is correctly passed to the script. diff --git a/scripts/custom/provision-10-example.sh b/scripts/custom/provision-10-example.sh index 0b48540a2..320d46e2e 100644 --- a/scripts/custom/provision-10-example.sh +++ b/scripts/custom/provision-10-example.sh @@ -30,17 +30,26 @@ if echo "${DREVOPS_PROVISION_ENVIRONMENT:-}" | grep -q -e dev -e test -e ci -e l # Set site name. drush php:eval "\Drupal::service('config.factory')->getEditable('system.site')->set('name', 'YOURSITE')->save();" + # Enable contrib modules. + drush pm:install admin_toolbar coffee config_split config_update media environment_indicator pathauto redirect shield stage_file_proxy + + #;< REDIS + drush pm:install redis + #;> REDIS + + #;< CLAMAV + drush pm:install clamav + #;> CLAMAV + + #;< SOLR + drush pm:install search_api search_api_solr + #;> SOLR + # Enable custom site module and run its deployment hooks. # - # In this example, the deployment hook implementation conditionally enables - # other custom modules: - # - Redis cache backend, if it is used in the project - # - ClamAV, if it is used in the project - # - Additional Solr search configuration, if Solr is used in the project - # # Note that deployment hooks for already enabled modules have run in the # parent "provision.sh" script. - drush pm:install ys_core + drush pm:install ys_core ys_search drush deploy:hook # Conditionally perform an action if this is a "fresh" database. diff --git a/web/modules/custom/ys_core/ys_core.deploy.php b/web/modules/custom/ys_core/ys_core.deploy.php index 023a31629..fdba0966f 100644 --- a/web/modules/custom/ys_core/ys_core.deploy.php +++ b/web/modules/custom/ys_core/ys_core.deploy.php @@ -5,15 +5,10 @@ * Deploy functions called from drush deploy:hook. * * @see https://www.drush.org/latest/deploycommand/ - * - * phpcs:disable Squiz.WhiteSpace.FunctionSpacing.Before - * phpcs:disable Squiz.WhiteSpace.FunctionSpacing.After */ declare(strict_types=1); -use Drupal\Core\Extension\ExtensionDiscovery; - /** * Installs custom theme. */ @@ -22,45 +17,3 @@ function ys_core_deploy_install_theme(): void { \Drupal::service('theme_installer')->install(['your_site_theme']); \Drupal::service('config.factory')->getEditable('system.theme')->set('default', 'your_site_theme')->save(); } - -// phpcs:ignore #;< REDIS -/** - * Enables Redis module. - */ -function ys_core_deploy_enable_redis(): void { - $listing = new ExtensionDiscovery(\Drupal::root()); - $modules = $listing->scan('module'); - if (!empty($modules['redis'])) { - \Drupal::service('module_installer')->install(['redis']); - } -} - -// phpcs:ignore #;> REDIS - -// phpcs:ignore #;< CLAMAV -/** - * Enables Search API and Search API Solr modules. - */ -function ys_core_deploy_enable_clamav(): void { - $listing = new ExtensionDiscovery(\Drupal::root()); - $modules = $listing->scan('module'); - if (!empty($modules['clamav'])) { - \Drupal::service('module_installer')->install(['media']); - \Drupal::service('module_installer')->install(['clamav']); - } -} - -// phpcs:ignore #;> CLAMAV - -// phpcs:ignore #;< SOLR -/** - * Enables Search API and Search API Solr modules. - */ -function ys_core_deploy_enable_search_api_solr(): void { - $listing = new ExtensionDiscovery(\Drupal::root()); - $modules = $listing->scan('module'); - if (!empty($modules['search_api']) && !empty($modules['search_api_solr']) && !empty($modules['ys_search'])) { - \Drupal::service('module_installer')->install(['ys_search']); - } -} -// phpcs:ignore #;> SOLR diff --git a/web/modules/custom/ys_core/ys_core.info.yml b/web/modules/custom/ys_core/ys_core.info.yml index 98872dd06..0d9d12313 100644 --- a/web/modules/custom/ys_core/ys_core.info.yml +++ b/web/modules/custom/ys_core/ys_core.info.yml @@ -3,14 +3,3 @@ type: module description: Core feature for YOURSITE site. core_version_requirement: ^10 package: your_site -dependencies: - - admin_toolbar:admin_toolbar - - coffee:coffee - - config_split:config_split - - config_update:config_update - - drupal:media - - environment_indicator:environment_indicator - - pathauto:pathauto - - redirect:redirect - - shield:shield - - stage_file_proxy:stage_file_proxy