diff --git a/scripts/install_module.sh b/scripts/install_module.sh new file mode 100755 index 0000000000000000000000000000000000000000..7533c1a0cc6f0d277c3fe608f37de6e286d94c1b --- /dev/null +++ b/scripts/install_module.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +# NAME +# install_module.sh - Re/install the module in a local dev environment. +# +# SYNOPSIS +# bash scripts/install_module.sh +# +# DESCRIPTION +# Install this module physically (i.e., code only, no database changes) into +# an existing local development environment, e.g., one created with +# scripts/setup_local_dev.sh. Only files committed to Git will be affected. +# Excluded files such as settings.php will not be changed or deleted. + +# cSpell:disable + +cd "$(dirname "$0")/../" || exit; + +MODULE_DIRECTORY=$(pwd) + +# Find the site root directory. Check up to three directories above. +DIR=$(pwd) +for i in {0..3}; do + DIR=$(dirname "$DIR") + if test -f "$DIR/core/composer.json"; then + SITE_DIRECTORY="$DIR" + break + fi +done + +# Exit if the site can't be found. +if test -z "$SITE_DIRECTORY"; then + echo "Could not find the local development environment. Are you inside a Drupal site's 'modules' directory?" + exit 1 +fi + +cd "$SITE_DIRECTORY" || exit 1 + +# Eliminate any changes to the environment because they will need to be +# overwritten--especially Composer files. +git reset --hard + +# Tell Composer to look for the package in the local clone. This is done rather +# than MERELY cloning the module so that the composer.json of the code under +# development is actually exercised and dependencies don't have to be added +# manually. +composer config \ + repositories.automatic_updates \ + path \ + "$MODULE_DIRECTORY" + +# Prevent Composer from symlinking path repositories. +export COMPOSER_MIRROR_PATH_REPOS=1 + +# Update the Composer platform PHP emulation. +composer config platform.php 7.4.0 + +# Prevent Composer from installing symlinks from common packages known to +# contain them. +# @see https://www.drupal.org/docs/develop/using-composer/using-drupals-vendor-hardening-composer-plugin +composer config --json extra.drupal-core-vendor-hardening.drush/drush '["docs"]' +composer config --json extra.drupal-core-vendor-hardening.grasmash/yaml-expander '["scenarios"]' + +# Require the module using the checked out dev branch. +composer require \ + --no-ansi \ + drupal/automatic_updates:*@dev + +# Revert needless changes to Core Composer metapackages. +git checkout -- "$SITE_DIRECTORY/composer/Metapackage" + +cat << DONE + +$(printf "\e[1;34m")================================================================================ +$(printf "\e[1;33m") + oooooooooo. .oooooo. ooooo ooo oooooooooooo .o. + '888' 'Y8b d8P' 'Y8b '888b. '8' '888' '8 888 + 888 888 888 888 8 '88b. 8 888 888 + 888 888 888 888 8 '88b. 8 888oooo8 Y8P + 888 888 888 888 8 '88b.8 888 ' '8' + 888 d88' '88b d88' 8 '888 888 o .o. + o888bood8P' 'Y8bood8P' o8o '8 o888ooooood8 Y8P + +$(printf "\e[1;34m")================================================================================ + +DONE diff --git a/scripts/phpcbf.sh b/scripts/phpcbf.sh index 0575ea6aefeee23c0e70b2450de88b6edff09e88..04a06c8d5c33c89d1e2ea50ed960defaa9c34fcb 100755 --- a/scripts/phpcbf.sh +++ b/scripts/phpcbf.sh @@ -13,6 +13,8 @@ # It is assumed that this module is inside a Drupal core installation, in # modules or modules/contrib. See setup_local_dev.sh. +# cSpell:disable + cd "$(dirname "$0")" || exit 0; # Find PHPCBF in Drupal core. Check up to three directories up. diff --git a/scripts/phpcs.sh b/scripts/phpcs.sh index 8ffb58ffec798d91043df60006aabfb95bc68f8e..f6fc8cca7c5acb07407d7003710987132f3e6742 100755 --- a/scripts/phpcs.sh +++ b/scripts/phpcs.sh @@ -13,6 +13,8 @@ # It is assumed that this module is inside a Drupal core installation, in # modules or modules/contrib. See setup_local_dev.sh. +# cSpell:disable + cd "$(dirname "$0")" || exit 0; # Find PHPCS in Drupal core. Check up to three directories up. diff --git a/scripts/phpunit.sh b/scripts/phpunit.sh index 4a58223074bce09a24afba595ef2cd4e4b5c8c5a..7ef23b583b5d8a9c0dea562875a80ede7a1a9fcd 100755 --- a/scripts/phpunit.sh +++ b/scripts/phpunit.sh @@ -12,6 +12,8 @@ # It is assumed that this module is inside a Drupal core installation, in # modules or modules/contrib. See setup_local_dev.sh. +# cSpell:disable + cd "$(dirname "$0")" || exit 0; # Find PHPUnit in Drupal core. Check up to three directories up. diff --git a/scripts/setup_local_dev.sh b/scripts/setup_local_dev.sh index 34d696c9a14061293b2e05e4679ee8b32560139f..06fb68b25f007f86f25d51b66d150e415069f85d 100755 --- a/scripts/setup_local_dev.sh +++ b/scripts/setup_local_dev.sh @@ -12,6 +12,8 @@ # installing the module and its dependencies. It does NOT set up a web # server or install Drupal in a database. +# cSpell:disable + # GNU realpath can't be depended upon to always be available. Simulate it. # https://stackoverflow.com/questions/3572030/bash-script-absolute-path-with-os-x safe_realpath() { @@ -108,6 +110,7 @@ modules profiles themes # Drupal site configuration +default sites # Composer libraries vendor