vite-plus 0.2.9 → 0.3.1
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.
- package/LICENSE +29 -29
- package/README.md +6 -5
- package/binding/index.cjs +63 -55
- package/binding/index.d.cts +218 -14
- package/dist/{agent-DQU8uS6P.js → agent-C5jMYVfB.js} +3 -2
- package/dist/bin.js +101 -60
- package/dist/cli-parse-DHE8NrBU.js +13 -0
- package/dist/client/bundledDevClient.mjs +1 -1
- package/dist/client/client.mjs +1 -1
- package/dist/client/env.mjs +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/command-CLJK5jGW.js +2 -0
- package/dist/command-CguLh2KL.js +471 -0
- package/dist/config/bin.js +85 -55
- package/dist/{constants-CG513DRa.js → constants-0IAVgpox.js} +5 -3
- package/dist/create/bin.d.ts +13 -5
- package/dist/create/bin.js +55 -232
- package/dist/{define-config-DyNLA_f0.cjs → define-config-DIE9de46.cjs} +2 -2
- package/dist/{define-config-DWoAkNdp.d.ts → define-config-DPNEJxPz.d.ts} +5 -9
- package/dist/{define-config-CV4bQG_8.js → define-config-U3_xg7i-.js} +2 -2
- package/dist/define-config.cjs +1 -1
- package/dist/define-config.d.ts +1 -1
- package/dist/define-config.js +1 -1
- package/dist/dist-DfmT__Aw.js +619 -0
- package/dist/{editor-g4PosU99.js → editor-B5-lvRaU.js} +619 -88
- package/dist/{terminal-Bz-ps6rJ.js → help-BmKpeOP9.js} +1 -38
- package/dist/hooks/bin.js +9 -113
- package/dist/{hooks-pNCBWtFT.js → hooks-C-4gykWR.js} +5 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/dist/migration/bin.js +76 -146
- package/dist/migration/compat/worker.js +1 -1
- package/dist/module-runner.d.ts +1 -1
- package/dist/module-runner.js +1 -1
- package/dist/{oxlint-plugin-config-BEZ9IUf7.js → oxlint-plugin-config-Drdl67Xp.js} +1 -1
- package/dist/oxlint-plugin.d.ts +2 -2
- package/dist/oxlint-plugin.js +1 -1
- package/dist/{pack-PvUg_xpv.d.ts → pack-BK38MLVZ.d.ts} +1 -1
- package/dist/pack-bin.d.ts +2 -3
- package/dist/pack-bin.js +9 -625
- package/dist/pack-client.d.ts +1 -1
- package/dist/pack.d.ts +2 -2
- package/dist/pack.js +1 -1
- package/dist/{package-B4T8RGMG.js → package-BZz2Ij68.js} +2 -2
- package/dist/{prompts-CHz_98bJ.js → prompts-CtzEgFY-.js} +7 -1872
- package/dist/{report-BS7ULx7A.js → report-CK5TnTsr.js} +2 -0
- package/dist/{resolve-vite-config-Dmeyeyj-.js → resolve-vite-config-CGks1xR7.js} +3 -3
- package/dist/resolve-vite-config-Dnmc-lBc.js +2 -0
- package/dist/semver-CaDAb8vV.js +1400 -0
- package/dist/staged/bin.js +82 -187
- package/dist/sync-versions/bin.d.ts +1 -0
- package/dist/sync-versions/bin.js +3884 -0
- package/dist/sync-versions/bin.mjs +13323 -0
- package/dist/terminal-MKGAuy-p.js +39 -0
- package/dist/toolchain.js +11 -11
- package/dist/toolchain.json +11 -11
- package/dist/{tsconfig-7v_BHagU.js → tsconfig-CUggNuJR.js} +5 -4
- package/dist/tsconfig-VAbm4ZzJ.js +2 -0
- package/dist/tsgolint-path.d.ts +3 -4
- package/dist/types/customEvent.d.ts +1 -1
- package/dist/types/hmrPayload.d.ts +1 -1
- package/dist/types/hot.d.ts +1 -1
- package/dist/types/import-meta.d.ts +1 -1
- package/dist/types/importGlob.d.ts +1 -1
- package/dist/types/importMeta.d.ts +1 -1
- package/dist/types/metadata.d.ts +1 -1
- package/dist/version.d.ts +2 -3
- package/dist/version.js +4 -3
- package/dist/versions.js +6 -6
- package/dist/vitest-ecosystem-BiRqcaRI.js +23 -0
- package/docs/guide/check.md +1 -0
- package/docs/guide/ci.md +42 -2
- package/docs/guide/env.md +136 -50
- package/docs/guide/ide-integration.md +14 -2
- package/docs/guide/index.md +1 -1
- package/docs/guide/install.md +5 -2
- package/docs/guide/installer-env-vars.md +51 -5
- package/docs/guide/migrate-rules.md +66 -2
- package/docs/guide/migrate.md +5 -5
- package/docs/guide/test.md +8 -0
- package/docs/guide/upgrade.md +48 -1
- package/package.json +34 -37
- package/dist/lib-L3DWSRQp.js +0 -75
- package/docs/_data/team.ts +0 -131
- package/docs/package.json +0 -30
- package/docs/pnpm-lock.yaml +0 -4003
- package/docs/pnpm-workspace.yaml +0 -13
- package/docs/public/checkmark.svg +0 -1
- package/docs/public/cta-background.jpg +0 -0
- package/docs/public/favicon.svg +0 -1
- package/docs/public/icon.svg +0 -1
- package/docs/public/logo.svg +0 -1
- package/docs/public/og.jpg +0 -0
- package/docs/vite.config.ts +0 -20
- package/dist/{json-qlK6UH0r.js → json-cULBl7Pi.js} +107 -107
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import { r as __toESM } from "./rolldown-runtime-CMFfr-1z.js";
|
|
2
|
-
import { a as
|
|
3
|
-
import { i as ensureVitePlusImportRuleDefaults, r as createDefaultVitePlusLintConfig } from "./oxlint-plugin-config-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { a as SETUP_VP_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-0IAVgpox.js";
|
|
3
|
+
import { i as ensureVitePlusImportRuleDefaults, r as createDefaultVitePlusLintConfig } from "./oxlint-plugin-config-Drdl67Xp.js";
|
|
4
|
+
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";
|
|
5
|
+
import { n as detectPackageMetadata, r as getScopeFromPackageName } from "./package-BZz2Ij68.js";
|
|
6
|
+
import { C as multiselect, S as log, T as select, _ as getSpinner, b as confirm, d as readYamlFile, f as scalarString, g as getSilentSpinner, k as isCancel, t as cancelAndExit, u as editYamlFile, y as PackageManager } from "./prompts-CtzEgFY-.js";
|
|
7
|
+
import { t as require_semver } from "./semver-CaDAb8vV.js";
|
|
8
|
+
import { l as displayRelative, u as rulesDir } from "./agent-C5jMYVfB.js";
|
|
9
|
+
import { n as addMigrationWarning, t as addManualStep } from "./report-CK5TnTsr.js";
|
|
10
|
+
import { n as runCommandSilently, r as require_cross_spawn } from "./command-CguLh2KL.js";
|
|
6
11
|
import { t as require_dist } from "./dist-BDYZP12R.js";
|
|
7
|
-
import { a as
|
|
8
|
-
import { n as
|
|
9
|
-
import {
|
|
10
|
-
import { n as addMigrationWarning, t as addManualStep } from "./report-BS7ULx7A.js";
|
|
11
|
-
import { a as findUnsafeHookInstallPath, n as SUPPORTED_GIT_HOOK_NAMES } from "./hooks-pNCBWtFT.js";
|
|
12
|
+
import { a as hasBaseUrlInTsconfig, c as hasVitestTypesInTsconfig, l as removeDeprecatedTsconfigFalseOption, n as findTsconfigFiles, s as hasTypesToRewriteInTsconfig, u as rewriteTypesInTsconfig } from "./tsconfig-CUggNuJR.js";
|
|
13
|
+
import { n as extractOverrideTargetName, t as isAlignableVitestEcosystemPackage } from "./vitest-ecosystem-BiRqcaRI.js";
|
|
14
|
+
import { i as findUnsafeHookInstallPath, t as SUPPORTED_GIT_HOOK_NAMES } from "./hooks-C-4gykWR.js";
|
|
12
15
|
import path, { posix, win32 } from "node:path";
|
|
13
16
|
import { fileURLToPath } from "node:url";
|
|
14
|
-
import { detectWorkspace, hasConfigKey, mergeJsonConfig, mergeTsdownConfig, rewriteEslint, rewriteImportsInDirectory, rewritePrettier, rewriteScripts, wrapLazyPlugins } from "../binding/index.js";
|
|
17
|
+
import { detectWorkspace, getVpDirs, hasConfigKey, mergeJsonConfig, mergeTsdownConfig, rewriteEslint, rewriteImportsInDirectory, rewritePrettier, rewriteScripts, wrapLazyPlugins } from "../binding/index.js";
|
|
15
18
|
import { styleText } from "node:util";
|
|
16
19
|
import * as actualFS from "node:fs";
|
|
17
20
|
import fs from "node:fs";
|
|
18
21
|
import os from "node:os";
|
|
19
|
-
import { lstatSync as lstatSync$1, readdir, readdirSync as readdirSync$1, readlinkSync, realpathSync as realpathSync$1 } from "fs";
|
|
20
22
|
import "oxlint";
|
|
23
|
+
import { lstatSync as lstatSync$1, readdir, readdirSync as readdirSync$1, readlinkSync, realpathSync as realpathSync$1 } from "fs";
|
|
24
|
+
import corePkg from "vite/package.json" with { type: "json" };
|
|
21
25
|
import fsPromises, { lstat, readdir as readdir$1, readlink, realpath } from "node:fs/promises";
|
|
22
26
|
import { EventEmitter } from "node:events";
|
|
23
27
|
import Stream from "node:stream";
|
|
@@ -82,6 +86,48 @@ const VITEST_BROWSER_DEP_NAMES = [
|
|
|
82
86
|
];
|
|
83
87
|
const VITEST_IS_MANAGED_OVERRIDE = "vitest" in VITE_PLUS_OVERRIDE_PACKAGES;
|
|
84
88
|
const LEGACY_WRAPPER_FALLBACK_VERSIONS = { vitest: VITEST_VERSION };
|
|
89
|
+
/**
|
|
90
|
+
* Managed pnpm override keys use an explicit `@*` range, not a bare package
|
|
91
|
+
* name: `vite@*`, not `vite`.
|
|
92
|
+
*
|
|
93
|
+
* pnpm applies overrides through a read-package hook. The hook replaces the
|
|
94
|
+
* declared spec on every manifest, importer manifests included, before
|
|
95
|
+
* resolution runs. A bare override key has no range, and pnpm treats a key with
|
|
96
|
+
* no range as a match for every declared spec. That includes `catalog:`. An
|
|
97
|
+
* importer that declares `vite: "catalog:"` therefore loses its link to the
|
|
98
|
+
* catalog during resolution, and `pnpm update` then writes the resolved core
|
|
99
|
+
* alias into that importer's package.json (issue #2309).
|
|
100
|
+
*
|
|
101
|
+
* The `@*` range keeps the override on the declared semver ranges that
|
|
102
|
+
* transitive and peer `vite` declarations use. Those declarations are the
|
|
103
|
+
* reason this override exists. The range leaves `catalog:` specs alone, because
|
|
104
|
+
* `catalog:` is not a valid semver range, so pnpm's `isIntersectingRange`
|
|
105
|
+
* rejects it before it compares anything. The installed result does not change:
|
|
106
|
+
* an importer that references the catalog already resolves to the aliased core
|
|
107
|
+
* through its catalog entry.
|
|
108
|
+
*
|
|
109
|
+
* Known gap on pnpm 9 to 11: a declaration that pins an EXACT prerelease, such
|
|
110
|
+
* as `vite: "8.0.0-beta.18"`, escapes the override. pnpm compares with
|
|
111
|
+
* `semver.intersects(declaredSpec, keyRange)`. That call is asymmetric for
|
|
112
|
+
* prereleases: it returns false for an exact prerelease against a wildcard
|
|
113
|
+
* range. The reversed argument order returns true. No range string avoids
|
|
114
|
+
* this, because node-semver only admits a prerelease when a comparator carries
|
|
115
|
+
* the same version tuple. A prerelease RANGE such as `^8.0.0-beta.1` still
|
|
116
|
+
* matches. pnpm 12 matches the exact form too. A bare key would cover this
|
|
117
|
+
* case, but a bare key is what clobbers `catalog:` specs. Below pnpm 12,
|
|
118
|
+
* prerelease coverage and `catalog:` safety cannot both hold.
|
|
119
|
+
*
|
|
120
|
+
* This applies to pnpm only. npm and bun `overrides`, and yarn `resolutions`,
|
|
121
|
+
* keep bare keys. Those package managers have no `catalog:` importer specs to
|
|
122
|
+
* lose. Bun catalogs live in package.json, and bun resolves them before it
|
|
123
|
+
* applies overrides.
|
|
124
|
+
*/
|
|
125
|
+
function pnpmOverrideKey(dependencyName) {
|
|
126
|
+
return `${dependencyName}@*`;
|
|
127
|
+
}
|
|
128
|
+
function managedOverrideKey(dependencyName, keyStyle) {
|
|
129
|
+
return keyStyle === "pnpm-ranged" ? pnpmOverrideKey(dependencyName) : dependencyName;
|
|
130
|
+
}
|
|
85
131
|
function warnMigration(message, report) {
|
|
86
132
|
addMigrationWarning(report, message);
|
|
87
133
|
if (!report) log.warn(message);
|
|
@@ -132,6 +178,16 @@ function pnpmMajor(version) {
|
|
|
132
178
|
//#endregion
|
|
133
179
|
//#region src/migration/detector.ts
|
|
134
180
|
const PRETTIER_PACKAGE_JSON_CONFIG = "package.json#prettier";
|
|
181
|
+
const TSUP_PACKAGE_JSON_CONFIG = "package.json#tsup";
|
|
182
|
+
const TSUP_CONFIG_FILES = [
|
|
183
|
+
"tsup.config.ts",
|
|
184
|
+
"tsup.config.mts",
|
|
185
|
+
"tsup.config.cts",
|
|
186
|
+
"tsup.config.js",
|
|
187
|
+
"tsup.config.mjs",
|
|
188
|
+
"tsup.config.cjs",
|
|
189
|
+
"tsup.config.json"
|
|
190
|
+
];
|
|
135
191
|
const PRETTIER_CONFIG_FILES = [
|
|
136
192
|
".prettierrc",
|
|
137
193
|
".prettierrc.json",
|
|
@@ -182,6 +238,10 @@ function detectConfigs(projectPath) {
|
|
|
182
238
|
configs.tsdownConfig = config;
|
|
183
239
|
break;
|
|
184
240
|
}
|
|
241
|
+
for (const config of TSUP_CONFIG_FILES) if (fs.existsSync(path.join(projectPath, config))) {
|
|
242
|
+
configs.tsupConfig = config;
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
185
245
|
for (const config of [".oxlintrc.json", ".oxlintrc.jsonc"]) if (fs.existsSync(path.join(projectPath, config))) {
|
|
186
246
|
configs.oxlintConfig = config;
|
|
187
247
|
break;
|
|
@@ -223,6 +283,7 @@ function detectConfigs(projectPath) {
|
|
|
223
283
|
const content = fs.readFileSync(packageJsonPath, "utf8");
|
|
224
284
|
const pkg = JSON.parse(content);
|
|
225
285
|
if (!configs.prettierConfig && pkg.prettier) configs.prettierConfig = PRETTIER_PACKAGE_JSON_CONFIG;
|
|
286
|
+
if (!configs.tsupConfig && pkg.tsup) configs.tsupConfig = TSUP_PACKAGE_JSON_CONFIG;
|
|
226
287
|
const voltaNode = pkg.volta?.node;
|
|
227
288
|
if (typeof voltaNode === "string") configs.voltaNode = voltaNode;
|
|
228
289
|
} catch {}
|
|
@@ -881,6 +942,397 @@ async function promptPrettierMigration(projectPath, interactive, packages) {
|
|
|
881
942
|
return true;
|
|
882
943
|
}
|
|
883
944
|
//#endregion
|
|
945
|
+
//#region src/migration/migrator/tsup.ts
|
|
946
|
+
function showTsdownMigrationOptions(targetLabel = "the project root", automaticMigrationFailed = false) {
|
|
947
|
+
const lines = [
|
|
948
|
+
"Choose one of these manual migration methods:",
|
|
949
|
+
` 1. Run \`vp dlx tsdown-migrate\` in ${targetLabel}.`,
|
|
950
|
+
" 2. Use the tsdown migration skill:",
|
|
951
|
+
` ${TSDOWN_MIGRATION_SKILL_URL}`
|
|
952
|
+
];
|
|
953
|
+
if (automaticMigrationFailed) {
|
|
954
|
+
lines.unshift("Automatic tsup migration failed.", "");
|
|
955
|
+
lines.push("");
|
|
956
|
+
}
|
|
957
|
+
log.info(lines.join("\n"));
|
|
958
|
+
}
|
|
959
|
+
function showTsdownMigrationSkillGuidance(instructions) {
|
|
960
|
+
log.info([
|
|
961
|
+
...instructions,
|
|
962
|
+
"",
|
|
963
|
+
"Use the tsdown migration skill for guidance:",
|
|
964
|
+
` ${TSDOWN_MIGRATION_SKILL_URL}`
|
|
965
|
+
].join("\n"));
|
|
966
|
+
}
|
|
967
|
+
function detectTsupProject(projectPath, packages) {
|
|
968
|
+
const packageJsonPath = path.join(projectPath, "package.json");
|
|
969
|
+
let hasDependency = false;
|
|
970
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
971
|
+
const pkg = readJsonFile(packageJsonPath);
|
|
972
|
+
hasDependency = !!(pkg.devDependencies?.tsup || pkg.dependencies?.tsup);
|
|
973
|
+
}
|
|
974
|
+
const configFile = detectConfigs(projectPath).tsupConfig;
|
|
975
|
+
let hasConfig = !!configFile;
|
|
976
|
+
for (const wp of packages ?? []) {
|
|
977
|
+
const workspacePath = path.join(projectPath, wp.path);
|
|
978
|
+
hasConfig ||= !!detectConfigs(workspacePath).tsupConfig;
|
|
979
|
+
if (!hasDependency) {
|
|
980
|
+
const workspacePackageJsonPath = path.join(workspacePath, "package.json");
|
|
981
|
+
if (fs.existsSync(workspacePackageJsonPath)) {
|
|
982
|
+
const workspacePackageJson = readJsonFile(workspacePackageJsonPath);
|
|
983
|
+
hasDependency = !!(workspacePackageJson.devDependencies?.tsup || workspacePackageJson.dependencies?.tsup);
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
return {
|
|
988
|
+
hasDependency,
|
|
989
|
+
hasConfig,
|
|
990
|
+
configFile
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
const TSDOWN_MIGRATION_FILES = [
|
|
994
|
+
"package.json",
|
|
995
|
+
...TSUP_CONFIG_FILES,
|
|
996
|
+
...TSUP_CONFIG_FILES.map((file) => file.replace("tsup", "tsdown"))
|
|
997
|
+
];
|
|
998
|
+
function escapeRegExp(value) {
|
|
999
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1000
|
+
}
|
|
1001
|
+
const STANDARD_TSUP_CONFIG_FILE_PATTERN = TSUP_CONFIG_FILES.flatMap((file) => [file, file.replace("tsup", "tsdown")]).map(escapeRegExp).join("|");
|
|
1002
|
+
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");
|
|
1003
|
+
const TSUP_CONFIG_OPTION_RE = /\btsup(?:-node)?\b(?:(?!&&|\|\||[;|]).)*?\s+(?:--config(?:=|\s+)|-c\s+)(?:"([^"]+)"|'([^']+)'|([^\s;&|]+))(?=\s|$|[;&|])/g;
|
|
1004
|
+
function removeStandardTsdownConfigOption(script) {
|
|
1005
|
+
return script.replace(TSDOWN_STANDARD_CONFIG_OPTION_RE, "$1");
|
|
1006
|
+
}
|
|
1007
|
+
function resolveScriptConfigPath(packagePath, configPath) {
|
|
1008
|
+
return path.resolve(packagePath, configPath.replace(/[\\/]/g, path.sep));
|
|
1009
|
+
}
|
|
1010
|
+
function collectSharedTsupConfigs(projectPath, packages, tsupTargets) {
|
|
1011
|
+
const migratedConfigPaths = new Set(tsupTargets.flatMap((target) => TSUP_CONFIG_FILES.map((file) => path.join(target, file)).filter((file) => fs.existsSync(file))));
|
|
1012
|
+
const sharedConfigs = /* @__PURE__ */ new Map();
|
|
1013
|
+
const consumers = [{
|
|
1014
|
+
label: "the project root",
|
|
1015
|
+
packagePath: path.resolve(projectPath)
|
|
1016
|
+
}, ...(packages ?? []).map((workspacePackage) => ({
|
|
1017
|
+
label: workspacePackage.path,
|
|
1018
|
+
packagePath: path.resolve(projectPath, workspacePackage.path)
|
|
1019
|
+
}))];
|
|
1020
|
+
for (const { label, packagePath } of consumers) {
|
|
1021
|
+
const packageJsonPath = path.join(packagePath, "package.json");
|
|
1022
|
+
if (!fs.existsSync(packageJsonPath)) continue;
|
|
1023
|
+
const packageJson = readJsonFile(packageJsonPath);
|
|
1024
|
+
for (const [scriptName, script] of Object.entries(packageJson.scripts ?? {})) for (const match of script.matchAll(TSUP_CONFIG_OPTION_RE)) {
|
|
1025
|
+
const configPath = resolveScriptConfigPath(packagePath, match[1] ?? match[2] ?? match[3]);
|
|
1026
|
+
if (!migratedConfigPaths.has(configPath) || path.dirname(configPath) === packagePath) continue;
|
|
1027
|
+
const sharedConfig = sharedConfigs.get(configPath) ?? { consumers: /* @__PURE__ */ new Map() };
|
|
1028
|
+
const consumer = sharedConfig.consumers.get(packagePath) ?? {
|
|
1029
|
+
label,
|
|
1030
|
+
packagePath,
|
|
1031
|
+
scriptNames: /* @__PURE__ */ new Set()
|
|
1032
|
+
};
|
|
1033
|
+
consumer.scriptNames.add(scriptName);
|
|
1034
|
+
sharedConfig.consumers.set(packagePath, consumer);
|
|
1035
|
+
sharedConfigs.set(configPath, sharedConfig);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
return sharedConfigs;
|
|
1039
|
+
}
|
|
1040
|
+
function collectTsupConfigCollisions(tsupTargets) {
|
|
1041
|
+
const collisions = [];
|
|
1042
|
+
for (const target of tsupTargets) {
|
|
1043
|
+
const tsdownConfig = detectConfigs(target).tsdownConfig;
|
|
1044
|
+
if (tsdownConfig) collisions.push({ configPath: path.join(target, tsdownConfig) });
|
|
1045
|
+
const packageJsonPath = path.join(target, "package.json");
|
|
1046
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
1047
|
+
const packageJson = readJsonFile(packageJsonPath);
|
|
1048
|
+
if (Object.hasOwn(packageJson, "tsdown")) collisions.push({ configPath: `${packageJsonPath}#tsdown` });
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
return collisions;
|
|
1052
|
+
}
|
|
1053
|
+
function collectInlineTsupConfigs(tsupTargets) {
|
|
1054
|
+
return tsupTargets.flatMap((target) => {
|
|
1055
|
+
const packageJsonPath = path.join(target, "package.json");
|
|
1056
|
+
if (!fs.existsSync(packageJsonPath) || !Object.hasOwn(readJsonFile(packageJsonPath), "tsup")) return [];
|
|
1057
|
+
return [{ configPath: `${packageJsonPath}#tsup` }];
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
function isRemovableDefaultConfigArgument(configArgument, defaultConfig) {
|
|
1061
|
+
return !!defaultConfig && (configArgument === defaultConfig || configArgument === `./${defaultConfig}` || configArgument === `.\\${defaultConfig}`);
|
|
1062
|
+
}
|
|
1063
|
+
function collectUnsupportedTsupConfigConsumers(tsupTargets) {
|
|
1064
|
+
const migratedConfigPaths = new Set(tsupTargets.flatMap((target) => TSUP_CONFIG_FILES.map((file) => path.join(target, file)).filter((file) => fs.existsSync(file))));
|
|
1065
|
+
const unsupported = [];
|
|
1066
|
+
for (const target of tsupTargets) {
|
|
1067
|
+
const packageJsonPath = path.join(target, "package.json");
|
|
1068
|
+
if (!fs.existsSync(packageJsonPath)) continue;
|
|
1069
|
+
const detectedConfig = detectConfigs(target).tsupConfig;
|
|
1070
|
+
const defaultConfigPath = detectedConfig && detectedConfig !== "package.json#tsup" ? path.join(target, detectedConfig) : void 0;
|
|
1071
|
+
const packageJson = readJsonFile(packageJsonPath);
|
|
1072
|
+
for (const [scriptName, script] of Object.entries(packageJson.scripts ?? {})) for (const match of script.matchAll(TSUP_CONFIG_OPTION_RE)) {
|
|
1073
|
+
const configArgument = match[1] ?? match[2] ?? match[3];
|
|
1074
|
+
const configPath = resolveScriptConfigPath(target, configArgument);
|
|
1075
|
+
const isDefaultConfig = configPath === defaultConfigPath && isRemovableDefaultConfigArgument(configArgument, detectedConfig);
|
|
1076
|
+
const isSharedMigratedConfig = migratedConfigPaths.has(configPath) && path.dirname(configPath) !== target;
|
|
1077
|
+
if (!isDefaultConfig && !isSharedMigratedConfig) unsupported.push({
|
|
1078
|
+
configArgument,
|
|
1079
|
+
packagePath: target,
|
|
1080
|
+
scriptName
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
return unsupported;
|
|
1085
|
+
}
|
|
1086
|
+
function restoreSharedTsupUsage(sharedConfigs, snapshots) {
|
|
1087
|
+
const preservedDependencyTargets = /* @__PURE__ */ new Set();
|
|
1088
|
+
const restoredScripts = /* @__PURE__ */ new Map();
|
|
1089
|
+
for (const [configPath, sharedConfig] of sharedConfigs) {
|
|
1090
|
+
const contents = snapshots.get(configPath);
|
|
1091
|
+
if (contents !== void 0) fs.writeFileSync(configPath, contents);
|
|
1092
|
+
preservedDependencyTargets.add(path.dirname(configPath));
|
|
1093
|
+
for (const consumer of sharedConfig.consumers.values()) {
|
|
1094
|
+
preservedDependencyTargets.add(consumer.packagePath);
|
|
1095
|
+
const scriptNames = restoredScripts.get(consumer.packagePath) ?? /* @__PURE__ */ new Set();
|
|
1096
|
+
for (const scriptName of consumer.scriptNames) scriptNames.add(scriptName);
|
|
1097
|
+
restoredScripts.set(consumer.packagePath, scriptNames);
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
for (const target of preservedDependencyTargets) {
|
|
1101
|
+
const packageJsonPath = path.join(target, "package.json");
|
|
1102
|
+
const originalPackageJson = snapshots.get(packageJsonPath);
|
|
1103
|
+
if (!originalPackageJson || !fs.existsSync(packageJsonPath)) continue;
|
|
1104
|
+
const original = JSON.parse(originalPackageJson.toString());
|
|
1105
|
+
editJsonFile(packageJsonPath, (pkg) => {
|
|
1106
|
+
let changed = false;
|
|
1107
|
+
for (const field of ["devDependencies", "dependencies"]) {
|
|
1108
|
+
const spec = original[field]?.tsup;
|
|
1109
|
+
if (spec && pkg[field]?.tsup !== spec) {
|
|
1110
|
+
pkg[field] ??= {};
|
|
1111
|
+
pkg[field].tsup = spec;
|
|
1112
|
+
changed = true;
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
for (const scriptName of restoredScripts.get(target) ?? []) {
|
|
1116
|
+
const script = original.scripts?.[scriptName];
|
|
1117
|
+
if (script !== void 0 && pkg.scripts?.[scriptName] !== script) {
|
|
1118
|
+
pkg.scripts ??= {};
|
|
1119
|
+
pkg.scripts[scriptName] = script;
|
|
1120
|
+
changed = true;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
return changed ? pkg : void 0;
|
|
1124
|
+
});
|
|
1125
|
+
}
|
|
1126
|
+
return preservedDependencyTargets;
|
|
1127
|
+
}
|
|
1128
|
+
function snapshotTsupMigrationTargets(targets) {
|
|
1129
|
+
const snapshots = /* @__PURE__ */ new Map();
|
|
1130
|
+
for (const target of targets) for (const file of TSDOWN_MIGRATION_FILES) {
|
|
1131
|
+
const filePath = path.join(target, file);
|
|
1132
|
+
snapshots.set(filePath, fs.existsSync(filePath) ? fs.readFileSync(filePath) : void 0);
|
|
1133
|
+
}
|
|
1134
|
+
return snapshots;
|
|
1135
|
+
}
|
|
1136
|
+
function restoreTsupMigrationTargets(snapshots) {
|
|
1137
|
+
const failures = [];
|
|
1138
|
+
for (const [filePath, contents] of snapshots) try {
|
|
1139
|
+
if (contents === void 0) fs.rmSync(filePath, { force: true });
|
|
1140
|
+
else fs.writeFileSync(filePath, contents);
|
|
1141
|
+
} catch {
|
|
1142
|
+
failures.push(displayRelative(filePath));
|
|
1143
|
+
}
|
|
1144
|
+
return failures;
|
|
1145
|
+
}
|
|
1146
|
+
function extractTsdownMigrationWarnings(output) {
|
|
1147
|
+
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);
|
|
1148
|
+
}
|
|
1149
|
+
/** Run `vp dlx tsdown-migrate` in `cwd` with graceful error handling. */
|
|
1150
|
+
async function runTsdownMigrateStep(vpBin, cwd, packageManager) {
|
|
1151
|
+
try {
|
|
1152
|
+
const result = await runCommandSilently({
|
|
1153
|
+
command: vpBin,
|
|
1154
|
+
args: [
|
|
1155
|
+
"dlx",
|
|
1156
|
+
`tsdown-migrate@${corePkg.bundledVersions.tsdown}`,
|
|
1157
|
+
"--yes",
|
|
1158
|
+
"--package-manager",
|
|
1159
|
+
packageManager,
|
|
1160
|
+
"--no-install"
|
|
1161
|
+
],
|
|
1162
|
+
cwd,
|
|
1163
|
+
envs: process.env
|
|
1164
|
+
});
|
|
1165
|
+
if (result.exitCode !== 0) {
|
|
1166
|
+
const stderr = result.stderr.toString().trim();
|
|
1167
|
+
if (stderr) log.warn(`⚠ ${stderr}`);
|
|
1168
|
+
return {
|
|
1169
|
+
ok: false,
|
|
1170
|
+
warnings: []
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
return {
|
|
1174
|
+
ok: true,
|
|
1175
|
+
warnings: [...extractTsdownMigrationWarnings(result.stdout), ...extractTsdownMigrationWarnings(result.stderr)]
|
|
1176
|
+
};
|
|
1177
|
+
} catch {
|
|
1178
|
+
return {
|
|
1179
|
+
ok: false,
|
|
1180
|
+
warnings: []
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
async function migrateTsupToTsdown(projectPath, interactive, packageManager, tsupConfigFile, packages, options) {
|
|
1185
|
+
const vpBin = process.env.VP_CLI_BIN ?? "vp";
|
|
1186
|
+
const spinner = options?.silent ? getSilentSpinner() : getSpinner(interactive);
|
|
1187
|
+
const rootPath = path.resolve(projectPath);
|
|
1188
|
+
const tsupTargets = [rootPath, ...(packages ?? []).map((p) => path.resolve(rootPath, p.path))].filter((target) => target === rootPath ? !!tsupConfigFile : !!detectConfigs(target).tsupConfig);
|
|
1189
|
+
const configCollisions = collectTsupConfigCollisions(tsupTargets);
|
|
1190
|
+
if (configCollisions.length > 0) {
|
|
1191
|
+
log.warn(`Automatic tsup migration was skipped because these tsdown configs already exist:\n${configCollisions.map(({ configPath }) => ` ${displayRelative(configPath, projectPath)}`).join("\n")}`);
|
|
1192
|
+
showTsdownMigrationSkillGuidance([
|
|
1193
|
+
"Resolve this configuration conflict manually:",
|
|
1194
|
+
" 1. Merge the tsup and tsdown configurations into `pack` in `vite.config.*`.",
|
|
1195
|
+
" 2. Do not run `tsdown-migrate`. It can overwrite the existing tsdown configuration."
|
|
1196
|
+
]);
|
|
1197
|
+
return false;
|
|
1198
|
+
}
|
|
1199
|
+
const inlineTsupConfigs = collectInlineTsupConfigs(tsupTargets);
|
|
1200
|
+
if (inlineTsupConfigs.length > 0) {
|
|
1201
|
+
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")}`);
|
|
1202
|
+
showTsdownMigrationSkillGuidance([
|
|
1203
|
+
"Resolve this inline configuration manually:",
|
|
1204
|
+
" 1. Move each `package.json#tsup` configuration into `pack` in `vite.config.*`.",
|
|
1205
|
+
" 2. Do not run `tsdown-migrate`. Vite+ Pack does not read `package.json#tsdown`."
|
|
1206
|
+
]);
|
|
1207
|
+
return false;
|
|
1208
|
+
}
|
|
1209
|
+
const unsupportedConfigConsumers = collectUnsupportedTsupConfigConsumers(tsupTargets);
|
|
1210
|
+
if (unsupportedConfigConsumers.length > 0) {
|
|
1211
|
+
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")}`);
|
|
1212
|
+
showTsdownMigrationSkillGuidance([
|
|
1213
|
+
"Resolve these config paths manually:",
|
|
1214
|
+
" 1. Migrate each listed config into `pack` in `vite.config.*`.",
|
|
1215
|
+
" 2. Update each listed script.",
|
|
1216
|
+
" 3. Do not run `tsdown-migrate`. It cannot safely resolve these config paths."
|
|
1217
|
+
]);
|
|
1218
|
+
return false;
|
|
1219
|
+
}
|
|
1220
|
+
const sharedConfigs = collectSharedTsupConfigs(projectPath, packages, tsupTargets);
|
|
1221
|
+
let preservedDependencyTargets = /* @__PURE__ */ new Set();
|
|
1222
|
+
if (tsupTargets.length > 0) {
|
|
1223
|
+
const snapshots = snapshotTsupMigrationTargets(tsupTargets);
|
|
1224
|
+
const migrationWarnings = [];
|
|
1225
|
+
spinner.start("Migrating tsup config to tsdown...");
|
|
1226
|
+
for (const target of tsupTargets) {
|
|
1227
|
+
const targetLabel = target === rootPath ? "the project root" : displayRelative(target, projectPath);
|
|
1228
|
+
const migrateResult = await runTsdownMigrateStep(vpBin, target, packageManager);
|
|
1229
|
+
if (!migrateResult.ok) {
|
|
1230
|
+
spinner.stop();
|
|
1231
|
+
const restoreFailures = restoreTsupMigrationTargets(snapshots);
|
|
1232
|
+
if (restoreFailures.length > 0) log.warn(`Could not restore these files after the failed migration:\n${restoreFailures.map((file) => ` ${file}`).join("\n")}`);
|
|
1233
|
+
showTsdownMigrationOptions(targetLabel, true);
|
|
1234
|
+
return false;
|
|
1235
|
+
}
|
|
1236
|
+
for (const warning of migrateResult.warnings) migrationWarnings.push({
|
|
1237
|
+
targetLabel,
|
|
1238
|
+
warning
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
spinner.stop("tsup config migrated to tsdown.config");
|
|
1242
|
+
preservedDependencyTargets = restoreSharedTsupUsage(sharedConfigs, snapshots);
|
|
1243
|
+
for (const { targetLabel, warning } of migrationWarnings) {
|
|
1244
|
+
const message = targetLabel === "the project root" ? `tsdown-migrate: ${warning}` : `tsdown-migrate (${targetLabel}): ${warning}`;
|
|
1245
|
+
if (options?.report) addMigrationWarning(options.report, message);
|
|
1246
|
+
else log.warn(message);
|
|
1247
|
+
}
|
|
1248
|
+
for (const [configPath, sharedConfig] of sharedConfigs) {
|
|
1249
|
+
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.`;
|
|
1250
|
+
if (options?.report) addMigrationWarning(options.report, message);
|
|
1251
|
+
else log.warn(message);
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
if (options?.report) options.report.tsupMigrated = true;
|
|
1255
|
+
for (const target of tsupTargets) {
|
|
1256
|
+
if (!fs.existsSync(path.join(target, "package.json"))) continue;
|
|
1257
|
+
deleteTsupConfigFiles(target, new Set([...sharedConfigs.keys()].filter((configPath) => path.dirname(configPath) === path.resolve(target))), options?.report, options?.silent);
|
|
1258
|
+
rewriteTsupPackageJson(path.join(target, "package.json"), preservedDependencyTargets.has(path.resolve(target)));
|
|
1259
|
+
}
|
|
1260
|
+
return true;
|
|
1261
|
+
}
|
|
1262
|
+
function deleteTsupConfigFiles(basePath, preservedConfigs, report, silent = false) {
|
|
1263
|
+
const configs = detectConfigs(basePath);
|
|
1264
|
+
if (configs.tsupConfig && configs.tsupConfig !== "package.json#tsup") {
|
|
1265
|
+
const configPath = path.join(basePath, configs.tsupConfig);
|
|
1266
|
+
if (!preservedConfigs.has(configPath) && fs.existsSync(configPath)) {
|
|
1267
|
+
fs.unlinkSync(configPath);
|
|
1268
|
+
if (report) report.removedConfigCount++;
|
|
1269
|
+
if (!silent) log.success(`✔ Removed ${displayRelative(configPath)}`);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
for (const file of TSUP_CONFIG_FILES) {
|
|
1273
|
+
if (file === configs.tsupConfig) continue;
|
|
1274
|
+
const configPath = path.join(basePath, file);
|
|
1275
|
+
if (!preservedConfigs.has(configPath) && fs.existsSync(configPath)) {
|
|
1276
|
+
fs.unlinkSync(configPath);
|
|
1277
|
+
if (report) report.removedConfigCount++;
|
|
1278
|
+
if (!silent) log.success(`✔ Removed ${displayRelative(configPath)}`);
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
editJsonFile(path.join(basePath, "package.json"), (pkg) => {
|
|
1282
|
+
if (pkg.tsup) {
|
|
1283
|
+
delete pkg.tsup;
|
|
1284
|
+
return pkg;
|
|
1285
|
+
}
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
function rewriteTsupPackageJson(packageJsonPath, preserveTsupDependency = false) {
|
|
1289
|
+
if (!fs.existsSync(packageJsonPath)) return;
|
|
1290
|
+
editJsonFile(packageJsonPath, (pkg) => {
|
|
1291
|
+
let changed = false;
|
|
1292
|
+
for (const [name, script] of Object.entries(pkg.scripts ?? {})) {
|
|
1293
|
+
const rewritten = removeStandardTsdownConfigOption(script);
|
|
1294
|
+
if (rewritten !== script) {
|
|
1295
|
+
pkg.scripts[name] = rewritten;
|
|
1296
|
+
changed = true;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
if (!preserveTsupDependency) {
|
|
1300
|
+
for (const field of ["devDependencies", "dependencies"]) if (pkg[field]?.tsup) {
|
|
1301
|
+
delete pkg[field].tsup;
|
|
1302
|
+
changed = true;
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
return changed ? pkg : void 0;
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
function warnMissingTsupConfig() {
|
|
1309
|
+
log.warn("tsup detected, but no tsup config was found. The tsup setup must be migrated manually.");
|
|
1310
|
+
}
|
|
1311
|
+
async function confirmTsupMigration(interactive) {
|
|
1312
|
+
if (interactive) {
|
|
1313
|
+
const confirmed = await confirm({
|
|
1314
|
+
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."),
|
|
1315
|
+
initialValue: true
|
|
1316
|
+
});
|
|
1317
|
+
if (isCancel(confirmed)) cancelAndExit();
|
|
1318
|
+
if (!confirmed) showTsdownMigrationOptions();
|
|
1319
|
+
return confirmed;
|
|
1320
|
+
}
|
|
1321
|
+
log.info("tsup configuration detected. Auto-migrating to tsdown...");
|
|
1322
|
+
return true;
|
|
1323
|
+
}
|
|
1324
|
+
async function promptTsupMigration(projectPath, interactive, packageManager, packages) {
|
|
1325
|
+
const tsupProject = detectTsupProject(projectPath, packages);
|
|
1326
|
+
if (!tsupProject.hasDependency) return false;
|
|
1327
|
+
if (!tsupProject.hasConfig) {
|
|
1328
|
+
warnMissingTsupConfig();
|
|
1329
|
+
return false;
|
|
1330
|
+
}
|
|
1331
|
+
if (!await confirmTsupMigration(interactive)) return false;
|
|
1332
|
+
if (!await migrateTsupToTsdown(projectPath, interactive, packageManager, tsupProject.configFile, packages)) cancelAndExit("Complete the tsup migration manually, then re-run `vp migrate`.", 1);
|
|
1333
|
+
return true;
|
|
1334
|
+
}
|
|
1335
|
+
//#endregion
|
|
884
1336
|
//#region src/migration/migrator/tsconfig.ts
|
|
885
1337
|
function cleanupDeprecatedTsconfigOptions(projectPath, silent = false, report) {
|
|
886
1338
|
const deprecatedOptions = ["esModuleInterop", "allowSyntheticDefaultImports"];
|
|
@@ -967,7 +1419,6 @@ function addFrameworkShim(projectPath, framework, report) {
|
|
|
967
1419
|
//#endregion
|
|
968
1420
|
//#region src/migration/migrator/vitest-ecosystem.ts
|
|
969
1421
|
var import_dist = require_dist();
|
|
970
|
-
const VITEST_ALIGN_EXCLUDED = /* @__PURE__ */ new Set(["@vitest/eslint-plugin", "@vitest/coverage-c8"]);
|
|
971
1422
|
const VITEST_DIRECT_USAGE_EXCLUDED = /* @__PURE__ */ new Set([
|
|
972
1423
|
"@vitest/eslint-plugin",
|
|
973
1424
|
"@vitest/expect",
|
|
@@ -979,24 +1430,6 @@ const VITEST_DIRECT_USAGE_EXCLUDED = /* @__PURE__ */ new Set([
|
|
|
979
1430
|
"@vitest/utils",
|
|
980
1431
|
"@vitest/ws-client"
|
|
981
1432
|
]);
|
|
982
|
-
function isAlignableVitestEcosystemPackage(name) {
|
|
983
|
-
return name.startsWith("@vitest/") && !VITEST_ALIGN_EXCLUDED.has(name);
|
|
984
|
-
}
|
|
985
|
-
function extractOverrideTargetName(key) {
|
|
986
|
-
let target = key.trim();
|
|
987
|
-
for (let delim = target.search(/[^ |@]>/); delim !== -1; delim = target.search(/[^ |@]>/)) target = target.slice(delim + 2).trim();
|
|
988
|
-
if (!target) return target;
|
|
989
|
-
if (target.includes("/")) {
|
|
990
|
-
const segments = target.split("/");
|
|
991
|
-
const last = segments[segments.length - 1];
|
|
992
|
-
const scope = segments[segments.length - 2];
|
|
993
|
-
target = scope?.startsWith("@") ? `${scope}/${last}` : last;
|
|
994
|
-
}
|
|
995
|
-
const nameStart = target.startsWith("@") ? target.indexOf("/") + 1 : 0;
|
|
996
|
-
const versionAt = target.indexOf("@", nameStart);
|
|
997
|
-
if (versionAt > 0) target = target.slice(0, versionAt);
|
|
998
|
-
return target;
|
|
999
|
-
}
|
|
1000
1433
|
function isRemovePackageOverrideKey(key) {
|
|
1001
1434
|
return PROVIDER_OVERRIDE_DROP_NAMES.includes(extractOverrideTargetName(key));
|
|
1002
1435
|
}
|
|
@@ -1137,17 +1570,21 @@ function projectListsRequiredVitestPeer(projectPath, pkg) {
|
|
|
1137
1570
|
function projectUsesVitestDirectly(projectPath, pkg, requiredVitestPeer, preserveNuxtVitestImports = true, precomputedScans) {
|
|
1138
1571
|
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));
|
|
1139
1572
|
}
|
|
1140
|
-
function removeManagedVitestEntry(record) {
|
|
1141
|
-
if (VITEST_IS_MANAGED_OVERRIDE
|
|
1142
|
-
|
|
1143
|
-
|
|
1573
|
+
function removeManagedVitestEntry(record, keyStyle = "bare") {
|
|
1574
|
+
if (!VITEST_IS_MANAGED_OVERRIDE || !record) return false;
|
|
1575
|
+
let removed = false;
|
|
1576
|
+
for (const key of managedVitestOverrideKeys(keyStyle)) if (typeof record[key] === "string") {
|
|
1577
|
+
delete record[key];
|
|
1578
|
+
removed = true;
|
|
1144
1579
|
}
|
|
1145
|
-
return
|
|
1580
|
+
return removed;
|
|
1146
1581
|
}
|
|
1147
|
-
function removeYamlMapVitestEntry(map) {
|
|
1582
|
+
function removeYamlMapVitestEntry(map, keyStyle = "bare") {
|
|
1148
1583
|
if (!VITEST_IS_MANAGED_OVERRIDE || !(map instanceof import_dist.YAMLMap)) return;
|
|
1149
|
-
const
|
|
1150
|
-
|
|
1584
|
+
for (const key of managedVitestOverrideKeys(keyStyle)) map.delete(key);
|
|
1585
|
+
}
|
|
1586
|
+
function managedVitestOverrideKeys(keyStyle) {
|
|
1587
|
+
return keyStyle === "pnpm-ranged" ? ["vitest", pnpmOverrideKey("vitest")] : ["vitest"];
|
|
1151
1588
|
}
|
|
1152
1589
|
function removeVitestPeerDependencyRule(peerDependencyRules) {
|
|
1153
1590
|
if (!VITEST_IS_MANAGED_OVERRIDE) return;
|
|
@@ -1240,7 +1677,7 @@ function vitestEcosystemCatalogReferencesPending(pkg, catalogDependencyResolver)
|
|
|
1240
1677
|
pkg.optionalDependencies
|
|
1241
1678
|
]) {
|
|
1242
1679
|
if (!dependencies) continue;
|
|
1243
|
-
for (const [name, spec] of Object.entries(dependencies)) if (isAlignableVitestEcosystemPackage(name) && spec.startsWith("catalog:") && catalogDependencyResolver(spec, name) !== "4.1.
|
|
1680
|
+
for (const [name, spec] of Object.entries(dependencies)) if (isAlignableVitestEcosystemPackage(name) && spec.startsWith("catalog:") && catalogDependencyResolver(spec, name) !== "4.1.11") return true;
|
|
1244
1681
|
}
|
|
1245
1682
|
return false;
|
|
1246
1683
|
}
|
|
@@ -6933,10 +7370,12 @@ function rewritePnpmWorkspaceYaml(projectPath, pnpmMajorVersion, shouldAllowBrow
|
|
|
6933
7370
|
const keysSnapshot = overrides.items.map((item) => item.key);
|
|
6934
7371
|
for (const keyNode of keysSnapshot) if (shouldDropProviderOverrideKey(keyNode instanceof import_dist.Scalar ? String(keyNode.value ?? "") : String(keyNode ?? ""))) overrides.delete(keyNode);
|
|
6935
7372
|
}
|
|
6936
|
-
if (!usesVitest) removeYamlMapVitestEntry(doc.getIn(["overrides"]));
|
|
7373
|
+
if (!usesVitest) removeYamlMapVitestEntry(doc.getIn(["overrides"]), "pnpm-ranged");
|
|
6937
7374
|
for (const key of Object.keys(managed)) {
|
|
6938
|
-
const
|
|
6939
|
-
|
|
7375
|
+
const overrideKey = pnpmOverrideKey(key);
|
|
7376
|
+
const version = getCatalogDependencySpec(getYamlMapScalarStringValue(overrides, overrideKey) ?? getYamlMapScalarStringValue(overrides, key), managed[key], true, { preferredCatalogSpec });
|
|
7377
|
+
if (overrides instanceof import_dist.YAMLMap) overrides.delete(key);
|
|
7378
|
+
doc.setIn(["overrides", scalarString(overrideKey)], scalarString(version));
|
|
6940
7379
|
}
|
|
6941
7380
|
const updatedOverrides = doc.getIn(["overrides"]);
|
|
6942
7381
|
const updatedOverrideKeys = updatedOverrides.items.map((item) => item.key);
|
|
@@ -7035,14 +7474,17 @@ function getCatalogDependencySpec(currentValue, version, supportCatalog, options
|
|
|
7035
7474
|
}
|
|
7036
7475
|
/**
|
|
7037
7476
|
* #1932: under pnpm, an importer that depends on `vite-plus` (which bundles
|
|
7038
|
-
* `vitest`) needs a DIRECT `vite` devDep
|
|
7039
|
-
* required `vite` peer to
|
|
7040
|
-
*
|
|
7477
|
+
* `vitest`) needs a DIRECT `vite` devDep pointing at @voidzero-dev/vite-plus-core
|
|
7478
|
+
* so vitest's required `vite` peer binds to it. Without a direct edge, pnpm's
|
|
7479
|
+
* `autoInstallPeers` fabricates a separate upstream `vite` to satisfy the
|
|
7041
7480
|
* peer, splitting vite-plus / vite / vitest into duplicate instances (the extra
|
|
7042
7481
|
* vite also lacks vite's `@voidzero-dev/vite-task-client` integration, breaking
|
|
7043
|
-
* the `vp test` cache).
|
|
7044
|
-
*
|
|
7045
|
-
*
|
|
7482
|
+
* the `vp test` cache). Under a catalog the edge is a `catalog:` reference and
|
|
7483
|
+
* the catalog entry carries the alias; the `vite@*` workspace override covers
|
|
7484
|
+
* transitive and peer declarations instead of this one (see `pnpmOverrideKey`).
|
|
7485
|
+
* npm/yarn/bun redirect transitive/peer vite via root overrides/resolutions (and
|
|
7486
|
+
* drop the aliased vite), so this is pnpm-only, mirroring the bun root-package
|
|
7487
|
+
* branch in `rewriteRootWorkspacePackageJson`.
|
|
7046
7488
|
*
|
|
7047
7489
|
* A package that already declares `vite` in ANY dependency field, including
|
|
7048
7490
|
* `peerDependencies` (e.g. a vite plugin pinning `vite ^6`), is left untouched
|
|
@@ -7157,6 +7599,39 @@ function getYamlMapScalarStringValue(map, key) {
|
|
|
7157
7599
|
if (!(map instanceof import_dist.YAMLMap)) return;
|
|
7158
7600
|
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;
|
|
7159
7601
|
}
|
|
7602
|
+
/**
|
|
7603
|
+
* Merge the managed override entries into a pnpm `overrides` record, under the
|
|
7604
|
+
* range-qualified keys (see `pnpmOverrideKey`).
|
|
7605
|
+
*
|
|
7606
|
+
* Both writers of the package.json `pnpm.overrides` sink go through this
|
|
7607
|
+
* helper: the standalone writer and the monorepo-root writer. That sink serves
|
|
7608
|
+
* pnpm 9.5 to 10.6.1. The helper deletes a bare managed key that a pre-#2309
|
|
7609
|
+
* migration left. Two keys for one package would restore the match that
|
|
7610
|
+
* clobbers `catalog:` importer specs.
|
|
7611
|
+
*
|
|
7612
|
+
* A bare key's `catalog:` value moves to the ranged key, so a user's own
|
|
7613
|
+
* `catalog:<name>` choice survives the re-keying. This mirrors
|
|
7614
|
+
* `getCatalogDependencySpec`, which keeps a `catalog:` reference in the
|
|
7615
|
+
* pnpm-workspace.yaml sink. A `file:` managed spec (force-override mode) always
|
|
7616
|
+
* wins, because there is no catalog to resolve against in that mode.
|
|
7617
|
+
*
|
|
7618
|
+
* Force-override mode also appends the `vite-plus` pin, under a BARE key. The
|
|
7619
|
+
* pin only exists in `file:` tgz mode, where migration writes the tgz spec
|
|
7620
|
+
* straight into every manifest instead of a `catalog:` reference. In that mode
|
|
7621
|
+
* there is no catalog provenance for a bare key to strip. This matches the
|
|
7622
|
+
* workspace-yaml force-override path in `rewriteStandaloneProject`.
|
|
7623
|
+
*/
|
|
7624
|
+
function mergeManagedPnpmOverrides(overrides, managed) {
|
|
7625
|
+
const next = { ...overrides };
|
|
7626
|
+
for (const [dependencyName, managedSpec] of Object.entries(managed)) {
|
|
7627
|
+
const overrideKey = pnpmOverrideKey(dependencyName);
|
|
7628
|
+
const existing = next[overrideKey] ?? next[dependencyName];
|
|
7629
|
+
delete next[dependencyName];
|
|
7630
|
+
next[overrideKey] = existing?.startsWith("catalog:") && !managedSpec.startsWith("file:") ? existing : managedSpec;
|
|
7631
|
+
}
|
|
7632
|
+
if (isForceOverrideMode()) next[VITE_PLUS_NAME] = VITE_PLUS_VERSION;
|
|
7633
|
+
return next;
|
|
7634
|
+
}
|
|
7160
7635
|
function pruneYamlMapLegacyWrapperAliases(map) {
|
|
7161
7636
|
if (!(map instanceof import_dist.YAMLMap)) return;
|
|
7162
7637
|
const stale = [];
|
|
@@ -7312,15 +7787,11 @@ function rewriteRootWorkspacePackageJson(projectPath, packageManager, skipStaged
|
|
|
7312
7787
|
const overrideKeys = Object.keys(managed);
|
|
7313
7788
|
if (!pnpmSupportsWorkspaceSettings(pnpmVersion ?? "")) {
|
|
7314
7789
|
dropRemovePackageOverrideKeys(pkg.pnpm?.overrides);
|
|
7315
|
-
if (!workspaceUsesVitest) removeManagedVitestEntry(pkg.pnpm?.overrides);
|
|
7790
|
+
if (!workspaceUsesVitest) removeManagedVitestEntry(pkg.pnpm?.overrides, "pnpm-ranged");
|
|
7316
7791
|
if (!workspaceUsesVitest && pkg.pnpm?.peerDependencyRules) removeVitestPeerDependencyRule(pkg.pnpm.peerDependencyRules);
|
|
7317
7792
|
pkg.pnpm = {
|
|
7318
7793
|
...pkg.pnpm,
|
|
7319
|
-
overrides:
|
|
7320
|
-
...pkg.pnpm?.overrides,
|
|
7321
|
-
...managed,
|
|
7322
|
-
...isForceOverrideMode() ? { [VITE_PLUS_NAME]: VITE_PLUS_VERSION } : {}
|
|
7323
|
-
},
|
|
7794
|
+
overrides: mergeManagedPnpmOverrides(pkg.pnpm?.overrides, managed),
|
|
7324
7795
|
peerDependencyRules: {
|
|
7325
7796
|
...pkg.pnpm?.peerDependencyRules,
|
|
7326
7797
|
allowAny: [.../* @__PURE__ */ new Set([...pkg.pnpm?.peerDependencyRules?.allowAny ?? [], ...overrideKeys])],
|
|
@@ -7709,9 +8180,11 @@ function overrideSpecSatisfiesVitePlus(dependencyName, spec, catalogDependencyRe
|
|
|
7709
8180
|
if (!spec.startsWith("catalog:")) return false;
|
|
7710
8181
|
return isSemanticVitePlusOverrideSpec(dependencyName, catalogDependencyResolver?.(spec, dependencyName));
|
|
7711
8182
|
}
|
|
7712
|
-
function overridesSatisfyVitePlus(overrides, usesVitest, catalogDependencyResolver) {
|
|
7713
|
-
|
|
7714
|
-
|
|
8183
|
+
function overridesSatisfyVitePlus(overrides, usesVitest, catalogDependencyResolver, keyStyle = "bare") {
|
|
8184
|
+
const managed = managedOverridePackages(usesVitest);
|
|
8185
|
+
if (!usesVitest && VITEST_IS_MANAGED_OVERRIDE && (typeof overrides?.vitest === "string" || keyStyle === "pnpm-ranged" && typeof overrides?.[pnpmOverrideKey("vitest")] === "string")) return false;
|
|
8186
|
+
if (keyStyle === "pnpm-ranged" && Object.keys(managed).some((dependencyName) => typeof overrides?.[dependencyName] === "string")) return false;
|
|
8187
|
+
return Object.keys(managed).every((dependencyName) => overrideSpecSatisfiesVitePlus(dependencyName, overrides?.[managedOverrideKey(dependencyName, keyStyle)], catalogDependencyResolver));
|
|
7715
8188
|
}
|
|
7716
8189
|
function hasPackageManagerPin(pkg) {
|
|
7717
8190
|
return Boolean(pkg.packageManager || pkg.devEngines?.packageManager);
|
|
@@ -7932,11 +8405,11 @@ function detectVitePlusBootstrapPending(projectPath, packageManager, packages, p
|
|
|
7932
8405
|
if (packageManager === PackageManager.pnpm) {
|
|
7933
8406
|
if (!pnpmWorkspaceExoticSubdepsSettingSatisfied(projectPath)) return true;
|
|
7934
8407
|
if (!usePnpmWorkspaceYaml) {
|
|
7935
|
-
if (supportCatalog) return catalogVitePlusDependencyPending(pkg, catalogDependencyResolver) || !overridesSatisfyVitePlus(pkg.pnpm?.overrides, usesVitest, catalogDependencyResolver) || !pnpmPeerDependencyRulesSatisfyVitePlus(pkg.pnpm?.peerDependencyRules, usesVitest);
|
|
7936
|
-
return vitePlusDependencyNeedsConcreteVersion(pkg) || !overridesSatisfyVitePlus(pkg.pnpm?.overrides, usesVitest) || !pnpmPeerDependencyRulesSatisfyVitePlus(pkg.pnpm?.peerDependencyRules, usesVitest);
|
|
8408
|
+
if (supportCatalog) return catalogVitePlusDependencyPending(pkg, catalogDependencyResolver) || !overridesSatisfyVitePlus(pkg.pnpm?.overrides, usesVitest, catalogDependencyResolver, "pnpm-ranged") || !pnpmPeerDependencyRulesSatisfyVitePlus(pkg.pnpm?.peerDependencyRules, usesVitest);
|
|
8409
|
+
return vitePlusDependencyNeedsConcreteVersion(pkg) || !overridesSatisfyVitePlus(pkg.pnpm?.overrides, usesVitest, void 0, "pnpm-ranged") || !pnpmPeerDependencyRulesSatisfyVitePlus(pkg.pnpm?.peerDependencyRules, usesVitest);
|
|
7937
8410
|
}
|
|
7938
8411
|
const resolver = readPnpmWorkspaceCatalogDependencyResolver(projectPath);
|
|
7939
|
-
return workspaceCatalogVitePlusDependencyPending(projectPath, packages, resolver) || !overridesSatisfyVitePlus(readPnpmWorkspaceOverrides(projectPath), usesVitest, resolver) || !pnpmPeerDependencyRulesSatisfyVitePlus(readPnpmWorkspacePeerDependencyRules(projectPath), usesVitest) || pnpmWorkspaceMinimumReleaseAgeExemptionsPending(projectPath);
|
|
8412
|
+
return workspaceCatalogVitePlusDependencyPending(projectPath, packages, resolver) || !overridesSatisfyVitePlus(readPnpmWorkspaceOverrides(projectPath), usesVitest, resolver, "pnpm-ranged") || !pnpmPeerDependencyRulesSatisfyVitePlus(readPnpmWorkspacePeerDependencyRules(projectPath), usesVitest) || pnpmWorkspaceMinimumReleaseAgeExemptionsPending(projectPath);
|
|
7940
8413
|
}
|
|
7941
8414
|
return false;
|
|
7942
8415
|
}
|
|
@@ -7975,13 +8448,21 @@ function ensureVitePlusDependencySpecs(pkg, version, ensurePresent = true) {
|
|
|
7975
8448
|
function readTextFileIfExists(filePath) {
|
|
7976
8449
|
return fs.existsSync(filePath) ? fs.readFileSync(filePath, "utf-8") : void 0;
|
|
7977
8450
|
}
|
|
7978
|
-
function ensureOverrideEntries(overrides, usesVitest, catalogDependencyResolver) {
|
|
8451
|
+
function ensureOverrideEntries(overrides, usesVitest, catalogDependencyResolver, keyStyle = "bare") {
|
|
7979
8452
|
const next = { ...overrides };
|
|
7980
8453
|
let changed = false;
|
|
7981
|
-
if (!usesVitest && removeManagedVitestEntry(next)) changed = true;
|
|
7982
|
-
for (const [dependencyName, overrideSpec] of Object.entries(managedOverridePackages(usesVitest)))
|
|
7983
|
-
|
|
7984
|
-
|
|
8454
|
+
if (!usesVitest && removeManagedVitestEntry(next, keyStyle)) changed = true;
|
|
8455
|
+
for (const [dependencyName, overrideSpec] of Object.entries(managedOverridePackages(usesVitest))) {
|
|
8456
|
+
const overrideKey = managedOverrideKey(dependencyName, keyStyle);
|
|
8457
|
+
if (overrideKey !== dependencyName && next[dependencyName] !== void 0) {
|
|
8458
|
+
next[overrideKey] ??= next[dependencyName];
|
|
8459
|
+
delete next[dependencyName];
|
|
8460
|
+
changed = true;
|
|
8461
|
+
}
|
|
8462
|
+
if (!overrideSpecSatisfiesVitePlus(dependencyName, next[overrideKey], catalogDependencyResolver)) {
|
|
8463
|
+
next[overrideKey] = overrideSpec;
|
|
8464
|
+
changed = true;
|
|
8465
|
+
}
|
|
7985
8466
|
}
|
|
7986
8467
|
return {
|
|
7987
8468
|
overrides: next,
|
|
@@ -8061,7 +8542,7 @@ function ensureVitePlusBootstrap(workspaceInfo, report) {
|
|
|
8061
8542
|
}
|
|
8062
8543
|
} else if (workspaceInfo.packageManager === PackageManager.pnpm && !usePnpmWorkspaceYaml) {
|
|
8063
8544
|
pkg.pnpm ??= {};
|
|
8064
|
-
const ensured = ensureOverrideEntries(pkg.pnpm.overrides, usesVitest, supportCatalog ? readPnpmWorkspaceCatalogDependencyResolver(projectPath) : void 0);
|
|
8545
|
+
const ensured = ensureOverrideEntries(pkg.pnpm.overrides, usesVitest, supportCatalog ? readPnpmWorkspaceCatalogDependencyResolver(projectPath) : void 0, "pnpm-ranged");
|
|
8065
8546
|
if (ensured.changed) {
|
|
8066
8547
|
pkg.pnpm.overrides = ensured.overrides;
|
|
8067
8548
|
packageJsonChanged = true;
|
|
@@ -8100,7 +8581,7 @@ function ensureVitePlusBootstrap(workspaceInfo, report) {
|
|
|
8100
8581
|
const before = readTextFileIfExists(pnpmWorkspaceYamlPath);
|
|
8101
8582
|
migratePnpmSettingsToWorkspaceYaml(projectPath, movedPnpmSettings);
|
|
8102
8583
|
const catalogDependencyResolver = readPnpmWorkspaceCatalogDependencyResolver(projectPath);
|
|
8103
|
-
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);
|
|
8584
|
+
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);
|
|
8104
8585
|
if (fs.existsSync(pnpmWorkspaceYamlPath)) ensurePnpmWorkspacePackages(projectPath, workspaceInfo.workspacePatterns);
|
|
8105
8586
|
result.packageManagerConfig = before !== readTextFileIfExists(pnpmWorkspaceYamlPath);
|
|
8106
8587
|
} else {
|
|
@@ -8591,6 +9072,7 @@ function rewriteAllImports(projectPath, silent = false, report, preserveNuxtVite
|
|
|
8591
9072
|
const modified = result.modifiedFiles.length;
|
|
8592
9073
|
const preserved = result.preservedVitestFiles.length;
|
|
8593
9074
|
const errors = result.errors.length;
|
|
9075
|
+
for (const warning of result.warnings) warnMigration(`${displayRelative(warning.path)}: ${warning.message}`, report);
|
|
8594
9076
|
if (report) {
|
|
8595
9077
|
report.rewrittenImportFileCount += modified;
|
|
8596
9078
|
report.preservedUpstreamVitestImportFileCount += preserved;
|
|
@@ -8629,12 +9111,19 @@ function findGitRoot(startPath) {
|
|
|
8629
9111
|
}
|
|
8630
9112
|
}
|
|
8631
9113
|
async function initGitRepository(cwd) {
|
|
8632
|
-
|
|
9114
|
+
const result = await runCommandSilently({
|
|
8633
9115
|
command: "git",
|
|
8634
9116
|
args: ["init"],
|
|
8635
9117
|
cwd,
|
|
8636
9118
|
envs: process.env
|
|
8637
|
-
})
|
|
9119
|
+
});
|
|
9120
|
+
if (result.exitCode !== 0) {
|
|
9121
|
+
log.warn("Failed to initialize git repository");
|
|
9122
|
+
const stderr = result.stderr.toString().trim();
|
|
9123
|
+
if (stderr) log.info(stderr);
|
|
9124
|
+
return false;
|
|
9125
|
+
}
|
|
9126
|
+
return true;
|
|
8638
9127
|
}
|
|
8639
9128
|
//#endregion
|
|
8640
9129
|
//#region src/migration/migrator/git-hooks.ts
|
|
@@ -8898,20 +9387,64 @@ function parseNvmrcVersion(alias) {
|
|
|
8898
9387
|
* are touched, so shell `cat .nvmrc` and comments are left alone.
|
|
8899
9388
|
*/
|
|
8900
9389
|
const NODE_VERSION_FILE_NVMRC_RE = /(node-version-file:[ \t]*)(['"]?)(\.\/)?\.nvmrc\2(?=\s|$)/gm;
|
|
9390
|
+
function isCompositeActionFile(filePath) {
|
|
9391
|
+
try {
|
|
9392
|
+
const action = (0, import_dist.parse)(fs.readFileSync(filePath, "utf8"));
|
|
9393
|
+
return isPlainRecord(action) && isPlainRecord(action.runs) && action.runs.using === "composite";
|
|
9394
|
+
} catch {
|
|
9395
|
+
return false;
|
|
9396
|
+
}
|
|
9397
|
+
}
|
|
8901
9398
|
/**
|
|
8902
|
-
* Collect
|
|
8903
|
-
*
|
|
8904
|
-
*
|
|
8905
|
-
* (`.github/actions/**/action.{yml,yaml}`, which may nest at any depth). Returns
|
|
8906
|
-
* absolute paths; a missing `.github` tree just yields an empty list. `nocase`
|
|
8907
|
-
* keeps the match case-insensitive on case-sensitive filesystems.
|
|
9399
|
+
* Collect top-level workflows and composite action definitions under `.github`.
|
|
9400
|
+
* Action metadata must declare `runs.using: composite`. Paths are absolute, and
|
|
9401
|
+
* filename matching is case-insensitive.
|
|
8908
9402
|
*/
|
|
8909
9403
|
function collectGithubActionFiles(projectPath) {
|
|
8910
|
-
|
|
9404
|
+
const globOptions = {
|
|
8911
9405
|
cwd: path.join(projectPath, ".github"),
|
|
8912
9406
|
absolute: true,
|
|
8913
|
-
nocase: true
|
|
8914
|
-
|
|
9407
|
+
nocase: true,
|
|
9408
|
+
nodir: true
|
|
9409
|
+
};
|
|
9410
|
+
const workflows = globSync("workflows/*.{yml,yaml}", globOptions);
|
|
9411
|
+
const compositeActions = globSync("**/action.{yml,yaml}", {
|
|
9412
|
+
...globOptions,
|
|
9413
|
+
dot: true
|
|
9414
|
+
}).filter(isCompositeActionFile);
|
|
9415
|
+
return [.../* @__PURE__ */ new Set([...workflows, ...compositeActions])];
|
|
9416
|
+
}
|
|
9417
|
+
/**
|
|
9418
|
+
* Match an exact `voidzero-dev/setup-vp@v1` action reference while preserving
|
|
9419
|
+
* indentation, list syntax, quote style, and trailing comments. The end guard
|
|
9420
|
+
* prevents prefix matches such as `@v1.2.3` or `@v10`.
|
|
9421
|
+
*/
|
|
9422
|
+
const SETUP_VP_V1_RE = /^([ \t]*(?:-[ \t]*)?uses[ \t]*:[ \t]*)(['"]?)voidzero-dev\/setup-vp@v1\2(?=[ \t]*(?:#.*)?\r?$)/gm;
|
|
9423
|
+
/**
|
|
9424
|
+
* Replace the frozen `voidzero-dev/setup-vp@v1` tag with the latest exact
|
|
9425
|
+
* release known to this Vite+ version. GitHub workflow files and composite
|
|
9426
|
+
* action definitions are both covered. Existing exact versions, commit SHAs,
|
|
9427
|
+
* and commented-out steps are left unchanged.
|
|
9428
|
+
*
|
|
9429
|
+
* Returns the project-relative paths of the updated files.
|
|
9430
|
+
*/
|
|
9431
|
+
function migrateSetupVpVersion(projectPath, report) {
|
|
9432
|
+
const updatedFiles = [];
|
|
9433
|
+
for (const filePath of collectGithubActionFiles(projectPath)) {
|
|
9434
|
+
const relativePath = path.relative(projectPath, filePath);
|
|
9435
|
+
try {
|
|
9436
|
+
const original = fs.readFileSync(filePath, "utf8");
|
|
9437
|
+
const rewritten = original.replace(SETUP_VP_V1_RE, `$1$2voidzero-dev/setup-vp@${SETUP_VP_VERSION}$2`);
|
|
9438
|
+
if (rewritten !== original) {
|
|
9439
|
+
fs.writeFileSync(filePath, rewritten);
|
|
9440
|
+
updatedFiles.push(relativePath);
|
|
9441
|
+
}
|
|
9442
|
+
} catch (error) {
|
|
9443
|
+
warnMigration(`Could not update the setup-vp version in ${relativePath}: ${error instanceof Error ? error.message : String(error)}`, report);
|
|
9444
|
+
}
|
|
9445
|
+
}
|
|
9446
|
+
if (report) report.setupVpVersionUpdatedFileCount += updatedFiles.length;
|
|
9447
|
+
return updatedFiles;
|
|
8915
9448
|
}
|
|
8916
9449
|
/**
|
|
8917
9450
|
* After `.nvmrc` is converted to `.node-version`, rewrite any GitHub Actions
|
|
@@ -9104,16 +9637,12 @@ function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigratio
|
|
|
9104
9637
|
if (!usePnpmWorkspaceYaml) {
|
|
9105
9638
|
dropRemovePackageOverrideKeys(pkg.pnpm?.overrides);
|
|
9106
9639
|
if (!usesVitest) {
|
|
9107
|
-
removeManagedVitestEntry(pkg.pnpm?.overrides);
|
|
9640
|
+
removeManagedVitestEntry(pkg.pnpm?.overrides, "pnpm-ranged");
|
|
9108
9641
|
if (pkg.pnpm?.peerDependencyRules) removeVitestPeerDependencyRule(pkg.pnpm.peerDependencyRules);
|
|
9109
9642
|
}
|
|
9110
9643
|
pkg.pnpm = {
|
|
9111
9644
|
...pkg.pnpm,
|
|
9112
|
-
overrides:
|
|
9113
|
-
...pkg.pnpm?.overrides,
|
|
9114
|
-
...managed,
|
|
9115
|
-
...isForceOverrideMode() ? { [VITE_PLUS_NAME]: VITE_PLUS_VERSION } : {}
|
|
9116
|
-
},
|
|
9645
|
+
overrides: mergeManagedPnpmOverrides(pkg.pnpm?.overrides, managed),
|
|
9117
9646
|
peerDependencyRules: {
|
|
9118
9647
|
...pkg.pnpm?.peerDependencyRules,
|
|
9119
9648
|
allowAny: [.../* @__PURE__ */ new Set([...pkg.pnpm?.peerDependencyRules?.allowAny ?? [], ...overrideKeys])],
|
|
@@ -9283,8 +9812,7 @@ const ZED_SETTINGS = {
|
|
|
9283
9812
|
].map((language) => [language, {
|
|
9284
9813
|
format_on_save: "on",
|
|
9285
9814
|
prettier: { allowed: false },
|
|
9286
|
-
formatter: [{ language_server: { name: "oxfmt" } }]
|
|
9287
|
-
...language === "JavaScript" ? { code_action: "source.fixAll.oxc" } : {}
|
|
9815
|
+
formatter: [{ language_server: { name: "oxfmt" } }, ...language === "JavaScript" ? [{ code_action: "source.fixAll.oxc" }] : []]
|
|
9288
9816
|
}]))
|
|
9289
9817
|
};
|
|
9290
9818
|
const JETBRAINS_EXTERNAL_DEPENDENCIES = `<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -9294,13 +9822,16 @@ const JETBRAINS_EXTERNAL_DEPENDENCIES = `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
9294
9822
|
</component>
|
|
9295
9823
|
</project>
|
|
9296
9824
|
`;
|
|
9825
|
+
function jetbrainsNodeInterpreterPath() {
|
|
9826
|
+
return path.join(getVpDirs().bin, process.platform === "win32" ? "node.exe" : "node");
|
|
9827
|
+
}
|
|
9297
9828
|
function jetbrainsWorkspaceConfig(packageManager) {
|
|
9298
9829
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
9299
9830
|
<project version="4">
|
|
9300
9831
|
<component name="PropertiesComponent">
|
|
9301
9832
|
<![CDATA[${JSON.stringify({ keyToString: {
|
|
9302
9833
|
"javascript.preferred.runtime.type.id": "node",
|
|
9303
|
-
nodejs_interpreter_path:
|
|
9834
|
+
nodejs_interpreter_path: jetbrainsNodeInterpreterPath(),
|
|
9304
9835
|
nodejs_package_manager_path: packageManager
|
|
9305
9836
|
} }, null, 2)}]]>
|
|
9306
9837
|
</component>
|
|
@@ -9588,4 +10119,4 @@ function resolveEditorIds(editors) {
|
|
|
9588
10119
|
return uniqueEditorIds.length === 0 ? void 0 : uniqueEditorIds;
|
|
9589
10120
|
}
|
|
9590
10121
|
//#endregion
|
|
9591
|
-
export {
|
|
10122
|
+
export { warnIncompatibleEslintIntegration as $, detectYarnPnpMode as A, migrateTsupToTsdown as B, injectLintTypeCheckDefaults as C, detectVitePlusBootstrapPending as D, collectToolchainVersionChanges as E, addFrameworkShim as F, migratePrettierToOxfmt as G, warnMissingTsupConfig as H, detectFramework as I, confirmEslintMigration as J, promptPrettierMigration as K, hasFrameworkShim as L, isBingoTemplate as M, updatePackageJsonWithDeps as N, ensureVitePlusBootstrap as O, updateWorkspaceConfig as P, promptEslintMigration as Q, confirmTsupMigration as R, injectCreateDefaultTemplate as S, mergeViteConfigFiles as T, confirmPrettierMigration as U, promptTsupMigration as V, detectPrettierProject as W, detectIncompatibleEslintIntegration as X, detectEslintProject as Y, migrateEslintToOxlint as Z, installGitHooks as _, selectEditors as a, findGitRoot as b, rewriteMonorepoProject as c, finalizeCoreMigrationForExistingVitePlus as d, warnLegacyEslintConfig as et, detectNodeVersionManagerFile as f, detectLegacyGitHooksMigrationCandidate as g, setPackageManager as h, selectEditor as i, detectWorkspace$1 as j, configureYarnNodeModulesMode as k, rewriteStandaloneProject as l, migrateSetupVpVersion as m, detectExistingEditors as n, checkViteVersion as nt, writeEditorConfigs as o, migrateNodeVersionManagerFile as p, warnPackageLevelPrettier as q, isJsonLikeFile as r, checkVitestVersion as rt, rewriteMonorepo as s, detectEditorConflicts as t, warnPackageLevelEslint as tt, detectPendingCoreMigration as u, preflightGitHooksSetup as v, mergeTsdownConfigFile as w, initGitRepository as x, shouldSkipStagedMigrationForHooks as y, detectTsupProject as z };
|