vite-plus 0.1.23 → 0.2.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 +30 -0
- package/README.md +8 -6
- package/bin/oxfmt +5 -2
- package/bin/oxlint +12 -2
- package/binding/index.cjs +84 -67
- package/binding/index.d.cts +155 -4
- package/dist/{agent-aSGY0osq.js → agent-BD31CsvU.js} +969 -89
- package/dist/bin.js +29 -33
- package/dist/{compat-DXZgnEyq.js → compat-Cql3K40m.js} +1 -1
- package/dist/config/bin.js +30 -14
- package/dist/constants-CrfJQIUX.js +66 -0
- package/dist/create/bin.d.ts +7 -1
- package/dist/create/bin.js +578 -266
- package/dist/define-config-2tfJoXr1.d.ts +305 -0
- package/dist/define-config-BGSjF6Xp.cjs +488 -0
- package/dist/define-config-DJUehepE.js +445 -0
- package/dist/define-config.cjs +8 -1
- package/dist/define-config.d.ts +2 -2
- package/dist/define-config.js +2 -2
- package/dist/dist-DRJUd9bL.js +3 -0
- package/dist/{dist-BgQuvbtq.js → dist-Oxo16Y0q.js} +4 -4
- package/dist/index.cjs +9 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/{main-DpJl3LoU.js → json-Dn87fvjk.js} +137 -1
- package/dist/migration/bin.js +301 -84
- package/dist/{oxlint-plugin-config-B89iKTKN.js → oxlint-plugin-config-q8a5PFch.js} +1 -1
- package/dist/oxlint-plugin.js +11 -3
- package/dist/pack-bin.js +44 -15
- package/dist/{package-PmBUZ-ve.js → package-BHirM1_v.js} +3 -138
- package/dist/{report-DgSBQUdz.js → report-BHSkWqRR.js} +2 -0
- package/dist/{resolve-vite-config-TTvhycU1.js → resolve-vite-config-CmdsfQzS.js} +13 -4
- package/dist/staged/bin.js +150 -417
- package/dist/test/_at-vitest-browser/context.d.ts +2 -0
- package/dist/test/_at-vitest-browser.d.ts +2 -0
- package/dist/test/browser/context.d.ts +2 -2
- package/dist/test/browser/context.js +1 -1
- package/dist/test/browser/providers/playwright/context.d.ts +1 -0
- package/dist/test/browser/providers/playwright/context.js +1 -0
- package/dist/test/browser/providers/playwright.d.ts +124 -2
- package/dist/test/browser/providers/playwright.js +1 -1
- package/dist/test/browser/providers/preview/context.d.ts +1 -0
- package/dist/test/browser/providers/preview/context.js +1 -0
- package/dist/test/browser/providers/preview.d.ts +32 -2
- package/dist/test/browser/providers/preview.js +1 -1
- package/dist/test/browser/providers/webdriverio/context.d.ts +1 -0
- package/dist/test/browser/providers/webdriverio/context.js +1 -0
- package/dist/test/browser/providers/webdriverio.d.ts +77 -2
- package/dist/test/browser/providers/webdriverio.js +1 -1
- package/dist/test/browser-compat.d.ts +2 -0
- package/dist/test/browser-compat.js +1 -1
- package/dist/test/browser-playwright/context.d.ts +1 -0
- package/dist/test/browser-playwright/context.js +1 -0
- package/dist/test/browser-playwright.d.ts +124 -2
- package/dist/test/browser-playwright.js +1 -1
- package/dist/test/browser-preview/context.d.ts +1 -0
- package/dist/test/browser-preview/context.js +1 -0
- package/dist/test/browser-preview.d.ts +32 -2
- package/dist/test/browser-preview.js +1 -1
- package/dist/test/browser-webdriverio/context.d.ts +1 -0
- package/dist/test/browser-webdriverio/context.js +1 -0
- package/dist/test/browser-webdriverio.d.ts +77 -2
- package/dist/test/browser-webdriverio.js +1 -1
- package/dist/test/browser.d.ts +2 -2
- package/dist/test/browser.js +1 -1
- package/dist/test/client.js +1 -1
- package/dist/test/config.cjs +1 -1
- package/dist/test/config.d.ts +2 -2
- package/dist/test/config.js +1 -1
- package/dist/test/context.d.ts +942 -2
- package/dist/test/context.js +1 -1
- package/dist/test/coverage.d.ts +2 -2
- package/dist/test/coverage.js +1 -1
- package/dist/test/environments.d.ts +2 -2
- package/dist/test/environments.js +1 -1
- package/dist/test/globals.d.ts +2 -2
- package/dist/test/import-meta.d.ts +2 -2
- package/dist/test/importMeta.d.ts +2 -2
- package/dist/test/index.cjs +1 -1
- package/dist/test/index.d.cts +2 -2
- package/dist/test/index.d.ts +2 -2
- package/dist/test/index.js +1 -1
- package/dist/test/internal/browser.d.ts +2 -2
- package/dist/test/internal/browser.js +1 -1
- package/dist/test/jsdom.d.ts +2 -2
- package/dist/test/locators.d.ts +294 -0
- package/dist/test/locators.js +1 -1
- package/dist/test/matchers.d.ts +29 -0
- package/dist/test/matchers.js +1 -1
- package/dist/test/node.d.ts +2 -2
- package/dist/test/node.js +1 -1
- package/dist/test/optional-runtime-types.js.d.ts +2 -2
- package/dist/test/optional-types.js.d.ts +2 -2
- package/dist/test/plugins/browser-client.js +1 -1
- package/dist/test/plugins/browser-context.js +1 -1
- package/dist/test/plugins/browser-locators.js +1 -1
- package/dist/test/plugins/browser-playwright.js +1 -1
- package/dist/test/plugins/browser-preview.js +1 -1
- package/dist/test/plugins/browser-webdriverio.js +1 -1
- package/dist/test/plugins/browser.js +1 -1
- package/dist/test/plugins/expect.js +1 -1
- package/dist/test/plugins/mocker-automock.js +1 -1
- package/dist/test/plugins/mocker-browser.js +1 -1
- package/dist/test/plugins/mocker-node.js +1 -1
- package/dist/test/plugins/mocker-redirect.js +1 -1
- package/dist/test/plugins/mocker-register.js +1 -1
- package/dist/test/plugins/mocker-transforms.js +1 -1
- package/dist/test/plugins/mocker.js +1 -1
- package/dist/test/plugins/pretty-format.js +1 -1
- package/dist/test/plugins/runner-types.js +1 -1
- package/dist/test/plugins/runner-utils.js +1 -1
- package/dist/test/plugins/runner.js +1 -1
- package/dist/test/plugins/snapshot-environment.js +1 -1
- package/dist/test/plugins/snapshot-manager.js +1 -1
- package/dist/test/plugins/snapshot.js +1 -1
- package/dist/test/plugins/spy.js +1 -1
- package/dist/test/plugins/utils-constants.js +1 -1
- package/dist/test/plugins/utils-diff.js +1 -1
- package/dist/test/plugins/utils-display.js +1 -1
- package/dist/test/plugins/utils-error.js +1 -1
- package/dist/test/plugins/utils-helpers.js +1 -1
- package/dist/test/plugins/utils-offset.js +1 -1
- package/dist/test/plugins/utils-resolver.js +1 -1
- package/dist/test/plugins/utils-serialize.js +1 -1
- package/dist/test/plugins/utils-source-map-node.js +1 -1
- package/dist/test/plugins/utils-source-map.js +1 -1
- package/dist/test/plugins/utils-timers.js +1 -1
- package/dist/test/plugins/utils.js +1 -1
- package/dist/test/reporters.d.ts +2 -2
- package/dist/test/reporters.js +1 -1
- package/dist/test/runners.d.ts +2 -2
- package/dist/test/runners.js +1 -1
- package/dist/test/runtime.d.ts +2 -2
- package/dist/test/runtime.js +1 -1
- package/dist/test/snapshot.d.ts +2 -2
- package/dist/test/snapshot.js +1 -1
- package/dist/test/suite.d.ts +2 -2
- package/dist/test/suite.js +1 -1
- package/dist/test/utils.js +1 -1
- package/dist/test/worker.d.ts +2 -2
- package/dist/test/worker.js +1 -1
- package/dist/{tsconfig-DlUVXT3J.js → tsconfig-CJ_StdFc.js} +605 -263
- package/dist/tsgolint-path-B-yOos8p.js +32 -0
- package/dist/tsgolint-path.d.ts +8 -0
- package/dist/tsgolint-path.js +2 -0
- package/dist/version.js +3 -3
- package/dist/versions.d.ts +1 -1
- package/dist/versions.js +7 -7
- package/dist/{workspace-DElv730L.js → workspace-Cjoc1c_A.js} +20 -18
- package/docs/_data/team.ts +5 -4
- package/docs/config/create.md +36 -1
- package/docs/config/index.md +7 -5
- package/docs/guide/commit-hooks.md +9 -0
- package/docs/guide/create.md +106 -2
- package/docs/guide/env.md +33 -5
- package/docs/guide/index.md +9 -3
- package/docs/guide/install.md +46 -10
- package/docs/guide/migrate.md +13 -3
- package/docs/guide/troubleshooting.md +3 -29
- package/docs/guide/upgrade.md +36 -6
- package/docs/package.json +3 -3
- package/docs/pnpm-lock.yaml +298 -395
- package/package.json +104 -56
- package/templates/generator/bin/index.ts +6 -3
- package/templates/generator/package.json +2 -3
- package/templates/generator/src/template.ts +0 -2
- package/templates/monorepo/package.json +1 -1
- package/dist/constants-DCBWlNrn.js +0 -33
- package/dist/define-config-BR1Y88zz.cjs +0 -84
- package/dist/define-config-BRC7qPNE.js +0 -21
- package/dist/define-config-COdn-tsn.d.ts +0 -177
- package/dist/dist-Bapm49IR.js +0 -3
- package/dist/test/plugins/utils-highlight.js +0 -1
- /package/dist/{chunk-DnnnRqeS.js → rolldown-runtime-DnnnRqeS.js} +0 -0
package/dist/migration/bin.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { r as __toESM } from "../
|
|
2
|
-
import {
|
|
3
|
-
import { A as
|
|
4
|
-
import { a as printHeader, i as muted, r as log$1, t as accent } from "../terminal-uTv0ZaMr.js";
|
|
1
|
+
import { r as __toESM } from "../rolldown-runtime-DnnnRqeS.js";
|
|
2
|
+
import { u as isForceOverrideMode } from "../constants-CrfJQIUX.js";
|
|
3
|
+
import { A as select, C as require_semver, D as log, P as R, S as PackageManager, T as confirm, c as cancelAndExit, d as promptGitHooks, g as upgradeYarn, h as selectPackageManager, i as hasBaseUrlInTsconfig, j as spinner, k as outro, l as defaultInteractive, m as runViteInstall, r as fixBaseUrlInTsconfig, t as confirmBaseUrlFix, u as downloadPackageManager } from "../tsconfig-CJ_StdFc.js";
|
|
4
|
+
import { a as printHeader, i as muted, r as log$1, s as warnMsg, t as accent } from "../terminal-uTv0ZaMr.js";
|
|
5
5
|
import { t as lib_default } from "../lib-L3DWSRQp.js";
|
|
6
|
-
import { a as readNearestPackageJson, i as hasVitePlusDependency } from "../package-
|
|
7
|
-
import { A as
|
|
8
|
-
import { n as addMigrationWarning, r as createMigrationReport } from "../report-
|
|
9
|
-
import {
|
|
6
|
+
import { a as readNearestPackageJson, i as hasVitePlusDependency } from "../package-BHirM1_v.js";
|
|
7
|
+
import { A as mergeViteConfigFiles, C as ensureVitePlusBootstrap, H as warnLegacyEslintConfig, L as rewriteMonorepo, M as migrateNodeVersionManagerFile, N as migratePrettierToOxfmt, O as injectLintTypeCheckDefaults, P as preflightGitHooksSetup, T as hasFrameworkShim, U as warnPackageLevelEslint, V as warnIncompatibleEslintIntegration, W as warnPackageLevelPrettier, _ as detectLegacyGitHooksMigrationCandidate, b as detectPrettierProject, d as checkVitestVersion, f as confirmEslintMigration, g as detectIncompatibleEslintIntegration, h as detectFramework, i as selectAgentTargetPaths, j as migrateEslintToOxlint, k as installGitHooks, l as addFrameworkShim, m as detectEslintProject, n as detectAgentConflicts, p as confirmPrettierMigration, q as displayRelative, r as detectExistingAgentTargetPaths, s as writeAgentInstructions, u as checkViteVersion, v as detectNodeVersionManagerFile, w as finalizeCoreMigrationForExistingVitePlus, x as detectVitePlusBootstrapPending, y as detectPendingCoreMigration, z as rewriteStandaloneProject } from "../agent-BD31CsvU.js";
|
|
8
|
+
import { n as addMigrationWarning, r as createMigrationReport } from "../report-BHSkWqRR.js";
|
|
9
|
+
import { a as detectEditorConflicts, l as writeEditorConfigs, s as selectEditor, t as detectWorkspace } from "../workspace-Cjoc1c_A.js";
|
|
10
10
|
import { t as renderCliDoc } from "../help-YP84FSEz.js";
|
|
11
11
|
import path from "node:path";
|
|
12
12
|
import { styleText } from "node:util";
|
|
@@ -22,7 +22,7 @@ async function confirmNodeVersionFileMigration(interactive, detection) {
|
|
|
22
22
|
message,
|
|
23
23
|
initialValue: true
|
|
24
24
|
});
|
|
25
|
-
if (
|
|
25
|
+
if (R(confirmed)) cancelAndExit();
|
|
26
26
|
return confirmed;
|
|
27
27
|
}
|
|
28
28
|
return true;
|
|
@@ -37,7 +37,7 @@ async function confirmFrameworkShim(framework, interactive) {
|
|
|
37
37
|
message: `Add TypeScript shim for ${name} component files (*.${framework})?\n ` + styleText("gray", `Lets TypeScript recognize .${framework} files until vp check fully supports them.`),
|
|
38
38
|
initialValue: true
|
|
39
39
|
});
|
|
40
|
-
if (
|
|
40
|
+
if (R(confirmed)) cancelAndExit();
|
|
41
41
|
return confirmed;
|
|
42
42
|
}
|
|
43
43
|
return true;
|
|
@@ -144,8 +144,9 @@ const helpMessage = renderCliDoc({
|
|
|
144
144
|
" After the migration:",
|
|
145
145
|
" - Confirm `vite` imports were rewritten to `vite-plus` where needed",
|
|
146
146
|
" - Confirm `vitest` imports were rewritten to `vite-plus/test` where needed",
|
|
147
|
-
" -
|
|
148
|
-
"
|
|
147
|
+
" - On pnpm, keep the `vite` / `vitest` entries that `vp migrate` aliased to",
|
|
148
|
+
" the Vite+ packages so the workspace override stays effective; with other",
|
|
149
|
+
" package managers you can remove them once those rewrites are confirmed",
|
|
149
150
|
" - Move remaining tool-specific config into the appropriate blocks in",
|
|
150
151
|
" `vite.config.ts`",
|
|
151
152
|
"",
|
|
@@ -196,16 +197,65 @@ function parseArgs() {
|
|
|
196
197
|
}
|
|
197
198
|
};
|
|
198
199
|
}
|
|
199
|
-
|
|
200
|
-
const
|
|
200
|
+
function getFrameworkShimCandidates(rootDir, packages) {
|
|
201
|
+
const allDetectedFrameworks = new Set(detectFramework(rootDir));
|
|
202
|
+
for (const pkg of packages ?? []) for (const framework of detectFramework(path.join(rootDir, pkg.path))) allDetectedFrameworks.add(framework);
|
|
203
|
+
return [...allDetectedFrameworks].filter((framework) => {
|
|
204
|
+
if (detectFramework(rootDir).includes(framework) && !hasFrameworkShim(rootDir, framework)) return true;
|
|
205
|
+
return (packages ?? []).some((pkg) => {
|
|
206
|
+
const pkgPath = path.join(rootDir, pkg.path);
|
|
207
|
+
return detectFramework(pkgPath).includes(framework) && !hasFrameworkShim(pkgPath, framework);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
async function collectFrameworkShimFrameworks(rootDir, options, packages) {
|
|
212
|
+
const frameworkShimFrameworks = [];
|
|
213
|
+
for (const framework of getFrameworkShimCandidates(rootDir, packages)) if (await confirmFrameworkShim(framework, options.interactive)) frameworkShimFrameworks.push(framework);
|
|
214
|
+
return frameworkShimFrameworks.length > 0 ? frameworkShimFrameworks : void 0;
|
|
215
|
+
}
|
|
216
|
+
function addFrameworkShimsForWorkspace(rootDir, frameworks, packages, report, updateMigrationProgress) {
|
|
217
|
+
if (!frameworks) return false;
|
|
218
|
+
let changed = false;
|
|
219
|
+
updateMigrationProgress("Adding TypeScript shim");
|
|
220
|
+
for (const framework of frameworks) {
|
|
221
|
+
if (detectFramework(rootDir).includes(framework) && !hasFrameworkShim(rootDir, framework)) {
|
|
222
|
+
addFrameworkShim(rootDir, framework, report);
|
|
223
|
+
changed = true;
|
|
224
|
+
}
|
|
225
|
+
for (const pkg of packages ?? []) {
|
|
226
|
+
const pkgPath = path.join(rootDir, pkg.path);
|
|
227
|
+
if (detectFramework(pkgPath).includes(framework) && !hasFrameworkShim(pkgPath, framework)) {
|
|
228
|
+
addFrameworkShim(pkgPath, framework, report);
|
|
229
|
+
changed = true;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return changed;
|
|
234
|
+
}
|
|
235
|
+
function hasEnabledOption(value) {
|
|
236
|
+
if (Array.isArray(value)) return value.some((item) => Boolean(item));
|
|
237
|
+
return value !== void 0 && value !== false && value !== "";
|
|
238
|
+
}
|
|
239
|
+
function hasExplicitExistingVitePlusSetupRequest(options) {
|
|
240
|
+
return options.hooks === true || hasEnabledOption(options.agent) || hasEnabledOption(options.editor);
|
|
241
|
+
}
|
|
242
|
+
function hasExistingVitePlusMigrationCandidates(workspaceInfo, options) {
|
|
243
|
+
const eslintProject = detectEslintProject(workspaceInfo.rootDir, workspaceInfo.packages);
|
|
244
|
+
const prettierProject = detectPrettierProject(workspaceInfo.rootDir, workspaceInfo.packages);
|
|
245
|
+
return hasExplicitExistingVitePlusSetupRequest(options) || detectLegacyGitHooksMigrationCandidate(workspaceInfo.rootDir) || hasBaseUrlInWorkspace(workspaceInfo) || eslintProject.hasDependency || prettierProject.hasDependency || detectNodeVersionManagerFile(workspaceInfo.rootDir) !== void 0 || getFrameworkShimCandidates(workspaceInfo.rootDir, workspaceInfo.packages).length > 0;
|
|
246
|
+
}
|
|
247
|
+
async function collectGitHooksDecision(rootDir, packageManager, options) {
|
|
201
248
|
let shouldSetupHooks = await promptGitHooks(options);
|
|
202
249
|
if (shouldSetupHooks) {
|
|
203
|
-
const reason = preflightGitHooksSetup(rootDir);
|
|
250
|
+
const reason = preflightGitHooksSetup(rootDir, packageManager);
|
|
204
251
|
if (reason) {
|
|
205
252
|
log.warn(`⚠ ${reason}`);
|
|
206
253
|
shouldSetupHooks = false;
|
|
207
254
|
}
|
|
208
255
|
}
|
|
256
|
+
return shouldSetupHooks;
|
|
257
|
+
}
|
|
258
|
+
async function collectAgentInstructionPlan(rootDir, options) {
|
|
209
259
|
const existingAgentTargetPaths = options.agent !== void 0 || !options.interactive ? void 0 : detectExistingAgentTargetPaths(rootDir);
|
|
210
260
|
const selectedAgentTargetPaths = existingAgentTargetPaths !== void 0 ? existingAgentTargetPaths : await selectAgentTargetPaths({
|
|
211
261
|
interactive: options.interactive,
|
|
@@ -231,9 +281,15 @@ async function collectMigrationPlan(rootDir, detectedPackageManager, options, pa
|
|
|
231
281
|
}],
|
|
232
282
|
initialValue: "skip"
|
|
233
283
|
});
|
|
234
|
-
if (
|
|
284
|
+
if (R(action)) cancelAndExit();
|
|
235
285
|
agentConflictDecisions.set(conflict.targetPath, action);
|
|
236
286
|
} else agentConflictDecisions.set(conflict.targetPath, "skip");
|
|
287
|
+
return {
|
|
288
|
+
selectedAgentTargetPaths,
|
|
289
|
+
agentConflictDecisions
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
async function collectEditorConfigPlan(rootDir, options) {
|
|
237
293
|
const selectedEditor = await selectEditor({
|
|
238
294
|
interactive: options.interactive,
|
|
239
295
|
editor: options.editor,
|
|
@@ -258,9 +314,15 @@ async function collectMigrationPlan(rootDir, detectedPackageManager, options, pa
|
|
|
258
314
|
}],
|
|
259
315
|
initialValue: "skip"
|
|
260
316
|
});
|
|
261
|
-
if (
|
|
317
|
+
if (R(action)) cancelAndExit();
|
|
262
318
|
editorConflictDecisions.set(conflict.fileName, action);
|
|
263
319
|
} else editorConflictDecisions.set(conflict.fileName, "merge");
|
|
320
|
+
return {
|
|
321
|
+
selectedEditor,
|
|
322
|
+
editorConflictDecisions
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
async function collectEslintMigrationDecision(rootDir, options, packages) {
|
|
264
326
|
const eslintProject = detectEslintProject(rootDir, packages);
|
|
265
327
|
const incompatibleEslintIntegration = detectIncompatibleEslintIntegration(rootDir, packages);
|
|
266
328
|
let migrateEslint = false;
|
|
@@ -268,6 +330,35 @@ async function collectMigrationPlan(rootDir, detectedPackageManager, options, pa
|
|
|
268
330
|
else if (eslintProject.hasDependency && !eslintProject.configFile && eslintProject.legacyConfigFile) warnLegacyEslintConfig(eslintProject.legacyConfigFile);
|
|
269
331
|
else if (eslintProject.hasDependency && eslintProject.configFile) migrateEslint = await confirmEslintMigration(options.interactive);
|
|
270
332
|
else if (eslintProject.hasDependency) warnPackageLevelEslint();
|
|
333
|
+
return {
|
|
334
|
+
migrateEslint,
|
|
335
|
+
eslintConfigFile: eslintProject.configFile
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
async function collectMigrationSetupPlan(rootDir, packageManager, options, packages, includeEslint = true) {
|
|
339
|
+
const shouldSetupHooks = await collectGitHooksDecision(rootDir, packageManager, options);
|
|
340
|
+
const agentPlan = await collectAgentInstructionPlan(rootDir, options);
|
|
341
|
+
const editorPlan = await collectEditorConfigPlan(rootDir, options);
|
|
342
|
+
const eslintPlan = includeEslint ? await collectEslintMigrationDecision(rootDir, options, packages) : { migrateEslint: false };
|
|
343
|
+
return {
|
|
344
|
+
shouldSetupHooks,
|
|
345
|
+
...agentPlan,
|
|
346
|
+
...editorPlan,
|
|
347
|
+
...eslintPlan
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function getExistingVitePlusSetupOptions(options, legacyGitHooksMigrationCandidate, useFullMigrationDefaults = false) {
|
|
351
|
+
if (useFullMigrationDefaults) return options;
|
|
352
|
+
return {
|
|
353
|
+
...options,
|
|
354
|
+
hooks: options.hooks ?? (legacyGitHooksMigrationCandidate ? options.interactive ? void 0 : true : false),
|
|
355
|
+
agent: options.agent ?? false,
|
|
356
|
+
editor: options.editor ?? false
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
async function collectMigrationPlan(rootDir, detectedPackageManager, options, packages) {
|
|
360
|
+
const packageManager = detectedPackageManager ?? await selectPackageManager(options.interactive, true);
|
|
361
|
+
const setupPlan = await collectMigrationSetupPlan(rootDir, packageManager, options, packages);
|
|
271
362
|
const prettierProject = detectPrettierProject(rootDir, packages);
|
|
272
363
|
let migratePrettier = false;
|
|
273
364
|
if (prettierProject.hasDependency && prettierProject.configFile) migratePrettier = await confirmPrettierMigration(options.interactive);
|
|
@@ -279,30 +370,16 @@ async function collectMigrationPlan(rootDir, detectedPackageManager, options, pa
|
|
|
279
370
|
const nodeVersionDetection = detectNodeVersionManagerFile(rootDir);
|
|
280
371
|
let migrateNodeVersionFile = false;
|
|
281
372
|
if (nodeVersionDetection) migrateNodeVersionFile = await confirmNodeVersionFileMigration(options.interactive, nodeVersionDetection);
|
|
282
|
-
const
|
|
283
|
-
for (const pkg of packages ?? []) for (const framework of detectFramework(path.join(rootDir, pkg.path))) allDetectedFrameworks.add(framework);
|
|
284
|
-
const frameworkShimFrameworks = [];
|
|
285
|
-
for (const framework of allDetectedFrameworks) if (detectFramework(rootDir).includes(framework) && !hasFrameworkShim(rootDir, framework) || (packages ?? []).some((pkg) => {
|
|
286
|
-
const pkgPath = path.join(rootDir, pkg.path);
|
|
287
|
-
return detectFramework(pkgPath).includes(framework) && !hasFrameworkShim(pkgPath, framework);
|
|
288
|
-
})) {
|
|
289
|
-
if (await confirmFrameworkShim(framework, options.interactive)) frameworkShimFrameworks.push(framework);
|
|
290
|
-
}
|
|
373
|
+
const frameworkShimFrameworks = await collectFrameworkShimFrameworks(rootDir, options, packages);
|
|
291
374
|
return {
|
|
292
375
|
packageManager,
|
|
293
|
-
|
|
294
|
-
selectedAgentTargetPaths,
|
|
295
|
-
agentConflictDecisions,
|
|
296
|
-
selectedEditor,
|
|
297
|
-
editorConflictDecisions,
|
|
298
|
-
migrateEslint,
|
|
299
|
-
eslintConfigFile: eslintProject.configFile,
|
|
376
|
+
...setupPlan,
|
|
300
377
|
migratePrettier,
|
|
301
378
|
prettierConfigFile: prettierProject.configFile,
|
|
302
379
|
fixBaseUrl,
|
|
303
380
|
migrateNodeVersionFile,
|
|
304
381
|
nodeVersionDetection,
|
|
305
|
-
frameworkShimFrameworks
|
|
382
|
+
frameworkShimFrameworks
|
|
306
383
|
};
|
|
307
384
|
}
|
|
308
385
|
function formatDuration(durationMs) {
|
|
@@ -311,13 +388,34 @@ function formatDuration(durationMs) {
|
|
|
311
388
|
if (durationSeconds < 10) return `${durationSeconds.toFixed(1)}s`;
|
|
312
389
|
return `${Math.round(durationSeconds)}s`;
|
|
313
390
|
}
|
|
391
|
+
/**
|
|
392
|
+
* Reconcile a CommandRunSummary from `runViteInstall` with the migration's
|
|
393
|
+
* duration counter and exit-code state. `runViteInstall` returns
|
|
394
|
+
* `{ status: 'failed', exitCode }` without throwing; treating that as a success
|
|
395
|
+
* (incrementing duration unconditionally) would let the migration claim
|
|
396
|
+
* "Dependencies installed" while node_modules is desynced from the just-mutated
|
|
397
|
+
* package.json. This helper centralizes the right handling: credit duration on
|
|
398
|
+
* success, warn + flip exitCode on failure, stay silent on skip.
|
|
399
|
+
*/
|
|
400
|
+
function handleInstallResult(installSummary, rootDir, report, options) {
|
|
401
|
+
if (installSummary.status === "installed") return installSummary.durationMs;
|
|
402
|
+
if (installSummary.status === "failed") {
|
|
403
|
+
const exitCode = installSummary.exitCode ?? 1;
|
|
404
|
+
const message = `Dependency installation failed (exit code ${exitCode}). Run \`vp install\` manually in ${rootDir} to resync node_modules.`;
|
|
405
|
+
warnMsg(message);
|
|
406
|
+
report.warnings.push(message);
|
|
407
|
+
if (options?.propagateExitCode !== false) process.exitCode = exitCode;
|
|
408
|
+
return 0;
|
|
409
|
+
}
|
|
410
|
+
return 0;
|
|
411
|
+
}
|
|
314
412
|
function showMigrationSummary(options) {
|
|
315
|
-
const { projectRoot, packageManager, packageManagerVersion, installDurationMs, report, updatedExistingVitePlus } = options;
|
|
413
|
+
const { projectRoot, packageManager, packageManagerVersion, installDurationMs, finalInstallOk, report, updatedExistingVitePlus } = options;
|
|
316
414
|
const projectLabel = displayRelative(projectRoot) || ".";
|
|
317
|
-
const configUpdates = report.createdViteConfigCount + report.mergedConfigCount + report.mergedStagedConfigCount + report.inlinedLintStagedConfigCount + report.removedConfigCount + report.tsdownImportCount;
|
|
415
|
+
const configUpdates = report.createdViteConfigCount + report.mergedConfigCount + report.mergedStagedConfigCount + report.inlinedLintStagedConfigCount + report.removedConfigCount + report.tsdownImportCount + report.wrappedPluginConfigCount;
|
|
318
416
|
log$1(`${styleText("magenta", "◇")} ${updatedExistingVitePlus ? "Updated" : "Migrated"} ${accent(projectLabel)}${updatedExistingVitePlus ? "" : " to Vite+"}`);
|
|
319
417
|
log$1(`${styleText("gray", "•")} Node ${process.versions.node} ${packageManager} ${packageManagerVersion}`);
|
|
320
|
-
if (installDurationMs > 0) log$1(`${styleText("green", "✓")} Dependencies installed in ${formatDuration(installDurationMs)}`);
|
|
418
|
+
if (finalInstallOk && installDurationMs > 0) log$1(`${styleText("green", "✓")} Dependencies installed in ${formatDuration(installDurationMs)}`);
|
|
321
419
|
if (configUpdates > 0 || report.rewrittenImportFileCount > 0) {
|
|
322
420
|
const parts = [];
|
|
323
421
|
if (configUpdates > 0) parts.push(`${configUpdates} ${configUpdates === 1 ? "config update" : "config updates"} applied`);
|
|
@@ -327,8 +425,10 @@ function showMigrationSummary(options) {
|
|
|
327
425
|
if (report.eslintMigrated) log$1(`${styleText("gray", "•")} ESLint rules migrated to Oxlint`);
|
|
328
426
|
if (report.prettierMigrated) log$1(`${styleText("gray", "•")} Prettier migrated to Oxfmt`);
|
|
329
427
|
if (report.nodeVersionFileMigrated) log$1(`${styleText("gray", "•")} Node version manager file migrated to .node-version`);
|
|
428
|
+
if (report.wrappedPluginConfigCount > 0) log$1(`${styleText("gray", "•")} Inline Vite plugins wrapped with lazyPlugins for check/lint/fmt`);
|
|
330
429
|
if (report.gitHooksConfigured) log$1(`${styleText("gray", "•")} Git hooks configured`);
|
|
331
430
|
if (report.frameworkShimAdded) log$1(`${styleText("gray", "•")} TypeScript shim added for framework component files`);
|
|
431
|
+
if (report.packageManagerBootstrapConfigured) log$1(`${styleText("gray", "•")} Package manager settings configured`);
|
|
332
432
|
if (report.warnings.length > 0) {
|
|
333
433
|
log$1(`${styleText("yellow", "!")} Warnings:`);
|
|
334
434
|
for (const warning of report.warnings) log$1(` - ${warning}`);
|
|
@@ -341,7 +441,7 @@ function showMigrationSummary(options) {
|
|
|
341
441
|
async function checkRolldownCompatibility(rootDir, report) {
|
|
342
442
|
try {
|
|
343
443
|
const { resolveConfig } = await import("../index.js");
|
|
344
|
-
const { checkManualChunksCompat } = await import("../compat-
|
|
444
|
+
const { checkManualChunksCompat } = await import("../compat-Cql3K40m.js");
|
|
345
445
|
checkManualChunksCompat((await resolveConfig({
|
|
346
446
|
root: rootDir,
|
|
347
447
|
logLevel: "silent",
|
|
@@ -349,6 +449,24 @@ async function checkRolldownCompatibility(rootDir, report) {
|
|
|
349
449
|
}, "build")).build?.rollupOptions?.output, report);
|
|
350
450
|
} catch {}
|
|
351
451
|
}
|
|
452
|
+
async function downloadSupportedPackageManager(options) {
|
|
453
|
+
const { rootDir, packageManager, packageManagerVersion, interactive, updateMigrationProgress, failMigrationProgress } = options;
|
|
454
|
+
updateMigrationProgress("Preparing migration");
|
|
455
|
+
const downloadResult = await downloadPackageManager(packageManager, packageManagerVersion, interactive, true);
|
|
456
|
+
if (packageManager === PackageManager.yarn && import_semver.default.satisfies(downloadResult.version, ">=4.0.0 <4.10.0")) {
|
|
457
|
+
updateMigrationProgress("Upgrading Yarn");
|
|
458
|
+
await upgradeYarn(rootDir, interactive, true);
|
|
459
|
+
} else if (packageManager === PackageManager.pnpm && import_semver.default.satisfies(downloadResult.version, "< 9.5.0")) {
|
|
460
|
+
failMigrationProgress("Migration failed");
|
|
461
|
+
log.error(`✘ pnpm@${downloadResult.version} is not supported by auto migration, please upgrade pnpm to >=9.5.0 first`);
|
|
462
|
+
cancelAndExit("Vite+ cannot automatically migrate this project yet.", 1);
|
|
463
|
+
} else if (packageManager === PackageManager.npm && import_semver.default.satisfies(downloadResult.version, "< 8.3.0")) {
|
|
464
|
+
failMigrationProgress("Migration failed");
|
|
465
|
+
log.error(`✘ npm@${downloadResult.version} is not supported by auto migration, please upgrade npm to >=8.3.0 first`);
|
|
466
|
+
cancelAndExit("Vite+ cannot automatically migrate this project yet.", 1);
|
|
467
|
+
}
|
|
468
|
+
return downloadResult;
|
|
469
|
+
}
|
|
352
470
|
async function executeMigrationPlan(workspaceInfoOptional, plan, interactive) {
|
|
353
471
|
const report = createMigrationReport();
|
|
354
472
|
const migrationProgress = interactive ? spinner({ indicator: "timer" }) : void 0;
|
|
@@ -374,25 +492,19 @@ async function executeMigrationPlan(workspaceInfoOptional, plan, interactive) {
|
|
|
374
492
|
migrationProgressStarted = false;
|
|
375
493
|
}
|
|
376
494
|
};
|
|
377
|
-
|
|
378
|
-
|
|
495
|
+
const downloadResult = await downloadSupportedPackageManager({
|
|
496
|
+
rootDir: workspaceInfoOptional.rootDir,
|
|
497
|
+
packageManager: plan.packageManager,
|
|
498
|
+
packageManagerVersion: workspaceInfoOptional.packageManagerVersion,
|
|
499
|
+
interactive,
|
|
500
|
+
updateMigrationProgress,
|
|
501
|
+
failMigrationProgress
|
|
502
|
+
});
|
|
379
503
|
const workspaceInfo = {
|
|
380
504
|
...workspaceInfoOptional,
|
|
381
505
|
packageManager: plan.packageManager,
|
|
382
506
|
downloadPackageManager: downloadResult
|
|
383
507
|
};
|
|
384
|
-
if (plan.packageManager === PackageManager.yarn && import_semver.default.satisfies(downloadResult.version, ">=4.0.0 <4.10.0")) {
|
|
385
|
-
updateMigrationProgress("Upgrading Yarn");
|
|
386
|
-
await upgradeYarn(workspaceInfo.rootDir, interactive, true);
|
|
387
|
-
} else if (plan.packageManager === PackageManager.pnpm && import_semver.default.satisfies(downloadResult.version, "< 9.5.0")) {
|
|
388
|
-
failMigrationProgress("Migration failed");
|
|
389
|
-
log.error(`✘ pnpm@${downloadResult.version} is not supported by auto migration, please upgrade pnpm to >=9.5.0 first`);
|
|
390
|
-
cancelAndExit("Vite+ cannot automatically migrate this project yet.", 1);
|
|
391
|
-
} else if (plan.packageManager === PackageManager.npm && import_semver.default.satisfies(downloadResult.version, "< 8.3.0")) {
|
|
392
|
-
failMigrationProgress("Migration failed");
|
|
393
|
-
log.error(`✘ npm@${downloadResult.version} is not supported by auto migration, please upgrade npm to >=8.3.0 first`);
|
|
394
|
-
cancelAndExit("Vite+ cannot automatically migrate this project yet.", 1);
|
|
395
|
-
}
|
|
396
508
|
if (plan.migrateNodeVersionFile && plan.nodeVersionDetection) {
|
|
397
509
|
updateMigrationProgress("Migrating node version file");
|
|
398
510
|
migrateNodeVersionManagerFile(workspaceInfo.rootDir, plan.nodeVersionDetection, report);
|
|
@@ -440,7 +552,7 @@ async function executeMigrationPlan(workspaceInfoOptional, plan, interactive) {
|
|
|
440
552
|
else rewriteStandaloneProject(workspaceInfo.rootDir, workspaceInfo, skipStagedMigration, true, report);
|
|
441
553
|
if (plan.shouldSetupHooks) {
|
|
442
554
|
updateMigrationProgress("Configuring git hooks");
|
|
443
|
-
installGitHooks(workspaceInfo.rootDir, true, report);
|
|
555
|
+
installGitHooks(workspaceInfo.rootDir, true, report, plan.packageManager);
|
|
444
556
|
}
|
|
445
557
|
updateMigrationProgress("Writing agent instructions");
|
|
446
558
|
await writeAgentInstructions({
|
|
@@ -458,17 +570,8 @@ async function executeMigrationPlan(workspaceInfoOptional, plan, interactive) {
|
|
|
458
570
|
conflictDecisions: plan.editorConflictDecisions,
|
|
459
571
|
silent: true
|
|
460
572
|
});
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
for (const framework of plan.frameworkShimFrameworks) {
|
|
464
|
-
if (detectFramework(workspaceInfo.rootDir).includes(framework) && !hasFrameworkShim(workspaceInfo.rootDir, framework)) addFrameworkShim(workspaceInfo.rootDir, framework, report);
|
|
465
|
-
for (const pkg of workspaceInfo.packages) {
|
|
466
|
-
const pkgPath = path.join(workspaceInfo.rootDir, pkg.path);
|
|
467
|
-
if (detectFramework(pkgPath).includes(framework) && !hasFrameworkShim(pkgPath, framework)) addFrameworkShim(pkgPath, framework, report);
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
const installArgs = plan.packageManager === PackageManager.npm || plan.packageManager === PackageManager.bun ? ["--force"] : void 0;
|
|
573
|
+
addFrameworkShimsForWorkspace(workspaceInfo.rootDir, plan.frameworkShimFrameworks, workspaceInfo.packages, report, updateMigrationProgress);
|
|
574
|
+
const installArgs = plan.packageManager === PackageManager.npm || plan.packageManager === PackageManager.bun ? ["--force"] : ["--no-frozen-lockfile"];
|
|
472
575
|
updateMigrationProgress("Installing dependencies");
|
|
473
576
|
const finalInstallSummary = await runViteInstall(workspaceInfo.rootDir, interactive, installArgs, {
|
|
474
577
|
silent: true,
|
|
@@ -477,7 +580,8 @@ async function executeMigrationPlan(workspaceInfoOptional, plan, interactive) {
|
|
|
477
580
|
});
|
|
478
581
|
clearMigrationProgress();
|
|
479
582
|
return {
|
|
480
|
-
installDurationMs: initialInstallSummary.
|
|
583
|
+
installDurationMs: handleInstallResult(initialInstallSummary, workspaceInfo.rootDir, report, { propagateExitCode: false }) + handleInstallResult(finalInstallSummary, workspaceInfo.rootDir, report),
|
|
584
|
+
finalInstallOk: finalInstallSummary.status === "installed",
|
|
481
585
|
packageManagerVersion: downloadResult.version,
|
|
482
586
|
report
|
|
483
587
|
};
|
|
@@ -492,10 +596,10 @@ async function main() {
|
|
|
492
596
|
printHeader();
|
|
493
597
|
const workspaceInfoOptional = await detectWorkspace(projectPath);
|
|
494
598
|
const resolvedPackageManager = workspaceInfoOptional.packageManager ?? "unknown";
|
|
495
|
-
|
|
496
|
-
if (hasVitePlusDependency(rootPkg) && !isForceOverrideMode()) {
|
|
599
|
+
if (hasVitePlusDependency(readNearestPackageJson(workspaceInfoOptional.rootDir)) && !isForceOverrideMode()) {
|
|
497
600
|
let didMigrate = false;
|
|
498
601
|
let installDurationMs = 0;
|
|
602
|
+
let finalInstallOk = true;
|
|
499
603
|
const report = createMigrationReport();
|
|
500
604
|
const migrationProgress = options.interactive ? spinner({ indicator: "timer" }) : void 0;
|
|
501
605
|
let migrationProgressStarted = false;
|
|
@@ -514,6 +618,60 @@ async function main() {
|
|
|
514
618
|
migrationProgressStarted = false;
|
|
515
619
|
}
|
|
516
620
|
};
|
|
621
|
+
const failMigrationProgress = (message) => {
|
|
622
|
+
if (migrationProgress && migrationProgressStarted) {
|
|
623
|
+
migrationProgress.error(message);
|
|
624
|
+
migrationProgressStarted = false;
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
const pendingCoreMigration = detectPendingCoreMigration(workspaceInfoOptional);
|
|
628
|
+
const legacyGitHooksMigrationCandidate = detectLegacyGitHooksMigrationCandidate(workspaceInfoOptional.rootDir);
|
|
629
|
+
const vitePlusBootstrapPending = detectVitePlusBootstrapPending(workspaceInfoOptional.rootDir, workspaceInfoOptional.packageManager);
|
|
630
|
+
let packageManager = vitePlusBootstrapPending ? workspaceInfoOptional.packageManager ?? await selectPackageManager(options.interactive, true) : workspaceInfoOptional.packageManager;
|
|
631
|
+
let downloadedPackageManager;
|
|
632
|
+
let packageManagerVersion = workspaceInfoOptional.packageManagerVersion;
|
|
633
|
+
const downloadExistingPackageManager = async () => {
|
|
634
|
+
if (!packageManager) return;
|
|
635
|
+
downloadedPackageManager ??= await downloadSupportedPackageManager({
|
|
636
|
+
rootDir: workspaceInfoOptional.rootDir,
|
|
637
|
+
packageManager,
|
|
638
|
+
packageManagerVersion,
|
|
639
|
+
interactive: options.interactive,
|
|
640
|
+
updateMigrationProgress,
|
|
641
|
+
failMigrationProgress
|
|
642
|
+
});
|
|
643
|
+
packageManagerVersion = downloadedPackageManager.version;
|
|
644
|
+
return downloadedPackageManager;
|
|
645
|
+
};
|
|
646
|
+
const ensureExistingPackageManager = async () => {
|
|
647
|
+
packageManager ??= await selectPackageManager(options.interactive, true);
|
|
648
|
+
return downloadExistingPackageManager();
|
|
649
|
+
};
|
|
650
|
+
if (vitePlusBootstrapPending) await ensureExistingPackageManager();
|
|
651
|
+
const coreMigrationResult = finalizeCoreMigrationForExistingVitePlus(workspaceInfoOptional, true, report, pendingCoreMigration);
|
|
652
|
+
if (coreMigrationResult.scripts || coreMigrationResult.tsconfigTypes || coreMigrationResult.imports) didMigrate = true;
|
|
653
|
+
if (!didMigrate && report.warnings.length === 0 && !vitePlusBootstrapPending && !hasExistingVitePlusMigrationCandidates(workspaceInfoOptional, options)) {
|
|
654
|
+
outro(`This project is already using Vite+! ${accent("Happy coding!")}`);
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
const fullMigrationSummary = vitePlusBootstrapPending || coreMigrationResult.scripts || coreMigrationResult.tsconfigTypes || coreMigrationResult.imports;
|
|
658
|
+
const setupOptions = getExistingVitePlusSetupOptions(options, legacyGitHooksMigrationCandidate, options.interactive && fullMigrationSummary);
|
|
659
|
+
const plan = await collectMigrationSetupPlan(workspaceInfoOptional.rootDir, packageManager, setupOptions, workspaceInfoOptional.packages);
|
|
660
|
+
const frameworkShimFrameworks = await collectFrameworkShimFrameworks(workspaceInfoOptional.rootDir, options, workspaceInfoOptional.packages);
|
|
661
|
+
let needsInstall = false;
|
|
662
|
+
if (vitePlusBootstrapPending) {
|
|
663
|
+
const downloadResult = await ensureExistingPackageManager();
|
|
664
|
+
if (downloadResult && packageManager) {
|
|
665
|
+
updateMigrationProgress("Configuring package manager");
|
|
666
|
+
const bootstrapResult = ensureVitePlusBootstrap({
|
|
667
|
+
...workspaceInfoOptional,
|
|
668
|
+
packageManager,
|
|
669
|
+
downloadPackageManager: downloadResult
|
|
670
|
+
}, report);
|
|
671
|
+
didMigrate = bootstrapResult.changed || didMigrate;
|
|
672
|
+
needsInstall = bootstrapResult.changed || needsInstall;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
517
675
|
const fixedBaseUrlProjectPaths = await fixBaseUrlForWorkspace(workspaceInfoOptional, hasBaseUrlInWorkspace(workspaceInfoOptional) ? await confirmBaseUrlFix(options.interactive) : false, updateMigrationProgress, report);
|
|
518
676
|
if (fixedBaseUrlProjectPaths.length > 0) {
|
|
519
677
|
updateMigrationProgress("Updating lint defaults");
|
|
@@ -521,32 +679,89 @@ async function main() {
|
|
|
521
679
|
didMigrate = true;
|
|
522
680
|
}
|
|
523
681
|
clearMigrationProgress();
|
|
524
|
-
|
|
525
|
-
|
|
682
|
+
let eslintMigrated = false;
|
|
683
|
+
if (plan.migrateEslint) {
|
|
684
|
+
await ensureExistingPackageManager();
|
|
685
|
+
updateMigrationProgress("Migrating ESLint");
|
|
686
|
+
if (!await migrateEslintToOxlint(workspaceInfoOptional.rootDir, options.interactive, plan.eslintConfigFile, workspaceInfoOptional.packages, {
|
|
687
|
+
silent: true,
|
|
688
|
+
report
|
|
689
|
+
})) {
|
|
690
|
+
clearMigrationProgress();
|
|
691
|
+
cancelAndExit("ESLint migration failed. Fix the issue and re-run `vp migrate`.", 1);
|
|
692
|
+
}
|
|
693
|
+
eslintMigrated = true;
|
|
694
|
+
}
|
|
695
|
+
const prettierProject = detectPrettierProject(workspaceInfoOptional.rootDir, workspaceInfoOptional.packages);
|
|
696
|
+
let prettierMigrated = false;
|
|
697
|
+
if (prettierProject.hasDependency && prettierProject.configFile) {
|
|
698
|
+
if (await confirmPrettierMigration(options.interactive)) {
|
|
699
|
+
await ensureExistingPackageManager();
|
|
700
|
+
updateMigrationProgress("Migrating Prettier");
|
|
701
|
+
if (!await migratePrettierToOxfmt(workspaceInfoOptional.rootDir, options.interactive, prettierProject.configFile, workspaceInfoOptional.packages, {
|
|
702
|
+
silent: true,
|
|
703
|
+
report
|
|
704
|
+
})) {
|
|
705
|
+
clearMigrationProgress();
|
|
706
|
+
cancelAndExit("Prettier migration failed. Fix the issue and re-run `vp migrate`.", 1);
|
|
707
|
+
}
|
|
708
|
+
prettierMigrated = true;
|
|
709
|
+
}
|
|
710
|
+
} else if (prettierProject.hasDependency) warnPackageLevelPrettier();
|
|
526
711
|
const nodeVersionDetection = detectNodeVersionManagerFile(workspaceInfoOptional.rootDir);
|
|
527
712
|
if (nodeVersionDetection) {
|
|
528
713
|
if (await confirmNodeVersionFileMigration(options.interactive, nodeVersionDetection) && migrateNodeVersionManagerFile(workspaceInfoOptional.rootDir, nodeVersionDetection, report)) didMigrate = true;
|
|
529
714
|
}
|
|
715
|
+
if (addFrameworkShimsForWorkspace(workspaceInfoOptional.rootDir, frameworkShimFrameworks, workspaceInfoOptional.packages, report, updateMigrationProgress)) didMigrate = true;
|
|
530
716
|
if (eslintMigrated || prettierMigrated) {
|
|
531
717
|
updateMigrationProgress("Rewriting configs");
|
|
532
718
|
mergeViteConfigFiles(workspaceInfoOptional.rootDir, true, report, workspaceInfoOptional.packages);
|
|
719
|
+
needsInstall = true;
|
|
720
|
+
didMigrate = true;
|
|
721
|
+
report.eslintMigrated = eslintMigrated;
|
|
722
|
+
report.prettierMigrated = prettierMigrated;
|
|
723
|
+
}
|
|
724
|
+
if (plan.shouldSetupHooks) {
|
|
725
|
+
await ensureExistingPackageManager();
|
|
726
|
+
updateMigrationProgress("Configuring git hooks");
|
|
727
|
+
if (installGitHooks(workspaceInfoOptional.rootDir, true, report, packageManager)) {
|
|
728
|
+
didMigrate = true;
|
|
729
|
+
needsInstall = true;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
if (needsInstall) {
|
|
733
|
+
const resolved = await ensureExistingPackageManager();
|
|
533
734
|
updateMigrationProgress("Installing dependencies");
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
const installSummary = await runViteInstall(workspaceInfoOptional.rootDir, options.interactive, void 0, {
|
|
735
|
+
const resolvedVersion = resolved?.version ?? packageManagerVersion;
|
|
736
|
+
const installSummary = await runViteInstall(workspaceInfoOptional.rootDir, options.interactive, packageManager === PackageManager.npm || packageManager === PackageManager.bun ? ["--force"] : ["--no-frozen-lockfile"], {
|
|
537
737
|
silent: true,
|
|
538
|
-
packageManager
|
|
738
|
+
packageManager,
|
|
539
739
|
packageManagerVersion: resolvedVersion
|
|
540
740
|
});
|
|
541
|
-
|
|
741
|
+
if (installSummary.status === "failed") clearMigrationProgress();
|
|
742
|
+
installDurationMs += handleInstallResult(installSummary, workspaceInfoOptional.rootDir, report);
|
|
743
|
+
}
|
|
744
|
+
if (plan.selectedAgentTargetPaths && plan.selectedAgentTargetPaths.length > 0) {
|
|
745
|
+
updateMigrationProgress("Writing agent instructions");
|
|
746
|
+
await writeAgentInstructions({
|
|
747
|
+
projectRoot: workspaceInfoOptional.rootDir,
|
|
748
|
+
targetPaths: plan.selectedAgentTargetPaths,
|
|
749
|
+
interactive: options.interactive,
|
|
750
|
+
conflictDecisions: plan.agentConflictDecisions,
|
|
751
|
+
silent: true
|
|
752
|
+
});
|
|
542
753
|
didMigrate = true;
|
|
543
|
-
report.eslintMigrated = eslintMigrated;
|
|
544
|
-
report.prettierMigrated = prettierMigrated;
|
|
545
754
|
}
|
|
546
|
-
if (
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
755
|
+
if (plan.selectedEditor) {
|
|
756
|
+
updateMigrationProgress("Writing editor configs");
|
|
757
|
+
await writeEditorConfigs({
|
|
758
|
+
projectRoot: workspaceInfoOptional.rootDir,
|
|
759
|
+
editorId: plan.selectedEditor,
|
|
760
|
+
interactive: options.interactive,
|
|
761
|
+
conflictDecisions: plan.editorConflictDecisions,
|
|
762
|
+
silent: true
|
|
763
|
+
});
|
|
764
|
+
didMigrate = true;
|
|
550
765
|
}
|
|
551
766
|
await checkRolldownCompatibility(workspaceInfoOptional.rootDir, report);
|
|
552
767
|
if (workspaceInfoOptional.packages) for (const pkg of workspaceInfoOptional.packages) await checkRolldownCompatibility(path.join(workspaceInfoOptional.rootDir, pkg.path), report);
|
|
@@ -554,13 +769,14 @@ async function main() {
|
|
|
554
769
|
clearMigrationProgress();
|
|
555
770
|
showMigrationSummary({
|
|
556
771
|
projectRoot: workspaceInfoOptional.rootDir,
|
|
557
|
-
packageManager: resolvedPackageManager,
|
|
558
|
-
packageManagerVersion
|
|
772
|
+
packageManager: packageManager ?? resolvedPackageManager,
|
|
773
|
+
packageManagerVersion,
|
|
559
774
|
installDurationMs,
|
|
775
|
+
finalInstallOk,
|
|
560
776
|
report,
|
|
561
|
-
updatedExistingVitePlus:
|
|
777
|
+
updatedExistingVitePlus: !fullMigrationSummary
|
|
562
778
|
});
|
|
563
|
-
} else outro(`This project is already using Vite+! ${accent(
|
|
779
|
+
} else outro(`This project is already using Vite+! ${accent("Happy coding!")}`);
|
|
564
780
|
return;
|
|
565
781
|
}
|
|
566
782
|
const plan = await collectMigrationPlan(workspaceInfoOptional.rootDir, workspaceInfoOptional.packageManager, options, workspaceInfoOptional.packages);
|
|
@@ -570,6 +786,7 @@ async function main() {
|
|
|
570
786
|
packageManager: plan.packageManager,
|
|
571
787
|
packageManagerVersion: result.packageManagerVersion,
|
|
572
788
|
installDurationMs: result.installDurationMs,
|
|
789
|
+
finalInstallOk: result.finalInstallOk,
|
|
573
790
|
report: result.report
|
|
574
791
|
});
|
|
575
792
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as VITE_PLUS_NAME } from "./constants-CrfJQIUX.js";
|
|
2
2
|
//#region src/oxlint-plugin-config.ts
|
|
3
3
|
const VITE_PLUS_OXLINT_PLUGIN_NAME = VITE_PLUS_NAME;
|
|
4
4
|
const VITE_PLUS_OXLINT_PLUGIN_SPECIFIER = `${VITE_PLUS_NAME}/oxlint-plugin`;
|
package/dist/oxlint-plugin.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import { n as VITE_PLUS_OXLINT_PLUGIN_NAME, t as PREFER_VITE_PLUS_IMPORTS_RULE_NAME } from "./oxlint-plugin-config-
|
|
1
|
+
import { n as VITE_PLUS_OXLINT_PLUGIN_NAME, t as PREFER_VITE_PLUS_IMPORTS_RULE_NAME } from "./oxlint-plugin-config-q8a5PFch.js";
|
|
2
2
|
import { definePlugin, defineRule } from "@oxlint/plugins";
|
|
3
3
|
//#region src/oxlint-plugin.ts
|
|
4
|
+
function isVitestFamilyDeclareModuleSpecifier(specifier) {
|
|
5
|
+
return specifier === "vitest" || specifier.startsWith("vitest/") || specifier === "@vitest/browser" || specifier.startsWith("@vitest/browser/") || specifier.startsWith("@vitest/browser-");
|
|
6
|
+
}
|
|
4
7
|
function rewriteVitePlusImportSpecifier(specifier) {
|
|
5
8
|
if (specifier === "vite") return "vite-plus";
|
|
6
9
|
if (specifier.startsWith("vite/")) return `vite-plus/${specifier.slice(5)}`;
|
|
7
10
|
if (specifier === "vitest/config") return "vite-plus";
|
|
8
11
|
if (specifier === "vitest") return "vite-plus/test";
|
|
12
|
+
if (specifier === "vitest/package.json") return null;
|
|
9
13
|
if (specifier.startsWith("vitest/")) return `vite-plus/test/${specifier.slice(7)}`;
|
|
10
14
|
if (specifier === "@vitest/browser") return "vite-plus/test/browser";
|
|
11
15
|
const browserSubpathRewrites = {
|
|
12
16
|
"@vitest/browser/context": "vite-plus/test/browser/context",
|
|
13
17
|
"@vitest/browser/client": "vite-plus/test/client",
|
|
14
|
-
"@vitest/browser/locators": "vite-plus/test/locators"
|
|
18
|
+
"@vitest/browser/locators": "vite-plus/test/locators",
|
|
19
|
+
"@vitest/browser/matchers": "vite-plus/test/matchers",
|
|
20
|
+
"@vitest/browser/utils": "vite-plus/test/utils"
|
|
15
21
|
};
|
|
16
22
|
if (specifier in browserSubpathRewrites) return browserSubpathRewrites[specifier];
|
|
17
23
|
for (const [prefix, provider] of [
|
|
@@ -78,7 +84,9 @@ const preferVitePlusImportsRule = defineRule({
|
|
|
78
84
|
},
|
|
79
85
|
TSModuleDeclaration(node) {
|
|
80
86
|
if (node.global) return;
|
|
81
|
-
|
|
87
|
+
const id = node.id;
|
|
88
|
+
if (id?.type === "Literal" && typeof id.value === "string" && isVitestFamilyDeclareModuleSpecifier(id.value)) return;
|
|
89
|
+
maybeReportLiteral(context, id);
|
|
82
90
|
}
|
|
83
91
|
};
|
|
84
92
|
}
|