Skip to content

Commit 3f06737

Browse files
author
Ofer Shaal
committed
fix: support drupal 11 (#146)
1 parent c66291d commit 3f06737

20 files changed

Lines changed: 475 additions & 133 deletions

.ddev/config.yaml

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
name: DrupalPod
2-
type: drupal10
2+
type: drupal
33
docroot: web
4-
php_version: "8.1"
4+
php_version: "8.3"
55
webserver_type: nginx-fpm
66
xdebug_enabled: false
77
additional_hostnames: []
88
additional_fqdns: []
99
database:
1010
type: mariadb
11-
version: "10.4"
11+
version: "10.6"
1212
use_dns_when_possible: true
1313
composer_version: "2"
1414
web_environment: []
15-
nodejs_version: "18"
15+
corepack_enable: false
1616

1717
# Key features of DDEV's config.yaml:
1818

1919
# name: <projectname> # Name of the project, automatically provides
2020
# http://projectname.ddev.site and https://projectname.ddev.site
2121

22-
# type: <projecttype> # drupal6/7/8, backdrop, typo3, wordpress, php
22+
# type: <projecttype> # backdrop, craftcms, django4, drupal, drupal6, drupal7, laravel, magento, magento2, php, python, shopware6, silverstripe, typo3, wordpress
23+
# See https://ddev.readthedocs.io/en/stable/users/quickstart/ for more
24+
# information on the different project types
25+
# "drupal" covers recent Drupal 8+
2326

2427
# docroot: <relative_path> # Relative path to the directory containing index.php.
2528

26-
# php_version: "8.1" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"
29+
# php_version: "8.2" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"
2730

2831
# You can explicitly specify the webimage but this
2932
# is not recommended, as the images are often closely tied to DDEV's' behavior,
@@ -33,9 +36,9 @@ nodejs_version: "18"
3336

3437
# database:
3538
# type: <dbtype> # mysql, mariadb, postgres
36-
# version: <version> # database version, like "10.4" or "8.0"
39+
# version: <version> # database version, like "10.11" or "8.0"
3740
# MariaDB versions can be 5.5-10.8 and 10.11, MySQL versions can be 5.5-8.0
38-
# PostgreSQL versions can be 9-15.
41+
# PostgreSQL versions can be 9-16.
3942

4043
# router_http_port: <port> # Port to be used for http (defaults to global configuration, usually 80)
4144
# router_https_port: <port> # Port for https (defaults to global configuration, usually 443)
@@ -74,10 +77,17 @@ nodejs_version: "18"
7477
# Alternatively, an explicit Composer version may be specified, for example "2.2.18".
7578
# To reinstall Composer after the image was built, run "ddev debug refresh".
7679

77-
# nodejs_version: "18"
78-
# change from the default system Node.js version to another supported version, like 14, 16, 18, 20.
79-
# Note that you can use 'ddev nvm' or nvm inside the web container to provide nearly any
80-
# Node.js version, including v6, etc.
80+
# nodejs_version: "20"
81+
# change from the default system Node.js version to any other version.
82+
# Numeric version numbers can be complete (i.e. 18.15.0) or
83+
# incomplete (18, 17.2, 16). 'lts' and 'latest' can be used as well along with
84+
# other named releases.
85+
# see https://www.npmjs.com/package/n#specifying-nodejs-versions
86+
# Note that you can continue using 'ddev nvm' or nvm inside the web container
87+
# to change the project's installed node version if you need to.
88+
89+
# corepack_enable: false
90+
# Change to 'true' to 'corepack enable' and gain access to latest versions of yarn/pnpm
8191

8292
# additional_hostnames:
8393
# - somename
@@ -105,6 +115,13 @@ nodejs_version: "18"
105115
# If true, turns off the normal warning that says
106116
# "You have Mutagen enabled and your 'php' project type doesn't have upload_dirs set"
107117

118+
# ddev_version_constraint: ""
119+
# Example:
120+
# ddev_version_constraint: ">= 1.22.4"
121+
# This will enforce that the running ddev version is within this constraint.
122+
# See https://github.com/Masterminds/semver#checking-version-constraints for
123+
# supported constraint formats
124+
108125
# working_dir:
109126
# web: /var/www/html
110127
# db: /home
@@ -129,8 +146,8 @@ nodejs_version: "18"
129146
# - "mutagen": enables Mutagen for this project.
130147
# - "nfs": enables NFS for this project.
131148
#
132-
# See https://ddev.readthedocs.io/en/latest/users/install/performance/#nfs
133-
# See https://ddev.readthedocs.io/en/latest/users/install/performance/#mutagen
149+
# See https://ddev.readthedocs.io/en/stable/users/install/performance/#nfs
150+
# See https://ddev.readthedocs.io/en/stable/users/install/performance/#mutagen
134151

135152
# fail_on_hook_fail: False
136153
# Decide whether 'ddev start' should be interrupted by a failing hook
@@ -241,10 +258,10 @@ nodejs_version: "18"
241258
# override_config: false
242259
# By default, config.*.yaml files are *merged* into the configuration
243260
# But this means that some things can't be overridden
244-
# For example, if you have 'nfs_mount_enabled: true'' you can't override it with a merge
261+
# For example, if you have 'use_dns_when_possible: true'' you can't override it with a merge
245262
# and you can't erase existing hooks or all environment variables.
246263
# However, with "override_config: true" in a particular config.*.yaml file,
247-
# 'nfs_mount_enabled: false' can override the existing values, and
264+
# 'use_dns_when_possible: false' can override the existing values, and
248265
# hooks:
249266
# post-start: []
250267
# or
@@ -262,5 +279,6 @@ nodejs_version: "18"
262279
# for them. Example:
263280
#hooks:
264281
# post-import-db:
265-
# - exec: drush cr
266-
# - exec: drush updb
282+
# - exec: drush sql:sanitize
283+
# - exec: drush updatedb
284+
# - exec: drush cache:rebuild

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ src/**/package-lock.json
1515
src/**/out/
1616
src/**/*.vsix
1717
src/**/.vscode-test/
18+
drush/
19+
.ddev/config.gitpod.yaml

.gitpod.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
image: drupalpod/drupalpod-gitpod-base:20230922
1+
image: drupalpod/drupalpod-gitpod-base:20240419
22

33
# DDEV and composer are running as part of the prebuild
44
# when starting a workspace all docker images are ready
@@ -7,7 +7,6 @@ tasks:
77
.gitpod/utils/send-a-message-gcs.sh > /tmp/output1.txt
88
.gitpod/utils/ddev-in-gitpod-setup.sh
99
.gitpod/utils/set-base-environment.sh
10-
time ddev start
1110
command: |
1211
# Temporary fix for wrong value of GITPOD_REPO_ROOT when opening a Gitpod snapshot
1312
# Todo: remove this when this issue is resolved - https://github.com/gitpod-io/gitpod/issues/9804

.gitpod/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
1. Update `.gitpod/images/Dockerfile`:
66

7+
1. Update `ddev` latest version.
78
1. Update `minio` latest version.
89
1. Update `gitui` latest version.
10+
1. Update `lazygit` latest version.
911

1012
1. Generate new custom docker image:
1113

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
set -eu -o pipefail
3+
4+
# Remove site that was installed before (for debugging)
5+
rm -rf "${GITPOD_REPO_ROOT}"/web
6+
rm -rf "${GITPOD_REPO_ROOT}"/vendor
7+
rm -f "${GITPOD_REPO_ROOT}"/composer.json
8+
rm -f "${GITPOD_REPO_ROOT}"/composer.lock

.gitpod/drupal/drupalpod-setup/drupal_version_specifics.sh renamed to .gitpod/drupal/drupalpod-setup/contrib_modules_setup.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
#!/usr/bin/env bash
2+
set -eu -o pipefail
3+
4+
# Check if additional modules should be installed
5+
export DEVEL_NAME="devel"
6+
export DEVEL_PACKAGE="drupal/devel"
7+
8+
export ADMIN_TOOLBAR_NAME="admin_toolbar_tools"
9+
export ADMIN_TOOLBAR_PACKAGE="drupal/admin_toolbar"
10+
11+
# TODO: once Drupalpod extension supports additional modules - remove these 2 lines
12+
export DP_EXTRA_DEVEL=1
13+
export DP_EXTRA_ADMIN_TOOLBAR=1
214

315
# Adding support for composer-drupal-lenient - https://packagist.org/packages/mglaman/composer-drupal-lenient
416
if [[ "$DP_CORE_VERSION" =~ ^10(\..*)?$ ]]; then
@@ -12,8 +24,8 @@ fi
1224
# Adding support for composer-drupal-lenient - https://packagist.org/packages/mglaman/composer-drupal-lenient
1325
if [[ "$DP_CORE_VERSION" =~ ^11(\..*)?$ ]]; then
1426
# admin_toolbar and devel are not compatible yet with Drupal 11
15-
DP_EXTRA_ADMIN_TOOLBAR=
16-
DP_EXTRA_DEVEL=
27+
export DP_EXTRA_ADMIN_TOOLBAR=
28+
export DP_EXTRA_DEVEL=
1729
if [ "$DP_PROJECT_TYPE" != "project_core" ]; then
1830
export COMPOSER_DRUPAL_LENIENT=mglaman/composer-drupal-lenient
1931
else
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
set -eu -o pipefail
3+
4+
# set PHP version, based on https://www.drupal.org/docs/getting-started/system-requirements/php-requirements#versions
5+
major_version=$(echo "$DP_CORE_VERSION" | cut -d '.' -f 1)
6+
minor_version=$(echo "$DP_CORE_VERSION" | cut -d '.' -f 2)
7+
8+
# Before Drupal 10.2, we should use php 8.2, otherwise use php 8.3
9+
if (( major_version < 10 )) || { (( major_version == 10 )) && (( minor_version < 2 )); }; then
10+
php_version="8.2"
11+
else
12+
php_version="8.3"
13+
fi
14+
15+
cat <<CONFIGEND > "${GITPOD_REPO_ROOT}"/.ddev/config.gitpod.yaml
16+
#ddev-gitpod-generated
17+
php_version: "$php_version"
18+
CONFIGEND
19+
20+
time ddev start

.gitpod/drupal/drupalpod-setup/drupal_setup_contrib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ if [ -n "$COMPOSER_DRUPAL_LENIENT" ]; then
2525
cd "${GITPOD_REPO_ROOT}" && time ddev . composer require "$COMPOSER_DRUPAL_LENIENT" --no-install
2626
fi
2727
# Add the project to composer (it will get the version according to the branch under `/repo/name_of_project`)
28-
cd "${GITPOD_REPO_ROOT}" && time ddev . composer require drupal/"$DP_PROJECT_NAME" --no-install
28+
cd "${GITPOD_REPO_ROOT}" && time ddev . composer require drupal/"$DP_PROJECT_NAME" --no-interaction --no-install

.gitpod/drupal/drupalpod-setup/drupal_setup_core.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@ cd "${GITPOD_REPO_ROOT}" &&
3131
# Removing the conflict part of composer
3232
echo "$(cat composer.json | jq 'del(.conflict)' --indent 4)" >composer.json
3333

34+
# If a core issue branch was chosen, we want the version of Drupal core that is in that issue branch
35+
# This is very helpful for issues that started with previous Drupal core versions, and the issue version automatically got updated to latest current drupal version
36+
if [ "$DP_PROJECT_TYPE" == "project_core" ] && [ -n "$DP_ISSUE_BRANCH" ]; then
37+
time composer require drupal/core-recommended:* drupal/core-project-message:* drupal/core-composer-scaffold:* --no-update
38+
fi
39+
3440
# Only after composer update, /web/core get symlinked to /repos/drupal/core
3541
# repos/drupal/core -> web/core
36-
time composer update --lock
42+
time composer update
3743

3844
# vendor -> repos/drupal/vendor
3945
if [ ! -L "$GITPOD_REPO_ROOT"/repos/drupal/vendor ]; then

.gitpod/drupal/drupalpod-setup/drupalpod-setup.sh

Lines changed: 31 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -26,93 +26,47 @@ if [ -n "$DEBUG_SCRIPT" ] || [ -n "$GITPOD_HEADLESS" ]; then
2626
set -x
2727
fi
2828

29-
time ddev start
30-
31-
# Measure the time it takes to go through the script
32-
script_start_time=$(date +%s)
29+
convert_version() {
30+
local version=$1
31+
if [[ $version =~ "-" ]]; then
32+
# Remove the part after the dash and replace the last numeric segment with 'x'
33+
local base_version=${version%-*}
34+
echo "${base_version%.*}.x"
35+
else
36+
echo "$version"
37+
fi
38+
}
3339

34-
source "$DIR/setup_env.sh"
35-
source "$DIR/install_modules.sh"
36-
source "$DIR/drupal_version_specifics.sh"
40+
# Test cases
41+
# echo $(convert_version "9.2.5-dev1") # Output: 9.2.x
42+
# echo $(convert_version "9.2.5") # Output: 9.2.5
43+
# echo $(convert_version "10.1.0-beta1") # Output: 10.1.x
44+
# echo $(convert_version "11.0-dev") # Output: 11.x
3745

3846
# Skip setup if it already ran once and if no special setup is set by DrupalPod extension
39-
if [ ! -f "${GITPOD_REPO_ROOT}"/.drupalpod_initiated ] && [ -n "$DP_PROJECT_TYPE" ]; then
40-
41-
# Add git.drupal.org to known_hosts
42-
if [ -z "$GITPOD_HEADLESS" ]; then
43-
mkdir -p ~/.ssh
44-
host=git.drupal.org
45-
SSHKey=$(ssh-keyscan $host 2>/dev/null)
46-
echo "$SSHKey" >>~/.ssh/known_hosts
47+
if [ ! -f "${GITPOD_REPO_ROOT}"/.drupalpod_initiated ]; then
48+
49+
# Set a default setup if project type wasn't specified
50+
if [ -z "$DP_PROJECT_TYPE" ]; then
51+
source "$DIR/fallback_setup.sh"
4752
fi
4853

49-
# Ignore specific directories during Drupal core development
50-
cp "${GITPOD_REPO_ROOT}"/.gitpod/drupal/templates/git-exclude.template "${GITPOD_REPO_ROOT}"/.git/info/exclude
54+
source "$DIR/git_setup.sh"
5155

52-
# Get the required repo ready
53-
if [ "$DP_PROJECT_TYPE" == "project_core" ]; then
54-
# Find if requested core version is dev or stable
55-
d="$DP_CORE_VERSION"
56-
case $d in
57-
*.x)
58-
# If dev - use git checkout origin/*
59-
checkout_type=origin
60-
;;
61-
*)
62-
# stable - use git checkout tags/*
63-
checkout_type=tags
64-
;;
65-
esac
66-
67-
# Use origin or tags in git checkout command
68-
cd "${GITPOD_REPO_ROOT}"/repos/drupal &&
69-
git fetch origin &&
70-
git fetch --all --tags &&
71-
git checkout "$checkout_type"/"$DP_CORE_VERSION"
72-
73-
# Ignore specific directories during Drupal core development
74-
cp "${GITPOD_REPO_ROOT}"/.gitpod/drupal/templates/git-exclude.template "${GITPOD_REPO_ROOT}"/repos/drupal/.git/info/exclude
75-
else
76-
# If not core - clone selected project into /repos and remove drupal core
77-
rm -rf "${GITPOD_REPO_ROOT}"/repos/drupal
78-
if [ ! -d repos/"${DP_PROJECT_NAME}" ]; then
79-
mkdir -p repos
80-
cd "${GITPOD_REPO_ROOT}"/repos && time git clone https://git.drupalcode.org/project/"$DP_PROJECT_NAME".git
81-
fi
56+
# If this is an issue fork of Drupal core - set the drupal core version based on that issue fork
57+
if [ "$DP_PROJECT_TYPE" == "project_core" ] && [ -n "$DP_ISSUE_FORK" ]; then
58+
VERSION_FROM_GIT=$(grep 'const VERSION' "${GITPOD_REPO_ROOT}"/repos/drupal/core/lib/Drupal.php | awk -F "'" '{print $2}')
59+
DP_CORE_VERSION=$(convert_version "$VERSION_FROM_GIT")
60+
export DP_CORE_VERSION
8261
fi
8362

84-
# Set WORK_DIR
85-
export WORK_DIR="${GITPOD_REPO_ROOT}"/repos/$DP_PROJECT_NAME
86-
87-
# Dynamically generate .gitmodules file
88-
cat <<GITMODULESEND >"${GITPOD_REPO_ROOT}"/.gitmodules
89-
# This file was dynamically generated by a script
90-
[submodule "$DP_PROJECT_NAME"]
91-
path = repos/$DP_PROJECT_NAME
92-
url = https://git.drupalcode.org/project/$DP_PROJECT_NAME.git
93-
ignore = dirty
94-
GITMODULESEND
95-
96-
# Checkout specific branch only if there's issue_branch
97-
if [ -n "$DP_ISSUE_BRANCH" ]; then
98-
# If branch already exist only run checkout,
99-
if cd "${WORK_DIR}" && git show-ref -q --heads "$DP_ISSUE_BRANCH"; then
100-
cd "${WORK_DIR}" && git checkout "$DP_ISSUE_BRANCH"
101-
else
102-
cd "${WORK_DIR}" && git remote add "$DP_ISSUE_FORK" https://git.drupalcode.org/issue/"$DP_ISSUE_FORK".git
103-
cd "${WORK_DIR}" && git fetch "$DP_ISSUE_FORK"
104-
cd "${WORK_DIR}" && git checkout -b "$DP_ISSUE_BRANCH" --track "$DP_ISSUE_FORK"/"$DP_ISSUE_BRANCH"
105-
fi
106-
elif [ -n "$DP_MODULE_VERSION" ] && [ "$DP_PROJECT_TYPE" != "project_core" ]; then
107-
cd "${WORK_DIR}" && git checkout "$DP_MODULE_VERSION"
108-
fi
63+
source "$DIR/ddev_setup.sh"
10964

110-
# Remove site that was installed before (for debugging)
111-
rm -rf "${GITPOD_REPO_ROOT}"/web
112-
rm -rf "${GITPOD_REPO_ROOT}"/vendor
113-
rm -f "${GITPOD_REPO_ROOT}"/composer.json
114-
rm -f "${GITPOD_REPO_ROOT}"/composer.lock
65+
# Measure the time it takes to go through the script
66+
script_start_time=$(date +%s)
11567

68+
source "$DIR/contrib_modules_setup.sh"
69+
source "$DIR/cleanup.sh"
11670
source "$DIR/composer_setup.sh"
11771

11872
if [ -n "$DP_PATCH_FILE" ]; then

0 commit comments

Comments
 (0)