Skip to content

Commit

Permalink
Moved core module dependencies into post-provision script.
Browse files Browse the repository at this point in the history
t
  • Loading branch information
AlexSkrypnyk committed Aug 16, 2024
1 parent 2ed1cd6 commit 8721fd2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 64 deletions.
28 changes: 28 additions & 0 deletions .scaffold/tests/bats/provision.bats
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ 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 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"
"@drush -y deploy:hook"
"Executing example operations in non-production environment."
Expand Down Expand Up @@ -246,6 +250,10 @@ 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 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"
"@drush -y deploy:hook"
"Executing example operations in non-production environment."
Expand Down Expand Up @@ -370,6 +378,10 @@ 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 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"
"@drush -y deploy:hook"
"Executing example operations in non-production environment."
Expand Down Expand Up @@ -498,6 +510,10 @@ 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 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"
"@drush -y deploy:hook"
"Executing example operations in non-production environment."
Expand Down Expand Up @@ -622,6 +638,10 @@ 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 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"
"@drush -y deploy:hook"
"Executing example operations in non-production environment."
Expand Down Expand Up @@ -740,6 +760,10 @@ 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 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"
"@drush -y deploy:hook"
"Executing example operations in non-production environment."
Expand Down Expand Up @@ -865,6 +889,10 @@ 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 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"
"@drush -y deploy:hook"
"Executing example operations in non-production environment."
Expand Down
21 changes: 15 additions & 6 deletions scripts/custom/provision-10-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,23 @@ 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
Expand Down
47 changes: 0 additions & 47 deletions web/modules/custom/ys_core/ys_core.deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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
11 changes: 0 additions & 11 deletions web/modules/custom/ys_core/ys_core.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

1 comment on commit 8721fd2

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.