@remylagerweij/vue-doctor 2.0.0 → 2.0.2

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 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-DSozxZ0-.js";
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-DCDjxRw-.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 { b as isMonorepoRoot, 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-C0n-wTpF.js";
5
- 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-Cv8YQ738.js";
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-DrQCWqKC.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-B9fi0v2a.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";
@@ -578,6 +579,10 @@ const toTrustedUrl = (url, trustedBaseUrl) => {
578
579
  /** Keeps only characters that are safe inside an HTML comment marker (no `-`, so `-->` cannot occur). */
579
580
  const sanitizeMarkerId = (id) => id.replace(/[^A-Za-z0-9_.:]/g, "");
580
581
  const SUMMARY_MARKER = "<!-- vue-doctor:summary -->";
582
+ /** Sticky summary marker for one scanned directory; the repository root keeps the unscoped marker. */
583
+ const summaryMarker = (scope = "") => scope ? `<!-- vue-doctor:summary:${sanitizeMarkerScope(scope)} -->` : SUMMARY_MARKER;
584
+ /** Keeps a repository path usable inside an HTML comment marker. */
585
+ const sanitizeMarkerScope = (scope) => scope.replace(/[^A-Za-z0-9_./@-]/g, "");
581
586
  const DEFAULT_MAX_FINDINGS = 50;
582
587
  const DEFAULT_MAX_FINDINGS_PER_RULE = 10;
583
588
  /** Room kept for the "not shown" notice and closing tags when the findings list is cut. */
@@ -615,11 +620,11 @@ const renderCategoryTable = (project) => {
615
620
  ""
616
621
  ];
617
622
  };
618
- const renderProjectSummary = (project, heading, docsBaseUrl) => {
623
+ const renderProjectSummary = (project, heading, docsBaseUrl, scope = "") => {
619
624
  const { score } = project;
620
625
  const lines = [];
621
626
  const scoreText = `${scoreIcon(score.value)} **${score.value}/100** (${escapeMarkdown(score.label)})`;
622
- if (heading === null) lines.push(`## 🩺 Vue Doctor: ${scoreText}`, "");
627
+ if (heading === null) lines.push(`## 🩺 Vue Doctor${scope ? ` (${markdownCode(scope)})` : ""}: ${scoreText}`, "");
623
628
  else lines.push(`### ${escapeMarkdown(heading)}: ${scoreText}`, "");
624
629
  if (score.cap) lines.push(`> **Score capped at ${score.cap.value}** (${score.rawScore} before the cap) because of a ${CAP_REASONS[score.cap.reason]} in ${markdownCode(score.cap.ruleId)}.`, "");
625
630
  const counts = [plural$1(project.summary.errors, "error"), plural$1(project.summary.warnings, "warning")];
@@ -647,8 +652,8 @@ const renderProjectSummary = (project, heading, docsBaseUrl) => {
647
652
  const renderMarkdownSummary = (report, options = {}) => {
648
653
  const docsBaseUrl = options.docsBaseUrl ?? "https://remylagerweij.github.io/vue-doctor";
649
654
  const lines = [];
650
- if (options.stickyMarker) lines.push(SUMMARY_MARKER, "");
651
- if (report.projects.length === 1) lines.push(...renderProjectSummary(report.projects[0], null, docsBaseUrl));
655
+ if (options.stickyMarker) lines.push(summaryMarker(options.scope), "");
656
+ if (report.projects.length === 1) lines.push(...renderProjectSummary(report.projects[0], null, docsBaseUrl, options.scope));
652
657
  else {
653
658
  lines.push(`## 🩺 Vue Doctor: ${plural$1(report.summary.projects, "project")}`, "", `${plural$1(report.summary.errors, "error")} · ${plural$1(report.summary.warnings, "warning")}`, "");
654
659
  for (const project of report.projects) lines.push(...renderProjectSummary(project, project.name, docsBaseUrl));
@@ -1823,8 +1828,8 @@ const createBatchProgressReporter = async (options) => {
1823
1828
  //#region src/scan.ts
1824
1829
  const printProjectDetection = (projectInfo, isDiffMode, includePaths) => {
1825
1830
  const lines = [];
1826
- const title = `${pc.bold(pc.green("Vue Doctor"))} ${pc.dim("v2.0.0")}`;
1827
- lines.push(createFramedLine(`Vue Doctor v2.0.0`, title));
1831
+ const title = `${pc.bold(pc.green("Vue Doctor"))} ${pc.dim("v2.0.2")}`;
1832
+ lines.push(createFramedLine(`Vue Doctor v2.0.2`, title));
1828
1833
  const vueVersionDisplay = projectInfo.vueVersion ? `Vue ${projectInfo.vueVersion}` : "Vue";
1829
1834
  const frameworkDisplay = formatFrameworkName(projectInfo.framework);
1830
1835
  const projectLine = `${projectInfo.projectName} · ${frameworkDisplay} · ${vueVersionDisplay}`;
@@ -2067,6 +2072,22 @@ const scanProjects = async (projects, concurrency = resolveScanConcurrency(proje
2067
2072
  return outcomes;
2068
2073
  };
2069
2074
  //#endregion
2075
+ //#region src/utils/find-source-root.ts
2076
+ /**
2077
+ * The directory that SARIF `%SRCROOT%` stands for: the git repository root containing `directory`
2078
+ * (what GitHub code scanning resolves paths against), else the current working directory.
2079
+ */
2080
+ const findSourceRoot = (directory) => {
2081
+ const result = spawnSync("git", ["rev-parse", "--show-toplevel"], {
2082
+ cwd: directory,
2083
+ encoding: "utf-8"
2084
+ });
2085
+ const topLevel = result.status === 0 ? result.stdout.trim() : "";
2086
+ return topLevel ? path.resolve(topLevel) : process.cwd();
2087
+ };
2088
+ /** POSIX path from the source root to `directory` (`""` when they are the same). */
2089
+ const relativeToSourceRoot = (directory) => path.relative(findSourceRoot(directory), path.resolve(directory)).split(path.sep).join("/");
2090
+ //#endregion
2070
2091
  //#region src/ci/github-client.ts
2071
2092
  var GitHubClient = class {
2072
2093
  token;
@@ -2155,18 +2176,27 @@ var GitHubClient = class {
2155
2176
  };
2156
2177
  //#endregion
2157
2178
  //#region src/ci/feedback.ts
2179
+ const SCOPE_MARKER_PREFIX = "<!-- vue-doctor:scope:";
2180
+ const normalizeScope = (prefix = "") => prefix.split("/").filter((part) => part !== "" && part !== ".").join("/");
2181
+ const scopeMarker = (scope) => `${SCOPE_MARKER_PREFIX}${sanitizeMarkerScope(scope)} -->`;
2182
+ /** The scanned directory a review comment belongs to; comments without a scope marker belong to the repository root. */
2183
+ const extractScope = (body) => {
2184
+ const match = body.match(/<!-- vue-doctor:scope:([^\s]*) -->/);
2185
+ return match ? match[1] : "";
2186
+ };
2158
2187
  /**
2159
2188
  * Extracts the marker ID from a comment body if present.
2160
2189
  */
2161
2190
  const extractFindingMarker = (body) => {
2162
- const match = body.match(/<!-- vue-doctor:finding:([a-zA-Z0-9_\-]+) -->/);
2191
+ const match = body.match(/<!-- vue-doctor:finding:([a-zA-Z0-9_-]+) -->/);
2163
2192
  return match ? match[1] : null;
2164
2193
  };
2165
2194
  /**
2166
2195
  * Groups findings according to the specified grouping mode.
2167
2196
  */
2168
- const groupFindings = (findings, grouping, agentPrompt) => {
2197
+ const groupFindings = (findings, grouping, agentPrompt, scope = "") => {
2169
2198
  if (findings.length === 0) return [];
2199
+ const withScope = (body) => scope ? `${body.trimEnd()}\n${scopeMarker(scope)}\n` : body;
2170
2200
  if (grouping === "finding") return findings.map((finding) => {
2171
2201
  const markerId = sanitizeMarkerId(finding.fingerprint || `${finding.file}:${finding.line}:${finding.ruleId}`);
2172
2202
  const body = renderMarkdownFinding(finding, {
@@ -2180,7 +2210,7 @@ const groupFindings = (findings, grouping, agentPrompt) => {
2180
2210
  line: Math.max(1, finding.line),
2181
2211
  ruleId: finding.ruleId,
2182
2212
  findings: [finding],
2183
- body
2213
+ body: withScope(body)
2184
2214
  };
2185
2215
  });
2186
2216
  const groups = /* @__PURE__ */ new Map();
@@ -2191,7 +2221,7 @@ const groupFindings = (findings, grouping, agentPrompt) => {
2191
2221
  groups.set(key, list);
2192
2222
  }
2193
2223
  const commentGroups = [];
2194
- for (const [key, groupList] of groups) {
2224
+ for (const groupList of groups.values()) {
2195
2225
  const first = groupList[0];
2196
2226
  const markerId = sanitizeMarkerId(grouping === "rule-per-file" ? `${first.file}::${first.ruleId}` : `rule::${first.ruleId}`);
2197
2227
  const lines = [
@@ -2212,7 +2242,7 @@ const groupFindings = (findings, grouping, agentPrompt) => {
2212
2242
  line: Math.max(1, first.line),
2213
2243
  ruleId: first.ruleId,
2214
2244
  findings: groupList,
2215
- body: lines.join("\n") + "\n"
2245
+ body: withScope(lines.join("\n") + "\n")
2216
2246
  });
2217
2247
  }
2218
2248
  return commentGroups;
@@ -2222,11 +2252,14 @@ const groupFindings = (findings, grouping, agentPrompt) => {
2222
2252
  */
2223
2253
  const postStickySummary = async (client, options, report) => {
2224
2254
  if (!options.pullNumber) return;
2255
+ const scope = normalizeScope(options.sourceRootPrefix);
2225
2256
  const summaryMarkdown = renderMarkdownSummary(report, {
2226
2257
  stickyMarker: true,
2227
- collapseFindings: true
2258
+ collapseFindings: true,
2259
+ scope
2228
2260
  });
2229
- const existing = (await client.listIssueComments(options.owner, options.repo, options.pullNumber)).find((c) => c.body?.includes(SUMMARY_MARKER));
2261
+ const marker = summaryMarker(scope);
2262
+ const existing = (await client.listIssueComments(options.owner, options.repo, options.pullNumber)).find((c) => c.body?.includes(marker));
2230
2263
  if (existing) {
2231
2264
  if (existing.body !== summaryMarkdown) {
2232
2265
  logger.log(`Updating sticky summary comment #${existing.id}...`);
@@ -2242,14 +2275,19 @@ const postStickySummary = async (client, options, report) => {
2242
2275
  */
2243
2276
  const postReviewComments = async (client, options, report) => {
2244
2277
  if (!options.pullNumber) return;
2245
- const allFindings = report.projects.flatMap((p) => p.findings);
2246
- const activeGroups = groupFindings(allFindings, options.grouping, options.agentPrompt).slice(0, options.maxComments);
2278
+ const prefix = options.sourceRootPrefix ?? "";
2279
+ const scope = normalizeScope(prefix);
2280
+ const allFindings = report.projects.flatMap((p) => p.findings.map((finding) => ({
2281
+ ...finding,
2282
+ file: toRepoPath(prefix, p.root, finding.file)
2283
+ })));
2284
+ const activeGroups = groupFindings(allFindings, options.grouping, options.agentPrompt, scope).slice(0, options.maxComments);
2247
2285
  const activeMarkers = new Set(activeGroups.map((g) => g.marker));
2248
2286
  const existingComments = await client.listReviewComments(options.owner, options.repo, options.pullNumber);
2249
2287
  const trackedComments = /* @__PURE__ */ new Map();
2250
2288
  for (const c of existingComments) {
2251
2289
  const marker = extractFindingMarker(c.body);
2252
- if (marker) trackedComments.set(marker, {
2290
+ if (marker && extractScope(c.body) === scope) trackedComments.set(marker, {
2253
2291
  id: c.id,
2254
2292
  body: c.body
2255
2293
  });
@@ -2300,17 +2338,11 @@ const postCommitStatus = async (client, options, report, passedGate) => {
2300
2338
  });
2301
2339
  };
2302
2340
  /**
2303
- * Emits inline GitHub Action workflow annotations to stdout/stderr.
2341
+ * Emits inline GitHub Action workflow annotations to stdout, with repository-relative paths.
2304
2342
  */
2305
- const emitAnnotations = (report) => {
2306
- for (const project of report.projects) for (const finding of project.findings) {
2307
- const level = finding.severity === "error" ? "error" : "warning";
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
- }
2343
+ const emitAnnotations = (report, sourceRootPrefix = "") => {
2344
+ const output = formatGithub(report, { sourceRootPrefix });
2345
+ if (output) process.stdout.write(output.endsWith("\n") ? output : `${output}\n`);
2314
2346
  };
2315
2347
  //#endregion
2316
2348
  //#region src/ci/score-cache.ts
@@ -2499,7 +2531,7 @@ const writeGitHubOutput = (key, value) => {
2499
2531
  };
2500
2532
  const registerCiCommand = (program) => {
2501
2533
  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", "changed").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([
2534
+ 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
2535
  "finding",
2504
2536
  "rule-per-file",
2505
2537
  "rule"
@@ -2515,7 +2547,8 @@ const registerCiCommand = (program) => {
2515
2547
  const scope = options.scope ?? (isPr ? "changed" : "full");
2516
2548
  let changedFiles;
2517
2549
  if (scope === "changed" || scope === "lines") {
2518
- const diffInfo = getDiffInfo(projectDir, process.env.GITHUB_BASE_REF);
2550
+ const baseRef = process.env.GITHUB_BASE_REF?.trim() || void 0;
2551
+ const diffInfo = getDiffInfo(projectDir, baseRef);
2519
2552
  if (diffInfo.status === "ok") {
2520
2553
  changedFiles = filterSourceFiles(diffInfo.changedFiles);
2521
2554
  logger.log(`Scanning ${changedFiles.length} changed files...`);
@@ -2590,7 +2623,8 @@ const registerCiCommand = (program) => {
2590
2623
  if (sarifPath) writeGitHubOutput("sarif-path", sarifPath);
2591
2624
  if (reportPath) writeGitHubOutput("report-path", reportPath);
2592
2625
  const feedbackModes = (options.feedback ?? "summary,findings").split(",").map((m) => m.trim().toLowerCase());
2593
- if (feedbackModes.includes("annotations")) emitAnnotations(report);
2626
+ const sourceRootPrefix = relativeToSourceRoot(projectDir);
2627
+ if (feedbackModes.includes("annotations")) emitAnnotations(report, sourceRootPrefix);
2594
2628
  const token = options.githubToken ?? process.env.GITHUB_TOKEN;
2595
2629
  const repoFullName = process.env.GITHUB_REPOSITORY;
2596
2630
  const prNumberStr = process.env.GITHUB_REF_NAME?.split("/")[0] || process.env.PR_NUMBER;
@@ -2609,7 +2643,8 @@ const registerCiCommand = (program) => {
2609
2643
  pullNumber: prNumber && !Number.isNaN(prNumber) ? prNumber : void 0,
2610
2644
  commitSha,
2611
2645
  scoreDelta: deltaInfo.scoreDelta ?? void 0,
2612
- baseScore: deltaInfo.baseScore ?? void 0
2646
+ baseScore: deltaInfo.baseScore ?? void 0,
2647
+ sourceRootPrefix
2613
2648
  };
2614
2649
  if (feedbackModes.includes("summary") && feedbackOpts.pullNumber) await postStickySummary(client, feedbackOpts, report);
2615
2650
  if (feedbackModes.includes("findings") && feedbackOpts.pullNumber) await postReviewComments(client, feedbackOpts, report);
@@ -2943,15 +2978,16 @@ const registerInitCommand = (program) => {
2943
2978
  const projectDir = path.resolve(directoryArg);
2944
2979
  const isInteractive = Boolean(process.stdin.isTTY) && !options.yes;
2945
2980
  const clack = isInteractive ? await import("@clack/prompts") : null;
2946
- const { discoverProject, formatFrameworkName } = await import("./discover-project-NDbR7YIn.js");
2981
+ const { discoverProject, formatFrameworkName } = await import("./discover-project-DhOxGanX.js");
2982
+ const { isMonorepoRoot } = await import("./find-monorepo-root-DhN-SSup.js");
2947
2983
  const projectInfo = discoverProject(projectDir);
2948
2984
  if (isInteractive && clack) {
2949
2985
  clack.intro("🩺 Vue Doctor Setup Wizard");
2950
2986
  const details = [
2951
2987
  formatFrameworkName(projectInfo.framework),
2952
2988
  projectInfo.vueVersion ? `Vue ${projectInfo.vueVersion}` : null,
2953
- projectInfo.typescript ? "TypeScript" : null,
2954
- projectInfo.isMonorepo ? "Monorepo" : null
2989
+ projectInfo.hasTypeScript ? "TypeScript" : null,
2990
+ isMonorepoRoot(projectDir) ? "Monorepo" : null
2955
2991
  ].filter(Boolean).join(" · ");
2956
2992
  clack.note(details || "Vue project detected", "Project Detection");
2957
2993
  }
@@ -3033,7 +3069,7 @@ const registerInitCommand = (program) => {
3033
3069
  }
3034
3070
  createBaselineSnapshot = Boolean(baselineChoice);
3035
3071
  }
3036
- const configFileName = `vue-doctor.config.${projectInfo.typescript ? "ts" : "js"}`;
3072
+ const configFileName = `vue-doctor.config.${projectInfo.hasTypeScript ? "ts" : "js"}`;
3037
3073
  const configPath = path.join(projectDir, configFileName);
3038
3074
  let shouldWriteConfig = true;
3039
3075
  if (fs.existsSync(configPath) && !options.force) {
@@ -3129,7 +3165,7 @@ const registerInitCommand = (program) => {
3129
3165
  if (spinner) spinner.start("Scanning project to record baseline snapshot...");
3130
3166
  else logger.log("Scanning project to record baseline snapshot...");
3131
3167
  try {
3132
- const { diagnose } = await import("./diagnose-Uhhk0XM9.js");
3168
+ const { diagnose } = await import("./diagnose-CfTVpINk.js");
3133
3169
  const { createBaseline, writeBaseline } = await import("./baseline-CvI0x3dv.js");
3134
3170
  const baselineData = createBaseline((await diagnose(projectDir, { baseline: null })).diagnostics);
3135
3171
  writeBaseline(path.join(projectDir, baselineFileName), baselineData);
@@ -3149,29 +3185,13 @@ const registerInitCommand = (program) => {
3149
3185
  //#region src/commands/mcp.ts
3150
3186
  const registerMcpCommand = (program) => {
3151
3187
  program.command("mcp").description("Start Model Context Protocol (MCP) server over stdio for AI agents").action(async () => {
3152
- const { McpServer } = await import("./server-CXe6F5YL.js");
3188
+ const { McpServer } = await import("./server-B2KIHhnE.js");
3153
3189
  new McpServer().startStdio();
3154
3190
  });
3155
3191
  };
3156
3192
  //#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
3193
  //#region src/program.ts
3174
- const VERSION = "2.0.0";
3194
+ const VERSION = "2.0.2";
3175
3195
  const parseScore = (value) => {
3176
3196
  const score = Number(value);
3177
3197
  if (!Number.isInteger(score) || score < 0 || score > 100) throw new InvalidArgumentError("Expected an integer between 0 and 100.");
@@ -3225,7 +3245,7 @@ const createProgram = () => {
3225
3245
  const legacyHtmlReport = options.report === true;
3226
3246
  if (legacyHtmlReport) logger.warn("--report is deprecated and will be removed in a future release; use --format html --output <file>.");
3227
3247
  if (options.fix) {
3228
- const { runFixes } = await import("./runner-CPsa1irw.js");
3248
+ const { runFixes } = await import("./runner-CRvgMfVK.js");
3229
3249
  for (const projectDirectory of projectDirectories) {
3230
3250
  const fixReport = runFixes(projectDirectory, { dryRun: options.dryRun });
3231
3251
  if (options.dryRun) {
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { n as diagnose } from "./diagnose-DCDjxRw-.js";
3
+ export { diagnose };
@@ -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-BpaHm1-R.js";
4
- import { _ as VUE_FILE_PATTERN, b as isMonorepoRoot, 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, x as readPackageJson, y as findMonorepoRoot } from "./discover-project-C0n-wTpF.js";
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-DrQCWqKC.js";
5
6
  import { createRequire } from "node:module";
6
7
  import fs from "node:fs";
7
8
  import path from "node:path";
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { r as formatFrameworkName, t as discoverProject } from "./discover-project-C0n-wTpF.js";
2
+ import { r as formatFrameworkName, t as discoverProject } from "./discover-project-DrQCWqKC.js";
3
3
  export { discoverProject, formatFrameworkName };
@@ -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.0";
16
+ const VERSION = "2.0.2";
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, isMonorepoRoot as b, 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, readPackageJson as x, findMonorepoRoot as y };
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 };
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { n as isMonorepoRoot } from "./find-monorepo-root-DePS93uu.js";
3
+ export { isMonorepoRoot };
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).replace(/\\/g, "/");
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).replace(/\\/g, "/");
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-DSozxZ0-.js";
2
+ import { a as logger } from "./diagnose-DCDjxRw-.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-C0n-wTpF.js";
4
+ import { l as DEFAULT_BRANCH_CANDIDATES, m as SOURCE_FILE_PATTERN, u as DOCS_BASE_URL } from "./discover-project-DrQCWqKC.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-BpaHm1-R.js";
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_\-]+)\b([^>]*\bv-for\s*=\s*["']([^"']+)["'][^>]*)>/gi, (fullTag, tagName, attrs, vForExpr) => {
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-DSozxZ0-.js";
2
+ import { n as diagnose } from "./diagnose-DCDjxRw-.js";
3
3
  import { _ as getCanonicalRuleId, f as RULE_REGISTRY } from "./baseline-BKB_9B33.js";
4
- import { g as VERSION } from "./discover-project-C0n-wTpF.js";
5
- import { a as filterSourceFiles, i as toRuleInfo, o as getDiffInfo, t as findRuleMeta } from "./rules-Cv8YQ738.js";
4
+ import { g as VERSION } from "./discover-project-DrQCWqKC.js";
5
+ import { a as filterSourceFiles, i as toRuleInfo, o as getDiffInfo, t as findRuleMeta } from "./rules-B9fi0v2a.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.0",
3
+ "version": "2.0.2",
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": "^6.0.3"
86
+ "typescript": "^7.0.2"
87
87
  },
88
88
  "main": "./dist/index.js",
89
89
  "types": "./dist/index.d.ts"
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import { n as diagnose } from "./diagnose-DSozxZ0-.js";
3
- export { diagnose };