@remylagerweij/vue-doctor 2.0.0 → 2.0.1
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.js +49 -46
- package/dist/{diagnose-DSozxZ0-.js → diagnose-BdHGmTpm.js} +3 -2
- package/dist/diagnose-CGPcvfhI.js +3 -0
- package/dist/{discover-project-C0n-wTpF.js → discover-project-Bgz3pq6f.js} +3 -51
- package/dist/{discover-project-NDbR7YIn.js → discover-project-CDEFT0XH.js} +1 -1
- package/dist/find-monorepo-root-DePS93uu.js +53 -0
- package/dist/find-monorepo-root-DhN-SSup.js +3 -0
- package/dist/index.d.ts +13 -13
- package/dist/index.js +1 -1
- package/dist/{list-source-files-BpaHm1-R.js → list-source-files-CUakQejy.js} +1 -1
- package/dist/{rules-Cv8YQ738.js → rules-BTNz1N64.js} +2 -2
- package/dist/{runner-CPsa1irw.js → runner-CRvgMfVK.js} +2 -2
- package/dist/{server-CXe6F5YL.js → server-BdR8FjL9.js} +3 -3
- package/package.json +2 -2
- package/dist/diagnose-Uhhk0XM9.js +0 -3
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as logger, c as getToolVersions, d as loadConfig, i as configureLogger, l as mapWithConcurrency, n as diagnose, o as output, r as createKnipSession, s as highlighter, t as NoVueDependencyError, u as createPrivateTempDirectory } from "./diagnose-
|
|
2
|
+
import { a as logger, c as getToolVersions, d as loadConfig, i as configureLogger, l as mapWithConcurrency, n as diagnose, o as output, r as createKnipSession, s as highlighter, t as NoVueDependencyError, u as createPrivateTempDirectory } from "./diagnose-BdHGmTpm.js";
|
|
3
3
|
import { _ as getCanonicalRuleId, d as PLUGIN_NAME, f as RULE_REGISTRY, i as createBaseline, l as ruleIdOf, n as DEFAULT_BASELINE_FILENAME, o as writeBaseline, y as getRuleMeta } from "./baseline-BKB_9B33.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { n as isMonorepoRoot } from "./find-monorepo-root-DePS93uu.js";
|
|
5
|
+
import { c as listWorkspacePackages, f as MILLISECONDS_PER_SECOND, g as VERSION$1, i as getRootPackage, n as discoverVueSubprojects, r as formatFrameworkName, t as discoverProject } from "./discover-project-Bgz3pq6f.js";
|
|
6
|
+
import { a as filterSourceFiles, c as EXIT_CODES, d as evaluateGate, l as FAIL_ON_VALUES, n as registerExplainCommand, o as getDiffInfo, r as registerRulesCommand, s as docsUrl, u as GATE_SCOPE_VALUES } from "./rules-BTNz1N64.js";
|
|
6
7
|
import { n as REPORT_SCHEMA_URL, t as REPORT_FORMAT } from "./constants-CeYU52R7.js";
|
|
7
8
|
import fs from "node:fs";
|
|
8
9
|
import path from "node:path";
|
|
@@ -1823,8 +1824,8 @@ const createBatchProgressReporter = async (options) => {
|
|
|
1823
1824
|
//#region src/scan.ts
|
|
1824
1825
|
const printProjectDetection = (projectInfo, isDiffMode, includePaths) => {
|
|
1825
1826
|
const lines = [];
|
|
1826
|
-
const title = `${pc.bold(pc.green("Vue Doctor"))} ${pc.dim("v2.0.
|
|
1827
|
-
lines.push(createFramedLine(`Vue Doctor v2.0.
|
|
1827
|
+
const title = `${pc.bold(pc.green("Vue Doctor"))} ${pc.dim("v2.0.1")}`;
|
|
1828
|
+
lines.push(createFramedLine(`Vue Doctor v2.0.1`, title));
|
|
1828
1829
|
const vueVersionDisplay = projectInfo.vueVersion ? `Vue ${projectInfo.vueVersion}` : "Vue";
|
|
1829
1830
|
const frameworkDisplay = formatFrameworkName(projectInfo.framework);
|
|
1830
1831
|
const projectLine = `${projectInfo.projectName} · ${frameworkDisplay} · ${vueVersionDisplay}`;
|
|
@@ -2067,6 +2068,22 @@ const scanProjects = async (projects, concurrency = resolveScanConcurrency(proje
|
|
|
2067
2068
|
return outcomes;
|
|
2068
2069
|
};
|
|
2069
2070
|
//#endregion
|
|
2071
|
+
//#region src/utils/find-source-root.ts
|
|
2072
|
+
/**
|
|
2073
|
+
* The directory that SARIF `%SRCROOT%` stands for: the git repository root containing `directory`
|
|
2074
|
+
* (what GitHub code scanning resolves paths against), else the current working directory.
|
|
2075
|
+
*/
|
|
2076
|
+
const findSourceRoot = (directory) => {
|
|
2077
|
+
const result = spawnSync("git", ["rev-parse", "--show-toplevel"], {
|
|
2078
|
+
cwd: directory,
|
|
2079
|
+
encoding: "utf-8"
|
|
2080
|
+
});
|
|
2081
|
+
const topLevel = result.status === 0 ? result.stdout.trim() : "";
|
|
2082
|
+
return topLevel ? path.resolve(topLevel) : process.cwd();
|
|
2083
|
+
};
|
|
2084
|
+
/** POSIX path from the source root to `directory` (`""` when they are the same). */
|
|
2085
|
+
const relativeToSourceRoot = (directory) => path.relative(findSourceRoot(directory), path.resolve(directory)).split(path.sep).join("/");
|
|
2086
|
+
//#endregion
|
|
2070
2087
|
//#region src/ci/github-client.ts
|
|
2071
2088
|
var GitHubClient = class {
|
|
2072
2089
|
token;
|
|
@@ -2159,7 +2176,7 @@ var GitHubClient = class {
|
|
|
2159
2176
|
* Extracts the marker ID from a comment body if present.
|
|
2160
2177
|
*/
|
|
2161
2178
|
const extractFindingMarker = (body) => {
|
|
2162
|
-
const match = body.match(/<!-- vue-doctor:finding:([a-zA-Z0-9_
|
|
2179
|
+
const match = body.match(/<!-- vue-doctor:finding:([a-zA-Z0-9_-]+) -->/);
|
|
2163
2180
|
return match ? match[1] : null;
|
|
2164
2181
|
};
|
|
2165
2182
|
/**
|
|
@@ -2191,7 +2208,7 @@ const groupFindings = (findings, grouping, agentPrompt) => {
|
|
|
2191
2208
|
groups.set(key, list);
|
|
2192
2209
|
}
|
|
2193
2210
|
const commentGroups = [];
|
|
2194
|
-
for (const
|
|
2211
|
+
for (const groupList of groups.values()) {
|
|
2195
2212
|
const first = groupList[0];
|
|
2196
2213
|
const markerId = sanitizeMarkerId(grouping === "rule-per-file" ? `${first.file}::${first.ruleId}` : `rule::${first.ruleId}`);
|
|
2197
2214
|
const lines = [
|
|
@@ -2242,7 +2259,11 @@ const postStickySummary = async (client, options, report) => {
|
|
|
2242
2259
|
*/
|
|
2243
2260
|
const postReviewComments = async (client, options, report) => {
|
|
2244
2261
|
if (!options.pullNumber) return;
|
|
2245
|
-
const
|
|
2262
|
+
const prefix = options.sourceRootPrefix ?? "";
|
|
2263
|
+
const allFindings = report.projects.flatMap((p) => p.findings.map((finding) => ({
|
|
2264
|
+
...finding,
|
|
2265
|
+
file: toRepoPath(prefix, p.root, finding.file)
|
|
2266
|
+
})));
|
|
2246
2267
|
const activeGroups = groupFindings(allFindings, options.grouping, options.agentPrompt).slice(0, options.maxComments);
|
|
2247
2268
|
const activeMarkers = new Set(activeGroups.map((g) => g.marker));
|
|
2248
2269
|
const existingComments = await client.listReviewComments(options.owner, options.repo, options.pullNumber);
|
|
@@ -2300,17 +2321,11 @@ const postCommitStatus = async (client, options, report, passedGate) => {
|
|
|
2300
2321
|
});
|
|
2301
2322
|
};
|
|
2302
2323
|
/**
|
|
2303
|
-
* Emits inline GitHub Action workflow annotations to stdout
|
|
2324
|
+
* Emits inline GitHub Action workflow annotations to stdout, with repository-relative paths.
|
|
2304
2325
|
*/
|
|
2305
|
-
const emitAnnotations = (report) => {
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
const file = finding.file;
|
|
2309
|
-
const line = finding.line > 0 ? finding.line : 1;
|
|
2310
|
-
const col = finding.column > 0 ? finding.column : 1;
|
|
2311
|
-
const msg = `[${finding.ruleId}] ${finding.message}`;
|
|
2312
|
-
console.log(`::${level} file=${file},line=${line},col=${col}::${msg}`);
|
|
2313
|
-
}
|
|
2326
|
+
const emitAnnotations = (report, sourceRootPrefix = "") => {
|
|
2327
|
+
const output = formatGithub(report, { sourceRootPrefix });
|
|
2328
|
+
if (output) process.stdout.write(output.endsWith("\n") ? output : `${output}\n`);
|
|
2314
2329
|
};
|
|
2315
2330
|
//#endregion
|
|
2316
2331
|
//#region src/ci/score-cache.ts
|
|
@@ -2499,7 +2514,7 @@ const writeGitHubOutput = (key, value) => {
|
|
|
2499
2514
|
};
|
|
2500
2515
|
const registerCiCommand = (program) => {
|
|
2501
2516
|
const ci = program.command("ci").description("CI automation, GitHub Actions integration and PR feedback");
|
|
2502
|
-
ci.command("run").description("Execute CI scan with gate evaluation, reports and optional PR feedback").argument("[directory]", "Directory to scan", ".").option("--scope <scope>", "Scope: changed, lines, or full"
|
|
2517
|
+
ci.command("run").description("Execute CI scan with gate evaluation, reports and optional PR feedback").argument("[directory]", "Directory to scan", ".").option("--scope <scope>", "Scope: changed, lines, or full").addOption(new Option("--fail-on <severity>", "Gate severity").choices(FAIL_ON_VALUES).default("error")).addOption(new Option("--gate <scope>", "Gate scope").choices(GATE_SCOPE_VALUES).default("new")).option("--min-score <score>", "Fail if score is below this threshold", Number).option("--strict", "Strict gate: analyzer failures fail the gate", false).option("--feedback <modes>", "Feedback modes comma-separated: summary,findings,annotations,none", "summary,findings").addOption(new Option("--grouping <grouping>", "PR comments grouping").choices([
|
|
2503
2518
|
"finding",
|
|
2504
2519
|
"rule-per-file",
|
|
2505
2520
|
"rule"
|
|
@@ -2515,7 +2530,8 @@ const registerCiCommand = (program) => {
|
|
|
2515
2530
|
const scope = options.scope ?? (isPr ? "changed" : "full");
|
|
2516
2531
|
let changedFiles;
|
|
2517
2532
|
if (scope === "changed" || scope === "lines") {
|
|
2518
|
-
const
|
|
2533
|
+
const baseRef = process.env.GITHUB_BASE_REF?.trim() || void 0;
|
|
2534
|
+
const diffInfo = getDiffInfo(projectDir, baseRef);
|
|
2519
2535
|
if (diffInfo.status === "ok") {
|
|
2520
2536
|
changedFiles = filterSourceFiles(diffInfo.changedFiles);
|
|
2521
2537
|
logger.log(`Scanning ${changedFiles.length} changed files...`);
|
|
@@ -2590,7 +2606,8 @@ const registerCiCommand = (program) => {
|
|
|
2590
2606
|
if (sarifPath) writeGitHubOutput("sarif-path", sarifPath);
|
|
2591
2607
|
if (reportPath) writeGitHubOutput("report-path", reportPath);
|
|
2592
2608
|
const feedbackModes = (options.feedback ?? "summary,findings").split(",").map((m) => m.trim().toLowerCase());
|
|
2593
|
-
|
|
2609
|
+
const sourceRootPrefix = relativeToSourceRoot(projectDir);
|
|
2610
|
+
if (feedbackModes.includes("annotations")) emitAnnotations(report, sourceRootPrefix);
|
|
2594
2611
|
const token = options.githubToken ?? process.env.GITHUB_TOKEN;
|
|
2595
2612
|
const repoFullName = process.env.GITHUB_REPOSITORY;
|
|
2596
2613
|
const prNumberStr = process.env.GITHUB_REF_NAME?.split("/")[0] || process.env.PR_NUMBER;
|
|
@@ -2609,7 +2626,8 @@ const registerCiCommand = (program) => {
|
|
|
2609
2626
|
pullNumber: prNumber && !Number.isNaN(prNumber) ? prNumber : void 0,
|
|
2610
2627
|
commitSha,
|
|
2611
2628
|
scoreDelta: deltaInfo.scoreDelta ?? void 0,
|
|
2612
|
-
baseScore: deltaInfo.baseScore ?? void 0
|
|
2629
|
+
baseScore: deltaInfo.baseScore ?? void 0,
|
|
2630
|
+
sourceRootPrefix
|
|
2613
2631
|
};
|
|
2614
2632
|
if (feedbackModes.includes("summary") && feedbackOpts.pullNumber) await postStickySummary(client, feedbackOpts, report);
|
|
2615
2633
|
if (feedbackModes.includes("findings") && feedbackOpts.pullNumber) await postReviewComments(client, feedbackOpts, report);
|
|
@@ -2943,15 +2961,16 @@ const registerInitCommand = (program) => {
|
|
|
2943
2961
|
const projectDir = path.resolve(directoryArg);
|
|
2944
2962
|
const isInteractive = Boolean(process.stdin.isTTY) && !options.yes;
|
|
2945
2963
|
const clack = isInteractive ? await import("@clack/prompts") : null;
|
|
2946
|
-
const { discoverProject, formatFrameworkName } = await import("./discover-project-
|
|
2964
|
+
const { discoverProject, formatFrameworkName } = await import("./discover-project-CDEFT0XH.js");
|
|
2965
|
+
const { isMonorepoRoot } = await import("./find-monorepo-root-DhN-SSup.js");
|
|
2947
2966
|
const projectInfo = discoverProject(projectDir);
|
|
2948
2967
|
if (isInteractive && clack) {
|
|
2949
2968
|
clack.intro("🩺 Vue Doctor Setup Wizard");
|
|
2950
2969
|
const details = [
|
|
2951
2970
|
formatFrameworkName(projectInfo.framework),
|
|
2952
2971
|
projectInfo.vueVersion ? `Vue ${projectInfo.vueVersion}` : null,
|
|
2953
|
-
projectInfo.
|
|
2954
|
-
|
|
2972
|
+
projectInfo.hasTypeScript ? "TypeScript" : null,
|
|
2973
|
+
isMonorepoRoot(projectDir) ? "Monorepo" : null
|
|
2955
2974
|
].filter(Boolean).join(" · ");
|
|
2956
2975
|
clack.note(details || "Vue project detected", "Project Detection");
|
|
2957
2976
|
}
|
|
@@ -3033,7 +3052,7 @@ const registerInitCommand = (program) => {
|
|
|
3033
3052
|
}
|
|
3034
3053
|
createBaselineSnapshot = Boolean(baselineChoice);
|
|
3035
3054
|
}
|
|
3036
|
-
const configFileName = `vue-doctor.config.${projectInfo.
|
|
3055
|
+
const configFileName = `vue-doctor.config.${projectInfo.hasTypeScript ? "ts" : "js"}`;
|
|
3037
3056
|
const configPath = path.join(projectDir, configFileName);
|
|
3038
3057
|
let shouldWriteConfig = true;
|
|
3039
3058
|
if (fs.existsSync(configPath) && !options.force) {
|
|
@@ -3129,7 +3148,7 @@ const registerInitCommand = (program) => {
|
|
|
3129
3148
|
if (spinner) spinner.start("Scanning project to record baseline snapshot...");
|
|
3130
3149
|
else logger.log("Scanning project to record baseline snapshot...");
|
|
3131
3150
|
try {
|
|
3132
|
-
const { diagnose } = await import("./diagnose-
|
|
3151
|
+
const { diagnose } = await import("./diagnose-CGPcvfhI.js");
|
|
3133
3152
|
const { createBaseline, writeBaseline } = await import("./baseline-CvI0x3dv.js");
|
|
3134
3153
|
const baselineData = createBaseline((await diagnose(projectDir, { baseline: null })).diagnostics);
|
|
3135
3154
|
writeBaseline(path.join(projectDir, baselineFileName), baselineData);
|
|
@@ -3149,29 +3168,13 @@ const registerInitCommand = (program) => {
|
|
|
3149
3168
|
//#region src/commands/mcp.ts
|
|
3150
3169
|
const registerMcpCommand = (program) => {
|
|
3151
3170
|
program.command("mcp").description("Start Model Context Protocol (MCP) server over stdio for AI agents").action(async () => {
|
|
3152
|
-
const { McpServer } = await import("./server-
|
|
3171
|
+
const { McpServer } = await import("./server-BdR8FjL9.js");
|
|
3153
3172
|
new McpServer().startStdio();
|
|
3154
3173
|
});
|
|
3155
3174
|
};
|
|
3156
3175
|
//#endregion
|
|
3157
|
-
//#region src/utils/find-source-root.ts
|
|
3158
|
-
/**
|
|
3159
|
-
* The directory that SARIF `%SRCROOT%` stands for: the git repository root containing `directory`
|
|
3160
|
-
* (what GitHub code scanning resolves paths against), else the current working directory.
|
|
3161
|
-
*/
|
|
3162
|
-
const findSourceRoot = (directory) => {
|
|
3163
|
-
const result = spawnSync("git", ["rev-parse", "--show-toplevel"], {
|
|
3164
|
-
cwd: directory,
|
|
3165
|
-
encoding: "utf-8"
|
|
3166
|
-
});
|
|
3167
|
-
const topLevel = result.status === 0 ? result.stdout.trim() : "";
|
|
3168
|
-
return topLevel ? path.resolve(topLevel) : process.cwd();
|
|
3169
|
-
};
|
|
3170
|
-
/** POSIX path from the source root to `directory` (`""` when they are the same). */
|
|
3171
|
-
const relativeToSourceRoot = (directory) => path.relative(findSourceRoot(directory), path.resolve(directory)).split(path.sep).join("/");
|
|
3172
|
-
//#endregion
|
|
3173
3176
|
//#region src/program.ts
|
|
3174
|
-
const VERSION = "2.0.
|
|
3177
|
+
const VERSION = "2.0.1";
|
|
3175
3178
|
const parseScore = (value) => {
|
|
3176
3179
|
const score = Number(value);
|
|
3177
3180
|
if (!Number.isInteger(score) || score < 0 || score > 100) throw new InvalidArgumentError("Expected an integer between 0 and 100.");
|
|
@@ -3225,7 +3228,7 @@ const createProgram = () => {
|
|
|
3225
3228
|
const legacyHtmlReport = options.report === true;
|
|
3226
3229
|
if (legacyHtmlReport) logger.warn("--report is deprecated and will be removed in a future release; use --format html --output <file>.");
|
|
3227
3230
|
if (options.fix) {
|
|
3228
|
-
const { runFixes } = await import("./runner-
|
|
3231
|
+
const { runFixes } = await import("./runner-CRvgMfVK.js");
|
|
3229
3232
|
for (const projectDirectory of projectDirectories) {
|
|
3230
3233
|
const fixReport = runFixes(projectDirectory, { dryRun: options.dryRun });
|
|
3231
3234
|
if (options.dryRun) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { S as CUSTOM_TEMPLATE_RULES, a as readBaseline, b as toDiagnosticRule, c as resolveRuleKey, d as PLUGIN_NAME, g as createTemplateRuleConfig, h as createOxlintConfig, l as ruleIdOf, m as createCustomTemplateRuleConfig, r as applyBaseline, s as createRuleIdReporter, u as AUDIT_RULES, v as getEnabledFsRules, x as CUSTOM_TEMPLATE_PLUGIN_NAME, y as getRuleMeta } from "./baseline-BKB_9B33.js";
|
|
3
|
-
import { i as normalizeRelativePath, n as isInsideAnyDirectory, r as listProjectSourceFiles, t as LINTABLE_FILE_PATTERN } from "./list-source-files-
|
|
4
|
-
import {
|
|
3
|
+
import { i as normalizeRelativePath, n as isInsideAnyDirectory, r as listProjectSourceFiles, t as LINTABLE_FILE_PATTERN } from "./list-source-files-CUakQejy.js";
|
|
4
|
+
import { n as isMonorepoRoot, r as readPackageJson, t as findMonorepoRoot } from "./find-monorepo-root-DePS93uu.js";
|
|
5
|
+
import { _ as VUE_FILE_PATTERN, c as listWorkspacePackages, d as ERROR_RULE_PENALTY, o as listNestedWorkspaceDirectories, p as OXLINT_NODE_REQUIREMENT, s as listWorkspaceDirectories, t as discoverProject, v as WARNING_RULE_PENALTY } from "./discover-project-Bgz3pq6f.js";
|
|
5
6
|
import { createRequire } from "node:module";
|
|
6
7
|
import fs from "node:fs";
|
|
7
8
|
import path from "node:path";
|
|
@@ -1,56 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { n as isMonorepoRoot, r as readPackageJson, t as findMonorepoRoot } from "./find-monorepo-root-DePS93uu.js";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import { spawnSync } from "node:child_process";
|
|
5
|
-
//#region src/utils/read-package-json.ts
|
|
6
|
-
const packageJsonCache = /* @__PURE__ */ new Map();
|
|
7
|
-
/**
|
|
8
|
-
* Reads and parses a `package.json` (`{}` when it does not exist). Within a process the parsed
|
|
9
|
-
* result is reused, but only while the file's modification time and size are unchanged, so a
|
|
10
|
-
* manifest edited between two `diagnose()` calls (or by a test) is always re-read. Callers must
|
|
11
|
-
* treat the result as read-only. Invalid JSON throws and is never cached.
|
|
12
|
-
*/
|
|
13
|
-
const readPackageJson = (packageJsonPath) => {
|
|
14
|
-
let stats;
|
|
15
|
-
try {
|
|
16
|
-
stats = fs.statSync(packageJsonPath);
|
|
17
|
-
} catch {
|
|
18
|
-
packageJsonCache.delete(packageJsonPath);
|
|
19
|
-
return {};
|
|
20
|
-
}
|
|
21
|
-
const cached = packageJsonCache.get(packageJsonPath);
|
|
22
|
-
if (cached && cached.mtimeMs === stats.mtimeMs && cached.size === stats.size) return cached.value;
|
|
23
|
-
const value = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
24
|
-
packageJsonCache.set(packageJsonPath, {
|
|
25
|
-
mtimeMs: stats.mtimeMs,
|
|
26
|
-
size: stats.size,
|
|
27
|
-
value
|
|
28
|
-
});
|
|
29
|
-
return value;
|
|
30
|
-
};
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/utils/find-monorepo-root.ts
|
|
33
|
-
const isMonorepoRoot = (directory) => {
|
|
34
|
-
const packageJsonPath = path.join(directory, "package.json");
|
|
35
|
-
if (!fs.existsSync(packageJsonPath)) return false;
|
|
36
|
-
const pnpmWorkspacePath = path.join(directory, "pnpm-workspace.yaml");
|
|
37
|
-
if (fs.existsSync(pnpmWorkspacePath)) return true;
|
|
38
|
-
try {
|
|
39
|
-
return Boolean(readPackageJson(packageJsonPath).workspaces);
|
|
40
|
-
} catch {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const findMonorepoRoot = (directory) => {
|
|
45
|
-
let currentDirectory = path.resolve(directory);
|
|
46
|
-
while (true) {
|
|
47
|
-
const parentDirectory = path.dirname(currentDirectory);
|
|
48
|
-
if (parentDirectory === currentDirectory) return null;
|
|
49
|
-
currentDirectory = parentDirectory;
|
|
50
|
-
if (isMonorepoRoot(currentDirectory)) return currentDirectory;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
//#endregion
|
|
54
6
|
//#region src/constants.ts
|
|
55
7
|
const DOCS_BASE_URL = "https://remylagerweij.github.io/vue-doctor";
|
|
56
8
|
const SOURCE_FILE_PATTERN = /\.(vue|tsx?|jsx?|mjs|cjs)$/;
|
|
@@ -61,7 +13,7 @@ const SPAWN_ARGS_MAX_LENGTH_CHARS = 24e3;
|
|
|
61
13
|
const DEFAULT_BRANCH_CANDIDATES = ["main", "master"];
|
|
62
14
|
const ERROR_RULE_PENALTY = 1.5;
|
|
63
15
|
const WARNING_RULE_PENALTY = .75;
|
|
64
|
-
const VERSION = "2.0.
|
|
16
|
+
const VERSION = "2.0.1";
|
|
65
17
|
const OXLINT_NODE_REQUIREMENT = "^22.12.0 || >=24.0.0";
|
|
66
18
|
//#endregion
|
|
67
19
|
//#region src/utils/discover-project.ts
|
|
@@ -307,4 +259,4 @@ const discoverProject = (directory) => {
|
|
|
307
259
|
};
|
|
308
260
|
};
|
|
309
261
|
//#endregion
|
|
310
|
-
export { VUE_FILE_PATTERN as _, hasVueDependency as a,
|
|
262
|
+
export { VUE_FILE_PATTERN as _, hasVueDependency as a, listWorkspacePackages as c, ERROR_RULE_PENALTY as d, MILLISECONDS_PER_SECOND as f, VERSION as g, SPAWN_ARGS_MAX_LENGTH_CHARS as h, getRootPackage as i, DEFAULT_BRANCH_CANDIDATES as l, SOURCE_FILE_PATTERN as m, discoverVueSubprojects as n, listNestedWorkspaceDirectories as o, OXLINT_NODE_REQUIREMENT as p, formatFrameworkName as r, listWorkspaceDirectories as s, discoverProject as t, DOCS_BASE_URL as u, WARNING_RULE_PENALTY as v };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
//#region src/utils/read-package-json.ts
|
|
5
|
+
const packageJsonCache = /* @__PURE__ */ new Map();
|
|
6
|
+
/**
|
|
7
|
+
* Reads and parses a `package.json` (`{}` when it does not exist). Within a process the parsed
|
|
8
|
+
* result is reused, but only while the file's modification time and size are unchanged, so a
|
|
9
|
+
* manifest edited between two `diagnose()` calls (or by a test) is always re-read. Callers must
|
|
10
|
+
* treat the result as read-only. Invalid JSON throws and is never cached.
|
|
11
|
+
*/
|
|
12
|
+
const readPackageJson = (packageJsonPath) => {
|
|
13
|
+
let stats;
|
|
14
|
+
try {
|
|
15
|
+
stats = fs.statSync(packageJsonPath);
|
|
16
|
+
} catch {
|
|
17
|
+
packageJsonCache.delete(packageJsonPath);
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
const cached = packageJsonCache.get(packageJsonPath);
|
|
21
|
+
if (cached && cached.mtimeMs === stats.mtimeMs && cached.size === stats.size) return cached.value;
|
|
22
|
+
const value = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
23
|
+
packageJsonCache.set(packageJsonPath, {
|
|
24
|
+
mtimeMs: stats.mtimeMs,
|
|
25
|
+
size: stats.size,
|
|
26
|
+
value
|
|
27
|
+
});
|
|
28
|
+
return value;
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/utils/find-monorepo-root.ts
|
|
32
|
+
const isMonorepoRoot = (directory) => {
|
|
33
|
+
const packageJsonPath = path.join(directory, "package.json");
|
|
34
|
+
if (!fs.existsSync(packageJsonPath)) return false;
|
|
35
|
+
const pnpmWorkspacePath = path.join(directory, "pnpm-workspace.yaml");
|
|
36
|
+
if (fs.existsSync(pnpmWorkspacePath)) return true;
|
|
37
|
+
try {
|
|
38
|
+
return Boolean(readPackageJson(packageJsonPath).workspaces);
|
|
39
|
+
} catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const findMonorepoRoot = (directory) => {
|
|
44
|
+
let currentDirectory = path.resolve(directory);
|
|
45
|
+
while (true) {
|
|
46
|
+
const parentDirectory = path.dirname(currentDirectory);
|
|
47
|
+
if (parentDirectory === currentDirectory) return null;
|
|
48
|
+
currentDirectory = parentDirectory;
|
|
49
|
+
if (isMonorepoRoot(currentDirectory)) return currentDirectory;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
export { isMonorepoRoot as n, readPackageJson as r, findMonorepoRoot as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,49 +7,49 @@ import { z } from "zod";
|
|
|
7
7
|
*/
|
|
8
8
|
declare const PRESET_NAMES: readonly ["vue-doctor/recommended", "vue-doctor/strict", "vue-doctor/security"];
|
|
9
9
|
declare const severitySchema: z.ZodEnum<{
|
|
10
|
+
error: "error";
|
|
10
11
|
off: "off";
|
|
11
12
|
warn: "warn";
|
|
12
13
|
warning: "warning";
|
|
13
|
-
error: "error";
|
|
14
14
|
}>;
|
|
15
15
|
declare const ruleEntrySchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
16
|
+
error: "error";
|
|
16
17
|
off: "off";
|
|
17
18
|
warn: "warn";
|
|
18
19
|
warning: "warning";
|
|
19
|
-
error: "error";
|
|
20
20
|
}>, z.ZodTuple<[z.ZodEnum<{
|
|
21
|
+
error: "error";
|
|
21
22
|
off: "off";
|
|
22
23
|
warn: "warn";
|
|
23
24
|
warning: "warning";
|
|
24
|
-
error: "error";
|
|
25
25
|
}>], null>, z.ZodTuple<[z.ZodEnum<{
|
|
26
|
+
error: "error";
|
|
26
27
|
off: "off";
|
|
27
28
|
warn: "warn";
|
|
28
29
|
warning: "warning";
|
|
29
|
-
error: "error";
|
|
30
30
|
}>, z.ZodRecord<z.ZodString, z.ZodUnknown>], null>]>;
|
|
31
31
|
declare const configSchema: z.ZodObject<{
|
|
32
32
|
$schema: z.ZodOptional<z.ZodString>;
|
|
33
33
|
extends: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
34
34
|
"vue-doctor/recommended": "vue-doctor/recommended";
|
|
35
|
-
"vue-doctor/strict": "vue-doctor/strict";
|
|
36
35
|
"vue-doctor/security": "vue-doctor/security";
|
|
36
|
+
"vue-doctor/strict": "vue-doctor/strict";
|
|
37
37
|
}>>>;
|
|
38
38
|
rules: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodEnum<{
|
|
39
|
+
error: "error";
|
|
39
40
|
off: "off";
|
|
40
41
|
warn: "warn";
|
|
41
42
|
warning: "warning";
|
|
42
|
-
error: "error";
|
|
43
43
|
}>, z.ZodTuple<[z.ZodEnum<{
|
|
44
|
+
error: "error";
|
|
44
45
|
off: "off";
|
|
45
46
|
warn: "warn";
|
|
46
47
|
warning: "warning";
|
|
47
|
-
error: "error";
|
|
48
48
|
}>], null>, z.ZodTuple<[z.ZodEnum<{
|
|
49
|
+
error: "error";
|
|
49
50
|
off: "off";
|
|
50
51
|
warn: "warn";
|
|
51
52
|
warning: "warning";
|
|
52
|
-
error: "error";
|
|
53
53
|
}>, z.ZodRecord<z.ZodString, z.ZodUnknown>], null>]>>>;
|
|
54
54
|
ignore: z.ZodOptional<z.ZodObject<{
|
|
55
55
|
files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -57,13 +57,13 @@ declare const configSchema: z.ZodObject<{
|
|
|
57
57
|
}, z.core.$strict>>;
|
|
58
58
|
gate: z.ZodOptional<z.ZodObject<{
|
|
59
59
|
failOn: z.ZodOptional<z.ZodEnum<{
|
|
60
|
-
warning: "warning";
|
|
61
60
|
error: "error";
|
|
62
61
|
none: "none";
|
|
62
|
+
warning: "warning";
|
|
63
63
|
}>>;
|
|
64
64
|
scope: z.ZodOptional<z.ZodEnum<{
|
|
65
|
-
new: "new";
|
|
66
65
|
all: "all";
|
|
66
|
+
new: "new";
|
|
67
67
|
}>>;
|
|
68
68
|
minScore: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
69
69
|
strict: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -74,15 +74,15 @@ declare const configSchema: z.ZodObject<{
|
|
|
74
74
|
baseline: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
75
75
|
pr: z.ZodOptional<z.ZodObject<{
|
|
76
76
|
modes: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
77
|
-
none: "none";
|
|
78
|
-
summary: "summary";
|
|
79
77
|
annotations: "annotations";
|
|
80
78
|
findings: "findings";
|
|
79
|
+
none: "none";
|
|
80
|
+
summary: "summary";
|
|
81
81
|
}>>>;
|
|
82
82
|
grouping: z.ZodOptional<z.ZodEnum<{
|
|
83
83
|
finding: "finding";
|
|
84
|
-
"rule-per-file": "rule-per-file";
|
|
85
84
|
rule: "rule";
|
|
85
|
+
"rule-per-file": "rule-per-file";
|
|
86
86
|
}>>;
|
|
87
87
|
maxComments: z.ZodOptional<z.ZodNumber>;
|
|
88
88
|
agentPrompt: z.ZodOptional<z.ZodBoolean>;
|
package/dist/index.js
CHANGED
|
@@ -7020,7 +7020,7 @@ const SKIPPED_DIRECTORY_NAMES = /* @__PURE__ */ new Set([
|
|
|
7020
7020
|
"out"
|
|
7021
7021
|
]);
|
|
7022
7022
|
const GIT_LIST_MAX_BUFFER_BYTES$1 = 268435456;
|
|
7023
|
-
const normalizeRelativePath = (filePath) => path.normalize(filePath
|
|
7023
|
+
const normalizeRelativePath = (filePath) => path.posix.normalize(filePath.replace(/\\/g, "/"));
|
|
7024
7024
|
const listFilesWithGit = (rootDirectory) => {
|
|
7025
7025
|
const result = spawnSync("git", [
|
|
7026
7026
|
"ls-files",
|
|
@@ -13,7 +13,7 @@ const SKIPPED_DIRECTORY_NAMES = /* @__PURE__ */ new Set([
|
|
|
13
13
|
"out"
|
|
14
14
|
]);
|
|
15
15
|
const GIT_LIST_MAX_BUFFER_BYTES = 268435456;
|
|
16
|
-
const normalizeRelativePath = (filePath) => path.normalize(filePath
|
|
16
|
+
const normalizeRelativePath = (filePath) => path.posix.normalize(filePath.replace(/\\/g, "/"));
|
|
17
17
|
const listFilesWithGit = (rootDirectory) => {
|
|
18
18
|
const result = spawnSync("git", [
|
|
19
19
|
"ls-files",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as logger } from "./diagnose-
|
|
2
|
+
import { a as logger } from "./diagnose-BdHGmTpm.js";
|
|
3
3
|
import { _ as getCanonicalRuleId, f as RULE_REGISTRY, p as categorySlug } from "./baseline-BKB_9B33.js";
|
|
4
|
-
import { l as DEFAULT_BRANCH_CANDIDATES, m as SOURCE_FILE_PATTERN, u as DOCS_BASE_URL } from "./discover-project-
|
|
4
|
+
import { l as DEFAULT_BRANCH_CANDIDATES, m as SOURCE_FILE_PATTERN, u as DOCS_BASE_URL } from "./discover-project-Bgz3pq6f.js";
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { spawnSync } from "node:child_process";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { r as listProjectSourceFiles } from "./list-source-files-
|
|
2
|
+
import { r as listProjectSourceFiles } from "./list-source-files-CUakQejy.js";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
//#region src/fix/codemods.ts
|
|
@@ -80,7 +80,7 @@ const fixTargetBlankRel = (source) => {
|
|
|
80
80
|
const fixVForKey = (source) => {
|
|
81
81
|
let fixed = false;
|
|
82
82
|
return {
|
|
83
|
-
code: source.replace(/<([a-zA-Z0-9_
|
|
83
|
+
code: source.replace(/<([a-zA-Z0-9_-]+)\b([^>]*\bv-for\s*=\s*["']([^"']+)["'][^>]*)>/gi, (fullTag, tagName, attrs, vForExpr) => {
|
|
84
84
|
if (/(?:^|\s)(?::key|v-bind:key|key)\s*=/i.test(attrs)) return fullTag;
|
|
85
85
|
fixed = true;
|
|
86
86
|
const match = /^\s*(?:\(\s*([a-zA-Z0-9_$]+)|\s*([a-zA-Z0-9_$]+))/i.exec(vForExpr);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as diagnose } from "./diagnose-
|
|
2
|
+
import { n as diagnose } from "./diagnose-BdHGmTpm.js";
|
|
3
3
|
import { _ as getCanonicalRuleId, f as RULE_REGISTRY } from "./baseline-BKB_9B33.js";
|
|
4
|
-
import { g as VERSION } from "./discover-project-
|
|
5
|
-
import { a as filterSourceFiles, i as toRuleInfo, o as getDiffInfo, t as findRuleMeta } from "./rules-
|
|
4
|
+
import { g as VERSION } from "./discover-project-Bgz3pq6f.js";
|
|
5
|
+
import { a as filterSourceFiles, i as toRuleInfo, o as getDiffInfo, t as findRuleMeta } from "./rules-BTNz1N64.js";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import readline from "node:readline";
|
|
8
8
|
//#region src/mcp/server.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remylagerweij/vue-doctor",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Diagnose and fix performance issues in your Vue.js app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"diagnostics",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"ajv-formats": "^3.0.1",
|
|
84
84
|
"happy-dom": "^20.14.5",
|
|
85
85
|
"tsdown": "^0.23.0",
|
|
86
|
-
"typescript": "^
|
|
86
|
+
"typescript": "^7.0.2"
|
|
87
87
|
},
|
|
88
88
|
"main": "./dist/index.js",
|
|
89
89
|
"types": "./dist/index.d.ts"
|