From 42e4e2455a14b6a494f0ef31dec513214bcae7cb Mon Sep 17 00:00:00 2001 From: "voidzero-bot[bot]" <348775505+voidzero-bot[bot]@users.noreply.github.com> Date: Sun, 29 Nov 2026 05:29:56 +0000 Subject: [PATCH] fix(cli): stop writing the managed vitest pnpm peerDependencyRules entry --- .../snapshots/migration_from_vitest_config.md | 5 - .../snapshots/migration_from_vitest_files.md | 5 - .../snapshots/migration_import_rule_fresh.md | 5 - .../snapshots/migration_import_rule_full.md | 5 - .../migration_import_rule_upgrade.md | 5 - ...gration_import_rule_template_dependency.md | 5 - .../migration_merge_vite_config_ts.md | 5 - .../snapshots/migration_monorepo_pnpm.md | 5 - .../snapshots/migration_npmx_dev.md | 6 +- .../snapshots/migration_playwright_test.md | 6 +- .../migration_rewrite_declare_module.md | 5 - ...igration_upgrade_browser_peer_only_pnpm.md | 5 - ...ration_upgrade_browser_source_only_pnpm.md | 5 - ...ration_upgrade_browser_webdriverio_pnpm.md | 5 - .../upgrade_community_provider_catalog.md | 5 - .../migration_upgrade_hooks_flag_pnpm.md | 1 + ..._upgrade_monorepo_vitest_localized_pnpm.md | 5 - ...ration_upgrade_nuxt_test_utils_monorepo.md | 5 - .../migration_upgrade_pkg_pr_new_pnpm.md | 5 +- .../migration_upgrade_pnpm9_overrides.md | 6 +- .../migration_upgrade_setup_full_pnpm.md | 1 + ...tion_upgrade_setup_skipped_default_pnpm.md | 1 + .../migration_upgrade_stale_local_pnpm.md | 1 + .../snapshots/migration_vitest_peer_dep.md | 5 - .../migration_workspace_vite_template.md | 5 - docs/guide/migrate-rules.md | 8 +- .../vite-peer-dependency-rule.spec.ts | 150 +++++++++++++++++- packages/cli/src/migration/bin.ts | 5 + .../cli/src/migration/migrator/catalog.ts | 52 +++--- .../src/migration/migrator/orchestrators.ts | 10 +- packages/cli/src/migration/migrator/shared.ts | 23 +++ .../migration/migrator/vite-plus-bootstrap.ts | 6 +- .../migration/migrator/vitest-ecosystem.ts | 20 ++- packages/cli/src/migration/report.ts | 2 + 34 files changed, 251 insertions(+), 137 deletions(-) diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_from_vitest_config/snapshots/migration_from_vitest_config.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_from_vitest_config/snapshots/migration_from_vitest_config.md index 54cb5e435b..55f6a44402 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_from_vitest_config/snapshots/migration_from_vitest_config.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_from_vitest_config/snapshots/migration_from_vitest_config.md @@ -106,9 +106,4 @@ overrides: vite@*: 'catalog:' vitest@*: 'catalog:' '@vitest/browser@*': -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_from_vitest_files/snapshots/migration_from_vitest_files.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_from_vitest_files/snapshots/migration_from_vitest_files.md index f3a6324d81..f205d20aee 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_from_vitest_files/snapshots/migration_from_vitest_files.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_from_vitest_files/snapshots/migration_from_vitest_files.md @@ -50,11 +50,6 @@ catalog: overrides: vite@*: 'catalog:' vitest@*: 'catalog:' -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` ## `vpt print-file test/hello.ts` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_import_rule/snapshots/migration_import_rule_fresh.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_import_rule/snapshots/migration_import_rule_fresh.md index 53a68f912c..1c8bd19853 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_import_rule/snapshots/migration_import_rule_fresh.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_import_rule/snapshots/migration_import_rule_fresh.md @@ -100,9 +100,4 @@ overrides: unrelated-package: 1.0.0 vite@*: 'catalog:' vitest@*: 'catalog:' -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_import_rule/snapshots/migration_import_rule_full.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_import_rule/snapshots/migration_import_rule_full.md index 5e64cff4b8..bc5044b338 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_import_rule/snapshots/migration_import_rule_full.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_import_rule/snapshots/migration_import_rule_full.md @@ -96,11 +96,6 @@ overrides: unrelated-package: 1.0.0 vite@*: 'catalog:' vitest@*: 'catalog:' -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` ## `vpt write-file packages/app/unit.test.ts 'import { test } from '\''vitest'\''; diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_import_rule/snapshots/migration_import_rule_upgrade.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_import_rule/snapshots/migration_import_rule_upgrade.md index f3b78ecf3b..d74f413dbe 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_import_rule/snapshots/migration_import_rule_upgrade.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_import_rule/snapshots/migration_import_rule_upgrade.md @@ -96,11 +96,6 @@ overrides: unrelated-package: 1.0.0 vite@*: 'catalog:' vitest@*: 'catalog:' -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` ## `vp migrate --no-interactive --no-hooks --no-agent --no-editor` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_import_rule_template_dependency/snapshots/migration_import_rule_template_dependency.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_import_rule_template_dependency/snapshots/migration_import_rule_template_dependency.md index 4e65297ef1..f5b06de110 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_import_rule_template_dependency/snapshots/migration_import_rule_template_dependency.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_import_rule_template_dependency/snapshots/migration_import_rule_template_dependency.md @@ -70,11 +70,6 @@ catalog: overrides: vite@*: 'catalog:' vitest@*: 'catalog:' -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` ## `vpt stat-file templates/starter/node_modules --assert missing` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_merge_vite_config_ts/snapshots/migration_merge_vite_config_ts.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_merge_vite_config_ts/snapshots/migration_merge_vite_config_ts.md index 097d14b181..11f589d45f 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_merge_vite_config_ts/snapshots/migration_merge_vite_config_ts.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_merge_vite_config_ts/snapshots/migration_merge_vite_config_ts.md @@ -162,9 +162,4 @@ catalog: overrides: vite@*: 'catalog:' vitest@*: 'catalog:' -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_monorepo_pnpm/snapshots/migration_monorepo_pnpm.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_monorepo_pnpm/snapshots/migration_monorepo_pnpm.md index 99c3d99404..99cf383c12 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_monorepo_pnpm/snapshots/migration_monorepo_pnpm.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_monorepo_pnpm/snapshots/migration_monorepo_pnpm.md @@ -138,11 +138,6 @@ trustPolicyExclude: overrides: vite@*: 'catalog:' vitest@*: 'catalog:' -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' minimumReleaseAgeExclude: - vite-plus - '@voidzero-dev/*' diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_npmx_dev/snapshots/migration_npmx_dev.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_npmx_dev/snapshots/migration_npmx_dev.md index 5e1ad05ab6..47ca942435 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_npmx_dev/snapshots/migration_npmx_dev.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_npmx_dev/snapshots/migration_npmx_dev.md @@ -17,6 +17,7 @@ VITE+ - The Unified Toolchain for the Web @vitest/coverage-v8 4.1.10 → • Package manager settings configured • Removed `vite` from pnpm peerDependencyRules: the core version now matches the bundled Vite +• Removed `vitest` from pnpm peerDependencyRules: the managed `vitest` is pinned to the real bundled Vitest version ``` ## `vpt print-file package.json` @@ -61,9 +62,4 @@ catalog: overrides: vite@*: 'catalog:' vitest@*: 'catalog:' -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_playwright_test/snapshots/migration_playwright_test.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_playwright_test/snapshots/migration_playwright_test.md index 7140b67dc1..f0e731b522 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_playwright_test/snapshots/migration_playwright_test.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_playwright_test/snapshots/migration_playwright_test.md @@ -17,6 +17,7 @@ VITE+ - The Unified Toolchain for the Web @vitest/coverage-v8 4.1.10 → • Package manager settings configured • Removed `vite` from pnpm peerDependencyRules: the core version now matches the bundled Vite +• Removed `vitest` from pnpm peerDependencyRules: the managed `vitest` is pinned to the real bundled Vitest version ``` ## `vpt print-file package.json` @@ -61,9 +62,4 @@ catalog: overrides: vite@*: 'catalog:' vitest@*: 'catalog:' -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_rewrite_declare_module/snapshots/migration_rewrite_declare_module.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_rewrite_declare_module/snapshots/migration_rewrite_declare_module.md index de54e90796..b2ace8b54b 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_rewrite_declare_module/snapshots/migration_rewrite_declare_module.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_rewrite_declare_module/snapshots/migration_rewrite_declare_module.md @@ -82,9 +82,4 @@ catalog: overrides: vite@*: 'catalog:' vitest@*: 'catalog:' -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_browser_peer_only_pnpm/snapshots/migration_upgrade_browser_peer_only_pnpm.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_browser_peer_only_pnpm/snapshots/migration_upgrade_browser_peer_only_pnpm.md index 1ee7aa7d57..efdebeb714 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_browser_peer_only_pnpm/snapshots/migration_upgrade_browser_peer_only_pnpm.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_browser_peer_only_pnpm/snapshots/migration_upgrade_browser_peer_only_pnpm.md @@ -55,11 +55,6 @@ catalog: overrides: vite@*: 'catalog:' vitest@*: 'catalog:' -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` ## `vp migrate --no-interactive` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_browser_source_only_pnpm/snapshots/migration_upgrade_browser_source_only_pnpm.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_browser_source_only_pnpm/snapshots/migration_upgrade_browser_source_only_pnpm.md index be418e27f8..7286a5d96f 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_browser_source_only_pnpm/snapshots/migration_upgrade_browser_source_only_pnpm.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_browser_source_only_pnpm/snapshots/migration_upgrade_browser_source_only_pnpm.md @@ -58,9 +58,4 @@ catalog: overrides: vite@*: 'catalog:' vitest@*: 'catalog:' -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_browser_webdriverio_pnpm/snapshots/migration_upgrade_browser_webdriverio_pnpm.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_browser_webdriverio_pnpm/snapshots/migration_upgrade_browser_webdriverio_pnpm.md index 2264e3d0cf..0b5128f015 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_browser_webdriverio_pnpm/snapshots/migration_upgrade_browser_webdriverio_pnpm.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_browser_webdriverio_pnpm/snapshots/migration_upgrade_browser_webdriverio_pnpm.md @@ -76,11 +76,6 @@ overrides: vite@*: 'catalog:' vitest@*: 'catalog:' '@vitest/browser@*': -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' allowBuilds: edgedriver: true geckodriver: true diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_browser_webdriverio_pnpm/snapshots/upgrade_community_provider_catalog.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_browser_webdriverio_pnpm/snapshots/upgrade_community_provider_catalog.md index f93ad80924..f68b63a35b 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_browser_webdriverio_pnpm/snapshots/upgrade_community_provider_catalog.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_browser_webdriverio_pnpm/snapshots/upgrade_community_provider_catalog.md @@ -73,11 +73,6 @@ overrides: allowBuilds: edgedriver: true geckodriver: true -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` ## `vp migrate --no-interactive` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_hooks_flag_pnpm/snapshots/migration_upgrade_hooks_flag_pnpm.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_hooks_flag_pnpm/snapshots/migration_upgrade_hooks_flag_pnpm.md index 8e1a3d1342..5011e27c0d 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_hooks_flag_pnpm/snapshots/migration_upgrade_hooks_flag_pnpm.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_hooks_flag_pnpm/snapshots/migration_upgrade_hooks_flag_pnpm.md @@ -19,6 +19,7 @@ VITE+ - The Unified Toolchain for the Web • Git hooks configured • Package manager settings configured • Removed `vite` from pnpm peerDependencyRules: the core version now matches the bundled Vite +• Removed `vitest` from pnpm peerDependencyRules: the managed `vitest` is pinned to the real bundled Vitest version ``` ## `git config --local core.hooksPath` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_monorepo_vitest_localized_pnpm/snapshots/migration_upgrade_monorepo_vitest_localized_pnpm.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_monorepo_vitest_localized_pnpm/snapshots/migration_upgrade_monorepo_vitest_localized_pnpm.md index 28c87514c2..7f95b61e80 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_monorepo_vitest_localized_pnpm/snapshots/migration_upgrade_monorepo_vitest_localized_pnpm.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_monorepo_vitest_localized_pnpm/snapshots/migration_upgrade_monorepo_vitest_localized_pnpm.md @@ -67,9 +67,4 @@ catalog: overrides: vite@*: 'catalog:' vitest@*: 'catalog:' -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_nuxt_test_utils_monorepo/snapshots/migration_upgrade_nuxt_test_utils_monorepo.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_nuxt_test_utils_monorepo/snapshots/migration_upgrade_nuxt_test_utils_monorepo.md index fe95d68337..f78b30444b 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_nuxt_test_utils_monorepo/snapshots/migration_upgrade_nuxt_test_utils_monorepo.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_nuxt_test_utils_monorepo/snapshots/migration_upgrade_nuxt_test_utils_monorepo.md @@ -60,11 +60,6 @@ catalog: overrides: vite@*: 'catalog:' vitest@*: 'catalog:' -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` ## `vpt print-file packages/nuxt/nuxt.spec.ts` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_pkg_pr_new_pnpm/snapshots/migration_upgrade_pkg_pr_new_pnpm.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_pkg_pr_new_pnpm/snapshots/migration_upgrade_pkg_pr_new_pnpm.md index 59094af3ff..753be68d56 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_pkg_pr_new_pnpm/snapshots/migration_upgrade_pkg_pr_new_pnpm.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_pkg_pr_new_pnpm/snapshots/migration_upgrade_pkg_pr_new_pnpm.md @@ -15,6 +15,7 @@ VITE+ - The Unified Toolchain for the Web vitest 0.1.20 → @vitest/coverage-v8 4.1.6 → • Package manager settings configured +• Removed `vitest` from pnpm peerDependencyRules: the managed `vitest` is pinned to the real bundled Vitest version ``` ## `vpt print-file package.json` @@ -57,10 +58,8 @@ overrides: peerDependencyRules: allowAny: - vite - - vitest allowedVersions: vite: '*' - vitest: '*' ``` ## `vp migrate --no-interactive` @@ -113,8 +112,6 @@ overrides: peerDependencyRules: allowAny: - vite - - vitest allowedVersions: vite: '*' - vitest: '*' ``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_pnpm9_overrides/snapshots/migration_upgrade_pnpm9_overrides.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_pnpm9_overrides/snapshots/migration_upgrade_pnpm9_overrides.md index 79bec01712..07e8328df8 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_pnpm9_overrides/snapshots/migration_upgrade_pnpm9_overrides.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_pnpm9_overrides/snapshots/migration_upgrade_pnpm9_overrides.md @@ -38,12 +38,10 @@ pnpm.overrides stay catalog: (not inlined to a version) }, "peerDependencyRules": { "allowAny": [ - "vite", - "vitest" + "vite" ], "allowedVersions": { - "vite": "*", - "vitest": "*" + "vite": "*" } } } diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_setup_full_pnpm/snapshots/migration_upgrade_setup_full_pnpm.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_setup_full_pnpm/snapshots/migration_upgrade_setup_full_pnpm.md index 145033fe63..ef822ae45f 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_setup_full_pnpm/snapshots/migration_upgrade_setup_full_pnpm.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_setup_full_pnpm/snapshots/migration_upgrade_setup_full_pnpm.md @@ -23,6 +23,7 @@ VITE+ - The Unified Toolchain for the Web • Node version manager file migrated to .node-version • Package manager settings configured • Removed `vite` from pnpm peerDependencyRules: the core version now matches the bundled Vite +• Removed `vitest` from pnpm peerDependencyRules: the managed `vitest` is pinned to the real bundled Vitest version → Manual follow-up: - Remove the "volta" field from package.json ``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_setup_skipped_default_pnpm/snapshots/migration_upgrade_setup_skipped_default_pnpm.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_setup_skipped_default_pnpm/snapshots/migration_upgrade_setup_skipped_default_pnpm.md index 69513ff898..785c9184be 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_setup_skipped_default_pnpm/snapshots/migration_upgrade_setup_skipped_default_pnpm.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_setup_skipped_default_pnpm/snapshots/migration_upgrade_setup_skipped_default_pnpm.md @@ -14,6 +14,7 @@ VITE+ - The Unified Toolchain for the Web vite → • Package manager settings configured • Removed `vite` from pnpm peerDependencyRules: the core version now matches the bundled Vite +• Removed `vitest` from pnpm peerDependencyRules: the managed `vitest` is pinned to the real bundled Vitest version • Skipped editor, hooks, and lint setup. Run `vp migrate --full` to apply them. ``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_stale_local_pnpm/snapshots/migration_upgrade_stale_local_pnpm.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_stale_local_pnpm/snapshots/migration_upgrade_stale_local_pnpm.md index 9e2e00f978..3897c45699 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_stale_local_pnpm/snapshots/migration_upgrade_stale_local_pnpm.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_upgrade_stale_local_pnpm/snapshots/migration_upgrade_stale_local_pnpm.md @@ -17,6 +17,7 @@ VITE+ - The Unified Toolchain for the Web vite → • Package manager settings configured • Removed `vite` from pnpm peerDependencyRules: the core version now matches the bundled Vite +• Removed `vitest` from pnpm peerDependencyRules: the managed `vitest` is pinned to the real bundled Vitest version ``` ## `vpt print-file package.json` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_vitest_peer_dep/snapshots/migration_vitest_peer_dep.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_vitest_peer_dep/snapshots/migration_vitest_peer_dep.md index 56e0db8748..9ab585435b 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_vitest_peer_dep/snapshots/migration_vitest_peer_dep.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_vitest_peer_dep/snapshots/migration_vitest_peer_dep.md @@ -49,9 +49,4 @@ catalog: overrides: vite@*: 'catalog:' vitest@*: 'catalog:' -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_workspace_vite_template/snapshots/migration_workspace_vite_template.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_workspace_vite_template/snapshots/migration_workspace_vite_template.md index 28587cbef0..dd03933be3 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_workspace_vite_template/snapshots/migration_workspace_vite_template.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/migration_workspace_vite_template/snapshots/migration_workspace_vite_template.md @@ -96,11 +96,6 @@ catalog: overrides: vite@*: 'catalog:' vitest@*: 'catalog:' -peerDependencyRules: - allowAny: - - vitest - allowedVersions: - vitest: '*' ``` ## `vpt print-file packages/app/package.json` diff --git a/docs/guide/migrate-rules.md b/docs/guide/migrate-rules.md index 94a87b558c..b73ac45301 100644 --- a/docs/guide/migrate-rules.md +++ b/docs/guide/migrate-rules.md @@ -394,7 +394,13 @@ Migration converts the Volta `volta.node` pin to `.node-version`, because Vite+ - pnpm 12.17.0 and later: add the override `'vite-plugin-foo>vite:peer': '*'`. pnpm deprecated `peerDependencyRules` in this version. - Earlier pnpm versions: add the rule `allowedVersions: { 'vite-plugin-foo>vite': '*' }`. - Migration removes only the plain `vite` key, so both forms stay. + Migration removes only the plain `vite` and `vitest` keys, so both forms stay. + +**Vitest peer rule.** The managed `vitest` is pinned to the real bundled Vitest version (not an alias), so pnpm checks `vitest` peer ranges against a genuine version. + +- Migration does not add `vitest` to `peerDependencyRules.allowAny` or `peerDependencyRules.allowedVersions`, also when the workspace uses Vitest directly. The rule was needed only while `vitest` aliased to the deleted `@voidzero-dev/vite-plus-test` wrapper; with the real version it only hides real incompatibilities. +- Migration removes `vitest` from `allowAny` and removes `allowedVersions.vitest` when its value is `'*'`, also when you wrote the entry. Another `allowedVersions.vitest` range, such as `'4 || 5'`, stays. The migrate summary names the removed rule. +- After migration, a package whose `vitest` peer range excludes the bundled Vitest produces a peer warning. Update the package, or widen its `vitest` peer range only, with the same per-package forms as for `vite` above. **Other rules.** diff --git a/packages/cli/src/migration/__tests__/vite-peer-dependency-rule.spec.ts b/packages/cli/src/migration/__tests__/vite-peer-dependency-rule.spec.ts index d23b0f822e..f4178fdfb5 100644 --- a/packages/cli/src/migration/__tests__/vite-peer-dependency-rule.spec.ts +++ b/packages/cli/src/migration/__tests__/vite-peer-dependency-rule.spec.ts @@ -7,7 +7,7 @@ import { parse as parseYaml } from 'yaml'; import type { WorkspaceInfo } from '../../types/index.ts'; import { PackageManager } from '../../types/index.ts'; -import { VITE_PLUS_OVERRIDE_PACKAGES } from '../../utils/constants.ts'; +import { VITE_PLUS_OVERRIDE_PACKAGES, VITEST_VERSION } from '../../utils/constants.ts'; import { readJsonFile as readJson } from '../../utils/json.ts'; import type { PnpmPeerDependencyRules as PeerDependencyRules } from '../migrator/shared.ts'; import { createMigrationReport } from '../report.ts'; @@ -28,6 +28,7 @@ const { ensureVitePlusBootstrap, rewriteStandaloneProject, vitePeerDependencyRuleRequired, + vitestPeerDependencyRuleRequired, } = await import('../migrator.ts'); const STABLE_CORE = 'npm:@voidzero-dev/vite-plus-core@8.3.5000'; @@ -127,6 +128,153 @@ describe('vitePeerDependencyRuleRequired with a pnpm version', () => { }); }); +describe('vitestPeerDependencyRuleRequired', () => { + // The managed `vitest` spec is the real bundled Vitest version, so `vitest` + // peer ranges are checked against a genuine version and the rule would only + // hide real incompatibilities. Every other spec — the deleted + // `@voidzero-dev/vite-plus-test` wrapper alias, a dist-tag, a `file:` spec, + // or a prerelease/build that fails ranges such as `^5.0.0` — still needs it. + it.each([ + [VITEST_VERSION, false], + ['5.2.0', false], + ['5.2.0-beta.1', true], + ['5.1.1+build.1', true], + ['npm:@voidzero-dev/vite-plus-test@latest', true], + ['latest', true], + ['file:../vite-plus-test.tgz', true], + [undefined, true], + ])('%s requires the rule: %s', (spec, required) => { + expect(vitestPeerDependencyRuleRequired(spec)).toBe(required); + }); +}); + +function writeVitePlusVitestProject(projectPath: string, peerDependencyRules: Array) { + fs.writeFileSync( + path.join(projectPath, 'package.json'), + JSON.stringify({ + name: 'test', + devDependencies: { + 'vite-plus': 'catalog:', + '@vitest/coverage-v8': 'catalog:', + vitest: 'catalog:', + }, + devEngines: { + packageManager: { name: 'pnpm', version: '10.33.0', onFail: 'download' }, + }, + }), + ); + fs.writeFileSync( + path.join(projectPath, 'pnpm-workspace.yaml'), + [ + 'catalog:', + ` vite: ${VITE_PLUS_OVERRIDE_PACKAGES.vite}`, + ` vitest: ${VITE_PLUS_OVERRIDE_PACKAGES.vitest}`, + ' vite-plus: latest', + ` '@vitest/coverage-v8': ${VITEST_VERSION}`, + 'overrides:', + " vite@*: 'catalog:'", + " vitest@*: 'catalog:'", + ...peerDependencyRules, + '', + ].join('\n'), + ); +} + +describe('pnpm vitest peer rule', () => { + let tmpDir: string; + const savedViteOverride = VITE_PLUS_OVERRIDE_PACKAGES.vite; + const savedVitestOverride = VITE_PLUS_OVERRIDE_PACKAGES.vitest; + + beforeEach(() => { + tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'vp-vitest-peer-rule-')); + }); + + afterEach(() => { + VITE_PLUS_OVERRIDE_PACKAGES.vite = savedViteOverride; + VITE_PLUS_OVERRIDE_PACKAGES.vitest = savedVitestOverride; + fs.rmSync(tmpDir, { recursive: true, force: true }); + }); + + describe('with a stable core version', () => { + beforeEach(() => { + VITE_PLUS_OVERRIDE_PACKAGES.vite = STABLE_CORE; + }); + + it('removes the vitest rule from a Vitest-using workspace and reports it', () => { + writeVitePlusVitestProject(tmpDir, [ + 'peerDependencyRules:', + ' allowAny:', + ' - vitest', + ' allowedVersions:', + " vitest: '*'", + ]); + const report = createMigrationReport(); + + expect(detectVitePlusBootstrapPending(tmpDir, PackageManager.pnpm)).toBe(true); + ensureVitePlusBootstrap(makeWorkspaceInfo(tmpDir), report); + + expect(readWorkspaceRules(tmpDir)).toBeUndefined(); + expect(report.vitestPeerDependencyRuleRemoved).toBe(true); + expect(detectVitePlusBootstrapPending(tmpDir, PackageManager.pnpm)).toBe(false); + expect(ensureVitePlusBootstrap(makeWorkspaceInfo(tmpDir)).changed).toBe(false); + }); + + it('does not write a vitest rule for a Vitest-using workspace without one', () => { + writeVitePlusVitestProject(tmpDir, []); + const report = createMigrationReport(); + + expect(detectVitePlusBootstrapPending(tmpDir, PackageManager.pnpm)).toBe(false); + ensureVitePlusBootstrap(makeWorkspaceInfo(tmpDir), report); + + expect(readWorkspaceRules(tmpDir)).toBeUndefined(); + expect(report.vitestPeerDependencyRuleRemoved).toBe(false); + expect(detectVitePlusBootstrapPending(tmpDir, PackageManager.pnpm)).toBe(false); + expect(ensureVitePlusBootstrap(makeWorkspaceInfo(tmpDir)).changed).toBe(false); + }); + + it('keeps a user vitest range while removing the managed entries', () => { + writeVitePlusVitestProject(tmpDir, [ + 'peerDependencyRules:', + ' allowAny:', + ' - vitest', + ' allowedVersions:', + " vitest: '4 || 5'", + ]); + const report = createMigrationReport(); + + ensureVitePlusBootstrap(makeWorkspaceInfo(tmpDir), report); + + expect(readWorkspaceRules(tmpDir)).toEqual({ allowedVersions: { vitest: '4 || 5' } }); + expect(report.vitestPeerDependencyRuleRemoved).toBe(true); + expect(detectVitePlusBootstrapPending(tmpDir, PackageManager.pnpm)).toBe(false); + }); + }); + + describe('with a non-stable managed vitest spec', () => { + beforeEach(() => { + VITE_PLUS_OVERRIDE_PACKAGES.vite = STABLE_CORE; + // A prerelease pin fails ranges such as `^5.0.0`, so the rule is still + // required — the vitest counterpart of the preview-core vite behavior. + VITE_PLUS_OVERRIDE_PACKAGES.vitest = '5.2.0-beta.1'; + }); + + it('keeps writing the vitest rule', () => { + writeVitePlusVitestProject(tmpDir, []); + const report = createMigrationReport(); + + expect(detectVitePlusBootstrapPending(tmpDir, PackageManager.pnpm)).toBe(true); + ensureVitePlusBootstrap(makeWorkspaceInfo(tmpDir), report); + + expect(readWorkspaceRules(tmpDir)).toEqual({ + allowAny: ['vitest'], + allowedVersions: { vitest: '*' }, + }); + expect(report.vitestPeerDependencyRuleRemoved).toBe(false); + expect(detectVitePlusBootstrapPending(tmpDir, PackageManager.pnpm)).toBe(false); + }); + }); +}); + describe('pnpm vite peer rule', () => { let tmpDir: string; const savedViteOverride = VITE_PLUS_OVERRIDE_PACKAGES.vite; diff --git a/packages/cli/src/migration/bin.ts b/packages/cli/src/migration/bin.ts index ff7c6b4cbf..2c8c67c22a 100644 --- a/packages/cli/src/migration/bin.ts +++ b/packages/cli/src/migration/bin.ts @@ -667,6 +667,11 @@ function showMigrationSummary(options: { `${styleText('gray', '•')} Removed \`vite\` from pnpm peerDependencyRules: the core version now matches the bundled Vite`, ); } + if (report.vitestPeerDependencyRuleRemoved) { + log( + `${styleText('gray', '•')} Removed \`vitest\` from pnpm peerDependencyRules: the managed \`vitest\` is pinned to the real bundled Vitest version`, + ); + } if (suggestFullMigration) { log(FULL_MIGRATION_HINT); } diff --git a/packages/cli/src/migration/migrator/catalog.ts b/packages/cli/src/migration/migrator/catalog.ts index a50edc4c3f..3f3fe15926 100644 --- a/packages/cli/src/migration/migrator/catalog.ts +++ b/packages/cli/src/migration/migrator/catalog.ts @@ -1471,39 +1471,55 @@ export function readPnpmWorkspacePeerDependencyRules( } // Whether the root pnpm config (the package.json `pnpm` field or -// pnpm-workspace.yaml) holds a `vite` peer rule. -function hasVitePeerDependencyRule(projectPath: string): boolean { - if ( - peerDependencyRulesHaveStaleEntry(readPnpmWorkspacePeerDependencyRules(projectPath), ['vite']) - ) { +// pnpm-workspace.yaml) holds a managed `vite`/`vitest` peer rule. +function hasManagedPeerDependencyRule(projectPath: string, key: string): boolean { + if (peerDependencyRulesHaveStaleEntry(readPnpmWorkspacePeerDependencyRules(projectPath), [key])) { return true; } const pkg = readPackageJsonIfExists(path.join(projectPath, 'package.json')); const pnpm = pkg && 'pnpm' in pkg && isJsonObject(pkg.pnpm) ? pkg.pnpm : undefined; const rules = pnpm?.peerDependencyRules; - return peerDependencyRulesHaveStaleEntry(isObjectValue(rules) ? rules : undefined, ['vite']); + return peerDependencyRulesHaveStaleEntry(isObjectValue(rules) ? rules : undefined, [key]); } -// Capture the `vite` peer rule before a migration step. Call the returned -// function after the step: it records the rule's removal in the report, so the -// migrate summary names it (see `vitePeerDependencyRuleRequired`). -export function trackVitePeerDependencyRuleRemoval( +// Capture the managed peer rules before a migration step. Call the returned +// function after the step: it records each rule's removal in the report, so +// the migrate summary names it (see `vitePeerDependencyRuleRequired` and +// `vitestPeerDependencyRuleRequired`). +export function trackPeerDependencyRuleRemoval( projectPath: string, packageManager: PackageManager, report: MigrationReport | undefined, pnpmVersion: string | undefined, ): () => void { - if ( - !report || - packageManager !== PackageManager.pnpm || - vitePeerDependencyRuleRequired(VITE_PLUS_OVERRIDE_PACKAGES.vite, pnpmVersion) || - !hasVitePeerDependencyRule(projectPath) - ) { + if (!report || packageManager !== PackageManager.pnpm) { + return () => {}; + } + // A rule is only tracked when this migration may remove it: the `vite` rule + // once the core alias satisfies `vite` peer ranges on this pnpm version, and + // the `vitest` rule whenever `vitest` is a managed override (its removal is + // keyed on the real bundled spec, see `pnpmPeerDependencyRuleKeys`). + const candidates = new Set(); + if (!vitePeerDependencyRuleRequired(VITE_PLUS_OVERRIDE_PACKAGES.vite, pnpmVersion)) { + candidates.add('vite'); + } + if (VITEST_IS_MANAGED_OVERRIDE) { + candidates.add('vitest'); + } + const tracked = [...candidates].filter((key) => hasManagedPeerDependencyRule(projectPath, key)); + if (tracked.length === 0) { return () => {}; } return () => { - if (!hasVitePeerDependencyRule(projectPath)) { - report.vitePeerDependencyRuleRemoved = true; + for (const key of tracked) { + if (hasManagedPeerDependencyRule(projectPath, key)) { + continue; + } + if (key === 'vite') { + report.vitePeerDependencyRuleRemoved = true; + } else { + report.vitestPeerDependencyRuleRemoved = true; + } } }; } diff --git a/packages/cli/src/migration/migrator/orchestrators.ts b/packages/cli/src/migration/migrator/orchestrators.ts index 093bff699d..f7eec018ea 100644 --- a/packages/cli/src/migration/migrator/orchestrators.ts +++ b/packages/cli/src/migration/migrator/orchestrators.ts @@ -60,7 +60,7 @@ import { setDirectViteEdge, sourceTreeReferencesRetainedVitestModule, takePnpmWorkspaceSettings, - trackVitePeerDependencyRuleRemoval, + trackPeerDependencyRuleRemoval, usesVitestBrowserMode, usesWebdriverioProvider, workspaceUsesVitestDirectly, @@ -92,7 +92,7 @@ export function rewriteStandaloneProject( } const packageManager = workspaceInfo.packageManager; - const reportVitePeerDependencyRuleRemoval = trackVitePeerDependencyRuleRemoval( + const reportPeerDependencyRuleRemoval = trackPeerDependencyRuleRemoval( projectPath, packageManager, report, @@ -370,7 +370,7 @@ export function rewriteStandaloneProject( dropDeadOxlintPluginsDependency(projectPath, workspaceInfo.packages, originalOxlintDependencies); wrapLazyPluginsInViteConfig(projectPath, silent, report); migrateTaskCacheConfigInViteConfig(projectPath, silent, report); - reportVitePeerDependencyRuleRemoval(); + reportPeerDependencyRuleRemoval(); } /** @@ -384,7 +384,7 @@ export function rewriteMonorepo( report?: MigrationReport, importRuleConfig?: string, ): void { - const reportVitePeerDependencyRuleRemoval = trackVitePeerDependencyRuleRemoval( + const reportPeerDependencyRuleRemoval = trackPeerDependencyRuleRemoval( workspaceInfo.rootDir, workspaceInfo.packageManager, report, @@ -559,7 +559,7 @@ export function rewriteMonorepo( wrapLazyPluginsInViteConfig(projectPath, silent, report); migrateTaskCacheConfigInViteConfig(projectPath, silent, report); } - reportVitePeerDependencyRuleRemoval(); + reportPeerDependencyRuleRemoval(); } /** diff --git a/packages/cli/src/migration/migrator/shared.ts b/packages/cli/src/migration/migrator/shared.ts index f136365131..4e7a4f2b2c 100644 --- a/packages/cli/src/migration/migrator/shared.ts +++ b/packages/cli/src/migration/migrator/shared.ts @@ -283,6 +283,29 @@ export function vitePeerDependencyRuleRequired( ); } +/** + * Whether pnpm still needs the managed `vitest` peer rule + * (`allowAny: [vitest]`, `allowedVersions: { vitest: '*' }`) for the given + * managed vitest spec. + * + * The wrapper era resolved `vitest` to `npm:@voidzero-dev/vite-plus-test@…`, + * whose version was not a real Vitest version, so `vitest` peer ranges were + * checked against it and failed — the rule was needed to silence that noise + * (see PR #1222). Since the wrapper was deleted (PR #1588) the managed spec is + * the real bundled Vitest version (`VITEST_VERSION`), so package managers check + * `vitest` peer ranges against a genuine version and the rule would only hide + * real incompatibilities — the same reasoning that drops the `vite` rule for an + * aligned core (see `vitePeerDependencyRuleRequired` and the "Out of scope" + * note in rfcs/core-version-alignment.md). Every other spec still needs the + * rule: a wrapper alias, a dist-tag (`latest`), a `file:` or URL spec whose + * version is unknown, or a prerelease/build version that fails ranges such as + * `^5.0.0`. + */ +export function vitestPeerDependencyRuleRequired(vitestSpec: string | undefined): boolean { + const version = vitestSpec ? tryParse(vitestSpec) : null; + return !version || (version.prerelease?.length ?? 0) > 0 || (version.build?.length ?? 0) > 0; +} + // Fallback specs used when normalizing a stale wrapper alias. Real user // ranges (e.g. `vitest: ^3.0.0`) are preserved — only the wrapper alias is // rewritten. For `vitest`, we substitute the vitest version vite-plus diff --git a/packages/cli/src/migration/migrator/vite-plus-bootstrap.ts b/packages/cli/src/migration/migrator/vite-plus-bootstrap.ts index bcb0737a07..a3c62e83c9 100644 --- a/packages/cli/src/migration/migrator/vite-plus-bootstrap.ts +++ b/packages/cli/src/migration/migrator/vite-plus-bootstrap.ts @@ -56,7 +56,7 @@ import { setDirectViteEdge, pnpmPeerDependencyRuleKeys, takePnpmWorkspaceSettings, - trackVitePeerDependencyRuleRemoval, + trackPeerDependencyRuleRemoval, vitestEcosystemCatalogReferencesPending, workspaceUsesVitestDirectly, workspaceUsesWebdriverio, @@ -981,7 +981,7 @@ export function ensureVitePlusBootstrap( if (!fs.existsSync(packageJsonPath)) { return result; } - const reportVitePeerDependencyRuleRemoval = trackVitePeerDependencyRuleRemoval( + const reportPeerDependencyRuleRemoval = trackPeerDependencyRuleRemoval( projectPath, workspaceInfo.packageManager, report, @@ -1293,7 +1293,7 @@ export function ensureVitePlusBootstrap( if (result.changed && report) { report.packageManagerBootstrapConfigured = true; } - reportVitePeerDependencyRuleRemoval(); + reportPeerDependencyRuleRemoval(); return result; } diff --git a/packages/cli/src/migration/migrator/vitest-ecosystem.ts b/packages/cli/src/migration/migrator/vitest-ecosystem.ts index a5b05b3d67..fbbaea9019 100644 --- a/packages/cli/src/migration/migrator/vitest-ecosystem.ts +++ b/packages/cli/src/migration/migrator/vitest-ecosystem.ts @@ -40,6 +40,7 @@ import { isPlainRecord, pnpmOverrideKey, vitePeerDependencyRuleRequired, + vitestPeerDependencyRuleRequired, } from './shared.ts'; // Official packages that do not declare a required `vitest` peer. Keep them @@ -597,8 +598,12 @@ export interface PnpmPeerDependencyRuleKeys { // The pnpm peerDependencyRules keys vite-plus manages and removes. The managed // keys are the managed override keys, minus `vite` once its core alias // satisfies `vite` peer ranges on this pnpm version (see -// `vitePeerDependencyRuleRequired`). The stale keys are: -// - `vitest`, a lingering managed rule, when the workspace does not use Vitest. +// `vitePeerDependencyRuleRequired`), and minus `vitest` once its managed spec +// is the real bundled Vitest version (see `vitestPeerDependencyRuleRequired`). +// The stale keys are: +// - `vitest`, a lingering managed rule, when the rule is not required — also +// when the workspace uses Vitest, since the rule then only hides real +// incompatibilities. // - `vite`, when the rule is not required. Then it only hides real // incompatibilities. Migration cannot tell whether an earlier migration or the // user wrote the entry; its only purpose was to accept the `1.x` alias, so @@ -611,11 +616,13 @@ export function pnpmPeerDependencyRuleKeys( VITE_PLUS_OVERRIDE_PACKAGES.vite, pnpmVersion, ); + const vitestRuleRequired = + usesVitest && vitestPeerDependencyRuleRequired(VITE_PLUS_OVERRIDE_PACKAGES.vitest); const managed = Object.keys(managedOverridePackages(usesVitest)).filter( - (key) => viteRuleRequired || key !== 'vite', + (key) => (viteRuleRequired || key !== 'vite') && (vitestRuleRequired || key !== 'vitest'), ); const stale: Array = []; - if (!usesVitest && VITEST_IS_MANAGED_OVERRIDE) { + if (VITEST_IS_MANAGED_OVERRIDE && !vitestRuleRequired) { stale.push('vitest'); } if (!viteRuleRequired) { @@ -625,9 +632,10 @@ export function pnpmPeerDependencyRuleKeys( } // Whether migration wrote this `allowedVersions` value. It only ever wrote `'*'` -// for `vite`, so another `vite` range is the user's own constraint and stays. +// for `vite` and `vitest`, so another range is the user's own constraint and +// stays. export function isManagedAllowedVersion(key: string, value: unknown): boolean { - return key !== 'vite' || value === '*'; + return (key !== 'vite' && key !== 'vitest') || value === '*'; } // Whether pnpm peerDependencyRules hold a stale `allowAny` or `allowedVersions` diff --git a/packages/cli/src/migration/report.ts b/packages/cli/src/migration/report.ts index 44813bd7c5..b67a72b6c7 100644 --- a/packages/cli/src/migration/report.ts +++ b/packages/cli/src/migration/report.ts @@ -34,6 +34,7 @@ export interface MigrationReport { frameworkShimAdded: boolean; packageManagerBootstrapConfigured: boolean; vitePeerDependencyRuleRemoved: boolean; + vitestPeerDependencyRuleRemoved: boolean; dependencyUpgrades: Array; warnings: Array; manualSteps: Array; @@ -64,6 +65,7 @@ export function createMigrationReport(): MigrationReport { frameworkShimAdded: false, packageManagerBootstrapConfigured: false, vitePeerDependencyRuleRemoved: false, + vitestPeerDependencyRuleRemoved: false, dependencyUpgrades: [], warnings: [], manualSteps: [],