Skip to content

Commit

Permalink
Initial Drupal 11 + automatic core selection
Browse files Browse the repository at this point in the history
  • Loading branch information
shaal committed Jun 8, 2023
1 parent 0efc728 commit a63c82d
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 8 deletions.
26 changes: 21 additions & 5 deletions .gitpod/drupal/drupalpod-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ export DP_EXTRA_DEVEL=1
export DP_EXTRA_ADMIN_TOOLBAR=1

# Adding support for composer-drupal-lenient - https://packagist.org/packages/mglaman/composer-drupal-lenient
if [[ "$DP_CORE_VERSION" == 10* ]]; then
# admin_toolbar not compatible yet with Drupal 10
unset DP_EXTRA_ADMIN_TOOLBAR
if [[ "$DP_CORE_VERSION" == 10* ]] || [[ "$DP_CORE_VERSION" == 11* ]]; then
if [ "$DP_PROJECT_TYPE" != "project_core" ]; then
export COMPOSER_DRUPAL_LENIENT=mglaman/composer-drupal-lenient
else
export COMPOSER_DRUPAL_LENIENT=''
fi
fi

if [[ "$DP_CORE_VERSION" == 11* ]]; then
# admin_toolbar not compatible yet with Drupal 10
unset DP_EXTRA_ADMIN_TOOLBAR
fi

# Use PHP 8.1 for Drupal 10.0.x
Expand Down Expand Up @@ -128,6 +131,9 @@ GITMODULESEND
fi
done

# TODO: check time for installing from scratch
unset ready_made_env_exist

# Make sure DDEV is running
ddev start

Expand All @@ -152,6 +158,16 @@ GITMODULESEND
else
# If not, run composer create-project with the requested version


# TODO: remove this
export DP_CORE_VERSION="automatic"

# Automatically recognize Drupal core version from issue fork
if [[ "$DP_CORE_VERSION" == 'automatic' && "$DP_PROJECT_TYPE" == "project_core" ]]; then
DP_CORE_VERSION=$(git describe --tags --abbrev=0 "$DP_ISSUE_BRANCH" )
export DP_CORE_VERSION
fi

# For versions end with x - add `-dev` suffix (ie. 9.3.x-dev)
# For versions without x - add `~` prefix (ie. ~9.2.0)
d="$DP_CORE_VERSION"
Expand All @@ -165,8 +181,8 @@ GITMODULESEND
esac

# Create required composer.json and composer.lock files
cd "$GITPOD_REPO_ROOT" && ddev . composer create -n --no-install drupal/recommended-project:"$install_version" temp-composer-files
cp "$GITPOD_REPO_ROOT"/temp-composer-files/* "$GITPOD_REPO_ROOT"/.
cd "$GITPOD_REPO_ROOT" && ddev . composer create -n drupal/recommended-project:"$install_version" temp-composer-files
mv "$GITPOD_REPO_ROOT"/temp-composer-files/* "$GITPOD_REPO_ROOT"/.
rm -rf "$GITPOD_REPO_ROOT"/temp-composer-files
fi
fi
Expand Down
12 changes: 10 additions & 2 deletions .gitpod/drupal/install-essential-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ if [ "$DP_EXTRA_ADMIN_TOOLBAR" != '1' ]; then
unset ADMIN_TOOLBAR_PACKAGE
fi

if [ "$DP_CORE_VERSION" = "11.x" ]; then
DRUSH_PACKAGE="drush/drush:^12.0"
unset DEVEL_PACKAGE
unset ADMIN_TOOLBAR_PACKAGE
else
DRUSH_PACKAGE="drush/drush:^11.0"
fi

cd "${GITPOD_REPO_ROOT}" && time ddev composer require --dev drupal/core-dev:* -W --no-install
cd "${GITPOD_REPO_ROOT}" && time ddev composer require --dev phpspec/prophecy-phpunit:^2 --no-install
cd "${GITPOD_REPO_ROOT}" && time ddev . composer require drush/drush:^11.0 drupal/coder:^8.3 "$DEVEL_PACKAGE" "$ADMIN_TOOLBAR_PACKAGE" --no-install
cd "${GITPOD_REPO_ROOT}" && time ddev composer update
cd "${GITPOD_REPO_ROOT}" && time ddev . composer require "$DRUSH_PACKAGE" drupal/coder:^8.3 "$DEVEL_PACKAGE" "$ADMIN_TOOLBAR_PACKAGE" --no-install
# cd "${GITPOD_REPO_ROOT}" && time ddev composer update
13 changes: 12 additions & 1 deletion src/composer-drupal-core-setup/patch-core-index-and-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,15 @@ if [ -n "$DEBUG_SCRIPT" ] || [ -n "$GITPOD_HEADLESS" ]; then
set -x
fi

git apply --directory=web -v src/composer-drupal-core-setup/scaffold-patch-index-and-update-php.patch
# Drupal v11 requires a different patch than v9 and v10.
if [ "$DP_CORE_VERSION" = "11.x" ]; then
PATCH_FILE="scaffold-patch-index-and-update-php-drupal-11.patch"
else
PATCH_FILE="scaffold-patch-index-and-update-php.patch"
fi

# Apply patch to core index.php and update.php
# This is needed to make the core index.php and update.php work with the
# composer-drupal-core-setup project.

git apply --directory=web -v src/composer-drupal-core-setup/$PATCH_FILE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/index.php b/index.php
index 750dc282dc..bda22cee8d 100644
--- a/index.php
+++ b/index.php
@@ -13,7 +13,7 @@

$autoloader = require_once 'autoload.php';

-$kernel = new DrupalKernel('prod', $autoloader);
+$kernel = new DrupalKernel('prod', $autoloader, TRUE, __DIR__);

$request = Request::createFromGlobals();
$response = $kernel->handle($request);
diff --git a/update.php b/update.php
index b65649cb87..02ffa2245d 100644
--- a/update.php
+++ b/update.php
@@ -21,7 +21,7 @@
gc_disable();
}

-$kernel = new UpdateKernel('prod', $autoloader, FALSE);
+$kernel = new UpdateKernel('prod', $autoloader, FALSE, __DIR__);
$request = Request::createFromGlobals();

$response = $kernel->handle($request);

0 comments on commit a63c82d

Please sign in to comment.