@@ -61,20 +61,40 @@ jobs:
6161 dependency-versions : highest
6262
6363 - working-directory : test_apps/encore-app
64- run : pnpm install --ignore-workspace
64+ run : npm install
6565
6666 - if : matrix.ux-packages-source == 'js-packages'
6767 name : Install UX JS packages with a JS package manager
6868 working-directory : test_apps/encore-app
6969 run : |
7070 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')
71+ for PACKAGE_DATA in $(cd ../..; pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
72+ PACKAGE_NAME=$(echo $PACKAGE_DATA | jq -r '.name')
73+ PACKAGE_ABSOLUTE_PATH=$(echo $PACKAGE_DATA | jq -r '.path')
7374 PACKAGE_RELATIVE_PATH=$(realpath --relative-to=. "$PACKAGE_ABSOLUTE_PATH")
7475 PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL file:$PACKAGE_RELATIVE_PATH"
76+
77+ # Manually replace "workspace:" constraints with the actual package version, it ensure packages can be installed with npm
78+ jq -rc '[(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.value == "workspace:*") | .key][]' "$PACKAGE_ABSOLUTE_PATH/package.json" | while read -r PACKAGE_FROM_WORKSPACE ; do
79+ # Extract the resolved version of the package from the workspace, e.g.: "link:../../../../assets"
80+ RESOLVED_VERSION=$(pnpm ls --filter @symfony/ux-google-map --json | jq -r --arg PACKAGE_FROM_WORKSPACE $PACKAGE_FROM_WORKSPACE '
81+ .[].dependencies // {} + .[].devDependencies // {} |
82+ to_entries[] |
83+ select(.value.from == $PACKAGE_FROM_WORKSPACE) |
84+ .value.version
85+ ')
86+
87+ # Replace "link:" (pnpm) with "file:" (compatible with npm)
88+ RESOLVED_VERSION=${RESOLVED_VERSION/link:/file:}
89+
90+ # Replace the package "workspace:*" with the actual version
91+ echo "Replacing \"$PACKAGE_FROM_WORKSPACE\" with \"$RESOLVED_VERSION\" in $PACKAGE_ABSOLUTE_PATH/package.json"
92+ sed -i "s|\"$PACKAGE_FROM_WORKSPACE\": \"workspace:\*\"|\"$PACKAGE_FROM_WORKSPACE\": \"$RESOLVED_VERSION\"|g" "$PACKAGE_ABSOLUTE_PATH/package.json"
93+ done;
7594 done
95+
7696 echo "Installing packages: $PACKAGES_TO_INSTALL"
77- pnpm add --save-dev $PACKAGES_TO_INSTALL
97+ npm add --save-dev $PACKAGES_TO_INSTALL
7898
7999 - name : Ensure UX packages are installed from "${{ env.EXPECTED_PATTERN }}"
80100 working-directory : test_apps/encore-app
97117
98118 - name : Ensure project can be built in dev mode
99119 working-directory : test_apps/encore-app
100- run : pnpm run dev
120+ run : npm run dev
101121
102122 - name : Ensure project can be built in prod mode
103123 working-directory : test_apps/encore-app
104- run : pnpm run build
124+ run : npm run build
0 commit comments