diff --git a/.ddev/commands/host/exec_dir b/.ddev/commands/host/exec_dir new file mode 100755 index 0000000..3e565ee --- /dev/null +++ b/.ddev/commands/host/exec_dir @@ -0,0 +1,12 @@ +#!/bin/bash + +## Description: Run programs in container, based on current host directory +## Usage: exec_d [args] +## Example: "ddev exec_d yarn" + +if [ -z "$1" ]; then + echo "No argument supplied" + exit 1 +fi + +ddev exec -d /var/www/html/"$(echo "$PWD" | cut -d'/' -f4-)" "$@" diff --git a/.ddev/commands/web/phix b/.ddev/commands/web/phix index c1d3e06..299e1f7 100755 --- a/.ddev/commands/web/phix +++ b/.ddev/commands/web/phix @@ -4,4 +4,4 @@ ## Usage: phix ## Example: "ddev phix" -/var/www/html/bin/phpcbf $* +/var/www/html/vendor/bin/phpcbf $* diff --git a/.ddev/commands/web/phpcs b/.ddev/commands/web/phpcs index 90303a2..f280835 100755 --- a/.ddev/commands/web/phpcs +++ b/.ddev/commands/web/phpcs @@ -4,4 +4,4 @@ ## Usage: phpcs ## Example: "ddev phpcs" -/var/www/html/bin/phpcs -p $* \ No newline at end of file +/var/www/html/vendor/bin/phpcs -p $* \ No newline at end of file diff --git a/.ddev/commands/web/phpstan b/.ddev/commands/web/phpstan index 665b226..f09f3a0 100755 --- a/.ddev/commands/web/phpstan +++ b/.ddev/commands/web/phpstan @@ -4,4 +4,4 @@ ## Usage: phpix ## Example: "ddev phix" -/var/www/html/bin/phpstan $* \ No newline at end of file +/var/www/html/vendor/bin/phpstan $* \ No newline at end of file diff --git a/.ddev/commands/web/phpunit b/.ddev/commands/web/phpunit index 30b0274..1ce37cf 100755 --- a/.ddev/commands/web/phpunit +++ b/.ddev/commands/web/phpunit @@ -4,4 +4,4 @@ ## Usage: phpunit ## Example: "ddev phpunit" -/var/www/html/bin/phpunit $* \ No newline at end of file +/var/www/html/vendor/bin/phpunit $* \ No newline at end of file diff --git a/.ddev/config.yaml b/.ddev/config.yaml index c52eb4c..dcb9fa1 100644 --- a/.ddev/config.yaml +++ b/.ddev/config.yaml @@ -1,5 +1,5 @@ name: localgov -type: drupal9 +type: drupal10 docroot: web php_version: "8.1" webserver_type: nginx-fpm diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e848fa1..6714082 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,6 +36,7 @@ jobs: php-version: - '8.1' - '8.2' + - '8.3' steps: @@ -99,6 +100,7 @@ jobs: php-version: - '8.1' - '8.2' + - '8.3' steps: @@ -135,6 +137,7 @@ jobs: php-version: - '8.1' - '8.2' + - '8.3' steps: @@ -170,6 +173,7 @@ jobs: php-version: - '8.1' - '8.2' + - '8.3' steps: diff --git a/.gitignore b/.gitignore index e8b9513..861a9cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ # Ignore directories generated by Composer -/bin /drush/contrib/ /vendor/ /web/core/ @@ -77,3 +76,7 @@ .ddev/homeadditions/ .ddev/providers/ .ddev/xhprof/ + +# Ignore macOS DS_Store files +.DS_Store +**/.DS_Store diff --git a/.gitpod.yml b/.gitpod.yml index f59429b..c5ff15f 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,4 +1,4 @@ -image: drupalpod/drupalpod-gitpod-base:20221216 +image: drupalpod/drupalpod-gitpod-base:20240419 # ddev and composer are running as part of the prebuild # when starting a workspace all docker images are ready @@ -8,6 +8,8 @@ tasks: ddev composer install ddev drush si localgov -y --account-pass=admin --site-name='localgov_project' command: | + .gitpod/utils/ddev-in-gitpod-setup.sh + .gitpod/utils/env-setup.sh ddev start -y gp ports await 8080 && gp preview $(gp url 8080) diff --git a/.gitpod/README.md b/.gitpod/README.md new file mode 100644 index 0000000..658c01b --- /dev/null +++ b/.gitpod/README.md @@ -0,0 +1,33 @@ +# Setting up a new version for DrupalPod + +## Build custom Gitpod image + +1. Update `.gitpod/images/Dockerfile`: + + 1. Update `ddev` latest version. + 1. Update `minio` latest version. + 1. Update `gitui` latest version. + 1. Update `lazygit` latest version. + +1. Generate new custom docker image: + + 1. Run `docker login` to authenticate and push new images to docker hub. + 1. In `/.gitpod/images` run `./push.sh` command to build and push the new custom docker image. + 1. Confirm the process run without errors and that the new custom image gets uploaded to . + 1. Update `/.gitpod.yml` with the new image file. + +1. Push code, and re-open Gitpod workspace, to use latest custom docker image. + +1. Run manual prebuild (to load ddev's images) + +1. Confirm latest setup + 1. Open new workspace. + 1. Check if there are any updates (ie. DDEV's default settings files). + +1. Test various scenarios with DrupalPod browser extension + 1. Confirm core issues work as expected. + 1. Confirm contrib issue work as expected. + +1. Merge PR into `main` branch + +1. Confirm `main` branch work as expected 🎉 diff --git a/.gitpod/utils/ddev-in-gitpod-setup.sh b/.gitpod/utils/ddev-in-gitpod-setup.sh new file mode 100755 index 0000000..c03dfe6 --- /dev/null +++ b/.gitpod/utils/ddev-in-gitpod-setup.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +if [ -n "$DEBUG_SCRIPT" ] || [ -n "$GITPOD_HEADLESS" ]; then + set -x +fi + +# Misc housekeeping before start +ddev config global --instrumentation-opt-in=true diff --git a/.gitpod/utils/env-setup.sh b/.gitpod/utils/env-setup.sh new file mode 100755 index 0000000..84361ac --- /dev/null +++ b/.gitpod/utils/env-setup.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +if [ -n "$DEBUG_SCRIPT" ]; then + set -x +fi + +cd "${GITPOD_REPO_ROOT}"/.gitpod/utils/script-templates || exit + +# Create a phpstorm command +sudo cp phpstorm.template.sh /usr/local/bin/phpstorm + +# Create a preview command +sudo cp preview.template.sh /usr/local/bin/preview + +# Create a protect-my-git command +sudo cp protect-my-git.template.sh /usr/local/bin/protect-my-git + +# Create php command (run php inside ddev container) +sudo cp ddev-php.template.sh /usr/local/bin/php + +# Create drush command (run drush inside ddev container) +sudo cp ddev-drush.template.sh /usr/local/bin/drush + +# Create yarn command (run yarn inside ddev container) +sudo cp ddev-yarn.template.sh /usr/local/bin/yarn + +# Create composer command (run composer inside ddev container) +sudo cp ddev-composer.template.sh /usr/local/bin/composer + +# Create node command (run composer inside ddev container) +sudo cp ddev-node.template.sh /usr/local/bin/node + +# Create nvm command (run composer inside ddev container) +sudo cp ddev-nvm.template.sh /usr/local/bin/nvm + +# Create npx command (run composer inside ddev container) +sudo cp ddev-npx.template.sh /usr/local/bin/npx diff --git a/.gitpod/utils/script-templates/ddev-composer.template.sh b/.gitpod/utils/script-templates/ddev-composer.template.sh new file mode 100755 index 0000000..138f48b --- /dev/null +++ b/.gitpod/utils/script-templates/ddev-composer.template.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +echo "Notice: running 'composer $*' in ddev" +ddev exec_d composer "$@" diff --git a/.gitpod/utils/script-templates/ddev-drush.template.sh b/.gitpod/utils/script-templates/ddev-drush.template.sh new file mode 100755 index 0000000..7ac0f90 --- /dev/null +++ b/.gitpod/utils/script-templates/ddev-drush.template.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +echo "Notice: running 'drush $*' in ddev" +ddev exec_d drush "$@" diff --git a/.gitpod/utils/script-templates/ddev-node.template.sh b/.gitpod/utils/script-templates/ddev-node.template.sh new file mode 100755 index 0000000..5a30952 --- /dev/null +++ b/.gitpod/utils/script-templates/ddev-node.template.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +echo "Notice: running 'node $*' in ddev" +ddev exec_d node "$@" diff --git a/.gitpod/utils/script-templates/ddev-npx.template.sh b/.gitpod/utils/script-templates/ddev-npx.template.sh new file mode 100755 index 0000000..73eeeee --- /dev/null +++ b/.gitpod/utils/script-templates/ddev-npx.template.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +echo "Notice: running 'npx $*' in ddev" +ddev exec_d npx "$@" diff --git a/.gitpod/utils/script-templates/ddev-nvm.template.sh b/.gitpod/utils/script-templates/ddev-nvm.template.sh new file mode 100755 index 0000000..acd5c45 --- /dev/null +++ b/.gitpod/utils/script-templates/ddev-nvm.template.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +echo "Notice: running 'nvm $*' in ddev" +ddev exec_d nvm "$@" diff --git a/.gitpod/utils/script-templates/ddev-php.template.sh b/.gitpod/utils/script-templates/ddev-php.template.sh new file mode 100755 index 0000000..610926b --- /dev/null +++ b/.gitpod/utils/script-templates/ddev-php.template.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +echo "Notice: running 'php $*' in ddev" +ddev exec_d php "$@" diff --git a/.gitpod/utils/script-templates/ddev-yarn.template.sh b/.gitpod/utils/script-templates/ddev-yarn.template.sh new file mode 100755 index 0000000..d3ffa81 --- /dev/null +++ b/.gitpod/utils/script-templates/ddev-yarn.template.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +echo "Notice: running 'yarn $*' in ddev" +ddev exec_d yarn "$@" diff --git a/.gitpod/utils/script-templates/phpstorm.template.sh b/.gitpod/utils/script-templates/phpstorm.template.sh new file mode 100755 index 0000000..48c04d2 --- /dev/null +++ b/.gitpod/utils/script-templates/phpstorm.template.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +if [ -n "$DEBUG_SCRIPT" ]; then + set -x +fi + +if [ ! -x ~/.projector/configs/PhpStorm/run.sh ]; then + echo "PhpStorm runner not found" && exit 1 +fi + +# When port 9999 is ready - open that port in a new browser tab +gp await-port 9999 && gp preview "$(gp url 9999)" --external & + +# Run PHPStorm +~/.projector/configs/PhpStorm/run.sh "$GITPOD_REPO_ROOT" diff --git a/.gitpod/utils/script-templates/preview.template.sh b/.gitpod/utils/script-templates/preview.template.sh new file mode 100755 index 0000000..916a7fc --- /dev/null +++ b/.gitpod/utils/script-templates/preview.template.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +if [ -n "$DEBUG_SCRIPT" ]; then + set -x +fi + +# Preview port 8080 +gp preview "$(gp url 8080)" diff --git a/.gitpod/utils/script-templates/protect-my-git.template.sh b/.gitpod/utils/script-templates/protect-my-git.template.sh new file mode 100755 index 0000000..d9e7f82 --- /dev/null +++ b/.gitpod/utils/script-templates/protect-my-git.template.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +if [ -n "$DEBUG_SCRIPT" ]; then + set -x +fi + +# Remove access to user's Git credentials (restore by restart workspace) +git config --global --unset credential.helper diff --git a/.gitpod/utils/send-a-message-gcs.sh b/.gitpod/utils/send-a-message-gcs.sh new file mode 100755 index 0000000..5c53aba --- /dev/null +++ b/.gitpod/utils/send-a-message-gcs.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +# Get current user and current branch +branch_user="$GITPOD_GIT_USER_NAME, $(git branch --show-current)" + +# Load env vars during prebuild using `gp env` command +if [ -z "$IFTTT_TOKEN" ]; then + eval "$(gp env -e | grep IFTTT_TOKEN)" +fi + +# Load env vars during prebuild using `gp env` command +if [ -z "$DP_GOOGLE_ACCESS_KEY" ]; then + eval "$(gp env -e | grep DP_GOOGLE_ACCESS_KEY)" +fi + +# Load env vars during prebuild using `gp env` command +if [ -z "$DP_GOOGLE_SECRET" ]; then + eval "$(gp env -e | grep DP_GOOGLE_SECRET)" +fi + +# Establish connection with Google Cloud through Minio client +mc config host add gcs https://storage.googleapis.com "$DP_GOOGLE_ACCESS_KEY" "$DP_GOOGLE_SECRET" + +# If there's a problem send the error code +if mc find gcs/drupalpod/ready-made-envs.tar.gz; then + message="Success: Google Cloud is ready" +else + message="Error: Envs file wasn't found, it will be recreated" +fi + +# Send a message through IFTTT +curl -X POST -H "Content-Type: application/json" -d "{\"value1\":\"$branch_user\",\"value2\":\"$message\"}" https://maker.ifttt.com/trigger/drupalpod_prebuild_initiated/with/key/"$IFTTT_TOKEN" diff --git a/.gitpod/utils/send-a-message-gitpod.sh b/.gitpod/utils/send-a-message-gitpod.sh new file mode 100755 index 0000000..b0de49c --- /dev/null +++ b/.gitpod/utils/send-a-message-gitpod.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Get current user and current branch +branch_user="$GITPOD_GIT_USER_NAME, $(git branch --show-current)" + +# Load env vars during prebuild using `gp env` command +if [ -z "$DP_READY_MADE_ENVS_URL" ]; then + eval "$(gp env -e | grep DP_READY_MADE_ENVS_URL)" +fi + +# Load env vars during prebuild using `gp env` command +if [ -z "$IFTTT_TOKEN" ]; then + eval "$(gp env -e | grep IFTTT_TOKEN)" +fi + +# Check the status of ready-made envs file +# https://stackoverflow.com/a/53358157/5754049 +url_status=$(wget --server-response --spider --quiet "${DP_READY_MADE_ENVS_URL}" 2>&1 | awk 'NR==1{print $2}') + +# If there's a problem send the error code +if [ "$url_status" = '200' ]; then + message="100%" +else + message="Error: $url_status - $DP_READY_MADE_ENVS_URL" +fi + +# Send a message through IFTTT +curl -X POST -H "Content-Type: application/json" -d "{\"value1\":\"$branch_user\",\"value2\":\"$message\"}" https://maker.ifttt.com/trigger/drupalpod_prebuild_initiated/with/key/"$IFTTT_TOKEN" diff --git a/.gitpod/utils/set-base-environment.sh b/.gitpod/utils/set-base-environment.sh new file mode 100755 index 0000000..6305af8 --- /dev/null +++ b/.gitpod/utils/set-base-environment.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +if [ -n "$DEBUG_SCRIPT" ]; then + set -x +fi + +# Load default envs +# export "$(grep -v '^#' "$GITPOD_REPO_ROOT"/.env | xargs -d '\n')" + +# Clone Drupal core repo +mkdir -p "${GITPOD_REPO_ROOT}"/repos +cd "${GITPOD_REPO_ROOT}"/repos && time git clone https://git.drupalcode.org/project/drupal.git diff --git a/.lando.dist.yml b/.lando.dist.yml index a42f565..c601d78 100644 --- a/.lando.dist.yml +++ b/.lando.dist.yml @@ -12,6 +12,8 @@ proxy: - 'solr-sitewide.localgov.lndo.site:8983' services: appserver: + scanner: + retry: 5 xdebug: true build_as_root: # This disables Xdebug during build, but puts all dependencies in place @@ -71,24 +73,27 @@ services: config: dir: .lando/solr/localgov_sitewide_solr tooling: + composer: + service: appserver + cmd: /usr/local/bin/composer deprecated: service: appserver - cmd: 'bash -c "/app/bin/phpstan analyse -c /app/phpstan.neon /app/web/profiles/contrib/localgov* /app/web/modules/contrib/localgov* /app/web/themes/contrib/localgov*"' + cmd: 'bash -c "/app/vendor/bin/phpstan analyse -c /app/phpstan.neon /app/web/profiles/contrib/localgov* /app/web/modules/contrib/localgov* /app/web/themes/contrib/localgov*"' drush: service: appserver - cmd: '/app/bin/drush' + cmd: '/app/vendor/bin/drush' phpcs: service: appserver - cmd: '/app/bin/phpcs -p' + cmd: '/app/vendor/bin/phpcs -p' phix: service: appserver - cmd: '/app/bin/phpcbf' + cmd: '/app/vendor/bin/phpcbf' phpstan: service: appserver - cmd: '/app/bin/phpstan' + cmd: '/app/vendor/bin/phpstan' phpunit: service: appserver - cmd: '/app/bin/phpunit --testdox' + cmd: '/app/vendor/bin/phpunit --testdox' xdebug-on: service: appserver description: Enable Xdebug for Apache. diff --git a/assets/composer/settings.lando.php b/assets/composer/settings.lando.php index e5690b8..1256f2d 100644 --- a/assets/composer/settings.lando.php +++ b/assets/composer/settings.lando.php @@ -33,7 +33,7 @@ * @see https://wiki.php.net/rfc/expectations */ assert_options(ASSERT_ACTIVE, TRUE); -\Drupal\Component\Assertion\Handle::register(); +assert_options(ASSERT_EXCEPTION, TRUE); /** * Enable local development services. diff --git a/bin b/bin new file mode 120000 index 0000000..a3db776 --- /dev/null +++ b/bin @@ -0,0 +1 @@ +vendor/bin \ No newline at end of file diff --git a/composer.json b/composer.json index e424d52..10a02bb 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,6 @@ "prefer-stable": true, "config": { "sort-packages": true, - "bin-dir": "bin/", "allow-plugins": { "composer/installers": true, "cweagans/composer-patches": true, @@ -48,6 +47,9 @@ }, "extra": { "enable-patching": true, + "patchLevel": { + "drupal/core": "-p2" + }, "drupal-scaffold": { "locations": { "web-root": "web/" diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 3ff8bbe..bab863a 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -3,12 +3,16 @@ PHP CodeSniffer configuration for LocalGovDrupal. - + web/modules/contrib/ web/profiles/contrib/localgov/ + web/themes/contrib/ + web\/modules\/contrib\/(?!localgov_.*) + web\/themes\/contrib\/(?!localgov_.*) +