@@ -21,14 +21,12 @@ set -eu
21
21
# Variables (passed from environment; provided for reference only).
22
22
# -------------------------------------------------------------------------------
23
23
24
- # Drupal core version to use. If not provided - the latest stable version will be used.
25
- # Must be coupled with DRUPAL_PROJECT_SHA below.
26
- DRUPAL_VERSION=" ${DRUPAL_VERSION:- 10} "
24
+ # Drupal core version to use.
25
+ DRUPAL_VERSION=" ${DRUPAL_VERSION:- 11} "
27
26
28
27
# Commit SHA of the drupal-project to install custom core version. If not
29
- # provided - the latest version will be used.
30
- # Must be coupled with DRUPAL_VERSION above.
31
- DRUPAL_PROJECT_SHA=" ${DRUPAL_PROJECT_SHA:- 10.x} "
28
+ # provided - will be calculated from `$DRUPAL_VERSION` above.
29
+ DRUPAL_PROJECT_SHA=" ${DRUPAL_PROJECT_SHA:- } "
32
30
33
31
# Repository for "drupal-composer/drupal-project" project.
34
32
# May be overwritten to use forked repos that may have not been accepted
@@ -51,19 +49,23 @@ echo " 🏗️ ASSEMBLE "
51
49
echo " ==============================="
52
50
echo
53
51
52
+ # Validate required variables.
53
+ [ -z " ${DRUPAL_VERSION} " ] && { fail " ERROR: DRUPAL_VERSION is not set." ; exit 1; }
54
+ [ -z " ${DRUPAL_PROJECT_REPO} " ] && { fail " ERROR: DRUPAL_PROJECT_REPO is not set." ; exit 1; }
55
+
54
56
# Make sure Composer doesn't run out of memory.
55
57
export COMPOSER_MEMORY_LIMIT=-1
56
58
57
59
info " Validate tools."
58
- ! command -v git > /dev/null && echo " ERROR: Git is required for this script to run." && exit 1
59
- ! command -v php > /dev/null && echo " ERROR: PHP is required for this script to run." && exit 1
60
- ! command -v composer > /dev/null && echo " ERROR: Composer (https://getcomposer.org/) is required for this script to run." && exit 1
61
- ! command -v jq > /dev/null && echo " ERROR: jq (https://stedolan.github.io/jq/) is required for this script to run." && exit 1
60
+ ! command -v git > /dev/null && fail " ERROR: Git is required for this script to run." && exit 1
61
+ ! command -v php > /dev/null && fail " ERROR: PHP is required for this script to run." && exit 1
62
+ ! command -v composer > /dev/null && fail " ERROR: Composer (https://getcomposer.org/) is required for this script to run." && exit 1
63
+ ! command -v jq > /dev/null && fail " ERROR: jq (https://stedolan.github.io/jq/) is required for this script to run." && exit 1
62
64
pass " Tools are valid."
63
65
64
66
# Extension name, taken from the .info file.
65
67
extension=" $( basename -s .info.yml -- ./* .info.yml) "
66
- [ " ${extension} " == " *" ] && echo " ERROR: No .info.yml file found." && exit 1
68
+ [ " ${extension} " == " *" ] && fail " ERROR: No .info.yml file found." && exit 1
67
69
68
70
# Extension type.
69
71
type=$( grep -q " type: theme" " ${extension} .info.yml" && echo " themes" || echo " modules" )
@@ -80,25 +82,23 @@ if [ -d "build" ]; then
80
82
fi
81
83
82
84
info " Creating Drupal codebase."
83
- # Allow installing custom version of Drupal core from drupal-composer/drupal-project,
84
- # but only coupled with drupal-project SHA (required to get correct dependencies).
85
- if [ -n " ${DRUPAL_VERSION:- } " ] && [ -n " ${DRUPAL_PROJECT_SHA:- } " ]; then
86
- note " Initialising Drupal site from the scaffold repo ${DRUPAL_PROJECT_REPO} commit ${DRUPAL_PROJECT_SHA} ."
87
-
88
- # Clone Drupal core at the specific commit SHA.
89
- git clone -n " ${DRUPAL_PROJECT_REPO} " " build"
90
- git --git-dir=" build/.git" --work-tree=" build" checkout " ${DRUPAL_PROJECT_SHA} "
91
- rm -rf " build/.git" > /dev/null
92
-
93
- note " Pin Drupal to a specific version ${DRUPAL_VERSION} ."
94
- sed_opts=(-i) && [ " $( uname) " == " Darwin" ] && sed_opts=(-i ' ' )
95
- sed " ${sed_opts[@]} " ' s|\(.*"drupal\/core"\): "\(.*\)",.*|\1: ' " \" $DRUPAL_VERSION \" ,|" " build/composer.json"
96
- cat " build/composer.json"
97
- else
98
- note " Initialising Drupal site from the latest scaffold."
99
- # There are no releases in "drupal-composer/drupal-project", so have to use "@dev".
100
- composer create-project drupal-composer/drupal-project:@dev " build" --no-interaction --no-install
85
+
86
+ if [ -z " ${DRUPAL_PROJECT_SHA:- } " ]; then
87
+ DRUPAL_PROJECT_SHA=" $( echo " ${DRUPAL_VERSION} " | cut -d ' .' -f 1 | cut -d ' @' -f 1) .x"
101
88
fi
89
+
90
+ note " Initialising Drupal site from the scaffold repo ${DRUPAL_PROJECT_REPO} ref ${DRUPAL_PROJECT_SHA} ."
91
+
92
+ # Clone Drupal project at the specific commit SHA.
93
+ git clone -n " ${DRUPAL_PROJECT_REPO} " " build"
94
+ git --git-dir=" build/.git" --work-tree=" build" checkout " ${DRUPAL_PROJECT_SHA} "
95
+ rm -rf " build/.git" > /dev/null
96
+
97
+ note " Pinning Drupal to a specific version ${DRUPAL_VERSION} ."
98
+ sed_opts=(-i) && [ " $( uname) " == " Darwin" ] && sed_opts=(-i ' ' )
99
+ sed " ${sed_opts[@]} " ' s|\(.*"drupal\/core.*"\): "\(.*\)",.*|\1: ' " \" ~$DRUPAL_VERSION \" ,|" " build/composer.json"
100
+ grep ' "drupal/core-.*": "' " build/composer.json"
101
+
102
102
pass " Drupal codebase created."
103
103
104
104
info " Merging configuration from composer.dev.json."
@@ -148,7 +148,7 @@ if [ -f "package-lock.json" ]; then
148
148
if [ -f " .nvmrc" ]; then nvm use || true ; fi
149
149
if [ ! -d " node_modules" ]; then npm ci; fi
150
150
151
- echo " > Building front-end dependencies."
151
+ note " Building front-end dependencies."
152
152
if [ ! -f " .skip_npm_build" ]; then npm run build; fi
153
153
pass " Front-end dependencies installed."
154
154
fi
@@ -170,6 +170,6 @@ echo " 🏗 ASSEMBLE COMPLETE ✅ "
170
170
echo " ==============================="
171
171
echo
172
172
echo " > Next steps:"
173
- echo " .devtools/start.sh # Start the webserver"
173
+ echo " .devtools/start.sh # Start the webserver"
174
174
echo " .devtools/provision.sh # Provision the website"
175
175
echo
0 commit comments