vite-plus 0.3.2 → 1.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +35 -146
- package/README.md +3 -3
- package/binding/index.cjs +140 -55
- package/binding/index.d.cts +49 -0
- package/dist/{agent-C59HKB4Y.js → agent-Dinpyd-k.js} +6 -5
- package/dist/bin.js +48 -18
- package/dist/config/bin.js +2 -2
- package/dist/constants-CiKwrA0v.js +356 -0
- package/dist/create/bin.js +96 -71
- package/dist/{define-config-DPNEJxPz.d.ts → define-config-B9usMnEa.d.ts} +51 -10
- package/dist/{define-config-DpAPETDf.cjs → define-config-CBccpane.cjs} +173 -44
- package/dist/{define-config-DAaCa0U_.js → define-config-jhuYJ7Tb.js} +158 -42
- package/dist/define-config.cjs +1 -1
- package/dist/define-config.d.ts +1 -1
- package/dist/define-config.js +1 -1
- package/dist/documentation-DqcZSthV.js +11 -0
- package/dist/{editor-QOIGtmH4.js → editor-DMBczTdj.js} +216 -152
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{json-cULBl7Pi.js → json-JP24qHUF.js} +14 -6
- package/dist/lint-plugins.cjs +1 -1
- package/dist/migration/bin.js +3122 -15
- package/dist/{oxlint-plugin-config-BU42tr8y.js → oxlint-plugin-config-BgsDA6ua.js} +1 -1
- package/dist/oxlint-plugin.js +9 -7
- package/dist/pack-bin.js +1 -1
- package/dist/{package-BB-Jh_z3.js → package-B85H2Nw0.js} +6 -2
- package/dist/{vitest-ecosystem-BiRqcaRI.js → package-overrides-Dpn4scvN.js} +1 -7
- package/dist/{prompts-CujFOJXu.js → prompts-CQobX7uP.js} +2 -2
- package/dist/{resolve-vite-config-CHHjsjKJ.js → resolve-vite-config-BUFUmi8h.js} +2 -2
- package/dist/{resolve-vite-config-6Nox70uP.js → resolve-vite-config-I8fmpR7I.js} +1 -1
- package/dist/staged/bin.js +1205 -3317
- package/dist/sync-versions/bin.js +3 -2
- package/dist/sync-versions/bin.mjs +17 -2
- package/dist/test/browser/context.js +1 -1
- package/dist/test/browser/providers/playwright/context.js +1 -1
- package/dist/test/browser/providers/preview/context.js +1 -1
- package/dist/test/browser-playwright/context.js +1 -1
- package/dist/test/browser-preview/context.js +1 -1
- package/dist/test/context.d.ts +2 -942
- package/dist/test/context.js +1 -1
- package/dist/test/internal/traces.js +1 -0
- package/dist/test/locators.d.ts +2 -294
- package/dist/test/matchers.d.ts +2 -29
- package/dist/test/mocker.d.ts +2 -0
- package/dist/test/mocker.js +1 -0
- package/dist/test/{browser-webdriverio/context.js → plugins/browser-context.d.ts} +1 -0
- package/dist/test/plugins/browser-context.js +1 -1
- package/dist/test/plugins/browser-locators.d.ts +2 -0
- package/dist/test/plugins/browser-playwright.d.ts +2 -0
- package/dist/test/plugins/browser-preview.d.ts +2 -0
- package/dist/test/plugins/browser.d.ts +2 -0
- package/dist/test/plugins/mocker-automock.d.ts +2 -0
- package/dist/test/plugins/mocker-browser.d.ts +2 -0
- package/dist/test/plugins/mocker-node.d.ts +2 -0
- package/dist/test/plugins/mocker-redirect.d.ts +2 -0
- package/dist/test/plugins/mocker-register.d.ts +2 -0
- package/dist/test/plugins/mocker-transforms.d.ts +2 -0
- package/dist/test/plugins/mocker.d.ts +2 -0
- package/dist/test/plugins/pretty-format.d.ts +2 -0
- package/dist/test/plugins/snapshot-environment.d.ts +2 -0
- package/dist/test/plugins/snapshot-manager.d.ts +2 -0
- package/dist/test/plugins/snapshot.d.ts +2 -0
- package/dist/test/plugins/spy.d.ts +2 -0
- package/dist/test/plugins/utils-constants.d.ts +2 -0
- package/dist/test/plugins/utils-diff.d.ts +2 -0
- package/dist/test/plugins/utils-display.d.ts +2 -0
- package/dist/test/plugins/utils-error.d.ts +2 -0
- package/dist/test/plugins/utils-helpers.d.ts +2 -0
- package/dist/test/plugins/utils-offset.d.ts +2 -0
- package/dist/test/plugins/utils-resolver.d.ts +2 -0
- package/dist/test/plugins/utils-serialize.d.ts +2 -0
- package/dist/test/plugins/utils-source-map-node.d.ts +2 -0
- package/dist/test/plugins/utils-source-map.d.ts +2 -0
- package/dist/test/plugins/utils-timers.d.ts +2 -0
- package/dist/test/plugins/utils.d.ts +2 -0
- package/dist/toolchain.js +10 -10
- package/dist/toolchain.json +10 -10
- package/dist/{tsconfig-DCtWfQPA.js → tsconfig-Buo0RSzz.js} +8 -4
- package/dist/{tsconfig-MXktI3SX.js → tsconfig-C1VeTG9k.js} +1 -1
- package/dist/version.js +5 -3
- package/dist/versions.js +5 -5
- package/dist/vitest-ecosystem-BU0AqZq-.js +23 -0
- package/dist/vitest-v5-entry-points-DthU1e_O.js +25 -0
- package/docs/config/fmt.md +2 -2
- package/docs/config/lint.md +2 -2
- package/docs/config/run.md +1 -1
- package/docs/config/staged.md +1 -2
- package/docs/guide/check.md +2 -0
- package/docs/guide/ci.md +28 -31
- package/docs/guide/commit-hooks.md +18 -34
- package/docs/guide/create.md +1 -2
- package/docs/guide/docker.md +20 -68
- package/docs/guide/env.md +47 -32
- package/docs/guide/fmt.md +4 -2
- package/docs/guide/global-cli.md +426 -0
- package/docs/guide/ide-integration.md +1 -2
- package/docs/guide/implode.md +14 -1
- package/docs/guide/index.md +38 -35
- package/docs/guide/install.md +18 -20
- package/docs/guide/lint.md +6 -10
- package/docs/guide/local-cli.md +123 -0
- package/docs/guide/migrate-rules.md +104 -297
- package/docs/guide/migrate.md +82 -59
- package/docs/guide/monorepo.md +5 -1
- package/docs/guide/run.md +1 -1
- package/docs/guide/test.md +2 -0
- package/docs/guide/troubleshooting.md +6 -11
- package/docs/guide/upgrade-project.md +61 -0
- package/docs/guide/upgrade.md +17 -62
- package/docs/guide/vitest-v5.md +221 -0
- package/package.json +67 -90
- package/bin/oxfmt +0 -33
- package/bin/oxlint +0 -38
- package/dist/cli-truncate-Bg3RDXpi.js +0 -865
- package/dist/constants-IhOditRA.js +0 -80
- package/dist/is-fullwidth-code-point-BUNlIICg.js +0 -8
- package/dist/log-update-CoW8Z4Dl.js +0 -491
- package/dist/strip-ansi-C3wrWz9t.js +0 -853
- package/dist/test/browser/providers/webdriverio/context.d.ts +0 -1
- package/dist/test/browser/providers/webdriverio/context.js +0 -1
- package/dist/test/browser/providers/webdriverio.d.ts +0 -77
- package/dist/test/browser/providers/webdriverio.js +0 -1
- package/dist/test/browser-webdriverio/context.d.ts +0 -1
- package/dist/test/browser-webdriverio.d.ts +0 -77
- package/dist/test/browser-webdriverio.js +0 -1
- package/dist/test/coverage.d.ts +0 -2
- package/dist/test/coverage.js +0 -1
- package/dist/test/environments.d.ts +0 -2
- package/dist/test/environments.js +0 -1
- package/dist/test/plugins/browser-webdriverio.js +0 -1
- package/dist/test/plugins/expect.js +0 -1
- package/dist/test/plugins/runner-types.js +0 -1
- package/dist/test/plugins/runner-utils.js +0 -1
- package/dist/test/plugins/runner.js +0 -1
- package/dist/test/reporters.d.ts +0 -2
- package/dist/test/reporters.js +0 -1
- package/dist/test/runners.d.ts +0 -2
- package/dist/test/runners.js +0 -1
- package/dist/test/snapshot.d.ts +0 -2
- package/dist/test/snapshot.js +0 -1
- package/dist/test/suite.d.ts +0 -2
- package/dist/test/suite.js +0 -1
- package/dist/tsgolint-path-CbDReEOx.js +0 -34
- package/dist/tsgolint-path.d.ts +0 -7
- package/dist/tsgolint-path.js +0 -2
- package/dist/wrap-ansi-DNjkuBEp.js +0 -157
- package/dist/wrap-ansi-DUi52C6W.js +0 -2
- package/docs/guide/installer-env-vars.md +0 -286
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { r as __toESM } from "./rolldown-runtime-CMFfr-1z.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as
|
|
6
|
-
import {
|
|
2
|
+
import { t as documentationUrl$1 } from "./documentation-DqcZSthV.js";
|
|
3
|
+
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-CiKwrA0v.js";
|
|
4
|
+
import { i as ensureVitePlusImportRuleDefaults, r as createDefaultVitePlusLintConfig } from "./oxlint-plugin-config-BgsDA6ua.js";
|
|
5
|
+
import { a as writeJsonFile, c as modify, i as readJsonFile, l as parse, n as editJsonFile, o as applyEdits, r as isJsonFile, t as detectFormattingOptions } from "./json-JP24qHUF.js";
|
|
6
|
+
import { n as detectPackageMetadata, o as fetchNpmResource, r as getScopeFromPackageName, s as getNpmRegistry } from "./package-B85H2Nw0.js";
|
|
7
|
+
import { n as isAlignableVitestEcosystemPackage } from "./vitest-ecosystem-BU0AqZq-.js";
|
|
8
|
+
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-CQobX7uP.js";
|
|
7
9
|
import { t as require_semver } from "./semver-CaDAb8vV.js";
|
|
8
|
-
import { l as displayRelative, u as rulesDir } from "./agent-
|
|
10
|
+
import { l as displayRelative, u as rulesDir } from "./agent-Dinpyd-k.js";
|
|
9
11
|
import { n as addMigrationWarning, t as addManualStep } from "./report-CK5TnTsr.js";
|
|
10
12
|
import { n as runCommandSilently, r as require_cross_spawn } from "./command-CguLh2KL.js";
|
|
11
13
|
import { t as require_dist } from "./dist-BDYZP12R.js";
|
|
12
|
-
import { a as hasBaseUrlInTsconfig, c as hasVitestTypesInTsconfig, l as removeDeprecatedTsconfigFalseOption, n as findTsconfigFiles, s as hasTypesToRewriteInTsconfig, u as rewriteTypesInTsconfig } from "./tsconfig-
|
|
13
|
-
import {
|
|
14
|
+
import { a as hasBaseUrlInTsconfig, c as hasVitestTypesInTsconfig, l as removeDeprecatedTsconfigFalseOption, n as findTsconfigFiles, s as hasTypesToRewriteInTsconfig, u as rewriteTypesInTsconfig } from "./tsconfig-Buo0RSzz.js";
|
|
15
|
+
import { t as extractOverrideTargetName } from "./package-overrides-Dpn4scvN.js";
|
|
14
16
|
import { i as findUnsafeHookInstallPath, t as SUPPORTED_GIT_HOOK_NAMES } from "./hooks-C-4gykWR.js";
|
|
15
17
|
import path, { posix, win32 } from "node:path";
|
|
16
18
|
import { fileURLToPath } from "node:url";
|
|
@@ -56,28 +58,18 @@ const REMOVE_PACKAGES = [
|
|
|
56
58
|
];
|
|
57
59
|
const WEBDRIVERIO_PROVIDER = "@vitest/browser-webdriverio";
|
|
58
60
|
const PLAYWRIGHT_PROVIDER = "@vitest/browser-playwright";
|
|
59
|
-
const OPT_IN_BROWSER_PROVIDERS = [
|
|
61
|
+
const OPT_IN_BROWSER_PROVIDERS = [PLAYWRIGHT_PROVIDER];
|
|
60
62
|
const PROVIDER_OVERRIDE_DROP_NAMES = [...REMOVE_PACKAGES, ...OPT_IN_BROWSER_PROVIDERS];
|
|
61
|
-
const BROWSER_PROVIDER_PEER_DEPS = {
|
|
62
|
-
"@vitest/browser-playwright": "playwright",
|
|
63
|
-
"@vitest/browser-webdriverio": "webdriverio"
|
|
64
|
-
};
|
|
63
|
+
const BROWSER_PROVIDER_PEER_DEPS = { "@vitest/browser-playwright": "playwright" };
|
|
65
64
|
const RUNTIME_PEER_INCLUDED_BY = { playwright: ["@playwright/test"] };
|
|
66
|
-
const PROVIDER_PEER_VERSION_SIBLINGS = { webdriverio: ["@wdio/cli", "@wdio/globals"] };
|
|
67
65
|
function findDeclaredSpec(pkg, name) {
|
|
68
66
|
return pkg.dependencies?.[name] ?? pkg.devDependencies?.[name] ?? pkg.peerDependencies?.[name] ?? pkg.optionalDependencies?.[name];
|
|
69
67
|
}
|
|
70
68
|
function hasProviderPeerDependency(pkg, runtimePeer) {
|
|
71
69
|
return findDeclaredSpec(pkg, runtimePeer) !== void 0 || (RUNTIME_PEER_INCLUDED_BY[runtimePeer] ?? []).some((packageName) => findDeclaredSpec(pkg, packageName) !== void 0);
|
|
72
70
|
}
|
|
73
|
-
function resolveProviderPeerSpec(
|
|
74
|
-
|
|
75
|
-
for (const sibling of PROVIDER_PEER_VERSION_SIBLINGS[peer] ?? []) {
|
|
76
|
-
const spec = findDeclaredSpec(pkg, sibling);
|
|
77
|
-
const resolved = spec?.startsWith("catalog:") ? catalogDependencyResolver?.(spec, sibling) : spec;
|
|
78
|
-
if (resolved && !resolved.includes(":")) return resolved;
|
|
79
|
-
}
|
|
80
|
-
return "*";
|
|
71
|
+
function resolveProviderPeerSpec(peer, supportCatalog, catalogDependencyResolver) {
|
|
72
|
+
return supportCatalog && catalogDependencyResolver?.("catalog:", peer) !== void 0 ? "catalog:" : "*";
|
|
81
73
|
}
|
|
82
74
|
const VITEST_BROWSER_DEP_NAMES = [
|
|
83
75
|
"@vitest/browser",
|
|
@@ -363,6 +355,29 @@ function extractSkippedRules(output) {
|
|
|
363
355
|
return block.join("\n");
|
|
364
356
|
}
|
|
365
357
|
/**
|
|
358
|
+
* Resolve the `@oxlint/migrate` version to install. `@oxlint/migrate`
|
|
359
|
+
* trails `oxlint` releases (published minutes to days later), so the exact
|
|
360
|
+
* bundled-oxlint pin can name a version the registry does not have yet.
|
|
361
|
+
* Pick the greatest published version that is not newer than the bundled
|
|
362
|
+
* Oxlint. Fall back to the exact pin when the registry cannot be reached
|
|
363
|
+
* and let the dlx step surface the failure.
|
|
364
|
+
*/
|
|
365
|
+
async function resolveOxlintMigrateVersion(oxlintVersion) {
|
|
366
|
+
try {
|
|
367
|
+
const response = await fetchNpmResource(`${getNpmRegistry("@oxlint")}/@oxlint/migrate`, {
|
|
368
|
+
headers: { accept: "application/vnd.npm.install-v1+json" },
|
|
369
|
+
timeoutMs: 5e3
|
|
370
|
+
});
|
|
371
|
+
if (!response.ok) return oxlintVersion;
|
|
372
|
+
const packument = await response.json();
|
|
373
|
+
if (packument.versions && Object.hasOwn(packument.versions, oxlintVersion)) return oxlintVersion;
|
|
374
|
+
const candidates = Object.keys(packument.versions ?? {}).filter((version) => import_semver.default.valid(version) && import_semver.default.lte(version, oxlintVersion));
|
|
375
|
+
return candidates.length > 0 ? candidates.toSorted(import_semver.default.rcompare)[0] : oxlintVersion;
|
|
376
|
+
} catch {
|
|
377
|
+
return oxlintVersion;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
366
381
|
* Run a `vp dlx @oxlint/migrate` step with graceful error handling.
|
|
367
382
|
* Returns true on success, false on failure (spawn error or non-zero exit).
|
|
368
383
|
*/
|
|
@@ -400,7 +415,7 @@ async function migrateEslintToOxlint(projectPath, interactive, eslintConfigFile,
|
|
|
400
415
|
const spinner = options?.silent ? getSilentSpinner() : getSpinner(interactive);
|
|
401
416
|
if (eslintConfigFile) {
|
|
402
417
|
const { versions } = await import("./versions.js");
|
|
403
|
-
const migratePackage = `@oxlint/migrate@${versions.oxlint}`;
|
|
418
|
+
const migratePackage = `@oxlint/migrate@${await resolveOxlintMigrateVersion(versions.oxlint)}`;
|
|
404
419
|
const migrateArgs = [
|
|
405
420
|
"--merge",
|
|
406
421
|
...!hasBaseUrlInTsconfig(projectPath) ? ["--type-aware"] : [],
|
|
@@ -689,6 +704,14 @@ function jsPluginsToNamespaces(entries) {
|
|
|
689
704
|
ns.delete("");
|
|
690
705
|
return ns;
|
|
691
706
|
}
|
|
707
|
+
function stripUnsupportedReactRefreshOption(rules) {
|
|
708
|
+
const rule = rules?.["react/only-export-components"];
|
|
709
|
+
if (!Array.isArray(rule)) return false;
|
|
710
|
+
const options = rule[1];
|
|
711
|
+
if (!options || typeof options !== "object" || Array.isArray(options) || !("allowCompoundComponents" in options)) return false;
|
|
712
|
+
delete options.allowCompoundComponents;
|
|
713
|
+
return true;
|
|
714
|
+
}
|
|
692
715
|
/**
|
|
693
716
|
* Sanitize the `.oxlintrc.json` produced by `@oxlint/migrate` (in-place)
|
|
694
717
|
* before it gets merged into `vite.config.ts`. Drop references that
|
|
@@ -710,6 +733,7 @@ function jsPluginsToNamespaces(entries) {
|
|
|
710
733
|
function sanitizeMigratedOxlintConfig(config, availablePackages, report) {
|
|
711
734
|
const allDroppedJsPlugins = /* @__PURE__ */ new Set();
|
|
712
735
|
const allDroppedPlugins = /* @__PURE__ */ new Set();
|
|
736
|
+
let droppedReactRefreshOption = stripUnsupportedReactRefreshOption(config.rules);
|
|
713
737
|
const baseSplit = partitionJsPlugins(config.jsPlugins ?? [], availablePackages);
|
|
714
738
|
for (const n of baseSplit.dropped) allDroppedJsPlugins.add(n);
|
|
715
739
|
if (config.jsPlugins && baseSplit.dropped.length > 0) config.jsPlugins = baseSplit.kept;
|
|
@@ -726,6 +750,7 @@ function sanitizeMigratedOxlintConfig(config, availablePackages, report) {
|
|
|
726
750
|
if (Object.keys(filtered).length !== Object.keys(config.rules).length) config.rules = filtered;
|
|
727
751
|
}
|
|
728
752
|
if (Array.isArray(config.overrides)) for (const override of config.overrides) {
|
|
753
|
+
if (stripUnsupportedReactRefreshOption(override.rules)) droppedReactRefreshOption = true;
|
|
729
754
|
let overrideSurvivors = [];
|
|
730
755
|
if (override.jsPlugins) {
|
|
731
756
|
const split = partitionJsPlugins(override.jsPlugins, availablePackages);
|
|
@@ -746,6 +771,7 @@ function sanitizeMigratedOxlintConfig(config, availablePackages, report) {
|
|
|
746
771
|
if (Object.keys(filtered).length !== Object.keys(override.rules).length) override.rules = filtered;
|
|
747
772
|
}
|
|
748
773
|
}
|
|
774
|
+
if (droppedReactRefreshOption) warnMigration("The bundled Oxlint does not support react/only-export-components.allowCompoundComponents. Removed this option from the migrated config; compound component exports may now report lint errors.", report);
|
|
749
775
|
if (allDroppedJsPlugins.size > 0) warnMigration(`Stripped JS plugin reference(s) from the generated lint config: ${[...allDroppedJsPlugins].join(", ")}. No matching package is present in this workspace, so loading them at lint time would fail. If you want their Oxlint coverage back, install each package (e.g. \`vp install <name>\`) and add its name back to \`lint.jsPlugins\` in vite.config.ts.`, report);
|
|
750
776
|
if (allDroppedPlugins.size > 0) warnMigration(`Stripped unknown plugin reference(s) from the generated lint config: ${[...allDroppedPlugins].join(", ")}. These aren't native Oxlint plugins and no surviving JS plugin contributes them.`, report);
|
|
751
777
|
}
|
|
@@ -1561,9 +1587,12 @@ function dropRemovePackageOverrideKeys(overrides, ancestorChain = []) {
|
|
|
1561
1587
|
}
|
|
1562
1588
|
return removed;
|
|
1563
1589
|
}
|
|
1564
|
-
function managedOverridePackages(usesVitest) {
|
|
1565
|
-
|
|
1566
|
-
return
|
|
1590
|
+
function managedOverridePackages(usesVitest, usesWebdriverioProvider = false) {
|
|
1591
|
+
const managed = usesVitest ? VITE_PLUS_OVERRIDE_PACKAGES : Object.fromEntries(Object.entries(VITE_PLUS_OVERRIDE_PACKAGES).filter(([key]) => key !== "vitest"));
|
|
1592
|
+
return usesWebdriverioProvider && VITEST_IS_MANAGED_OVERRIDE ? {
|
|
1593
|
+
...managed,
|
|
1594
|
+
"@vitest/browser": VITEST_VERSION
|
|
1595
|
+
} : managed;
|
|
1567
1596
|
}
|
|
1568
1597
|
function projectListsVitestEcosystemDep(pkg) {
|
|
1569
1598
|
return [
|
|
@@ -1713,7 +1742,7 @@ function vitestEcosystemCatalogReferencesPending(pkg, catalogDependencyResolver)
|
|
|
1713
1742
|
pkg.optionalDependencies
|
|
1714
1743
|
]) {
|
|
1715
1744
|
if (!dependencies) continue;
|
|
1716
|
-
for (const [name, spec] of Object.entries(dependencies)) if (isAlignableVitestEcosystemPackage(name) && spec.startsWith("catalog:") && catalogDependencyResolver(spec, name) !== "
|
|
1745
|
+
for (const [name, spec] of Object.entries(dependencies)) if (isAlignableVitestEcosystemPackage(name) && spec.startsWith("catalog:") && catalogDependencyResolver(spec, name) !== "5.0.1") return true;
|
|
1717
1746
|
}
|
|
1718
1747
|
return false;
|
|
1719
1748
|
}
|
|
@@ -1732,6 +1761,37 @@ function collectVitestEcosystemInstallDependencyNames(rootDir, packages) {
|
|
|
1732
1761
|
return names;
|
|
1733
1762
|
}
|
|
1734
1763
|
//#endregion
|
|
1764
|
+
//#region src/utils/git.ts
|
|
1765
|
+
var import_cross_spawn = /* @__PURE__ */ __toESM(require_cross_spawn(), 1);
|
|
1766
|
+
/**
|
|
1767
|
+
* Walk up from `startPath` looking for `.git` (directory or file — submodules
|
|
1768
|
+
* use a `.git` file). Returns the directory that contains `.git`, or `null`.
|
|
1769
|
+
*/
|
|
1770
|
+
function findGitRoot(startPath) {
|
|
1771
|
+
let dir = startPath;
|
|
1772
|
+
while (true) {
|
|
1773
|
+
if (fs.existsSync(path.join(dir, ".git"))) return dir;
|
|
1774
|
+
const parent = path.dirname(dir);
|
|
1775
|
+
if (parent === dir) return null;
|
|
1776
|
+
dir = parent;
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
async function initGitRepository(cwd) {
|
|
1780
|
+
const result = await runCommandSilently({
|
|
1781
|
+
command: "git",
|
|
1782
|
+
args: ["init"],
|
|
1783
|
+
cwd,
|
|
1784
|
+
envs: process.env
|
|
1785
|
+
});
|
|
1786
|
+
if (result.exitCode !== 0) {
|
|
1787
|
+
log.warn("Failed to initialize git repository");
|
|
1788
|
+
const stderr = result.stderr.toString().trim();
|
|
1789
|
+
if (stderr) log.info(stderr);
|
|
1790
|
+
return false;
|
|
1791
|
+
}
|
|
1792
|
+
return true;
|
|
1793
|
+
}
|
|
1794
|
+
//#endregion
|
|
1735
1795
|
//#region ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
|
|
1736
1796
|
const balanced = (a, b, str) => {
|
|
1737
1797
|
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
@@ -3837,7 +3897,7 @@ var L = class c {
|
|
|
3837
3897
|
}
|
|
3838
3898
|
};
|
|
3839
3899
|
//#endregion
|
|
3840
|
-
//#region ../../node_modules/.pnpm/minipass@7.1.
|
|
3900
|
+
//#region ../../node_modules/.pnpm/minipass@7.1.3/node_modules/minipass/dist/esm/index.js
|
|
3841
3901
|
const proc = typeof process === "object" && process ? process : {
|
|
3842
3902
|
stdout: null,
|
|
3843
3903
|
stderr: null
|
|
@@ -3932,7 +3992,7 @@ var PipeProxyErrors = class extends Pipe {
|
|
|
3932
3992
|
}
|
|
3933
3993
|
constructor(src, dest, opts) {
|
|
3934
3994
|
super(src, dest, opts);
|
|
3935
|
-
this.proxyErrors = (er) => dest.emit("error", er);
|
|
3995
|
+
this.proxyErrors = (er) => this.dest.emit("error", er);
|
|
3936
3996
|
src.on("error", this.proxyErrors);
|
|
3937
3997
|
}
|
|
3938
3998
|
};
|
|
@@ -4571,7 +4631,8 @@ while (this[FLUSHCHUNK](this[BUFFERSHIFT]()) && this[BUFFER].length);
|
|
|
4571
4631
|
return: stop,
|
|
4572
4632
|
[Symbol.asyncIterator]() {
|
|
4573
4633
|
return this;
|
|
4574
|
-
}
|
|
4634
|
+
},
|
|
4635
|
+
[Symbol.asyncDispose]: async () => {}
|
|
4575
4636
|
};
|
|
4576
4637
|
}
|
|
4577
4638
|
/**
|
|
@@ -4611,7 +4672,8 @@ while (this[FLUSHCHUNK](this[BUFFERSHIFT]()) && this[BUFFER].length);
|
|
|
4611
4672
|
return: stop,
|
|
4612
4673
|
[Symbol.iterator]() {
|
|
4613
4674
|
return this;
|
|
4614
|
-
}
|
|
4675
|
+
},
|
|
4676
|
+
[Symbol.dispose]: () => {}
|
|
4615
4677
|
};
|
|
4616
4678
|
}
|
|
4617
4679
|
/**
|
|
@@ -4654,7 +4716,7 @@ while (this[FLUSHCHUNK](this[BUFFERSHIFT]()) && this[BUFFER].length);
|
|
|
4654
4716
|
}
|
|
4655
4717
|
};
|
|
4656
4718
|
//#endregion
|
|
4657
|
-
//#region ../../node_modules/.pnpm/path-scurry@2.0.
|
|
4719
|
+
//#region ../../node_modules/.pnpm/path-scurry@2.0.2/node_modules/path-scurry/dist/esm/index.js
|
|
4658
4720
|
const realpathSync$2 = realpathSync$1.native;
|
|
4659
4721
|
const defaultFS = {
|
|
4660
4722
|
lstatSync: lstatSync$1,
|
|
@@ -7391,10 +7453,10 @@ function migratePnpmSettingsToWorkspaceYaml(projectPath, settings) {
|
|
|
7391
7453
|
* Rewrite pnpm-workspace.yaml to add vite-plus dependencies
|
|
7392
7454
|
* @param projectPath - The path to the project
|
|
7393
7455
|
*/
|
|
7394
|
-
function rewritePnpmWorkspaceYaml(projectPath, pnpmMajorVersion, shouldAllowBrowserBuilds, usesVitest, vitestEcosystemPackages, writeWorkspaceSettings = true, catalogAdditions = /* @__PURE__ */ new Set()) {
|
|
7456
|
+
function rewritePnpmWorkspaceYaml(projectPath, pnpmMajorVersion, shouldAllowBrowserBuilds, usesVitest, vitestEcosystemPackages, writeWorkspaceSettings = true, catalogAdditions = /* @__PURE__ */ new Set(), usesWebdriverioProvider = false) {
|
|
7395
7457
|
const pnpmWorkspaceYamlPath = path.join(projectPath, "pnpm-workspace.yaml");
|
|
7396
7458
|
if (!fs.existsSync(pnpmWorkspaceYamlPath)) fs.writeFileSync(pnpmWorkspaceYamlPath, "");
|
|
7397
|
-
const managed = managedOverridePackages(usesVitest);
|
|
7459
|
+
const managed = managedOverridePackages(usesVitest, usesWebdriverioProvider);
|
|
7398
7460
|
editYamlFile(pnpmWorkspaceYamlPath, (doc) => {
|
|
7399
7461
|
const preferredCatalogSpec = rewriteCatalog(doc, usesVitest, vitestEcosystemPackages, catalogAdditions);
|
|
7400
7462
|
if (!writeWorkspaceSettings) return;
|
|
@@ -7409,7 +7471,9 @@ function rewritePnpmWorkspaceYaml(projectPath, pnpmMajorVersion, shouldAllowBrow
|
|
|
7409
7471
|
if (!usesVitest) removeYamlMapVitestEntry(doc.getIn(["overrides"]), "pnpm-ranged");
|
|
7410
7472
|
for (const key of Object.keys(managed)) {
|
|
7411
7473
|
const overrideKey = pnpmOverrideKey(key);
|
|
7412
|
-
const
|
|
7474
|
+
const currentVersion = getYamlMapScalarStringValue(overrides, overrideKey) ?? getYamlMapScalarStringValue(overrides, key);
|
|
7475
|
+
// @vitest/browser is an override-only entry: migration removes its direct
|
|
7476
|
+
const version = key === "@vitest/browser" ? managed[key] : getCatalogDependencySpec(currentVersion, managed[key], true, { preferredCatalogSpec });
|
|
7413
7477
|
if (overrides instanceof import_dist.YAMLMap) overrides.delete(key);
|
|
7414
7478
|
doc.setIn(["overrides", scalarString(overrideKey)], scalarString(version));
|
|
7415
7479
|
}
|
|
@@ -7428,14 +7492,14 @@ function rewritePnpmWorkspaceYaml(projectPath, pnpmMajorVersion, shouldAllowBrow
|
|
|
7428
7492
|
}
|
|
7429
7493
|
if (!usesVitest && VITEST_IS_MANAGED_OVERRIDE) allowAny.items = allowAny.items.filter((n) => n.value !== "vitest");
|
|
7430
7494
|
const existing = new Set(allowAny.items.map((n) => n.value));
|
|
7431
|
-
for (const key of Object.keys(
|
|
7495
|
+
for (const key of Object.keys(managedOverridePackages(usesVitest))) if (!existing.has(key)) allowAny.add(scalarString(key));
|
|
7432
7496
|
doc.setIn(["peerDependencyRules", "allowAny"], allowAny);
|
|
7433
7497
|
const allowedVersionsNode = doc.getIn(["peerDependencyRules", "allowedVersions"]);
|
|
7434
7498
|
let allowedVersions;
|
|
7435
7499
|
if (allowedVersionsNode instanceof import_dist.YAMLMap) allowedVersions = allowedVersionsNode;
|
|
7436
7500
|
else allowedVersions = new import_dist.YAMLMap();
|
|
7437
7501
|
if (!usesVitest) removeYamlMapVitestEntry(allowedVersions);
|
|
7438
|
-
for (const key of Object.keys(
|
|
7502
|
+
for (const key of Object.keys(managedOverridePackages(usesVitest))) allowedVersions.set(scalarString(key), scalarString("*"));
|
|
7439
7503
|
doc.setIn(["peerDependencyRules", "allowedVersions"], allowedVersions);
|
|
7440
7504
|
if (doc.has("minimumReleaseAge")) {
|
|
7441
7505
|
let minimumReleaseAgeExclude = doc.getIn(["minimumReleaseAgeExclude"]);
|
|
@@ -7509,38 +7573,10 @@ function getCatalogDependencySpec(currentValue, version, supportCatalog, options
|
|
|
7509
7573
|
return currentValue?.startsWith("catalog:") ? currentValue : options?.preferredCatalogSpec ?? "catalog:";
|
|
7510
7574
|
}
|
|
7511
7575
|
/**
|
|
7512
|
-
* #1932: under pnpm, an importer that depends on `vite-plus` (which bundles
|
|
7513
|
-
* `vitest`) needs a DIRECT `vite` devDep pointing at @voidzero-dev/vite-plus-core
|
|
7514
|
-
* so vitest's required `vite` peer binds to it. Without a direct edge, pnpm's
|
|
7515
|
-
* `autoInstallPeers` fabricates a separate upstream `vite` to satisfy the
|
|
7516
|
-
* peer, splitting vite-plus / vite / vitest into duplicate instances (the extra
|
|
7517
|
-
* vite also lacks vite's `@voidzero-dev/vite-task-client` integration, breaking
|
|
7518
|
-
* the `vp test` cache). Under a catalog the edge is a `catalog:` reference and
|
|
7519
|
-
* the catalog entry carries the alias; the `vite@*` workspace override covers
|
|
7520
|
-
* transitive and peer declarations instead of this one (see `pnpmOverrideKey`).
|
|
7521
|
-
* npm/yarn/bun redirect transitive/peer vite via root overrides/resolutions (and
|
|
7522
|
-
* drop the aliased vite), so this is pnpm-only, mirroring the bun root-package
|
|
7523
|
-
* branch in `rewriteRootWorkspacePackageJson`.
|
|
7524
|
-
*
|
|
7525
|
-
* A package that already declares `vite` in ANY dependency field, including
|
|
7526
|
-
* `peerDependencies` (e.g. a vite plugin pinning `vite ^6`), is left untouched
|
|
7527
|
-
* so its existing version contract is preserved. Call this AFTER `vite-plus`
|
|
7528
|
-
* has been ensured in the package, so the dependency check sees it.
|
|
7529
|
-
*/
|
|
7530
|
-
function ensureDirectViteForPnpm(pkg, packageManager, supportCatalog, catalogDependencyResolver) {
|
|
7531
|
-
const viteOverride = VITE_PLUS_OVERRIDE_PACKAGES.vite;
|
|
7532
|
-
if (packageManager !== PackageManager.pnpm || !viteOverride) return false;
|
|
7533
|
-
const dependsOnVitePlus = pkg.dependencies?.["vite-plus"] !== void 0 || pkg.devDependencies?.["vite-plus"] !== void 0;
|
|
7534
|
-
const viteAlreadyDirect = pkg.dependencies?.vite !== void 0 || pkg.devDependencies?.vite !== void 0 || pkg.optionalDependencies?.vite !== void 0 || pkg.peerDependencies?.vite !== void 0;
|
|
7535
|
-
if (!dependsOnVitePlus || viteAlreadyDirect) return false;
|
|
7536
|
-
setDirectViteEdge(pkg, supportCatalog, catalogDependencyResolver);
|
|
7537
|
-
return true;
|
|
7538
|
-
}
|
|
7539
|
-
/**
|
|
7540
7576
|
* Insert (or overwrite) a DIRECT `vite` devDependency edge in SORTED position.
|
|
7541
7577
|
*
|
|
7542
7578
|
* Several migration paths need a direct `vite` devDep for different reasons
|
|
7543
|
-
* (
|
|
7579
|
+
* (bun peer pre-resolution oven-sh/bun#8406; npm
|
|
7544
7580
|
* `@vitest/mocker` hoisting for opt-in providers), but they all want the SAME
|
|
7545
7581
|
* spec and the SAME placement, so both are centralized here. Each caller keeps
|
|
7546
7582
|
* its OWN gate for WHEN a direct edge is needed; this owns only the spec +
|
|
@@ -7748,10 +7784,10 @@ function rewriteCatalogsObject(catalogs, usesVitest, vitestEcosystemPackages) {
|
|
|
7748
7784
|
* unlike pnpm which uses pnpm-workspace.yaml.
|
|
7749
7785
|
* @see https://bun.sh/docs/pm/catalogs
|
|
7750
7786
|
*/
|
|
7751
|
-
function rewriteBunCatalog(projectPath, usesVitest, vitestEcosystemPackages) {
|
|
7787
|
+
function rewriteBunCatalog(projectPath, usesVitest, vitestEcosystemPackages, usesWebdriverioProvider = false) {
|
|
7752
7788
|
const packageJsonPath = path.join(projectPath, "package.json");
|
|
7753
7789
|
if (!fs.existsSync(packageJsonPath)) return;
|
|
7754
|
-
const managed = managedOverridePackages(usesVitest);
|
|
7790
|
+
const managed = managedOverridePackages(usesVitest, usesWebdriverioProvider);
|
|
7755
7791
|
editJsonFile(packageJsonPath, (pkg) => {
|
|
7756
7792
|
const workspacesObj = pkg.workspaces && !Array.isArray(pkg.workspaces) ? pkg.workspaces : void 0;
|
|
7757
7793
|
const useWorkspacesCatalog = workspacesObj?.catalog != null || pkg.catalog == null && workspacesObj?.catalogs != null;
|
|
@@ -7785,7 +7821,7 @@ function rewriteBunCatalog(projectPath, usesVitest, vitestEcosystemPackages) {
|
|
|
7785
7821
|
for (const [key, value] of Object.entries(managed)) {
|
|
7786
7822
|
const current = overrides[key];
|
|
7787
7823
|
if (current !== void 0 && typeof current !== "string") continue;
|
|
7788
|
-
overrides[key] = getCatalogDependencySpec(current, value, true);
|
|
7824
|
+
overrides[key] = key === "@vitest/browser" ? value : getCatalogDependencySpec(current, value, true);
|
|
7789
7825
|
}
|
|
7790
7826
|
pkg.overrides = overrides;
|
|
7791
7827
|
return pkg;
|
|
@@ -7798,7 +7834,7 @@ function rewriteBunCatalog(projectPath, usesVitest, vitestEcosystemPackages) {
|
|
|
7798
7834
|
function rewriteRootWorkspacePackageJson(projectPath, packageManager, skipStagedMigration, catalogDependencyResolver, packages, pnpmMajorVersion, pnpmVersion, shouldAllowBrowserBuilds = false, workspaceUsesVitest = true, supportCatalog = true) {
|
|
7799
7835
|
const packageJsonPath = path.join(projectPath, "package.json");
|
|
7800
7836
|
if (!fs.existsSync(packageJsonPath)) return;
|
|
7801
|
-
const managed = managedOverridePackages(workspaceUsesVitest);
|
|
7837
|
+
const managed = managedOverridePackages(workspaceUsesVitest, workspaceUsesWebdriverioProvider(projectPath, packages));
|
|
7802
7838
|
let movedPnpmSettings;
|
|
7803
7839
|
editJsonFile(packageJsonPath, (pkg) => {
|
|
7804
7840
|
pruneLegacyWrapperAliases(pkg.resolutions);
|
|
@@ -7818,9 +7854,14 @@ function rewriteRootWorkspacePackageJson(projectPath, packageManager, skipStaged
|
|
|
7818
7854
|
...pkg.overrides,
|
|
7819
7855
|
...managed
|
|
7820
7856
|
};
|
|
7821
|
-
else if (packageManager === PackageManager.bun)
|
|
7822
|
-
|
|
7823
|
-
|
|
7857
|
+
else if (packageManager === PackageManager.bun) {
|
|
7858
|
+
if (managed["@vitest/browser"]) pkg.overrides = {
|
|
7859
|
+
...pkg.overrides,
|
|
7860
|
+
"@vitest/browser": managed["@vitest/browser"]
|
|
7861
|
+
};
|
|
7862
|
+
setDirectViteEdge(pkg, true, catalogDependencyResolver);
|
|
7863
|
+
} else if (packageManager === PackageManager.pnpm) {
|
|
7864
|
+
const overrideKeys = Object.keys(managedOverridePackages(workspaceUsesVitest));
|
|
7824
7865
|
if (!pnpmSupportsWorkspaceSettings(pnpmVersion ?? "")) {
|
|
7825
7866
|
dropRemovePackageOverrideKeys(pkg.pnpm?.overrides);
|
|
7826
7867
|
if (!workspaceUsesVitest) removeManagedVitestEntry(pkg.pnpm?.overrides, "pnpm-ranged");
|
|
@@ -7851,7 +7892,6 @@ function rewriteRootWorkspacePackageJson(projectPath, packageManager, skipStaged
|
|
|
7851
7892
|
...pkg.devDependencies,
|
|
7852
7893
|
[VITE_PLUS_NAME]: packageManager === PackageManager.npm || !supportCatalog || VITE_PLUS_VERSION.startsWith("file:") ? VITE_PLUS_VERSION : catalogDependencyResolver?.preferredCatalogSpec ?? "catalog:"
|
|
7853
7894
|
};
|
|
7854
|
-
ensureDirectViteForPnpm(pkg, packageManager, supportCatalog, catalogDependencyResolver);
|
|
7855
7895
|
return pkg;
|
|
7856
7896
|
});
|
|
7857
7897
|
migratePnpmSettingsToWorkspaceYaml(projectPath, movedPnpmSettings);
|
|
@@ -7907,6 +7947,12 @@ function readBunCatalogDependencyResolver(pkg) {
|
|
|
7907
7947
|
//#endregion
|
|
7908
7948
|
//#region src/migration/migrator/yarn.ts
|
|
7909
7949
|
const WEBDRIVERIO_ALLOW_SIGNAL_DEPS = ["webdriverio", WEBDRIVERIO_PROVIDER];
|
|
7950
|
+
function workspaceUsesWebdriverioProvider(rootDir, packages) {
|
|
7951
|
+
return [rootDir, ...(packages ?? []).map((pkg) => path.join(rootDir, pkg.path))].some((dir) => {
|
|
7952
|
+
const pkg = readPackageJsonIfExists(path.join(dir, "package.json"));
|
|
7953
|
+
return Boolean(pkg && findDeclaredSpec(pkg, "@vitest/browser-webdriverio") || usesWebdriverioProvider(dir));
|
|
7954
|
+
});
|
|
7955
|
+
}
|
|
7910
7956
|
function hasOwnWebdriverioDependency(pkg) {
|
|
7911
7957
|
for (const name of WEBDRIVERIO_ALLOW_SIGNAL_DEPS) if (pkg.dependencies?.[name] ?? pkg.devDependencies?.[name] ?? pkg.optionalDependencies?.[name] ?? pkg.peerDependencies?.[name]) return true;
|
|
7912
7958
|
return false;
|
|
@@ -8078,10 +8124,7 @@ const PLAYWRIGHT_PROVIDER_SPECIFIER_HINTS = [
|
|
|
8078
8124
|
"vite-plus/test/browser/providers/playwright",
|
|
8079
8125
|
"vite-plus/test/plugins/browser-playwright"
|
|
8080
8126
|
];
|
|
8081
|
-
const BROWSER_PROVIDER_SPECIFIER_HINTS = {
|
|
8082
|
-
[WEBDRIVERIO_PROVIDER]: WEBDRIVERIO_PROVIDER_SPECIFIER_HINTS,
|
|
8083
|
-
[PLAYWRIGHT_PROVIDER]: PLAYWRIGHT_PROVIDER_SPECIFIER_HINTS
|
|
8084
|
-
};
|
|
8127
|
+
const BROWSER_PROVIDER_SPECIFIER_HINTS = { [PLAYWRIGHT_PROVIDER]: PLAYWRIGHT_PROVIDER_SPECIFIER_HINTS };
|
|
8085
8128
|
const VITEST_SCAN_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
8086
8129
|
".ts",
|
|
8087
8130
|
".mts",
|
|
@@ -8103,7 +8146,8 @@ const VITEST_SCAN_SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
|
8103
8146
|
".nuxt",
|
|
8104
8147
|
".svelte-kit",
|
|
8105
8148
|
".vite",
|
|
8106
|
-
".cache"
|
|
8149
|
+
".cache",
|
|
8150
|
+
".yarn"
|
|
8107
8151
|
]);
|
|
8108
8152
|
const OXLINT_RETENTION_SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
8109
8153
|
"node_modules",
|
|
@@ -8150,10 +8194,11 @@ function sourceTreeMatches(projectPath, matchesContent, options = {}) {
|
|
|
8150
8194
|
if (entry.isDirectory()) {
|
|
8151
8195
|
if (skipDirs.has(entry.name)) continue;
|
|
8152
8196
|
if (scanDir(entryPath, false)) return true;
|
|
8153
|
-
} else if (entry.isFile() && (VITEST_SCAN_EXTENSIONS.has(path.extname(entry.name)) || options.includePackageReferences && entry.name === "package.json")) try {
|
|
8197
|
+
} else if (entry.isFile() && ![".pnp.cjs", ".pnp.loader.mjs"].includes(entry.name) && (VITEST_SCAN_EXTENSIONS.has(path.extname(entry.name)) || options.includeExtensionless && path.extname(entry.name) === "" || options.includePackageReferences && entry.name === "package.json")) try {
|
|
8154
8198
|
let content = fs.readFileSync(entryPath, "utf8");
|
|
8155
8199
|
if (entry.name === "package.json") {
|
|
8156
8200
|
const pkg = JSON.parse(content);
|
|
8201
|
+
if (options.matchesPackage?.(dir, pkg)) return true;
|
|
8157
8202
|
content = JSON.stringify({
|
|
8158
8203
|
imports: pkg.imports,
|
|
8159
8204
|
scripts: pkg.scripts
|
|
@@ -8213,37 +8258,81 @@ function collectProviderSourceModes(projectPath) {
|
|
|
8213
8258
|
return modes;
|
|
8214
8259
|
}
|
|
8215
8260
|
/**
|
|
8216
|
-
* Check final source, build output,
|
|
8261
|
+
* Check final source, build output, aliases, scripts, and dependency peers.
|
|
8217
8262
|
* A substring scan conservatively retains references the rewriter leaves alone,
|
|
8218
8263
|
* including require calls, type references, and strings.
|
|
8219
8264
|
*/
|
|
8220
|
-
function sourceTreeReferencesOxlintPluginsPackage(projectPath) {
|
|
8265
|
+
function sourceTreeReferencesOxlintPluginsPackage(projectPath, originalDependencies = collectOxlintDependencyNames(projectPath)) {
|
|
8221
8266
|
return sourceTreeMatches(projectPath, (content) => content.includes(OXLINT_PLUGINS_PACKAGE), {
|
|
8222
8267
|
crossPackageBoundaries: true,
|
|
8223
8268
|
includePackageReferences: true,
|
|
8269
|
+
includeExtensionless: true,
|
|
8270
|
+
matchesPackage: (dir, pkg) => projectListsRequiredOxlintPluginsPeer(dir, pkg, {
|
|
8271
|
+
retainUnknownPeers: originalDependencies.has(dir),
|
|
8272
|
+
originalDependencyNames: originalDependencies.get(dir)
|
|
8273
|
+
}),
|
|
8224
8274
|
skipDirs: OXLINT_RETENTION_SKIP_DIRS
|
|
8225
8275
|
});
|
|
8226
8276
|
}
|
|
8277
|
+
function projectListsRequiredOxlintPluginsPeer(projectPath, pkg, { retainUnknownPeers = true, originalDependencyNames } = {}) {
|
|
8278
|
+
const dependencyNames = collectInstallDependencyNames(pkg);
|
|
8279
|
+
dependencyNames.delete(OXLINT_PLUGINS_PACKAGE);
|
|
8280
|
+
dependencyNames.delete(VITE_PLUS_NAME);
|
|
8281
|
+
dependencyNames.delete("vite");
|
|
8282
|
+
for (const name of dependencyNames) {
|
|
8283
|
+
if (originalDependencyNames && !originalDependencyNames.has(name)) continue;
|
|
8284
|
+
const metadata = detectPackageMetadata(projectPath, name);
|
|
8285
|
+
if (!metadata) {
|
|
8286
|
+
if (retainUnknownPeers) return true;
|
|
8287
|
+
continue;
|
|
8288
|
+
}
|
|
8289
|
+
try {
|
|
8290
|
+
const installedPkg = readJsonFile(path.join(metadata.path, "package.json"));
|
|
8291
|
+
if (typeof installedPkg.peerDependencies?.["@oxlint/plugins"] === "string" && installedPkg.peerDependenciesMeta?.["@oxlint/plugins"]?.optional !== true) return true;
|
|
8292
|
+
} catch {
|
|
8293
|
+
if (retainUnknownPeers) return true;
|
|
8294
|
+
}
|
|
8295
|
+
}
|
|
8296
|
+
return false;
|
|
8297
|
+
}
|
|
8298
|
+
function collectInstallDependencyNames(pkg) {
|
|
8299
|
+
return /* @__PURE__ */ new Set([
|
|
8300
|
+
...Object.keys(pkg?.dependencies ?? {}),
|
|
8301
|
+
...Object.keys(pkg?.devDependencies ?? {}),
|
|
8302
|
+
...Object.keys(pkg?.optionalDependencies ?? {})
|
|
8303
|
+
]);
|
|
8304
|
+
}
|
|
8305
|
+
function collectOxlintDependencyNames(rootDir, packages) {
|
|
8306
|
+
const names = /* @__PURE__ */ new Map();
|
|
8307
|
+
for (const dir of [rootDir, ...(packages ?? []).map((pkg) => path.join(rootDir, pkg.path))]) {
|
|
8308
|
+
const pkg = readPackageJsonIfExists(path.join(dir, "package.json"));
|
|
8309
|
+
names.set(dir, collectInstallDependencyNames(pkg));
|
|
8310
|
+
}
|
|
8311
|
+
return names;
|
|
8312
|
+
}
|
|
8227
8313
|
/**
|
|
8228
8314
|
* Drop `@oxlint/plugins` from devDependencies once nothing names it any more.
|
|
8229
8315
|
*
|
|
8230
8316
|
* Runs AFTER the import rewrite, so the scan sees final source. Skips a package
|
|
8231
8317
|
* that owns the API as a runtime or peer dependency, and skips any package
|
|
8232
|
-
* whose source
|
|
8318
|
+
* whose source, build output, or installed dependencies still require it.
|
|
8233
8319
|
*/
|
|
8234
|
-
function dropDeadOxlintPluginsDependency(rootDir, packages) {
|
|
8320
|
+
function dropDeadOxlintPluginsDependency(rootDir, packages, originalDependencies = collectOxlintDependencyNames(rootDir, packages)) {
|
|
8321
|
+
let changed = false;
|
|
8235
8322
|
const dirs = [rootDir, ...(packages ?? []).map((pkg) => path.join(rootDir, pkg.path))];
|
|
8236
8323
|
for (const dir of dirs) {
|
|
8237
8324
|
const packageJsonPath = path.join(dir, "package.json");
|
|
8238
8325
|
const pkg = readPackageJsonIfExists(packageJsonPath);
|
|
8239
8326
|
if (pkg?.devDependencies?.["@oxlint/plugins"] === void 0) continue;
|
|
8240
|
-
if (packageOwnsOxlintApi(pkg) || sourceTreeReferencesOxlintPluginsPackage(dir)) continue;
|
|
8327
|
+
if (packageOwnsOxlintApi(pkg) || sourceTreeReferencesOxlintPluginsPackage(dir, originalDependencies)) continue;
|
|
8241
8328
|
editJsonFile(packageJsonPath, (json) => {
|
|
8242
8329
|
if (json.devDependencies?.["@oxlint/plugins"] === void 0) return;
|
|
8243
8330
|
delete json.devDependencies[OXLINT_PLUGINS_PACKAGE];
|
|
8331
|
+
changed = true;
|
|
8244
8332
|
return json;
|
|
8245
8333
|
});
|
|
8246
8334
|
}
|
|
8335
|
+
return changed;
|
|
8247
8336
|
}
|
|
8248
8337
|
//#endregion
|
|
8249
8338
|
//#region src/migration/migrator/vite-plus-bootstrap.ts
|
|
@@ -8256,6 +8345,7 @@ function isSemanticVitePlusOverrideSpec(dependencyName, spec) {
|
|
|
8256
8345
|
if (!spec) return false;
|
|
8257
8346
|
if (isLegacyWrapperSpec(spec)) return false;
|
|
8258
8347
|
if (spec === VITE_PLUS_OVERRIDE_PACKAGES[dependencyName]) return true;
|
|
8348
|
+
if (dependencyName === "@vitest/browser" && spec === "5.0.1") return true;
|
|
8259
8349
|
return false;
|
|
8260
8350
|
}
|
|
8261
8351
|
function overrideSpecSatisfiesVitePlus(dependencyName, spec, catalogDependencyResolver) {
|
|
@@ -8264,8 +8354,8 @@ function overrideSpecSatisfiesVitePlus(dependencyName, spec, catalogDependencyRe
|
|
|
8264
8354
|
if (!spec.startsWith("catalog:")) return false;
|
|
8265
8355
|
return isSemanticVitePlusOverrideSpec(dependencyName, catalogDependencyResolver?.(spec, dependencyName));
|
|
8266
8356
|
}
|
|
8267
|
-
function overridesSatisfyVitePlus(overrides, usesVitest, catalogDependencyResolver, keyStyle = "bare") {
|
|
8268
|
-
const managed = managedOverridePackages(usesVitest);
|
|
8357
|
+
function overridesSatisfyVitePlus(overrides, usesVitest, catalogDependencyResolver, keyStyle = "bare", usesWebdriverioProvider = false) {
|
|
8358
|
+
const managed = managedOverridePackages(usesVitest, usesWebdriverioProvider);
|
|
8269
8359
|
if (!usesVitest && VITEST_IS_MANAGED_OVERRIDE && (typeof overrides?.vitest === "string" || keyStyle === "pnpm-ranged" && typeof overrides?.[pnpmOverrideKey("vitest")] === "string")) return false;
|
|
8270
8360
|
if (keyStyle === "pnpm-ranged" && Object.keys(managed).some((dependencyName) => typeof overrides?.[dependencyName] === "string")) return false;
|
|
8271
8361
|
return Object.keys(managed).every((dependencyName) => overrideSpecSatisfiesVitePlus(dependencyName, overrides?.[managedOverrideKey(dependencyName, keyStyle)], catalogDependencyResolver));
|
|
@@ -8387,7 +8477,7 @@ function reconcileVitePlusBootstrapPackage(projectPath, pkg, vitePlusVersion, pa
|
|
|
8387
8477
|
const frameworkPeer = BROWSER_PROVIDER_PEER_DEPS[provider];
|
|
8388
8478
|
if (!hasProviderPeerDependency(pkg, frameworkPeer)) {
|
|
8389
8479
|
pkg.devDependencies ??= {};
|
|
8390
|
-
pkg.devDependencies[frameworkPeer] = resolveProviderPeerSpec(
|
|
8480
|
+
pkg.devDependencies[frameworkPeer] = resolveProviderPeerSpec(frameworkPeer, supportCatalog, catalogDependencyResolver);
|
|
8391
8481
|
}
|
|
8392
8482
|
}
|
|
8393
8483
|
for (const bundledPackage of REMOVE_PACKAGES) for (const dependencies of installGroups) if (dependencies?.[bundledPackage] !== void 0) delete dependencies[bundledPackage];
|
|
@@ -8408,7 +8498,6 @@ function reconcileVitePlusBootstrapPackage(projectPath, pkg, vitePlusVersion, pa
|
|
|
8408
8498
|
pkg.devDependencies.vitest = getCatalogDependencySpec(void 0, VITEST_VERSION, supportCatalog, { preferredCatalogSpec: catalogDependencyResolver?.preferredCatalogSpec });
|
|
8409
8499
|
}
|
|
8410
8500
|
} else for (const dependencies of installGroups) removeManagedVitestEntry(dependencies);
|
|
8411
|
-
ensureDirectViteForPnpm(pkg, packageManager, supportCatalog, catalogDependencyResolver);
|
|
8412
8501
|
return before !== JSON.stringify(pkg);
|
|
8413
8502
|
}
|
|
8414
8503
|
function bootstrapProjectPaths(rootDir, packages) {
|
|
@@ -8482,17 +8571,18 @@ function detectVitePlusBootstrapPending(projectPath, packageManager, packages, p
|
|
|
8482
8571
|
if (reconcileVitePlusBootstrapPackage(packagePath, JSON.parse(JSON.stringify(childPkg)), canonicalVitePlusSpec, packageManager, supportCatalog, index === 0, catalogDependencyResolver, providerCatalogAdditions)) return true;
|
|
8483
8572
|
}
|
|
8484
8573
|
const usesVitest = workspaceUsesVitestDirectly(projectPath, packages, true);
|
|
8485
|
-
|
|
8486
|
-
if (packageManager === PackageManager.
|
|
8487
|
-
if (packageManager === PackageManager.
|
|
8574
|
+
const usesWebdriverio = workspaceUsesWebdriverioProvider(projectPath, packages);
|
|
8575
|
+
if (packageManager === PackageManager.yarn) return !overridesSatisfyVitePlus(pkg.resolutions, usesVitest, void 0, "bare", usesWebdriverio) || !yarnrcSatisfiesVitePlus(projectPath, usesVitest, supportCatalog) || yarnWorkspaceHoistingOptOutPending(projectPath, packageManager, packages);
|
|
8576
|
+
if (packageManager === PackageManager.npm) return vitePlusDependencyNeedsConcreteVersion(pkg) || !overridesSatisfyVitePlus(pkg.overrides, usesVitest, void 0, "bare", usesWebdriverio) || npmVitePlusManagedDependenciesPending(pkg, usesVitest);
|
|
8577
|
+
if (packageManager === PackageManager.bun) return !overridesSatisfyVitePlus(pkg.overrides, usesVitest, supportCatalog ? readBunCatalogDependencyResolver(pkg) : void 0, "bare", usesWebdriverio);
|
|
8488
8578
|
if (packageManager === PackageManager.pnpm) {
|
|
8489
8579
|
if (!pnpmWorkspaceExoticSubdepsSettingSatisfied(projectPath)) return true;
|
|
8490
8580
|
if (!usePnpmWorkspaceYaml) {
|
|
8491
|
-
if (supportCatalog) return catalogVitePlusDependencyPending(pkg, catalogDependencyResolver) || !overridesSatisfyVitePlus(pkg.pnpm?.overrides, usesVitest, catalogDependencyResolver, "pnpm-ranged") || !pnpmPeerDependencyRulesSatisfyVitePlus(pkg.pnpm?.peerDependencyRules, usesVitest);
|
|
8492
|
-
return vitePlusDependencyNeedsConcreteVersion(pkg) || !overridesSatisfyVitePlus(pkg.pnpm?.overrides, usesVitest, void 0, "pnpm-ranged") || !pnpmPeerDependencyRulesSatisfyVitePlus(pkg.pnpm?.peerDependencyRules, usesVitest);
|
|
8581
|
+
if (supportCatalog) return catalogVitePlusDependencyPending(pkg, catalogDependencyResolver) || !overridesSatisfyVitePlus(pkg.pnpm?.overrides, usesVitest, catalogDependencyResolver, "pnpm-ranged", usesWebdriverio) || !pnpmPeerDependencyRulesSatisfyVitePlus(pkg.pnpm?.peerDependencyRules, usesVitest);
|
|
8582
|
+
return vitePlusDependencyNeedsConcreteVersion(pkg) || !overridesSatisfyVitePlus(pkg.pnpm?.overrides, usesVitest, void 0, "pnpm-ranged", usesWebdriverio) || !pnpmPeerDependencyRulesSatisfyVitePlus(pkg.pnpm?.peerDependencyRules, usesVitest);
|
|
8493
8583
|
}
|
|
8494
8584
|
const resolver = readPnpmWorkspaceCatalogDependencyResolver(projectPath);
|
|
8495
|
-
return workspaceCatalogVitePlusDependencyPending(projectPath, packages, resolver) || !overridesSatisfyVitePlus(readPnpmWorkspaceOverrides(projectPath), usesVitest, resolver, "pnpm-ranged") || !pnpmPeerDependencyRulesSatisfyVitePlus(readPnpmWorkspacePeerDependencyRules(projectPath), usesVitest) || pnpmWorkspaceMinimumReleaseAgeExemptionsPending(projectPath);
|
|
8585
|
+
return workspaceCatalogVitePlusDependencyPending(projectPath, packages, resolver) || !overridesSatisfyVitePlus(readPnpmWorkspaceOverrides(projectPath), usesVitest, resolver, "pnpm-ranged", usesWebdriverio) || !pnpmPeerDependencyRulesSatisfyVitePlus(readPnpmWorkspacePeerDependencyRules(projectPath), usesVitest) || pnpmWorkspaceMinimumReleaseAgeExemptionsPending(projectPath);
|
|
8496
8586
|
}
|
|
8497
8587
|
return false;
|
|
8498
8588
|
}
|
|
@@ -8531,11 +8621,11 @@ function ensureVitePlusDependencySpecs(pkg, version, ensurePresent = true) {
|
|
|
8531
8621
|
function readTextFileIfExists(filePath) {
|
|
8532
8622
|
return fs.existsSync(filePath) ? fs.readFileSync(filePath, "utf-8") : void 0;
|
|
8533
8623
|
}
|
|
8534
|
-
function ensureOverrideEntries(overrides, usesVitest, catalogDependencyResolver, keyStyle = "bare") {
|
|
8624
|
+
function ensureOverrideEntries(overrides, usesVitest, catalogDependencyResolver, keyStyle = "bare", usesWebdriverioProvider = false) {
|
|
8535
8625
|
const next = { ...overrides };
|
|
8536
8626
|
let changed = false;
|
|
8537
8627
|
if (!usesVitest && removeManagedVitestEntry(next, keyStyle)) changed = true;
|
|
8538
|
-
for (const [dependencyName, overrideSpec] of Object.entries(managedOverridePackages(usesVitest))) {
|
|
8628
|
+
for (const [dependencyName, overrideSpec] of Object.entries(managedOverridePackages(usesVitest, usesWebdriverioProvider))) {
|
|
8539
8629
|
const overrideKey = managedOverrideKey(dependencyName, keyStyle);
|
|
8540
8630
|
if (overrideKey !== dependencyName && next[dependencyName] !== void 0) {
|
|
8541
8631
|
next[overrideKey] ??= next[dependencyName];
|
|
@@ -8586,6 +8676,7 @@ function ensureVitePlusBootstrap(workspaceInfo, report) {
|
|
|
8586
8676
|
};
|
|
8587
8677
|
if (!fs.existsSync(packageJsonPath)) return result;
|
|
8588
8678
|
const usesVitest = workspaceUsesVitestDirectly(projectPath, workspaceInfo.packages, true);
|
|
8679
|
+
const usesWebdriverio = workspaceUsesWebdriverioProvider(projectPath, workspaceInfo.packages);
|
|
8589
8680
|
const pnpmMajorVersion = pnpmMajor(workspaceInfo.downloadPackageManager.version);
|
|
8590
8681
|
const shouldAllowBrowserBuilds = workspaceUsesWebdriverio(projectPath, workspaceInfo.packages);
|
|
8591
8682
|
const usePnpmWorkspaceYaml = workspaceInfo.packageManager === PackageManager.pnpm && pnpmSupportsWorkspaceSettings(workspaceInfo.downloadPackageManager.version);
|
|
@@ -8601,31 +8692,31 @@ function ensureVitePlusBootstrap(workspaceInfo, report) {
|
|
|
8601
8692
|
let pnpmWorkspaceCatalogBefore;
|
|
8602
8693
|
if (workspaceInfo.packageManager === PackageManager.pnpm && !usePnpmWorkspaceYaml) {
|
|
8603
8694
|
pnpmWorkspaceCatalogBefore = readTextFileIfExists(pnpmWorkspaceYamlPath);
|
|
8604
|
-
if (supportCatalog) rewritePnpmWorkspaceYaml(projectPath, pnpmMajorVersion, shouldAllowBrowserBuilds, usesVitest, vitestEcosystemPackages, false, providerCatalogAdditions);
|
|
8695
|
+
if (supportCatalog) rewritePnpmWorkspaceYaml(projectPath, pnpmMajorVersion, shouldAllowBrowserBuilds, usesVitest, vitestEcosystemPackages, false, providerCatalogAdditions, usesWebdriverio);
|
|
8605
8696
|
}
|
|
8606
8697
|
editJsonFile(packageJsonPath, (pkg) => {
|
|
8607
8698
|
let packageJsonChanged = reconcileVitePlusBootstrapPackage(projectPath, pkg, canonicalVitePlusSpec, workspaceInfo.packageManager, supportCatalog, true, catalogDependencyResolver, providerCatalogAdditions);
|
|
8608
8699
|
if (workspaceInfo.packageManager === PackageManager.yarn) {
|
|
8609
|
-
const ensured = ensureOverrideEntries(pkg.resolutions, usesVitest);
|
|
8700
|
+
const ensured = ensureOverrideEntries(pkg.resolutions, usesVitest, void 0, "bare", usesWebdriverio);
|
|
8610
8701
|
if (ensured.changed) {
|
|
8611
8702
|
pkg.resolutions = ensured.overrides;
|
|
8612
8703
|
packageJsonChanged = true;
|
|
8613
8704
|
}
|
|
8614
8705
|
} else if (workspaceInfo.packageManager === PackageManager.npm) {
|
|
8615
|
-
const ensured = ensureOverrideEntries(pkg.overrides, usesVitest);
|
|
8706
|
+
const ensured = ensureOverrideEntries(pkg.overrides, usesVitest, void 0, "bare", usesWebdriverio);
|
|
8616
8707
|
if (ensured.changed) {
|
|
8617
8708
|
pkg.overrides = ensured.overrides;
|
|
8618
8709
|
packageJsonChanged = true;
|
|
8619
8710
|
}
|
|
8620
8711
|
} else if (workspaceInfo.packageManager === PackageManager.bun) {
|
|
8621
|
-
const ensured = ensureOverrideEntries(pkg.overrides, usesVitest, supportCatalog ? readBunCatalogDependencyResolver(pkg) : void 0);
|
|
8712
|
+
const ensured = ensureOverrideEntries(pkg.overrides, usesVitest, supportCatalog ? readBunCatalogDependencyResolver(pkg) : void 0, "bare", usesWebdriverio);
|
|
8622
8713
|
if (ensured.changed) {
|
|
8623
8714
|
pkg.overrides = ensured.overrides;
|
|
8624
8715
|
packageJsonChanged = true;
|
|
8625
8716
|
}
|
|
8626
8717
|
} else if (workspaceInfo.packageManager === PackageManager.pnpm && !usePnpmWorkspaceYaml) {
|
|
8627
8718
|
pkg.pnpm ??= {};
|
|
8628
|
-
const ensured = ensureOverrideEntries(pkg.pnpm.overrides, usesVitest, supportCatalog ? readPnpmWorkspaceCatalogDependencyResolver(projectPath) : void 0, "pnpm-ranged");
|
|
8719
|
+
const ensured = ensureOverrideEntries(pkg.pnpm.overrides, usesVitest, supportCatalog ? readPnpmWorkspaceCatalogDependencyResolver(projectPath) : void 0, "pnpm-ranged", usesWebdriverio);
|
|
8629
8720
|
if (ensured.changed) {
|
|
8630
8721
|
pkg.pnpm.overrides = ensured.overrides;
|
|
8631
8722
|
packageJsonChanged = true;
|
|
@@ -8664,7 +8755,7 @@ function ensureVitePlusBootstrap(workspaceInfo, report) {
|
|
|
8664
8755
|
const before = readTextFileIfExists(pnpmWorkspaceYamlPath);
|
|
8665
8756
|
migratePnpmSettingsToWorkspaceYaml(projectPath, movedPnpmSettings);
|
|
8666
8757
|
const catalogDependencyResolver = readPnpmWorkspaceCatalogDependencyResolver(projectPath);
|
|
8667
|
-
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);
|
|
8758
|
+
if (movedPnpmSettings !== void 0 || result.packageJson || ecosystemCatalogReferencesPending || !pnpmWorkspaceExoticSubdepsSettingSatisfied(projectPath) || pnpmWorkspaceMinimumReleaseAgeExemptionsPending(projectPath) || workspaceCatalogVitePlusDependencyPending(projectPath, workspaceInfo.packages, catalogDependencyResolver) || !overridesSatisfyVitePlus(readPnpmWorkspaceOverrides(projectPath), usesVitest, catalogDependencyResolver, "pnpm-ranged", usesWebdriverio) || !pnpmPeerDependencyRulesSatisfyVitePlus(readPnpmWorkspacePeerDependencyRules(projectPath), usesVitest)) rewritePnpmWorkspaceYaml(projectPath, pnpmMajorVersion, shouldAllowBrowserBuilds, usesVitest, vitestEcosystemPackages, true, providerCatalogAdditions, usesWebdriverio);
|
|
8668
8759
|
if (fs.existsSync(pnpmWorkspaceYamlPath)) ensurePnpmWorkspacePackages(projectPath, workspaceInfo.workspacePatterns);
|
|
8669
8760
|
result.packageManagerConfig = before !== readTextFileIfExists(pnpmWorkspaceYamlPath);
|
|
8670
8761
|
} else {
|
|
@@ -8680,7 +8771,7 @@ function ensureVitePlusBootstrap(workspaceInfo, report) {
|
|
|
8680
8771
|
result.packageManagerConfig = before !== fs.readFileSync(yarnrcYmlPath, "utf-8");
|
|
8681
8772
|
} else if (isBunWorkspace) {
|
|
8682
8773
|
const before = fs.readFileSync(packageJsonPath, "utf-8");
|
|
8683
|
-
rewriteBunCatalog(projectPath, usesVitest, vitestEcosystemPackages);
|
|
8774
|
+
rewriteBunCatalog(projectPath, usesVitest, vitestEcosystemPackages, usesWebdriverio);
|
|
8684
8775
|
const after = fs.readFileSync(packageJsonPath, "utf-8");
|
|
8685
8776
|
result.packageJson = result.packageJson || before !== after;
|
|
8686
8777
|
}
|
|
@@ -8879,7 +8970,7 @@ function rewritePackageJson(pkg, packageManager, isMonorepo, skipStagedMigration
|
|
|
8879
8970
|
const peer = BROWSER_PROVIDER_PEER_DEPS[provider];
|
|
8880
8971
|
if (!hasProviderPeerDependency(pkg, peer)) {
|
|
8881
8972
|
pkg.devDependencies ??= {};
|
|
8882
|
-
pkg.devDependencies[peer] = resolveProviderPeerSpec(
|
|
8973
|
+
pkg.devDependencies[peer] = resolveProviderPeerSpec(peer, supportCatalog, catalogDependencyResolver);
|
|
8883
8974
|
}
|
|
8884
8975
|
needVitePlus = true;
|
|
8885
8976
|
}
|
|
@@ -8911,7 +9002,6 @@ function rewritePackageJson(pkg, packageManager, isMonorepo, skipStagedMigration
|
|
|
8911
9002
|
...pkg.devDependencies,
|
|
8912
9003
|
[VITE_PLUS_NAME]: canonicalVitePlusSpec
|
|
8913
9004
|
};
|
|
8914
|
-
ensureDirectViteForPnpm(pkg, packageManager, supportCatalog, catalogDependencyResolver);
|
|
8915
9005
|
if (needDirectVitest) {
|
|
8916
9006
|
if (!{
|
|
8917
9007
|
...pkg.dependencies,
|
|
@@ -8979,7 +9069,7 @@ function rewriteLintStagedConfigFile(projectPath, report) {
|
|
|
8979
9069
|
warnMigration(`${displayRelative(configPath)} — please migrate to "staged" in vite.config.ts manually`, report);
|
|
8980
9070
|
hasUnsupported = true;
|
|
8981
9071
|
}
|
|
8982
|
-
if (hasUnsupported) infoMigration(
|
|
9072
|
+
if (hasUnsupported) infoMigration(`Only "staged" in vite.config.ts is supported. See ${documentationUrl$1("/guide/migrate#lint-staged")}`, report);
|
|
8983
9073
|
}
|
|
8984
9074
|
/**
|
|
8985
9075
|
* Ensure vite.config.ts exists, create it if not
|
|
@@ -9017,7 +9107,7 @@ function mergeTsdownConfigFile(projectPath, silent = false, report) {
|
|
|
9017
9107
|
const tsdownRelativePath = `./${configs.tsdownConfig}`;
|
|
9018
9108
|
if (hasConfigKey(fullViteConfigPath, "pack")) {
|
|
9019
9109
|
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
|
|
9110
|
+
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 ${documentationUrl$1("/guide/migrate#tsdown")}`, report);
|
|
9021
9111
|
return false;
|
|
9022
9112
|
}
|
|
9023
9113
|
const result = mergeTsdownConfig(fullViteConfigPath, tsdownRelativePath);
|
|
@@ -9026,7 +9116,7 @@ function mergeTsdownConfigFile(projectPath, silent = false, report) {
|
|
|
9026
9116
|
if (report) report.tsdownImportCount++;
|
|
9027
9117
|
if (!silent) log.success(`✔ Added import for ${displayRelative(fullTsdownConfigPath)} in ${displayRelative(fullViteConfigPath)}`);
|
|
9028
9118
|
}
|
|
9029
|
-
infoMigration(`Please manually merge ${displayRelative(fullTsdownConfigPath)} into ${displayRelative(fullViteConfigPath)}, see
|
|
9119
|
+
infoMigration(`Please manually merge ${displayRelative(fullTsdownConfigPath)} into ${displayRelative(fullViteConfigPath)}, see ${documentationUrl$1("/guide/migrate#tsdown")}`, report);
|
|
9030
9120
|
return createdViteConfig || result.updated;
|
|
9031
9121
|
}
|
|
9032
9122
|
/**
|
|
@@ -9110,7 +9200,7 @@ function mergeAndRemoveJsonConfig(projectPath, viteConfigPath, jsonConfigPath, c
|
|
|
9110
9200
|
if (!silent) log.success(`✔ Merged ${displayRelative(fullJsonConfigPath)} into ${displayRelative(fullViteConfigPath)}`);
|
|
9111
9201
|
} else {
|
|
9112
9202
|
warnMigration(`Failed to merge ${displayRelative(fullJsonConfigPath)} into ${displayRelative(fullViteConfigPath)}`, report);
|
|
9113
|
-
infoMigration(
|
|
9203
|
+
infoMigration(`Please complete the merge manually and follow the instructions in the documentation: ${documentationUrl$1("/config/")}`, report);
|
|
9114
9204
|
}
|
|
9115
9205
|
}
|
|
9116
9206
|
/**
|
|
@@ -9135,7 +9225,7 @@ function mergeStagedConfigToViteConfig(projectPath, stagedConfig, silent = false
|
|
|
9135
9225
|
return true;
|
|
9136
9226
|
} else {
|
|
9137
9227
|
warnMigration(`Failed to merge staged config into ${displayRelative(fullViteConfigPath)}`, report);
|
|
9138
|
-
infoMigration(`Please add staged config to ${displayRelative(fullViteConfigPath)} manually, see
|
|
9228
|
+
infoMigration(`Please add staged config to ${displayRelative(fullViteConfigPath)} manually, see ${documentationUrl$1("/guide/migrate#lint-staged")}`, report);
|
|
9139
9229
|
return false;
|
|
9140
9230
|
}
|
|
9141
9231
|
}
|
|
@@ -9196,37 +9286,6 @@ function rewriteAllImports(projectPath, silent = false, report, preserveNuxtVite
|
|
|
9196
9286
|
return modified > 0;
|
|
9197
9287
|
}
|
|
9198
9288
|
//#endregion
|
|
9199
|
-
//#region src/utils/git.ts
|
|
9200
|
-
var import_cross_spawn = /* @__PURE__ */ __toESM(require_cross_spawn(), 1);
|
|
9201
|
-
/**
|
|
9202
|
-
* Walk up from `startPath` looking for `.git` (directory or file — submodules
|
|
9203
|
-
* use a `.git` file). Returns the directory that contains `.git`, or `null`.
|
|
9204
|
-
*/
|
|
9205
|
-
function findGitRoot(startPath) {
|
|
9206
|
-
let dir = startPath;
|
|
9207
|
-
while (true) {
|
|
9208
|
-
if (fs.existsSync(path.join(dir, ".git"))) return dir;
|
|
9209
|
-
const parent = path.dirname(dir);
|
|
9210
|
-
if (parent === dir) return null;
|
|
9211
|
-
dir = parent;
|
|
9212
|
-
}
|
|
9213
|
-
}
|
|
9214
|
-
async function initGitRepository(cwd) {
|
|
9215
|
-
const result = await runCommandSilently({
|
|
9216
|
-
command: "git",
|
|
9217
|
-
args: ["init"],
|
|
9218
|
-
cwd,
|
|
9219
|
-
envs: process.env
|
|
9220
|
-
});
|
|
9221
|
-
if (result.exitCode !== 0) {
|
|
9222
|
-
log.warn("Failed to initialize git repository");
|
|
9223
|
-
const stderr = result.stderr.toString().trim();
|
|
9224
|
-
if (stderr) log.info(stderr);
|
|
9225
|
-
return false;
|
|
9226
|
-
}
|
|
9227
|
-
return true;
|
|
9228
|
-
}
|
|
9229
|
-
//#endregion
|
|
9230
9289
|
//#region src/migration/migrator/git-hooks.ts
|
|
9231
9290
|
const OTHER_HOOK_TOOLS = [
|
|
9232
9291
|
"simple-git-hooks",
|
|
@@ -9323,7 +9382,7 @@ function preflightGitHooksSetup(projectPath, _packageManager, packages = []) {
|
|
|
9323
9382
|
const configuredHooksPath = gitRoot ? getConfiguredHooksPath(projectPath) : "";
|
|
9324
9383
|
const normalizedHooksPath = normalizeGitHooksPath(configuredHooksPath);
|
|
9325
9384
|
if (hasHuskySetup(projectPath, pkgContent) || normalizedHooksPath === ".husky" || normalizedHooksPath.startsWith(".husky/")) return "Detected Husky — leaving its hooks, configuration, and dependencies unchanged. Migrate Husky manually before enabling Vite+ hooks.";
|
|
9326
|
-
for (const tool of OTHER_HOOK_TOOLS) if (deps?.[tool] || prodDeps?.[tool] || pkgContent[tool]) return `Detected ${tool} — skipping git hooks setup. Please configure git hooks manually, see
|
|
9385
|
+
for (const tool of OTHER_HOOK_TOOLS) if (deps?.[tool] || prodDeps?.[tool] || pkgContent[tool]) return `Detected ${tool} — skipping git hooks setup. Please configure git hooks manually, see ${documentationUrl$1("/guide/migrate#git-hook-tools")}`;
|
|
9327
9386
|
const workspacePackageReason = findWorkspacePackageHookPolicy(projectPath, packages);
|
|
9328
9387
|
if (workspacePackageReason) return workspacePackageReason;
|
|
9329
9388
|
const disabledHooksEnvironment = [
|
|
@@ -9676,6 +9735,7 @@ function detectPendingCoreMigration(workspaceInfo) {
|
|
|
9676
9735
|
function finalizeCoreMigrationForExistingVitePlus(workspaceInfo, silent = false, report, pending = detectPendingCoreMigration(workspaceInfo)) {
|
|
9677
9736
|
const projectPaths = getCoreMigrationProjectPaths(workspaceInfo);
|
|
9678
9737
|
const result = {
|
|
9738
|
+
dependencies: false,
|
|
9679
9739
|
scripts: false,
|
|
9680
9740
|
tsconfigTypes: false,
|
|
9681
9741
|
imports: false,
|
|
@@ -9684,6 +9744,7 @@ function finalizeCoreMigrationForExistingVitePlus(workspaceInfo, silent = false,
|
|
|
9684
9744
|
if (pending.scripts) for (const projectPath of projectPaths) result.scripts = rewriteCorePackageScripts(projectPath) || result.scripts;
|
|
9685
9745
|
if (pending.tsconfigTypes) for (const projectPath of projectPaths) result.tsconfigTypes = rewriteTsconfigTypes(projectPath, silent, report) || result.tsconfigTypes;
|
|
9686
9746
|
result.imports = rewriteAllImports(workspaceInfo.rootDir, silent, report, true);
|
|
9747
|
+
result.dependencies = dropDeadOxlintPluginsDependency(workspaceInfo.rootDir, workspaceInfo.packages);
|
|
9687
9748
|
for (const projectPath of projectPaths) result.tsdownConfig = mergeTsdownConfigFile(projectPath, silent, report) || result.tsdownConfig;
|
|
9688
9749
|
return result;
|
|
9689
9750
|
}
|
|
@@ -9696,7 +9757,9 @@ function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigratio
|
|
|
9696
9757
|
const catalogDependencyResolver = createCatalogDependencyResolver(projectPath, packageManager);
|
|
9697
9758
|
const vitestEcosystemPackages = collectVitestEcosystemInstallDependencyNames(projectPath);
|
|
9698
9759
|
const oxlintOwnerDirs = collectOxlintOwnerDirs(projectPath, workspaceInfo.packages);
|
|
9760
|
+
const originalOxlintDependencies = collectOxlintDependencyNames(projectPath, workspaceInfo.packages);
|
|
9699
9761
|
const providerSourceModes = collectProviderSourceModes(projectPath);
|
|
9762
|
+
const usesWebdriverio = workspaceUsesWebdriverioProvider(projectPath);
|
|
9700
9763
|
const browserMode = usesVitestBrowserMode(projectPath);
|
|
9701
9764
|
const retainedVitestModule = sourceTreeReferencesRetainedVitestModule(projectPath);
|
|
9702
9765
|
const providerCatalogAdditions = collectInjectedProviderNames(projectPath, void 0, /* @__PURE__ */ new Map([[projectPath, providerSourceModes]]));
|
|
@@ -9715,7 +9778,7 @@ function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigratio
|
|
|
9715
9778
|
browserMode,
|
|
9716
9779
|
retainedModule: retainedVitestModule
|
|
9717
9780
|
});
|
|
9718
|
-
const managed = managedOverridePackages(usesVitest);
|
|
9781
|
+
const managed = managedOverridePackages(usesVitest, usesWebdriverio);
|
|
9719
9782
|
pruneLegacyWrapperAliases(pkg.resolutions);
|
|
9720
9783
|
pruneLegacyWrapperAliases(pkg.overrides);
|
|
9721
9784
|
pruneLegacyWrapperAliases(pkg.pnpm?.overrides);
|
|
@@ -9737,7 +9800,7 @@ function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigratio
|
|
|
9737
9800
|
if (packageManager === PackageManager.bun) setDirectViteEdge(pkg, supportCatalog, catalogDependencyResolver);
|
|
9738
9801
|
} else if (packageManager === PackageManager.pnpm) {
|
|
9739
9802
|
if (usePnpmWorkspaceYaml) shouldAddPnpmWorkspaceVitePlusOverride = isForceOverrideMode();
|
|
9740
|
-
const overrideKeys = Object.keys(
|
|
9803
|
+
const overrideKeys = Object.keys(managedOverridePackages(usesVitest));
|
|
9741
9804
|
if (!usePnpmWorkspaceYaml) {
|
|
9742
9805
|
dropRemovePackageOverrideKeys(pkg.pnpm?.overrides);
|
|
9743
9806
|
if (!usesVitest) {
|
|
@@ -9774,11 +9837,10 @@ function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigratio
|
|
|
9774
9837
|
[VITE_PLUS_NAME]: version
|
|
9775
9838
|
};
|
|
9776
9839
|
}
|
|
9777
|
-
ensureDirectViteForPnpm(pkg, packageManager, supportCatalog, catalogDependencyResolver);
|
|
9778
9840
|
return pkg;
|
|
9779
9841
|
});
|
|
9780
9842
|
migratePnpmSettingsToWorkspaceYaml(projectPath, movedPnpmSettings);
|
|
9781
|
-
if (packageManager === PackageManager.pnpm && (usePnpmWorkspaceYaml || supportCatalog)) rewritePnpmWorkspaceYaml(projectPath, pnpmMajorVersion, shouldAllowBrowserProviderBuilds, usesVitest, vitestEcosystemPackages, usePnpmWorkspaceYaml, providerCatalogAdditions);
|
|
9843
|
+
if (packageManager === PackageManager.pnpm && (usePnpmWorkspaceYaml || supportCatalog)) rewritePnpmWorkspaceYaml(projectPath, pnpmMajorVersion, shouldAllowBrowserProviderBuilds, usesVitest, vitestEcosystemPackages, usePnpmWorkspaceYaml, providerCatalogAdditions, usesWebdriverio);
|
|
9782
9844
|
if (shouldAddPnpmWorkspaceVitePlusOverride) migratePnpmOverridesToWorkspaceYaml(projectPath, { [VITE_PLUS_NAME]: VITE_PLUS_VERSION });
|
|
9783
9845
|
if (packageManager === PackageManager.pnpm) ensurePnpmWorkspaceExoticSubdepsSetting(projectPath);
|
|
9784
9846
|
if (packageManager === PackageManager.yarn) rewriteYarnrcYml(projectPath, usesVitest, vitestEcosystemPackages, providerCatalogAdditions, supportCatalog);
|
|
@@ -9793,7 +9855,7 @@ function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigratio
|
|
|
9793
9855
|
injectFmtDefaults(projectPath, silent, report);
|
|
9794
9856
|
mergeTsdownConfigFile(projectPath, silent, report);
|
|
9795
9857
|
rewriteAllImports(projectPath, silent, report, true, oxlintOwnerDirs);
|
|
9796
|
-
dropDeadOxlintPluginsDependency(projectPath, workspaceInfo.packages);
|
|
9858
|
+
dropDeadOxlintPluginsDependency(projectPath, workspaceInfo.packages, originalOxlintDependencies);
|
|
9797
9859
|
wrapLazyPluginsInViteConfig(projectPath, silent, report);
|
|
9798
9860
|
setPackageManager(projectPath, workspaceInfo.downloadPackageManager);
|
|
9799
9861
|
}
|
|
@@ -9804,18 +9866,20 @@ function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigratio
|
|
|
9804
9866
|
function rewriteMonorepo(workspaceInfo, skipStagedMigration, silent = false, report) {
|
|
9805
9867
|
const catalogDependencyResolver = createCatalogDependencyResolver(workspaceInfo.rootDir, workspaceInfo.packageManager);
|
|
9806
9868
|
const oxlintOwnerDirs = collectOxlintOwnerDirs(workspaceInfo.rootDir, workspaceInfo.packages);
|
|
9869
|
+
const originalOxlintDependencies = collectOxlintDependencyNames(workspaceInfo.rootDir, workspaceInfo.packages);
|
|
9807
9870
|
const pnpmMajorVersion = pnpmMajor(workspaceInfo.downloadPackageManager.version);
|
|
9808
9871
|
const usePnpmWorkspaceSettings = pnpmSupportsWorkspaceSettings(workspaceInfo.downloadPackageManager.version);
|
|
9809
9872
|
const workspaceShouldAllowBrowserBuilds = workspaceUsesWebdriverio(workspaceInfo.rootDir, workspaceInfo.packages);
|
|
9873
|
+
const usesWebdriverio = workspaceUsesWebdriverioProvider(workspaceInfo.rootDir, workspaceInfo.packages);
|
|
9810
9874
|
const workspaceUsesVitest = workspaceUsesVitestDirectly(workspaceInfo.rootDir, workspaceInfo.packages, true);
|
|
9811
9875
|
const vitestEcosystemPackages = collectVitestEcosystemInstallDependencyNames(workspaceInfo.rootDir, workspaceInfo.packages);
|
|
9812
9876
|
const providerCatalogAdditions = collectInjectedProviderNames(workspaceInfo.rootDir, workspaceInfo.packages);
|
|
9813
9877
|
const supportCatalog = supportsCatalog(workspaceInfo.packageManager, workspaceInfo.downloadPackageManager.version, true);
|
|
9814
9878
|
if (workspaceInfo.packageManager === PackageManager.yarn) rewriteYarnrcYml(workspaceInfo.rootDir, workspaceUsesVitest, vitestEcosystemPackages, providerCatalogAdditions, supportCatalog);
|
|
9815
|
-
else if (workspaceInfo.packageManager === PackageManager.bun) rewriteBunCatalog(workspaceInfo.rootDir, workspaceUsesVitest, vitestEcosystemPackages);
|
|
9879
|
+
else if (workspaceInfo.packageManager === PackageManager.bun) rewriteBunCatalog(workspaceInfo.rootDir, workspaceUsesVitest, vitestEcosystemPackages, usesWebdriverio);
|
|
9816
9880
|
rewriteRootWorkspacePackageJson(workspaceInfo.rootDir, workspaceInfo.packageManager, skipStagedMigration, catalogDependencyResolver, workspaceInfo.packages, pnpmMajorVersion, workspaceInfo.downloadPackageManager.version, workspaceShouldAllowBrowserBuilds, workspaceUsesVitest, supportCatalog);
|
|
9817
9881
|
if (workspaceInfo.packageManager === PackageManager.pnpm) {
|
|
9818
|
-
rewritePnpmWorkspaceYaml(workspaceInfo.rootDir, pnpmMajorVersion, workspaceShouldAllowBrowserBuilds, workspaceUsesVitest, vitestEcosystemPackages, usePnpmWorkspaceSettings, providerCatalogAdditions);
|
|
9882
|
+
rewritePnpmWorkspaceYaml(workspaceInfo.rootDir, pnpmMajorVersion, workspaceShouldAllowBrowserBuilds, workspaceUsesVitest, vitestEcosystemPackages, usePnpmWorkspaceSettings, providerCatalogAdditions, usesWebdriverio);
|
|
9819
9883
|
if (usePnpmWorkspaceSettings && isForceOverrideMode()) migratePnpmOverridesToWorkspaceYaml(workspaceInfo.rootDir, { [VITE_PLUS_NAME]: VITE_PLUS_VERSION });
|
|
9820
9884
|
}
|
|
9821
9885
|
const workspaceContext = {
|
|
@@ -9831,7 +9895,7 @@ function rewriteMonorepo(workspaceInfo, skipStagedMigration, silent = false, rep
|
|
|
9831
9895
|
injectFmtDefaults(workspaceInfo.rootDir, silent, report);
|
|
9832
9896
|
mergeTsdownConfigFile(workspaceInfo.rootDir, silent, report);
|
|
9833
9897
|
rewriteAllImports(workspaceInfo.rootDir, silent, report, true, oxlintOwnerDirs);
|
|
9834
|
-
dropDeadOxlintPluginsDependency(workspaceInfo.rootDir, workspaceInfo.packages);
|
|
9898
|
+
dropDeadOxlintPluginsDependency(workspaceInfo.rootDir, workspaceInfo.packages, originalOxlintDependencies);
|
|
9835
9899
|
wrapLazyPluginsInViteConfig(workspaceInfo.rootDir, silent, report);
|
|
9836
9900
|
for (const pkg of workspaceInfo.packages) wrapLazyPluginsInViteConfig(path.join(workspaceInfo.rootDir, pkg.path), silent, report);
|
|
9837
9901
|
setPackageManager(workspaceInfo.rootDir, workspaceInfo.downloadPackageManager);
|
|
@@ -10226,4 +10290,4 @@ function resolveEditorIds(editors) {
|
|
|
10226
10290
|
return uniqueEditorIds.length === 0 ? void 0 : uniqueEditorIds;
|
|
10227
10291
|
}
|
|
10228
10292
|
//#endregion
|
|
10229
|
-
export {
|
|
10293
|
+
export { confirmEslintMigration as $, createCatalogDependencyResolver as A, addFrameworkShim as B, mergeViteConfigFiles as C, usesWebdriverioProvider as D, ensureVitePlusBootstrap as E, updateWorkspaceConfig as F, migrateTsupToTsdown as G, hasFrameworkShim as H, minimatch as I, confirmPrettierMigration as J, promptTsupMigration as K, findGitRoot as L, detectWorkspace$1 as M, isBingoTemplate as N, configureYarnNodeModulesMode as O, updatePackageJsonWithDeps as P, warnPackageLevelPrettier as Q, initGitRepository as R, mergeTsdownConfigFile as S, detectVitePlusBootstrapPending as T, confirmTsupMigration as U, detectFramework as V, detectTsupProject as W, migratePrettierToOxfmt as X, detectPrettierProject as Y, promptPrettierMigration as Z, installGitHooks as _, selectEditors as a, warnLegacyEslintConfig as at, injectCreateDefaultTemplate as b, rewriteMonorepoProject as c, checkViteVersion as ct, finalizeCoreMigrationForExistingVitePlus as d, detectEslintProject as et, detectNodeVersionManagerFile as f, detectLegacyGitHooksMigrationCandidate as g, setPackageManager as h, selectEditor as i, warnIncompatibleEslintIntegration as it, supportsCatalog as j, detectYarnPnpMode as k, rewriteStandaloneProject as l, checkVitestVersion as lt, migrateSetupVpVersion as m, detectExistingEditors as n, migrateEslintToOxlint as nt, writeEditorConfigs as o, warnPackageLevelEslint as ot, migrateNodeVersionManagerFile as p, warnMissingTsupConfig as q, isJsonLikeFile as r, promptEslintMigration as rt, rewriteMonorepo as s, WEBDRIVERIO_PROVIDER as st, detectEditorConflicts as t, detectIncompatibleEslintIntegration as tt, detectPendingCoreMigration as u, preflightGitHooksSetup as v, collectToolchainVersionChanges as w, injectLintTypeCheckDefaults as x, shouldSkipStagedMigrationForHooks as y, extractOverrideParentSegments as z };
|