@@ -60,21 +60,38 @@ jobs:
6060 working-directory : test_apps/encore-app
6161 dependency-versions : highest
6262
63- - working-directory : test_apps/encore-app
64- run : pnpm install --ignore-workspace
65-
6663 - if : matrix.ux-packages-source == 'js-packages'
6764 name : Install UX JS packages with a JS package manager
6865 working-directory : test_apps/encore-app
6966 run : |
7067 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')
68+ for PACKAGE_DATA in $(cd ../..; pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
69+ PACKAGE_NAME=$(echo $PACKAGE_DATA | jq -r '.name')
70+ PACKAGE_ABSOLUTE_PATH=$(echo $PACKAGE_DATA | jq -r '.path')
7371 PACKAGE_RELATIVE_PATH=$(realpath --relative-to=. "$PACKAGE_ABSOLUTE_PATH")
7472 PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL file:$PACKAGE_RELATIVE_PATH"
73+
74+ # Manually replace "workspace:" constraints with the actual package version, it ensure packages can be installed with npm
75+ jq -rc '[(.dependencies // {}) + (.devDependencies // {}) | to_entries[] | select(.value == "workspace:*") | .key][]' "$PACKAGE_ABSOLUTE_PATH/package.json" | while read -r PACKAGE_FROM_WORKSPACE ; do
76+ # Extract the resolved version of the package from the workspace, e.g.: "link:../../../../assets"
77+ RESOLVED_VERSION=$(pnpm ls --filter @symfony/ux-google-map --json | jq -r --arg PACKAGE_FROM_WORKSPACE $PACKAGE_FROM_WORKSPACE '
78+ .[].dependencies // {} + .[].devDependencies // {} |
79+ to_entries[] |
80+ select(.value.from == $PACKAGE_FROM_WORKSPACE) |
81+ .value.version
82+ ')
83+
84+ # Replace "link:" (pnpm) with "file:" (compatible with npm)
85+ RESOLVED_VERSION=${RESOLVED_VERSION/link:/file:}
86+
87+ # Replace the package "workspace:*" with the actual version
88+ echo "Replacing \"$PACKAGE_FROM_WORKSPACE\" with \"$RESOLVED_VERSION\" in $PACKAGE_ABSOLUTE_PATH/package.json"
89+ sed -i "s|\"$PACKAGE_FROM_WORKSPACE\": \"workspace:\*\"|\"$PACKAGE_FROM_WORKSPACE\": \"$RESOLVED_VERSION\"|g" "$PACKAGE_ABSOLUTE_PATH/package.json"
90+ done;
7591 done
92+
7693 echo "Installing packages: $PACKAGES_TO_INSTALL"
77- pnpm add --save-dev $PACKAGES_TO_INSTALL
94+ npm add --save-dev $PACKAGES_TO_INSTALL
7895
7996 - name : Ensure UX packages are installed from "${{ env.EXPECTED_PATTERN }}"
8097 working-directory : test_apps/encore-app
97114
98115 - name : Ensure project can be built in dev mode
99116 working-directory : test_apps/encore-app
100- run : pnpm run dev
117+ run : npm run dev
101118
102119 - name : Ensure project can be built in prod mode
103120 working-directory : test_apps/encore-app
104- run : pnpm run build
121+ run : npm run build
0 commit comments