@farming-labs/docs 0.2.11 → 0.2.13
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/index.mjs
CHANGED
|
@@ -162,7 +162,7 @@ async function main() {
|
|
|
162
162
|
printAgentsGenerateHelp();
|
|
163
163
|
process.exit(1);
|
|
164
164
|
} else if (parsedCommand.command === "doctor") {
|
|
165
|
-
const { parseDoctorArgs, printDoctorHelp, runDoctor } = await import("../doctor-
|
|
165
|
+
const { parseDoctorArgs, printDoctorHelp, runDoctor } = await import("../doctor-CRtFloHw.mjs");
|
|
166
166
|
const doctorOptions = parseDoctorArgs(args.slice(1));
|
|
167
167
|
if (doctorOptions.help) {
|
|
168
168
|
printDoctorHelp();
|
|
@@ -341,6 +341,7 @@ ${pc.dim("Options for doctor:")}
|
|
|
341
341
|
${pc.cyan("doctor --human")} Alias for ${pc.cyan("doctor --site")}
|
|
342
342
|
${pc.cyan("doctor --json")} Print the report as JSON for CI, scripts, and automation
|
|
343
343
|
${pc.cyan("doctor --strict")} Exit with failure when any doctor check warns or fails
|
|
344
|
+
${pc.cyan("doctor --fail-on warn|fail")} Choose whether warnings or only failures fail CI
|
|
344
345
|
${pc.cyan("doctor agent")} Subcommand alias for agent scoring
|
|
345
346
|
${pc.cyan("doctor site")} Subcommand alias for reader-facing scoring
|
|
346
347
|
${pc.cyan("doctor human")} Legacy alias for reader-facing scoring
|
|
@@ -42,6 +42,10 @@ function parseDoctorOnlyMode(value) {
|
|
|
42
42
|
if (value === "site") return "human";
|
|
43
43
|
throw new Error("Invalid value for --only. Expected agent or site.");
|
|
44
44
|
}
|
|
45
|
+
function parseDoctorFailOn(value) {
|
|
46
|
+
if (value === "warn" || value === "fail") return value;
|
|
47
|
+
throw new Error("Invalid value for --fail-on. Expected warn or fail.");
|
|
48
|
+
}
|
|
45
49
|
function parseDoctorArgs(argv) {
|
|
46
50
|
const parsed = {};
|
|
47
51
|
for (let index = 0; index < argv.length; index += 1) {
|
|
@@ -62,6 +66,19 @@ function parseDoctorArgs(argv) {
|
|
|
62
66
|
parsed.strict = true;
|
|
63
67
|
continue;
|
|
64
68
|
}
|
|
69
|
+
if (arg.startsWith("--fail-on=")) {
|
|
70
|
+
const value = parseInlineFlag(arg).value;
|
|
71
|
+
if (!value) throw new Error("Missing value for --fail-on.");
|
|
72
|
+
parsed.failOn = parseDoctorFailOn(value);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (arg === "--fail-on") {
|
|
76
|
+
const value = argv[index + 1];
|
|
77
|
+
if (!value || value.startsWith("--")) throw new Error("Missing value for --fail-on.");
|
|
78
|
+
parsed.failOn = parseDoctorFailOn(value);
|
|
79
|
+
index += 1;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
65
82
|
if (arg.startsWith("--only=")) {
|
|
66
83
|
const value = parseInlineFlag(arg).value;
|
|
67
84
|
if (!value) throw new Error("Missing value for --only.");
|
|
@@ -120,6 +137,7 @@ ${pc.dim("Usage:")}
|
|
|
120
137
|
pnpm exec docs doctor --site
|
|
121
138
|
pnpm exec docs doctor --agent --json
|
|
122
139
|
pnpm exec docs doctor --agent --strict
|
|
140
|
+
pnpm exec docs doctor --agent --fail-on fail
|
|
123
141
|
pnpm exec docs doctor --only agent
|
|
124
142
|
pnpm exec docs doctor --only site
|
|
125
143
|
pnpm exec docs doctor agent
|
|
@@ -132,6 +150,7 @@ ${pc.dim("Options:")}
|
|
|
132
150
|
${pc.cyan("--only <mode>")} Run only one doctor suite: ${pc.cyan("agent")} or ${pc.cyan("site")}
|
|
133
151
|
${pc.cyan("--json")} Print the report as JSON for CI, scripts, and other agents
|
|
134
152
|
${pc.cyan("--strict")} Exit with failure when any check warns or fails
|
|
153
|
+
${pc.cyan("--fail-on <level>")} Exit with failure on ${pc.cyan("warn")} or only on ${pc.cyan("fail")}
|
|
135
154
|
${pc.cyan("--url <url>")} Probe hosted agent surfaces, e.g. ${pc.dim("https://docs.example.com")}
|
|
136
155
|
${pc.cyan("--config <path>")} Use a custom docs config path instead of ${pc.dim("docs.config.ts[x]")}
|
|
137
156
|
${pc.cyan("-h, --help")} Show this help message
|
|
@@ -1486,13 +1505,18 @@ function printDoctorJsonReport(report) {
|
|
|
1486
1505
|
function hasNonPassingDoctorCheck(report) {
|
|
1487
1506
|
return report.checks.some((check) => check.status !== "pass");
|
|
1488
1507
|
}
|
|
1489
|
-
function
|
|
1490
|
-
|
|
1508
|
+
function hasFailingDoctorCheck(report) {
|
|
1509
|
+
return report.checks.some((check) => check.status === "fail");
|
|
1510
|
+
}
|
|
1511
|
+
function applyDoctorExitCode(report, options) {
|
|
1512
|
+
const failOn = options.failOn ?? (options.strict ? "warn" : void 0);
|
|
1513
|
+
if (!failOn) return;
|
|
1514
|
+
if (failOn === "warn" ? hasNonPassingDoctorCheck(report) : hasFailingDoctorCheck(report)) process.exitCode = 1;
|
|
1491
1515
|
}
|
|
1492
1516
|
async function runDoctor(options = {}) {
|
|
1493
1517
|
if (options.mode === "human") {
|
|
1494
1518
|
const report = await inspectHumanReadiness(options);
|
|
1495
|
-
|
|
1519
|
+
applyDoctorExitCode(report, options);
|
|
1496
1520
|
if (options.json) {
|
|
1497
1521
|
printDoctorJsonReport(report);
|
|
1498
1522
|
return report;
|
|
@@ -1501,7 +1525,7 @@ async function runDoctor(options = {}) {
|
|
|
1501
1525
|
return report;
|
|
1502
1526
|
}
|
|
1503
1527
|
const report = await inspectAgentReadiness(options);
|
|
1504
|
-
|
|
1528
|
+
applyDoctorExitCode(report, options);
|
|
1505
1529
|
if (options.json) {
|
|
1506
1530
|
printDoctorJsonReport(report);
|
|
1507
1531
|
return report;
|