From 12db549adb2be6014e47076fdee76fc3a45c5b76 Mon Sep 17 00:00:00 2001 From: Bhanu <8525040+bhanu951@users.noreply.github.com> Date: Thu, 31 Oct 2024 18:02:03 +0530 Subject: [PATCH 1/7] Make DDEV Compatible. --- .ddev/commands/web/README.txt | 4 + .ddev/commands/web/code-check | 541 ++++++++++++++++++ .ddev/commands/web/cspell-check | 18 + .ddev/commands/web/install | 8 + .ddev/commands/web/nightwatch | 12 + .ddev/commands/web/phpcbf | 11 + .ddev/commands/web/phpcs | 11 + .ddev/commands/web/phpstan | 11 + .ddev/commands/web/phpunit | 10 + .ddev/commands/web/tests-cleanup | 19 + .ddev/config.yaml | 267 +++++++++ .ddev/docker-compose.override.yaml | 11 + .gitignore | 29 + .vscode/launch.json | 15 + README.md | 107 +++- composer.json | 7 +- .../DevelopmentProjectCommands.php | 2 +- repos/.gitkeep | 0 18 files changed, 1049 insertions(+), 34 deletions(-) create mode 100755 .ddev/commands/web/README.txt create mode 100755 .ddev/commands/web/code-check create mode 100755 .ddev/commands/web/cspell-check create mode 100755 .ddev/commands/web/install create mode 100755 .ddev/commands/web/nightwatch create mode 100755 .ddev/commands/web/phpcbf create mode 100755 .ddev/commands/web/phpcs create mode 100755 .ddev/commands/web/phpstan create mode 100755 .ddev/commands/web/phpunit create mode 100755 .ddev/commands/web/tests-cleanup create mode 100644 .ddev/config.yaml create mode 100644 .ddev/docker-compose.override.yaml create mode 100644 .gitignore create mode 100644 .vscode/launch.json create mode 100644 repos/.gitkeep diff --git a/.ddev/commands/web/README.txt b/.ddev/commands/web/README.txt new file mode 100755 index 0000000..e0c4a05 --- /dev/null +++ b/.ddev/commands/web/README.txt @@ -0,0 +1,4 @@ +#ddev-generated +Scripts in this directory will be executed inside the web container. + +See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/#environment-variables-provided for a list of environment variables that can be used in the scripts. diff --git a/.ddev/commands/web/code-check b/.ddev/commands/web/code-check new file mode 100755 index 0000000..d0ce547 --- /dev/null +++ b/.ddev/commands/web/code-check @@ -0,0 +1,541 @@ +#!/bin/bash + +## Description: This script performs code quality checks. +## Usage: code-check [flags] +## Example: "ddev code-check" or "ddev code-check --cached" + +# This script performs code quality checks. +# +# @internal +# This script is not covered by Drupal core's backwards compatibility promise. +# It exists only for core development purposes. +# +# The script makes the following checks: +# - Spell checking. +# - File modes. +# - No changes to core/node_modules directory. +# - PHPCS checks PHP and YAML files. +# - PHPStan checks PHP files. +# - ESLint checks JavaScript and YAML files. +# - Stylelint checks CSS files. +# - Checks .pcss.css and .css files are equivalent. + +# cSpell:disable + +TOP_LEVEL="/var/www/html/repos/drupal" +cd $TOP_LEVEL/core + +printf "\033[0;33mIf you have just started DDEV wait for couple of minutes \n" +printf "before using {ddev code-check} command, mutagen file sync of \n" +printf "node_modules takes time.\n\033[0m" + +corepack enable + +echo "NPM Version :" +npm --version + +echo "Yarn Version :" +yarn --version + +# Installs dependencies if not already run. +if [ ! -d /var/www/html/repos/drupal/core/node_modules/.bin ]; then + + corepack enable + + yarn --cwd /var/www/html/repos/drupal/core install + +fi + +cd $TOP_LEVEL + +# Searches an array. +contains_element() { + local e + for e in ${@:2}; do [[ "$e" == "$1" ]] && return 0; done + return 1 +} + +CACHED=0 +DRUPALCI=0 +BRANCH="" +while test $# -gt 0; do + case "$1" in + -h|--help) + echo "Drupal code quality checks" + echo " " + echo "options:" + echo "-h, --help show brief help" + echo "--branch BRANCH creates list of files to check by comparing against a branch" + echo "--cached checks staged files" + echo "--drupalci a special mode for DrupalCI" + echo " " + echo "Example usage: sh ./core/scripts/dev/commit-code-check.sh --branch 9.2.x" + exit 0 + ;; + --branch) + BRANCH="$2" + if [[ "$BRANCH" == "" ]]; then + printf "The --branch option requires a value. For example: --branch 9.2.x\n" + exit; + fi + shift 2 + ;; + --cached) + CACHED=1 + shift + ;; + --drupalci) + DRUPALCI=1 + shift + ;; + *) + break + ;; + esac +done + +# Set up variables to make colored output simple. Color output is disabled on +# DrupalCI because it is breaks reporting. +# @todo https://www.drupal.org/project/drupalci_testbot/issues/3181869 +if [[ "$DRUPALCI" == "1" ]]; then + red="" + green="" + reset="" + DRUPAL_VERSION=$(php -r "include 'vendor/autoload.php'; print preg_replace('#\.[0-9]+-dev#', '.x', \Drupal::VERSION);") + GIT="sudo -u www-data git" +else + red=$(tput setaf 1 && tput bold) + green=$(tput setaf 2) + reset=$(tput sgr0) + GIT="git" +fi + +# Gets list of files to check. +if [[ "$BRANCH" != "" ]]; then + FILES=$($GIT diff --name-only $BRANCH HEAD); +elif [[ "$CACHED" == "0" ]]; then + # For DrupalCI patch testing or when running without --cached or --branch, + # list of all changes in the working directory. + FILES=$($GIT ls-files --other --modified --exclude-standard --exclude=vendor --exclude=node_modules --exclude=sites --exclude=*.patch --exclude=*.diff --exclude=.DS_Store) +else + # Check staged files only. + if $GIT rev-parse --verify HEAD >/dev/null 2>&1 + then + AGAINST=HEAD + else + # Initial commit: diff against an empty tree object + AGAINST=4b825dc642cb6eb9a060e54bf8d69288fbee4904 + fi + FILES=$($GIT diff --cached --name-only $AGAINST); +fi + +if [[ "$FILES" == "" ]] && [[ "$DRUPALCI" == "1" ]]; then + # If the FILES is empty we might be testing a merge request on DrupalCI. We + # need to diff against the Drupal branch or tag related to the Drupal version. + printf "Creating list of files to check by comparing branch to %s\n" "$DRUPAL_VERSION" + # On DrupalCI there's a merge commit so we can compare to HEAD~1. + FILES=$($GIT diff --name-only HEAD~1 HEAD); +fi + +TOP_LEVEL=$($GIT rev-parse --show-toplevel) + +# This variable will be set to one when the file core/phpcs.xml.dist is changed. +PHPCS_XML_DIST_FILE_CHANGED=0 + +# This variable will be set to one when the files core/.phpstan-baseline.php or +# core/phpstan.neon.dist are changed. +PHPSTAN_DIST_FILE_CHANGED=0 + +# This variable will be set to one when one of the eslint config file is +# changed: +# - core/.eslintrc.passing.json +# - core/.eslintrc.json +# - core/.eslintrc.jquery.json +ESLINT_CONFIG_PASSING_FILE_CHANGED=0 + +# This variable will be set to one when the stylelint config file is changed. +# changed: +# - core/.stylelintignore +# - core/.stylelintrc.json +STYLELINT_CONFIG_FILE_CHANGED=0 + +# This variable will be set to one when JavaScript packages files are changed. +# changed: +# - core/package.json +# - core/yarn.lock +JAVASCRIPT_PACKAGES_CHANGED=0 + +# This variable will be set when a Drupal-specific CKEditor 5 plugin has changed +# it is used to make sure the compiled JS is valid. +CKEDITOR5_PLUGINS_CHANGED=0 + +# This variable will be set to when the dictionary has changed. +CSPELL_DICTIONARY_FILE_CHANGED=0 + +# Build up a list of absolute file names. +ABS_FILES= +for FILE in $FILES; do + if [ -f "$TOP_LEVEL/$FILE" ]; then + ABS_FILES="$ABS_FILES $TOP_LEVEL/$FILE" + fi + + if [[ $FILE == "core/phpcs.xml.dist" ]]; then + PHPCS_XML_DIST_FILE_CHANGED=1; + fi; + + if [[ $FILE == "core/.phpstan-baseline.php" || $FILE == "core/phpstan.neon.dist" ]]; then + PHPSTAN_DIST_FILE_CHANGED=1; + fi; + + if [[ $FILE == "core/.eslintrc.json" || $FILE == "core/.eslintrc.passing.json" || $FILE == "core/.eslintrc.jquery.json" ]]; then + ESLINT_CONFIG_PASSING_FILE_CHANGED=1; + fi; + + if [[ $FILE == "core/.stylelintignore" || $FILE == "core/.stylelintrc.json" ]]; then + STYLELINT_CONFIG_FILE_CHANGED=1; + fi; + + # If JavaScript packages change, then rerun all JavaScript style checks. + if [[ $FILE == "core/package.json" || $FILE == "core/yarn.lock" ]]; then + ESLINT_CONFIG_PASSING_FILE_CHANGED=1; + STYLELINT_CONFIG_FILE_CHANGED=1; + JAVASCRIPT_PACKAGES_CHANGED=1; + fi; + + if [[ -f "$TOP_LEVEL/$FILE" ]] && [[ $FILE =~ \.js$ ]] && [[ $FILE =~ ^core/modules/ckeditor5/js/build || $FILE =~ ^core/modules/ckeditor5/js/ckeditor5_plugins ]]; then + CKEDITOR5_PLUGINS_CHANGED=1; + fi; + + if [[ $FILE == "core/misc/cspell/dictionary.txt" || $FILE == "core/misc/cspell/drupal-dictionary.txt" ]]; then + CSPELL_DICTIONARY_FILE_CHANGED=1; + fi +done + +# Exit early if there are no files. +if [[ "$ABS_FILES" == "" ]]; then + printf "There are no files to check. If you have staged a commit use the --cached option.\n" + exit; +fi; + +# This script assumes that composer install and yarn install have already been +# run and all dependencies are updated. +FINAL_STATUS=0 + +DEPENDENCIES_NEED_INSTALLING=0 +# Ensure PHP development dependencies are installed. +# @todo https://github.com/composer/composer/issues/4497 Improve this to +# determine if dependencies in the lock file match the installed versions. +# Using composer install --dry-run is not valid because it would depend on +# user-facing strings in Composer. +if ! [[ -f 'vendor/bin/phpcs' ]]; then + printf "Drupal's PHP development dependencies are not installed. Run 'composer install' from the root directory.\n" + DEPENDENCIES_NEED_INSTALLING=1; +fi + +cd "$TOP_LEVEL/core" + +# Ensure JavaScript development dependencies are installed. +yarn --version +yarn >/dev/null + +# Check all files for spelling in one go for better performance. +if [[ $CSPELL_DICTIONARY_FILE_CHANGED == "1" ]] ; then + printf "\nRunning spellcheck on *all* files.\n" + yarn run spellcheck:core --no-must-find-files --no-progress +else + # Check all files for spelling in one go for better performance. We pipe the + # list files in so we obey the globs set on the spellcheck:core command in + # core/package.json. + echo "${ABS_FILES}" | tr ' ' '\n' | yarn run spellcheck:core --no-must-find-files --file-list stdin +fi + +if [ "$?" -ne "0" ]; then + # If there are failures set the status to a number other than 0. + FINAL_STATUS=1 + printf "\nCSpell: ${red}failed${reset}\n" +else + printf "\nCSpell: ${green}passed${reset}\n" +fi +cd "$TOP_LEVEL" + +# Add a separator line to make the output easier to read. +printf "\n" +printf -- '-%.0s' {1..100} +printf "\n" + +# Run PHPStan on all files on DrupalCI or when phpstan files are changed. +# APCu is disabled to ensure that the composer classmap is not corrupted. +if [[ $PHPSTAN_DIST_FILE_CHANGED == "1" ]] || [[ "$DRUPALCI" == "1" ]]; then + printf "\nRunning PHPStan on *all* files.\n" + php -d apc.enabled=0 -d apc.enable_cli=0 vendor/bin/phpstan analyze --no-progress --configuration="$TOP_LEVEL/core/phpstan.neon.dist" +else + # Only run PHPStan on changed files locally. + printf "\nRunning PHPStan on changed files.\n" + php -d apc.enabled=0 -d apc.enable_cli=0 vendor/bin/phpstan analyze --memory-limit=2G --no-progress --configuration="$TOP_LEVEL/core/phpstan-partial.neon" $ABS_FILES +fi + +if [ "$?" -ne "0" ]; then + # If there are failures set the status to a number other than 0. + FINAL_STATUS=1 + printf "\nPHPStan: ${red}failed${reset}\n" +else + printf "\nPHPStan: ${green}passed${reset}\n" +fi + +# Add a separator line to make the output easier to read. +printf "\n" +printf -- '-%.0s' {1..100} +printf "\n" + +# Run PHPCS on all files on DrupalCI or when phpcs files are changed. +if [[ $PHPCS_XML_DIST_FILE_CHANGED == "1" ]] || [[ "$DRUPALCI" == "1" ]]; then + # Test all files with phpcs rules. + vendor/bin/phpcs -ps --parallel="$( (nproc || sysctl -n hw.logicalcpu || echo 4) 2>/dev/null)" --standard="$TOP_LEVEL/core/phpcs.xml.dist" + PHPCS=$? + if [ "$PHPCS" -ne "0" ]; then + # If there are failures set the status to a number other than 0. + FINAL_STATUS=1 + printf "\nPHPCS: ${red}failed${reset}\n" + else + printf "\nPHPCS: ${green}passed${reset}\n" + fi + # Add a separator line to make the output easier to read. + printf "\n" + printf -- '-%.0s' {1..100} + printf "\n" +fi + +# When the eslint config has been changed, then eslint must check all files. +if [[ $ESLINT_CONFIG_PASSING_FILE_CHANGED == "1" ]]; then + cd "$TOP_LEVEL/core" + yarn run lint:core-js-passing "$TOP_LEVEL/core" + CORRECTJS=$? + if [ "$CORRECTJS" -ne "0" ]; then + # If there are failures set the status to a number other than 0. + FINAL_STATUS=1 + printf "\neslint: ${red}failed${reset}\n" + else + printf "\neslint: ${green}passed${reset}\n" + fi + cd $TOP_LEVEL + # Add a separator line to make the output easier to read. + printf "\n" + printf -- '-%.0s' {1..100} + printf "\n" +fi + +# When the stylelint config has been changed, then stylelint must check all files. +if [[ $STYLELINT_CONFIG_FILE_CHANGED == "1" ]]; then + cd "$TOP_LEVEL/core" + yarn run lint:css + if [ "$?" -ne "0" ]; then + # If there are failures set the status to a number other than 0. + FINAL_STATUS=1 + printf "\nstylelint: ${red}failed${reset}\n" + else + printf "\nstylelint: ${green}passed${reset}\n" + fi + cd $TOP_LEVEL + # Add a separator line to make the output easier to read. + printf "\n" + printf -- '-%.0s' {1..100} + printf "\n" +fi + +# When a Drupal-specific CKEditor 5 plugin changed ensure that it is compiled +# properly. Only check on DrupalCI, since we're concerned about the build being +# run with the expected package versions and making sure the result of the build +# is in sync and conform to expectations. +if [[ "$DRUPALCI" == "1" ]] && [[ $CKEDITOR5_PLUGINS_CHANGED == "1" ]]; then + cd "$TOP_LEVEL/core" + yarn run check:ckeditor5 + if [ "$?" -ne "0" ]; then + # If there are failures set the status to a number other than 0. + FINAL_STATUS=1 + printf "\nDrupal-specific CKEditor 5 plugins: ${red}failed${reset}\n" + else + printf "\nDrupal-specific CKEditor 5 plugins: ${green}passed${reset}\n" + fi + cd $TOP_LEVEL + # Add a separator line to make the output easier to read. + printf "\n" + printf -- '-%.0s' {1..100} + printf "\n" +fi + +# When JavaScript packages change, then rerun all JavaScript style checks. +if [[ "$JAVASCRIPT_PACKAGES_CHANGED" == "1" ]]; then + cd "$TOP_LEVEL/core" + yarn run build:css --check + CORRECTCSS=$? + if [ "$CORRECTCSS" -ne "0" ]; then + FINAL_STATUS=1 + printf "\n${red}ERROR: The compiled CSS from the PCSS files" + printf "\n does not match the current CSS files. Some added" + printf "\n or updated JavaScript package made changes." + printf "\n Recompile the CSS with: yarn run build:css${reset}\n\n" + fi + cd $TOP_LEVEL + # Add a separator line to make the output easier to read. + printf "\n" + printf -- '-%.0s' {1..100} + printf "\n" +fi + +for FILE in $FILES; do + STATUS=0; + # Print a line to separate spellcheck output from per file output. + printf "Checking %s\n" "$FILE" + printf "\n" + + # Ensure the file still exists (i.e. is not being deleted). + if [ -a $FILE ]; then + if [ ${FILE: -3} != ".sh" ]; then + if [ -x $FILE ]; then + printf "${red}check failed:${reset} file $FILE should not be executable\n" + STATUS=1 + fi + fi + fi + + # Don't commit changes to vendor. + if [[ "$FILE" =~ ^vendor/ ]]; then + printf "${red}check failed:${reset} file in vendor directory being committed ($FILE)\n" + STATUS=1 + fi + + # Don't commit changes to core/node_modules. + if [[ "$FILE" =~ ^core/node_modules/ ]]; then + printf "${red}check failed:${reset} file in core/node_modules directory being committed ($FILE)\n" + STATUS=1 + fi + + ############################################################################ + ### PHP AND YAML FILES + ############################################################################ + if [[ -f "$TOP_LEVEL/$FILE" ]] && [[ $FILE =~ \.(inc|install|module|php|profile|test|theme|yml)$ ]] && [[ $PHPCS_XML_DIST_FILE_CHANGED == "0" ]] && [[ "$DRUPALCI" == "0" ]]; then + # Test files with phpcs rules. + vendor/bin/phpcs "$TOP_LEVEL/$FILE" --standard="$TOP_LEVEL/core/phpcs.xml.dist" + PHPCS=$? + if [ "$PHPCS" -ne "0" ]; then + # If there are failures set the status to a number other than 0. + STATUS=1 + else + printf "PHPCS: $FILE ${green}passed${reset}\n" + fi + fi + + ############################################################################ + ### YAML FILES + ############################################################################ + if [[ -f "$TOP_LEVEL/$FILE" ]] && [[ $FILE =~ \.yml$ ]]; then + # Test files with ESLint. + cd "$TOP_LEVEL/core" + node ./node_modules/eslint/bin/eslint.js --quiet --resolve-plugins-relative-to . "$TOP_LEVEL/$FILE" + YAMLLINT=$? + if [ "$YAMLLINT" -ne "0" ]; then + # If there are failures set the status to a number other than 0. + STATUS=1 + else + printf "ESLint: $FILE ${green}passed${reset}\n" + fi + cd $TOP_LEVEL + fi + + ############################################################################ + ### JAVASCRIPT FILES + ############################################################################ + if [[ -f "$TOP_LEVEL/$FILE" ]] && [[ $FILE =~ \.js$ ]]; then + cd "$TOP_LEVEL/core" + # Check the coding standards. + node ./node_modules/eslint/bin/eslint.js --quiet --config=.eslintrc.passing.json "$TOP_LEVEL/$FILE" + JSLINT=$? + if [ "$JSLINT" -ne "0" ]; then + # No need to write any output the node command will do this for us. + STATUS=1 + else + printf "ESLint: $FILE ${green}passed${reset}\n" + fi + cd $TOP_LEVEL + fi + + ############################################################################ + ### CSS FILES + ############################################################################ + if [[ -f "$TOP_LEVEL/$FILE" ]] && [[ $FILE =~ \.css$ ]]; then + # Work out the root name of the CSS so we can ensure that the PostCSS + # version has been compiled correctly. + if [[ $FILE =~ \.pcss\.css$ ]]; then + BASENAME=${FILE%.pcss.css} + COMPILE_CHECK=1 + else + BASENAME=${FILE%.css} + # We only need to compile check if the .pcss.css file is not also + # changing. This is because the compile check will occur for the + # .pcss.css file. This might occur if the compiled stylesheets have + # changed. + contains_element "$BASENAME.pcss.css" "${FILES[@]}" + HASPOSTCSS=$? + if [ "$HASPOSTCSS" -ne "0" ]; then + COMPILE_CHECK=1 + else + COMPILE_CHECK=0 + fi + fi + # PostCSS + if [[ "$COMPILE_CHECK" == "1" ]] && [[ -f "$TOP_LEVEL/$BASENAME.pcss.css" ]]; then + cd "$TOP_LEVEL/core" + yarn run build:css --check --file "$TOP_LEVEL/$BASENAME.pcss.css" + CORRECTCSS=$? + if [ "$CORRECTCSS" -ne "0" ]; then + # If the CSS does not match the PCSS, set the status to a number other + # than 0. + STATUS=1 + printf "\n${red}ERROR: The compiled CSS from" + printf "\n ${BASENAME}.pcss.css" + printf "\n does not match its CSS file. Recompile the CSS with:" + printf "\n yarn run build:css${reset}\n\n" + fi + cd $TOP_LEVEL + fi + fi + if [[ -f "$TOP_LEVEL/$FILE" ]] && [[ $FILE =~ \.css$ ]] && [[ -f "core/node_modules/.bin/stylelint" ]]; then + BASENAME=${FILE%.css} + # We only need to use stylelint on the .pcss.css file. So if this CSS file + # has a corresponding .pcss don't do stylelint. + if [[ $FILE =~ \.pcss\.css$ ]] || [[ ! -f "$TOP_LEVEL/$BASENAME.pcss.css" ]]; then + cd "$TOP_LEVEL/core" + node_modules/.bin/stylelint --allow-empty-input "$TOP_LEVEL/$FILE" + if [ "$?" -ne "0" ]; then + STATUS=1 + else + printf "STYLELINT: $FILE ${green}passed${reset}\n" + fi + cd $TOP_LEVEL + fi + fi + + if [[ "$STATUS" == "1" ]]; then + FINAL_STATUS=1 + # There is no need to print a failure message. The fail will be described + # already. + else + printf "%s ${green}passed${reset}\n" "$FILE" + fi + + # Print a line to separate each file's checks. + printf "\n" + printf -- '-%.0s' {1..100} + printf "\n" +done + +if [[ "$FINAL_STATUS" == "1" ]] && [[ "$DRUPALCI" == "1" ]]; then + printf "${red}Drupal code quality checks failed.${reset}\n" + printf "To reproduce this output locally:\n" + printf "* Apply the change as a patch\n" + printf "* Run this command locally: sh ./core/scripts/dev/commit-code-check.sh\n" + printf "OR:\n" + printf "* From the merge request branch\n" + printf "* Run this command locally: sh ./core/scripts/dev/commit-code-check.sh --branch %s\n" "$DRUPAL_VERSION" +fi +exit $FINAL_STATUS diff --git a/.ddev/commands/web/cspell-check b/.ddev/commands/web/cspell-check new file mode 100755 index 0000000..b858f56 --- /dev/null +++ b/.ddev/commands/web/cspell-check @@ -0,0 +1,18 @@ +#!/bin/bash + +## Description: This script performs cspell checks. +## Usage: cspell-check [flags] +## Example: "ddev cspell-check" + +# Installs dependencies if not already run. +if [ ! -d /var/www/html/repos/drupal/core/node_modules/.bin ]; then + + corepack enable + + yarn --cwd /var/www/html/repos/drupal/core install +fi + +TOP_LEVEL="/var/www/html/repos/drupal/core" +cd $TOP_LEVEL + +yarn run spellcheck:core --no-must-find-files --cache --cache-strategy content diff --git a/.ddev/commands/web/install b/.ddev/commands/web/install new file mode 100755 index 0000000..d42fff5 --- /dev/null +++ b/.ddev/commands/web/install @@ -0,0 +1,8 @@ +#!/bin/bash + +## Description: Performs a default drupal installation +## Usage: install +## Example: "ddev install" + +drush site:install standard --account-name=admin --account-pass=admin --site-name="Drupal 11" -y +# drush en admin_toolbar admin_toolbar_tools devel diff --git a/.ddev/commands/web/nightwatch b/.ddev/commands/web/nightwatch new file mode 100755 index 0000000..4b56faf --- /dev/null +++ b/.ddev/commands/web/nightwatch @@ -0,0 +1,12 @@ +#!/bin/bash + +## Description: Run Nightwatch +## Usage: nightwatch [flags] [args] +## Example: "ddev nightwatch" or "ddev nightwatch --tag core" + +# Installs dependencies if not already run. +if [ ! -d /var/www/html/repos/drupal/core/node_modules ]; then + yarn --cwd /var/www/html/repos/drupal/core install +fi + +yarn --cwd /var/www/html/repos/drupal/core test:nightwatch $@ diff --git a/.ddev/commands/web/phpcbf b/.ddev/commands/web/phpcbf new file mode 100755 index 0000000..32cc3dd --- /dev/null +++ b/.ddev/commands/web/phpcbf @@ -0,0 +1,11 @@ +#!/bin/bash + +## Description: Run phpcbf +## Usage: phpcbf [flags] [args] +## Example: "ddev phpcbf web/modules/contrib" + +TOP_LEVEL="/var/www/html/repos/drupal" +cd $TOP_LEVEL + +/var/www/html/vendor/bin/phpcbf --standard=Drupal,DrupalPractice $@ || \ +echo "Return code ignored" diff --git a/.ddev/commands/web/phpcs b/.ddev/commands/web/phpcs new file mode 100755 index 0000000..aac975c --- /dev/null +++ b/.ddev/commands/web/phpcs @@ -0,0 +1,11 @@ +#!/bin/bash + +## Description: Run phpcs +## Usage: phpcs [flags] [args] +## Example: "ddev phpcs web/modules/contrib" + +TOP_LEVEL="/var/www/html/repos/drupal" +cd $TOP_LEVEL + +/var/www/html/vendor/bin/phpcs --standard=Drupal,DrupalPractice $@ || \ +echo "Return code ignored" diff --git a/.ddev/commands/web/phpstan b/.ddev/commands/web/phpstan new file mode 100755 index 0000000..314e3a7 --- /dev/null +++ b/.ddev/commands/web/phpstan @@ -0,0 +1,11 @@ +#!/bin/bash + +## Description: Run phpstan +## Usage: phpstan [flags] [args] +## Example: "ddev phpstan core/modules/migrate_drupal_ui" + +TOP_LEVEL="/var/www/html/repos/drupal" +cd $TOP_LEVEL + +/var/www/html/vendor/bin/phpstan analyze --configuration="$TOP_LEVEL/core/phpstan.neon.dist" --xdebug --no-ansi --memory-limit=2G $@ || \ +echo "Return code ignored" diff --git a/.ddev/commands/web/phpunit b/.ddev/commands/web/phpunit new file mode 100755 index 0000000..cf1b575 --- /dev/null +++ b/.ddev/commands/web/phpunit @@ -0,0 +1,10 @@ +#!/bin/bash + +## Description: Run PHPUnit +## Usage: phpunit [flags] [args] +## Example: "ddev phpunit --group big_pipe" or "ddev phpunit web/core/modules/action" + +TOP_LEVEL="/var/www/html/repos/drupal" +cd $TOP_LEVEL + +/var/www/html/vendor/bin/phpunit -c /var/www/html/web/core/phpunit.xml.dist $@ diff --git a/.ddev/commands/web/tests-cleanup b/.ddev/commands/web/tests-cleanup new file mode 100755 index 0000000..690a769 --- /dev/null +++ b/.ddev/commands/web/tests-cleanup @@ -0,0 +1,19 @@ +#!/bin/bash + +## Description: Clean up test results +## Usage: tests-cleanup +## Example: "ddev tests-cleanup" + +TOP_LEVEL="/var/www/html" +cd $TOP_LEVEL + +if [ ! -d "web/sites/simpletest/browser_output" ] +then + echo "The expected folder web/sites/simpletest/browser_output does not exist." + exit +fi + +rm web/sites/simpletest/browser_output/*.counter +rm web/sites/simpletest/browser_output/*.html + +echo "Test files removed." diff --git a/.ddev/config.yaml b/.ddev/config.yaml new file mode 100644 index 0000000..6e53d9b --- /dev/null +++ b/.ddev/config.yaml @@ -0,0 +1,267 @@ +type: drupal +docroot: web +php_version: "8.3" +webserver_type: nginx-fpm +router_http_port: "80" +router_https_port: "443" +xdebug_enabled: false +additional_hostnames: + - drupal-core-testing +additional_fqdns: [] +database: + type: mariadb + version: "10.11" +nfs_mount_enabled: false +mutagen_enabled: false +use_dns_when_possible: true +composer_version: "2" +web_environment: [] +# webimage_extra_packages: [python3, python3-pip] +nodejs_version: "20" +project_tld: local +timezone: Asia/Kolkata +hooks: + post-start: + - exec: mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS phpunit; GRANT ALL ON phpunit.* to 'db'@'%';" + service: db + # - exec: pip install mkdocs-material +# Key features of ddev's config.yaml: + +# name: # Name of the project, automatically provides +# http://projectname.ddev.site and https://projectname.ddev.site + +# type: # drupal6/7/8, backdrop, typo3, wordpress, php + +# docroot: # Relative path to the directory containing index.php. + +# php_version: "7.4" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2" + +# You can explicitly specify the webimage but this +# is not recommended, as the images are often closely tied to ddev's' behavior, +# so this can break upgrades. + +# webimage: # nginx/php docker image. + +# database: +# type: # mysql, mariadb +# version: # database version, like "10.3" or "8.0" +# Note that mariadb_version or mysql_version from v1.18 and earlier +# will automatically be converted to this notation with just a "ddev config --auto" + +# router_http_port: # Port to be used for http (defaults to port 80) +# router_https_port: # Port for https (defaults to 443) + +# xdebug_enabled: false # Set to true to enable xdebug and "ddev start" or "ddev restart" +# Note that for most people the commands +# "ddev xdebug" to enable xdebug and "ddev xdebug off" to disable it work better, +# as leaving xdebug enabled all the time is a big performance hit. + +# xhprof_enabled: false # Set to true to enable xhprof and "ddev start" or "ddev restart" +# Note that for most people the commands +# "ddev xhprof" to enable xhprof and "ddev xhprof off" to disable it work better, +# as leaving xhprof enabled all the time is a big performance hit. + +# webserver_type: nginx-fpm # or apache-fpm + +# timezone: Europe/Berlin +# This is the timezone used in the containers and by PHP; +# it can be set to any valid timezone, +# see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones +# For example Europe/Dublin or MST7MDT + +# composer_root: +# Relative path to the composer root directory from the project root. This is +# the directory which contains the composer.json and where all Composer related +# commands are executed. + +# composer_version: "2" +# You can set it to "" or "2" (default) for Composer v2 or "1" for Composer v1 +# to use the latest major version available at the time your container is built. +# It is also possible to use each other Composer version channel. This includes: +# - 2.2 (latest Composer LTS version) +# - stable +# - preview +# - snapshot +# Alternatively, an explicit Composer version may be specified, for example "2.2.18". +# To reinstall Composer after the image was built, run "ddev debug refresh". + +# nodejs_version: "16" +# change from the default system Node.js version to another supported version, like 12, 14, 17, 18. +# Note that you can use 'ddev nvm' or nvm inside the web container to provide nearly any +# Node.js version, including v6, etc. + +# additional_hostnames: +# - somename +# - someothername +# would provide http and https URLs for "somename.ddev.site" +# and "someothername.ddev.site". + +# additional_fqdns: +# - example.com +# - sub1.example.com +# would provide http and https URLs for "example.com" and "sub1.example.com" +# Please take care with this because it can cause great confusion. + +# upload_dir: custom/upload/dir +# would set the destination path for ddev import-files to /custom/upload/dir +# When mutagen is enabled this path is bind-mounted so that all the files +# in the upload_dir don't have to be synced into mutagen + +# working_dir: +# web: /var/www/html +# db: /home +# would set the default working directory for the web and db services. +# These values specify the destination directory for ddev ssh and the +# directory in which commands passed into ddev exec are run. + +# omit_containers: [db, dba, ddev-ssh-agent] +# Currently only these containers are supported. Some containers can also be +# omitted globally in the ~/.ddev/global_config.yaml. Note that if you omit +# the "db" container, several standard features of ddev that access the +# database container will be unusable. In the global configuration it is also +# possible to omit ddev-router, but not here. + +# nfs_mount_enabled: false +# Great performance improvement but requires host configuration first. +# See https://ddev.readthedocs.io/en/latest/users/install/performance/#nfs + +# mutagen_enabled: false +# Performance improvement using mutagen asynchronous updates. +# See https://ddev.readthedocs.io/en/latest/users/install/performance/#mutagen + +# fail_on_hook_fail: False +# Decide whether 'ddev start' should be interrupted by a failing hook + +# host_https_port: "59002" +# The host port binding for https can be explicitly specified. It is +# dynamic unless otherwise specified. +# This is not used by most people, most people use the *router* instead +# of the localhost port. + +# host_webserver_port: "59001" +# The host port binding for the ddev-webserver can be explicitly specified. It is +# dynamic unless otherwise specified. +# This is not used by most people, most people use the *router* instead +# of the localhost port. + +# host_db_port: "59002" +# The host port binding for the ddev-dbserver can be explicitly specified. It is dynamic +# unless explicitly specified. + +# phpmyadmin_port: "8036" +# phpmyadmin_https_port: "8037" +# The PHPMyAdmin ports can be changed from the default 8036 and 8037 + +# host_phpmyadmin_port: "8036" +# The phpmyadmin (dba) port is not normally bound on the host at all, instead being routed +# through ddev-router, but it can be specified and bound. + +# mailhog_port: "8025" +# mailhog_https_port: "8026" +# The MailHog ports can be changed from the default 8025 and 8026 + +# host_mailhog_port: "8025" +# The mailhog port is not normally bound on the host at all, instead being routed +# through ddev-router, but it can be bound directly to localhost if specified here. + +# webimage_extra_packages: [php7.4-tidy, php-bcmath] +# Extra Debian packages that are needed in the webimage can be added here + +# dbimage_extra_packages: [telnet,netcat] +# Extra Debian packages that are needed in the dbimage can be added here + +# use_dns_when_possible: true +# If the host has internet access and the domain configured can +# successfully be looked up, DNS will be used for hostname resolution +# instead of editing /etc/hosts +# Defaults to true + +# project_tld: ddev.site +# The top-level domain used for project URLs +# The default "ddev.site" allows DNS lookup via a wildcard +# If you prefer you can change this to "ddev.local" to preserve +# pre-v1.9 behavior. + +# ngrok_args: --basic-auth username:pass1234 +# Provide extra flags to the "ngrok http" command, see +# https://ngrok.com/docs#http or run "ngrok http -h" + +# disable_settings_management: false +# If true, ddev will not create CMS-specific settings files like +# Drupal's settings.php/settings.ddev.php or TYPO3's AdditionalConfiguration.php +# In this case the user must provide all such settings. + +# You can inject environment variables into the web container with: +# web_environment: +# - SOMEENV=somevalue +# - SOMEOTHERENV=someothervalue + +# no_project_mount: false +# (Experimental) If true, ddev will not mount the project into the web container; +# the user is responsible for mounting it manually or via a script. +# This is to enable experimentation with alternate file mounting strategies. +# For advanced users only! + +# bind_all_interfaces: false +# If true, host ports will be bound on all network interfaces, +# not just the localhost interface. This means that ports +# will be available on the local network if the host firewall +# allows it. + +# default_container_timeout: 120 +# The default time that ddev waits for all containers to become ready can be increased from +# the default 120. This helps in importing huge databases, for example. + +#web_extra_exposed_ports: +#- name: nodejs +# container_port: 3000 +# http_port: 2999 +# https_port: 3000 +#- name: something +# container_port: 4000 +# https_port: 4000 +# http_port: 3999 +# Allows a set of extra ports to be exposed via ddev-router +# The port behavior on the ddev-webserver must be arranged separately, for example +# using web_extra_daemons. +# For example, with a web app on port 3000 inside the container, this config would +# expose that web app on https://.ddev.site:9999 and http://.ddev.site:9998 +# web_extra_exposed_ports: +# - container_port: 3000 +# http_port: 9998 +# https_port: 9999 + +#web_extra_daemons: +#- name: "http-1" +# command: "/var/www/html/node_modules/.bin/http-server -p 3000" +# directory: /var/www/html +#- name: "http-2" +# command: "/var/www/html/node_modules/.bin/http-server /var/www/html/sub -p 3000" +# directory: /var/www/html + +# override_config: false +# By default, config.*.yaml files are *merged* into the configuration +# But this means that some things can't be overridden +# For example, if you have 'nfs_mount_enabled: true'' you can't override it with a merge +# and you can't erase existing hooks or all environment variables. +# However, with "override_config: true" in a particular config.*.yaml file, +# 'nfs_mount_enabled: false' can override the existing values, and +# hooks: +# post-start: [] +# or +# web_environment: [] +# or +# additional_hostnames: [] +# can have their intended affect. 'override_config' affects only behavior of the +# config.*.yaml file it exists in. + +# Many ddev commands can be extended to run tasks before or after the +# ddev command is executed, for example "post-start", "post-import-db", +# "pre-composer", "post-composer" +# See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/ for more +# information on the commands that can be extended and the tasks you can define +# for them. Example: +#hooks: +# post-import-db: +# - exec: drush cr +# - exec: drush updb diff --git a/.ddev/docker-compose.override.yaml b/.ddev/docker-compose.override.yaml new file mode 100644 index 0000000..91832a4 --- /dev/null +++ b/.ddev/docker-compose.override.yaml @@ -0,0 +1,11 @@ +# +# This file can be used for overriding ENV variables. +# +services: + web: + environment: + - BROWSERTEST_OUTPUT_DIRECTORY=/var/www/html/web/sites/simpletest/browser_output + - BROWSERTEST_OUTPUT_BASE_URL=https://drupal-core-testing.local + - SIMPLETEST_BASE_URL=${DDEV_PRIMARY_URL} + # - SIMPLETEST_DB=sqlite://tmp/sites/simpletest/db.sqlite + - SIMPLETEST_DB=mysql://root:root@db/phpunit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62f54bd --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +repos/.DS_Store +repos/drupal/ +vendor/ +.ddev/ +.DS_Store +databases +composer.lock +web/core +web/.csslintrc +web/.eslintignore +web/.eslintrc.json +web/.ht.router.php +web/.htaccess +web/INSTALL.txt +web/README.md +web/autoload.php +web/example.gitignore +web/index.php +web/modules/README.txt +web/profiles/README.txt +web/robots.txt +web/sites/README.txt +web/sites/development.services.yml +web/sites/example.settings.local.php +web/sites/example.sites.php +web/themes/README.txt +web/update.php +web/sites/ +web/modules/contrib/ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..85c89e5 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Listen for Xdebug", + "type": "php", + "request": "launch", + "hostname": "127.0.0.1", + "port": 9003, + "pathMappings": { + "/var/www/html": "${workspaceRoot}", + } + } + ] +} diff --git a/README.md b/README.md index 69d22fa..76fd6a4 100644 --- a/README.md +++ b/README.md @@ -21,14 +21,19 @@ It allows the following: Get this into Drupal core! See https://www.drupal.org/project/drupal/issues/1792310. +## Roadmap + +Get this into Drupal core! See +https://www.drupal.org/project/drupal/issues/1792310. + ## Installation ### Basic installation To install a Drupal project for working on Drupal core: -``` -$ composer create-project joachim-n/drupal-core-development-project +```bash +composer create-project joachim-n/drupal-core-development-project ``` Composer will clone Drupal core into a 'repos/drupal' directory within the @@ -47,12 +52,12 @@ either with `drush si` or with the web UI. First, make sure your DDEV version is at least 1.23.0. Next, create a new folder for your project and `cd` into it. Then: -``` -$ ddev config --project-type=drupal --php-version=8.3 -$ ddev start -$ ddev composer create joachim-n/drupal-core-development-project -$ ddev config --update -$ ddev restart +``` bash +ddev config --project-type=drupal --php-version=8.3 +ddev start +ddev composer create joachim-n/drupal-core-development-project +ddev config --update +ddev restart ``` ### Installation on DDEV with the justafish/ddev-drupal-core-dev DDEV addon @@ -155,8 +160,8 @@ The following are required to run tests. The simplest way to run tests with this setup is to put the phpunit.xml file in the project root and then run tests from there: -``` -$ vendor/bin/phpunit web/core/PATH-TO-TEST-FILE/TestFile.php +``` bash +vendor/bin/phpunit web/core/PATH-TO-TEST-FILE/TestFile.php ``` ##### On DDEV @@ -164,8 +169,8 @@ $ vendor/bin/phpunit web/core/PATH-TO-TEST-FILE/TestFile.php 1. Copy the `phpunit-ddev.xml` file that this template provides and rename it to `phpunit.xml`: -``` -$ cp phpunit-ddev.xml phpunit.xml +``` bash +cp phpunit-ddev.xml phpunit.xml ``` 2. Change the BROWSERTEST_OUTPUT_BASE_URL value to the host URL of the project. @@ -175,8 +180,8 @@ $ cp phpunit-ddev.xml phpunit.xml 1. Copy Drupal core's sample `phpunit.xml.dist`` file to the project root and rename it to `phpunit.xml`: -``` -$ cp web/core/phpunit.xml.dist phpunit.xml +``` bash +cp web/core/phpunit.xml.dist phpunit.xml ``` 2. Change the `bootstrap` attribute so the path is correct: @@ -192,7 +197,7 @@ that it recognises the process being run from the project root. For example, in VSCode, this is done as follows in the debugger configuration: -``` +``` json "pathMappings": { // Make this work with the root project. "/ABSOLUTE/PATH/TO/PROJECT/repos/drupal": "${workspaceRoot}" @@ -227,28 +232,28 @@ Composer script. Clone the repository for this template into, say, 'drupal-dev'. -``` -$ cd drupal-dev +``` bash +cd drupal-dev # Create a folder in which to store git clones, which Composer will symlink in. -$ mkdir repos -$ cd repos +mkdir repos +cd repos # Clone Drupal core, to whatever branch you like. -$ git clone --branch 9.2.x https://git.drupalcode.org/project/drupal.git +git clone --branch 11.x https://git.drupalcode.org/project/drupal.git # Go back to the project root. -$ cd .. +cd .. # Install packages with Composer. -$ composer install +composer install ``` The Drupal core git clone will be clean apart from: -``` - sites/default/settings.php - vendor +``` bash + sites/default/settings.php + vendor ``` Since it doesn't have a .gitignore at the top level, you can add one to ignore @@ -261,8 +266,8 @@ clone of the template repository. In a separate location, do: -``` -$ composer create-project joachim-n/drupal-core-development-project NEW_PROJECT_DIRECTORY --stability=dev --repository='{"url":"/path/to/git/clone/of/project/template/","type":"vcs"}' +``` bash +composer create-project joachim-n/drupal-core-development-project NEW_PROJECT_DIRECTORY --stability=dev --repository='{"url":"/path/to/git/clone/of/project/template/","type":"vcs"}' ``` ### Workarounds @@ -282,7 +287,7 @@ otherwise code in core that expects to find a Composer autoloader fails. This is done by a Composer script after initial installation. The manual command is: -``` +``` bash ln -s ../../vendor ./repos/drupal/vendor ``` @@ -296,7 +301,7 @@ can't find the settings.php file. This is done by a Composer script after initial installation. The manual commands are: -``` +``` bash cd web && patch -p1 <../scaffold/scaffold-patch-index-php.patch cd web && patch -p1 <../scaffold/scaffold-patch-update-php.patch ``` @@ -329,7 +334,7 @@ root and symlink it into the Drupal core git clone. This is done by a Composer script after initial installation. The manual command is: -``` +``` bash mkdir -p web/sites/simpletest ln -s ../../../web/sites/simpletest repos/drupal/sites ``` @@ -339,3 +344,45 @@ ln -s ../../../web/sites/simpletest repos/drupal/sites Drupal's /composer folder is not symlinked and therefore isn't visible to Composer. It's needed for some tests, and so is declared as an autoload location. + +## Core Development Using DDEV + +1. Clone this repository by using `git clone --branch=master https://github.com/bhanu951/drupal-core-development-project.git` +2. cd repos +3. git clone --branch=11.x https://git.drupalcode.org/project/drupal.git drupal +4. ddev get drud/ddev-selenium-standalone-chrome (downloads latest chrome driver) +5. ddev composer install (from project root) +6. ddev composer require drupal/admin_toolbar drupal/devel +7. cd repos/drupal ; `git status` to track core changes + +### DDEV Commands Usage + +1. ddev phpcs core/modules/user/src/RegisterForm.php (from repos/drupal directory) +2. ddev phpcbf core/modules/user/src/RegisterForm.php (from repos/drupal directory) +3. ddev phpunit core/modules/user/tests/src/Functional/UserAdminTest.php (from repos/drupal directory) +4. ddev code-check (ddev equivalent of running `sh core/scripts/dev/commit-code-check.sh`) +5. ddev cspell-check (Checks for forbidden and new words which are not present in dictonary) +6. ddev install (Installs new site) +7. ddev drush [arguments] (from project root) + +### TODO + +1. Add DDEV Rector Commands +2. Find workaround for ddev phpstan command failures + +### Tips + +1. ddev drush si --site-name=drupal-145353 + +### Known Issues + +There is a known issue where PHPSTAN doesnt work when the +`ComponentTestDoesNotExtendCoreTest` is enabled in `core/phpstan.neon.dist` +hence it advised to comment the rule for local analysis. + +```yaml +rules: +# - Drupal\PHPStan\Rules\ComponentTestDoesNotExtendCoreTest +- PHPStan\Rules\Functions\MissingFunctionReturnTypehintRule +- PHPStan\Rules\Methods\MissingMethodReturnTypehintRule +``` diff --git a/composer.json b/composer.json index 85dc80d..2d5dae6 100644 --- a/composer.json +++ b/composer.json @@ -42,11 +42,11 @@ ], "require": { "composer/installers": "^1.9 | ^2", - "drupal/core-composer-scaffold": "*", - "drupal/drupal": "*", "drupal/core": "*", + "drupal/core-composer-scaffold": "*", "drupal/core-dev": "*", "drupal/core-recommended": "*", + "drupal/drupal": "*", "drush/drush": "^13", "phpspec/prophecy-phpunit": "*", "symfony/var-dumper": "*" @@ -62,7 +62,8 @@ "drupal/core-composer-scaffold": true, "php-http/discovery": true, "phpstan/extension-installer": true, - "dealerdirect/phpcodesniffer-composer-installer": true + "dealerdirect/phpcodesniffer-composer-installer": true, + "tbachert/spi": true } }, "scripts": { diff --git a/drush/Commands/core_development/DevelopmentProjectCommands.php b/drush/Commands/core_development/DevelopmentProjectCommands.php index 85ac1cf..00acf0f 100644 --- a/drush/Commands/core_development/DevelopmentProjectCommands.php +++ b/drush/Commands/core_development/DevelopmentProjectCommands.php @@ -30,7 +30,7 @@ public function __construct( public static function createEarly(DrushContainer $drush_container): self { $commandHandler = new static( - $drush_container->get('loader') + $drush_container->get('loader') ); return $commandHandler; diff --git a/repos/.gitkeep b/repos/.gitkeep new file mode 100644 index 0000000..e69de29 From 50349eb8e46a3961cfce4970951cb8326dfcaabe Mon Sep 17 00:00:00 2001 From: Bhanu <8525040+bhanu951@users.noreply.github.com> Date: Thu, 31 Oct 2024 20:14:58 +0530 Subject: [PATCH 2/7] DDEV Config updated. --- .ddev/config.yaml | 262 ++-------------------------------------------- 1 file changed, 10 insertions(+), 252 deletions(-) diff --git a/.ddev/config.yaml b/.ddev/config.yaml index 6e53d9b..8a2e8c0 100644 --- a/.ddev/config.yaml +++ b/.ddev/config.yaml @@ -2,266 +2,24 @@ type: drupal docroot: web php_version: "8.3" webserver_type: nginx-fpm -router_http_port: "80" -router_https_port: "443" xdebug_enabled: false -additional_hostnames: - - drupal-core-testing +additional_hostnames: [] additional_fqdns: [] database: - type: mariadb - version: "10.11" -nfs_mount_enabled: false -mutagen_enabled: false + type: mariadb + version: "10.11" use_dns_when_possible: true composer_version: "2" -web_environment: [] -# webimage_extra_packages: [python3, python3-pip] +corepack_enable: true nodejs_version: "20" project_tld: local -timezone: Asia/Kolkata +web_environment: + - BROWSERTEST_OUTPUT_DIRECTORY=/var/www/html/web/sites/simpletest/browser_output + - BROWSERTEST_OUTPUT_BASE_URL=https://drupal-core-testing.local + - SIMPLETEST_BASE_URL=${DDEV_PRIMARY_URL} + # - SIMPLETEST_DB=sqlite://tmp/sites/simpletest/db.sqlite + - SIMPLETEST_DB=mysql://root:root@db/phpunit hooks: post-start: - exec: mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS phpunit; GRANT ALL ON phpunit.* to 'db'@'%';" service: db - # - exec: pip install mkdocs-material -# Key features of ddev's config.yaml: - -# name: # Name of the project, automatically provides -# http://projectname.ddev.site and https://projectname.ddev.site - -# type: # drupal6/7/8, backdrop, typo3, wordpress, php - -# docroot: # Relative path to the directory containing index.php. - -# php_version: "7.4" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2" - -# You can explicitly specify the webimage but this -# is not recommended, as the images are often closely tied to ddev's' behavior, -# so this can break upgrades. - -# webimage: # nginx/php docker image. - -# database: -# type: # mysql, mariadb -# version: # database version, like "10.3" or "8.0" -# Note that mariadb_version or mysql_version from v1.18 and earlier -# will automatically be converted to this notation with just a "ddev config --auto" - -# router_http_port: # Port to be used for http (defaults to port 80) -# router_https_port: # Port for https (defaults to 443) - -# xdebug_enabled: false # Set to true to enable xdebug and "ddev start" or "ddev restart" -# Note that for most people the commands -# "ddev xdebug" to enable xdebug and "ddev xdebug off" to disable it work better, -# as leaving xdebug enabled all the time is a big performance hit. - -# xhprof_enabled: false # Set to true to enable xhprof and "ddev start" or "ddev restart" -# Note that for most people the commands -# "ddev xhprof" to enable xhprof and "ddev xhprof off" to disable it work better, -# as leaving xhprof enabled all the time is a big performance hit. - -# webserver_type: nginx-fpm # or apache-fpm - -# timezone: Europe/Berlin -# This is the timezone used in the containers and by PHP; -# it can be set to any valid timezone, -# see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones -# For example Europe/Dublin or MST7MDT - -# composer_root: -# Relative path to the composer root directory from the project root. This is -# the directory which contains the composer.json and where all Composer related -# commands are executed. - -# composer_version: "2" -# You can set it to "" or "2" (default) for Composer v2 or "1" for Composer v1 -# to use the latest major version available at the time your container is built. -# It is also possible to use each other Composer version channel. This includes: -# - 2.2 (latest Composer LTS version) -# - stable -# - preview -# - snapshot -# Alternatively, an explicit Composer version may be specified, for example "2.2.18". -# To reinstall Composer after the image was built, run "ddev debug refresh". - -# nodejs_version: "16" -# change from the default system Node.js version to another supported version, like 12, 14, 17, 18. -# Note that you can use 'ddev nvm' or nvm inside the web container to provide nearly any -# Node.js version, including v6, etc. - -# additional_hostnames: -# - somename -# - someothername -# would provide http and https URLs for "somename.ddev.site" -# and "someothername.ddev.site". - -# additional_fqdns: -# - example.com -# - sub1.example.com -# would provide http and https URLs for "example.com" and "sub1.example.com" -# Please take care with this because it can cause great confusion. - -# upload_dir: custom/upload/dir -# would set the destination path for ddev import-files to /custom/upload/dir -# When mutagen is enabled this path is bind-mounted so that all the files -# in the upload_dir don't have to be synced into mutagen - -# working_dir: -# web: /var/www/html -# db: /home -# would set the default working directory for the web and db services. -# These values specify the destination directory for ddev ssh and the -# directory in which commands passed into ddev exec are run. - -# omit_containers: [db, dba, ddev-ssh-agent] -# Currently only these containers are supported. Some containers can also be -# omitted globally in the ~/.ddev/global_config.yaml. Note that if you omit -# the "db" container, several standard features of ddev that access the -# database container will be unusable. In the global configuration it is also -# possible to omit ddev-router, but not here. - -# nfs_mount_enabled: false -# Great performance improvement but requires host configuration first. -# See https://ddev.readthedocs.io/en/latest/users/install/performance/#nfs - -# mutagen_enabled: false -# Performance improvement using mutagen asynchronous updates. -# See https://ddev.readthedocs.io/en/latest/users/install/performance/#mutagen - -# fail_on_hook_fail: False -# Decide whether 'ddev start' should be interrupted by a failing hook - -# host_https_port: "59002" -# The host port binding for https can be explicitly specified. It is -# dynamic unless otherwise specified. -# This is not used by most people, most people use the *router* instead -# of the localhost port. - -# host_webserver_port: "59001" -# The host port binding for the ddev-webserver can be explicitly specified. It is -# dynamic unless otherwise specified. -# This is not used by most people, most people use the *router* instead -# of the localhost port. - -# host_db_port: "59002" -# The host port binding for the ddev-dbserver can be explicitly specified. It is dynamic -# unless explicitly specified. - -# phpmyadmin_port: "8036" -# phpmyadmin_https_port: "8037" -# The PHPMyAdmin ports can be changed from the default 8036 and 8037 - -# host_phpmyadmin_port: "8036" -# The phpmyadmin (dba) port is not normally bound on the host at all, instead being routed -# through ddev-router, but it can be specified and bound. - -# mailhog_port: "8025" -# mailhog_https_port: "8026" -# The MailHog ports can be changed from the default 8025 and 8026 - -# host_mailhog_port: "8025" -# The mailhog port is not normally bound on the host at all, instead being routed -# through ddev-router, but it can be bound directly to localhost if specified here. - -# webimage_extra_packages: [php7.4-tidy, php-bcmath] -# Extra Debian packages that are needed in the webimage can be added here - -# dbimage_extra_packages: [telnet,netcat] -# Extra Debian packages that are needed in the dbimage can be added here - -# use_dns_when_possible: true -# If the host has internet access and the domain configured can -# successfully be looked up, DNS will be used for hostname resolution -# instead of editing /etc/hosts -# Defaults to true - -# project_tld: ddev.site -# The top-level domain used for project URLs -# The default "ddev.site" allows DNS lookup via a wildcard -# If you prefer you can change this to "ddev.local" to preserve -# pre-v1.9 behavior. - -# ngrok_args: --basic-auth username:pass1234 -# Provide extra flags to the "ngrok http" command, see -# https://ngrok.com/docs#http or run "ngrok http -h" - -# disable_settings_management: false -# If true, ddev will not create CMS-specific settings files like -# Drupal's settings.php/settings.ddev.php or TYPO3's AdditionalConfiguration.php -# In this case the user must provide all such settings. - -# You can inject environment variables into the web container with: -# web_environment: -# - SOMEENV=somevalue -# - SOMEOTHERENV=someothervalue - -# no_project_mount: false -# (Experimental) If true, ddev will not mount the project into the web container; -# the user is responsible for mounting it manually or via a script. -# This is to enable experimentation with alternate file mounting strategies. -# For advanced users only! - -# bind_all_interfaces: false -# If true, host ports will be bound on all network interfaces, -# not just the localhost interface. This means that ports -# will be available on the local network if the host firewall -# allows it. - -# default_container_timeout: 120 -# The default time that ddev waits for all containers to become ready can be increased from -# the default 120. This helps in importing huge databases, for example. - -#web_extra_exposed_ports: -#- name: nodejs -# container_port: 3000 -# http_port: 2999 -# https_port: 3000 -#- name: something -# container_port: 4000 -# https_port: 4000 -# http_port: 3999 -# Allows a set of extra ports to be exposed via ddev-router -# The port behavior on the ddev-webserver must be arranged separately, for example -# using web_extra_daemons. -# For example, with a web app on port 3000 inside the container, this config would -# expose that web app on https://.ddev.site:9999 and http://.ddev.site:9998 -# web_extra_exposed_ports: -# - container_port: 3000 -# http_port: 9998 -# https_port: 9999 - -#web_extra_daemons: -#- name: "http-1" -# command: "/var/www/html/node_modules/.bin/http-server -p 3000" -# directory: /var/www/html -#- name: "http-2" -# command: "/var/www/html/node_modules/.bin/http-server /var/www/html/sub -p 3000" -# directory: /var/www/html - -# override_config: false -# By default, config.*.yaml files are *merged* into the configuration -# But this means that some things can't be overridden -# For example, if you have 'nfs_mount_enabled: true'' you can't override it with a merge -# and you can't erase existing hooks or all environment variables. -# However, with "override_config: true" in a particular config.*.yaml file, -# 'nfs_mount_enabled: false' can override the existing values, and -# hooks: -# post-start: [] -# or -# web_environment: [] -# or -# additional_hostnames: [] -# can have their intended affect. 'override_config' affects only behavior of the -# config.*.yaml file it exists in. - -# Many ddev commands can be extended to run tasks before or after the -# ddev command is executed, for example "post-start", "post-import-db", -# "pre-composer", "post-composer" -# See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/ for more -# information on the commands that can be extended and the tasks you can define -# for them. Example: -#hooks: -# post-import-db: -# - exec: drush cr -# - exec: drush updb From 5e4b846bbfe0bd923fe6465602feff8bf1451caa Mon Sep 17 00:00:00 2001 From: Bhanu <8525040+bhanu951@users.noreply.github.com> Date: Thu, 31 Oct 2024 20:15:51 +0530 Subject: [PATCH 3/7] Delete .ddev/commands/web/README.txt --- .ddev/commands/web/README.txt | 4 ---- 1 file changed, 4 deletions(-) delete mode 100755 .ddev/commands/web/README.txt diff --git a/.ddev/commands/web/README.txt b/.ddev/commands/web/README.txt deleted file mode 100755 index e0c4a05..0000000 --- a/.ddev/commands/web/README.txt +++ /dev/null @@ -1,4 +0,0 @@ -#ddev-generated -Scripts in this directory will be executed inside the web container. - -See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/#environment-variables-provided for a list of environment variables that can be used in the scripts. From 157c444ccf2e359c6e9fb51ea64ccbcaa88d869b Mon Sep 17 00:00:00 2001 From: Bhanu <8525040+bhanu951@users.noreply.github.com> Date: Thu, 31 Oct 2024 20:16:34 +0530 Subject: [PATCH 4/7] Update .vscode/launch.json Co-authored-by: Randy Fay --- .vscode/launch.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 85c89e5..43a2f71 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "name": "Listen for Xdebug", "type": "php", "request": "launch", - "hostname": "127.0.0.1", + "hostname": "0.0.0.0", "port": 9003, "pathMappings": { "/var/www/html": "${workspaceRoot}", From 4a9de55ea3807236ae28482015b0c7dcafb0c804 Mon Sep 17 00:00:00 2001 From: Bhanu <8525040+bhanu951@users.noreply.github.com> Date: Thu, 31 Oct 2024 20:18:52 +0530 Subject: [PATCH 5/7] Delete .ddev/docker-compose.override.yaml --- .ddev/docker-compose.override.yaml | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .ddev/docker-compose.override.yaml diff --git a/.ddev/docker-compose.override.yaml b/.ddev/docker-compose.override.yaml deleted file mode 100644 index 91832a4..0000000 --- a/.ddev/docker-compose.override.yaml +++ /dev/null @@ -1,11 +0,0 @@ -# -# This file can be used for overriding ENV variables. -# -services: - web: - environment: - - BROWSERTEST_OUTPUT_DIRECTORY=/var/www/html/web/sites/simpletest/browser_output - - BROWSERTEST_OUTPUT_BASE_URL=https://drupal-core-testing.local - - SIMPLETEST_BASE_URL=${DDEV_PRIMARY_URL} - # - SIMPLETEST_DB=sqlite://tmp/sites/simpletest/db.sqlite - - SIMPLETEST_DB=mysql://root:root@db/phpunit From baf799b12a576a79bca7a3b3da3d270c398415f9 Mon Sep 17 00:00:00 2001 From: Bhanu <8525040+bhanu951@users.noreply.github.com> Date: Thu, 31 Oct 2024 20:27:26 +0530 Subject: [PATCH 6/7] Update README. --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index 76fd6a4..d7b7abb 100644 --- a/README.md +++ b/README.md @@ -21,11 +21,6 @@ It allows the following: Get this into Drupal core! See https://www.drupal.org/project/drupal/issues/1792310. -## Roadmap - -Get this into Drupal core! See -https://www.drupal.org/project/drupal/issues/1792310. - ## Installation ### Basic installation From 36b68079f6280bd938bd1e92417b39d7298daf3d Mon Sep 17 00:00:00 2001 From: Bhanu <8525040+bhanu951@users.noreply.github.com> Date: Thu, 31 Oct 2024 20:35:39 +0530 Subject: [PATCH 7/7] Updated DDEV Configuration. --- .ddev/config.yaml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.ddev/config.yaml b/.ddev/config.yaml index 8a2e8c0..d007d47 100644 --- a/.ddev/config.yaml +++ b/.ddev/config.yaml @@ -3,23 +3,22 @@ docroot: web php_version: "8.3" webserver_type: nginx-fpm xdebug_enabled: false -additional_hostnames: [] +additional_hostnames: + - drupal-core-testing additional_fqdns: [] database: type: mariadb version: "10.11" +hooks: + post-start: + - exec: mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS phpunit; GRANT ALL ON phpunit.* to 'db'@'%';" + service: db +project_tld: local use_dns_when_possible: true composer_version: "2" -corepack_enable: true -nodejs_version: "20" -project_tld: local web_environment: - BROWSERTEST_OUTPUT_DIRECTORY=/var/www/html/web/sites/simpletest/browser_output - BROWSERTEST_OUTPUT_BASE_URL=https://drupal-core-testing.local - SIMPLETEST_BASE_URL=${DDEV_PRIMARY_URL} - # - SIMPLETEST_DB=sqlite://tmp/sites/simpletest/db.sqlite - SIMPLETEST_DB=mysql://root:root@db/phpunit -hooks: - post-start: - - exec: mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS phpunit; GRANT ALL ON phpunit.* to 'db'@'%';" - service: db +corepack_enable: true