vite-doctor 0.0.3 → 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.
Files changed (49) hide show
  1. package/README.md +11 -1
  2. package/dist/cli.mjs +204 -3
  3. package/dist/{config-B96z9mkv.d.mts → config-BmPOr4h2.d.mts} +2 -1
  4. package/dist/config.d.mts +1 -1
  5. package/dist/{core-WTY_jAiL.mjs → core-xDy0T1J2.mjs} +503 -47
  6. package/dist/{doctor-DfkqNcNR.mjs → doctor-Bg0UJqwf.mjs} +7 -7
  7. package/dist/{index-BZ2DY0NT.d.mts → index-Cej8hbDn.d.mts} +1 -1
  8. package/dist/{index-CFlFH8Pi.d.mts → index-DELTN2OW.d.mts} +17 -5
  9. package/dist/index.d.mts +2 -2
  10. package/dist/index.mjs +1 -1
  11. package/dist/{module-Cy-5RxgV.mjs → module-Bhfqw7wj.mjs} +24 -6
  12. package/dist/{module-D63348VO.d.mts → module-DpsQYVY7.d.mts} +2 -2
  13. package/dist/nitro-DP7qe6zn.mjs +2 -0
  14. package/dist/nuxt.d.mts +1 -1
  15. package/dist/nuxt.mjs +1 -1
  16. package/dist/{plugin-7rCuA-AZ.mjs → plugin-B-mvNSii.mjs} +2 -2
  17. package/dist/{plugin-CWjUWdmC.d.mts → plugin-BMTLuRfv.d.mts} +2 -2
  18. package/dist/plugin.d.mts +1 -1
  19. package/dist/plugin.mjs +1 -1
  20. package/dist/{primitives-mLCLAmZ3.d.mts → primitives-UOE4-YE8.d.mts} +49 -1
  21. package/dist/rule-packs/nitro/index.d.mts +2 -2
  22. package/dist/rule-packs/nitro/index.mjs +3 -3
  23. package/dist/rule-packs/nitro/rules.d.mts +2 -2
  24. package/dist/rule-packs/nitro/rules.mjs +2 -2
  25. package/dist/rule-packs/nuxt/index.d.mts +2 -2
  26. package/dist/rule-packs/nuxt/index.mjs +1 -1
  27. package/dist/rule-packs/nuxt/module.d.mts +2 -2
  28. package/dist/rule-packs/nuxt/module.mjs +1 -1
  29. package/dist/rule-packs/nuxt/rules/index.d.mts +2 -2
  30. package/dist/rule-packs/nuxt/rules/index.mjs +2 -2
  31. package/dist/rule-packs/vite/index.d.mts +1 -1
  32. package/dist/rule-packs/vite/index.mjs +1 -1
  33. package/dist/rule-packs/vite/rules/index.d.mts +1 -1
  34. package/dist/rule-packs/vite/rules/index.mjs +1 -1
  35. package/dist/rule-packs/vue/index.d.mts +1 -1
  36. package/dist/rule-packs/vue/index.mjs +1 -1
  37. package/dist/rule-packs/vue/rules.d.mts +1 -1
  38. package/dist/rule-packs/vue/rules.mjs +1 -1
  39. package/dist/{rules-cyFhFs4w.mjs → rules-BY3D2U9g.mjs} +1 -1
  40. package/dist/{rules-BDMsIiOi.mjs → rules-D233rRrp.mjs} +207 -43
  41. package/dist/{rules-BELxdqAV.d.mts → rules-D_ZBKNuF.d.mts} +1 -1
  42. package/dist/rules-DdChlCWs.mjs +2 -0
  43. package/dist/{rules-M6yUv7EP.mjs → rules-drBDqot9.mjs} +80 -6
  44. package/dist/{rules-DBiaAWeX.mjs → rules-pUteKop1.mjs} +1 -1
  45. package/dist/rules.d.mts +1 -1
  46. package/dist/rules.mjs +2 -2
  47. package/package.json +3 -1
  48. package/dist/nitro-D2XxIgEp.mjs +0 -2
  49. package/dist/rules-BGjZej-N.mjs +0 -2
@@ -1,4 +1,5 @@
1
1
  import "./config-Dnzvhp-h.mjs";
2
+ import { createRequire } from "node:module";
2
3
  import { dirname, join, relative, resolve } from "pathe";
3
4
  import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
4
5
  import { createHash } from "node:crypto";
@@ -6,6 +7,7 @@ import * as oxcParser from "oxc-parser";
6
7
  import { parseSync } from "oxc-parser";
7
8
  import { defineDiagnostics, formatDiagnostic } from "nostics";
8
9
  import { glob } from "node:fs/promises";
10
+ import { satisfies, valid, validRange } from "semver";
9
11
  import { execFile } from "node:child_process";
10
12
  import { matchesGlob } from "node:path";
11
13
  import MagicString from "magic-string";
@@ -162,6 +164,10 @@ const doctorInternalDiagnostics = defineDiagnostics({ codes: {
162
164
  DOC0021: {
163
165
  why: (params) => params.code ? `Diagnostic "${params.code}" for rule "${params.ruleId}" is missing a fix.` : `Rule "${params.ruleId}" reported a diagnostic without a fix.`,
164
166
  fix: "Provide actionable nostics fix text for every Doctor diagnostic."
167
+ },
168
+ DOC0022: {
169
+ why: (params) => `Doctor could not resolve the governing runtime graph: ${params.details}`,
170
+ fix: "Install project dependencies and run Doctor from the target project package. For computed Nuxt config, make future.compatibilityVersion statically provable or run pnpm nuxt doctor so the Nuxt integration can record the resolved value."
165
171
  }
166
172
  } });
167
173
  //#endregion
@@ -212,8 +218,346 @@ function normalizeNuxtModuleSources(sources) {
212
218
  }));
213
219
  }
214
220
  //#endregion
221
+ //#region src/core/internal/runtime-graph.ts
222
+ const packageCandidates = {
223
+ nuxt: ["nuxt"],
224
+ nitro: ["nitro", "nitropack"],
225
+ h3: ["h3"],
226
+ vue: ["vue"]
227
+ };
228
+ const acceptedIdentities = {
229
+ nuxt: new Set(["nuxt", "nuxt-nightly"]),
230
+ nitro: new Set([
231
+ "nitro",
232
+ "nitropack",
233
+ "nitro-nightly"
234
+ ]),
235
+ h3: new Set(["h3", "h3-nightly"]),
236
+ vue: new Set(["vue"])
237
+ };
238
+ function resolveRuntimeGraph(root, framework) {
239
+ const rootManifest = join(root, "package.json");
240
+ const packages = {};
241
+ const edges = [];
242
+ if (framework === "nuxt") {
243
+ packages.nuxt = resolveRuntimePackage("nuxt", rootManifest, "project");
244
+ edges.push(edge("project", packages.nuxt));
245
+ packages.nitro = packages.nuxt.state === "resolved" && packages.nuxt.packageJsonPath ? resolveRuntimePackage("nitro", packages.nuxt.packageJsonPath, "nuxt") : blockedRuntime("nitro", "nuxt", packages.nuxt);
246
+ edges.push(edge("nuxt", packages.nitro));
247
+ packages.h3 = packages.nitro.state === "resolved" && packages.nitro.packageJsonPath ? resolveRuntimePackage("h3", packages.nitro.packageJsonPath, "nitro") : blockedRuntime("h3", "nitro", packages.nitro);
248
+ edges.push(edge("nitro", packages.h3));
249
+ packages.vue = resolveRuntimePackage("vue", rootManifest, "project");
250
+ edges.push(edge("project", packages.vue));
251
+ } else if (framework === "nitro") {
252
+ packages.nitro = resolveRuntimePackage("nitro", rootManifest, "project");
253
+ edges.push(edge("project", packages.nitro));
254
+ packages.h3 = packages.nitro.state === "resolved" && packages.nitro.packageJsonPath ? resolveRuntimePackage("h3", packages.nitro.packageJsonPath, "nitro") : blockedRuntime("h3", "nitro", packages.nitro);
255
+ edges.push(edge("nitro", packages.h3));
256
+ } else if (framework === "vue") {
257
+ packages.vue = resolveRuntimePackage("vue", rootManifest, "project");
258
+ edges.push(edge("project", packages.vue));
259
+ }
260
+ return {
261
+ packages,
262
+ edges
263
+ };
264
+ }
265
+ function resolveNuxtCompatibility(root, graph, manifest) {
266
+ if (!graph.packages.nuxt) return void 0;
267
+ const config = readNuxtConfig(root);
268
+ const manifestGeneratedAt = manifest?.generatedAt ? Date.parse(manifest.generatedAt) : NaN;
269
+ const configModifiedAt = config ? configModifiedTime(config.file) : void 0;
270
+ const manifestMatchesConfig = configModifiedAt === void 0 || (Number.isFinite(manifest?.nuxtConfigMtimeMs) ? manifest?.nuxtConfigMtimeMs === configModifiedAt : manifestGeneratedAt >= configModifiedAt);
271
+ if (Number.isFinite(manifestGeneratedAt) && isSupportedNuxtCompatibility(manifest?.compatibilityVersion) && manifestMatchesConfig) return {
272
+ state: "resolved",
273
+ version: manifest.compatibilityVersion,
274
+ provenance: "manifest"
275
+ };
276
+ if (config) {
277
+ const configured = readExportedCompatibilityVersion(config.file, config.text);
278
+ if (configured.state === "resolved") return {
279
+ state: "resolved",
280
+ version: configured.version,
281
+ provenance: "config",
282
+ file: config.file
283
+ };
284
+ if (configured.state === "unknown") return {
285
+ state: "unknown",
286
+ provenance: "config",
287
+ reason: configured.reason,
288
+ file: config.file
289
+ };
290
+ }
291
+ const nuxt = graph.packages.nuxt;
292
+ if (nuxt.state !== "resolved" || !nuxt.version) return {
293
+ state: "unknown",
294
+ provenance: "default",
295
+ reason: "Nuxt compatibility defaults require a resolved Nuxt version."
296
+ };
297
+ return {
298
+ state: "resolved",
299
+ version: Number(nuxt.version.split(".")[0]) >= 5 ? 5 : 4,
300
+ provenance: "default"
301
+ };
302
+ }
303
+ function isSupportedNuxtCompatibility(value) {
304
+ return value === 4 || value === 5;
305
+ }
306
+ function applyRuntimeTarget(graph, compatibility, target) {
307
+ if (!target) return {
308
+ graph,
309
+ compatibility
310
+ };
311
+ const packages = { ...graph.packages };
312
+ for (const runtime of [
313
+ "nuxt",
314
+ "nitro",
315
+ "h3",
316
+ "vue"
317
+ ]) {
318
+ const version = target[runtime];
319
+ if (!version) continue;
320
+ packages[runtime] = {
321
+ runtime,
322
+ state: "resolved",
323
+ requestedName: runtime,
324
+ name: runtime,
325
+ version,
326
+ owner: packages[runtime]?.owner ?? targetOwner(runtime),
327
+ provenance: "target",
328
+ identity: "exact"
329
+ };
330
+ }
331
+ return {
332
+ graph: {
333
+ packages,
334
+ edges: graph.edges.map((item) => ({
335
+ ...item,
336
+ state: packages[item.to]?.state ?? item.state
337
+ }))
338
+ },
339
+ compatibility: target.nuxtCompatibility === void 0 ? compatibility : {
340
+ state: "resolved",
341
+ version: target.nuxtCompatibility,
342
+ provenance: "target"
343
+ }
344
+ };
345
+ }
346
+ function resolveRuntimePackage(runtime, ownerManifest, owner) {
347
+ const ownerPackage = readPackageManifest(ownerManifest);
348
+ const require = createRequire(ownerManifest);
349
+ let lastReason = `No ${runtime} package is resolvable from ${ownerManifest}.`;
350
+ const declaredCandidates = packageCandidates[runtime].filter((name) => packageDeclaration(ownerPackage, name) !== void 0);
351
+ const candidates = declaredCandidates.length ? declaredCandidates : packageCandidates[runtime];
352
+ for (const requestedName of candidates) {
353
+ const declaration = packageDeclaration(ownerPackage, requestedName);
354
+ try {
355
+ const packageJsonPath = resolvePackageJson(require, requestedName);
356
+ const manifest = readPackageManifest(packageJsonPath);
357
+ const name = typeof manifest?.name === "string" ? manifest.name : void 0;
358
+ const version = typeof manifest?.version === "string" ? manifest.version : void 0;
359
+ const identity = packageIdentity(runtime, requestedName, name);
360
+ if (!name || !version || !valid(version)) return unknownRuntime(runtime, requestedName, owner, declaration, {
361
+ name,
362
+ version,
363
+ packageJsonPath,
364
+ reason: `Resolved ${requestedName} has no valid package name and exact semver version.`
365
+ });
366
+ if (identity === "unknown") return unknownRuntime(runtime, requestedName, owner, declaration, {
367
+ name,
368
+ version,
369
+ packageJsonPath,
370
+ reason: `Resolved ${requestedName} to unrecognized package identity ${name}.`
371
+ });
372
+ return {
373
+ runtime,
374
+ state: "resolved",
375
+ requestedName,
376
+ name,
377
+ version,
378
+ packageJsonPath,
379
+ resolvedPath: resolvePackageEntry(require, requestedName),
380
+ owner,
381
+ provenance: "node-resolve",
382
+ declaration,
383
+ identity
384
+ };
385
+ } catch (error) {
386
+ lastReason = error instanceof Error ? error.message : String(error);
387
+ }
388
+ }
389
+ const requestedName = packageCandidates[runtime][0];
390
+ return unknownRuntime(runtime, requestedName, owner, packageDeclaration(ownerPackage, requestedName), { reason: lastReason });
391
+ }
392
+ function resolvePackageJson(require, name) {
393
+ try {
394
+ return require.resolve(`${name}/package.json`);
395
+ } catch {
396
+ const entry = require.resolve(name);
397
+ let current = dirname(entry);
398
+ while (current !== dirname(current)) {
399
+ const candidate = join(current, "package.json");
400
+ if (readPackageManifest(candidate)?.name) return candidate;
401
+ current = dirname(current);
402
+ }
403
+ throw new Error(`Could not locate package.json for ${name} from ${entry}.`);
404
+ }
405
+ }
406
+ function resolvePackageEntry(require, name) {
407
+ try {
408
+ return require.resolve(name);
409
+ } catch {
410
+ return;
411
+ }
412
+ }
413
+ function packageIdentity(runtime, requestedName, actualName) {
414
+ if (!actualName || !acceptedIdentities[runtime].has(actualName)) return "unknown";
415
+ return actualName === requestedName ? "exact" : "alias";
416
+ }
417
+ function packageDeclaration(manifest, name) {
418
+ for (const key of [
419
+ "dependencies",
420
+ "devDependencies",
421
+ "peerDependencies",
422
+ "optionalDependencies"
423
+ ]) {
424
+ const dependencies = manifest?.[key];
425
+ if (dependencies && typeof dependencies === "object") {
426
+ const value = dependencies[name];
427
+ if (typeof value === "string") return value;
428
+ }
429
+ }
430
+ }
431
+ function unknownRuntime(runtime, requestedName, owner, declaration, details) {
432
+ return {
433
+ runtime,
434
+ state: "unknown",
435
+ requestedName,
436
+ owner,
437
+ provenance: "node-resolve",
438
+ declaration,
439
+ identity: details.identity ?? "unknown",
440
+ ...details
441
+ };
442
+ }
443
+ function blockedRuntime(runtime, owner, ownerInstance) {
444
+ return unknownRuntime(runtime, packageCandidates[runtime][0], owner, void 0, { reason: `Cannot resolve ${runtime} because the owning ${ownerInstance.runtime} package is unresolved.` });
445
+ }
446
+ function edge(from, instance) {
447
+ return {
448
+ from,
449
+ to: instance.runtime,
450
+ state: instance.state
451
+ };
452
+ }
453
+ function targetOwner(runtime) {
454
+ if (runtime === "nitro") return "nuxt";
455
+ if (runtime === "h3") return "nitro";
456
+ return "project";
457
+ }
458
+ function readNuxtConfig(root) {
459
+ for (const extension of [
460
+ "ts",
461
+ "mts",
462
+ "js",
463
+ "mjs",
464
+ "cjs",
465
+ "cts"
466
+ ]) {
467
+ const file = join(root, `nuxt.config.${extension}`);
468
+ if (!existsSync(file)) continue;
469
+ try {
470
+ return {
471
+ file,
472
+ text: readFileSync(file, "utf8")
473
+ };
474
+ } catch {
475
+ return null;
476
+ }
477
+ }
478
+ return null;
479
+ }
480
+ function configModifiedTime(file) {
481
+ try {
482
+ return statSync(file).mtimeMs;
483
+ } catch {
484
+ return;
485
+ }
486
+ }
487
+ function readExportedCompatibilityVersion(file, text) {
488
+ const program = parseScript(file, text);
489
+ if (!program) return /\bfuture\s*:[\s\S]{0,200}\bcompatibilityVersion\s*:/.test(text) ? {
490
+ state: "unknown",
491
+ reason: `Doctor found future.compatibilityVersion in ${file} but could not parse the exported Nuxt config safely.`
492
+ } : { state: "absent" };
493
+ const exported = program.body?.find((node) => node.type === "ExportDefaultDeclaration");
494
+ if (!exported) return { state: "absent" };
495
+ let config = unwrapExpression(exported.declaration);
496
+ if (config?.type === "CallExpression" && config.callee?.name === "defineNuxtConfig") config = unwrapExpression(config.arguments?.[0]);
497
+ if (config?.type !== "ObjectExpression") return {
498
+ state: "unknown",
499
+ reason: `The exported Nuxt config in ${file} is computed, so Doctor cannot prove the effective future.compatibilityVersion.`
500
+ };
501
+ const future = objectProperty(config, "future");
502
+ if (future.state === "absent") return future;
503
+ if (future.state === "unknown") return {
504
+ state: "unknown",
505
+ reason: `A spread in the exported Nuxt config at ${file} may define or override future.compatibilityVersion.`
506
+ };
507
+ const futureObject = unwrapExpression(future.value);
508
+ if (futureObject?.type !== "ObjectExpression") return {
509
+ state: "unknown",
510
+ reason: `Nuxt future in ${file} is computed, so Doctor cannot prove the effective compatibilityVersion.`
511
+ };
512
+ const compatibility = objectProperty(futureObject, "compatibilityVersion");
513
+ if (compatibility.state === "absent") return compatibility;
514
+ if (compatibility.state === "unknown") return {
515
+ state: "unknown",
516
+ reason: `A spread in Nuxt future at ${file} may define or override compatibilityVersion.`
517
+ };
518
+ const value = unwrapExpression(compatibility.value);
519
+ return value?.type === "Literal" && (value.value === 4 || value.value === 5) ? {
520
+ state: "resolved",
521
+ version: value.value
522
+ } : {
523
+ state: "unknown",
524
+ reason: `Nuxt future.compatibilityVersion in ${file} is not a static 4 or 5 literal.`
525
+ };
526
+ }
527
+ function unwrapExpression(node) {
528
+ let current = node;
529
+ while (current && [
530
+ "TSAsExpression",
531
+ "TSSatisfiesExpression",
532
+ "ParenthesizedExpression"
533
+ ].includes(current.type)) current = current.expression;
534
+ return current;
535
+ }
536
+ function objectProperty(object, name) {
537
+ let result = { state: "absent" };
538
+ for (const property of object.properties ?? []) {
539
+ if (property.type === "SpreadElement") {
540
+ result = { state: "unknown" };
541
+ continue;
542
+ }
543
+ const key = property.key;
544
+ if ((key?.name ?? key?.value) === name) result = {
545
+ state: "resolved",
546
+ value: property.value
547
+ };
548
+ }
549
+ return result;
550
+ }
551
+ function readPackageManifest(file) {
552
+ try {
553
+ return JSON.parse(readFileSync(resolve(file), "utf8"));
554
+ } catch {
555
+ return null;
556
+ }
557
+ }
558
+ //#endregion
215
559
  //#region src/core/internal/project.ts
216
- async function detectProject(root, requested = "auto") {
560
+ async function detectProject(root, requested = "auto", runtimeTarget) {
217
561
  const packageJson = readJson(join(root, "package.json"));
218
562
  const deps = {
219
563
  ...packageJson?.dependencies,
@@ -228,16 +572,23 @@ async function detectProject(root, requested = "auto") {
228
572
  const ssr = framework === "nuxt" || framework === "nitro" || hasVueSsrEvidence(packageJson, deps);
229
573
  const isMonorepo = existsSync(join(root, "pnpm-workspace.yaml")) || existsSync(join(root, "turbo.json"));
230
574
  const nuxt = framework === "nuxt" ? await detectNuxt(root, nuxtVersion ?? ">=4", deps) : void 0;
575
+ const detectedGraph = resolveRuntimeGraph(root, framework);
576
+ const manifest = framework === "nuxt" ? readJson(join(root, ".nuxt/doctor.manifest.json")) : null;
577
+ const targeted = applyRuntimeTarget(detectedGraph, framework === "nuxt" ? resolveNuxtCompatibility(root, detectedGraph, manifest) : void 0, runtimeTarget);
578
+ const resolvedNuxtVersion = targeted.graph.packages.nuxt?.version;
579
+ const resolvedVueVersion = targeted.graph.packages.vue?.version;
231
580
  return {
232
581
  root: resolve(root),
233
582
  framework,
234
583
  ssr,
235
- vueVersion: cleanVersion(vueVersion),
236
- nuxtVersion: nuxt ? cleanVersion(nuxtVersion ?? nuxt.version) : void 0,
584
+ vueVersion: resolvedVueVersion ?? cleanVersion(vueVersion),
585
+ nuxtVersion: nuxt ? resolvedNuxtVersion ?? cleanVersion(nuxtVersion ?? nuxt.version) : void 0,
237
586
  isMonorepo,
238
587
  packageName: packageJson?.name,
239
588
  tsconfigPath: existsSync(join(root, "tsconfig.json")) ? join(root, "tsconfig.json") : void 0,
240
- nuxt
589
+ nuxt,
590
+ runtimeGraph: targeted.graph,
591
+ nuxtCompatibility: targeted.compatibility
241
592
  };
242
593
  }
243
594
  function hasVueSsrEvidence(packageJson, deps) {
@@ -887,6 +1238,74 @@ function nativeMatch$1(value, pattern) {
887
1238
  return value === pattern || value.includes(pattern);
888
1239
  }
889
1240
  //#endregion
1241
+ //#region src/core/internal/applicability.ts
1242
+ function evaluateRuleApplicability(rule, project) {
1243
+ const requirements = {
1244
+ ...rule.meta.frameworkVersions,
1245
+ ...rule.meta.applicability?.runtimes
1246
+ };
1247
+ const results = Object.entries(requirements).map(([runtime, range]) => evaluateRuntimeRange(project, runtime, range, rule.meta.applicability?.includePrerelease));
1248
+ const compatibilityRange = rule.meta.applicability?.nuxtCompatibility;
1249
+ if (compatibilityRange) results.push(evaluateNuxtCompatibility(project, compatibilityRange));
1250
+ return combineApplicability(results);
1251
+ }
1252
+ function evaluatePackActivation(pack, project) {
1253
+ if (!pack.activation) return active();
1254
+ if (pack.activation.nuxt && project.framework !== "nuxt") return inactive(`Rule Pack ${pack.name} requires a Nuxt project.`);
1255
+ const results = [];
1256
+ if (pack.activation.nuxt) results.push(evaluateRuntimeRange(project, "nuxt", pack.activation.nuxt));
1257
+ if (Boolean(pack.activation.packages?.length || pack.activation.modules?.length)) {
1258
+ const moduleNames = new Set((project.nuxt?.modules ?? []).map((module) => module.name));
1259
+ const matched = pack.activation.packages?.some((name) => moduleNames.has(name)) || pack.activation.modules?.some((name) => moduleNames.has(name));
1260
+ results.push(matched ? active() : inactive(`Rule Pack ${pack.name} package or module activation did not match.`));
1261
+ }
1262
+ return combineApplicability(results);
1263
+ }
1264
+ function evaluateRuntimeRange(project, runtime, range, includePrerelease = false) {
1265
+ if (!validRange(range)) return unknown(`Invalid ${runtime} applicability range ${range}.`);
1266
+ const instance = project.runtimeGraph?.packages[runtime];
1267
+ if (!instance || instance.state !== "resolved" || !instance.version || !valid(instance.version)) return unknown(instance?.reason ?? `The ${runtime} runtime is unresolved.`);
1268
+ return satisfies(instance.version, range, { includePrerelease }) ? active() : inactive(`${runtime} ${instance.version} does not satisfy ${range}.`);
1269
+ }
1270
+ function evaluateNuxtCompatibility(project, range) {
1271
+ if (!validRange(range)) return unknown(`Invalid Nuxt compatibility range ${range}.`);
1272
+ const compatibility = project.nuxtCompatibility;
1273
+ if (compatibility?.state !== "resolved" || compatibility.version === void 0) return unknown(compatibility?.reason ?? "Nuxt compatibility behavior is unresolved.");
1274
+ return satisfies(`${compatibility.version}.0.0`, range) ? active() : inactive(`Nuxt compatibility ${compatibility.version} does not satisfy ${range}.`);
1275
+ }
1276
+ function combineApplicability(results) {
1277
+ if (!results.length) return active();
1278
+ const inactiveResults = results.filter((item) => item.state === "inactive");
1279
+ if (inactiveResults.length) return {
1280
+ state: "inactive",
1281
+ reasons: inactiveResults.flatMap((item) => item.reasons)
1282
+ };
1283
+ const unknownResults = results.filter((item) => item.state === "unknown");
1284
+ if (unknownResults.length) return {
1285
+ state: "unknown",
1286
+ reasons: unknownResults.flatMap((item) => item.reasons)
1287
+ };
1288
+ return active();
1289
+ }
1290
+ function active() {
1291
+ return {
1292
+ state: "active",
1293
+ reasons: []
1294
+ };
1295
+ }
1296
+ function inactive(reason) {
1297
+ return {
1298
+ state: "inactive",
1299
+ reasons: [reason]
1300
+ };
1301
+ }
1302
+ function unknown(reason) {
1303
+ return {
1304
+ state: "unknown",
1305
+ reasons: [reason]
1306
+ };
1307
+ }
1308
+ //#endregion
890
1309
  //#region src/core/internal/scan-session.ts
891
1310
  const DEFAULT_CONFIG = { cache: { dir: ".vite-doctor/cache" } };
892
1311
  var MemoryRuleCache = class {
@@ -940,7 +1359,7 @@ async function createScanSession(options) {
940
1359
  };
941
1360
  markSession(sessionBase, "config", started);
942
1361
  started = performance.now();
943
- const project = await detectProject(root, options.framework ?? "auto");
1362
+ const project = await detectProject(root, options.framework ?? "auto", options.runtimeTarget);
944
1363
  const projectDefaults = project.framework === "nuxt" ? mergeDoctorConfig(DEFAULT_CONFIG, { cache: { dir: ".nuxt/doctor/cache" } }) : DEFAULT_CONFIG;
945
1364
  if (projectDefaults !== DEFAULT_CONFIG || project.nuxt?.doctorConfig) {
946
1365
  config = mergeDoctorConfig(mergeDoctorConfig(projectDefaults, project.nuxt?.doctorConfig), options.config);
@@ -1050,21 +1469,17 @@ async function applyProjectContributions(project, registry) {
1050
1469
  };
1051
1470
  }
1052
1471
  }
1053
- function isActivePack(pack, project) {
1054
- if (!pack.activation) return true;
1055
- if (pack.activation.nuxt && project.framework !== "nuxt") return false;
1056
- if (!Boolean(pack.activation.packages?.length || pack.activation.modules?.length)) return true;
1057
- const moduleNames = new Set((project.nuxt?.modules ?? []).map((module) => module.name));
1058
- return Boolean(pack.activation.packages?.some((name) => moduleNames.has(name)) || pack.activation.modules?.some((name) => moduleNames.has(name)));
1059
- }
1060
1472
  function selectRules(registry, ruleConfigs, options, project) {
1061
1473
  const wanted = options.rules?.split(",").map((item) => item.trim()).filter(Boolean);
1062
1474
  const selectedRules = resolveExtends(registry.packs, options, project);
1063
- return registry.rules.filter((rule) => selectedRules.has(rule.meta.id)).filter((rule) => !rule.meta.requires?.nuxt || project.framework === "nuxt").filter((rule) => !rule.meta.requires?.nitro || project.framework === "nitro" || project.framework === "nuxt").filter((rule) => !rule.meta.requires?.vue || project.framework === "vue" || project.framework === "nuxt").filter((rule) => !rule.meta.requires?.types || options.types).filter((rule) => supportsFrameworkVersion(rule, project)).filter((rule) => !wanted?.length || wanted.some((pattern) => nativeMatch$1(rule.meta.id, pattern))).filter((rule) => resolvedConfig(ruleConfigs, rule.meta.id).enabled);
1475
+ return registry.rules.filter((rule) => selectedRules.has(rule.meta.id)).filter((rule) => !rule.meta.requires?.nuxt || project.framework === "nuxt").filter((rule) => !rule.meta.requires?.nitro || project.framework === "nitro" || project.framework === "nuxt").filter((rule) => !rule.meta.requires?.vue || project.framework === "vue" || project.framework === "nuxt").filter((rule) => !rule.meta.requires?.types || options.types).filter((rule) => !wanted?.length || wanted.some((pattern) => nativeMatch$1(rule.meta.id, pattern))).filter((rule) => resolvedConfig(ruleConfigs, rule.meta.id).enabled).map((rule) => ({
1476
+ rule,
1477
+ applicability: evaluateRuleApplicability(rule, project)
1478
+ })).filter((item) => item.applicability.state === "active").map((item) => item.rule);
1064
1479
  }
1065
1480
  function resolveExtends(packs, options, project) {
1066
1481
  const requested = options.extends ?? options.config?.extends ?? "auto";
1067
- if (requested === "auto") return new Set(packs.filter((pack) => isActivePack(pack, project)).flatMap((pack) => pack.presets.recommended));
1482
+ if (requested === "auto") return new Set(packs.filter((pack) => evaluatePackActivation(pack, project).state === "active").flatMap((pack) => pack.presets.recommended));
1068
1483
  const selected = /* @__PURE__ */ new Set();
1069
1484
  for (const entry of requested) {
1070
1485
  const slash = entry.lastIndexOf("/");
@@ -1129,37 +1544,6 @@ function resolvedConfig(ruleConfigs, ruleId) {
1129
1544
  function isSeverity(value) {
1130
1545
  return value === "blocker" || value === "error" || value === "warn" || value === "info";
1131
1546
  }
1132
- function supportsFrameworkVersion(rule, project) {
1133
- const vue = rule.meta.frameworkVersions?.vue;
1134
- if (vue && !satisfiesVersion(project.vueVersion, vue)) return false;
1135
- const nuxt = rule.meta.frameworkVersions?.nuxt;
1136
- if (nuxt && !project.nuxtVersion) return false;
1137
- if (nuxt && project.nuxtVersion && !satisfiesVersion(project.nuxtVersion, nuxt)) return false;
1138
- return true;
1139
- }
1140
- function satisfiesVersion(version, range) {
1141
- const match = range.trim().match(/^(>=|>|<=|<|=)?\s*(\d+(?:\.\d+){0,2})/);
1142
- if (!match) return true;
1143
- const operator = match[1] ?? "=";
1144
- const comparison = compareVersions(version, match[2]);
1145
- if (operator === ">=") return comparison >= 0;
1146
- if (operator === ">") return comparison > 0;
1147
- if (operator === "<=") return comparison <= 0;
1148
- if (operator === "<") return comparison < 0;
1149
- return comparison === 0;
1150
- }
1151
- function compareVersions(left, right) {
1152
- const leftParts = numericVersionParts(left);
1153
- const rightParts = numericVersionParts(right);
1154
- for (let index = 0; index < 3; index++) {
1155
- const diff = (leftParts[index] ?? 0) - (rightParts[index] ?? 0);
1156
- if (diff) return diff;
1157
- }
1158
- return 0;
1159
- }
1160
- function numericVersionParts(version) {
1161
- return version.replace(/^[^\d]*/, "").split(/[.-]/).slice(0, 3).map((part) => Number.parseInt(part, 10) || 0);
1162
- }
1163
1547
  function createCacheKey(session, phase, input) {
1164
1548
  return `${phase}:${sha256(JSON.stringify({
1165
1549
  version: VERSION,
@@ -1708,6 +2092,10 @@ const allDoctorDiagnosticRegistry = defineDoctorDiagnostics([
1708
2092
  ruleId: "doctor/internal/missing-diagnostic-fix",
1709
2093
  docs: false
1710
2094
  },
2095
+ {
2096
+ code: "DOC0022",
2097
+ ruleId: "doctor/inventory/unresolved-runtime"
2098
+ },
1711
2099
  {
1712
2100
  code: "VUE0001",
1713
2101
  ruleId: "vue/i18n/no-untranslated-text"
@@ -1940,6 +2328,26 @@ const allDoctorDiagnosticRegistry = defineDoctorDiagnostics([
1940
2328
  code: "NITRO0012",
1941
2329
  ruleId: "nitro/request/prefer-route-method-suffix"
1942
2330
  },
2331
+ {
2332
+ code: "NITRO0013",
2333
+ ruleId: "nitro/runtime/no-event-runtime-config-in-server"
2334
+ },
2335
+ {
2336
+ code: "NITRO0014",
2337
+ ruleId: "nitro/migration/no-v2-imports"
2338
+ },
2339
+ {
2340
+ code: "NITRO0015",
2341
+ ruleId: "nitro/h3/no-removed-send"
2342
+ },
2343
+ {
2344
+ code: "NITRO0016",
2345
+ ruleId: "nitro/h3/prefer-redirect-response"
2346
+ },
2347
+ {
2348
+ code: "NITRO0017",
2349
+ ruleId: "nitro/h3/prefer-with-base"
2350
+ },
1943
2351
  {
1944
2352
  code: "NUXT0001",
1945
2353
  ruleId: "docus/appconfig/no-unknown-key"
@@ -2227,6 +2635,10 @@ const allDoctorDiagnosticRegistry = defineDoctorDiagnostics([
2227
2635
  {
2228
2636
  code: "NUXT0072",
2229
2637
  ruleId: "vueuse/prefer-usewindow-size"
2638
+ },
2639
+ {
2640
+ code: "NUXT0073",
2641
+ ruleId: "nuxt/config/no-ignored-compatibility-config"
2230
2642
  }
2231
2643
  ]);
2232
2644
  const allDiagnosticCodesByRuleId = allDoctorDiagnosticRegistry.codesByRuleId;
@@ -2379,6 +2791,37 @@ function pushDiagnostic(session, diagnostic) {
2379
2791
  })
2380
2792
  });
2381
2793
  }
2794
+ function reportRuntimeInventoryUnknown(session) {
2795
+ const unresolved = (session.project.framework === "nuxt" ? [
2796
+ "nuxt",
2797
+ "nitro",
2798
+ "h3"
2799
+ ] : session.project.framework === "nitro" ? ["nitro", "h3"] : session.project.framework === "vue" ? ["vue"] : []).map((runtime) => session.project.runtimeGraph?.packages[runtime]).filter((item) => item?.state === "unknown");
2800
+ const details = [...unresolved.map((item) => `${item?.owner} -> ${item?.runtime}: ${item?.reason ?? "unresolved"}`), ...session.project.nuxtCompatibility?.state === "unknown" ? [`Nuxt compatibility: ${session.project.nuxtCompatibility.reason ?? "unresolved"}`] : []];
2801
+ if (!details.length) return;
2802
+ const runtimeFix = "Install project dependencies and run Doctor from the target project package. If the project uses Yarn PnP, run Doctor through Yarn so its loader is active.";
2803
+ const compatibilityFix = "Make the effective future.compatibilityVersion statically provable in nuxt.config, or run pnpm nuxt doctor so the Nuxt integration can record the resolved value.";
2804
+ const compatibilityUnknown = session.project.nuxtCompatibility?.state === "unknown";
2805
+ pushDiagnostic(session, {
2806
+ ruleId: "doctor/inventory/unresolved-runtime",
2807
+ severity: "warn",
2808
+ category: "inventory",
2809
+ file: unresolved.length || !compatibilityUnknown ? resolve(session.root, "package.json") : session.project.nuxtCompatibility?.file ?? resolve(session.root, "package.json"),
2810
+ why: `Doctor could not resolve the governing runtime graph: ${details.join("; ")}`,
2811
+ suggestion: [unresolved.length ? runtimeFix : void 0, compatibilityUnknown ? compatibilityFix : void 0].filter(Boolean).join(" "),
2812
+ evidence: [...unresolved.map((item) => ({
2813
+ kind: "manifest",
2814
+ summary: `${item?.owner} -> ${item?.runtime} is unresolved.`,
2815
+ file: item?.packageJsonPath
2816
+ })), ...session.project.nuxtCompatibility?.state === "unknown" ? [{
2817
+ kind: "manifest",
2818
+ summary: "Nuxt compatibility behavior is unresolved.",
2819
+ file: session.project.nuxtCompatibility?.file ?? session.project.nuxt?.manifestPath
2820
+ }] : []],
2821
+ confidence: "manifest-backed",
2822
+ analysisPhase: "manifest"
2823
+ });
2824
+ }
2382
2825
  function defaultConfidenceForPhase(phase) {
2383
2826
  if (phase === "graph") return "proven";
2384
2827
  if (phase === "type") return "type-backed";
@@ -3230,6 +3673,10 @@ const coreDiagnosticRegistry = defineDoctorDiagnostics([
3230
3673
  code: "DOC0021",
3231
3674
  ruleId: "doctor/internal/missing-diagnostic-fix",
3232
3675
  docs: false
3676
+ },
3677
+ {
3678
+ code: "DOC0022",
3679
+ ruleId: "doctor/inventory/unresolved-runtime"
3233
3680
  }
3234
3681
  ]);
3235
3682
  coreDiagnosticRegistry.diagnostics;
@@ -3240,6 +3687,12 @@ function createTextReport(result) {
3240
3687
  const lines = [];
3241
3688
  lines.push(`Detected: ${frameworkLabel(result)}`);
3242
3689
  lines.push(`Workspace: ${result.root}`);
3690
+ for (const edge of result.project.runtimeGraph?.edges ?? []) {
3691
+ const runtime = result.project.runtimeGraph?.packages[edge.to];
3692
+ const identity = runtime?.state === "resolved" ? `${runtime.name}@${runtime.version}${runtime.packageJsonPath ? ` (${runtime.packageJsonPath})` : ""}` : `unknown${runtime?.reason ? ` (${runtime.reason})` : ""}`;
3693
+ lines.push(`Runtime: ${edge.from} -> ${edge.to} ${identity}`);
3694
+ }
3695
+ if (result.project.nuxtCompatibility) lines.push(`Nuxt compatibility: ${result.project.nuxtCompatibility.state === "resolved" ? result.project.nuxtCompatibility.version : "unknown"} (${result.project.nuxtCompatibility.provenance})`);
3243
3696
  lines.push(`Health score: ${result.score}/100`);
3244
3697
  if (result.project.nuxt?.manifest) {
3245
3698
  const evidence = result.project.nuxt.manifest.evidence;
@@ -3305,7 +3758,9 @@ function createJsonReport(result) {
3305
3758
  suppressedDiagnostics: result.suppressedDiagnostics?.map(serializeDiagnostic),
3306
3759
  timings: result.timings,
3307
3760
  phases: result.phases,
3308
- graph: result.graph
3761
+ graph: result.graph,
3762
+ runtimeGraph: result.project.runtimeGraph,
3763
+ nuxtCompatibility: result.project.nuxtCompatibility
3309
3764
  }, null, 2)}\n`;
3310
3765
  }
3311
3766
  function createSarifReport(result) {
@@ -3468,6 +3923,7 @@ function serializeDiagnostic(diagnostic) {
3468
3923
  //#region src/core/index.ts
3469
3924
  async function runDoctor(options = {}) {
3470
3925
  const session = await createScanSession(options);
3926
+ reportRuntimeInventoryUnknown(session);
3471
3927
  await runPhase(session, "parseFileFacts", () => parseSourceFiles(session));
3472
3928
  await runPhase(session, "fileRules", () => runFileRules(session));
3473
3929
  await runPhase(session, "manifestRules", () => runManifestRules(session));
@@ -3485,4 +3941,4 @@ async function runDoctor(options = {}) {
3485
3941
  return result;
3486
3942
  }
3487
3943
  //#endregion
3488
- export { codeForRuleId as a, cleanCache as c, defineRulePack as d, doctorInternalDiagnostics as f, explainRule as i, createRule as l, createReport as n, defineDoctorDiagnostics as o, createRulesReport as r, diagnosticForCode as s, runDoctor as t, defineDoctorExtension as u };
3944
+ export { codeForRuleId as a, cleanCache as c, createRule as d, defineDoctorExtension as f, explainRule as i, evaluateRuleApplicability as l, doctorInternalDiagnostics as m, createReport as n, defineDoctorDiagnostics as o, defineRulePack as p, createRulesReport as r, diagnosticForCode as s, runDoctor as t, detectProject as u };