vite-doctor 0.0.2 → 0.0.4
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/README.md +11 -1
- package/dist/cli.mjs +204 -3
- package/dist/{config-B96z9mkv.d.mts → config-BmPOr4h2.d.mts} +2 -1
- package/dist/config.d.mts +1 -1
- package/dist/{core-DXS10waH.mjs → core-xDy0T1J2.mjs} +706 -66
- package/dist/{doctor-D_fAijfx.mjs → doctor-Bg0UJqwf.mjs} +7 -7
- package/dist/{index-BZ2DY0NT.d.mts → index-Cej8hbDn.d.mts} +1 -1
- package/dist/{index-oT29pHXX.d.mts → index-DELTN2OW.d.mts} +20 -5
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{module-Cy-5RxgV.mjs → module-Bhfqw7wj.mjs} +24 -6
- package/dist/{module-D63348VO.d.mts → module-DpsQYVY7.d.mts} +2 -2
- package/dist/nitro-DP7qe6zn.mjs +2 -0
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.mjs +1 -1
- package/dist/{plugin-QYmdGYMa.mjs → plugin-B-mvNSii.mjs} +2 -2
- package/dist/{plugin-CWjUWdmC.d.mts → plugin-BMTLuRfv.d.mts} +2 -2
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.mjs +1 -1
- package/dist/{primitives-mLCLAmZ3.d.mts → primitives-UOE4-YE8.d.mts} +49 -1
- package/dist/rule-packs/nitro/index.d.mts +2 -2
- package/dist/rule-packs/nitro/index.mjs +3 -3
- package/dist/rule-packs/nitro/rules.d.mts +2 -2
- package/dist/rule-packs/nitro/rules.mjs +2 -2
- package/dist/rule-packs/nuxt/index.d.mts +2 -2
- package/dist/rule-packs/nuxt/index.mjs +1 -1
- package/dist/rule-packs/nuxt/module.d.mts +2 -2
- package/dist/rule-packs/nuxt/module.mjs +1 -1
- package/dist/rule-packs/nuxt/rules/index.d.mts +2 -2
- package/dist/rule-packs/nuxt/rules/index.mjs +2 -2
- package/dist/rule-packs/vite/index.d.mts +1 -1
- package/dist/rule-packs/vite/index.mjs +1 -1
- package/dist/rule-packs/vite/rules/index.d.mts +1 -1
- package/dist/rule-packs/vite/rules/index.mjs +1 -1
- package/dist/rule-packs/vue/index.d.mts +1 -1
- package/dist/rule-packs/vue/index.mjs +1 -1
- package/dist/rule-packs/vue/rules.d.mts +1 -1
- package/dist/rule-packs/vue/rules.mjs +1 -1
- package/dist/{rules-TJ8mVfH6.mjs → rules-BY3D2U9g.mjs} +1 -1
- package/dist/rules-D233rRrp.mjs +884 -0
- package/dist/{rules-BELxdqAV.d.mts → rules-D_ZBKNuF.d.mts} +1 -1
- package/dist/rules-DdChlCWs.mjs +2 -0
- package/dist/{rules-Wl3xtW3p.mjs → rules-drBDqot9.mjs} +94 -15
- package/dist/{rules-CpZKSMoL.mjs → rules-pUteKop1.mjs} +20 -10
- package/dist/rules.d.mts +1 -1
- package/dist/rules.mjs +2 -2
- package/package.json +4 -2
- package/dist/nitro-CFxa1y5r.mjs +0 -2
- package/dist/rules-8_T4dDGE.mjs +0 -2
- package/dist/rules-Ci1PkZG_.mjs +0 -529
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Run Vite Doctor from the project root:
|
|
|
22
22
|
pnpm dlx vite-doctor .
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
Vite Doctor reads app code, build config, project metadata, and server handlers to catch framework bugs before review. It
|
|
25
|
+
Vite Doctor reads app code, build config, project metadata, and server handlers to catch framework bugs before review. It resolves the installed Nuxt, Nitro, and H3 runtime graph and picks diagnostics that match the versions the framework actually loads.
|
|
26
26
|
|
|
27
27
|
Need a narrower Doctor Run? Select exact presets, one Rule, or a framework override:
|
|
28
28
|
|
|
@@ -41,6 +41,16 @@ pnpm nuxt doctor
|
|
|
41
41
|
|
|
42
42
|
Use `--framework` only when Doctor cannot identify the framework automatically.
|
|
43
43
|
|
|
44
|
+
Check a migration before changing dependencies:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pnpm dlx vite-doctor migrate .
|
|
48
|
+
pnpm dlx vite-doctor migrate . --to nuxt@5 --format json
|
|
49
|
+
pnpm dlx vite-doctor migrate . --to nitro@3
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The migration report stages source changes that are safe on the installed runtime, then dependency, configuration, and source changes that must land together, followed by checks that require the target runtime. It does not rewrite the project.
|
|
53
|
+
|
|
44
54
|
## Configuration
|
|
45
55
|
|
|
46
56
|
Standalone trusted config files can use the full Doctor config shape:
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as explainRule,
|
|
3
|
-
import { i as viteDoctorVersion, n as shouldFailDoctorRun, r as viteDoctorRulePacks, t as runViteDoctor } from "./doctor-
|
|
4
|
-
import { resolve } from "pathe";
|
|
2
|
+
import { c as cleanCache, i as explainRule, l as evaluateRuleApplicability, n as createReport, r as createRulesReport, u as detectProject } from "./core-xDy0T1J2.mjs";
|
|
3
|
+
import { i as viteDoctorVersion, n as shouldFailDoctorRun, r as viteDoctorRulePacks, t as runViteDoctor } from "./doctor-Bg0UJqwf.mjs";
|
|
4
|
+
import { relative, resolve } from "pathe";
|
|
5
5
|
import { realpathSync, statSync } from "node:fs";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { cac } from "cac";
|
|
@@ -88,10 +88,200 @@ function normalizeDoctorCommand(args, commands) {
|
|
|
88
88
|
return ["scan", ...args];
|
|
89
89
|
}
|
|
90
90
|
//#endregion
|
|
91
|
+
//#region src/migration.ts
|
|
92
|
+
async function createMigrationReport(root, requestedTargets = []) {
|
|
93
|
+
const current = await detectProject(root);
|
|
94
|
+
const targetSpec = requestedTargets.length ? parseExplicitTargets(requestedTargets) : inferTarget(current);
|
|
95
|
+
validateTargetFramework(current.framework, targetSpec.requested);
|
|
96
|
+
const targetProject = await detectProject(root, current.framework, targetSpec.runtime);
|
|
97
|
+
const packs = await viteDoctorRulePacks({
|
|
98
|
+
root,
|
|
99
|
+
framework: current.framework
|
|
100
|
+
});
|
|
101
|
+
const activated = [];
|
|
102
|
+
const retained = [];
|
|
103
|
+
const migrationRuleIds = [];
|
|
104
|
+
for (const rule of packs.flatMap((pack) => pack.rules)) {
|
|
105
|
+
const currentState = evaluateRuleApplicability(rule, current).state;
|
|
106
|
+
if (evaluateRuleApplicability(rule, targetProject).state !== "active") continue;
|
|
107
|
+
if (currentState === "active") retained.push(rule.meta.id);
|
|
108
|
+
else activated.push(rule.meta.id);
|
|
109
|
+
if (currentState !== "active" || rule.meta.category === "migration" || rule.meta.applicability) migrationRuleIds.push(rule.meta.id);
|
|
110
|
+
}
|
|
111
|
+
const diagnostics = (await runViteDoctor({
|
|
112
|
+
root,
|
|
113
|
+
framework: current.framework,
|
|
114
|
+
runtimeTarget: targetSpec.runtime,
|
|
115
|
+
rules: migrationRuleIds.length ? migrationRuleIds.join(",") : "__doctor_no_rules__",
|
|
116
|
+
cache: false
|
|
117
|
+
})).diagnostics.filter((item) => item.ruleId !== "doctor/inventory/unresolved-runtime").map((item) => migrationDiagnostic(root, item));
|
|
118
|
+
const activatedRules = new Set(activated);
|
|
119
|
+
const sourceDiagnostics = diagnostics.filter((item) => !activatedRules.has(item.ruleId));
|
|
120
|
+
const targetDiagnostics = diagnostics.filter((item) => activatedRules.has(item.ruleId));
|
|
121
|
+
const changes = dependencyChanges(current, targetSpec.requested, targetSpec.runtime);
|
|
122
|
+
return {
|
|
123
|
+
version: viteDoctorVersion,
|
|
124
|
+
reportVersion: 1,
|
|
125
|
+
command: "migrate",
|
|
126
|
+
root,
|
|
127
|
+
framework: current.framework,
|
|
128
|
+
target: targetSpec,
|
|
129
|
+
applicability: {
|
|
130
|
+
activated: activated.sort(),
|
|
131
|
+
retained: retained.sort()
|
|
132
|
+
},
|
|
133
|
+
stages: [
|
|
134
|
+
{
|
|
135
|
+
id: "source",
|
|
136
|
+
title: "Safe source changes before the dependency upgrade",
|
|
137
|
+
diagnostics: sourceDiagnostics
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
id: "dependencies",
|
|
141
|
+
title: "Dependency, configuration, and coupled source changes",
|
|
142
|
+
diagnostics: targetDiagnostics,
|
|
143
|
+
changes
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
id: "deferred",
|
|
147
|
+
title: "Checks after the target runtime is installed",
|
|
148
|
+
checks: [
|
|
149
|
+
{
|
|
150
|
+
id: "install-target",
|
|
151
|
+
instruction: "Install the target dependency graph with the project package manager."
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: "rerun-doctor",
|
|
155
|
+
instruction: "Run vite-doctor again without migrate so Doctor verifies the runtime versions that were actually installed."
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
id: "run-project-checks",
|
|
159
|
+
instruction: "Run the project's type checks, tests, and production build on the installed target."
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
],
|
|
164
|
+
summary: {
|
|
165
|
+
diagnostics: diagnostics.length,
|
|
166
|
+
errors: diagnostics.filter((item) => item.severity === "blocker" || item.severity === "error").length,
|
|
167
|
+
warnings: diagnostics.filter((item) => item.severity === "warn").length,
|
|
168
|
+
dependencyChanges: changes.length
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function formatMigrationReport(report, format = "text") {
|
|
173
|
+
if (format === "json") return `${JSON.stringify(report, null, 2)}\n`;
|
|
174
|
+
const lines = [
|
|
175
|
+
`Migration target: ${report.target.requested.join(", ")} (${report.target.source})`,
|
|
176
|
+
`Workspace: ${report.root}`,
|
|
177
|
+
""
|
|
178
|
+
];
|
|
179
|
+
for (const stage of report.stages) {
|
|
180
|
+
lines.push(stage.title);
|
|
181
|
+
if (stage.id === "source") {
|
|
182
|
+
if (!stage.diagnostics.length) lines.push(" No source changes detected.");
|
|
183
|
+
for (const diagnostic of stage.diagnostics) {
|
|
184
|
+
const location = diagnostic.range ? `${diagnostic.file}:${diagnostic.range.line}:${diagnostic.range.column}` : diagnostic.file;
|
|
185
|
+
lines.push(` ${diagnostic.code} ${location}`);
|
|
186
|
+
lines.push(` ${diagnostic.why}`);
|
|
187
|
+
lines.push(` Fix: ${diagnostic.fix}`);
|
|
188
|
+
}
|
|
189
|
+
} else if (stage.id === "dependencies") {
|
|
190
|
+
if (!stage.changes.length && !stage.diagnostics.length) lines.push(" No dependency, config, or coupled source changes inferred.");
|
|
191
|
+
for (const change of stage.changes) lines.push(` ${change.instruction}`);
|
|
192
|
+
for (const diagnostic of stage.diagnostics) {
|
|
193
|
+
const location = diagnostic.range ? `${diagnostic.file}:${diagnostic.range.line}:${diagnostic.range.column}` : diagnostic.file;
|
|
194
|
+
lines.push(` ${diagnostic.code} ${location}`);
|
|
195
|
+
lines.push(` ${diagnostic.why}`);
|
|
196
|
+
lines.push(` Fix with the target upgrade: ${diagnostic.fix}`);
|
|
197
|
+
}
|
|
198
|
+
} else for (const check of stage.checks) lines.push(` ${check.instruction}`);
|
|
199
|
+
lines.push("");
|
|
200
|
+
}
|
|
201
|
+
lines.push(`Summary: ${report.summary.diagnostics} diagnostics, ${report.summary.dependencyChanges} dependency/config changes`);
|
|
202
|
+
return `${lines.join("\n")}\n`;
|
|
203
|
+
}
|
|
204
|
+
function inferTarget(project) {
|
|
205
|
+
const nuxt = project.runtimeGraph?.packages.nuxt;
|
|
206
|
+
const nitro = project.runtimeGraph?.packages.nitro;
|
|
207
|
+
if (project.framework === "nuxt" && nuxt?.state === "resolved" && major(nuxt.version) < 5) return targetFromRequested(["nuxt@5"], "inferred");
|
|
208
|
+
if ((project.framework === "nuxt" || project.framework === "nitro") && nitro?.state === "resolved" && major(nitro.version) < 3) return targetFromRequested(["nitro@3"], "inferred");
|
|
209
|
+
throw new Error("Doctor cannot infer one supported next runtime target from the installed graph. Pass --to nuxt@5 or --to nitro@3.");
|
|
210
|
+
}
|
|
211
|
+
function parseExplicitTargets(targets) {
|
|
212
|
+
return targetFromRequested(targets.flatMap((target) => target.split(",")).map((target) => target.trim()).filter(Boolean), "explicit");
|
|
213
|
+
}
|
|
214
|
+
function validateTargetFramework(framework, targets) {
|
|
215
|
+
for (const target of targets) if (!(target === "nuxt@5" ? framework === "nuxt" : target === "nitro@3" && (framework === "nuxt" || framework === "nitro"))) throw new Error(`Migration target ${target} is not supported for ${framework} projects.`);
|
|
216
|
+
}
|
|
217
|
+
function targetFromRequested(requested, source) {
|
|
218
|
+
const runtime = {};
|
|
219
|
+
for (const target of requested) {
|
|
220
|
+
if (target === "nuxt@5") {
|
|
221
|
+
runtime.nuxt = "5.0.0-0";
|
|
222
|
+
runtime.nitro = "3.0.0-0";
|
|
223
|
+
runtime.h3 = "2.0.0-0";
|
|
224
|
+
runtime.nuxtCompatibility = 5;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (target === "nitro@3") {
|
|
228
|
+
runtime.nitro = "3.0.0-0";
|
|
229
|
+
runtime.h3 = "2.0.0-0";
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
throw new Error(`Unsupported migration target "${target}". Use nuxt@5 or nitro@3.`);
|
|
233
|
+
}
|
|
234
|
+
if (!requested.length) throw new Error("Migration requires at least one target.");
|
|
235
|
+
return {
|
|
236
|
+
source,
|
|
237
|
+
requested,
|
|
238
|
+
runtime
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function dependencyChanges(project, requested, runtime) {
|
|
242
|
+
const changes = [];
|
|
243
|
+
for (const target of requested) {
|
|
244
|
+
const [runtimeName, targetMajor] = target.split("@");
|
|
245
|
+
const current = project.runtimeGraph?.packages[runtimeName];
|
|
246
|
+
const packageName = runtimeName === "nitro" && current?.name === "nitropack" ? "nitro" : runtimeName;
|
|
247
|
+
changes.push({
|
|
248
|
+
kind: "dependency",
|
|
249
|
+
package: packageName,
|
|
250
|
+
from: current?.version,
|
|
251
|
+
to: `${packageName}@${targetMajor}`,
|
|
252
|
+
instruction: `Update ${current?.name ?? packageName}${current?.version ? ` from ${current.version}` : ""} to ${packageName}@${targetMajor}.`
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
if (runtime.nuxtCompatibility === 5 && project.nuxtCompatibility?.version !== 5) {
|
|
256
|
+
const unknownCompatibility = project.nuxtCompatibility?.state === "unknown";
|
|
257
|
+
changes.push({
|
|
258
|
+
kind: "config",
|
|
259
|
+
to: "future.compatibilityVersion: 5",
|
|
260
|
+
instruction: unknownCompatibility ? "Verify that the effective future.compatibilityVersion resolves to 5; Doctor could not prove it from the composed Nuxt config." : "Set future.compatibilityVersion to 5 while preparing the Nuxt upgrade, then resolve the reported compatibility diagnostics."
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
return changes;
|
|
264
|
+
}
|
|
265
|
+
function migrationDiagnostic(root, diagnostic) {
|
|
266
|
+
return {
|
|
267
|
+
code: diagnostic.code,
|
|
268
|
+
ruleId: diagnostic.ruleId,
|
|
269
|
+
severity: diagnostic.severity,
|
|
270
|
+
file: relative(root, diagnostic.file),
|
|
271
|
+
range: diagnostic.range,
|
|
272
|
+
why: diagnostic.why,
|
|
273
|
+
fix: diagnostic.suggestion ?? diagnostic.diagnostic.fix ?? "Review this migration diagnostic."
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function major(version) {
|
|
277
|
+
return Number(version?.split(".")[0] ?? NaN);
|
|
278
|
+
}
|
|
279
|
+
//#endregion
|
|
91
280
|
//#region src/cli-main.ts
|
|
92
281
|
const commands = new Set([
|
|
93
282
|
"scan",
|
|
94
283
|
"check",
|
|
284
|
+
"migrate",
|
|
95
285
|
"rules",
|
|
96
286
|
"explain",
|
|
97
287
|
"cache"
|
|
@@ -110,6 +300,17 @@ async function main(args = process.argv.slice(2), cwd = process.cwd()) {
|
|
|
110
300
|
const cli = cac("vite-doctor");
|
|
111
301
|
addScanCommand(cli, "scan", cwd, (code) => exitCode = code);
|
|
112
302
|
addScanCommand(cli, "check", cwd, (code) => exitCode = code);
|
|
303
|
+
cli.command("migrate [path]", "Evaluate current source against a future runtime graph.").option("--to <target>", "Explicit target such as nuxt@5 or nitro@3.").option("--format <format>", "Machine output: json.").action(async (path = ".", options) => {
|
|
304
|
+
const root = resolve(cwd, path);
|
|
305
|
+
if (!statSync(root, { throwIfNoEntry: false })?.isDirectory()) {
|
|
306
|
+
errorHuman(`No readable directory found at ${root}`);
|
|
307
|
+
exitCode = 1;
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const report = await createMigrationReport(root, options.to ? [options.to] : []);
|
|
311
|
+
process.stdout.write(formatMigrationReport(report, options.format));
|
|
312
|
+
exitCode = report.summary.errors > 0 ? 1 : 0;
|
|
313
|
+
});
|
|
113
314
|
cli.command("rules", "List available Doctor rules.").option("--format <format>", "Machine output: json or sarif.").option("--framework <framework>", "Framework override.").action(async (options) => {
|
|
114
315
|
const runOptions = { root: cwd };
|
|
115
316
|
applyDoctorOptions(runOptions, options);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as DoctorSerializableConfig, n as DoctorFramework, t as DoctorExtension } from "./primitives-
|
|
1
|
+
import { i as DoctorSerializableConfig, n as DoctorFramework, s as RuntimeTarget, t as DoctorExtension } from "./primitives-UOE4-YE8.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/core/config.d.ts
|
|
4
4
|
interface DoctorConfig extends DoctorSerializableConfig {
|
|
@@ -33,6 +33,7 @@ interface DoctorRunOptions {
|
|
|
33
33
|
scoreOnly?: boolean;
|
|
34
34
|
maxWarnings?: number;
|
|
35
35
|
extensions?: DoctorExtension[];
|
|
36
|
+
runtimeTarget?: RuntimeTarget;
|
|
36
37
|
}
|
|
37
38
|
declare function defineDoctorConfig(config: DoctorConfig): DoctorConfig;
|
|
38
39
|
interface LoadDoctorConfigOptions {
|
package/dist/config.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as loadDoctorConfig, i as defineDoctorConfig, n as DoctorRunOptions, r as LoadDoctorConfigOptions, t as DoctorConfig } from "./config-
|
|
1
|
+
import { a as loadDoctorConfig, i as defineDoctorConfig, n as DoctorRunOptions, r as LoadDoctorConfigOptions, t as DoctorConfig } from "./config-BmPOr4h2.mjs";
|
|
2
2
|
export { type DoctorConfig, type DoctorRunOptions, type LoadDoctorConfigOptions, defineDoctorConfig, loadDoctorConfig };
|