vite-doctor 0.0.5 → 0.0.7
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/dist/cli.mjs +2 -2
- package/dist/{config-CXNytHmY.d.mts → config-GYUYW1FL.d.mts} +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/{core-DIaW0HIr.mjs → core-jvU53IG0.mjs} +139 -35
- package/dist/{doctor-yC2Ke8Ae.mjs → doctor-CPU6PJkE.mjs} +13 -8
- package/dist/index-BZSYm1ow.d.mts +29 -0
- package/dist/{index-DxuqP4UF.d.mts → index-CC_PA_16.d.mts} +1 -1
- package/dist/index-CpbGR6NE.d.mts +3 -0
- package/dist/{index-B8FjkmY1.d.mts → index-ST_3aaT7.d.mts} +1 -1
- package/dist/index-tu1l5mxN.d.mts +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{module-DHwkZLxN.mjs → module--Dgf9XPW.mjs} +30 -4
- package/dist/{module-DtYfgazD.d.mts → module-B-h3EZka.d.mts} +13 -8
- package/dist/nitro-DUjsFYpW.mjs +2 -0
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.mjs +1 -1
- package/dist/{plugin-tOk2jSfx.mjs → plugin-BUgSIN2M.mjs} +2 -2
- package/dist/{plugin-Dnhz_kMz.d.mts → plugin-C3bX7b3u.d.mts} +3 -3
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.mjs +1 -1
- package/dist/{primitives-Nhpqd5ap.d.mts → primitives-BB8AakLb.d.mts} +27 -0
- package/dist/rule-packs/nitro/index.d.mts +2 -2
- package/dist/rule-packs/nitro/index.mjs +2 -2
- package/dist/rule-packs/nitro/rules.d.mts +1 -1
- package/dist/rule-packs/nitro/rules.mjs +1 -1
- 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 +4 -4
- package/dist/rule-packs/nuxt/rules/index.mjs +2 -2
- package/dist/rule-packs/typescript/index.d.mts +2 -0
- package/dist/rule-packs/typescript/index.mjs +3 -0
- package/dist/rule-packs/typescript/rules/index.d.mts +2 -0
- package/dist/rule-packs/typescript/rules/index.mjs +2 -0
- 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-CQY9fsh1.mjs → rules-B3yMC9sr.mjs} +56 -12
- package/dist/{rules-D66KCcT1.d.mts → rules-BW08SCmi.d.mts} +1 -1
- package/dist/rules-BYSi5HL7.mjs +2 -0
- package/dist/rules-C5pNbGfH.mjs +637 -0
- package/dist/{rules-DPvqsm4U.mjs → rules-Coo8Oc8h.mjs} +2 -1
- package/dist/{rules-0AWH0_wP.mjs → rules-DZdYc6nv.mjs} +1 -1
- package/dist/{rules-Cp2zeuza.mjs → rules-wGXdGC9F.mjs} +1 -1
- package/dist/rules.d.mts +1 -1
- package/dist/rules.mjs +2 -2
- package/dist/typescript-BzDAG0C4.mjs +2 -0
- package/package.json +4 -1
- package/dist/index-Benbi54b.d.mts +0 -3
- package/dist/index-xAh4vxLh.d.mts +0 -1
- package/dist/nitro-BRgJaQgL.mjs +0 -2
- package/dist/rules-CPBmmZ0K.mjs +0 -2
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as cleanCache, i as explainRule, l as evaluateRuleApplicability, n as createReport, r as createRulesReport, u as detectProject } from "./core-
|
|
3
|
-
import { i as viteDoctorVersion, n as shouldFailDoctorRun, r as viteDoctorRulePacks, t as runViteDoctor } from "./doctor-
|
|
2
|
+
import { c as cleanCache, i as explainRule, l as evaluateRuleApplicability, n as createReport, r as createRulesReport, u as detectProject } from "./core-jvU53IG0.mjs";
|
|
3
|
+
import { i as viteDoctorVersion, n as shouldFailDoctorRun, r as viteDoctorRulePacks, t as runViteDoctor } from "./doctor-CPU6PJkE.mjs";
|
|
4
4
|
import { relative, resolve } from "pathe";
|
|
5
5
|
import { realpathSync, statSync } from "node:fs";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as DoctorSerializableConfig, n as DoctorFramework, s as RuntimeTarget, t as DoctorExtension } from "./primitives-
|
|
1
|
+
import { i as DoctorSerializableConfig, n as DoctorFramework, s as RuntimeTarget, t as DoctorExtension } from "./primitives-BB8AakLb.mjs";
|
|
2
2
|
//#region src/core/config.d.ts
|
|
3
3
|
interface DoctorConfig extends DoctorSerializableConfig {
|
|
4
4
|
extensions?: DoctorExtension[];
|
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-GYUYW1FL.mjs";
|
|
2
2
|
export { type DoctorConfig, type DoctorRunOptions, type LoadDoctorConfigOptions, defineDoctorConfig, loadDoctorConfig };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./config-cx1PzoSm.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { dirname, join, relative, resolve } from "pathe";
|
|
4
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { createHash } from "node:crypto";
|
|
6
6
|
import * as oxcParser from "oxc-parser";
|
|
7
7
|
import { parseSync } from "oxc-parser";
|
|
@@ -24,7 +24,7 @@ function parseScript(file, source, lang = langFromFile(file)) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
function langFromFile(file) {
|
|
27
|
-
return file.endsWith(".tsx") ? "tsx" : file.endsWith(".jsx") ? "jsx" : file.endsWith(".ts") || file.endsWith(".vue") ? "ts" : "js";
|
|
27
|
+
return file.endsWith(".tsx") ? "tsx" : file.endsWith(".jsx") ? "jsx" : file.endsWith(".ts") || file.endsWith(".mts") || file.endsWith(".cts") || file.endsWith(".vue") ? "ts" : "js";
|
|
28
28
|
}
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/core/internal/template.ts
|
|
@@ -194,6 +194,7 @@ function createNuxtProjectInventory(root, manifest, manifestPath, fallbackImport
|
|
|
194
194
|
pluginFiles: (manifest?.pluginFiles ?? []).map((file) => resolve(root, file)),
|
|
195
195
|
keyedComposables: (manifest?.keyedComposables ?? []).map(String),
|
|
196
196
|
aliases: manifest?.aliases ?? {},
|
|
197
|
+
autoImportTransform: manifest?.autoImportTransform,
|
|
197
198
|
appScanRoots: (manifest?.appScanRoots ?? [manifest?.appDir ?? "app"]).map((dir) => resolve(root, dir)),
|
|
198
199
|
sharedScanRoots: (manifest?.sharedScanRoots ?? ["shared/utils", "shared/types"]).map((dir) => resolve(root, dir)),
|
|
199
200
|
hasManifest: Boolean(manifestPath),
|
|
@@ -266,9 +267,7 @@ function resolveNuxtCompatibility(root, graph, manifest) {
|
|
|
266
267
|
if (!graph.packages.nuxt) return void 0;
|
|
267
268
|
const config = readNuxtConfig(root);
|
|
268
269
|
const manifestGeneratedAt = manifest?.generatedAt ? Date.parse(manifest.generatedAt) : NaN;
|
|
269
|
-
|
|
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 {
|
|
270
|
+
if (Number.isFinite(manifestGeneratedAt) && isSupportedNuxtCompatibility(manifest?.compatibilityVersion) && isNuxtManifestCurrent(root, manifest)) return {
|
|
272
271
|
state: "resolved",
|
|
273
272
|
version: manifest.compatibilityVersion,
|
|
274
273
|
provenance: "manifest"
|
|
@@ -300,6 +299,13 @@ function resolveNuxtCompatibility(root, graph, manifest) {
|
|
|
300
299
|
provenance: "default"
|
|
301
300
|
};
|
|
302
301
|
}
|
|
302
|
+
function isNuxtManifestCurrent(root, manifest) {
|
|
303
|
+
if (!manifest?.generatedAt || !Number.isFinite(Date.parse(manifest.generatedAt))) return false;
|
|
304
|
+
const config = readNuxtConfig(root);
|
|
305
|
+
const configModifiedAt = config ? configModifiedTime(config.file) : void 0;
|
|
306
|
+
if (configModifiedAt === void 0) return true;
|
|
307
|
+
return Number.isFinite(manifest.nuxtConfigMtimeMs) ? manifest.nuxtConfigMtimeMs === configModifiedAt : Date.parse(manifest.generatedAt) >= configModifiedAt;
|
|
308
|
+
}
|
|
303
309
|
function isSupportedNuxtCompatibility(value) {
|
|
304
310
|
return value === 4 || value === 5;
|
|
305
311
|
}
|
|
@@ -577,6 +583,7 @@ async function detectProject(root, requested = "auto", runtimeTarget) {
|
|
|
577
583
|
const targeted = applyRuntimeTarget(detectedGraph, framework === "nuxt" ? resolveNuxtCompatibility(root, detectedGraph, manifest) : void 0, runtimeTarget);
|
|
578
584
|
const resolvedNuxtVersion = targeted.graph.packages.nuxt?.version;
|
|
579
585
|
const resolvedVueVersion = targeted.graph.packages.vue?.version;
|
|
586
|
+
const tsconfigPath = existsSync(join(root, "tsconfig.json")) ? join(root, "tsconfig.json") : void 0;
|
|
580
587
|
return {
|
|
581
588
|
root: resolve(root),
|
|
582
589
|
framework,
|
|
@@ -585,12 +592,56 @@ async function detectProject(root, requested = "auto", runtimeTarget) {
|
|
|
585
592
|
nuxtVersion: nuxt ? resolvedNuxtVersion ?? cleanVersion(nuxtVersion ?? nuxt.version) : void 0,
|
|
586
593
|
isMonorepo,
|
|
587
594
|
packageName: packageJson?.name,
|
|
588
|
-
tsconfigPath
|
|
595
|
+
tsconfigPath,
|
|
596
|
+
languages: await detectProjectLanguages(root, Boolean(tsconfigPath)),
|
|
589
597
|
nuxt,
|
|
590
598
|
runtimeGraph: targeted.graph,
|
|
591
599
|
nuxtCompatibility: targeted.compatibility
|
|
592
600
|
};
|
|
593
601
|
}
|
|
602
|
+
async function detectProjectLanguages(root, hasTsconfig) {
|
|
603
|
+
let hasTypeScript = hasTsconfig;
|
|
604
|
+
let hasJavaScript = false;
|
|
605
|
+
for await (const entry of glob("**/*.{vue,ts,tsx,mts,cts,js,jsx,mjs,cjs}", {
|
|
606
|
+
cwd: root,
|
|
607
|
+
exclude: [
|
|
608
|
+
"**/node_modules/**",
|
|
609
|
+
"**/dist/**",
|
|
610
|
+
"**/.nuxt/**",
|
|
611
|
+
"**/.next/**",
|
|
612
|
+
"**/.output/**",
|
|
613
|
+
"**/coverage/**",
|
|
614
|
+
"**/generated/**"
|
|
615
|
+
]
|
|
616
|
+
})) {
|
|
617
|
+
if (typeof entry !== "string") continue;
|
|
618
|
+
if (/\.(?:ts|tsx|mts|cts)$/.test(entry)) hasTypeScript = true;
|
|
619
|
+
if (/\.(?:js|jsx|mjs|cjs)$/.test(entry)) hasJavaScript = true;
|
|
620
|
+
if (entry.endsWith(".vue")) {
|
|
621
|
+
const languages = detectVueScriptLanguages(root, entry);
|
|
622
|
+
hasTypeScript ||= languages.includes("typescript");
|
|
623
|
+
hasJavaScript ||= languages.includes("javascript");
|
|
624
|
+
}
|
|
625
|
+
if (hasTypeScript && hasJavaScript) break;
|
|
626
|
+
}
|
|
627
|
+
return [...hasTypeScript ? ["typescript"] : [], ...hasJavaScript ? ["javascript"] : []];
|
|
628
|
+
}
|
|
629
|
+
function detectVueScriptLanguages(root, file) {
|
|
630
|
+
try {
|
|
631
|
+
let hasTypeScript = false;
|
|
632
|
+
let hasJavaScript = false;
|
|
633
|
+
const source = readFileSync(join(root, file), "utf8");
|
|
634
|
+
for (const match of source.matchAll(/<script\b([^>]*)>/gi)) {
|
|
635
|
+
const langMatch = match[1]?.match(/\blang\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s"'=<>`]+))/i);
|
|
636
|
+
const lang = (langMatch?.[1] ?? langMatch?.[2] ?? langMatch?.[3] ?? "js").toLowerCase();
|
|
637
|
+
if (lang === "ts" || lang === "tsx") hasTypeScript = true;
|
|
638
|
+
if (lang === "js" || lang === "jsx") hasJavaScript = true;
|
|
639
|
+
}
|
|
640
|
+
return [...hasTypeScript ? ["typescript"] : [], ...hasJavaScript ? ["javascript"] : []];
|
|
641
|
+
} catch {
|
|
642
|
+
return [];
|
|
643
|
+
}
|
|
644
|
+
}
|
|
594
645
|
function hasVueSsrEvidence(packageJson, deps) {
|
|
595
646
|
if (Object.keys(deps).some((name) => /^(vitepress|vuepress|@vuepress\/|@vue\/server-renderer|vite-ssg|vite-plugin-ssr|vike|nuxt)$/.test(name))) return true;
|
|
596
647
|
return Object.values(packageJson?.scripts ?? {}).some((script) => /\b(vitepress|vuepress|vite-ssg|vike|vite\s+build\s+--ssr)\b/.test(script));
|
|
@@ -605,6 +656,8 @@ async function normalizeNuxtProject(root, version, deps, manifest, manifestPath)
|
|
|
605
656
|
version: cleanVersion(manifest?.nuxtVersion ?? version),
|
|
606
657
|
appDir: resolve(root, manifest?.appDir ?? (existsSync(join(root, "app")) ? "app" : ".")),
|
|
607
658
|
appRoots: manifest?.layers?.length ? manifest.layers.map((layer) => resolve(root, layer.root)).sort() : await detectNuxtAppRoots(root),
|
|
659
|
+
autoImportEnabled: manifest ? manifest.autoImportEnabled === true : true,
|
|
660
|
+
autoImportsAuthoritative: manifest?.autoImportEnabled !== void 0 && isNuxtManifestCurrent(root, manifest),
|
|
608
661
|
autoImports: new Map((manifest?.autoImports ?? coreAutoImports()).map((entry) => [entry.as ?? entry.name, entry])),
|
|
609
662
|
components: new Map((manifest?.components ?? []).map((component) => [component.name, component])),
|
|
610
663
|
layers: manifest?.layers ?? [{
|
|
@@ -706,11 +759,13 @@ function extendsDocus(root) {
|
|
|
706
759
|
//#endregion
|
|
707
760
|
//#region src/core/internal/source-inventory.ts
|
|
708
761
|
const DEFAULT_INCLUDE = [
|
|
709
|
-
"**/*.{vue,ts,tsx,js,mjs,cjs}",
|
|
762
|
+
"**/*.{vue,ts,tsx,mts,cts,js,jsx,mjs,cjs}",
|
|
710
763
|
"vite.config.{ts,js,mjs,cjs,mts,cts}",
|
|
711
764
|
"vitest.config.{ts,js,mjs,cjs,mts,cts}"
|
|
712
765
|
];
|
|
713
766
|
const CONTENT_INCLUDE = ["content/**/*.{md,mdc}"];
|
|
767
|
+
const GENERATED_HEADER_BYTES = 800;
|
|
768
|
+
const GENERATED_HEADER_PATTERN = /@generated|generated by|do not edit|auto-generated/i;
|
|
714
769
|
const DEFAULT_EXCLUDE = [
|
|
715
770
|
"**/node_modules/**",
|
|
716
771
|
"**/.nuxt/**",
|
|
@@ -720,18 +775,17 @@ const DEFAULT_EXCLUDE = [
|
|
|
720
775
|
"**/coverage/**",
|
|
721
776
|
"**/public/**",
|
|
722
777
|
"**/generated/**",
|
|
723
|
-
"**/*.
|
|
724
|
-
"
|
|
725
|
-
"
|
|
778
|
+
"**/*.generated.{ts,tsx,mts,cts,js,jsx,mjs,cjs,vue}",
|
|
779
|
+
"**/*.min.{ts,tsx,mts,cts,js,jsx,mjs,cjs}",
|
|
780
|
+
"**/{test,tests,__tests__,__snapshots__,fixtures,test-d,typetest,__typetest__,type-tests,dts-test,dtslint}/**",
|
|
781
|
+
"**/*.{test,spec}.{ts,tsx,mts,cts,js,jsx,mjs,cjs,vue}",
|
|
726
782
|
"doctor.config.*"
|
|
727
783
|
];
|
|
728
784
|
async function selectScanFiles(root, config, options, project) {
|
|
729
785
|
if (options.changed || options.since) {
|
|
730
786
|
const changed = await gitChangedFiles(root, options.since);
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
return changed.filter((file) => includeContent ? /\.(vue|[cm]?[jt]sx?|mdc?)$/.test(file) : /\.(vue|[cm]?[jt]sx?)$/.test(file)).filter((file) => statSync(resolve(root, file), { throwIfNoEntry: false })?.isFile()).map((file) => createAppFileEntry(root, file));
|
|
734
|
-
}
|
|
787
|
+
const includeContent = hasContentFiles(project);
|
|
788
|
+
return changed.filter((file) => includeContent ? /\.(vue|[cm]?[jt]sx?|mdc?)$/.test(file) : /\.(vue|[cm]?[jt]sx?)$/.test(file)).filter((file) => isScannableFile(resolve(root, file))).map((file) => createAppFileEntry(root, file));
|
|
735
789
|
}
|
|
736
790
|
const files = /* @__PURE__ */ new Map();
|
|
737
791
|
const exclude = [...DEFAULT_EXCLUDE, ...config.exclude ?? []];
|
|
@@ -742,7 +796,7 @@ async function selectScanFiles(root, config, options, project) {
|
|
|
742
796
|
})) {
|
|
743
797
|
if (typeof entry !== "string") continue;
|
|
744
798
|
const absolute = resolve(root, entry);
|
|
745
|
-
if (
|
|
799
|
+
if (isScannableFile(absolute)) files.set(absolute, createAppFileEntry(root, entry));
|
|
746
800
|
}
|
|
747
801
|
for (const source of project.nuxt?.moduleSources ?? []) {
|
|
748
802
|
const include = source.include?.length ? source.include : DEFAULT_INCLUDE;
|
|
@@ -753,7 +807,7 @@ async function selectScanFiles(root, config, options, project) {
|
|
|
753
807
|
})) {
|
|
754
808
|
if (typeof entry !== "string") continue;
|
|
755
809
|
const absolute = resolve(source.root, entry);
|
|
756
|
-
if (!
|
|
810
|
+
if (!isScannableFile(absolute)) continue;
|
|
757
811
|
files.set(absolute, {
|
|
758
812
|
path: absolute,
|
|
759
813
|
displayPath: `${source.module}:${relative(source.root, absolute)}`,
|
|
@@ -764,6 +818,19 @@ async function selectScanFiles(root, config, options, project) {
|
|
|
764
818
|
}
|
|
765
819
|
return [...files.values()].sort((a, b) => a.displayPath.localeCompare(b.displayPath));
|
|
766
820
|
}
|
|
821
|
+
function isScannableFile(file) {
|
|
822
|
+
return Boolean(statSync(file, { throwIfNoEntry: false })?.isFile()) && !hasGeneratedHeader(file);
|
|
823
|
+
}
|
|
824
|
+
function hasGeneratedHeader(file) {
|
|
825
|
+
const descriptor = openSync(file, "r");
|
|
826
|
+
try {
|
|
827
|
+
const buffer = Buffer.alloc(GENERATED_HEADER_BYTES);
|
|
828
|
+
const bytesRead = readSync(descriptor, buffer, 0, buffer.length, 0);
|
|
829
|
+
return GENERATED_HEADER_PATTERN.test(buffer.toString("utf8", 0, bytesRead));
|
|
830
|
+
} finally {
|
|
831
|
+
closeSync(descriptor);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
767
834
|
function defaultIncludeForProject(project) {
|
|
768
835
|
if (hasContentFiles(project)) return [...DEFAULT_INCLUDE, ...CONTENT_INCLUDE];
|
|
769
836
|
return DEFAULT_INCLUDE;
|
|
@@ -784,23 +851,19 @@ function detectAppSourceKind(root, file) {
|
|
|
784
851
|
return relative(root, file).startsWith("layers/") ? "layer" : "app";
|
|
785
852
|
}
|
|
786
853
|
async function gitChangedFiles(root, since) {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
], root)).split(/\r?\n/).filter(Boolean);
|
|
801
|
-
} catch {
|
|
802
|
-
return [];
|
|
803
|
-
}
|
|
854
|
+
return (await execFileText("git", since ? [
|
|
855
|
+
"diff",
|
|
856
|
+
"--name-only",
|
|
857
|
+
"--diff-filter=ACMR",
|
|
858
|
+
since,
|
|
859
|
+
"--"
|
|
860
|
+
] : [
|
|
861
|
+
"diff",
|
|
862
|
+
"--name-only",
|
|
863
|
+
"--diff-filter=ACMR",
|
|
864
|
+
"--cached",
|
|
865
|
+
"--"
|
|
866
|
+
], root)).split(/\r?\n/).filter(Boolean);
|
|
804
867
|
}
|
|
805
868
|
function execFileText(command, args, cwd) {
|
|
806
869
|
return new Promise((resolvePromise, reject) => {
|
|
@@ -1254,6 +1317,11 @@ function evaluatePackActivation(pack, project) {
|
|
|
1254
1317
|
if (pack.activation.nuxt && project.framework !== "nuxt") return inactive(`Rule Pack ${pack.name} requires a Nuxt project.`);
|
|
1255
1318
|
const results = [];
|
|
1256
1319
|
if (pack.activation.nuxt) results.push(evaluateRuntimeRange(project, "nuxt", pack.activation.nuxt));
|
|
1320
|
+
if (pack.activation.languages?.length) {
|
|
1321
|
+
const languages = new Set(project.languages ?? []);
|
|
1322
|
+
const matched = pack.activation.languages.some((language) => languages.has(language));
|
|
1323
|
+
results.push(matched ? active() : inactive(`Rule Pack ${pack.name} language activation did not match.`));
|
|
1324
|
+
}
|
|
1257
1325
|
if (Boolean(pack.activation.packages?.length || pack.activation.modules?.length)) {
|
|
1258
1326
|
const moduleNames = new Set((project.nuxt?.modules ?? []).map((module) => module.name));
|
|
1259
1327
|
const matched = pack.activation.packages?.some((name) => moduleNames.has(name)) || pack.activation.modules?.some((name) => moduleNames.has(name));
|
|
@@ -1483,6 +1551,10 @@ function resolveExtends(packs, options, project) {
|
|
|
1483
1551
|
if (requested === "auto") return new Set(packs.filter((pack) => evaluatePackActivation(pack, project).state === "active").flatMap((pack) => pack.presets.recommended));
|
|
1484
1552
|
const selected = /* @__PURE__ */ new Set();
|
|
1485
1553
|
for (const entry of requested) {
|
|
1554
|
+
if (entry === "auto") {
|
|
1555
|
+
for (const ruleId of packs.filter((pack) => evaluatePackActivation(pack, project).state === "active").flatMap((pack) => pack.presets.recommended)) selected.add(ruleId);
|
|
1556
|
+
continue;
|
|
1557
|
+
}
|
|
1486
1558
|
const slash = entry.lastIndexOf("/");
|
|
1487
1559
|
if (slash === -1) throw doctorInternalDiagnostics.DOC0016({ entry });
|
|
1488
1560
|
const packKey = entry.slice(0, slash);
|
|
@@ -2281,6 +2353,38 @@ const allDoctorDiagnosticRegistry = defineDoctorDiagnostics([
|
|
|
2281
2353
|
code: "VITE0021",
|
|
2282
2354
|
ruleId: "vite/worker/require-worker-url-pattern"
|
|
2283
2355
|
},
|
|
2356
|
+
{
|
|
2357
|
+
code: "TS0001",
|
|
2358
|
+
ruleId: "typescript/evidence/no-chained-type-assertions"
|
|
2359
|
+
},
|
|
2360
|
+
{
|
|
2361
|
+
code: "TS0002",
|
|
2362
|
+
ruleId: "typescript/evidence/no-object-parameters"
|
|
2363
|
+
},
|
|
2364
|
+
{
|
|
2365
|
+
code: "TS0003",
|
|
2366
|
+
ruleId: "typescript/evidence/no-unknown-type-aliases"
|
|
2367
|
+
},
|
|
2368
|
+
{
|
|
2369
|
+
code: "TS0004",
|
|
2370
|
+
ruleId: "typescript/evidence/no-caller-chosen-result-type"
|
|
2371
|
+
},
|
|
2372
|
+
{
|
|
2373
|
+
code: "TS0005",
|
|
2374
|
+
ruleId: "typescript/boundaries/no-unvalidated-deserialization"
|
|
2375
|
+
},
|
|
2376
|
+
{
|
|
2377
|
+
code: "TS0006",
|
|
2378
|
+
ruleId: "typescript/style/no-conditional-empty-object-spread"
|
|
2379
|
+
},
|
|
2380
|
+
{
|
|
2381
|
+
code: "TS0007",
|
|
2382
|
+
ruleId: "typescript/strict/no-runtime-typeof"
|
|
2383
|
+
},
|
|
2384
|
+
{
|
|
2385
|
+
code: "TS0008",
|
|
2386
|
+
ruleId: "typescript/strict/require-safety-comment-for-type-assertion"
|
|
2387
|
+
},
|
|
2284
2388
|
{
|
|
2285
2389
|
code: "NITRO0001",
|
|
2286
2390
|
ruleId: "nitro/context/no-navigateto-in-nitro"
|
|
@@ -2772,8 +2876,8 @@ function normalizeDiagnosticFromRuleCode(input) {
|
|
|
2772
2876
|
};
|
|
2773
2877
|
}
|
|
2774
2878
|
function nearestAnchor(source, offset) {
|
|
2775
|
-
const last = [...source.slice(0, offset).matchAll(/\b(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)|\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)|<([A-Z][\w.-]*)\b/g)].at(-1);
|
|
2776
|
-
return last ? last[1] ?? last[2] ?? last[3] ?? "file" : "file";
|
|
2879
|
+
const last = [...source.slice(0, offset).matchAll(/\b(?:export\s+)?(?:async\s+)?function\s+([A-Za-z_$][\w$]*)|\b(?:const|let|var)\s+(?:([A-Za-z_$][\w$]*)|(\{[^}\n]*\}|\[[^\]\n]*\]))|<([A-Z][\w.-]*)\b/g)].at(-1);
|
|
2880
|
+
return last ? last[1] ?? last[2] ?? last[3] ?? last[4] ?? "file" : "file";
|
|
2777
2881
|
}
|
|
2778
2882
|
function pushDiagnostic(session, diagnostic) {
|
|
2779
2883
|
const normalized = normalizeDiagnosticFromRuleCode(diagnostic);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { f as defineDoctorExtension, t as runDoctor } from "./core-
|
|
2
|
-
import { t as nitroRulePack } from "./rules-
|
|
3
|
-
import "./nitro-
|
|
4
|
-
import { t as vueRulePack } from "./rules-
|
|
5
|
-
import { n as nuxtRulePacks, t as nuxtDoctorExtensions } from "./rules-
|
|
6
|
-
import { t as viteRulePack } from "./rules-
|
|
7
|
-
import "./rules-
|
|
1
|
+
import { f as defineDoctorExtension, t as runDoctor } from "./core-jvU53IG0.mjs";
|
|
2
|
+
import { t as nitroRulePack } from "./rules-wGXdGC9F.mjs";
|
|
3
|
+
import "./nitro-DUjsFYpW.mjs";
|
|
4
|
+
import { t as vueRulePack } from "./rules-Coo8Oc8h.mjs";
|
|
5
|
+
import { n as nuxtRulePacks, t as nuxtDoctorExtensions } from "./rules-B3yMC9sr.mjs";
|
|
6
|
+
import { t as viteRulePack } from "./rules-DZdYc6nv.mjs";
|
|
7
|
+
import "./rules-BYSi5HL7.mjs";
|
|
8
|
+
import { t as typescriptRulePack } from "./rules-C5pNbGfH.mjs";
|
|
9
|
+
import "./typescript-BzDAG0C4.mjs";
|
|
8
10
|
import { join } from "pathe";
|
|
9
11
|
import { existsSync, readFileSync } from "node:fs";
|
|
10
12
|
//#region src/version.ts
|
|
@@ -21,7 +23,7 @@ function readPackageVersion() {
|
|
|
21
23
|
//#region src/doctor.ts
|
|
22
24
|
async function viteDoctorRulePacks(options = {}) {
|
|
23
25
|
const framework = detectRequestedFramework(options);
|
|
24
|
-
const packs = [viteRulePack];
|
|
26
|
+
const packs = [viteRulePack, typescriptRulePack];
|
|
25
27
|
if (framework === "vue") packs.push(vueRulePack);
|
|
26
28
|
if (framework === "nitro") packs.push(nitroRulePack);
|
|
27
29
|
if (framework === "nuxt") packs.push(...nuxtRulePacks());
|
|
@@ -32,6 +34,9 @@ async function viteDoctorExtensions(options = {}) {
|
|
|
32
34
|
const extensions = [defineDoctorExtension({
|
|
33
35
|
name: "vite-doctor/builtin-vite",
|
|
34
36
|
rulePacks: [viteRulePack]
|
|
37
|
+
}), defineDoctorExtension({
|
|
38
|
+
name: "vite-doctor/builtin-typescript",
|
|
39
|
+
rulePacks: [typescriptRulePack]
|
|
35
40
|
})];
|
|
36
41
|
if (framework === "vue") extensions.push(defineDoctorExtension({
|
|
37
42
|
name: "vite-doctor/builtin-vue",
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { o as RulePack, r as DoctorRule } from "./primitives-BB8AakLb.mjs";
|
|
2
|
+
//#region src/rule-packs/typescript/rules/no-caller-chosen-result-type.d.ts
|
|
3
|
+
declare const noCallerChosenResultType: DoctorRule;
|
|
4
|
+
//#endregion
|
|
5
|
+
//#region src/rule-packs/typescript/rules/no-chained-type-assertions.d.ts
|
|
6
|
+
declare const noChainedTypeAssertions: DoctorRule;
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/rule-packs/typescript/rules/no-conditional-empty-object-spread.d.ts
|
|
9
|
+
declare const noConditionalEmptyObjectSpread: DoctorRule;
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/rule-packs/typescript/rules/no-object-parameters.d.ts
|
|
12
|
+
declare const noObjectParameters: DoctorRule;
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/rule-packs/typescript/rules/no-runtime-typeof.d.ts
|
|
15
|
+
declare const noRuntimeTypeof: DoctorRule;
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/rule-packs/typescript/rules/no-unknown-type-aliases.d.ts
|
|
18
|
+
declare const noUnknownTypeAliases: DoctorRule;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/rule-packs/typescript/rules/no-unvalidated-deserialization.d.ts
|
|
21
|
+
declare const noUnvalidatedDeserialization: DoctorRule;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/rule-packs/typescript/rules/require-safety-comment-for-type-assertion.d.ts
|
|
24
|
+
declare const requireSafetyCommentForTypeAssertion: DoctorRule;
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/rule-packs/typescript/rules/index.d.ts
|
|
27
|
+
declare const typescriptRulePack: RulePack;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { noRuntimeTypeof as a, noChainedTypeAssertions as c, noUnknownTypeAliases as i, noCallerChosenResultType as l, requireSafetyCommentForTypeAssertion as n, noObjectParameters as o, noUnvalidatedDeserialization as r, noConditionalEmptyObjectSpread as s, typescriptRulePack as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as RulePack, r as DoctorRule } from "./primitives-
|
|
1
|
+
import { o as RulePack, r as DoctorRule } from "./primitives-BB8AakLb.mjs";
|
|
2
2
|
//#region src/rule-packs/vite/rules/define.d.ts
|
|
3
3
|
declare const noUnusedDefine: DoctorRule;
|
|
4
4
|
declare const noUntypedDefine: DoctorRule;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as RulePack, r as DoctorRule } from "./primitives-
|
|
1
|
+
import { o as RulePack, r as DoctorRule } from "./primitives-BB8AakLb.mjs";
|
|
2
2
|
//#region src/rule-packs/nitro/rules/no-use-nuxt-app-in-nitro.d.ts
|
|
3
3
|
declare const noUseNuxtAppInNitro: DoctorRule;
|
|
4
4
|
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./index-ST_3aaT7.mjs";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as defineDoctorConfig, n as DoctorRunOptions, t as DoctorConfig } from "./config-
|
|
2
|
-
import { n as doctor, t as ViteDoctorSurfaceOptions } from "./plugin-
|
|
1
|
+
import { i as defineDoctorConfig, n as DoctorRunOptions, t as DoctorConfig } from "./config-GYUYW1FL.mjs";
|
|
2
|
+
import { n as doctor, t as ViteDoctorSurfaceOptions } from "./plugin-C3bX7b3u.mjs";
|
|
3
3
|
export { type DoctorConfig, type DoctorRunOptions, type ViteDoctorSurfaceOptions, defineDoctorConfig, doctor };
|
package/dist/index.mjs
CHANGED
|
@@ -12,8 +12,12 @@ async function nuxtDoctorModule(options = {}, nuxt) {
|
|
|
12
12
|
prerenderRoutes: /* @__PURE__ */ new Set(),
|
|
13
13
|
buildManifest: void 0,
|
|
14
14
|
componentDirs: [],
|
|
15
|
-
importDirs: []
|
|
15
|
+
importDirs: [],
|
|
16
|
+
autoImportContext: void 0
|
|
16
17
|
};
|
|
18
|
+
nuxt.hook?.("imports:context", (context) => {
|
|
19
|
+
evidence.autoImportContext = context;
|
|
20
|
+
});
|
|
17
21
|
nuxt.hook?.("pages:resolved", (pages) => {
|
|
18
22
|
evidence.pages = flattenPages(pages).map((page) => ({
|
|
19
23
|
path: page.path,
|
|
@@ -64,7 +68,8 @@ async function collectNuxtDoctorExtensions(nuxt) {
|
|
|
64
68
|
async function writeManifest(nuxt, evidence) {
|
|
65
69
|
const rootDir = resolve(nuxt.options.rootDir ?? process.cwd());
|
|
66
70
|
const buildDir = resolve(rootDir, nuxt.options.buildDir ?? ".nuxt");
|
|
67
|
-
const
|
|
71
|
+
const srcDir = resolve(rootDir, nuxt.options.srcDir ?? ".");
|
|
72
|
+
const appDir = srcDir;
|
|
68
73
|
const moduleSources = [];
|
|
69
74
|
await nuxt.callHook?.("doctor:extendSources", moduleSources);
|
|
70
75
|
const modules = toArray(nuxt.options.modules).map((entry) => ({
|
|
@@ -72,16 +77,19 @@ async function writeManifest(nuxt, evidence) {
|
|
|
72
77
|
version: entry?.meta?.version,
|
|
73
78
|
doctorPlugin: entry?.doctor?.plugin
|
|
74
79
|
}));
|
|
80
|
+
const resolvedAutoImports = evidence?.autoImportContext?.getImports ? await evidence.autoImportContext.getImports() : toArray(nuxt.options.imports?.imports);
|
|
75
81
|
const manifest = {
|
|
76
82
|
nuxtConfigMtimeMs: nuxtConfigModifiedAt(rootDir),
|
|
77
83
|
nuxtVersion: nuxt._version ?? nuxt.version ?? "4",
|
|
78
84
|
vueVersion: nuxt.options.vue?.version ?? "3.5",
|
|
79
85
|
compatibilityVersion: nuxt.options.future?.compatibilityVersion,
|
|
80
86
|
rootDir,
|
|
81
|
-
srcDir
|
|
87
|
+
srcDir,
|
|
82
88
|
appDir,
|
|
83
89
|
buildDir,
|
|
84
|
-
|
|
90
|
+
autoImportEnabled: nuxt.options.imports?.autoImport !== false,
|
|
91
|
+
autoImportTransform: serializeImportTransform(nuxt.options.imports?.transform),
|
|
92
|
+
autoImports: normalizeAutoImports(resolvedAutoImports),
|
|
85
93
|
components: toArray(nuxt.options.components ?? nuxt._components),
|
|
86
94
|
layers: toArray(nuxt.options._layers ?? [{ cwd: rootDir }]).map((layer, index) => ({
|
|
87
95
|
root: resolve(layer.cwd ?? layer.config?.rootDir ?? rootDir),
|
|
@@ -157,6 +165,24 @@ function toArray(value) {
|
|
|
157
165
|
function normalizeDirs(rootDir, dirs) {
|
|
158
166
|
return dirs.map((dir) => typeof dir === "string" ? dir : dir?.path).filter(Boolean).map((dir) => resolve(rootDir, dir));
|
|
159
167
|
}
|
|
168
|
+
function normalizeAutoImports(imports) {
|
|
169
|
+
return imports.map((entry) => ({
|
|
170
|
+
name: entry?.name,
|
|
171
|
+
as: entry?.as,
|
|
172
|
+
from: entry?.from,
|
|
173
|
+
type: entry?.type === true || void 0
|
|
174
|
+
})).filter((entry) => entry.name && entry.from);
|
|
175
|
+
}
|
|
176
|
+
function serializeImportTransform(transform) {
|
|
177
|
+
const serialize = (patterns) => patterns.filter((pattern) => pattern instanceof RegExp).map(({ source, flags }) => ({
|
|
178
|
+
source,
|
|
179
|
+
flags
|
|
180
|
+
}));
|
|
181
|
+
return {
|
|
182
|
+
include: serialize(toArray(transform?.include)),
|
|
183
|
+
exclude: serialize(toArray(transform?.exclude))
|
|
184
|
+
};
|
|
185
|
+
}
|
|
160
186
|
function normalizePluginFiles(rootDir, plugins) {
|
|
161
187
|
return plugins.map((plugin) => typeof plugin === "string" ? plugin : plugin?.src ?? plugin?.file).filter(Boolean).map((file) => resolve(rootDir, file));
|
|
162
188
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as NuxtDoctorManifest, o as RulePack, t as DoctorExtension } from "./primitives-
|
|
2
|
-
import { t as DoctorConfig } from "./config-
|
|
3
|
-
import "./index-
|
|
1
|
+
import { a as NuxtDoctorManifest, o as RulePack, t as DoctorExtension } from "./primitives-BB8AakLb.mjs";
|
|
2
|
+
import { t as DoctorConfig } from "./config-GYUYW1FL.mjs";
|
|
3
|
+
import "./index-CpbGR6NE.mjs";
|
|
4
4
|
//#region src/rule-packs/nuxt/module.d.ts
|
|
5
5
|
interface NuxtDoctorModuleOptions {
|
|
6
6
|
config?: DoctorConfig;
|
|
@@ -16,10 +16,10 @@ type EvidenceBuildManifest = {
|
|
|
16
16
|
isDynamicEntry?: boolean;
|
|
17
17
|
}>;
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
type NuxtAutoImportContext = {
|
|
20
|
+
getImports?: () => Promise<unknown[]> | unknown[];
|
|
21
|
+
};
|
|
22
|
+
type NuxtDoctorEvidence = {
|
|
23
23
|
pages?: Array<{
|
|
24
24
|
path?: string;
|
|
25
25
|
file?: string;
|
|
@@ -29,6 +29,11 @@ declare function writeManifest(nuxt: any, evidence?: {
|
|
|
29
29
|
buildManifest?: EvidenceBuildManifest;
|
|
30
30
|
componentDirs?: unknown[];
|
|
31
31
|
importDirs?: unknown[];
|
|
32
|
-
|
|
32
|
+
autoImportContext?: NuxtAutoImportContext;
|
|
33
|
+
};
|
|
34
|
+
declare function nuxtDoctorModule(options: NuxtDoctorModuleOptions | undefined, nuxt: any): Promise<void>;
|
|
35
|
+
declare function collectNuxtDoctorRulePacks(nuxt: any): Promise<RulePack[]>;
|
|
36
|
+
declare function collectNuxtDoctorExtensions(nuxt: any): Promise<DoctorExtension[]>;
|
|
37
|
+
declare function writeManifest(nuxt: any, evidence?: NuxtDoctorEvidence): Promise<NuxtDoctorManifest>;
|
|
33
38
|
//#endregion
|
|
34
39
|
export { writeManifest as a, nuxtDoctorModule as i, collectNuxtDoctorExtensions as n, collectNuxtDoctorRulePacks as r, NuxtDoctorModuleOptions as t };
|
package/dist/nuxt.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as nuxtDoctorModule, t as NuxtDoctorModuleOptions } from "./module-
|
|
1
|
+
import { i as nuxtDoctorModule, t as NuxtDoctorModuleOptions } from "./module-B-h3EZka.mjs";
|
|
2
2
|
export { type NuxtDoctorModuleOptions, nuxtDoctorModule as default };
|
package/dist/nuxt.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { r as nuxtDoctorModule } from "./module
|
|
1
|
+
import { r as nuxtDoctorModule } from "./module--Dgf9XPW.mjs";
|
|
2
2
|
export { nuxtDoctorModule as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as defineDoctorExtension, n as createReport } from "./core-
|
|
2
|
-
import { n as shouldFailDoctorRun, t as runViteDoctor } from "./doctor-
|
|
1
|
+
import { f as defineDoctorExtension, n as createReport } from "./core-jvU53IG0.mjs";
|
|
2
|
+
import { n as shouldFailDoctorRun, t as runViteDoctor } from "./doctor-CPU6PJkE.mjs";
|
|
3
3
|
import { resolve } from "pathe";
|
|
4
4
|
//#region src/plugin.ts
|
|
5
5
|
function doctor(options = {}) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as DoctorExtension } from "./primitives-
|
|
2
|
-
import { n as DoctorRunOptions, t as DoctorConfig } from "./config-
|
|
3
|
-
import "./index-
|
|
1
|
+
import { t as DoctorExtension } from "./primitives-BB8AakLb.mjs";
|
|
2
|
+
import { n as DoctorRunOptions, t as DoctorConfig } from "./config-GYUYW1FL.mjs";
|
|
3
|
+
import "./index-CpbGR6NE.mjs";
|
|
4
4
|
import { Plugin } from "vite";
|
|
5
5
|
//#region src/plugin.d.ts
|
|
6
6
|
interface ViteDoctorSurfaceOptions {
|
package/dist/plugin.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as doctor, t as ViteDoctorSurfaceOptions } from "./plugin-
|
|
1
|
+
import { n as doctor, t as ViteDoctorSurfaceOptions } from "./plugin-C3bX7b3u.mjs";
|
|
2
2
|
export { ViteDoctorSurfaceOptions, doctor };
|
package/dist/plugin.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as doctor } from "./plugin-
|
|
1
|
+
import { t as doctor } from "./plugin-BUgSIN2M.mjs";
|
|
2
2
|
export { doctor };
|