Skip to content

Commit e30ef50

Browse files
committed
🔧 Add pnpm package manager to streamline startup and update cypress docker image version to 13.14.2v4
- Install pnpm in cypress docker container - Add config variable to .env and set default to pnpm - Update docker image version to 13.14.2v4
1 parent 593f3bd commit e30ef50

File tree

9 files changed

+8341
-12
lines changed

9 files changed

+8341
-12
lines changed

‎.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ data/sites/*
1414
**/output
1515
**/import
1616
**/tests/cypress/downloads/**
17-
!visual-regression/import/sitemap.csv.example
17+
!visual-regression/import/sitemap.csv.example
18+
**/.pnpm-store

‎.tools/.env

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
IMAGE_NAME_TAG=joomla-cypress-included:13.14.2v3
1+
IMAGE_NAME_TAG=joomla-cypress-included:13.14.2v4
22
WEB_IMAGE_NAME_TAG=joomla-cypress-web:php-8.3
33

44
WEB_LOCAL_PORT=8080
@@ -10,5 +10,8 @@ JC_OVERRIDE_BACKUP=yes
1010
# Options smart, always
1111
NPM_DEPS_INSTALL=smart
1212

13+
# Options pnpm, npm
14+
PACKAGE_MANAGER_PREFS=pnpm
15+
1316
# Default test project
1417
DEFAULT_TEST_PROJECT=cms

‎.tools/build/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ RUN set -ex; \
3232
# apt-get install -y \
3333
# codium;
3434

35+
# Install pnpm as alternative package manager
36+
RUN npm install -g pnpm
37+
3538
# Install Sublime Text
3639
RUN wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | gpg --dearmor | tee /etc/apt/trusted.gpg.d/sublimehq-archive.gpg > /dev/null
3740
RUN echo "deb https://download.sublimetext.com/ apt/stable/" | tee /etc/apt/sources.list.d/sublime-text.list

‎.tools/build/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
set e+x
1010

11-
LOCAL_NAME=joomla-cypress-included:13.14.2v3
11+
LOCAL_NAME=joomla-cypress-included:13.14.2v4
1212
BUILD_PATH=${BUILD:-.}
1313

1414
echo "Building $LOCAL_NAME"

‎.tools/build/entrypoint.sh

+39-8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,28 @@ copyConfig() {
3939
cp -f $TOOLS_ROOT/config/cypress.config.dist.mjs $WORKDIR/tests/cypress.config.mjs
4040
}
4141

42+
# Install dependencies
43+
installDependencies() {
44+
cd $WORKDIR/tests/
45+
46+
if [ ${PACKAGE_MANAGER_PREFS:-npm} == 'pnpm' ]; then
47+
if [ ! -f $WORKDIR/tests/pnpm-lock.yaml ] && [ -f $WORKDIR/tests/package-lock.json ]; then
48+
pnpm import package-lock.json
49+
fi
50+
if [ ! -f $WORKDIR/tests/pnpm-lock.yaml ]; then
51+
pnpm install
52+
else
53+
pnpm install --frozen-lockfile
54+
fi
55+
else
56+
if [ ! -f $WORKDIR/tests/package-lock.json ]; then
57+
npm i
58+
else
59+
npm ci
60+
fi
61+
fi
62+
}
63+
4264
# Setup configuration file
4365
# Backup the original file if a backup file not already exists and .env variable is not set to false/no/0
4466
# Copy the configuration file to the working directory if .env variable is set to true/yes
@@ -162,36 +184,45 @@ if [ ! -f $WORKDIR/tests/package.json ]; then
162184
echo "[ATTENTION] No package.json found in the tests folder. A general default one will be injected."
163185
cp -f $TOOLS_ROOT/config/package.json $WORKDIR/tests/package.json
164186
cp -f $TOOLS_ROOT/config/package-lock.json $WORKDIR/tests/package-lock.json
187+
cp -f $TOOLS_ROOT/config/pnpm-lock.yaml $WORKDIR/tests/pnpm-lock.yaml
165188
fi
166189

167190
# Set the correct permissions
168-
chown node:node $WORKDIR/tests/package.json $WORKDIR/tests/package-lock.json
191+
chown node:node $WORKDIR/tests/package.json
192+
193+
if [ -f $WORKDIR/tests/pnpm-lock.yaml ]; then
194+
chown node:node $WORKDIR/tests/pnpm-lock.yaml
195+
fi
196+
197+
if [ -f $WORKDIR/tests/package-lock.json ]; then
198+
chown node:node $WORKDIR/tests/package-lock.json
199+
fi
169200

170201
# Install the assets
171202
if [ -f $WORKDIR/tests/package.json ]; then
172203
case ${NPM_DEPS_INSTALL:-smart} in
173204
always)
174205
echo "Cleaning the assets"
175206
rm -rf $WORKDIR/tests/node_modules
207+
if [ ${PACKAGE_MANAGER_PREFS:-npm} == 'pnpm' ]; then
208+
cd $WORKDIR/tests && pnpm store prune
209+
fi
176210
echo -e " > Installing the assets (takes a while!)"
177-
cd $WORKDIR/tests/
178-
npm ci
211+
installDependencies
179212
;;
180213
*)
181214
if [ ! -d $WORKDIR/tests/node_modules ]; then
182215
echo -e " > Installing the assets (takes a while!)"
183-
cd $WORKDIR/tests/
184-
npm ci
216+
installDependencies
185217
elif [ -d $WORKDIR/tests/node_modules ] && [[ $(find "$WORKDIR/tests/node_modules" -type d -mtime +1 -print) ]]; then
186218
echo "Assets already installed but older than 1 day"
187219
echo "Cleaning the assets"
188220
rm -rf $WORKDIR/tests/node_modules
189221
echo -e " > Installing the assets (takes a while!)"
190-
cd $WORKDIR/tests/
191-
npm ci
222+
installDependencies
192223
else
193224
echo "Assets already installed"
194-
echo "Skipping npm install"
225+
echo "Skipping ${PACKAGE_MANAGER_PREFS:-npm} install"
195226
fi
196227
;;
197228
esac

0 commit comments

Comments
 (0)