diff --git a/.ddev/addon-metadata/adminer/manifest.yaml b/.ddev/addon-metadata/adminer/manifest.yaml index b6d4302c..03da0493 100644 --- a/.ddev/addon-metadata/adminer/manifest.yaml +++ b/.ddev/addon-metadata/adminer/manifest.yaml @@ -1,7 +1,7 @@ name: adminer repository: ddev/ddev-adminer -version: v1.1.0 -install_date: "2025-03-12T09:43:10+02:00" +version: v1.1.4 +install_date: "2025-05-04T08:53:02+03:00" project_files: - docker-compose.adminer.yaml - docker-compose.adminer_norouter.yaml diff --git a/.ddev/addon-metadata/varnish/manifest.yaml b/.ddev/addon-metadata/varnish/manifest.yaml index 88d88e73..703e5738 100644 --- a/.ddev/addon-metadata/varnish/manifest.yaml +++ b/.ddev/addon-metadata/varnish/manifest.yaml @@ -1,7 +1,7 @@ name: varnish repository: ddev/ddev-varnish -version: v0.2.3 -install_date: "2024-08-13T15:59:06+03:00" +version: v0.2.6 +install_date: "2025-05-04T09:14:13+03:00" project_files: - docker-compose.varnish.yaml - varnish @@ -10,6 +10,7 @@ global_files: [] removal_actions: - | #ddev-nodisplay + #ddev-description:Remove docker-compose.varnish_extras.yaml file if [ -f docker-compose.varnish_extras.yaml ]; then if grep -q '#ddev-generated' docker-compose.varnish_extras.yaml; then rm -f docker-compose.varnish_extras.yaml diff --git a/.ddev/commands/host/wunderio-core-syncdb.sh b/.ddev/commands/host/wunderio-core-syncdb.sh new file mode 100755 index 00000000..367be516 --- /dev/null +++ b/.ddev/commands/host/wunderio-core-syncdb.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +## Description: Synchronise local database with production. +## Usage: syncdb +## Example: "ddev syncdb" + + +.ddev/wunderio/core/_run-scripts.sh tooling-syncdb.sh "$@" diff --git a/.ddev/commands/varnish/varnishadm b/.ddev/commands/varnish/varnishadm index ff195b35..96727bef 100755 --- a/.ddev/commands/varnish/varnishadm +++ b/.ddev/commands/varnish/varnishadm @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ## #ddev-generated ## Description: Control a running Varnish instance diff --git a/.ddev/commands/varnish/varnishd b/.ddev/commands/varnish/varnishd index a934247f..57396fc2 100755 --- a/.ddev/commands/varnish/varnishd +++ b/.ddev/commands/varnish/varnishd @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ## #ddev-generated ## Description: Varnish-cli diff --git a/.ddev/commands/varnish/varnishhist b/.ddev/commands/varnish/varnishhist index 77216c78..c9dfd6a0 100755 --- a/.ddev/commands/varnish/varnishhist +++ b/.ddev/commands/varnish/varnishhist @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ## #ddev-generated ## Description: Display Varnish request histogram diff --git a/.ddev/commands/varnish/varnishlog b/.ddev/commands/varnish/varnishlog index c107f503..9000b394 100755 --- a/.ddev/commands/varnish/varnishlog +++ b/.ddev/commands/varnish/varnishlog @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ## #ddev-generated ## Description: Display Varnish logs diff --git a/.ddev/commands/varnish/varnishncsa b/.ddev/commands/varnish/varnishncsa index 499da9d9..2293d06d 100755 --- a/.ddev/commands/varnish/varnishncsa +++ b/.ddev/commands/varnish/varnishncsa @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ## #ddev-generated ## Description: Display Varnish logs in Apache / NCSA combined log format diff --git a/.ddev/commands/varnish/varnishstat b/.ddev/commands/varnish/varnishstat index f28733e4..fa7c56ad 100755 --- a/.ddev/commands/varnish/varnishstat +++ b/.ddev/commands/varnish/varnishstat @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ## #ddev-generated ## Description: Display Varnish Cache statistics diff --git a/.ddev/commands/varnish/varnishtest b/.ddev/commands/varnish/varnishtest index 2600b0db..846ae683 100755 --- a/.ddev/commands/varnish/varnishtest +++ b/.ddev/commands/varnish/varnishtest @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ## #ddev-generated ## Description: Test program for Varnish diff --git a/.ddev/commands/varnish/varnishtop b/.ddev/commands/varnish/varnishtop index e83d5e78..05ea1b06 100755 --- a/.ddev/commands/varnish/varnishtop +++ b/.ddev/commands/varnish/varnishtop @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ## #ddev-generated ## Description: Display Varnish log entry ranking diff --git a/.ddev/commands/web/grumphp-command.sh b/.ddev/commands/web/grumphp-command.sh deleted file mode 100755 index 1e1f4df7..00000000 --- a/.ddev/commands/web/grumphp-command.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -## Description: Run a GrumPHP command. -## Usage: grumphp -## Example: "ddev grumphp" - -php /var/www/html/vendor/bin/grumphp "$@" diff --git a/.ddev/commands/web/phpunit-command.sh b/.ddev/commands/web/phpunit-command.sh deleted file mode 100755 index 67d32d16..00000000 --- a/.ddev/commands/web/phpunit-command.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -## Description: Run PHPUnit commands. -## Usage: phpunit -## Example: "ddev phpunit" - -php /var/www/html/vendor/bin/phpunit -c /var/www/html/phpunit.xml --testdox diff --git a/.ddev/commands/web/wunderio-core-grumphp.sh b/.ddev/commands/web/wunderio-core-grumphp.sh new file mode 100755 index 00000000..2603cbd1 --- /dev/null +++ b/.ddev/commands/web/wunderio-core-grumphp.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +## Description: Runs GrumPHP commands. +## Usage: grumphp +## Example: "ddev grumphp" + +/var/www/html/.ddev/wunderio/core/_run-scripts.sh tooling-grumphp.sh "$@" diff --git a/.ddev/commands/web/wunderio-core-phpunit.sh b/.ddev/commands/web/wunderio-core-phpunit.sh new file mode 100755 index 00000000..5b72e165 --- /dev/null +++ b/.ddev/commands/web/wunderio-core-phpunit.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +## Description: Runs PHPUnit commands. +## Usage: phpunit +## Example: "ddev phpunit" + +/var/www/html/.ddev/wunderio/core/_run-scripts.sh tooling-phpunit.sh "$@" diff --git a/.ddev/commands/web/wunderio-core-pmu.sh b/.ddev/commands/web/wunderio-core-pmu.sh new file mode 100755 index 00000000..a7d7f629 --- /dev/null +++ b/.ddev/commands/web/wunderio-core-pmu.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +## Description: Runs drush pmu commands but also creates dummy module folder if it does not exist. +## Usage: pmu +## Example: "ddev pmu module1 module2 ..." + +/var/www/html/.ddev/wunderio/core/_run-scripts.sh tooling-pmu.sh "$@" diff --git a/.ddev/commands/web/wunderio-core-regenerate-phpunit-config.sh b/.ddev/commands/web/wunderio-core-regenerate-phpunit-config.sh new file mode 100755 index 00000000..9f200072 --- /dev/null +++ b/.ddev/commands/web/wunderio-core-regenerate-phpunit-config.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +## Description: Regenerates fresh PHPUnit configuration. +## Usage: regenerate-phpunit-config +## Example: "ddev regenerate-phpunit-config" + +/var/www/html/.ddev/wunderio/core/_run-scripts.sh tooling-regenerate-phpunit-config.sh diff --git a/.ddev/commands/web/wunderio-core-yq.sh b/.ddev/commands/web/wunderio-core-yq.sh new file mode 100755 index 00000000..c087b919 --- /dev/null +++ b/.ddev/commands/web/wunderio-core-yq.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +## Description: Runs yq commands (yq is a lightweight and portable command-line YAML processor). +## Usage: yq +## Example: "ddev yq" + +yq "$@" diff --git a/.ddev/config.wunderio.yaml b/.ddev/config.wunderio.yaml new file mode 100644 index 00000000..7d67e517 --- /dev/null +++ b/.ddev/config.wunderio.yaml @@ -0,0 +1,29 @@ +hooks: + post-import-db: + - exec: "/var/www/html/.ddev/wunderio/core/_run-scripts.sh hooks-db-post-import.sh" + post-restore-snapshot: + - exec: "/var/www/html/.ddev/wunderio/core/_run-scripts.sh hooks-db-post-import.sh" + post-start: + # Build hook workaround to run composer install on first start. + # @todo We could potentially make this more like lando build hook by creating tmp files. + - exec: "[ ! -d \"/var/www/html/vendor\" ] && /var/www/html/.ddev/wunderio/core/_run-scripts.sh hooks-web-post-start-once.sh || true" + # Script to run on every start on the host. + - exec-host: ".ddev/wunderio/core/_run-scripts.sh hooks-host-post-start.sh" + # Script to run on every start. + - exec: "/var/www/html/.ddev/wunderio/core/_run-scripts.sh hooks-web-post-start.sh" + # Wunderio/ddev-drupal update check. + - exec: "UPDATE_SCRIPT=\"/var/www/html/vendor/wunderio/ddev-drupal/scripts/update_check.sh\"; [ -f \"$UPDATE_SCRIPT\" ] && $UPDATE_SCRIPT || true" +web_environment: +# Both this project and wunderio/lando-drupal use the same file +# at drush/sites/local.site.yml. To make sure that the local alias +# is working, we need to set the same environment variables here. +- LANDO_WEBROOT=$DDEV_COMPOSER_ROOT/$DDEV_DOCROOT +# When Mutagen is enabled (which it is by default in DDEV v1.19+), +# these directories are bind-mounted directly rather than synced via Mutagen +# This improves performance for large file directories by bypassing Mutagen's +# syncing. +# The paths are relative to the project root. +upload_dirs: + # Configure database_dumps directory to be bind-mounted directly + # instead of being synced via Mutagen for better performance + - ../database_dumps diff --git a/.ddev/config.yaml b/.ddev/config.yaml index 6451960a..f69abe70 100644 --- a/.ddev/config.yaml +++ b/.ddev/config.yaml @@ -21,25 +21,7 @@ web_environment: - DB_HOST=db - DRUSH_OPTIONS_URI=https://drupal-project.ddev.site - ENVIRONMENT_NAME=ddev - - EXEC_GRUMPHP_COMMAND=ddev php - HASH_SALT=notsosecurehash - - ELASTICSEARCH_HOST=elasticsearch - VARNISH_ADMIN_HOST=varnish - VARNISH_ADMIN_PORT=80 - - SMTP_ADDRESS=localhost:1025 - corepack_enable: false -hooks: - post-start: - - exec: "composer install" - - exec: "npm ci" - - exec-host: | - # Run the Elasticsearch plugin setup script - ddev exec -s elasticsearch /mnt/ddev_config/elasticsearch/elasticsearch-setup.sh - - # Check for the restart marker file - if [ -f .ddev/elasticsearch/restart_needed ]; then - echo "Elasticsearch plugins installed. Restarting elasticsearch container..." - docker restart ddev-${DDEV_SITENAME}-elasticsearch - rm .ddev/elasticsearch/restart_needed - fi diff --git a/.ddev/docker-compose.adminer.yaml b/.ddev/docker-compose.adminer.yaml index 5d72a079..00441fea 100644 --- a/.ddev/docker-compose.adminer.yaml +++ b/.ddev/docker-compose.adminer.yaml @@ -22,12 +22,14 @@ services: - "ddev-global-cache:/mnt/ddev-global-cache" depends_on: - db + command: ["php", "-S", "[::]:8080", "-t", "/var/www/html", "ddev-adminer.php"] configs: - - source: adminer-index.php - target: /var/www/html/index.php + - source: ddev-adminer.php + target: /var/www/html/ddev-adminer.php + mode: "0444" configs: - adminer-index.php: + ddev-adminer.php: content: | $$_ENV['ADMINER_DEFAULT_PASSWORD'], ]; } - include './adminer.php'; + include './index.php'; ?> diff --git a/.ddev/docker-compose.adminer_norouter.yaml b/.ddev/docker-compose.adminer_norouter.yaml index 09c267a7..338f90bc 100644 --- a/.ddev/docker-compose.adminer_norouter.yaml +++ b/.ddev/docker-compose.adminer_norouter.yaml @@ -1,4 +1,4 @@ #ddev-generated # If omit_containers[ddev-router] then this file will be replaced -# with another with a `ports` statement to directly expose port 8080 to 9100 +# with another with a 'ports' statement to directly expose port 8080 to 9100 services: {} diff --git a/.ddev/docker-compose.varnish.yaml b/.ddev/docker-compose.varnish.yaml index 7ecfe7fb..11607dfd 100644 --- a/.ddev/docker-compose.varnish.yaml +++ b/.ddev/docker-compose.varnish.yaml @@ -2,7 +2,7 @@ services: varnish: container_name: ddev-${DDEV_SITENAME}-varnish - image: varnish:6.0 + image: ${VARNISH_DOCKER_IMAGE:-varnish:6.0} # These labels ensure this service is discoverable by ddev. labels: com.ddev.site-name: ${DDEV_SITENAME} @@ -15,8 +15,8 @@ services: - VIRTUAL_HOST=$DDEV_HOSTNAME # This defines the ports the service should be accessible from at # sitename.ddev.site. - - HTTPS_EXPOSE=443:80,8026:8025 - - HTTP_EXPOSE=80:80,8025:8025 + - HTTPS_EXPOSE=${DDEV_ROUTER_HTTPS_PORT}:80,${DDEV_MAILPIT_HTTPS_PORT}:8025 + - HTTP_EXPOSE=${DDEV_ROUTER_HTTP_PORT}:80,${DDEV_MAILPIT_PORT}:8025 volumes: # This exposes a mount to the host system `.ddev/varnish` directory where # your default.vcl should be. @@ -24,8 +24,8 @@ services: - ".:/mnt/ddev_config" depends_on: - web - # Add mailhog support + # Add mailpit support expose: - "8025" entrypoint: - /usr/local/bin/docker-varnish-entrypoint -a 0.0.0.0:8025 \ No newline at end of file + /usr/local/bin/docker-varnish-entrypoint -a 0.0.0.0:8025 diff --git a/.ddev/docker-compose.varnish_extras.yaml b/.ddev/docker-compose.varnish_extras.yaml index fc6857db..7ccb6fea 100644 --- a/.ddev/docker-compose.varnish_extras.yaml +++ b/.ddev/docker-compose.varnish_extras.yaml @@ -1,7 +1,7 @@ #ddev-generated # This is the second half of the trick that puts varnish "in front of" the web -# container, just by switching the names. +# container, by switching all hostnames with "novarnish" subdomain prefix. services: web: environment: - - VIRTUAL_HOST=novarnish.drupal-project.ddev.site + - VIRTUAL_HOST=novarnish.${DDEV_PROJECT}.${DDEV_TLD} diff --git a/.ddev/varnish/default.vcl b/.ddev/varnish/default.vcl index 283804f6..8d3dd4e4 100644 --- a/.ddev/varnish/default.vcl +++ b/.ddev/varnish/default.vcl @@ -1,89 +1,20 @@ +# Simple default VCL. +#ddev-generated # For a more advanced example see https://github.com/mattiasgeniar/varnish-6.0-configuration-templates + vcl 4.1; import std; -# Define an ACL for trusted purge clients -acl purge { - "127.0.0.1"; - "::1"; - "web"; -} - backend default { .host = "web"; .port = "80"; } -# @see: https://github.com/wunderio/charts/blob/master/drupal/templates/varnish-configmap-vcl.yaml -# The routine when we deliver the HTTP request to the user -# Last chance to modify headers that are sent to the client. -sub vcl_deliver { - # Called before a cached object is delivered to the client. - - # Add debug header to see if it's a HIT/MISS and the number of hits, disable when not needed. - if (obj.hits > 0) { - set resp.http.X-W-Cache = "HIT"; - set resp.http.X-W-Cache-Hits = obj.hits; - } else { - set resp.http.X-W-Cache = "MISS"; - } -} sub vcl_recv { if (std.port(server.ip) == 8025) { return (synth(750)); } - - # Handle PURGE requests for Drupal's varnish_purger module - if (req.method == "PURGE") { - # Allow PURGE requests from trusted clients only - if (!client.ip ~ purge) { - return (synth(403, "Access denied.")); - } - - # Purge by Cache-Tags header - if (req.http.Cache-Tags) { - ban("obj.http.Cache-Tags ~ " + req.http.Cache-Tags); - return (synth(200, "Purge executed.")); - } - - # For URL-based purging - return (hash); - } - - # Handle BAN requests for Drupal's cache tags - if (req.method == "BAN") { - # Allow BAN requests from trusted clients only - if (!client.ip ~ purge) { - return (synth(403, "Access denied.")); - } - - # Ban by Cache-Tags header (sent by Drupal's varnish_purger module) - if (req.http.Cache-Tags) { - ban("obj.http.Cache-Tags ~ " + req.http.Cache-Tags); - return (synth(200, "Ban added.")); - } - - return (synth(403, "Invalid ban request")); - } -} - -sub vcl_hit { - if (req.method == "PURGE") { - # We found the object in cache, now invalidate it - set req.http.X-Purge-URL = req.url; - set req.http.X-Purge-Host = req.http.host; - return (synth(200, "Purged " + req.url)); - } -} - -sub vcl_miss { - if (req.method == "PURGE") { - # Object not in cache, but we still respond with a success - set req.http.X-Purge-URL = req.url; - set req.http.X-Purge-Host = req.http.host; - return (synth(200, "Purged " + req.url + " (not in cache)")); - } } sub vcl_synth { @@ -94,10 +25,3 @@ sub vcl_synth { return (deliver); } } - -# Store the Cache-Tags header from backend responses -sub vcl_backend_response { - if (beresp.http.Cache-Tags) { - set beresp.http.Cache-Tags = beresp.http.Cache-Tags; - } -} diff --git a/.ddev/wunderio/core/__.env b/.ddev/wunderio/core/__.env new file mode 100644 index 00000000..3c8ef9a4 --- /dev/null +++ b/.ddev/wunderio/core/__.env @@ -0,0 +1,8 @@ +# NOT USED, __ prefix means it's under evaluation if to be removed. +# Inject additional environment variables into every Lando service +# @see: https://docs.lando.dev/config/env.html#environment-files +DB_NAME_DRUPAL=drupal10 +DB_USER_DRUPAL=drupal10 +DB_PASS_DRUPAL=drupal10 +DB_HOST_DRUPAL=database +DRUSH_OPTIONS_URI=https://drupal-project.lndo.site diff --git a/.ddev/wunderio/core/__varnish.vcl b/.ddev/wunderio/core/__varnish.vcl new file mode 100644 index 00000000..fdbcfed5 --- /dev/null +++ b/.ddev/wunderio/core/__varnish.vcl @@ -0,0 +1,15 @@ +# NOT USED, __ prefix means it's under evaluation if to be removed. +# @see: https://github.com/wunderio/charts/blob/master/drupal/templates/varnish-configmap-vcl.yaml +# The routine when we deliver the HTTP request to the user +# Last chance to modify headers that are sent to the client +sub vcl_deliver { + # Called before a cached object is delivered to the client. + + # Add debug header to see if it's a HIT/MISS and the number of hits, disable when not needed. + if (obj.hits > 0) { + set resp.http.X-W-Cache = "HIT"; + set resp.http.X-W-Cache-Hits = obj.hits; + } else { + set resp.http.X-W-Cache = "MISS"; + } +} diff --git a/.ddev/wunderio/core/_helpers.sh b/.ddev/wunderio/core/_helpers.sh new file mode 100755 index 00000000..70341848 --- /dev/null +++ b/.ddev/wunderio/core/_helpers.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# +# Helper functions. +# + +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 + +# Function to display status message +display_status_message() { + local color_green="\033[38;5;70m" + local color_reset="\033[0m" + local message="$1" + + printf "${color_green}${message}${color_reset}\n" +} diff --git a/.ddev/wunderio/core/_run-scripts.sh b/.ddev/wunderio/core/_run-scripts.sh new file mode 100755 index 00000000..f71dae77 --- /dev/null +++ b/.ddev/wunderio/core/_run-scripts.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# +# Helper script to run other scripts and allow overriding them by having the +# same file in .ddev/wunderio/custom folder. +# + +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 + +script_name="$1" +# Remove the first argument (the script name) to get the remaining arguments +shift 1 + +custom_script=".ddev/wunderio/custom/$script_name" +core_script=".ddev/wunderio/core/$script_name" + +# Check if the custom script exists and is executable +if [ -x "$custom_script" ]; then + echo "Running custom script: $custom_script" + # Run the script and pass all remaining arguments. + "$custom_script" "$@" +elif [ -x "$core_script" ]; then + # If the custom script doesn't exist, run the core script. + echo "Running core script: $core_script" + # Run the script and pass all remaining arguments. + "$core_script" "$@" +else + echo "Script not found or not executable: $script_name" + exit 1 +fi diff --git a/.ddev/wunderio/core/hooks-db-post-import.sh b/.ddev/wunderio/core/hooks-db-post-import.sh new file mode 100755 index 00000000..6310cbc3 --- /dev/null +++ b/.ddev/wunderio/core/hooks-db-post-import.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# +# Helper script to run posb-import db hook. +# + +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 + +source /var/www/html/.ddev/wunderio/core/_helpers.sh + +cd $DDEV_COMPOSER_ROOT && drush cache:rebuild -y && drush sqlsan -y + +uli_link=$(drush uli) +display_status_message "Drupal is working, running drush uli: $uli_link" diff --git a/.ddev/wunderio/core/hooks-host-post-start.sh b/.ddev/wunderio/core/hooks-host-post-start.sh new file mode 100755 index 00000000..2f118ee8 --- /dev/null +++ b/.ddev/wunderio/core/hooks-host-post-start.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# +# Helper script to run host post-start commands. +# + +set -eu +if [[ -n "${WUNDERIO_DEBUG:-}" ]]; then + set -x +fi +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin diff --git a/.ddev/wunderio/core/hooks-web-post-start-once.sh b/.ddev/wunderio/core/hooks-web-post-start-once.sh new file mode 100755 index 00000000..9d965762 --- /dev/null +++ b/.ddev/wunderio/core/hooks-web-post-start-once.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# +# Helper script to run web commands on first post start. +# +# This is run only if there's no vendor folder. There's no 'build' +# command as we have in Lando so we have this instead. +# + +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 + +composer install diff --git a/.ddev/wunderio/core/hooks-web-post-start.sh b/.ddev/wunderio/core/hooks-web-post-start.sh new file mode 100755 index 00000000..612679e7 --- /dev/null +++ b/.ddev/wunderio/core/hooks-web-post-start.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# +# Helper script to run web post-start commands. +# + +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 + +source .ddev/wunderio/core/_helpers.sh + +# Function to check if Drupal is working. +is_drupal_working() { + # Drush 11 and older. + status=$(drush status bootstrap 2>&1) + if echo "$status" | grep -q "Successful"; then + # "Successful" found, Drupal is working. + return 0 + fi + + # Drush 12 and newer. + status=$(drush status --field=bootstrap 2>&1) + if echo "$status" | grep -q "Successful"; then + # "Successful" found, Drupal is working. + return 0 + fi + + return 1 +} + +# Commands to run if Drupal is working. +if is_drupal_working; then + uli_link=$(drush uli) + display_status_message "Drupal is working, running drush uli: $uli_link" +fi diff --git a/.ddev/wunderio/core/tooling-grumphp.sh b/.ddev/wunderio/core/tooling-grumphp.sh new file mode 100755 index 00000000..e8f1d8e4 --- /dev/null +++ b/.ddev/wunderio/core/tooling-grumphp.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# +# Helper script to run GrumPHP. +# + +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 + +php /var/www/html/vendor/bin/grumphp "$@" diff --git a/.ddev/wunderio/core/tooling-phpunit.sh b/.ddev/wunderio/core/tooling-phpunit.sh new file mode 100755 index 00000000..23920d46 --- /dev/null +++ b/.ddev/wunderio/core/tooling-phpunit.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# +# Helper script to run PHPUnit. +# + +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 + +if [ ! -f "/var/www/html/phpunit.xml" ]; then + echo "phpunit.xml not found! Please run 'ddev regenerate-phpunit-config'." + exit 1 +fi + +php /var/www/html/vendor/bin/phpunit -c /var/www/html/phpunit.xml --testdox "$@" diff --git a/.ddev/wunderio/core/tooling-pmu.sh b/.ddev/wunderio/core/tooling-pmu.sh new file mode 100755 index 00000000..7f85636b --- /dev/null +++ b/.ddev/wunderio/core/tooling-pmu.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# +# Helper script to run pmu, but also create temporary module directory if it doesn't exist. +# + +set -u +if [[ -n "${WUNDERIO_DEBUG:-}" ]]; then + set -x +fi +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/var/www/html/vendor/bin + +if [[ "$#" -lt 1 ]]; then + echo "Usage: ddev pmu ..." + exit 0 +fi + +modules="$1" + +cd /var/www/html + +disable_module() { + local module_name="$1" + + local module_path="web/modules/custom/$module_name" + + # Check if the module directory exists. + local module_exists=0 + if [ -d "web/modules/contrib/$module_name" ] || [ -d "$module_path" ] || [ -d "web/core/modules/$module_name" ]; then + module_exists=1 + fi + + # Create dummy module if the module directory doesn't exist. + if [ $module_exists -eq 0 ]; then + mkdir -p "$module_path" + echo "name: 'Dummy module created by ddev pmu'" > "$module_path/$module_name.info.yml" + echo "type: module" >> "$module_path/$module_name.info.yml" + echo "core_version_requirement: ^9 || ^10 || ^11" >> "$module_path/$module_name.info.yml" + fi + + # Clear caches to make the module available. + drush cr + + # Run "drush pmu" command. + echo "Disabling module $module_name..." + drush pmu -y "$module_name" + + # Remove dummy module if it was created. + if [ $module_exists -eq 0 ]; then + rm -rf "$module_path" + fi +} + +for module in $* +do + disable_module "$module" +done diff --git a/.ddev/wunderio/core/tooling-regenerate-phpunit-config.sh b/.ddev/wunderio/core/tooling-regenerate-phpunit-config.sh new file mode 100755 index 00000000..5340ae6b --- /dev/null +++ b/.ddev/wunderio/core/tooling-regenerate-phpunit-config.sh @@ -0,0 +1,35 @@ +#!/bin/bash +set -eu +if [[ -n "${WUNDERIO_DEBUG:-}" ]]; then + set -x +fi + +# Configure PHPUnit tests for the DDEV environment. +# +# Initially this was part of lando build process but we decided +# to commit the phpunit.xml. Still the functionality of this +# script could be useful as it always gets the latest distributed +# configuration from core. From time to time it wouldn't hurt +# try and update the file with 'lando regenerate-phpunit-config'. + +PHPUNIT_CONFIG=/var/www/html/phpunit.xml + +if [ -f "$PHPUNIT_CONFIG" ]; then + rm "$PHPUNIT_CONFIG" +fi + +cd /var/www/html/ +cp -n web/core/phpunit.xml.dist "$PHPUNIT_CONFIG" +sed -i 's|tests\/bootstrap\.php|./web/core/tests/bootstrap.php|g' "$PHPUNIT_CONFIG" +sed -i 's|\.\/tests\/|./web/core/tests/|g' "$PHPUNIT_CONFIG" +sed -i 's|directory>\.\/|directory>./web/core/|g' "$PHPUNIT_CONFIG" +sed -i 's|directory>\.\.\/|directory>./web/core/|g' "$PHPUNIT_CONFIG" +sed -i 's|||g' "$PHPUNIT_CONFIG" +sed -i 's|||g' "$PHPUNIT_CONFIG" +sed -i 's|.\/web\/core\/tests\/TestSuites\/UnitTestSuite.php<\/file>|.\/web\/modules\/custom\/*\/tests\/src\/Unit<\/directory>|g' "$PHPUNIT_CONFIG" +sed -i 's|.\/web\/core\/tests\/TestSuites\/KernelTestSuite.php<\/file>|.\/web\/modules\/custom\/*\/tests\/src\/Kernel<\/directory>|g' "$PHPUNIT_CONFIG" +sed -i 's|.\/web\/core\/tests\/TestSuites\/FunctionalTestSuite.php<\/file>|.\/web\/modules\/custom\/*\/tests\/src\/Functional<\/directory>|g' "$PHPUNIT_CONFIG" +sed -i 's|.\/web\/core\/tests\/TestSuites\/FunctionalJavascriptTestSuite.php<\/file>|.\/web\/modules\/custom\/*\/tests\/src\/FunctionalJavascript<\/directory>|g' "$PHPUNIT_CONFIG" +sed -i '/.\/web\/core\/tests\/TestSuites\/BuildTestSuite.php<\/file>/d' "$PHPUNIT_CONFIG" +vendor/bin/phpunit --migrate-configuration +rm phpunit.xml.bak diff --git a/.ddev/wunderio/core/tooling-syncdb.sh b/.ddev/wunderio/core/tooling-syncdb.sh new file mode 100755 index 00000000..7b90a989 --- /dev/null +++ b/.ddev/wunderio/core/tooling-syncdb.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# +# Synchronise local database with the production environment. +# +# Based on https://github.com/wunderio/unisport/blob/master/.lando/syncdb.sh +# + +set -eu +if [[ -n "${WUNDERIO_DEBUG:-}" ]]; then + set -x +fi +export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin + +source .ddev/wunderio/core/_helpers.sh + +sql_file="prod-syncdb-$(date +'%Y-%m-%d').sql" + +# Read the production alias from the drush configuration. +# For some reason "ddev drush sql-sync @prod @local -y" does not work and times out. +prod_alias=$(ddev drush sa @prod) +prod_ssh_user=$(echo "$prod_alias" | ddev yq '.\"@self.prod\".user' ) +prod_ssh_options=$(echo "$prod_alias" | ddev yq '.\"@self.prod\".ssh.options' ) +prod_ssh_host=$(echo "$prod_alias" | ddev yq '.\"@self.prod\".host' ) + +set -x +ssh "$prod_ssh_user@$prod_ssh_host" "$prod_ssh_options" "drush sql-dump --structure-tables-list=cache,cache_*,history,search_*,sessions" > "$sql_file" +ddev import-db --file="$sql_file" +rm "$sql_file" +{ set +x; } 2>/dev/null + +display_status_message "Sync complete!" diff --git a/.ddev/wunderio/custom/.gitignore b/.ddev/wunderio/custom/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/composer.json b/composer.json index 339e0ec1..d3663c85 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,8 @@ }, "require-dev": { "drupal/core-dev": "^11.1", - "wunderio/code-quality": "^3.0" + "wunderio/code-quality": "^3.0", + "wunderio/ddev-drupal": "^0.5.0" }, "conflict": { "drupal/drupal": "*" @@ -51,7 +52,8 @@ "php-http/discovery": true, "phpro/grumphp": true, "phpstan/extension-installer": true, - "tbachert/spi": true + "tbachert/spi": true, + "wunderio/ddev-drupal": true }, "discard-changes": true, "process-timeout": 0, diff --git a/drush/sites/local.site.yml b/drush/sites/local.site.yml new file mode 100644 index 00000000..82c83db4 --- /dev/null +++ b/drush/sites/local.site.yml @@ -0,0 +1,5 @@ +# Add local alias. +# Docs at https://github.com/drush-ops/drush/blob/master/examples/example.site.yml +local: + root: ${env.LANDO_WEBROOT} + uri: ${env.DRUSH_OPTIONS_URI}