Skip to content

Commit 78d243e

Browse files
committed
minor #2349 [DX] Some improvements for dependencies management when testing (Kocal)
This PR was merged into the 2.x branch. Discussion ---------- [DX] Some improvements for dependencies management when testing | Q | A | ------------- | --- | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Issues | Fix #... <!-- 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. - 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). --> Added two new internal features to the test process: 1. We now check for `peerDependencies.*` and `symfony.importmap.*` homogeneity, that was pretty useful before, when versions were altered without being restored when running `yarn test`. It's in fact less necessary due to the 2nd feature: ``` ➜ assets git:(test-improvments-versions) ✗ yarn test Processing workspace `@symfony`/ux-chartjs at location /Users/kocal/workspace-os/symfony-ux/src/Chartjs/assets... Checking '/Users/kocal/workspace-os/symfony-ux/src/Chartjs/assets/package.json' for peerDependencies and importmap dependencies to have the same version -> Version mismatch for chart.js: ^4.0 (peerDependencies) vs ^3.4.1 || ^4.0 (importmap) -> You need to match the version of the "peerDependency" with the version in the "importmap" ``` 2. We now cleanup changes when a peerDependency changed because it has multiple versions, this allows us to keep a clean `package.json` and `yarn.lock`, and so a clean project state: ``` ➜ assets git:(test-improvments-versions) yarn test Processing workspace `@symfony`/ux-chartjs at location /Users/kocal/workspace-os/symfony-ux/src/Chartjs/assets... Checking '/Users/kocal/workspace-os/symfony-ux/src/Chartjs/assets/package.json' for peerDependencies and importmap dependencies to have the same version Checking '/Users/kocal/workspace-os/symfony-ux/src/Chartjs/assets/package.json' for peerDependencies with multiple versions defined -> Multiple versions found for peerDependencies: chart.js - Install chart.js@^3.4.1 for `@symfony`/ux-chartjs ➤ YN0000: · Yarn 4.5.0 ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed ➤ YN0000: ┌ Post-resolution validation ➤ YN0060: │ rollup is listed by your project with version 4.22.5 (pf8256), which doesn't satisfy what `@rollup`/pluginutils (via `@rollup`/plugin-commonjs) and other dependencies request (^2.78.0 || ^3.0.0). ➤ YN0002: │ `@symfony`/ux-autocomplete@workspace:src/Autocomplete/assets doesn't provide vitest (pc8205), requested by vitest-fetch-mock. ➤ YN0002: │ `@symfony`/ux-chartjs@workspace:src/Chartjs/assets doesn't provide vitest (pccf90), requested by vitest-canvas-mock. ➤ YN0002: │ `@symfony`/ux-react@workspace:src/React/assets doesn't provide vite (pbe8ce), requested by `@vitejs`/plugin-react. ➤ YN0002: │ `@symfony`/ux-svelte@workspace:src/Svelte/assets doesn't provide vite (pf0478), requested by `@sveltejs`/vite-plugin-svelte. ➤ YN0002: │ `@symfony`/ux-vue@workspace:src/Vue/assets doesn't provide vite (p99573), requested by `@vitejs`/plugin-vue. ➤ YN0086: │ Some peer dependencies are incorrectly met by your project; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code. ➤ YN0086: │ Some peer dependencies are incorrectly met by dependencies; run yarn explain peer-requirements for details. ➤ YN0000: └ Completed ➤ YN0000: ┌ Fetch step ➤ YN0000: └ Completed in 0s 268ms ➤ YN0000: ┌ Link step ➤ YN0000: └ Completed ➤ YN0000: · Done with warnings in 0s 666ms Running tests for `@symfony`/ux-chartjs... RUN v2.1.1 /Users/kocal/workspace-os/symfony-ux/src/Chartjs/assets ✓ test/controller.test.ts (5) ✓ ChartjsController (5) ✓ connect without options ✓ connect with options ✓ will update when the view data changes ✓ will update when the view data changes without options ✓ dispatches the events correctly Test Files 1 passed (1) Tests 5 passed (5) Start at 10:21:45 Duration 1.13s (transform 51ms, setup 93ms, collect 205ms, tests 114ms, environment 480ms, prepare 63ms) - Install chart.js@^4.0 for `@symfony`/ux-chartjs ➤ YN0000: · Yarn 4.5.0 ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed ➤ YN0000: ┌ Post-resolution validation ➤ YN0060: │ rollup is listed by your project with version 4.22.5 (pf8256), which doesn't satisfy what `@rollup`/pluginutils (via `@rollup`/plugin-commonjs) and other dependencies request (^2.78.0 || ^3.0.0). ➤ YN0002: │ `@symfony`/ux-autocomplete@workspace:src/Autocomplete/assets doesn't provide vitest (pc8205), requested by vitest-fetch-mock. ➤ YN0002: │ `@symfony`/ux-chartjs@workspace:src/Chartjs/assets doesn't provide vitest (pccf90), requested by vitest-canvas-mock. ➤ YN0002: │ `@symfony`/ux-react@workspace:src/React/assets doesn't provide vite (pbe8ce), requested by `@vitejs`/plugin-react. ➤ YN0002: │ `@symfony`/ux-svelte@workspace:src/Svelte/assets doesn't provide vite (pf0478), requested by `@sveltejs`/vite-plugin-svelte. ➤ YN0002: │ `@symfony`/ux-vue@workspace:src/Vue/assets doesn't provide vite (p99573), requested by `@vitejs`/plugin-vue. ➤ YN0086: │ Some peer dependencies are incorrectly met by your project; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code. ➤ YN0086: │ Some peer dependencies are incorrectly met by dependencies; run yarn explain peer-requirements for details. ➤ YN0000: └ Completed ➤ YN0000: ┌ Fetch step ➤ YN0000: └ Completed in 0s 259ms ➤ YN0000: ┌ Link step ➤ YN0000: └ Completed ➤ YN0000: · Done with warnings in 0s 664ms Running tests for `@symfony`/ux-chartjs... RUN v2.1.1 /Users/kocal/workspace-os/symfony-ux/src/Chartjs/assets ✓ test/controller.test.ts (5) ✓ ChartjsController (5) ✓ connect without options ✓ connect with options ✓ will update when the view data changes ✓ will update when the view data changes without options ✓ dispatches the events correctly Test Files 1 passed (1) Tests 5 passed (5) Start at 10:21:48 Duration 757ms (transform 49ms, setup 69ms, collect 149ms, tests 114ms, environment 221ms, prepare 62ms) -> Reverting version changes for chart.js ➤ YN0000: · Yarn 4.5.0 ➤ YN0000: ┌ Resolution step ➤ YN0000: └ Completed ➤ YN0000: ┌ Post-resolution validation ➤ YN0060: │ rollup is listed by your project with version 4.22.5 (pf8256), which doesn't satisfy what `@rollup`/pluginutils (via `@rollup`/plugin-commonjs) and other dependencies request (^2.78.0 || ^3.0.0). ➤ YN0002: │ `@symfony`/ux-autocomplete@workspace:src/Autocomplete/assets doesn't provide vitest (pc8205), requested by vitest-fetch-mock. ➤ YN0002: │ `@symfony`/ux-chartjs@workspace:src/Chartjs/assets doesn't provide vitest (pccf90), requested by vitest-canvas-mock. ➤ YN0002: │ `@symfony`/ux-react@workspace:src/React/assets doesn't provide vite (pbe8ce), requested by `@vitejs`/plugin-react. ➤ YN0002: │ `@symfony`/ux-svelte@workspace:src/Svelte/assets doesn't provide vite (pf0478), requested by `@sveltejs`/vite-plugin-svelte. ➤ YN0002: │ `@symfony`/ux-vue@workspace:src/Vue/assets doesn't provide vite (p99573), requested by `@vitejs`/plugin-vue. ➤ YN0086: │ Some peer dependencies are incorrectly met by your project; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code. ➤ YN0086: │ Some peer dependencies are incorrectly met by dependencies; run yarn explain peer-requirements for details. ➤ YN0000: └ Completed ➤ YN0000: ┌ Fetch step ➤ YN0000: └ Completed in 0s 259ms ➤ YN0000: ┌ Link step ➤ YN0000: └ Completed ➤ YN0000: · Done with warnings in 0s 665ms All tests passed! ``` Commits ------- 11342b4 [Test] Check for peerDependencies/symfony.importmap homogeneity, cleanup changes when a peerDependency changed because multiple versions
2 parents 86e571c + 11342b4 commit 78d243e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

bin/test_package.sh

+16
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@ processWorkspace() {
4747
fi
4848

4949
echo -e "Processing workspace $workspace at location $location...\n"
50+
51+
echo "Checking '$package_json_path' for peerDependencies and importmap dependencies to have the same version"
52+
deps=$(jq -r '.peerDependencies | keys[]' "$package_json_path")
53+
for library in $deps; do
54+
version=$(jq -r ".peerDependencies.\"$library\"" "$package_json_path")
55+
importmap_version=$(jq -r ".symfony.importmap.\"$library\"" "$package_json_path")
56+
57+
if [ "$version" != "$importmap_version" ]; then
58+
echo " -> Version mismatch for $library: $version (peerDependencies) vs $importmap_version (importmap)"
59+
echo " -> You need to match the version of the \"peerDependency\" with the version in the \"importmap\""
60+
exit
61+
fi
62+
done
5063

5164
echo "Checking '$package_json_path' for peerDependencies with multiple versions defined"
5265
deps_with_multiple_versions=$(jq -r '.peerDependencies | to_entries[] | select(.value | contains("||")) | .key' "$package_json_path")
@@ -68,6 +81,9 @@ processWorkspace() {
6881
runTestSuite
6982
fi
7083
done
84+
85+
echo " -> Reverting version changes for $library"
86+
yarn workspace "$workspace" add "$library@$versionValue" --peer
7187
done
7288
else
7389
echo -e " -> No peerDependencies found with multiple versions defined\n"

0 commit comments

Comments
 (0)