From c70a482ecc5b50995df74593d10e44c66ebc7734 Mon Sep 17 00:00:00 2001 From: Hannes Kirsman Date: Fri, 23 Feb 2024 14:49:33 +0200 Subject: [PATCH] #7 Add script to update grumphp.yml to add DDEV support. --- scripts/update-grumphp-command.sh | 32 +++++++++++++++++++++++++++++++ src/InstallHelperPlugin.php | 5 +++-- 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100755 scripts/update-grumphp-command.sh diff --git a/scripts/update-grumphp-command.sh b/scripts/update-grumphp-command.sh new file mode 100755 index 0000000..59e1e77 --- /dev/null +++ b/scripts/update-grumphp-command.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# +# Script to update the grumphp.yml file to use both Lando and DDEV on GIT commit. +# +# It's run on composer install, only if grumphp.yml exists and if it contains: +# EXEC_GRUMPHP_COMMAND: lando php +# This is the previous default we've used. +# + +set -eu +if [ -n "${WUNDERIO_DEBUG:-}" ]; then + set -x +fi +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/var/www/html/vendor/bin + +# Path to the grumphp.yml file +config_file="grumphp.yml" + +# Define the pattern to search for. +pattern="EXEC_GRUMPHP_COMMAND: lando php" + +if [ -f "$config_file" ] && grep -q "$pattern" "$config_file"; then + sed -i "s#$pattern#EXEC_GRUMPHP_COMMAND: \"[ -d .ddev/traefik/ ] \&\& GRUMPHP_COMMAND='ddev php' || GRUMPHP_COMMAND='lando php' \&\& \$GRUMPHP_COMMAND\"#g" "$config_file" + + # Add a message to the user. + color_red="\033[0;31m" + color_reset="\033[0m" + printf "${color_red}Added DDEV support to $config_file.\n" + echo "Please run \"ddev grumphp git:init\" for the changes to take affect." + printf "${color_reset}" +fi diff --git a/src/InstallHelperPlugin.php b/src/InstallHelperPlugin.php index 7f234a9..cebd304 100644 --- a/src/InstallHelperPlugin.php +++ b/src/InstallHelperPlugin.php @@ -120,8 +120,9 @@ public function onWunderIoDdevDrupalPackageInstall(PackageEvent $event) { self::deployDdevFiles(); - #$output = shell_exec('bash vendor/wunderio/lando-drupal/scripts/load_extensions.sh'); - #$this->io->write("{$output}"); + // Run the update-grumphp-command.php script. + $output = shell_exec('bash vendor/wunderio/ddev-drupal/scripts/update-grumphp-command.sh'); + $this->io->write("{$output}"); } /**