vite-plus 0.3.0 → 0.3.2
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 +3 -3
- package/bin/vp +1 -1
- package/binding/index.cjs +60 -56
- package/binding/index.d.cts +137 -14
- package/dist/{agent-Wqx0MPk0.js → agent-C59HKB4Y.js} +3 -2
- package/dist/bin.js +90 -58
- 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/config/bin.js +83 -55
- package/dist/{constants-Bn-U8o4v.js → constants-IhOditRA.js} +3 -3
- package/dist/create/bin.d.ts +13 -5
- package/dist/create/bin.js +50 -193
- package/dist/{define-config-GXUdVT-0.js → define-config-DAaCa0U_.js} +2 -2
- package/dist/{define-config-DWoAkNdp.d.ts → define-config-DPNEJxPz.d.ts} +5 -9
- package/dist/{define-config-WiVlryJ2.cjs → define-config-DpAPETDf.cjs} +1 -1
- 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-CC4DqODz.js → editor-QOIGtmH4.js} +205 -70
- package/dist/hooks/bin.js +9 -114
- package/dist/{hooks-DFqViZqZ.js → hooks-C-4gykWR.js} +1 -1
- 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/lint-plugins-dev.d.ts +3 -0
- package/dist/lint-plugins-dev.js +2 -0
- package/dist/lint-plugins.cjs +21 -0
- package/dist/lint-plugins.d.ts +3 -0
- package/dist/lint-plugins.js +2 -0
- package/dist/migration/bin.js +25 -144
- 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-DX5ezKbB.js → oxlint-plugin-config-BU42tr8y.js} +1 -1
- package/dist/oxlint-plugin.d.ts +2 -2
- package/dist/oxlint-plugin.js +93 -32
- 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 +5 -622
- package/dist/pack-client.d.ts +1 -1
- package/dist/pack.d.ts +2 -2
- package/dist/pack.js +1 -1
- package/dist/{package-CBe9EWPY.js → package-BB-Jh_z3.js} +1 -1
- package/dist/{prompts-DF3yU-eU.js → prompts-CujFOJXu.js} +3 -1400
- package/dist/{report-ZNR1Mk6h.js → report-CK5TnTsr.js} +1 -0
- package/dist/resolve-vite-config-6Nox70uP.js +2 -0
- package/dist/{resolve-vite-config-ipGb39Jo.js → resolve-vite-config-CHHjsjKJ.js} +3 -3
- package/dist/semver-CaDAb8vV.js +1400 -0
- package/dist/staged/bin.js +83 -218
- 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/toolchain.js +10 -10
- package/dist/toolchain.json +10 -10
- package/dist/{tsconfig-LD2QhQ0O.js → tsconfig-DCtWfQPA.js} +2 -2
- package/dist/{tsconfig-BVHG3DpR.js → tsconfig-MXktI3SX.js} +1 -1
- 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 +2 -2
- package/dist/versions.js +5 -5
- package/dist/vitest-ecosystem-BiRqcaRI.js +23 -0
- package/docs/config/fmt.md +4 -2
- package/docs/config/lint.md +4 -2
- package/docs/guide/check.md +1 -0
- package/docs/guide/ci.md +42 -2
- package/docs/guide/env.md +148 -52
- package/docs/guide/fmt.md +3 -1
- package/docs/guide/ide-integration.md +14 -2
- package/docs/guide/index.md +1 -1
- package/docs/guide/install.md +4 -1
- package/docs/guide/installer-env-vars.md +45 -1
- package/docs/guide/lint.md +58 -1
- package/docs/guide/migrate-rules.md +95 -2
- package/docs/guide/migrate.md +1 -1
- package/docs/guide/monorepo.md +2 -0
- package/docs/guide/troubleshooting.md +14 -0
- package/package.json +27 -20
- package/templates/generator/README.md +14 -0
- package/templates/generator/bin/index.ts +54 -5
- package/dist/lib-L3DWSRQp.js +0 -75
- package/dist/{log-update-DHZRyJ2m.js → log-update-CoW8Z4Dl.js} +1 -1
|
@@ -1,15 +1,17 @@
|
|
|
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 { 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";
|
|
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-IhOditRA.js";
|
|
3
|
+
import { i as ensureVitePlusImportRuleDefaults, r as createDefaultVitePlusLintConfig } from "./oxlint-plugin-config-BU42tr8y.js";
|
|
5
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";
|
|
6
|
-
import { n as detectPackageMetadata, r as getScopeFromPackageName } from "./package-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { n as detectPackageMetadata, r as getScopeFromPackageName } from "./package-BB-Jh_z3.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-CujFOJXu.js";
|
|
7
|
+
import { t as require_semver } from "./semver-CaDAb8vV.js";
|
|
8
|
+
import { l as displayRelative, u as rulesDir } from "./agent-C59HKB4Y.js";
|
|
9
|
+
import { n as addMigrationWarning, t as addManualStep } from "./report-CK5TnTsr.js";
|
|
9
10
|
import { n as runCommandSilently, r as require_cross_spawn } from "./command-CguLh2KL.js";
|
|
10
11
|
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-
|
|
12
|
-
import {
|
|
12
|
+
import { a as hasBaseUrlInTsconfig, c as hasVitestTypesInTsconfig, l as removeDeprecatedTsconfigFalseOption, n as findTsconfigFiles, s as hasTypesToRewriteInTsconfig, u as rewriteTypesInTsconfig } from "./tsconfig-DCtWfQPA.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";
|
|
13
15
|
import path, { posix, win32 } from "node:path";
|
|
14
16
|
import { fileURLToPath } from "node:url";
|
|
15
17
|
import { detectWorkspace, getVpDirs, hasConfigKey, mergeJsonConfig, mergeTsdownConfig, rewriteEslint, rewriteImportsInDirectory, rewritePrettier, rewriteScripts, wrapLazyPlugins } from "../binding/index.js";
|
|
@@ -19,6 +21,7 @@ import fs from "node:fs";
|
|
|
19
21
|
import os from "node:os";
|
|
20
22
|
import "oxlint";
|
|
21
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" };
|
|
22
25
|
import fsPromises, { lstat, readdir as readdir$1, readlink, realpath } from "node:fs/promises";
|
|
23
26
|
import { EventEmitter } from "node:events";
|
|
24
27
|
import Stream from "node:stream";
|
|
@@ -59,13 +62,14 @@ const BROWSER_PROVIDER_PEER_DEPS = {
|
|
|
59
62
|
"@vitest/browser-playwright": "playwright",
|
|
60
63
|
"@vitest/browser-webdriverio": "webdriverio"
|
|
61
64
|
};
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
webdriverio: ["@wdio/cli", "@wdio/globals"]
|
|
65
|
-
};
|
|
65
|
+
const RUNTIME_PEER_INCLUDED_BY = { playwright: ["@playwright/test"] };
|
|
66
|
+
const PROVIDER_PEER_VERSION_SIBLINGS = { webdriverio: ["@wdio/cli", "@wdio/globals"] };
|
|
66
67
|
function findDeclaredSpec(pkg, name) {
|
|
67
68
|
return pkg.dependencies?.[name] ?? pkg.devDependencies?.[name] ?? pkg.peerDependencies?.[name] ?? pkg.optionalDependencies?.[name];
|
|
68
69
|
}
|
|
70
|
+
function hasProviderPeerDependency(pkg, runtimePeer) {
|
|
71
|
+
return findDeclaredSpec(pkg, runtimePeer) !== void 0 || (RUNTIME_PEER_INCLUDED_BY[runtimePeer] ?? []).some((packageName) => findDeclaredSpec(pkg, packageName) !== void 0);
|
|
72
|
+
}
|
|
69
73
|
function resolveProviderPeerSpec(pkg, peer, supportCatalog, catalogDependencyResolver) {
|
|
70
74
|
if (supportCatalog && catalogDependencyResolver?.("catalog:", peer) !== void 0) return "catalog:";
|
|
71
75
|
for (const sibling of PROVIDER_PEER_VERSION_SIBLINGS[peer] ?? []) {
|
|
@@ -172,6 +176,24 @@ function pnpmMajor(version) {
|
|
|
172
176
|
const coerced = version ? import_semver.default.coerce(version)?.version : void 0;
|
|
173
177
|
return coerced ? import_semver.default.major(coerced) : void 0;
|
|
174
178
|
}
|
|
179
|
+
const OXLINT_PLUGINS_PACKAGE = "@oxlint/plugins";
|
|
180
|
+
const OXLINT_PLUGIN_API_PACKAGES = ["oxlint", OXLINT_PLUGINS_PACKAGE];
|
|
181
|
+
function packageOwnsOxlintApi(pkg) {
|
|
182
|
+
return pkg.optionalDependencies?.["@oxlint/plugins"] !== void 0 || OXLINT_PLUGIN_API_PACKAGES.some((name) => pkg.dependencies?.[name] !== void 0 || pkg.peerDependencies?.[name] !== void 0);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Capture plugin owners before manifest edits, so the import rewriter can
|
|
186
|
+
* preserve their upstream API imports after those edits.
|
|
187
|
+
*/
|
|
188
|
+
function collectOxlintOwnerDirs(rootDir, packages) {
|
|
189
|
+
const owners = [];
|
|
190
|
+
const candidates = [rootDir, ...(packages ?? []).map((pkg) => path.join(rootDir, pkg.path))];
|
|
191
|
+
for (const dir of candidates) {
|
|
192
|
+
const pkg = readPackageJsonIfExists(path.join(dir, "package.json"));
|
|
193
|
+
if (pkg && packageOwnsOxlintApi(pkg)) owners.push(dir);
|
|
194
|
+
}
|
|
195
|
+
return owners;
|
|
196
|
+
}
|
|
175
197
|
//#endregion
|
|
176
198
|
//#region src/migration/detector.ts
|
|
177
199
|
const PRETTIER_PACKAGE_JSON_CONFIG = "package.json#prettier";
|
|
@@ -328,6 +350,18 @@ function detectEslintProject(projectPath, packages) {
|
|
|
328
350
|
legacyConfigFile
|
|
329
351
|
};
|
|
330
352
|
}
|
|
353
|
+
function extractSkippedRules(output) {
|
|
354
|
+
const lines = output.toString().replaceAll("\r\n", "\n").split("\n");
|
|
355
|
+
const start = lines.findIndex((line) => /^\s*Skipped \d+ rules:/.test(line));
|
|
356
|
+
if (start === -1) return;
|
|
357
|
+
const indentation = lines[start].search(/\S/);
|
|
358
|
+
const block = [lines[start].trim()];
|
|
359
|
+
for (const line of lines.slice(start + 1)) {
|
|
360
|
+
if (line.trim() === "" || line.search(/\S/) <= indentation) break;
|
|
361
|
+
block.push(` ${line.slice(indentation)}`);
|
|
362
|
+
}
|
|
363
|
+
return block.join("\n");
|
|
364
|
+
}
|
|
331
365
|
/**
|
|
332
366
|
* Run a `vp dlx @oxlint/migrate` step with graceful error handling.
|
|
333
367
|
* Returns true on success, false on failure (spawn error or non-zero exit).
|
|
@@ -349,13 +383,16 @@ async function runOxlintMigrateStep(vpBin, cwd, migratePackage, args, spinner, f
|
|
|
349
383
|
const stderr = result.stderr.toString().trim();
|
|
350
384
|
if (stderr) log.warn(`⚠ ${stderr}`);
|
|
351
385
|
log.info(manualHint);
|
|
352
|
-
return false;
|
|
386
|
+
return { ok: false };
|
|
353
387
|
}
|
|
354
|
-
return
|
|
388
|
+
return {
|
|
389
|
+
ok: true,
|
|
390
|
+
skippedRules: extractSkippedRules(result.stdout)
|
|
391
|
+
};
|
|
355
392
|
} catch {
|
|
356
393
|
spinner.stop(failMessage);
|
|
357
394
|
log.info(manualHint);
|
|
358
|
-
return false;
|
|
395
|
+
return { ok: false };
|
|
359
396
|
}
|
|
360
397
|
}
|
|
361
398
|
async function migrateEslintToOxlint(projectPath, interactive, eslintConfigFile, packages, options) {
|
|
@@ -371,10 +408,12 @@ async function migrateEslintToOxlint(projectPath, interactive, eslintConfigFile,
|
|
|
371
408
|
"--details"
|
|
372
409
|
];
|
|
373
410
|
spinner.start("Migrating ESLint config to Oxlint...");
|
|
374
|
-
|
|
411
|
+
const migrateResult = await runOxlintMigrateStep(vpBin, projectPath, migratePackage, migrateArgs, spinner, "ESLint migration failed", `You can run \`vp dlx ${migratePackage} ${migrateArgs.join(" ")}\` manually later`);
|
|
412
|
+
if (!migrateResult.ok) return false;
|
|
375
413
|
spinner.stop("ESLint config migrated to .oxlintrc.json");
|
|
414
|
+
if (migrateResult.skippedRules) warnMigration(migrateResult.skippedRules, options?.report);
|
|
376
415
|
spinner.start("Replacing ESLint comments with Oxlint equivalents...");
|
|
377
|
-
if (await runOxlintMigrateStep(vpBin, projectPath, migratePackage, ["--replace-eslint-comments"], spinner, "ESLint comment replacement failed", `You can run \`vp dlx ${migratePackage} --replace-eslint-comments\` manually later`)) spinner.stop("ESLint comments replaced");
|
|
416
|
+
if ((await runOxlintMigrateStep(vpBin, projectPath, migratePackage, ["--replace-eslint-comments"], spinner, "ESLint comment replacement failed", `You can run \`vp dlx ${migratePackage} --replace-eslint-comments\` manually later`)).ok) spinner.stop("ESLint comments replaced");
|
|
378
417
|
}
|
|
379
418
|
if (options?.report) options.report.eslintMigrated = true;
|
|
380
419
|
const preserveJsPlugins = collectJsPluginPackageNames(projectPath);
|
|
@@ -1150,7 +1189,7 @@ async function runTsdownMigrateStep(vpBin, cwd, packageManager) {
|
|
|
1150
1189
|
command: vpBin,
|
|
1151
1190
|
args: [
|
|
1152
1191
|
"dlx",
|
|
1153
|
-
`tsdown-migrate@${
|
|
1192
|
+
`tsdown-migrate@${corePkg.bundledVersions.tsdown}`,
|
|
1154
1193
|
"--yes",
|
|
1155
1194
|
"--package-manager",
|
|
1156
1195
|
packageManager,
|
|
@@ -1416,7 +1455,6 @@ function addFrameworkShim(projectPath, framework, report) {
|
|
|
1416
1455
|
//#endregion
|
|
1417
1456
|
//#region src/migration/migrator/vitest-ecosystem.ts
|
|
1418
1457
|
var import_dist = require_dist();
|
|
1419
|
-
const VITEST_ALIGN_EXCLUDED = /* @__PURE__ */ new Set(["@vitest/eslint-plugin", "@vitest/coverage-c8"]);
|
|
1420
1458
|
const VITEST_DIRECT_USAGE_EXCLUDED = /* @__PURE__ */ new Set([
|
|
1421
1459
|
"@vitest/eslint-plugin",
|
|
1422
1460
|
"@vitest/expect",
|
|
@@ -1428,24 +1466,6 @@ const VITEST_DIRECT_USAGE_EXCLUDED = /* @__PURE__ */ new Set([
|
|
|
1428
1466
|
"@vitest/utils",
|
|
1429
1467
|
"@vitest/ws-client"
|
|
1430
1468
|
]);
|
|
1431
|
-
function isAlignableVitestEcosystemPackage(name) {
|
|
1432
|
-
return name.startsWith("@vitest/") && !VITEST_ALIGN_EXCLUDED.has(name);
|
|
1433
|
-
}
|
|
1434
|
-
function extractOverrideTargetName(key) {
|
|
1435
|
-
let target = key.trim();
|
|
1436
|
-
for (let delim = target.search(/[^ |@]>/); delim !== -1; delim = target.search(/[^ |@]>/)) target = target.slice(delim + 2).trim();
|
|
1437
|
-
if (!target) return target;
|
|
1438
|
-
if (target.includes("/")) {
|
|
1439
|
-
const segments = target.split("/");
|
|
1440
|
-
const last = segments[segments.length - 1];
|
|
1441
|
-
const scope = segments[segments.length - 2];
|
|
1442
|
-
target = scope?.startsWith("@") ? `${scope}/${last}` : last;
|
|
1443
|
-
}
|
|
1444
|
-
const nameStart = target.startsWith("@") ? target.indexOf("/") + 1 : 0;
|
|
1445
|
-
const versionAt = target.indexOf("@", nameStart);
|
|
1446
|
-
if (versionAt > 0) target = target.slice(0, versionAt);
|
|
1447
|
-
return target;
|
|
1448
|
-
}
|
|
1449
1469
|
function isRemovePackageOverrideKey(key) {
|
|
1450
1470
|
return PROVIDER_OVERRIDE_DROP_NAMES.includes(extractOverrideTargetName(key));
|
|
1451
1471
|
}
|
|
@@ -8085,6 +8105,12 @@ const VITEST_SCAN_SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
|
8085
8105
|
".vite",
|
|
8086
8106
|
".cache"
|
|
8087
8107
|
]);
|
|
8108
|
+
const OXLINT_RETENTION_SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
8109
|
+
"node_modules",
|
|
8110
|
+
".git",
|
|
8111
|
+
".hg",
|
|
8112
|
+
".svn"
|
|
8113
|
+
]);
|
|
8088
8114
|
/**
|
|
8089
8115
|
* Detect whether a package uses vitest's browser mode.
|
|
8090
8116
|
*
|
|
@@ -8109,26 +8135,35 @@ const VITEST_SCAN_SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
|
8109
8135
|
* is a separate package that the migration scans on its own pass, so the root
|
|
8110
8136
|
* package must not inherit a browser-mode signal from a sub-package.
|
|
8111
8137
|
*/
|
|
8112
|
-
function sourceTreeMatches(projectPath, matchesContent) {
|
|
8113
|
-
const
|
|
8138
|
+
function sourceTreeMatches(projectPath, matchesContent, options = {}) {
|
|
8139
|
+
const skipDirs = options.skipDirs ?? VITEST_SCAN_SKIP_DIRS;
|
|
8140
|
+
function scanDir(dir, isRoot) {
|
|
8114
8141
|
let entries;
|
|
8115
8142
|
try {
|
|
8116
8143
|
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
8117
8144
|
} catch {
|
|
8118
8145
|
return false;
|
|
8119
8146
|
}
|
|
8120
|
-
if (!isRoot && entries.some((e) => e.isFile() && e.name === "package.json")) return false;
|
|
8147
|
+
if (!options.crossPackageBoundaries && !isRoot && entries.some((e) => e.isFile() && e.name === "package.json")) return false;
|
|
8121
8148
|
for (const entry of entries) {
|
|
8122
8149
|
const entryPath = path.join(dir, entry.name);
|
|
8123
8150
|
if (entry.isDirectory()) {
|
|
8124
|
-
if (
|
|
8151
|
+
if (skipDirs.has(entry.name)) continue;
|
|
8125
8152
|
if (scanDir(entryPath, false)) return true;
|
|
8126
|
-
} else if (entry.isFile() && VITEST_SCAN_EXTENSIONS.has(path.extname(entry.name))) try {
|
|
8127
|
-
|
|
8153
|
+
} else if (entry.isFile() && (VITEST_SCAN_EXTENSIONS.has(path.extname(entry.name)) || options.includePackageReferences && entry.name === "package.json")) try {
|
|
8154
|
+
let content = fs.readFileSync(entryPath, "utf8");
|
|
8155
|
+
if (entry.name === "package.json") {
|
|
8156
|
+
const pkg = JSON.parse(content);
|
|
8157
|
+
content = JSON.stringify({
|
|
8158
|
+
imports: pkg.imports,
|
|
8159
|
+
scripts: pkg.scripts
|
|
8160
|
+
});
|
|
8161
|
+
}
|
|
8162
|
+
if (matchesContent(content)) return true;
|
|
8128
8163
|
} catch {}
|
|
8129
8164
|
}
|
|
8130
8165
|
return false;
|
|
8131
|
-
}
|
|
8166
|
+
}
|
|
8132
8167
|
return scanDir(projectPath, true);
|
|
8133
8168
|
}
|
|
8134
8169
|
function sourceTreeReferencesAny(projectPath, hints) {
|
|
@@ -8177,6 +8212,39 @@ function collectProviderSourceModes(projectPath) {
|
|
|
8177
8212
|
for (const provider of OPT_IN_BROWSER_PROVIDERS) modes[provider] = sourceTreeReferencesAny(projectPath, BROWSER_PROVIDER_SPECIFIER_HINTS[provider]);
|
|
8178
8213
|
return modes;
|
|
8179
8214
|
}
|
|
8215
|
+
/**
|
|
8216
|
+
* Check final source, build output, package import aliases, and package scripts.
|
|
8217
|
+
* A substring scan conservatively retains references the rewriter leaves alone,
|
|
8218
|
+
* including require calls, type references, and strings.
|
|
8219
|
+
*/
|
|
8220
|
+
function sourceTreeReferencesOxlintPluginsPackage(projectPath) {
|
|
8221
|
+
return sourceTreeMatches(projectPath, (content) => content.includes(OXLINT_PLUGINS_PACKAGE), {
|
|
8222
|
+
crossPackageBoundaries: true,
|
|
8223
|
+
includePackageReferences: true,
|
|
8224
|
+
skipDirs: OXLINT_RETENTION_SKIP_DIRS
|
|
8225
|
+
});
|
|
8226
|
+
}
|
|
8227
|
+
/**
|
|
8228
|
+
* Drop `@oxlint/plugins` from devDependencies once nothing names it any more.
|
|
8229
|
+
*
|
|
8230
|
+
* Runs AFTER the import rewrite, so the scan sees final source. Skips a package
|
|
8231
|
+
* that owns the API as a runtime or peer dependency, and skips any package
|
|
8232
|
+
* whose source or build output still names it.
|
|
8233
|
+
*/
|
|
8234
|
+
function dropDeadOxlintPluginsDependency(rootDir, packages) {
|
|
8235
|
+
const dirs = [rootDir, ...(packages ?? []).map((pkg) => path.join(rootDir, pkg.path))];
|
|
8236
|
+
for (const dir of dirs) {
|
|
8237
|
+
const packageJsonPath = path.join(dir, "package.json");
|
|
8238
|
+
const pkg = readPackageJsonIfExists(packageJsonPath);
|
|
8239
|
+
if (pkg?.devDependencies?.["@oxlint/plugins"] === void 0) continue;
|
|
8240
|
+
if (packageOwnsOxlintApi(pkg) || sourceTreeReferencesOxlintPluginsPackage(dir)) continue;
|
|
8241
|
+
editJsonFile(packageJsonPath, (json) => {
|
|
8242
|
+
if (json.devDependencies?.["@oxlint/plugins"] === void 0) return;
|
|
8243
|
+
delete json.devDependencies[OXLINT_PLUGINS_PACKAGE];
|
|
8244
|
+
return json;
|
|
8245
|
+
});
|
|
8246
|
+
}
|
|
8247
|
+
}
|
|
8180
8248
|
//#endregion
|
|
8181
8249
|
//#region src/migration/migrator/vite-plus-bootstrap.ts
|
|
8182
8250
|
function bunWorkspaceDeclaresPackages(workspaces) {
|
|
@@ -8317,8 +8385,7 @@ function reconcileVitePlusBootstrapPackage(projectPath, pkg, vitePlusVersion, pa
|
|
|
8317
8385
|
pkg.devDependencies[provider] = getCatalogDependencySpec(void 0, VITEST_VERSION, supportCatalog && packageManager !== PackageManager.bun, { preferredCatalogSpec: catalogDependencyResolver?.preferredCatalogSpec });
|
|
8318
8386
|
}
|
|
8319
8387
|
const frameworkPeer = BROWSER_PROVIDER_PEER_DEPS[provider];
|
|
8320
|
-
|
|
8321
|
-
if (frameworkPeer && !frameworkPresent) {
|
|
8388
|
+
if (!hasProviderPeerDependency(pkg, frameworkPeer)) {
|
|
8322
8389
|
pkg.devDependencies ??= {};
|
|
8323
8390
|
pkg.devDependencies[frameworkPeer] = resolveProviderPeerSpec(pkg, frameworkPeer, supportCatalog, catalogDependencyResolver);
|
|
8324
8391
|
}
|
|
@@ -8778,11 +8845,23 @@ function rewritePackageJson(pkg, packageManager, isMonorepo, skipStagedMigration
|
|
|
8778
8845
|
}
|
|
8779
8846
|
}
|
|
8780
8847
|
const hasBrowserDepSignal = VITEST_BROWSER_DEP_NAMES.some((name) => dependencyGroups.some(({ dependencies }) => dependencies?.[name] !== void 0));
|
|
8848
|
+
const ownsOxlintApi = packageOwnsOxlintApi(pkg);
|
|
8849
|
+
if (pkg.devDependencies?.["@oxlint/plugins"] !== void 0 && !ownsOxlintApi) needVitePlus = true;
|
|
8781
8850
|
for (const name of REMOVE_PACKAGES) {
|
|
8782
8851
|
let wasRemoved = false;
|
|
8783
|
-
for (const { dependencies } of dependencyGroups)
|
|
8784
|
-
|
|
8785
|
-
|
|
8852
|
+
for (const { dependencyField, dependencies } of dependencyGroups) {
|
|
8853
|
+
if (ownsOxlintApi && (dependencyField === "peerDependencies" || dependencyField === "dependencies") && OXLINT_PLUGIN_API_PACKAGES.includes(name)) {
|
|
8854
|
+
const current = dependencies?.[name];
|
|
8855
|
+
if (current?.startsWith("catalog:") && dependencies) {
|
|
8856
|
+
const resolved = catalogDependencyResolver?.(current, name);
|
|
8857
|
+
if (resolved) dependencies[name] = resolved;
|
|
8858
|
+
}
|
|
8859
|
+
continue;
|
|
8860
|
+
}
|
|
8861
|
+
if (dependencies?.[name]) {
|
|
8862
|
+
delete dependencies[name];
|
|
8863
|
+
wasRemoved = true;
|
|
8864
|
+
}
|
|
8786
8865
|
}
|
|
8787
8866
|
if (wasRemoved) needVitePlus = true;
|
|
8788
8867
|
}
|
|
@@ -8798,8 +8877,7 @@ function rewritePackageJson(pkg, packageManager, isMonorepo, skipStagedMigration
|
|
|
8798
8877
|
pkg.devDependencies[provider] = getCatalogDependencySpec(void 0, VITEST_VERSION, supportCatalog && packageManager !== PackageManager.bun, { preferredCatalogSpec: catalogDependencyResolver?.preferredCatalogSpec });
|
|
8799
8878
|
}
|
|
8800
8879
|
const peer = BROWSER_PROVIDER_PEER_DEPS[provider];
|
|
8801
|
-
|
|
8802
|
-
if (peer && !peerPresent) {
|
|
8880
|
+
if (!hasProviderPeerDependency(pkg, peer)) {
|
|
8803
8881
|
pkg.devDependencies ??= {};
|
|
8804
8882
|
pkg.devDependencies[peer] = resolveProviderPeerSpec(pkg, peer, supportCatalog, catalogDependencyResolver);
|
|
8805
8883
|
}
|
|
@@ -8927,15 +9005,21 @@ export default defineConfig({});
|
|
|
8927
9005
|
*/
|
|
8928
9006
|
function mergeTsdownConfigFile(projectPath, silent = false, report) {
|
|
8929
9007
|
const configs = detectConfigs(projectPath);
|
|
8930
|
-
if (!configs.tsdownConfig) return;
|
|
9008
|
+
if (!configs.tsdownConfig) return false;
|
|
9009
|
+
const createdViteConfig = !configs.viteConfig;
|
|
8931
9010
|
const viteConfig = ensureViteConfig(projectPath, configs, silent, report);
|
|
8932
9011
|
const fullViteConfigPath = path.join(projectPath, viteConfig);
|
|
8933
9012
|
const fullTsdownConfigPath = path.join(projectPath, configs.tsdownConfig);
|
|
8934
9013
|
if (configs.tsdownConfig.endsWith(".json")) {
|
|
8935
9014
|
mergeAndRemoveJsonConfig(projectPath, viteConfig, configs.tsdownConfig, "pack", silent, report);
|
|
8936
|
-
return;
|
|
9015
|
+
return createdViteConfig || !fs.existsSync(fullTsdownConfigPath);
|
|
8937
9016
|
}
|
|
8938
9017
|
const tsdownRelativePath = `./${configs.tsdownConfig}`;
|
|
9018
|
+
if (hasConfigKey(fullViteConfigPath, "pack")) {
|
|
9019
|
+
const viteConfigContent = fs.readFileSync(fullViteConfigPath, "utf8");
|
|
9020
|
+
if (![tsdownRelativePath, tsdownRelativePath.replace(/\.mts$/, ".mjs").replace(/\.cts$/, ".cjs").replace(/\.ts$/, ".js")].some((importPath) => viteConfigContent.includes(`from '${importPath}'`) || viteConfigContent.includes(`from "${importPath}"`))) infoMigration(`Please manually merge ${displayRelative(fullTsdownConfigPath)} into ${displayRelative(fullViteConfigPath)}, see https://viteplus.dev/guide/migrate#tsdown`, report);
|
|
9021
|
+
return false;
|
|
9022
|
+
}
|
|
8939
9023
|
const result = mergeTsdownConfig(fullViteConfigPath, tsdownRelativePath);
|
|
8940
9024
|
if (result.updated) {
|
|
8941
9025
|
fs.writeFileSync(fullViteConfigPath, result.content);
|
|
@@ -8943,6 +9027,7 @@ function mergeTsdownConfigFile(projectPath, silent = false, report) {
|
|
|
8943
9027
|
if (!silent) log.success(`✔ Added import for ${displayRelative(fullTsdownConfigPath)} in ${displayRelative(fullViteConfigPath)}`);
|
|
8944
9028
|
}
|
|
8945
9029
|
infoMigration(`Please manually merge ${displayRelative(fullTsdownConfigPath)} into ${displayRelative(fullViteConfigPath)}, see https://viteplus.dev/guide/migrate#tsdown`, report);
|
|
9030
|
+
return createdViteConfig || result.updated;
|
|
8946
9031
|
}
|
|
8947
9032
|
/**
|
|
8948
9033
|
* Merge oxlint and oxfmt config into vite.config.ts
|
|
@@ -9083,11 +9168,12 @@ function wrapLazyPluginsInViteConfig(projectPath, silent = false, report) {
|
|
|
9083
9168
|
* This rewrites vite/vitest imports to @voidzero-dev/vite-plus
|
|
9084
9169
|
* @param projectPath - The root directory to search for files
|
|
9085
9170
|
*/
|
|
9086
|
-
function rewriteAllImports(projectPath, silent = false, report, preserveNuxtVitestImports = true) {
|
|
9087
|
-
const result = rewriteImportsInDirectory(projectPath, preserveNuxtVitestImports);
|
|
9171
|
+
function rewriteAllImports(projectPath, silent = false, report, preserveNuxtVitestImports = true, oxlintOwnerDirs = []) {
|
|
9172
|
+
const result = rewriteImportsInDirectory(projectPath, preserveNuxtVitestImports, oxlintOwnerDirs);
|
|
9088
9173
|
const modified = result.modifiedFiles.length;
|
|
9089
9174
|
const preserved = result.preservedVitestFiles.length;
|
|
9090
9175
|
const errors = result.errors.length;
|
|
9176
|
+
for (const warning of result.warnings) warnMigration(`${displayRelative(warning.path)}: ${warning.message}`, report);
|
|
9091
9177
|
if (report) {
|
|
9092
9178
|
report.rewrittenImportFileCount += modified;
|
|
9093
9179
|
report.preservedUpstreamVitestImportFileCount += preserved;
|
|
@@ -9402,20 +9488,64 @@ function parseNvmrcVersion(alias) {
|
|
|
9402
9488
|
* are touched, so shell `cat .nvmrc` and comments are left alone.
|
|
9403
9489
|
*/
|
|
9404
9490
|
const NODE_VERSION_FILE_NVMRC_RE = /(node-version-file:[ \t]*)(['"]?)(\.\/)?\.nvmrc\2(?=\s|$)/gm;
|
|
9491
|
+
function isCompositeActionFile(filePath) {
|
|
9492
|
+
try {
|
|
9493
|
+
const action = (0, import_dist.parse)(fs.readFileSync(filePath, "utf8"));
|
|
9494
|
+
return isPlainRecord(action) && isPlainRecord(action.runs) && action.runs.using === "composite";
|
|
9495
|
+
} catch {
|
|
9496
|
+
return false;
|
|
9497
|
+
}
|
|
9498
|
+
}
|
|
9405
9499
|
/**
|
|
9406
|
-
* Collect
|
|
9407
|
-
*
|
|
9408
|
-
*
|
|
9409
|
-
* (`.github/actions/**\/action.{yml,yaml}`, which may nest at any depth). Returns
|
|
9410
|
-
* absolute paths; a missing `.github` tree just yields an empty list. `nocase`
|
|
9411
|
-
* keeps the match case-insensitive on case-sensitive filesystems.
|
|
9500
|
+
* Collect top-level workflows and composite action definitions under `.github`.
|
|
9501
|
+
* Action metadata must declare `runs.using: composite`. Paths are absolute, and
|
|
9502
|
+
* filename matching is case-insensitive.
|
|
9412
9503
|
*/
|
|
9413
9504
|
function collectGithubActionFiles(projectPath) {
|
|
9414
|
-
|
|
9505
|
+
const globOptions = {
|
|
9415
9506
|
cwd: path.join(projectPath, ".github"),
|
|
9416
9507
|
absolute: true,
|
|
9417
|
-
nocase: true
|
|
9418
|
-
|
|
9508
|
+
nocase: true,
|
|
9509
|
+
nodir: true
|
|
9510
|
+
};
|
|
9511
|
+
const workflows = globSync("workflows/*.{yml,yaml}", globOptions);
|
|
9512
|
+
const compositeActions = globSync("**/action.{yml,yaml}", {
|
|
9513
|
+
...globOptions,
|
|
9514
|
+
dot: true
|
|
9515
|
+
}).filter(isCompositeActionFile);
|
|
9516
|
+
return [.../* @__PURE__ */ new Set([...workflows, ...compositeActions])];
|
|
9517
|
+
}
|
|
9518
|
+
/**
|
|
9519
|
+
* Match an exact `voidzero-dev/setup-vp@v1` action reference while preserving
|
|
9520
|
+
* indentation, list syntax, quote style, and trailing comments. The end guard
|
|
9521
|
+
* prevents prefix matches such as `@v1.2.3` or `@v10`.
|
|
9522
|
+
*/
|
|
9523
|
+
const SETUP_VP_V1_RE = /^([ \t]*(?:-[ \t]*)?uses[ \t]*:[ \t]*)(['"]?)voidzero-dev\/setup-vp@v1\2(?=[ \t]*(?:#.*)?\r?$)/gm;
|
|
9524
|
+
/**
|
|
9525
|
+
* Replace the frozen `voidzero-dev/setup-vp@v1` tag with the latest exact
|
|
9526
|
+
* release known to this Vite+ version. GitHub workflow files and composite
|
|
9527
|
+
* action definitions are both covered. Existing exact versions, commit SHAs,
|
|
9528
|
+
* and commented-out steps are left unchanged.
|
|
9529
|
+
*
|
|
9530
|
+
* Returns the project-relative paths of the updated files.
|
|
9531
|
+
*/
|
|
9532
|
+
function migrateSetupVpVersion(projectPath, report) {
|
|
9533
|
+
const updatedFiles = [];
|
|
9534
|
+
for (const filePath of collectGithubActionFiles(projectPath)) {
|
|
9535
|
+
const relativePath = path.relative(projectPath, filePath);
|
|
9536
|
+
try {
|
|
9537
|
+
const original = fs.readFileSync(filePath, "utf8");
|
|
9538
|
+
const rewritten = original.replace(SETUP_VP_V1_RE, `$1$2voidzero-dev/setup-vp@${SETUP_VP_VERSION}$2`);
|
|
9539
|
+
if (rewritten !== original) {
|
|
9540
|
+
fs.writeFileSync(filePath, rewritten);
|
|
9541
|
+
updatedFiles.push(relativePath);
|
|
9542
|
+
}
|
|
9543
|
+
} catch (error) {
|
|
9544
|
+
warnMigration(`Could not update the setup-vp version in ${relativePath}: ${error instanceof Error ? error.message : String(error)}`, report);
|
|
9545
|
+
}
|
|
9546
|
+
}
|
|
9547
|
+
if (report) report.setupVpVersionUpdatedFileCount += updatedFiles.length;
|
|
9548
|
+
return updatedFiles;
|
|
9419
9549
|
}
|
|
9420
9550
|
/**
|
|
9421
9551
|
* After `.nvmrc` is converted to `.node-version`, rewrite any GitHub Actions
|
|
@@ -9548,11 +9678,13 @@ function finalizeCoreMigrationForExistingVitePlus(workspaceInfo, silent = false,
|
|
|
9548
9678
|
const result = {
|
|
9549
9679
|
scripts: false,
|
|
9550
9680
|
tsconfigTypes: false,
|
|
9551
|
-
imports: false
|
|
9681
|
+
imports: false,
|
|
9682
|
+
tsdownConfig: false
|
|
9552
9683
|
};
|
|
9553
9684
|
if (pending.scripts) for (const projectPath of projectPaths) result.scripts = rewriteCorePackageScripts(projectPath) || result.scripts;
|
|
9554
9685
|
if (pending.tsconfigTypes) for (const projectPath of projectPaths) result.tsconfigTypes = rewriteTsconfigTypes(projectPath, silent, report) || result.tsconfigTypes;
|
|
9555
9686
|
result.imports = rewriteAllImports(workspaceInfo.rootDir, silent, report, true);
|
|
9687
|
+
for (const projectPath of projectPaths) result.tsdownConfig = mergeTsdownConfigFile(projectPath, silent, report) || result.tsdownConfig;
|
|
9556
9688
|
return result;
|
|
9557
9689
|
}
|
|
9558
9690
|
//#endregion
|
|
@@ -9563,6 +9695,7 @@ function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigratio
|
|
|
9563
9695
|
const packageManager = workspaceInfo.packageManager;
|
|
9564
9696
|
const catalogDependencyResolver = createCatalogDependencyResolver(projectPath, packageManager);
|
|
9565
9697
|
const vitestEcosystemPackages = collectVitestEcosystemInstallDependencyNames(projectPath);
|
|
9698
|
+
const oxlintOwnerDirs = collectOxlintOwnerDirs(projectPath, workspaceInfo.packages);
|
|
9566
9699
|
const providerSourceModes = collectProviderSourceModes(projectPath);
|
|
9567
9700
|
const browserMode = usesVitestBrowserMode(projectPath);
|
|
9568
9701
|
const retainedVitestModule = sourceTreeReferencesRetainedVitestModule(projectPath);
|
|
@@ -9659,7 +9792,8 @@ function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigratio
|
|
|
9659
9792
|
injectLintTypeCheckDefaults(projectPath, silent, report);
|
|
9660
9793
|
injectFmtDefaults(projectPath, silent, report);
|
|
9661
9794
|
mergeTsdownConfigFile(projectPath, silent, report);
|
|
9662
|
-
rewriteAllImports(projectPath, silent, report, true);
|
|
9795
|
+
rewriteAllImports(projectPath, silent, report, true, oxlintOwnerDirs);
|
|
9796
|
+
dropDeadOxlintPluginsDependency(projectPath, workspaceInfo.packages);
|
|
9663
9797
|
wrapLazyPluginsInViteConfig(projectPath, silent, report);
|
|
9664
9798
|
setPackageManager(projectPath, workspaceInfo.downloadPackageManager);
|
|
9665
9799
|
}
|
|
@@ -9669,6 +9803,7 @@ function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigratio
|
|
|
9669
9803
|
*/
|
|
9670
9804
|
function rewriteMonorepo(workspaceInfo, skipStagedMigration, silent = false, report) {
|
|
9671
9805
|
const catalogDependencyResolver = createCatalogDependencyResolver(workspaceInfo.rootDir, workspaceInfo.packageManager);
|
|
9806
|
+
const oxlintOwnerDirs = collectOxlintOwnerDirs(workspaceInfo.rootDir, workspaceInfo.packages);
|
|
9672
9807
|
const pnpmMajorVersion = pnpmMajor(workspaceInfo.downloadPackageManager.version);
|
|
9673
9808
|
const usePnpmWorkspaceSettings = pnpmSupportsWorkspaceSettings(workspaceInfo.downloadPackageManager.version);
|
|
9674
9809
|
const workspaceShouldAllowBrowserBuilds = workspaceUsesWebdriverio(workspaceInfo.rootDir, workspaceInfo.packages);
|
|
@@ -9695,7 +9830,8 @@ function rewriteMonorepo(workspaceInfo, skipStagedMigration, silent = false, rep
|
|
|
9695
9830
|
injectLintTypeCheckDefaults(workspaceInfo.rootDir, silent, report);
|
|
9696
9831
|
injectFmtDefaults(workspaceInfo.rootDir, silent, report);
|
|
9697
9832
|
mergeTsdownConfigFile(workspaceInfo.rootDir, silent, report);
|
|
9698
|
-
rewriteAllImports(workspaceInfo.rootDir, silent, report, true);
|
|
9833
|
+
rewriteAllImports(workspaceInfo.rootDir, silent, report, true, oxlintOwnerDirs);
|
|
9834
|
+
dropDeadOxlintPluginsDependency(workspaceInfo.rootDir, workspaceInfo.packages);
|
|
9699
9835
|
wrapLazyPluginsInViteConfig(workspaceInfo.rootDir, silent, report);
|
|
9700
9836
|
for (const pkg of workspaceInfo.packages) wrapLazyPluginsInViteConfig(path.join(workspaceInfo.rootDir, pkg.path), silent, report);
|
|
9701
9837
|
setPackageManager(workspaceInfo.rootDir, workspaceInfo.downloadPackageManager);
|
|
@@ -9783,8 +9919,7 @@ const ZED_SETTINGS = {
|
|
|
9783
9919
|
].map((language) => [language, {
|
|
9784
9920
|
format_on_save: "on",
|
|
9785
9921
|
prettier: { allowed: false },
|
|
9786
|
-
formatter: [{ language_server: { name: "oxfmt" } }]
|
|
9787
|
-
...language === "JavaScript" ? { code_action: "source.fixAll.oxc" } : {}
|
|
9922
|
+
formatter: [{ language_server: { name: "oxfmt" } }, ...language === "JavaScript" ? [{ code_action: "source.fixAll.oxc" }] : []]
|
|
9788
9923
|
}]))
|
|
9789
9924
|
};
|
|
9790
9925
|
const JETBRAINS_EXTERNAL_DEPENDENCIES = `<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -10091,4 +10226,4 @@ function resolveEditorIds(editors) {
|
|
|
10091
10226
|
return uniqueEditorIds.length === 0 ? void 0 : uniqueEditorIds;
|
|
10092
10227
|
}
|
|
10093
10228
|
//#endregion
|
|
10094
|
-
export {
|
|
10229
|
+
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 };
|
package/dist/hooks/bin.js
CHANGED
|
@@ -1,128 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
//#region src/hooks/args.ts
|
|
6
|
-
const KNOWN_HOOKS_ARG_KEYS = /* @__PURE__ */ new Set([
|
|
7
|
-
"_",
|
|
8
|
-
"help",
|
|
9
|
-
"h",
|
|
10
|
-
"hooks-dir"
|
|
11
|
-
]);
|
|
12
|
-
/**
|
|
13
|
-
* Reject leftover positionals and unknown flags before enable/disable mutate state.
|
|
14
|
-
*/
|
|
15
|
-
function unexpectedHooksArgsError(args) {
|
|
16
|
-
const extra = args._.map(String).filter((value) => value !== "");
|
|
17
|
-
if (extra.length > 0) return `Unexpected argument "${extra[0]}". Use --hooks-dir <path> to set a custom hooks directory.`;
|
|
18
|
-
for (const key of Object.keys(args)) if (!KNOWN_HOOKS_ARG_KEYS.has(key)) return `Unknown option "--${key}".`;
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
1
|
+
import { i as log } from "../terminal-MKGAuy-p.js";
|
|
2
|
+
import { l as status, n as disable, r as enable } from "../hooks-C-4gykWR.js";
|
|
3
|
+
import { t as unwrapCliParseOutcome } from "../cli-parse-DHE8NrBU.js";
|
|
4
|
+
import { parseHooksArgs } from "../../binding/index.js";
|
|
22
5
|
//#region src/hooks/bin.ts
|
|
23
|
-
const SUBCOMMANDS = [
|
|
24
|
-
"enable",
|
|
25
|
-
"disable",
|
|
26
|
-
"status"
|
|
27
|
-
];
|
|
28
|
-
function isSubcommand(value) {
|
|
29
|
-
return !!value && SUBCOMMANDS.includes(value);
|
|
30
|
-
}
|
|
31
|
-
function printHelp() {
|
|
32
|
-
const helpMessage = renderCliDoc({
|
|
33
|
-
usage: "vp hooks <COMMAND> [OPTIONS]",
|
|
34
|
-
summary: "Manage the Vite+ Git hook dispatcher for this repository.",
|
|
35
|
-
documentationUrl: "https://viteplus.dev/guide/commit-hooks",
|
|
36
|
-
sections: [
|
|
37
|
-
{
|
|
38
|
-
title: "Commands",
|
|
39
|
-
rows: [
|
|
40
|
-
{
|
|
41
|
-
label: "enable",
|
|
42
|
-
description: "Install or refresh the hook dispatcher (sets core.hooksPath)"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
label: "disable",
|
|
46
|
-
description: "Disable hooks: unset core.hooksPath, remove <dir>/_, persist preference"
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
label: "status",
|
|
50
|
-
description: "Show preference, core.hooksPath, and dispatcher state"
|
|
51
|
-
}
|
|
52
|
-
]
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
title: "Options",
|
|
56
|
-
rows: [{
|
|
57
|
-
label: "--hooks-dir <path>",
|
|
58
|
-
description: `Custom hooks directory (default: ${DEFAULT_HOOKS_DIR}, or last used)`
|
|
59
|
-
}, {
|
|
60
|
-
label: "-h, --help",
|
|
61
|
-
description: "Show this help message"
|
|
62
|
-
}]
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
title: "Environment",
|
|
66
|
-
rows: [{
|
|
67
|
-
label: "VP_GIT_HOOKS=0",
|
|
68
|
-
description: "Skip dispatcher install in enable (and skip hooks at commit time)"
|
|
69
|
-
}]
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
title: "Examples",
|
|
73
|
-
lines: [
|
|
74
|
-
" vp hooks enable",
|
|
75
|
-
" vp hooks enable --hooks-dir .custom-hooks",
|
|
76
|
-
" vp hooks disable",
|
|
77
|
-
" vp hooks status"
|
|
78
|
-
]
|
|
79
|
-
}
|
|
80
|
-
]
|
|
81
|
-
});
|
|
82
|
-
printHeader();
|
|
83
|
-
log(helpMessage);
|
|
84
|
-
}
|
|
85
6
|
function applyResult(result) {
|
|
86
7
|
if (result.message) log(result.message);
|
|
87
8
|
if (result.isError) process.exit(1);
|
|
88
9
|
}
|
|
89
10
|
async function main() {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
const wantsHelp = raw.includes("-h") || raw.includes("--help");
|
|
93
|
-
if (!first || first === "-h" || first === "--help") {
|
|
94
|
-
printHelp();
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (!isSubcommand(first)) {
|
|
98
|
-
log(`Unknown hooks command "${first}". Expected one of: ${SUBCOMMANDS.join(", ")}`);
|
|
99
|
-
process.exit(1);
|
|
100
|
-
}
|
|
101
|
-
const subcommand = first;
|
|
102
|
-
const args = lib_default(raw.slice(1), {
|
|
103
|
-
boolean: ["help"],
|
|
104
|
-
string: ["hooks-dir"],
|
|
105
|
-
alias: { h: "help" }
|
|
106
|
-
});
|
|
107
|
-
if (args.help || wantsHelp) {
|
|
108
|
-
printHelp();
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const unexpected = unexpectedHooksArgsError(args);
|
|
112
|
-
if (unexpected) {
|
|
113
|
-
log(unexpected);
|
|
114
|
-
process.exit(1);
|
|
115
|
-
}
|
|
116
|
-
const dirFlag = args["hooks-dir"];
|
|
117
|
-
switch (subcommand) {
|
|
11
|
+
const args = unwrapCliParseOutcome(parseHooksArgs(process.argv.slice(3)));
|
|
12
|
+
switch (args.command) {
|
|
118
13
|
case "enable":
|
|
119
|
-
applyResult(enable(
|
|
14
|
+
applyResult(enable(args.hooksDir));
|
|
120
15
|
return;
|
|
121
16
|
case "disable":
|
|
122
|
-
applyResult(disable(
|
|
17
|
+
applyResult(disable(args.hooksDir));
|
|
123
18
|
return;
|
|
124
19
|
case "status":
|
|
125
|
-
applyResult(status(
|
|
20
|
+
applyResult(status(args.hooksDir));
|
|
126
21
|
return;
|
|
127
22
|
}
|
|
128
23
|
}
|
|
@@ -570,4 +570,4 @@ function status(dir) {
|
|
|
570
570
|
};
|
|
571
571
|
}
|
|
572
572
|
//#endregion
|
|
573
|
-
export {
|
|
573
|
+
export { install as a, resolveHooksLocation as c, findUnsafeHookInstallPath as i, status as l, disable as n, isGitHooksEnvDisabled as o, enable as r, isHooksUserDisabled as s, SUPPORTED_GIT_HOOK_NAMES as t };
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_define_config = require("./define-config-
|
|
1
|
+
const require_define_config = require("./define-config-DpAPETDf.cjs");
|
|
2
2
|
//#region src/index.cts
|
|
3
|
-
const vite = require("
|
|
3
|
+
const vite = require("vite");
|
|
4
4
|
const { configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude } = require("vitest/config");
|
|
5
5
|
const { defineConfig, defineProject, lazyPlugins } = (require_define_config.init_define_config(), require_define_config.__toCommonJS(require_define_config.define_config_exports));
|
|
6
6
|
module.exports = {
|