4040 cache-dependency-path : |
4141 package.json
4242 src/**/package.json
43- test_apps/encore-app/pnpm-lock.yaml
44- test_apps/encore-app/package.json
4543
4644 - uses : shivammathur/setup-php@v2
4745
@@ -60,35 +58,56 @@ jobs:
6058 working-directory : test_apps/encore-app
6159 dependency-versions : highest
6260
61+ - name : Manually replacing "workspace:*" references
62+ run : |
63+ # npm does not support "workspace:*" references, so we need to replace them with the actual package path
64+ for PACKAGE_DATA in $(pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
65+ PACKAGE=$(echo $PACKAGE_DATA | jq -r '.name')
66+ PACKAGE_PATH=$(echo $PACKAGE_DATA | jq -r '.path')
67+
68+ echo "🔍 Searching for \"workspace:*\" references in $PACKAGE_PATH/package.json"
69+
70+ # Manually replace "workspace:" constraints with the actual package version, it ensure packages can be installed with npm
71+ jq -rc '[(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.value == "workspace:*") | .key][]' "$PACKAGE_PATH/package.json" | while read -r PACKAGE_FROM_WORKSPACE ; do
72+ echo "ℹ️ Found \"$PACKAGE_FROM_WORKSPACE\" with \"workspace:*\""
73+
74+ PACKAGE_FROM_WORKSPACE_PATH=$(pnpm ls --filter $PACKAGE_FROM_WORKSPACE --json --depth -1 | jq -r '.[].path')
75+ echo "ℹ️ The package \"$PACKAGE_FROM_WORKSPACE\" is located in \"$PACKAGE_FROM_WORKSPACE_PATH\" directory"
76+
77+ echo "⚒️ Replacing \"$PACKAGE_FROM_WORKSPACE\" with \"file:$PACKAGE_FROM_WORKSPACE_PATH\" in $PACKAGE_PATH/package.json"
78+ sed -i "s|\"$PACKAGE_FROM_WORKSPACE\": \"workspace:\*\"|\"$PACKAGE_FROM_WORKSPACE\": \"file:$PACKAGE_FROM_WORKSPACE_PATH\"|g" "$PACKAGE_PATH/package.json"
79+ done;
80+ done
81+
6382 - working-directory : test_apps/encore-app
64- run : pnpm install --ignore-workspace
83+ run : npm install
6584
6685 - if : matrix.ux-packages-source == 'js-packages'
6786 name : Install UX JS packages with a JS package manager
6887 working-directory : test_apps/encore-app
6988 run : |
7089 PACKAGES_TO_INSTALL=''
71- for PACKAGE in $(cd ../..; pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
72- PACKAGE_ABSOLUTE_PATH=$(echo $PACKAGE | jq -r '.path')
73- PACKAGE_RELATIVE_PATH=$(realpath --relative-to=. "$PACKAGE_ABSOLUTE_PATH")
74- PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL file:$PACKAGE_RELATIVE_PATH"
90+ for PACKAGE_DATA in $(pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
91+ PACKAGE_PATH=$(echo $PACKAGE_DATA | jq -r '.path')
92+ PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL file:$(realpath --relative-to=. "$PACKAGE_PATH")"
7593 done
94+
7695 echo "Installing packages: $PACKAGES_TO_INSTALL"
77- pnpm add --save-dev $PACKAGES_TO_INSTALL
96+ npm add --save-dev --install-links $PACKAGES_TO_INSTALL
7897
7998 - name : Ensure UX packages are installed from "${{ env.EXPECTED_PATTERN }}"
8099 working-directory : test_apps/encore-app
81100 run : |
82- for PACKAGE in $(cat package.json | jq -c '(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.key | startswith("@symfony/ux-")) | {name: .key, version: .value}'); do
83- PACKAGE_NAME =$(echo $PACKAGE | jq -r '.name')
84- PACKAGE_VERSION=$(echo $PACKAGE | jq -r '.version')
101+ for PACKAGE_DATA in $(cat package.json | jq -c '(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.key | startswith("@symfony/ux-")) | {name: .key, version: .value}'); do
102+ PACKAGE =$(echo $PACKAGE_DATA | jq -r '.name')
103+ PACKAGE_VERSION=$(echo $PACKAGE_DATA | jq -r '.version')
85104
86- echo -n "Checking $PACKAGE_NAME @$PACKAGE_VERSION..."
105+ echo -n "Checking $PACKAGE @$PACKAGE_VERSION..."
87106 if [[ $PACKAGE_VERSION == $EXPECTED_PATTERN* ]]; then
88- echo " OK"
107+ echo "✅ OK"
89108 else
90- echo " KO"
91- echo "The package version of $PACKAGE_NAME must starts with the pattern (e.g.: $EXPECTED_PATTERN), got $PACKAGE_VERSION instead."
109+ echo "❌ KO"
110+ echo "ℹ️ The package version of $PACKAGE must starts with the pattern (e.g.: $EXPECTED_PATTERN), got $PACKAGE_VERSION instead."
92111 exit 1
93112 fi
94113 done;
97116
98117 - name : Ensure project can be built in dev mode
99118 working-directory : test_apps/encore-app
100- run : pnpm run dev
119+ run : npm run dev
101120
102121 - name : Ensure project can be built in prod mode
103122 working-directory : test_apps/encore-app
104- run : pnpm run build
123+ run : npm run build
0 commit comments