40
40
cache-dependency-path : |
41
41
package.json
42
42
src/**/package.json
43
- test_apps/encore-app/pnpm-lock.yaml
44
43
test_apps/encore-app/package.json
45
44
46
45
- uses : shivammathur/setup-php@v2
@@ -60,35 +59,56 @@ jobs:
60
59
working-directory : test_apps/encore-app
61
60
dependency-versions : highest
62
61
62
+ - name : Manually replacing "workspace:*" references
63
+ run : |
64
+ # npm does not support "workspace:*" references, so we need to replace them with the actual package path
65
+ for PACKAGE_DATA in $(pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
66
+ PACKAGE=$(echo $PACKAGE_DATA | jq -r '.name')
67
+ PACKAGE_PATH=$(echo $PACKAGE_DATA | jq -r '.path')
68
+
69
+ echo "🔍 Searching for \"workspace:*\" references in $PACKAGE_PATH/package.json"
70
+
71
+ # Manually replace "workspace:" constraints with the actual package version, it ensure packages can be installed with npm
72
+ jq -rc '[(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.value == "workspace:*") | .key][]' "$PACKAGE_PATH/package.json" | while read -r PACKAGE_FROM_WORKSPACE ; do
73
+ echo "ℹ️ Found \"$PACKAGE_FROM_WORKSPACE\" with \"workspace:*\""
74
+
75
+ PACKAGE_FROM_WORKSPACE_PATH=$(pnpm ls --filter $PACKAGE_FROM_WORKSPACE --json --depth -1 | jq -r '.[].path')
76
+ echo "ℹ️ The package \"$PACKAGE_FROM_WORKSPACE\" is located in \"$PACKAGE_FROM_WORKSPACE_PATH\" directory"
77
+
78
+ echo "⚒️ Replacing \"$PACKAGE_FROM_WORKSPACE\" with \"file:$PACKAGE_FROM_WORKSPACE_PATH\" in $PACKAGE_PATH/package.json"
79
+ sed -i "s|\"$PACKAGE_FROM_WORKSPACE\": \"workspace:\*\"|\"$PACKAGE_FROM_WORKSPACE\": \"file:$PACKAGE_FROM_WORKSPACE_PATH\"|g" "$PACKAGE_PATH/package.json"
80
+ done;
81
+ done
82
+
63
83
- working-directory : test_apps/encore-app
64
- run : pnpm install --ignore-workspace
84
+ run : npm install
65
85
66
86
- if : matrix.ux-packages-source == 'js-packages'
67
87
name : Install UX JS packages with a JS package manager
68
88
working-directory : test_apps/encore-app
69
89
run : |
70
90
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"
91
+ for PACKAGE_DATA in $(pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
92
+ PACKAGE_PATH=$(echo $PACKAGE_DATA | jq -r '.path')
93
+ PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL file:$(realpath --relative-to=. "$PACKAGE_PATH")"
75
94
done
95
+
76
96
echo "Installing packages: $PACKAGES_TO_INSTALL"
77
- pnpm add --save-dev $PACKAGES_TO_INSTALL
97
+ npm add --save-dev $PACKAGES_TO_INSTALL
78
98
79
99
- name : Ensure UX packages are installed from "${{ env.EXPECTED_PATTERN }}"
80
100
working-directory : test_apps/encore-app
81
101
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')
102
+ for PACKAGE_DATA in $(cat package.json | jq -c '(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.key | startswith("@symfony/ux-")) | {name: .key, version: .value}'); do
103
+ PACKAGE =$(echo $PACKAGE_DATA | jq -r '.name')
104
+ PACKAGE_VERSION=$(echo $PACKAGE_DATA | jq -r '.version')
85
105
86
- echo -n "Checking $PACKAGE_NAME @$PACKAGE_VERSION..."
106
+ echo -n "Checking $PACKAGE @$PACKAGE_VERSION..."
87
107
if [[ $PACKAGE_VERSION == $EXPECTED_PATTERN* ]]; then
88
- echo " OK"
108
+ echo "✅ OK"
89
109
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."
110
+ echo "❌ KO"
111
+ echo "ℹ️ The package version of $PACKAGE must starts with the pattern (e.g.: $EXPECTED_PATTERN), got $PACKAGE_VERSION instead."
92
112
exit 1
93
113
fi
94
114
done;
97
117
98
118
- name : Ensure project can be built in dev mode
99
119
working-directory : test_apps/encore-app
100
- run : pnpm run dev
120
+ run : npm run dev
101
121
102
122
- name : Ensure project can be built in prod mode
103
123
working-directory : test_apps/encore-app
104
- run : pnpm run build
124
+ run : npm run build
0 commit comments