Skip to content

Commit f2b7945

Browse files
committed
bug symfony#2952 Fix package.json files to not use "catalog" feature from PNPM, as it breaks installation from vendor/ PHP packages (Kocal)
This PR was merged into the 2.x branch. Discussion ---------- Fix package.json files to not use "catalog" feature from PNPM, as it breaks installation from `vendor/` PHP packages | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Docs? | no <!-- required for new features --> | Issues | Fix symfony#2951 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - For new features, provide some code snippets to help understand usage. - Features and deprecations must be submitted against branch main. - Update/add documentation as required (we can help!) - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Since symfony#2932 Dropping any fancy stuff from our `package.json` since it can breaks when people install JS packages through the PHP packages I will edit the "test apps" jobs to use `npm` to install dependencies, so we will be sure in the future we are not breaking things again. Commits ------- 4c24ce6 Fix package.json files to not use "catalog" feature from PNPM, as it breaks installation from `vendor/` PHP packages
2 parents 0ecca4c + 4c24ce6 commit f2b7945

File tree

27 files changed

+353
-362
lines changed

27 files changed

+353
-362
lines changed

.github/workflows/app-tests.yaml

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,35 +60,60 @@ jobs:
6060
working-directory: test_apps/encore-app
6161
dependency-versions: highest
6262

63+
- name: Manually replacing "workspace:*" references
64+
run: |
65+
for PACKAGE_DATA in $(cd ../..; 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+
echo '---'
77+
pnpm ls --filter $PACKAGE_FROM_WORKSPACE --json --depth -1
78+
echo '---'
79+
80+
PACKAGE_FROM_WORKSPACE_PATH=$(cd ../..; pnpm ls --filter $PACKAGE_FROM_WORKSPACE --json --depth -1 | jq -r '.[].path')
81+
echo "ℹ️ The package \"$PACKAGE_FROM_WORKSPACE\" is located in \"$PACKAGE_FROM_WORKSPACE_PATH\" directory"
82+
83+
echo "⚒️ Replacing \"$PACKAGE_FROM_WORKSPACE\" with \"file:$PACKAGE_FROM_WORKSPACE_PATH\" in $PACKAGE_PATH/package.json"
84+
sed -i "s|\"$PACKAGE_FROM_WORKSPACE\": \"workspace:\*\"|\"$PACKAGE_FROM_WORKSPACE\": \"file:$PACKAGE_FROM_WORKSPACE_PATH\"|g" "$PACKAGE_PATH/package.json"
85+
done;
86+
done
87+
6388
- working-directory: test_apps/encore-app
64-
run: pnpm install --ignore-workspace
89+
run: npm install
6590

6691
- if: matrix.ux-packages-source == 'js-packages'
6792
name: Install UX JS packages with a JS package manager
6893
working-directory: test_apps/encore-app
6994
run: |
7095
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"
96+
for PACKAGE_DATA in $(cd ../..; pnpm ls -r --json --depth -1 | jq 'map(select(.private != true))' | jq -c '.[]'); do
97+
PACKAGE_PATH=$(echo $PACKAGE_DATA | jq -r '.path')
98+
PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL file:$(realpath --relative-to=. "$PACKAGE_PATH")"
7599
done
100+
76101
echo "Installing packages: $PACKAGES_TO_INSTALL"
77-
pnpm add --save-dev $PACKAGES_TO_INSTALL
102+
npm add --save-dev $PACKAGES_TO_INSTALL
78103
79104
- name: Ensure UX packages are installed from "${{ env.EXPECTED_PATTERN }}"
80105
working-directory: test_apps/encore-app
81106
run: |
82107
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')
108+
PACKAGE=$(echo $PACKAGE | jq -r '.name')
84109
PACKAGE_VERSION=$(echo $PACKAGE | jq -r '.version')
85110
86-
echo -n "Checking $PACKAGE_NAME@$PACKAGE_VERSION..."
111+
echo -n "Checking $PACKAGE@$PACKAGE_VERSION..."
87112
if [[ $PACKAGE_VERSION == $EXPECTED_PATTERN* ]]; then
88113
echo " OK"
89114
else
90115
echo " KO"
91-
echo "The package version of $PACKAGE_NAME must starts with the pattern (e.g.: $EXPECTED_PATTERN), got $PACKAGE_VERSION instead."
116+
echo "The package version of $PACKAGE must starts with the pattern (e.g.: $EXPECTED_PATTERN), got $PACKAGE_VERSION instead."
92117
exit 1
93118
fi
94119
done;
@@ -97,8 +122,8 @@ jobs:
97122

98123
- name: Ensure project can be built in dev mode
99124
working-directory: test_apps/encore-app
100-
run: pnpm run dev
125+
run: npm run dev
101126

102127
- name: Ensure project can be built in prod mode
103128
working-directory: test_apps/encore-app
104-
run: pnpm run build
129+
run: npm run build

.github/workflows/code-quality.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ on:
66
- 'src/*/doc/**'
77
- 'src/**/*.md'
88
- 'ux.symfony.com/**'
9+
- '.github/workflows/app-tests.yaml'
910
pull_request:
1011
paths-ignore:
1112
- 'src/*/doc/**'
1213
- 'src/**/*.md'
1314
- 'ux.symfony.com/**'
15+
- '.github/workflows/app-tests.yaml'
1416

1517
concurrency:
1618
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

.github/workflows/unit-tests.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ on:
1010
- 'src/*/doc/**'
1111
- 'src/**/*.md'
1212
- 'ux.symfony.com/**'
13+
- '.github/workflows/app-tests.yaml'
1314
pull_request:
1415
paths-ignore:
1516
- 'src/*/doc/**'
1617
- 'src/**/*.md'
1718
- 'ux.symfony.com/**'
19+
- '.github/workflows/app-tests.yaml'
1820

1921
concurrency:
2022
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

.github/workflows/ux.symfony.com.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ on:
88
- '!src/*/doc/**'
99
- '!src/**/*.md'
1010
- '.github/**'
11+
- '!.github/workflows/app-tests.yaml'
1112
pull_request:
1213
paths:
1314
- 'ux.symfony.com/**'
1415
- 'src/*/**'
1516
- '!src/*/doc/**'
1617
- '!src/**/*.md'
1718
- '.github/**'
19+
- '!.github/workflows/app-tests.yaml'
1820

1921
jobs:
2022

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
},
1515
"devDependencies": {
1616
"@biomejs/biome": "^2.0.4",
17-
"@testing-library/dom": "catalog:",
18-
"@testing-library/jest-dom": "catalog:",
17+
"@testing-library/dom": "^10.4.0",
18+
"@testing-library/jest-dom": "^6.6.3",
1919
"@types/node": "^22.6.0",
2020
"lightningcss": "^1.28.2",
2121
"pkg-types": "^2.2.0",
2222
"playwright": "^1.47.0",
2323
"tinyglobby": "^0.2.14",
2424
"tsup": "^8.5.0",
25-
"vitest": "catalog:"
25+
"vitest": "^3.2.4"
2626
},
2727
"version": "2.27.0"
2828
}

0 commit comments

Comments
 (0)