vite-plus 0.2.8 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/AGENTS.md +7 -0
  2. package/README.md +13 -6
  3. package/binding/index.cjs +57 -54
  4. package/binding/index.d.cts +100 -3
  5. package/dist/{agent-CI79DuSy.js → agent-Wqx0MPk0.js} +4 -188
  6. package/dist/bin.js +298 -278
  7. package/dist/command-CLJK5jGW.js +2 -0
  8. package/dist/command-CguLh2KL.js +471 -0
  9. package/dist/config/bin.js +29 -15
  10. package/dist/{constants-BppDcRc1.js → constants-Bn-U8o4v.js} +13 -3
  11. package/dist/create/bin.js +197 -247
  12. package/dist/{define-config-DPnHe1Mx.js → define-config-GXUdVT-0.js} +3 -3
  13. package/dist/{define-config-CEm_MtvJ.cjs → define-config-WiVlryJ2.cjs} +2 -2
  14. package/dist/define-config.cjs +1 -1
  15. package/dist/define-config.js +1 -1
  16. package/dist/{dist-CSQWHI6y.js → dist-BDYZP12R.js} +193 -149
  17. package/dist/dist-Dqv1-Clg.js +3 -0
  18. package/dist/{editor-CGWdbLgD.js → editor-CC4DqODz.js} +736 -153
  19. package/dist/{terminal-CrqqK8WT.js → help-BmKpeOP9.js} +27 -34
  20. package/dist/hooks/bin.d.ts +1 -0
  21. package/dist/hooks/bin.js +131 -0
  22. package/dist/hooks-DFqViZqZ.js +573 -0
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/{json-BU88uu6o.js → json-cULBl7Pi.js} +145 -139
  26. package/dist/migration/bin.js +67 -21
  27. package/dist/migration/compat/worker.js +1 -1
  28. package/dist/{oxlint-plugin-config-BHOzlwMw.js → oxlint-plugin-config-DX5ezKbB.js} +1 -1
  29. package/dist/oxlint-plugin.js +1 -1
  30. package/dist/pack-bin.js +5 -4
  31. package/dist/{package-hV-77cBb.js → package-CBe9EWPY.js} +2 -2
  32. package/dist/{prompts-DYap08te.js → prompts-DF3yU-eU.js} +136 -512
  33. package/dist/{report-BS7ULx7A.js → report-ZNR1Mk6h.js} +1 -0
  34. package/dist/{resolve-vite-config-EWXclqvV.js → resolve-vite-config-ipGb39Jo.js} +2 -9
  35. package/dist/staged/bin.js +299 -251
  36. package/dist/terminal-MKGAuy-p.js +39 -0
  37. package/dist/test/browser/providers/playwright/context.d.ts +1 -1
  38. package/dist/test/browser/providers/playwright.d.ts +6 -6
  39. package/dist/test/browser/providers/preview/context.d.ts +1 -1
  40. package/dist/test/browser/providers/preview.d.ts +4 -4
  41. package/dist/test/browser/providers/webdriverio/context.d.ts +1 -1
  42. package/dist/test/browser/providers/webdriverio.d.ts +6 -6
  43. package/dist/test/browser-playwright/context.d.ts +1 -1
  44. package/dist/test/browser-playwright.d.ts +6 -6
  45. package/dist/test/browser-preview/context.d.ts +1 -1
  46. package/dist/test/browser-preview.d.ts +4 -4
  47. package/dist/test/browser-webdriverio/context.d.ts +1 -1
  48. package/dist/test/browser-webdriverio.d.ts +6 -6
  49. package/dist/test/context.d.ts +3 -3
  50. package/dist/test/locators.d.ts +1 -1
  51. package/dist/toolchain.d.ts +25 -0
  52. package/dist/toolchain.js +194 -0
  53. package/dist/toolchain.json +193 -0
  54. package/dist/tsconfig-BVHG3DpR.js +2 -0
  55. package/dist/{tsconfig-CVUKLfL8.js → tsconfig-LD2QhQ0O.js} +5 -4
  56. package/dist/tsgolint-path.js +1 -1
  57. package/dist/version.js +5 -4
  58. package/dist/versions.d.ts +3 -3
  59. package/dist/versions.js +6 -6
  60. package/docs/guide/ci.md +37 -4
  61. package/docs/guide/commit-hooks.md +87 -14
  62. package/docs/guide/create.md +7 -4
  63. package/docs/guide/env.md +20 -6
  64. package/docs/guide/fmt.md +2 -2
  65. package/docs/guide/github-actions-cache.md +5 -1
  66. package/docs/guide/ide-integration.md +61 -2
  67. package/docs/guide/index.md +3 -1
  68. package/docs/guide/install.md +27 -1
  69. package/docs/guide/installer-env-vars.md +53 -6
  70. package/docs/guide/lint.md +3 -1
  71. package/docs/guide/migrate-rules.md +9 -0
  72. package/docs/guide/migrate.md +41 -4
  73. package/docs/guide/monorepo.md +4 -4
  74. package/docs/guide/test.md +8 -0
  75. package/docs/guide/troubleshooting.md +12 -4
  76. package/docs/guide/upgrade.md +75 -5
  77. package/package.json +36 -33
  78. package/rules/vite-tools.yml +0 -7
  79. package/dist/dist-DT25H9pj.js +0 -3
  80. package/docs/_data/team.ts +0 -131
  81. package/docs/package.json +0 -30
  82. package/docs/pnpm-lock.yaml +0 -4003
  83. package/docs/pnpm-workspace.yaml +0 -6
  84. package/docs/public/checkmark.svg +0 -1
  85. package/docs/public/cta-background.jpg +0 -0
  86. package/docs/public/favicon.svg +0 -1
  87. package/docs/public/icon.svg +0 -1
  88. package/docs/public/logo.svg +0 -1
  89. package/docs/public/og.jpg +0 -0
  90. package/docs/vite.config.ts +0 -17
  91. package/dist/{log-update-CoW8Z4Dl.js → log-update-DHZRyJ2m.js} +1 -1
  92. package/dist/{tsgolint-path-eMZT-oea.js → tsgolint-path-CbDReEOx.js} +1 -1
@@ -1,22 +1,24 @@
1
1
  import { r as __toESM } from "./rolldown-runtime-CMFfr-1z.js";
2
- import { a as VITEST_AGE_GATE_EXEMPT_PACKAGES, c as VITE_PLUS_OVERRIDE_PACKAGES, d as isForceOverrideMode, l as VITE_PLUS_VERSION, n as BASEURL_TSCONFIG_WARNING, o as VITEST_VERSION, s as VITE_PLUS_NAME } from "./constants-BppDcRc1.js";
3
- import { i as ensureVitePlusImportRuleDefaults, r as createDefaultVitePlusLintConfig } from "./oxlint-plugin-config-BHOzlwMw.js";
4
- import { A as isCancel, C as log, E as select, M as runCommandSilently, N as require_cross_spawn, d as readYamlFile, f as scalarString, g as getSpinner, t as cancelAndExit, u as editYamlFile, v as PackageManager, w as multiselect, x as confirm, y as require_semver } from "./prompts-DYap08te.js";
5
- import { a as writeJsonFile, c as parse, i as readJsonFile, n as editJsonFile, o as applyEdits, r as isJsonFile, s as modify, t as detectFormattingOptions } from "./json-BU88uu6o.js";
6
- import { t as require_dist } from "./dist-CSQWHI6y.js";
7
- import { a as hasTypesToRewriteInTsconfig, c as rewriteTypesInTsconfig, i as hasBaseUrlInTsconfig, n as findTsconfigFiles, o as hasVitestTypesInTsconfig, s as removeDeprecatedTsconfigFalseOption } from "./tsconfig-CVUKLfL8.js";
8
- import { n as detectPackageMetadata, r as getScopeFromPackageName } from "./package-hV-77cBb.js";
9
- import { f as displayRelative, l as SUPPORTED_GIT_HOOK_NAMES, p as rulesDir, u as findUnsafeHookInstallPath } from "./agent-CI79DuSy.js";
10
- import { n as addMigrationWarning, t as addManualStep } from "./report-BS7ULx7A.js";
2
+ import { a as TSDOWN_MIGRATE_VERSION, c as VITEST_VERSION, d as VITE_PLUS_OVERRIDE_PACKAGES, f as VITE_PLUS_VERSION, l as VITE_CONFIG_FILES, m as isForceOverrideMode, n as BASEURL_TSCONFIG_WARNING, o as TSDOWN_MIGRATION_SKILL_URL, s as VITEST_AGE_GATE_EXEMPT_PACKAGES, u as VITE_PLUS_NAME } from "./constants-Bn-U8o4v.js";
3
+ import { i as ensureVitePlusImportRuleDefaults, r as createDefaultVitePlusLintConfig } from "./oxlint-plugin-config-DX5ezKbB.js";
4
+ import { A as isCancel, C as log, E as select, _ as getSpinner, b as require_semver, d as readYamlFile, f as scalarString, g as getSilentSpinner, t as cancelAndExit, u as editYamlFile, w as multiselect, x as confirm, y as PackageManager } from "./prompts-DF3yU-eU.js";
5
+ import { a as writeJsonFile, c as parse, i as readJsonFile, n as editJsonFile, o as applyEdits, r as isJsonFile, s as modify, t as detectFormattingOptions } from "./json-cULBl7Pi.js";
6
+ import { n as detectPackageMetadata, r as getScopeFromPackageName } from "./package-CBe9EWPY.js";
7
+ import { l as displayRelative, u as rulesDir } from "./agent-Wqx0MPk0.js";
8
+ import { n as addMigrationWarning, t as addManualStep } from "./report-ZNR1Mk6h.js";
9
+ import { n as runCommandSilently, r as require_cross_spawn } from "./command-CguLh2KL.js";
10
+ import { t as require_dist } from "./dist-BDYZP12R.js";
11
+ import { a as hasBaseUrlInTsconfig, c as hasVitestTypesInTsconfig, l as removeDeprecatedTsconfigFalseOption, n as findTsconfigFiles, s as hasTypesToRewriteInTsconfig, u as rewriteTypesInTsconfig } from "./tsconfig-LD2QhQ0O.js";
12
+ import { a as findUnsafeHookInstallPath, n as SUPPORTED_GIT_HOOK_NAMES } from "./hooks-DFqViZqZ.js";
11
13
  import path, { posix, win32 } from "node:path";
12
- import { detectWorkspace, hasConfigKey, mergeJsonConfig, mergeTsdownConfig, rewriteEslint, rewriteImportsInDirectory, rewritePrettier, rewriteScripts, wrapLazyPlugins } from "../binding/index.js";
14
+ import { fileURLToPath } from "node:url";
15
+ import { detectWorkspace, getVpDirs, hasConfigKey, mergeJsonConfig, mergeTsdownConfig, rewriteEslint, rewriteImportsInDirectory, rewritePrettier, rewriteScripts, wrapLazyPlugins } from "../binding/index.js";
13
16
  import { styleText } from "node:util";
14
17
  import * as actualFS from "node:fs";
15
18
  import fs from "node:fs";
16
19
  import os from "node:os";
17
- import { lstatSync as lstatSync$1, readdir, readdirSync, readlinkSync, realpathSync as realpathSync$1 } from "fs";
18
- import { fileURLToPath } from "node:url";
19
20
  import "oxlint";
21
+ import { lstatSync as lstatSync$1, readdir, readdirSync as readdirSync$1, readlinkSync, realpathSync as realpathSync$1 } from "fs";
20
22
  import fsPromises, { lstat, readdir as readdir$1, readlink, realpath } from "node:fs/promises";
21
23
  import { EventEmitter } from "node:events";
22
24
  import Stream from "node:stream";
@@ -81,6 +83,48 @@ const VITEST_BROWSER_DEP_NAMES = [
81
83
  ];
82
84
  const VITEST_IS_MANAGED_OVERRIDE = "vitest" in VITE_PLUS_OVERRIDE_PACKAGES;
83
85
  const LEGACY_WRAPPER_FALLBACK_VERSIONS = { vitest: VITEST_VERSION };
86
+ /**
87
+ * Managed pnpm override keys use an explicit `@*` range, not a bare package
88
+ * name: `vite@*`, not `vite`.
89
+ *
90
+ * pnpm applies overrides through a read-package hook. The hook replaces the
91
+ * declared spec on every manifest, importer manifests included, before
92
+ * resolution runs. A bare override key has no range, and pnpm treats a key with
93
+ * no range as a match for every declared spec. That includes `catalog:`. An
94
+ * importer that declares `vite: "catalog:"` therefore loses its link to the
95
+ * catalog during resolution, and `pnpm update` then writes the resolved core
96
+ * alias into that importer's package.json (issue #2309).
97
+ *
98
+ * The `@*` range keeps the override on the declared semver ranges that
99
+ * transitive and peer `vite` declarations use. Those declarations are the
100
+ * reason this override exists. The range leaves `catalog:` specs alone, because
101
+ * `catalog:` is not a valid semver range, so pnpm's `isIntersectingRange`
102
+ * rejects it before it compares anything. The installed result does not change:
103
+ * an importer that references the catalog already resolves to the aliased core
104
+ * through its catalog entry.
105
+ *
106
+ * Known gap on pnpm 9 to 11: a declaration that pins an EXACT prerelease, such
107
+ * as `vite: "8.0.0-beta.18"`, escapes the override. pnpm compares with
108
+ * `semver.intersects(declaredSpec, keyRange)`. That call is asymmetric for
109
+ * prereleases: it returns false for an exact prerelease against a wildcard
110
+ * range. The reversed argument order returns true. No range string avoids
111
+ * this, because node-semver only admits a prerelease when a comparator carries
112
+ * the same version tuple. A prerelease RANGE such as `^8.0.0-beta.1` still
113
+ * matches. pnpm 12 matches the exact form too. A bare key would cover this
114
+ * case, but a bare key is what clobbers `catalog:` specs. Below pnpm 12,
115
+ * prerelease coverage and `catalog:` safety cannot both hold.
116
+ *
117
+ * This applies to pnpm only. npm and bun `overrides`, and yarn `resolutions`,
118
+ * keep bare keys. Those package managers have no `catalog:` importer specs to
119
+ * lose. Bun catalogs live in package.json, and bun resolves them before it
120
+ * applies overrides.
121
+ */
122
+ function pnpmOverrideKey(dependencyName) {
123
+ return `${dependencyName}@*`;
124
+ }
125
+ function managedOverrideKey(dependencyName, keyStyle) {
126
+ return keyStyle === "pnpm-ranged" ? pnpmOverrideKey(dependencyName) : dependencyName;
127
+ }
84
128
  function warnMigration(message, report) {
85
129
  addMigrationWarning(report, message);
86
130
  if (!report) log.warn(message);
@@ -131,6 +175,16 @@ function pnpmMajor(version) {
131
175
  //#endregion
132
176
  //#region src/migration/detector.ts
133
177
  const PRETTIER_PACKAGE_JSON_CONFIG = "package.json#prettier";
178
+ const TSUP_PACKAGE_JSON_CONFIG = "package.json#tsup";
179
+ const TSUP_CONFIG_FILES = [
180
+ "tsup.config.ts",
181
+ "tsup.config.mts",
182
+ "tsup.config.cts",
183
+ "tsup.config.js",
184
+ "tsup.config.mjs",
185
+ "tsup.config.cjs",
186
+ "tsup.config.json"
187
+ ];
134
188
  const PRETTIER_CONFIG_FILES = [
135
189
  ".prettierrc",
136
190
  ".prettierrc.json",
@@ -153,14 +207,7 @@ const PRETTIER_CONFIG_FILES = [
153
207
  ];
154
208
  function detectConfigs(projectPath) {
155
209
  const configs = {};
156
- for (const config of [
157
- "vite.config.ts",
158
- "vite.config.mts",
159
- "vite.config.cts",
160
- "vite.config.js",
161
- "vite.config.mjs",
162
- "vite.config.cjs"
163
- ]) if (fs.existsSync(path.join(projectPath, config))) {
210
+ for (const config of VITE_CONFIG_FILES) if (fs.existsSync(path.join(projectPath, config))) {
164
211
  configs.viteConfig = config;
165
212
  break;
166
213
  }
@@ -188,6 +235,10 @@ function detectConfigs(projectPath) {
188
235
  configs.tsdownConfig = config;
189
236
  break;
190
237
  }
238
+ for (const config of TSUP_CONFIG_FILES) if (fs.existsSync(path.join(projectPath, config))) {
239
+ configs.tsupConfig = config;
240
+ break;
241
+ }
191
242
  for (const config of [".oxlintrc.json", ".oxlintrc.jsonc"]) if (fs.existsSync(path.join(projectPath, config))) {
192
243
  configs.oxlintConfig = config;
193
244
  break;
@@ -229,6 +280,7 @@ function detectConfigs(projectPath) {
229
280
  const content = fs.readFileSync(packageJsonPath, "utf8");
230
281
  const pkg = JSON.parse(content);
231
282
  if (!configs.prettierConfig && pkg.prettier) configs.prettierConfig = PRETTIER_PACKAGE_JSON_CONFIG;
283
+ if (!configs.tsupConfig && pkg.tsup) configs.tsupConfig = TSUP_PACKAGE_JSON_CONFIG;
232
284
  const voltaNode = pkg.volta?.node;
233
285
  if (typeof voltaNode === "string") configs.voltaNode = voltaNode;
234
286
  } catch {}
@@ -308,17 +360,7 @@ async function runOxlintMigrateStep(vpBin, cwd, migratePackage, args, spinner, f
308
360
  }
309
361
  async function migrateEslintToOxlint(projectPath, interactive, eslintConfigFile, packages, options) {
310
362
  const vpBin = process.env.VP_CLI_BIN ?? "vp";
311
- const spinner = options?.silent ? {
312
- start: () => {},
313
- stop: () => {},
314
- pause: () => {},
315
- resume: () => {},
316
- cancel: () => {},
317
- error: () => {},
318
- clear: () => {},
319
- message: () => {},
320
- isCancelled: false
321
- } : getSpinner(interactive);
363
+ const spinner = options?.silent ? getSilentSpinner() : getSpinner(interactive);
322
364
  if (eslintConfigFile) {
323
365
  const { versions } = await import("./versions.js");
324
366
  const migratePackage = `@oxlint/migrate@${versions.oxlint}`;
@@ -778,17 +820,7 @@ async function runPrettierMigrateStep(vpBin, cwd, spinner, failMessage, manualHi
778
820
  }
779
821
  async function migratePrettierToOxfmt(projectPath, interactive, prettierConfigFile, packages, options) {
780
822
  const vpBin = process.env.VP_CLI_BIN ?? "vp";
781
- const spinner = options?.silent ? {
782
- start: () => {},
783
- stop: () => {},
784
- pause: () => {},
785
- resume: () => {},
786
- cancel: () => {},
787
- error: () => {},
788
- clear: () => {},
789
- message: () => {},
790
- isCancelled: false
791
- } : getSpinner(interactive);
823
+ const spinner = options?.silent ? getSilentSpinner() : getSpinner(interactive);
792
824
  if (prettierConfigFile) {
793
825
  let tempPrettierConfig;
794
826
  if (prettierConfigFile === "package.json#prettier") {
@@ -907,6 +939,397 @@ async function promptPrettierMigration(projectPath, interactive, packages) {
907
939
  return true;
908
940
  }
909
941
  //#endregion
942
+ //#region src/migration/migrator/tsup.ts
943
+ function showTsdownMigrationOptions(targetLabel = "the project root", automaticMigrationFailed = false) {
944
+ const lines = [
945
+ "Choose one of these manual migration methods:",
946
+ ` 1. Run \`vp dlx tsdown-migrate\` in ${targetLabel}.`,
947
+ " 2. Use the tsdown migration skill:",
948
+ ` ${TSDOWN_MIGRATION_SKILL_URL}`
949
+ ];
950
+ if (automaticMigrationFailed) {
951
+ lines.unshift("Automatic tsup migration failed.", "");
952
+ lines.push("");
953
+ }
954
+ log.info(lines.join("\n"));
955
+ }
956
+ function showTsdownMigrationSkillGuidance(instructions) {
957
+ log.info([
958
+ ...instructions,
959
+ "",
960
+ "Use the tsdown migration skill for guidance:",
961
+ ` ${TSDOWN_MIGRATION_SKILL_URL}`
962
+ ].join("\n"));
963
+ }
964
+ function detectTsupProject(projectPath, packages) {
965
+ const packageJsonPath = path.join(projectPath, "package.json");
966
+ let hasDependency = false;
967
+ if (fs.existsSync(packageJsonPath)) {
968
+ const pkg = readJsonFile(packageJsonPath);
969
+ hasDependency = !!(pkg.devDependencies?.tsup || pkg.dependencies?.tsup);
970
+ }
971
+ const configFile = detectConfigs(projectPath).tsupConfig;
972
+ let hasConfig = !!configFile;
973
+ for (const wp of packages ?? []) {
974
+ const workspacePath = path.join(projectPath, wp.path);
975
+ hasConfig ||= !!detectConfigs(workspacePath).tsupConfig;
976
+ if (!hasDependency) {
977
+ const workspacePackageJsonPath = path.join(workspacePath, "package.json");
978
+ if (fs.existsSync(workspacePackageJsonPath)) {
979
+ const workspacePackageJson = readJsonFile(workspacePackageJsonPath);
980
+ hasDependency = !!(workspacePackageJson.devDependencies?.tsup || workspacePackageJson.dependencies?.tsup);
981
+ }
982
+ }
983
+ }
984
+ return {
985
+ hasDependency,
986
+ hasConfig,
987
+ configFile
988
+ };
989
+ }
990
+ const TSDOWN_MIGRATION_FILES = [
991
+ "package.json",
992
+ ...TSUP_CONFIG_FILES,
993
+ ...TSUP_CONFIG_FILES.map((file) => file.replace("tsup", "tsdown"))
994
+ ];
995
+ function escapeRegExp(value) {
996
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
997
+ }
998
+ const STANDARD_TSUP_CONFIG_FILE_PATTERN = TSUP_CONFIG_FILES.flatMap((file) => [file, file.replace("tsup", "tsdown")]).map(escapeRegExp).join("|");
999
+ const TSDOWN_STANDARD_CONFIG_OPTION_RE = new RegExp(String.raw`(\btsdown(?:-node)?\b(?:(?!&&|\|\||[;|]).)*?)\s+(?:--config(?:=|\s+)|-c\s+)["']?(?:\.[\\/])?(?:${STANDARD_TSUP_CONFIG_FILE_PATTERN})["']?(?=\s|$|[;&|])`, "g");
1000
+ const TSUP_CONFIG_OPTION_RE = /\btsup(?:-node)?\b(?:(?!&&|\|\||[;|]).)*?\s+(?:--config(?:=|\s+)|-c\s+)(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))(?=\s|$|[;&|])/g;
1001
+ function removeStandardTsdownConfigOption(script) {
1002
+ return script.replace(TSDOWN_STANDARD_CONFIG_OPTION_RE, "$1");
1003
+ }
1004
+ function resolveScriptConfigPath(packagePath, configPath) {
1005
+ return path.resolve(packagePath, configPath.replace(/[\\/]/g, path.sep));
1006
+ }
1007
+ function collectSharedTsupConfigs(projectPath, packages, tsupTargets) {
1008
+ const migratedConfigPaths = new Set(tsupTargets.flatMap((target) => TSUP_CONFIG_FILES.map((file) => path.join(target, file)).filter((file) => fs.existsSync(file))));
1009
+ const sharedConfigs = /* @__PURE__ */ new Map();
1010
+ const consumers = [{
1011
+ label: "the project root",
1012
+ packagePath: path.resolve(projectPath)
1013
+ }, ...(packages ?? []).map((workspacePackage) => ({
1014
+ label: workspacePackage.path,
1015
+ packagePath: path.resolve(projectPath, workspacePackage.path)
1016
+ }))];
1017
+ for (const { label, packagePath } of consumers) {
1018
+ const packageJsonPath = path.join(packagePath, "package.json");
1019
+ if (!fs.existsSync(packageJsonPath)) continue;
1020
+ const packageJson = readJsonFile(packageJsonPath);
1021
+ for (const [scriptName, script] of Object.entries(packageJson.scripts ?? {})) for (const match of script.matchAll(TSUP_CONFIG_OPTION_RE)) {
1022
+ const configPath = resolveScriptConfigPath(packagePath, match[1] ?? match[2] ?? match[3]);
1023
+ if (!migratedConfigPaths.has(configPath) || path.dirname(configPath) === packagePath) continue;
1024
+ const sharedConfig = sharedConfigs.get(configPath) ?? { consumers: /* @__PURE__ */ new Map() };
1025
+ const consumer = sharedConfig.consumers.get(packagePath) ?? {
1026
+ label,
1027
+ packagePath,
1028
+ scriptNames: /* @__PURE__ */ new Set()
1029
+ };
1030
+ consumer.scriptNames.add(scriptName);
1031
+ sharedConfig.consumers.set(packagePath, consumer);
1032
+ sharedConfigs.set(configPath, sharedConfig);
1033
+ }
1034
+ }
1035
+ return sharedConfigs;
1036
+ }
1037
+ function collectTsupConfigCollisions(tsupTargets) {
1038
+ const collisions = [];
1039
+ for (const target of tsupTargets) {
1040
+ const tsdownConfig = detectConfigs(target).tsdownConfig;
1041
+ if (tsdownConfig) collisions.push({ configPath: path.join(target, tsdownConfig) });
1042
+ const packageJsonPath = path.join(target, "package.json");
1043
+ if (fs.existsSync(packageJsonPath)) {
1044
+ const packageJson = readJsonFile(packageJsonPath);
1045
+ if (Object.hasOwn(packageJson, "tsdown")) collisions.push({ configPath: `${packageJsonPath}#tsdown` });
1046
+ }
1047
+ }
1048
+ return collisions;
1049
+ }
1050
+ function collectInlineTsupConfigs(tsupTargets) {
1051
+ return tsupTargets.flatMap((target) => {
1052
+ const packageJsonPath = path.join(target, "package.json");
1053
+ if (!fs.existsSync(packageJsonPath) || !Object.hasOwn(readJsonFile(packageJsonPath), "tsup")) return [];
1054
+ return [{ configPath: `${packageJsonPath}#tsup` }];
1055
+ });
1056
+ }
1057
+ function isRemovableDefaultConfigArgument(configArgument, defaultConfig) {
1058
+ return !!defaultConfig && (configArgument === defaultConfig || configArgument === `./${defaultConfig}` || configArgument === `.\\${defaultConfig}`);
1059
+ }
1060
+ function collectUnsupportedTsupConfigConsumers(tsupTargets) {
1061
+ const migratedConfigPaths = new Set(tsupTargets.flatMap((target) => TSUP_CONFIG_FILES.map((file) => path.join(target, file)).filter((file) => fs.existsSync(file))));
1062
+ const unsupported = [];
1063
+ for (const target of tsupTargets) {
1064
+ const packageJsonPath = path.join(target, "package.json");
1065
+ if (!fs.existsSync(packageJsonPath)) continue;
1066
+ const detectedConfig = detectConfigs(target).tsupConfig;
1067
+ const defaultConfigPath = detectedConfig && detectedConfig !== "package.json#tsup" ? path.join(target, detectedConfig) : void 0;
1068
+ const packageJson = readJsonFile(packageJsonPath);
1069
+ for (const [scriptName, script] of Object.entries(packageJson.scripts ?? {})) for (const match of script.matchAll(TSUP_CONFIG_OPTION_RE)) {
1070
+ const configArgument = match[1] ?? match[2] ?? match[3];
1071
+ const configPath = resolveScriptConfigPath(target, configArgument);
1072
+ const isDefaultConfig = configPath === defaultConfigPath && isRemovableDefaultConfigArgument(configArgument, detectedConfig);
1073
+ const isSharedMigratedConfig = migratedConfigPaths.has(configPath) && path.dirname(configPath) !== target;
1074
+ if (!isDefaultConfig && !isSharedMigratedConfig) unsupported.push({
1075
+ configArgument,
1076
+ packagePath: target,
1077
+ scriptName
1078
+ });
1079
+ }
1080
+ }
1081
+ return unsupported;
1082
+ }
1083
+ function restoreSharedTsupUsage(sharedConfigs, snapshots) {
1084
+ const preservedDependencyTargets = /* @__PURE__ */ new Set();
1085
+ const restoredScripts = /* @__PURE__ */ new Map();
1086
+ for (const [configPath, sharedConfig] of sharedConfigs) {
1087
+ const contents = snapshots.get(configPath);
1088
+ if (contents !== void 0) fs.writeFileSync(configPath, contents);
1089
+ preservedDependencyTargets.add(path.dirname(configPath));
1090
+ for (const consumer of sharedConfig.consumers.values()) {
1091
+ preservedDependencyTargets.add(consumer.packagePath);
1092
+ const scriptNames = restoredScripts.get(consumer.packagePath) ?? /* @__PURE__ */ new Set();
1093
+ for (const scriptName of consumer.scriptNames) scriptNames.add(scriptName);
1094
+ restoredScripts.set(consumer.packagePath, scriptNames);
1095
+ }
1096
+ }
1097
+ for (const target of preservedDependencyTargets) {
1098
+ const packageJsonPath = path.join(target, "package.json");
1099
+ const originalPackageJson = snapshots.get(packageJsonPath);
1100
+ if (!originalPackageJson || !fs.existsSync(packageJsonPath)) continue;
1101
+ const original = JSON.parse(originalPackageJson.toString());
1102
+ editJsonFile(packageJsonPath, (pkg) => {
1103
+ let changed = false;
1104
+ for (const field of ["devDependencies", "dependencies"]) {
1105
+ const spec = original[field]?.tsup;
1106
+ if (spec && pkg[field]?.tsup !== spec) {
1107
+ pkg[field] ??= {};
1108
+ pkg[field].tsup = spec;
1109
+ changed = true;
1110
+ }
1111
+ }
1112
+ for (const scriptName of restoredScripts.get(target) ?? []) {
1113
+ const script = original.scripts?.[scriptName];
1114
+ if (script !== void 0 && pkg.scripts?.[scriptName] !== script) {
1115
+ pkg.scripts ??= {};
1116
+ pkg.scripts[scriptName] = script;
1117
+ changed = true;
1118
+ }
1119
+ }
1120
+ return changed ? pkg : void 0;
1121
+ });
1122
+ }
1123
+ return preservedDependencyTargets;
1124
+ }
1125
+ function snapshotTsupMigrationTargets(targets) {
1126
+ const snapshots = /* @__PURE__ */ new Map();
1127
+ for (const target of targets) for (const file of TSDOWN_MIGRATION_FILES) {
1128
+ const filePath = path.join(target, file);
1129
+ snapshots.set(filePath, fs.existsSync(filePath) ? fs.readFileSync(filePath) : void 0);
1130
+ }
1131
+ return snapshots;
1132
+ }
1133
+ function restoreTsupMigrationTargets(snapshots) {
1134
+ const failures = [];
1135
+ for (const [filePath, contents] of snapshots) try {
1136
+ if (contents === void 0) fs.rmSync(filePath, { force: true });
1137
+ else fs.writeFileSync(filePath, contents);
1138
+ } catch {
1139
+ failures.push(displayRelative(filePath));
1140
+ }
1141
+ return failures;
1142
+ }
1143
+ function extractTsdownMigrationWarnings(output) {
1144
+ return output.toString().replaceAll("\r\n", "\n").split(/\n\s*\n/).map((block) => block.trim().match(/^WARN\s+([\s\S]+)$/)?.[1]?.trim()).filter((warning) => !!warning);
1145
+ }
1146
+ /** Run `vp dlx tsdown-migrate` in `cwd` with graceful error handling. */
1147
+ async function runTsdownMigrateStep(vpBin, cwd, packageManager) {
1148
+ try {
1149
+ const result = await runCommandSilently({
1150
+ command: vpBin,
1151
+ args: [
1152
+ "dlx",
1153
+ `tsdown-migrate@${TSDOWN_MIGRATE_VERSION}`,
1154
+ "--yes",
1155
+ "--package-manager",
1156
+ packageManager,
1157
+ "--no-install"
1158
+ ],
1159
+ cwd,
1160
+ envs: process.env
1161
+ });
1162
+ if (result.exitCode !== 0) {
1163
+ const stderr = result.stderr.toString().trim();
1164
+ if (stderr) log.warn(`⚠ ${stderr}`);
1165
+ return {
1166
+ ok: false,
1167
+ warnings: []
1168
+ };
1169
+ }
1170
+ return {
1171
+ ok: true,
1172
+ warnings: [...extractTsdownMigrationWarnings(result.stdout), ...extractTsdownMigrationWarnings(result.stderr)]
1173
+ };
1174
+ } catch {
1175
+ return {
1176
+ ok: false,
1177
+ warnings: []
1178
+ };
1179
+ }
1180
+ }
1181
+ async function migrateTsupToTsdown(projectPath, interactive, packageManager, tsupConfigFile, packages, options) {
1182
+ const vpBin = process.env.VP_CLI_BIN ?? "vp";
1183
+ const spinner = options?.silent ? getSilentSpinner() : getSpinner(interactive);
1184
+ const rootPath = path.resolve(projectPath);
1185
+ const tsupTargets = [rootPath, ...(packages ?? []).map((p) => path.resolve(rootPath, p.path))].filter((target) => target === rootPath ? !!tsupConfigFile : !!detectConfigs(target).tsupConfig);
1186
+ const configCollisions = collectTsupConfigCollisions(tsupTargets);
1187
+ if (configCollisions.length > 0) {
1188
+ log.warn(`Automatic tsup migration was skipped because these tsdown configs already exist:\n${configCollisions.map(({ configPath }) => ` ${displayRelative(configPath, projectPath)}`).join("\n")}`);
1189
+ showTsdownMigrationSkillGuidance([
1190
+ "Resolve this configuration conflict manually:",
1191
+ " 1. Merge the tsup and tsdown configurations into `pack` in `vite.config.*`.",
1192
+ " 2. Do not run `tsdown-migrate`. It can overwrite the existing tsdown configuration."
1193
+ ]);
1194
+ return false;
1195
+ }
1196
+ const inlineTsupConfigs = collectInlineTsupConfigs(tsupTargets);
1197
+ if (inlineTsupConfigs.length > 0) {
1198
+ log.warn(`Automatic tsup migration was skipped because these inline tsup configs cannot be migrated automatically:\n${inlineTsupConfigs.map(({ configPath }) => ` ${displayRelative(configPath, projectPath)}`).join("\n")}`);
1199
+ showTsdownMigrationSkillGuidance([
1200
+ "Resolve this inline configuration manually:",
1201
+ " 1. Move each `package.json#tsup` configuration into `pack` in `vite.config.*`.",
1202
+ " 2. Do not run `tsdown-migrate`. Vite+ Pack does not read `package.json#tsdown`."
1203
+ ]);
1204
+ return false;
1205
+ }
1206
+ const unsupportedConfigConsumers = collectUnsupportedTsupConfigConsumers(tsupTargets);
1207
+ if (unsupportedConfigConsumers.length > 0) {
1208
+ log.warn(`Automatic tsup migration was skipped because these scripts use configs that cannot be migrated automatically:\n${unsupportedConfigConsumers.map(({ configArgument, packagePath, scriptName }) => ` ${displayRelative(path.join(packagePath, "package.json"), projectPath)}#${scriptName} -> ${configArgument}`).join("\n")}`);
1209
+ showTsdownMigrationSkillGuidance([
1210
+ "Resolve these config paths manually:",
1211
+ " 1. Migrate each listed config into `pack` in `vite.config.*`.",
1212
+ " 2. Update each listed script.",
1213
+ " 3. Do not run `tsdown-migrate`. It cannot safely resolve these config paths."
1214
+ ]);
1215
+ return false;
1216
+ }
1217
+ const sharedConfigs = collectSharedTsupConfigs(projectPath, packages, tsupTargets);
1218
+ let preservedDependencyTargets = /* @__PURE__ */ new Set();
1219
+ if (tsupTargets.length > 0) {
1220
+ const snapshots = snapshotTsupMigrationTargets(tsupTargets);
1221
+ const migrationWarnings = [];
1222
+ spinner.start("Migrating tsup config to tsdown...");
1223
+ for (const target of tsupTargets) {
1224
+ const targetLabel = target === rootPath ? "the project root" : displayRelative(target, projectPath);
1225
+ const migrateResult = await runTsdownMigrateStep(vpBin, target, packageManager);
1226
+ if (!migrateResult.ok) {
1227
+ spinner.stop();
1228
+ const restoreFailures = restoreTsupMigrationTargets(snapshots);
1229
+ if (restoreFailures.length > 0) log.warn(`Could not restore these files after the failed migration:\n${restoreFailures.map((file) => ` ${file}`).join("\n")}`);
1230
+ showTsdownMigrationOptions(targetLabel, true);
1231
+ return false;
1232
+ }
1233
+ for (const warning of migrateResult.warnings) migrationWarnings.push({
1234
+ targetLabel,
1235
+ warning
1236
+ });
1237
+ }
1238
+ spinner.stop("tsup config migrated to tsdown.config");
1239
+ preservedDependencyTargets = restoreSharedTsupUsage(sharedConfigs, snapshots);
1240
+ for (const { targetLabel, warning } of migrationWarnings) {
1241
+ const message = targetLabel === "the project root" ? `tsdown-migrate: ${warning}` : `tsdown-migrate (${targetLabel}): ${warning}`;
1242
+ if (options?.report) addMigrationWarning(options.report, message);
1243
+ else log.warn(message);
1244
+ }
1245
+ for (const [configPath, sharedConfig] of sharedConfigs) {
1246
+ const message = `${displayRelative(configPath, projectPath)} is shared by ${[...sharedConfig.consumers.values()].map((consumer) => consumer.label).toSorted().join(", ")}. It was preserved and must be migrated manually.`;
1247
+ if (options?.report) addMigrationWarning(options.report, message);
1248
+ else log.warn(message);
1249
+ }
1250
+ }
1251
+ if (options?.report) options.report.tsupMigrated = true;
1252
+ for (const target of tsupTargets) {
1253
+ if (!fs.existsSync(path.join(target, "package.json"))) continue;
1254
+ deleteTsupConfigFiles(target, new Set([...sharedConfigs.keys()].filter((configPath) => path.dirname(configPath) === path.resolve(target))), options?.report, options?.silent);
1255
+ rewriteTsupPackageJson(path.join(target, "package.json"), preservedDependencyTargets.has(path.resolve(target)));
1256
+ }
1257
+ return true;
1258
+ }
1259
+ function deleteTsupConfigFiles(basePath, preservedConfigs, report, silent = false) {
1260
+ const configs = detectConfigs(basePath);
1261
+ if (configs.tsupConfig && configs.tsupConfig !== "package.json#tsup") {
1262
+ const configPath = path.join(basePath, configs.tsupConfig);
1263
+ if (!preservedConfigs.has(configPath) && fs.existsSync(configPath)) {
1264
+ fs.unlinkSync(configPath);
1265
+ if (report) report.removedConfigCount++;
1266
+ if (!silent) log.success(`✔ Removed ${displayRelative(configPath)}`);
1267
+ }
1268
+ }
1269
+ for (const file of TSUP_CONFIG_FILES) {
1270
+ if (file === configs.tsupConfig) continue;
1271
+ const configPath = path.join(basePath, file);
1272
+ if (!preservedConfigs.has(configPath) && fs.existsSync(configPath)) {
1273
+ fs.unlinkSync(configPath);
1274
+ if (report) report.removedConfigCount++;
1275
+ if (!silent) log.success(`✔ Removed ${displayRelative(configPath)}`);
1276
+ }
1277
+ }
1278
+ editJsonFile(path.join(basePath, "package.json"), (pkg) => {
1279
+ if (pkg.tsup) {
1280
+ delete pkg.tsup;
1281
+ return pkg;
1282
+ }
1283
+ });
1284
+ }
1285
+ function rewriteTsupPackageJson(packageJsonPath, preserveTsupDependency = false) {
1286
+ if (!fs.existsSync(packageJsonPath)) return;
1287
+ editJsonFile(packageJsonPath, (pkg) => {
1288
+ let changed = false;
1289
+ for (const [name, script] of Object.entries(pkg.scripts ?? {})) {
1290
+ const rewritten = removeStandardTsdownConfigOption(script);
1291
+ if (rewritten !== script) {
1292
+ pkg.scripts[name] = rewritten;
1293
+ changed = true;
1294
+ }
1295
+ }
1296
+ if (!preserveTsupDependency) {
1297
+ for (const field of ["devDependencies", "dependencies"]) if (pkg[field]?.tsup) {
1298
+ delete pkg[field].tsup;
1299
+ changed = true;
1300
+ }
1301
+ }
1302
+ return changed ? pkg : void 0;
1303
+ });
1304
+ }
1305
+ function warnMissingTsupConfig() {
1306
+ log.warn("tsup detected, but no tsup config was found. The tsup setup must be migrated manually.");
1307
+ }
1308
+ async function confirmTsupMigration(interactive) {
1309
+ if (interactive) {
1310
+ const confirmed = await confirm({
1311
+ message: "Migrate tsup config to tsdown using tsdown-migrate?\n " + styleText("gray", "tsdown is Vite+'s built-in bundler (exposed via `vp pack`) — a mostly drop-in tsup replacement powered by Rolldown. tsdown-migrate converts your existing config automatically."),
1312
+ initialValue: true
1313
+ });
1314
+ if (isCancel(confirmed)) cancelAndExit();
1315
+ if (!confirmed) showTsdownMigrationOptions();
1316
+ return confirmed;
1317
+ }
1318
+ log.info("tsup configuration detected. Auto-migrating to tsdown...");
1319
+ return true;
1320
+ }
1321
+ async function promptTsupMigration(projectPath, interactive, packageManager, packages) {
1322
+ const tsupProject = detectTsupProject(projectPath, packages);
1323
+ if (!tsupProject.hasDependency) return false;
1324
+ if (!tsupProject.hasConfig) {
1325
+ warnMissingTsupConfig();
1326
+ return false;
1327
+ }
1328
+ if (!await confirmTsupMigration(interactive)) return false;
1329
+ if (!await migrateTsupToTsdown(projectPath, interactive, packageManager, tsupProject.configFile, packages)) cancelAndExit("Complete the tsup migration manually, then re-run `vp migrate`.", 1);
1330
+ return true;
1331
+ }
1332
+ //#endregion
910
1333
  //#region src/migration/migrator/tsconfig.ts
911
1334
  function cleanupDeprecatedTsconfigOptions(projectPath, silent = false, report) {
912
1335
  const deprecatedOptions = ["esModuleInterop", "allowSyntheticDefaultImports"];
@@ -1163,17 +1586,21 @@ function projectListsRequiredVitestPeer(projectPath, pkg) {
1163
1586
  function projectUsesVitestDirectly(projectPath, pkg, requiredVitestPeer, preserveNuxtVitestImports = true, precomputedScans) {
1164
1587
  return projectListsVitestEcosystemDep(pkg) || (requiredVitestPeer ?? projectListsRequiredVitestPeer(projectPath, pkg)) || VITEST_BROWSER_DEP_NAMES.some((name) => pkg.peerDependencies?.[name] !== void 0) || (precomputedScans?.retainedModule ?? sourceTreeReferencesRetainedVitestModule(projectPath)) || preserveNuxtVitestImports && hasNuxtTestUtilsDependency(pkg) || (precomputedScans?.browserMode ?? usesVitestBrowserMode(projectPath));
1165
1588
  }
1166
- function removeManagedVitestEntry(record) {
1167
- if (VITEST_IS_MANAGED_OVERRIDE && typeof record?.vitest === "string") {
1168
- delete record.vitest;
1169
- return true;
1589
+ function removeManagedVitestEntry(record, keyStyle = "bare") {
1590
+ if (!VITEST_IS_MANAGED_OVERRIDE || !record) return false;
1591
+ let removed = false;
1592
+ for (const key of managedVitestOverrideKeys(keyStyle)) if (typeof record[key] === "string") {
1593
+ delete record[key];
1594
+ removed = true;
1170
1595
  }
1171
- return false;
1596
+ return removed;
1172
1597
  }
1173
- function removeYamlMapVitestEntry(map) {
1598
+ function removeYamlMapVitestEntry(map, keyStyle = "bare") {
1174
1599
  if (!VITEST_IS_MANAGED_OVERRIDE || !(map instanceof import_dist.YAMLMap)) return;
1175
- const target = map.items.find((item) => item.key instanceof import_dist.Scalar && item.key.value === "vitest")?.key;
1176
- if (target) map.delete(target);
1600
+ for (const key of managedVitestOverrideKeys(keyStyle)) map.delete(key);
1601
+ }
1602
+ function managedVitestOverrideKeys(keyStyle) {
1603
+ return keyStyle === "pnpm-ranged" ? ["vitest", pnpmOverrideKey("vitest")] : ["vitest"];
1177
1604
  }
1178
1605
  function removeVitestPeerDependencyRule(peerDependencyRules) {
1179
1606
  if (!VITEST_IS_MANAGED_OVERRIDE) return;
@@ -1266,7 +1693,7 @@ function vitestEcosystemCatalogReferencesPending(pkg, catalogDependencyResolver)
1266
1693
  pkg.optionalDependencies
1267
1694
  ]) {
1268
1695
  if (!dependencies) continue;
1269
- for (const [name, spec] of Object.entries(dependencies)) if (isAlignableVitestEcosystemPackage(name) && spec.startsWith("catalog:") && catalogDependencyResolver(spec, name) !== "4.1.10") return true;
1696
+ for (const [name, spec] of Object.entries(dependencies)) if (isAlignableVitestEcosystemPackage(name) && spec.startsWith("catalog:") && catalogDependencyResolver(spec, name) !== "4.1.11") return true;
1270
1697
  }
1271
1698
  return false;
1272
1699
  }
@@ -2711,9 +3138,10 @@ var Minimatch = class {
2711
3138
  const next = pp[i + 1];
2712
3139
  const prev = pp[i - 1];
2713
3140
  if (p !== GLOBSTAR || prev === GLOBSTAR) return;
2714
- if (prev === void 0) if (next !== void 0 && next !== GLOBSTAR) pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
2715
- else pp[i] = twoStar;
2716
- else if (next === void 0) pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + ")?";
3141
+ if (prev === void 0) {
3142
+ if (next !== void 0 && next !== GLOBSTAR) pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
3143
+ else pp[i] = twoStar;
3144
+ } else if (next === void 0) pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + ")?";
2717
3145
  else if (next !== GLOBSTAR) {
2718
3146
  pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
2719
3147
  pp[i + 1] = GLOBSTAR;
@@ -2971,7 +3399,7 @@ var L = class c {
2971
3399
  }
2972
3400
  }
2973
3401
  getRemainingTTL(t) {
2974
- return this.#s.has(t) ? Infinity : 0;
3402
+ return this.#s.has(t) ? 1 / 0 : 0;
2975
3403
  }
2976
3404
  #j() {
2977
3405
  let t = new z(this.#o), e = new z(this.#o);
@@ -3011,7 +3439,7 @@ var L = class c {
3011
3439
  let r = this.#s.get(h);
3012
3440
  if (r === void 0) return 0;
3013
3441
  let a = t[r], w = e[r];
3014
- if (!a || !w) return Infinity;
3442
+ if (!a || !w) return 1 / 0;
3015
3443
  return a - ((n || o()) - w);
3016
3444
  }, this.#p = (h) => {
3017
3445
  let r = e[h], a = t[h];
@@ -4211,7 +4639,7 @@ const realpathSync$2 = realpathSync$1.native;
4211
4639
  const defaultFS = {
4212
4640
  lstatSync: lstatSync$1,
4213
4641
  readdir,
4214
- readdirSync,
4642
+ readdirSync: readdirSync$1,
4215
4643
  readlinkSync,
4216
4644
  realpathSync: realpathSync$2,
4217
4645
  promises: {
@@ -4251,7 +4679,7 @@ const ENOREALPATH = 512;
4251
4679
  const ENOCHILD = 704;
4252
4680
  const TYPEMASK = 1023;
4253
4681
  const entToType = (s) => s.isFile() ? IFREG : s.isDirectory() ? IFDIR : s.isSymbolicLink() ? IFLNK : s.isCharacterDevice() ? IFCHR : s.isBlockDevice() ? IFBLK : s.isSocket() ? IFSOCK : s.isFIFO() ? IFIFO : UNKNOWN;
4254
- const normalizeCache = new L({ max: 2 ** 12 });
4682
+ const normalizeCache = new L({ max: 4096 });
4255
4683
  const normalize$1 = (s) => {
4256
4684
  const c = normalizeCache.get(s);
4257
4685
  if (c) return c;
@@ -4259,7 +4687,7 @@ const normalize$1 = (s) => {
4259
4687
  normalizeCache.set(s, n);
4260
4688
  return n;
4261
4689
  };
4262
- const normalizeNocaseCache = new L({ max: 2 ** 12 });
4690
+ const normalizeNocaseCache = new L({ max: 4096 });
4263
4691
  const normalizeNocase = (s) => {
4264
4692
  const c = normalizeNocaseCache.get(s);
4265
4693
  if (c) return c;
@@ -5979,8 +6407,10 @@ var Ignore = class {
5979
6407
  const absolute = p.isAbsolute();
5980
6408
  if (absolute) this.absolute.push(m);
5981
6409
  else this.relative.push(m);
5982
- if (children) if (absolute) this.absoluteChildren.push(m);
5983
- else this.relativeChildren.push(m);
6410
+ if (children) {
6411
+ if (absolute) this.absoluteChildren.push(m);
6412
+ else this.relativeChildren.push(m);
6413
+ }
5984
6414
  }
5985
6415
  }
5986
6416
  ignored(p) {
@@ -6956,10 +7386,12 @@ function rewritePnpmWorkspaceYaml(projectPath, pnpmMajorVersion, shouldAllowBrow
6956
7386
  const keysSnapshot = overrides.items.map((item) => item.key);
6957
7387
  for (const keyNode of keysSnapshot) if (shouldDropProviderOverrideKey(keyNode instanceof import_dist.Scalar ? String(keyNode.value ?? "") : String(keyNode ?? ""))) overrides.delete(keyNode);
6958
7388
  }
6959
- if (!usesVitest) removeYamlMapVitestEntry(doc.getIn(["overrides"]));
7389
+ if (!usesVitest) removeYamlMapVitestEntry(doc.getIn(["overrides"]), "pnpm-ranged");
6960
7390
  for (const key of Object.keys(managed)) {
6961
- const version = getCatalogDependencySpec(getYamlMapScalarStringValue(overrides, key), managed[key], true, { preferredCatalogSpec });
6962
- doc.setIn(["overrides", scalarString(key)], scalarString(version));
7391
+ const overrideKey = pnpmOverrideKey(key);
7392
+ const version = getCatalogDependencySpec(getYamlMapScalarStringValue(overrides, overrideKey) ?? getYamlMapScalarStringValue(overrides, key), managed[key], true, { preferredCatalogSpec });
7393
+ if (overrides instanceof import_dist.YAMLMap) overrides.delete(key);
7394
+ doc.setIn(["overrides", scalarString(overrideKey)], scalarString(version));
6963
7395
  }
6964
7396
  const updatedOverrides = doc.getIn(["overrides"]);
6965
7397
  const updatedOverrideKeys = updatedOverrides.items.map((item) => item.key);
@@ -7058,14 +7490,17 @@ function getCatalogDependencySpec(currentValue, version, supportCatalog, options
7058
7490
  }
7059
7491
  /**
7060
7492
  * #1932: under pnpm, an importer that depends on `vite-plus` (which bundles
7061
- * `vitest`) needs a DIRECT `vite` devDep so the `vite` override binds vitest's
7062
- * required `vite` peer to @voidzero-dev/vite-plus-core. Without a direct edge,
7063
- * pnpm's `autoInstallPeers` fabricates a separate upstream `vite` to satisfy the
7493
+ * `vitest`) needs a DIRECT `vite` devDep pointing at @voidzero-dev/vite-plus-core
7494
+ * so vitest's required `vite` peer binds to it. Without a direct edge, pnpm's
7495
+ * `autoInstallPeers` fabricates a separate upstream `vite` to satisfy the
7064
7496
  * peer, splitting vite-plus / vite / vitest into duplicate instances (the extra
7065
7497
  * vite also lacks vite's `@voidzero-dev/vite-task-client` integration, breaking
7066
- * the `vp test` cache). npm/yarn/bun redirect transitive/peer vite via root
7067
- * overrides/resolutions (and drop the aliased vite), so this is pnpm-only,
7068
- * mirroring the bun root-package branch in `rewriteRootWorkspacePackageJson`.
7498
+ * the `vp test` cache). Under a catalog the edge is a `catalog:` reference and
7499
+ * the catalog entry carries the alias; the `vite@*` workspace override covers
7500
+ * transitive and peer declarations instead of this one (see `pnpmOverrideKey`).
7501
+ * npm/yarn/bun redirect transitive/peer vite via root overrides/resolutions (and
7502
+ * drop the aliased vite), so this is pnpm-only, mirroring the bun root-package
7503
+ * branch in `rewriteRootWorkspacePackageJson`.
7069
7504
  *
7070
7505
  * A package that already declares `vite` in ANY dependency field, including
7071
7506
  * `peerDependencies` (e.g. a vite plugin pinning `vite ^6`), is left untouched
@@ -7180,6 +7615,39 @@ function getYamlMapScalarStringValue(map, key) {
7180
7615
  if (!(map instanceof import_dist.YAMLMap)) return;
7181
7616
  for (const item of map.items) if (item.key instanceof import_dist.Scalar && item.key.value === key && item.value instanceof import_dist.Scalar && typeof item.value.value === "string") return item.value.value;
7182
7617
  }
7618
+ /**
7619
+ * Merge the managed override entries into a pnpm `overrides` record, under the
7620
+ * range-qualified keys (see `pnpmOverrideKey`).
7621
+ *
7622
+ * Both writers of the package.json `pnpm.overrides` sink go through this
7623
+ * helper: the standalone writer and the monorepo-root writer. That sink serves
7624
+ * pnpm 9.5 to 10.6.1. The helper deletes a bare managed key that a pre-#2309
7625
+ * migration left. Two keys for one package would restore the match that
7626
+ * clobbers `catalog:` importer specs.
7627
+ *
7628
+ * A bare key's `catalog:` value moves to the ranged key, so a user's own
7629
+ * `catalog:<name>` choice survives the re-keying. This mirrors
7630
+ * `getCatalogDependencySpec`, which keeps a `catalog:` reference in the
7631
+ * pnpm-workspace.yaml sink. A `file:` managed spec (force-override mode) always
7632
+ * wins, because there is no catalog to resolve against in that mode.
7633
+ *
7634
+ * Force-override mode also appends the `vite-plus` pin, under a BARE key. The
7635
+ * pin only exists in `file:` tgz mode, where migration writes the tgz spec
7636
+ * straight into every manifest instead of a `catalog:` reference. In that mode
7637
+ * there is no catalog provenance for a bare key to strip. This matches the
7638
+ * workspace-yaml force-override path in `rewriteStandaloneProject`.
7639
+ */
7640
+ function mergeManagedPnpmOverrides(overrides, managed) {
7641
+ const next = { ...overrides };
7642
+ for (const [dependencyName, managedSpec] of Object.entries(managed)) {
7643
+ const overrideKey = pnpmOverrideKey(dependencyName);
7644
+ const existing = next[overrideKey] ?? next[dependencyName];
7645
+ delete next[dependencyName];
7646
+ next[overrideKey] = existing?.startsWith("catalog:") && !managedSpec.startsWith("file:") ? existing : managedSpec;
7647
+ }
7648
+ if (isForceOverrideMode()) next[VITE_PLUS_NAME] = VITE_PLUS_VERSION;
7649
+ return next;
7650
+ }
7183
7651
  function pruneYamlMapLegacyWrapperAliases(map) {
7184
7652
  if (!(map instanceof import_dist.YAMLMap)) return;
7185
7653
  const stale = [];
@@ -7335,15 +7803,11 @@ function rewriteRootWorkspacePackageJson(projectPath, packageManager, skipStaged
7335
7803
  const overrideKeys = Object.keys(managed);
7336
7804
  if (!pnpmSupportsWorkspaceSettings(pnpmVersion ?? "")) {
7337
7805
  dropRemovePackageOverrideKeys(pkg.pnpm?.overrides);
7338
- if (!workspaceUsesVitest) removeManagedVitestEntry(pkg.pnpm?.overrides);
7806
+ if (!workspaceUsesVitest) removeManagedVitestEntry(pkg.pnpm?.overrides, "pnpm-ranged");
7339
7807
  if (!workspaceUsesVitest && pkg.pnpm?.peerDependencyRules) removeVitestPeerDependencyRule(pkg.pnpm.peerDependencyRules);
7340
7808
  pkg.pnpm = {
7341
7809
  ...pkg.pnpm,
7342
- overrides: {
7343
- ...pkg.pnpm?.overrides,
7344
- ...managed,
7345
- ...isForceOverrideMode() ? { [VITE_PLUS_NAME]: VITE_PLUS_VERSION } : {}
7346
- },
7810
+ overrides: mergeManagedPnpmOverrides(pkg.pnpm?.overrides, managed),
7347
7811
  peerDependencyRules: {
7348
7812
  ...pkg.pnpm?.peerDependencyRules,
7349
7813
  allowAny: [.../* @__PURE__ */ new Set([...pkg.pnpm?.peerDependencyRules?.allowAny ?? [], ...overrideKeys])],
@@ -7732,9 +8196,11 @@ function overrideSpecSatisfiesVitePlus(dependencyName, spec, catalogDependencyRe
7732
8196
  if (!spec.startsWith("catalog:")) return false;
7733
8197
  return isSemanticVitePlusOverrideSpec(dependencyName, catalogDependencyResolver?.(spec, dependencyName));
7734
8198
  }
7735
- function overridesSatisfyVitePlus(overrides, usesVitest, catalogDependencyResolver) {
7736
- if (!usesVitest && VITEST_IS_MANAGED_OVERRIDE && typeof overrides?.vitest === "string") return false;
7737
- return Object.keys(managedOverridePackages(usesVitest)).every((dependencyName) => overrideSpecSatisfiesVitePlus(dependencyName, overrides?.[dependencyName], catalogDependencyResolver));
8199
+ function overridesSatisfyVitePlus(overrides, usesVitest, catalogDependencyResolver, keyStyle = "bare") {
8200
+ const managed = managedOverridePackages(usesVitest);
8201
+ if (!usesVitest && VITEST_IS_MANAGED_OVERRIDE && (typeof overrides?.vitest === "string" || keyStyle === "pnpm-ranged" && typeof overrides?.[pnpmOverrideKey("vitest")] === "string")) return false;
8202
+ if (keyStyle === "pnpm-ranged" && Object.keys(managed).some((dependencyName) => typeof overrides?.[dependencyName] === "string")) return false;
8203
+ return Object.keys(managed).every((dependencyName) => overrideSpecSatisfiesVitePlus(dependencyName, overrides?.[managedOverrideKey(dependencyName, keyStyle)], catalogDependencyResolver));
7738
8204
  }
7739
8205
  function hasPackageManagerPin(pkg) {
7740
8206
  return Boolean(pkg.packageManager || pkg.devEngines?.packageManager);
@@ -7955,11 +8421,11 @@ function detectVitePlusBootstrapPending(projectPath, packageManager, packages, p
7955
8421
  if (packageManager === PackageManager.pnpm) {
7956
8422
  if (!pnpmWorkspaceExoticSubdepsSettingSatisfied(projectPath)) return true;
7957
8423
  if (!usePnpmWorkspaceYaml) {
7958
- if (supportCatalog) return catalogVitePlusDependencyPending(pkg, catalogDependencyResolver) || !overridesSatisfyVitePlus(pkg.pnpm?.overrides, usesVitest, catalogDependencyResolver) || !pnpmPeerDependencyRulesSatisfyVitePlus(pkg.pnpm?.peerDependencyRules, usesVitest);
7959
- return vitePlusDependencyNeedsConcreteVersion(pkg) || !overridesSatisfyVitePlus(pkg.pnpm?.overrides, usesVitest) || !pnpmPeerDependencyRulesSatisfyVitePlus(pkg.pnpm?.peerDependencyRules, usesVitest);
8424
+ if (supportCatalog) return catalogVitePlusDependencyPending(pkg, catalogDependencyResolver) || !overridesSatisfyVitePlus(pkg.pnpm?.overrides, usesVitest, catalogDependencyResolver, "pnpm-ranged") || !pnpmPeerDependencyRulesSatisfyVitePlus(pkg.pnpm?.peerDependencyRules, usesVitest);
8425
+ return vitePlusDependencyNeedsConcreteVersion(pkg) || !overridesSatisfyVitePlus(pkg.pnpm?.overrides, usesVitest, void 0, "pnpm-ranged") || !pnpmPeerDependencyRulesSatisfyVitePlus(pkg.pnpm?.peerDependencyRules, usesVitest);
7960
8426
  }
7961
8427
  const resolver = readPnpmWorkspaceCatalogDependencyResolver(projectPath);
7962
- return workspaceCatalogVitePlusDependencyPending(projectPath, packages, resolver) || !overridesSatisfyVitePlus(readPnpmWorkspaceOverrides(projectPath), usesVitest, resolver) || !pnpmPeerDependencyRulesSatisfyVitePlus(readPnpmWorkspacePeerDependencyRules(projectPath), usesVitest) || pnpmWorkspaceMinimumReleaseAgeExemptionsPending(projectPath);
8428
+ return workspaceCatalogVitePlusDependencyPending(projectPath, packages, resolver) || !overridesSatisfyVitePlus(readPnpmWorkspaceOverrides(projectPath), usesVitest, resolver, "pnpm-ranged") || !pnpmPeerDependencyRulesSatisfyVitePlus(readPnpmWorkspacePeerDependencyRules(projectPath), usesVitest) || pnpmWorkspaceMinimumReleaseAgeExemptionsPending(projectPath);
7963
8429
  }
7964
8430
  return false;
7965
8431
  }
@@ -7998,13 +8464,21 @@ function ensureVitePlusDependencySpecs(pkg, version, ensurePresent = true) {
7998
8464
  function readTextFileIfExists(filePath) {
7999
8465
  return fs.existsSync(filePath) ? fs.readFileSync(filePath, "utf-8") : void 0;
8000
8466
  }
8001
- function ensureOverrideEntries(overrides, usesVitest, catalogDependencyResolver) {
8467
+ function ensureOverrideEntries(overrides, usesVitest, catalogDependencyResolver, keyStyle = "bare") {
8002
8468
  const next = { ...overrides };
8003
8469
  let changed = false;
8004
- if (!usesVitest && removeManagedVitestEntry(next)) changed = true;
8005
- for (const [dependencyName, overrideSpec] of Object.entries(managedOverridePackages(usesVitest))) if (!overrideSpecSatisfiesVitePlus(dependencyName, next[dependencyName], catalogDependencyResolver)) {
8006
- next[dependencyName] = overrideSpec;
8007
- changed = true;
8470
+ if (!usesVitest && removeManagedVitestEntry(next, keyStyle)) changed = true;
8471
+ for (const [dependencyName, overrideSpec] of Object.entries(managedOverridePackages(usesVitest))) {
8472
+ const overrideKey = managedOverrideKey(dependencyName, keyStyle);
8473
+ if (overrideKey !== dependencyName && next[dependencyName] !== void 0) {
8474
+ next[overrideKey] ??= next[dependencyName];
8475
+ delete next[dependencyName];
8476
+ changed = true;
8477
+ }
8478
+ if (!overrideSpecSatisfiesVitePlus(dependencyName, next[overrideKey], catalogDependencyResolver)) {
8479
+ next[overrideKey] = overrideSpec;
8480
+ changed = true;
8481
+ }
8008
8482
  }
8009
8483
  return {
8010
8484
  overrides: next,
@@ -8084,7 +8558,7 @@ function ensureVitePlusBootstrap(workspaceInfo, report) {
8084
8558
  }
8085
8559
  } else if (workspaceInfo.packageManager === PackageManager.pnpm && !usePnpmWorkspaceYaml) {
8086
8560
  pkg.pnpm ??= {};
8087
- const ensured = ensureOverrideEntries(pkg.pnpm.overrides, usesVitest, supportCatalog ? readPnpmWorkspaceCatalogDependencyResolver(projectPath) : void 0);
8561
+ const ensured = ensureOverrideEntries(pkg.pnpm.overrides, usesVitest, supportCatalog ? readPnpmWorkspaceCatalogDependencyResolver(projectPath) : void 0, "pnpm-ranged");
8088
8562
  if (ensured.changed) {
8089
8563
  pkg.pnpm.overrides = ensured.overrides;
8090
8564
  packageJsonChanged = true;
@@ -8118,20 +8592,21 @@ function ensureVitePlusBootstrap(workspaceInfo, report) {
8118
8592
  });
8119
8593
  result.packageJson = result.packageJson || childChanged;
8120
8594
  }
8121
- if (workspaceInfo.packageManager === PackageManager.pnpm) if (usePnpmWorkspaceYaml) {
8122
- const before = readTextFileIfExists(pnpmWorkspaceYamlPath);
8123
- migratePnpmSettingsToWorkspaceYaml(projectPath, movedPnpmSettings);
8124
- const catalogDependencyResolver = readPnpmWorkspaceCatalogDependencyResolver(projectPath);
8125
- if (movedPnpmSettings !== void 0 || result.packageJson || ecosystemCatalogReferencesPending || !pnpmWorkspaceExoticSubdepsSettingSatisfied(projectPath) || pnpmWorkspaceMinimumReleaseAgeExemptionsPending(projectPath) || workspaceCatalogVitePlusDependencyPending(projectPath, workspaceInfo.packages, catalogDependencyResolver) || !overridesSatisfyVitePlus(readPnpmWorkspaceOverrides(projectPath), usesVitest, catalogDependencyResolver) || !pnpmPeerDependencyRulesSatisfyVitePlus(readPnpmWorkspacePeerDependencyRules(projectPath), usesVitest)) rewritePnpmWorkspaceYaml(projectPath, pnpmMajorVersion, shouldAllowBrowserBuilds, usesVitest, vitestEcosystemPackages, true, providerCatalogAdditions);
8126
- if (fs.existsSync(pnpmWorkspaceYamlPath)) ensurePnpmWorkspacePackages(projectPath, workspaceInfo.workspacePatterns);
8127
- result.packageManagerConfig = before !== readTextFileIfExists(pnpmWorkspaceYamlPath);
8128
- } else {
8129
- const exoticChanged = ensurePnpmWorkspaceExoticSubdepsSetting(projectPath);
8130
- if (fs.existsSync(pnpmWorkspaceYamlPath)) ensurePnpmWorkspacePackages(projectPath, workspaceInfo.workspacePatterns);
8131
- const after = readTextFileIfExists(pnpmWorkspaceYamlPath);
8132
- result.packageManagerConfig = exoticChanged || pnpmWorkspaceCatalogBefore !== after;
8133
- }
8134
- else if (workspaceInfo.packageManager === PackageManager.yarn) {
8595
+ if (workspaceInfo.packageManager === PackageManager.pnpm) {
8596
+ if (usePnpmWorkspaceYaml) {
8597
+ const before = readTextFileIfExists(pnpmWorkspaceYamlPath);
8598
+ migratePnpmSettingsToWorkspaceYaml(projectPath, movedPnpmSettings);
8599
+ const catalogDependencyResolver = readPnpmWorkspaceCatalogDependencyResolver(projectPath);
8600
+ if (movedPnpmSettings !== void 0 || result.packageJson || ecosystemCatalogReferencesPending || !pnpmWorkspaceExoticSubdepsSettingSatisfied(projectPath) || pnpmWorkspaceMinimumReleaseAgeExemptionsPending(projectPath) || workspaceCatalogVitePlusDependencyPending(projectPath, workspaceInfo.packages, catalogDependencyResolver) || !overridesSatisfyVitePlus(readPnpmWorkspaceOverrides(projectPath), usesVitest, catalogDependencyResolver, "pnpm-ranged") || !pnpmPeerDependencyRulesSatisfyVitePlus(readPnpmWorkspacePeerDependencyRules(projectPath), usesVitest)) rewritePnpmWorkspaceYaml(projectPath, pnpmMajorVersion, shouldAllowBrowserBuilds, usesVitest, vitestEcosystemPackages, true, providerCatalogAdditions);
8601
+ if (fs.existsSync(pnpmWorkspaceYamlPath)) ensurePnpmWorkspacePackages(projectPath, workspaceInfo.workspacePatterns);
8602
+ result.packageManagerConfig = before !== readTextFileIfExists(pnpmWorkspaceYamlPath);
8603
+ } else {
8604
+ const exoticChanged = ensurePnpmWorkspaceExoticSubdepsSetting(projectPath);
8605
+ if (fs.existsSync(pnpmWorkspaceYamlPath)) ensurePnpmWorkspacePackages(projectPath, workspaceInfo.workspacePatterns);
8606
+ const after = readTextFileIfExists(pnpmWorkspaceYamlPath);
8607
+ result.packageManagerConfig = exoticChanged || pnpmWorkspaceCatalogBefore !== after;
8608
+ }
8609
+ } else if (workspaceInfo.packageManager === PackageManager.yarn) {
8135
8610
  const yarnrcYmlPath = path.join(projectPath, ".yarnrc.yml");
8136
8611
  const before = readTextFileIfExists(yarnrcYmlPath);
8137
8612
  rewriteYarnrcYml(projectPath, usesVitest, vitestEcosystemPackages, providerCatalogAdditions, supportCatalog);
@@ -8625,16 +9100,48 @@ function rewriteAllImports(projectPath, silent = false, report, preserveNuxtVite
8625
9100
  log.success(`Rewrote imports in ${modified === 1 ? "one file" : `${modified} files`}`);
8626
9101
  log.info(result.modifiedFiles.map((file) => ` ${displayRelative(file)}`).join("\n"));
8627
9102
  }
8628
- if (errors > 0) if (report) warnMigration(`${errors === 1 ? "one file had an error" : `${errors} files had errors`} while rewriting imports`, report);
8629
- else {
8630
- log.warn(`⚠ ${errors === 1 ? "one file had an error" : `${errors} files had errors`}:`);
8631
- for (const error of result.errors) log.error(` ${displayRelative(error.path)}: ${error.message}`);
9103
+ if (errors > 0) {
9104
+ if (report) warnMigration(`${errors === 1 ? "one file had an error" : `${errors} files had errors`} while rewriting imports`, report);
9105
+ else {
9106
+ log.warn(`⚠ ${errors === 1 ? "one file had an error" : `${errors} files had errors`}:`);
9107
+ for (const error of result.errors) log.error(` ${displayRelative(error.path)}: ${error.message}`);
9108
+ }
8632
9109
  }
8633
9110
  return modified > 0;
8634
9111
  }
8635
9112
  //#endregion
8636
- //#region src/migration/migrator/git-hooks.ts
9113
+ //#region src/utils/git.ts
8637
9114
  var import_cross_spawn = /* @__PURE__ */ __toESM(require_cross_spawn(), 1);
9115
+ /**
9116
+ * Walk up from `startPath` looking for `.git` (directory or file — submodules
9117
+ * use a `.git` file). Returns the directory that contains `.git`, or `null`.
9118
+ */
9119
+ function findGitRoot(startPath) {
9120
+ let dir = startPath;
9121
+ while (true) {
9122
+ if (fs.existsSync(path.join(dir, ".git"))) return dir;
9123
+ const parent = path.dirname(dir);
9124
+ if (parent === dir) return null;
9125
+ dir = parent;
9126
+ }
9127
+ }
9128
+ async function initGitRepository(cwd) {
9129
+ const result = await runCommandSilently({
9130
+ command: "git",
9131
+ args: ["init"],
9132
+ cwd,
9133
+ envs: process.env
9134
+ });
9135
+ if (result.exitCode !== 0) {
9136
+ log.warn("Failed to initialize git repository");
9137
+ const stderr = result.stderr.toString().trim();
9138
+ if (stderr) log.info(stderr);
9139
+ return false;
9140
+ }
9141
+ return true;
9142
+ }
9143
+ //#endregion
9144
+ //#region src/migration/migrator/git-hooks.ts
8638
9145
  const OTHER_HOOK_TOOLS = [
8639
9146
  "simple-git-hooks",
8640
9147
  "lefthook",
@@ -8669,19 +9176,6 @@ function findNonRegularViteHookPath(projectPath) {
8669
9176
  }
8670
9177
  return null;
8671
9178
  }
8672
- /**
8673
- * Walk up from `startPath` looking for `.git` (directory or file — submodules
8674
- * use a `.git` file). Returns the directory that contains `.git`, or `null`.
8675
- */
8676
- function findGitRoot(startPath) {
8677
- let dir = startPath;
8678
- while (true) {
8679
- if (fs.existsSync(path.join(dir, ".git"))) return dir;
8680
- const parent = path.dirname(dir);
8681
- if (parent === dir) return null;
8682
- dir = parent;
8683
- }
8684
- }
8685
9179
  function findWorkspacePackageHookPolicy(workspaceRoot, packages) {
8686
9180
  for (const pkg of packages) {
8687
9181
  const packagePath = path.join(workspaceRoot, pkg.path);
@@ -8912,7 +9406,7 @@ const NODE_VERSION_FILE_NVMRC_RE = /(node-version-file:[ \t]*)(['"]?)(\.\/)?\.nv
8912
9406
  * Collect GitHub Actions YAML files that may carry a `node-version-file:`
8913
9407
  * reference: top-level workflows (`.github/workflows/*.{yml,yaml}`, which GitHub
8914
9408
  * runs only when flat in that directory) and composite action definitions
8915
- * (`.github/actions/**​/action.{yml,yaml}`, which may nest at any depth). Returns
9409
+ * (`.github/actions/**\/action.{yml,yaml}`, which may nest at any depth). Returns
8916
9410
  * absolute paths; a missing `.github` tree just yields an empty list. `nocase`
8917
9411
  * keeps the match case-insensitive on case-sensitive filesystems.
8918
9412
  */
@@ -8996,10 +9490,26 @@ function readRulesYaml() {
8996
9490
  cachedRulesYaml ??= fs.readFileSync(RULES_YAML_PATH, "utf8");
8997
9491
  return cachedRulesYaml;
8998
9492
  }
9493
+ function splitRuleDocuments(yaml) {
9494
+ const lines = yaml.split("\n");
9495
+ const documents = [];
9496
+ let start = 0;
9497
+ for (const [index, line] of lines.entries()) {
9498
+ if (line.trimEnd() !== "---") continue;
9499
+ let documentStart = index;
9500
+ while (documentStart > start && lines[documentStart - 1].trimStart().startsWith("#")) documentStart--;
9501
+ if (documentStart > start) {
9502
+ documents.push(lines.slice(start, documentStart).join("\n"));
9503
+ start = documentStart;
9504
+ }
9505
+ }
9506
+ documents.push(lines.slice(start).join("\n"));
9507
+ return documents;
9508
+ }
8999
9509
  function getScriptRulesYaml(skipStagedMigration) {
9000
9510
  const yaml = readRulesYaml();
9001
9511
  if (!skipStagedMigration) return yaml;
9002
- cachedRulesYamlNoLintStaged ??= yaml.split("\n\n\n").filter((block) => !block.includes("id: replace-lint-staged")).join("\n\n\n");
9512
+ cachedRulesYamlNoLintStaged ??= splitRuleDocuments(yaml).filter((document) => !document.includes("id: replace-lint-staged")).join("\n");
9003
9513
  return cachedRulesYamlNoLintStaged;
9004
9514
  }
9005
9515
  function getCoreMigrationProjectPaths(workspaceInfo) {
@@ -9098,16 +9608,12 @@ function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigratio
9098
9608
  if (!usePnpmWorkspaceYaml) {
9099
9609
  dropRemovePackageOverrideKeys(pkg.pnpm?.overrides);
9100
9610
  if (!usesVitest) {
9101
- removeManagedVitestEntry(pkg.pnpm?.overrides);
9611
+ removeManagedVitestEntry(pkg.pnpm?.overrides, "pnpm-ranged");
9102
9612
  if (pkg.pnpm?.peerDependencyRules) removeVitestPeerDependencyRule(pkg.pnpm.peerDependencyRules);
9103
9613
  }
9104
9614
  pkg.pnpm = {
9105
9615
  ...pkg.pnpm,
9106
- overrides: {
9107
- ...pkg.pnpm?.overrides,
9108
- ...managed,
9109
- ...isForceOverrideMode() ? { [VITE_PLUS_NAME]: VITE_PLUS_VERSION } : {}
9110
- },
9616
+ overrides: mergeManagedPnpmOverrides(pkg.pnpm?.overrides, managed),
9111
9617
  peerDependencyRules: {
9112
9618
  ...pkg.pnpm?.peerDependencyRules,
9113
9619
  allowAny: [.../* @__PURE__ */ new Set([...pkg.pnpm?.peerDependencyRules?.allowAny ?? [], ...overrideKeys])],
@@ -9236,7 +9742,8 @@ const VSCODE_SETTINGS = {
9236
9742
  "[javascriptreact]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
9237
9743
  "[typescript]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
9238
9744
  "[typescriptreact]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
9239
- "oxc.fmt.configPath": "./vite.config.ts",
9745
+ "oxc.disableNestedConfig": true,
9746
+ "oxc.fmt.disableNestedConfig": true,
9240
9747
  "editor.formatOnSave": true,
9241
9748
  "editor.formatOnSaveMode": "file",
9242
9749
  "editor.codeActionsOnSave": { "source.fixAll.oxc": "explicit" }
@@ -9280,19 +9787,68 @@ const ZED_SETTINGS = {
9280
9787
  ...language === "JavaScript" ? { code_action: "source.fixAll.oxc" } : {}
9281
9788
  }]))
9282
9789
  };
9283
- const EDITORS = [{
9284
- id: "vscode",
9285
- label: "VSCode",
9286
- targetDir: ".vscode",
9287
- files: {
9288
- "settings.json": VSCODE_SETTINGS,
9289
- "extensions.json": VSCODE_EXTENSIONS
9790
+ const JETBRAINS_EXTERNAL_DEPENDENCIES = `<?xml version="1.0" encoding="UTF-8"?>
9791
+ <project version="4">
9792
+ <component name="ExternalDependencies">
9793
+ <plugin id="com.github.oxc.project.oxcintellijplugin" />
9794
+ </component>
9795
+ </project>
9796
+ `;
9797
+ function jetbrainsNodeInterpreterPath() {
9798
+ return path.join(getVpDirs().bin, process.platform === "win32" ? "node.exe" : "node");
9799
+ }
9800
+ function jetbrainsWorkspaceConfig(packageManager) {
9801
+ return `<?xml version="1.0" encoding="UTF-8"?>
9802
+ <project version="4">
9803
+ <component name="PropertiesComponent">
9804
+ <![CDATA[${JSON.stringify({ keyToString: {
9805
+ "javascript.preferred.runtime.type.id": "node",
9806
+ nodejs_interpreter_path: jetbrainsNodeInterpreterPath(),
9807
+ nodejs_package_manager_path: packageManager
9808
+ } }, null, 2)}]]>
9809
+ </component>
9810
+ </project>
9811
+ `;
9812
+ }
9813
+ const EDITORS = [
9814
+ {
9815
+ id: "vscode",
9816
+ label: "VSCode",
9817
+ targetDir: ".vscode",
9818
+ files: {
9819
+ "settings.json": VSCODE_SETTINGS,
9820
+ "extensions.json": VSCODE_EXTENSIONS
9821
+ }
9822
+ },
9823
+ {
9824
+ id: "zed",
9825
+ label: "Zed",
9826
+ targetDir: ".zed",
9827
+ files: { "settings.json": ZED_SETTINGS }
9828
+ },
9829
+ {
9830
+ id: "jetbrains",
9831
+ label: "JetBrains (IntelliJ, WebStorm, etc)",
9832
+ targetDir: ".idea",
9833
+ files: {
9834
+ "externalDependencies.xml": JETBRAINS_EXTERNAL_DEPENDENCIES,
9835
+ "workspace.xml": jetbrainsWorkspaceConfig(PackageManager.pnpm),
9836
+ "OxfmtSettings.xml": `<?xml version="1.0" encoding="UTF-8"?>
9837
+ <project version="4">
9838
+ <component name="OxfmtSettings">
9839
+ <option name="preferOxfmtCodeStyleSettings" value="true" />
9840
+ </component>
9841
+ </project>
9842
+ `
9843
+ }
9290
9844
  }
9845
+ ];
9846
+ const EDITOR_ALIASES = [{
9847
+ id: "intellij",
9848
+ alias: "jetbrains"
9291
9849
  }, {
9292
- id: "zed",
9293
- label: "Zed",
9294
- targetDir: ".zed",
9295
- files: { "settings.json": ZED_SETTINGS }
9850
+ id: "webstorm",
9851
+ alias: "jetbrains"
9296
9852
  }];
9297
9853
  async function selectEditor({ interactive, editor, onCancel }) {
9298
9854
  if (editor === false) return;
@@ -9374,7 +9930,7 @@ function detectEditorConflicts({ projectRoot, editorId }) {
9374
9930
  }
9375
9931
  return conflicts;
9376
9932
  }
9377
- async function writeEditorConfigs({ projectRoot, editorId, interactive, conflictDecisions, silent = false, extraVsCodeSettings }) {
9933
+ async function writeEditorConfigs({ projectRoot, editorId, interactive, conflictDecisions, silent = false, extraVsCodeSettings, packageManager = PackageManager.pnpm }) {
9378
9934
  const editorIds = normalizeEditorSelection(editorId);
9379
9935
  if (editorIds.length === 0) return;
9380
9936
  for (const currentEditorId of editorIds) await writeEditorConfig({
@@ -9383,10 +9939,11 @@ async function writeEditorConfigs({ projectRoot, editorId, interactive, conflict
9383
9939
  interactive,
9384
9940
  conflictDecisions,
9385
9941
  silent,
9386
- extraVsCodeSettings
9942
+ extraVsCodeSettings,
9943
+ packageManager
9387
9944
  });
9388
9945
  }
9389
- async function writeEditorConfig({ projectRoot, editorId, interactive, conflictDecisions, silent, extraVsCodeSettings }) {
9946
+ async function writeEditorConfig({ projectRoot, editorId, interactive, conflictDecisions, silent, extraVsCodeSettings, packageManager }) {
9390
9947
  const editorConfig = EDITORS.find((e) => e.id === editorId);
9391
9948
  if (!editorConfig) return;
9392
9949
  const targetDir = path.join(projectRoot, editorConfig.targetDir);
@@ -9395,8 +9952,9 @@ async function writeEditorConfig({ projectRoot, editorId, interactive, conflictD
9395
9952
  const incoming = editorId === "vscode" && fileName === "settings.json" && extraVsCodeSettings ? {
9396
9953
  ...extraVsCodeSettings,
9397
9954
  ...baseIncoming
9398
- } : baseIncoming;
9955
+ } : editorId === "jetbrains" && fileName === "workspace.xml" ? jetbrainsWorkspaceConfig(packageManager) : baseIncoming;
9399
9956
  const filePath = path.join(targetDir, fileName);
9957
+ const jsonFormat = isJsonLikeFile(fileName);
9400
9958
  if (fs.existsSync(filePath)) {
9401
9959
  const displayPath = `${editorConfig.targetDir}/${fileName}`;
9402
9960
  let conflictAction;
@@ -9404,11 +9962,11 @@ async function writeEditorConfig({ projectRoot, editorId, interactive, conflictD
9404
9962
  if (preResolved) conflictAction = preResolved;
9405
9963
  else if (interactive) {
9406
9964
  const action = await select({
9407
- message: `${displayPath} already exists.\n ` + styleText("gray", `Vite+ adds ${editorConfig.label} settings for the built-in linter and formatter. Merge adds new keys without overwriting existing ones.`),
9965
+ message: `${displayPath} already exists.\n ` + styleText("gray", jsonFormat ? `Vite+ adds ${editorConfig.label} settings for the built-in linter and formatter. Merge adds new keys without overwriting existing ones.` : `Vite+ adds ${editorConfig.label} settings for the built-in linter and formatter. Overwrite replaces the existing file with the generated config.`),
9408
9966
  options: [{
9409
- label: "Merge",
9967
+ label: jsonFormat ? "Merge" : "Overwrite",
9410
9968
  value: "merge",
9411
- hint: "Merge new settings into existing file"
9969
+ hint: jsonFormat ? "Merge new settings into existing file" : "Replace existing file with generated config"
9412
9970
  }, {
9413
9971
  label: "Skip",
9414
9972
  value: "skip",
@@ -9417,15 +9975,34 @@ async function writeEditorConfig({ projectRoot, editorId, interactive, conflictD
9417
9975
  initialValue: "skip"
9418
9976
  });
9419
9977
  conflictAction = isCancel(action) || action === "skip" ? "skip" : "merge";
9420
- } else conflictAction = "merge";
9421
- if (conflictAction === "merge") mergeAndWriteEditorConfig(filePath, incoming, fileName, displayPath, silent);
9422
- else if (!silent) log.info(`Skipped writing ${displayPath}`);
9978
+ } else conflictAction = jsonFormat ? "merge" : "skip";
9979
+ if (conflictAction === "merge") {
9980
+ if (jsonFormat) {
9981
+ if (!isPlainObject(incoming)) throw new Error(`Cannot merge editor config: ${displayPath} incoming value is not JSON`);
9982
+ mergeAndWriteEditorConfig(filePath, incoming, fileName, displayPath, silent);
9983
+ } else writeTextEditorConfig(filePath, incoming, displayPath, silent);
9984
+ } else if (!silent) log.info(`Skipped writing ${displayPath}`);
9423
9985
  continue;
9424
9986
  }
9425
- writeJsonFile(filePath, incoming);
9987
+ if (jsonFormat) {
9988
+ if (!isPlainObject(incoming)) throw new Error(`Cannot write editor config: ${editorConfig.targetDir}/${fileName} must be JSON`);
9989
+ writeJsonFile(filePath, incoming);
9990
+ } else writeTextEditorConfig(filePath, incoming, `${editorConfig.targetDir}/${fileName}`, silent);
9426
9991
  if (!silent) log.success(`Wrote editor config to ${editorConfig.targetDir}/${fileName}`);
9427
9992
  }
9428
9993
  }
9994
+ function isJsonLikeFile(fileName) {
9995
+ const ext = path.extname(fileName).toLowerCase();
9996
+ return ext === ".json" || ext === ".jsonc";
9997
+ }
9998
+ function writeTextEditorConfig(filePath, incoming, displayPath, silent = false) {
9999
+ if (typeof incoming !== "string") throw new Error(`Cannot write editor config: ${displayPath} must be text content`);
10000
+ if ((fs.existsSync(filePath) ? fs.readFileSync(filePath, "utf-8") : void 0) === incoming) {
10001
+ if (!silent) log.info(`No changes needed for ${displayPath}`);
10002
+ return;
10003
+ }
10004
+ fs.writeFileSync(filePath, incoming, "utf-8");
10005
+ }
9429
10006
  function normalizeEditorSelection(editorId) {
9430
10007
  if (!editorId) return [];
9431
10008
  return [...new Set(Array.isArray(editorId) ? editorId : [editorId])];
@@ -9497,7 +10074,13 @@ function mergeExtensionsText(text, existing, incoming, formattingOptions) {
9497
10074
  }
9498
10075
  function resolveEditorId(editor) {
9499
10076
  const normalized = editor.trim().toLowerCase();
9500
- return EDITORS.find((option) => option.id === normalized || option.label.toLowerCase() === normalized)?.id;
10077
+ const match = EDITORS.find((option) => option.id === normalized || option.label.toLowerCase() === normalized);
10078
+ if (match) return match.id;
10079
+ const aliasMatch = EDITOR_ALIASES.find((option) => option.id === normalized);
10080
+ if (aliasMatch) {
10081
+ log.warn(`--editor ${aliasMatch.id} was passed; use --editor ${aliasMatch.alias} instead, as it's the canonical ID for that editor.`);
10082
+ return aliasMatch.alias;
10083
+ }
9501
10084
  }
9502
10085
  function resolveEditorIds(editors) {
9503
10086
  const editorIds = editors.flatMap((editor) => {
@@ -9508,4 +10091,4 @@ function resolveEditorIds(editors) {
9508
10091
  return uniqueEditorIds.length === 0 ? void 0 : uniqueEditorIds;
9509
10092
  }
9510
10093
  //#endregion
9511
- export { addFrameworkShim as A, detectIncompatibleEslintIntegration as B, ensureVitePlusBootstrap as C, isBingoTemplate as D, detectWorkspace$1 as E, migratePrettierToOxfmt as F, warnPackageLevelEslint as G, promptEslintMigration as H, promptPrettierMigration as I, checkViteVersion as K, warnPackageLevelPrettier as L, hasFrameworkShim as M, confirmPrettierMigration as N, updatePackageJsonWithDeps as O, detectPrettierProject as P, confirmEslintMigration as R, detectVitePlusBootstrapPending as S, detectYarnPnpMode as T, warnIncompatibleEslintIntegration as U, migrateEslintToOxlint as V, warnLegacyEslintConfig as W, shouldSkipStagedMigrationForHooks as _, writeEditorConfigs as a, mergeViteConfigFiles as b, rewriteStandaloneProject as c, detectNodeVersionManagerFile as d, migrateNodeVersionManagerFile as f, preflightGitHooksSetup as g, installGitHooks as h, selectEditors as i, detectFramework as j, updateWorkspaceConfig as k, detectPendingCoreMigration as l, detectLegacyGitHooksMigrationCandidate as m, detectExistingEditors as n, rewriteMonorepo as o, setPackageManager as p, checkVitestVersion as q, selectEditor as r, rewriteMonorepoProject as s, detectEditorConflicts as t, finalizeCoreMigrationForExistingVitePlus as u, injectCreateDefaultTemplate as v, configureYarnNodeModulesMode as w, collectToolchainVersionChanges as x, injectLintTypeCheckDefaults as y, detectEslintProject as z };
10094
+ export { warnLegacyEslintConfig as $, detectWorkspace$1 as A, promptTsupMigration as B, mergeTsdownConfigFile as C, ensureVitePlusBootstrap as D, detectVitePlusBootstrapPending as E, detectFramework as F, promptPrettierMigration as G, confirmPrettierMigration as H, hasFrameworkShim as I, detectEslintProject as J, warnPackageLevelPrettier as K, confirmTsupMigration as L, updatePackageJsonWithDeps as M, updateWorkspaceConfig as N, configureYarnNodeModulesMode as O, addFrameworkShim as P, warnIncompatibleEslintIntegration as Q, detectTsupProject as R, injectLintTypeCheckDefaults as S, collectToolchainVersionChanges as T, detectPrettierProject as U, warnMissingTsupConfig as V, migratePrettierToOxfmt as W, migrateEslintToOxlint as X, detectIncompatibleEslintIntegration as Y, promptEslintMigration as Z, preflightGitHooksSetup as _, selectEditors as a, initGitRepository as b, rewriteMonorepoProject as c, finalizeCoreMigrationForExistingVitePlus as d, warnPackageLevelEslint as et, detectNodeVersionManagerFile as f, installGitHooks as g, detectLegacyGitHooksMigrationCandidate as h, selectEditor as i, isBingoTemplate as j, detectYarnPnpMode as k, rewriteStandaloneProject as l, setPackageManager as m, detectExistingEditors as n, checkVitestVersion as nt, writeEditorConfigs as o, migrateNodeVersionManagerFile as p, confirmEslintMigration as q, isJsonLikeFile as r, rewriteMonorepo as s, detectEditorConflicts as t, checkViteVersion as tt, detectPendingCoreMigration as u, shouldSkipStagedMigrationForHooks as v, mergeViteConfigFiles as w, injectCreateDefaultTemplate as x, findGitRoot as y, migrateTsupToTsdown as z };