4040 cache-dependency-path : |
4141 package.json
4242 src/**/package.json
43- test_apps/encore-app/pnpm-lock.yaml
4443 test_apps/encore-app/package.json
4544
4645 - uses : shivammathur/setup-php@v2
@@ -60,35 +59,60 @@ jobs:
6059 working-directory : test_apps/encore-app
6160 dependency-versions : highest
6261
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+ # Extract the resolved version of the package from the workspace, e.g.: "link:../../../../assets"
74+ echo "ℹ️ Found \"$PACKAGE_FROM_WORKSPACE\" with \"workspace:*\""
75+
76+ PACKAGE_FROM_WORKSPACE_PATH=$(pnpm ls --filter $PACKAGE_FROM_WORKSPACE --json --depth -1 | jq -r '.[].path')
77+ echo "ℹ️ The package \"$PACKAGE_FROM_WORKSPACE\" is located in \"$PACKAGE_FROM_WORKSPACE_PATH\" directory"
78+
79+ echo "⚒️ Replacing \"$PACKAGE_FROM_WORKSPACE\" with \"file:$PACKAGE_FROM_WORKSPACE_PATH\" in $PACKAGE_PATH/package.json"
80+ sed -i "s|\"$PACKAGE_FROM_WORKSPACE\": \"workspace:\*\"|\"$PACKAGE_FROM_WORKSPACE\": \"file:$PACKAGE_FROM_WORKSPACE_PATH\"|g" "$PACKAGE_PATH/package.json"
81+ done;
82+ done
83+
6384 - working-directory : test_apps/encore-app
64- run : pnpm install --ignore-workspace
85+ run : npm install
6586
6687 - if : matrix.ux-packages-source == 'js-packages'
6788 name : Install UX JS packages with a JS package manager
6889 working-directory : test_apps/encore-app
6990 run : |
7091 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"
92+ for PACKAGE_DATA in $(pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
93+ PACKAGE_PATH=$(echo $PACKAGE_DATA | jq -r '.path')
94+ PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL file:$(realpath --relative-to=. "$PACKAGE_PATH")"
7595 done
96+
7697 echo "Installing packages: $PACKAGES_TO_INSTALL"
77- pnpm add --save-dev $PACKAGES_TO_INSTALL
98+ npm add --save-dev $PACKAGES_TO_INSTALL
7899
79100 - name : Ensure UX packages are installed from "${{ env.EXPECTED_PATTERN }}"
80101 working-directory : test_apps/encore-app
81102 run : |
103+ cat package.json
104+ cat package.json | jq -c '(.dependencies // {}) + (.devDependencies // {})'
105+
82106 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')
107+ PACKAGE =$(echo $PACKAGE | jq -r '.name')
84108 PACKAGE_VERSION=$(echo $PACKAGE | jq -r '.version')
85109
86- echo -n "Checking $PACKAGE_NAME @$PACKAGE_VERSION..."
110+ echo -n "Checking $PACKAGE @$PACKAGE_VERSION..."
87111 if [[ $PACKAGE_VERSION == $EXPECTED_PATTERN* ]]; then
88112 echo " OK"
89113 else
90114 echo " KO"
91- echo "The package version of $PACKAGE_NAME must starts with the pattern (e.g.: $EXPECTED_PATTERN), got $PACKAGE_VERSION instead."
115+ echo "The package version of $PACKAGE must starts with the pattern (e.g.: $EXPECTED_PATTERN), got $PACKAGE_VERSION instead."
92116 exit 1
93117 fi
94118 done;
97121
98122 - name : Ensure project can be built in dev mode
99123 working-directory : test_apps/encore-app
100- run : pnpm run dev
124+ run : npm run dev
101125
102126 - name : Ensure project can be built in prod mode
103127 working-directory : test_apps/encore-app
104- run : pnpm run build
128+ run : npm run build
0 commit comments