saturndocs 0.5.0 → 0.6.0
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/auth-ITFO2JZX.js +17 -0
- package/dist/broken-links-RL4CXACC.js +50 -0
- package/dist/{build-OLTD5RJQ.js → build-A4TQWOOV.js} +18 -7
- package/dist/check-QPS7MTQP.js +160 -0
- package/dist/{chunk-CM2ONKCQ.js → chunk-23HQUZXQ.js} +39 -14
- package/dist/{chunk-F5G7PDQJ.js → chunk-2NFN6VFP.js} +11 -185
- package/dist/{chunk-MXJOVTOT.js → chunk-45AKGRMZ.js} +1 -54
- package/dist/{chunk-SDNJSBGO.js → chunk-4CKO5OQL.js} +11 -9
- package/dist/{chunk-RI5COFYL.js → chunk-4D3NBTL6.js} +27 -10
- package/dist/{chunk-GNR5NWNR.js → chunk-ALDS7N4Q.js} +168 -61
- package/dist/{broken-links-EOEGVH4F.js → chunk-AUKI4MTV.js} +132 -38
- package/dist/{chunk-C62AROBZ.js → chunk-C7NSZ6OB.js} +9 -7
- package/dist/{chunk-SIGMRKFJ.js → chunk-CTNXOVXJ.js} +8 -6
- package/dist/{chunk-27ARMXM2.js → chunk-CVJ2XMAD.js} +10 -8
- package/dist/{renderer-76D7VFQ3.js → chunk-D5WG63T5.js} +2 -1
- package/dist/{chunk-UJCRJ4XU.js → chunk-EMEVC3I7.js} +8 -6
- package/dist/{chunk-M2BZEDAS.js → chunk-FNZJHYAX.js} +2 -1
- package/dist/{chunk-ATM2LU6H.js → chunk-GDBDMUT4.js} +4 -2
- package/dist/{chunk-WDOLOQAV.js → chunk-GSZ7EXCV.js} +2 -2
- package/dist/{chunk-X2YU7MAC.js → chunk-HBK4T5U5.js} +18 -6
- package/dist/{chunk-33MGV73K.js → chunk-LR4MHIOQ.js} +12 -10
- package/dist/{chunk-NE6SDXXB.js → chunk-M3DLP36J.js} +31 -11
- package/dist/{chunk-L6EE6XS2.js → chunk-MJCIWAS4.js} +12 -10
- package/dist/{chunk-RNRRFICE.js → chunk-P7YJ2EEB.js} +2 -2
- package/dist/chunk-QLA74ZD6.js +109 -0
- package/dist/{chunk-OWKBGNGZ.js → chunk-QSJHJKJP.js} +18 -0
- package/dist/chunk-SN4CWEHN.js +21 -0
- package/dist/{chunk-JSKBT765.js → chunk-TAL5XRPC.js} +94 -36
- package/dist/{chunk-JFYMBFDW.js → chunk-VUBV3KNZ.js} +33 -11
- package/dist/chunk-WTGIPAFR.js +192 -0
- package/dist/chunk-X3QUPC5K.js +79 -0
- package/dist/{chunk-7QGSIPAS.js → chunk-XXL6UJYJ.js} +10 -8
- package/dist/{chunk-4MJYA6R5.js → chunk-YVF5SRRV.js} +12 -10
- package/dist/{chunk-FIFAZLRQ.js → chunk-ZMEJOXWN.js} +14 -12
- package/dist/cli.js +18 -8
- package/dist/coverage-J37TZFNH.js +16 -0
- package/dist/{dev-PXZCETLB.js → dev-DTOZC26U.js} +68 -13
- package/dist/{dist-RJ3HLSC7.js → dist-Q7BIZ2ZM.js} +14 -2
- package/dist/index.d.ts +10 -16
- package/dist/index.js +55 -51
- package/dist/init-5UAYTRNK.js +18 -0
- package/dist/{lint-MR7LHMLU.js → lint-JB2T2XON.js} +4 -3
- package/dist/local-metadata-JSZPFCDP.js +19 -0
- package/dist/{login-QW5GZLWK.js → login-C6NODYYR.js} +6 -5
- package/dist/manage-73GX3EOY.js +17 -0
- package/dist/nav-CGOD74U6.js +15 -0
- package/dist/{openapiCheck-XAZ6FOF2.js → openapiCheck-V3HL4OLS.js} +23 -22
- package/dist/pages-RN3UBKKG.js +17 -0
- package/dist/{read-UCTHVWS2.js → read-7KFJFSBV.js} +14 -12
- package/dist/{read-6RAHFNPS.js → read-BWDXUPIU.js} +13 -11
- package/dist/renderer-LKTT533L.js +12 -0
- package/dist/requests-6GFLCAZH.js +14 -0
- package/dist/schema-Y7ZZFE42.js +14 -0
- package/dist/sites-UAZ2V62J.js +16 -0
- package/dist/status-U4I2APGB.js +15 -0
- package/dist/{suggestions-WBWQP2UN.js → suggestions-PUSFPY4M.js} +14 -12
- package/dist/validate-Z4P4AGLW.js +15 -0
- package/package.json +6 -6
- package/dist/auth-47SI6KTG.js +0 -16
- package/dist/chunk-LLRWUKIR.js +0 -62
- package/dist/coverage-I3FWCRWG.js +0 -15
- package/dist/init-GQELTILS.js +0 -15
- package/dist/manage-OTGX2SGZ.js +0 -16
- package/dist/nav-3GHG5U5B.js +0 -14
- package/dist/pages-BA3MMNSL.js +0 -16
- package/dist/requests-6OIP4LGE.js +0 -13
- package/dist/schema-OEKCGF6Y.js +0 -13
- package/dist/sites-L6DPTMX6.js +0 -15
- package/dist/status-PMVNHRK6.js +0 -14
- package/dist/validate-LY3ZSHSV.js +0 -12
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AUTH_METADATA,
|
|
3
|
+
authStatusOf,
|
|
4
|
+
registerAuth,
|
|
5
|
+
savedLoginStatusOf
|
|
6
|
+
} from "./chunk-C7NSZ6OB.js";
|
|
7
|
+
import "./chunk-HBK4T5U5.js";
|
|
8
|
+
import "./chunk-GDBDMUT4.js";
|
|
9
|
+
import "./chunk-FNZJHYAX.js";
|
|
10
|
+
import "./chunk-WTGIPAFR.js";
|
|
11
|
+
import "./chunk-2NFN6VFP.js";
|
|
12
|
+
export {
|
|
13
|
+
AUTH_METADATA,
|
|
14
|
+
authStatusOf,
|
|
15
|
+
registerAuth,
|
|
16
|
+
savedLoginStatusOf
|
|
17
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkLinks
|
|
3
|
+
} from "./chunk-AUKI4MTV.js";
|
|
4
|
+
import "./chunk-QSJHJKJP.js";
|
|
5
|
+
import "./chunk-GSZ7EXCV.js";
|
|
6
|
+
import "./chunk-23HQUZXQ.js";
|
|
7
|
+
import {
|
|
8
|
+
requireDocsDir
|
|
9
|
+
} from "./chunk-SN4CWEHN.js";
|
|
10
|
+
import "./chunk-TAL5XRPC.js";
|
|
11
|
+
import "./chunk-ALDS7N4Q.js";
|
|
12
|
+
import "./chunk-45AKGRMZ.js";
|
|
13
|
+
import {
|
|
14
|
+
applyCommandHelp
|
|
15
|
+
} from "./chunk-FNZJHYAX.js";
|
|
16
|
+
import {
|
|
17
|
+
createResultWriter,
|
|
18
|
+
failureResult,
|
|
19
|
+
invalidInput,
|
|
20
|
+
resolveGlobalOptions,
|
|
21
|
+
successResult
|
|
22
|
+
} from "./chunk-WTGIPAFR.js";
|
|
23
|
+
import {
|
|
24
|
+
BROKEN_LINKS_METADATA
|
|
25
|
+
} from "./chunk-QLA74ZD6.js";
|
|
26
|
+
import "./chunk-2NFN6VFP.js";
|
|
27
|
+
|
|
28
|
+
// src/commands/broken-links.ts
|
|
29
|
+
function linkLine(d) {
|
|
30
|
+
const place = d.line === null ? d.file : `${d.file}:${d.line}:${d.column}`;
|
|
31
|
+
return `${place}: ${d.link} \u2014 ${d.reason}${d.occurrences > 1 ? ` (on ${d.occurrences} rendered pages, first ${d.rendered})` : ""}`;
|
|
32
|
+
}
|
|
33
|
+
function registerBrokenLinks(program, provide, cache) {
|
|
34
|
+
const command = program.command("broken-links [docs-dir]").option("--site-url <url>", "Override the production site URL.").action(async (dir, options, self) => {
|
|
35
|
+
const writer = createResultWriter({ json: resolveGlobalOptions(self).json });
|
|
36
|
+
const context = { command: "broken-links", siteId: null };
|
|
37
|
+
try {
|
|
38
|
+
const report = await checkLinks(requireDocsDir(dir), cache, provide, options.siteUrl);
|
|
39
|
+
if (report.diagnostics.length) throw invalidInput(report.diagnostics.map(linkLine).join("\n"), { data: report });
|
|
40
|
+
process.exitCode = writer.write(successResult(context, report), { text: "Author preview has no broken internal links." });
|
|
41
|
+
} catch (error) {
|
|
42
|
+
process.exitCode = writer.write(failureResult(error, context));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
applyCommandHelp(command, BROKEN_LINKS_METADATA[0]);
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
linkLine,
|
|
49
|
+
registerBrokenLinks
|
|
50
|
+
};
|
|
@@ -3,16 +3,26 @@ import {
|
|
|
3
3
|
} from "./chunk-LDE53VKA.js";
|
|
4
4
|
import {
|
|
5
5
|
buildGeneration
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
} from "./chunk-23HQUZXQ.js";
|
|
7
|
+
import {
|
|
8
|
+
requireDocsDir
|
|
9
|
+
} from "./chunk-SN4CWEHN.js";
|
|
10
|
+
import "./chunk-TAL5XRPC.js";
|
|
11
|
+
import "./chunk-ALDS7N4Q.js";
|
|
12
|
+
import "./chunk-45AKGRMZ.js";
|
|
13
|
+
import {
|
|
14
|
+
applyCommandHelp
|
|
15
|
+
} from "./chunk-FNZJHYAX.js";
|
|
10
16
|
import {
|
|
11
17
|
createResultWriter,
|
|
12
18
|
failureResult,
|
|
13
19
|
resolveGlobalOptions,
|
|
14
20
|
successResult
|
|
15
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-WTGIPAFR.js";
|
|
22
|
+
import {
|
|
23
|
+
BUILD_METADATA
|
|
24
|
+
} from "./chunk-QLA74ZD6.js";
|
|
25
|
+
import "./chunk-2NFN6VFP.js";
|
|
16
26
|
|
|
17
27
|
// src/lib/preview/output.ts
|
|
18
28
|
import { createHash, randomUUID } from "crypto";
|
|
@@ -121,11 +131,11 @@ async function exportBuild(docsDir, outDir, siteUrl, cacheDir, provide) {
|
|
|
121
131
|
|
|
122
132
|
// src/commands/build.ts
|
|
123
133
|
function registerBuild(program, provider, cache) {
|
|
124
|
-
program.command("build [docs-dir]").requiredOption("--out-dir <path>").option("--site-url <url>", "Site URL", "http://localhost").action(async (dir, options, self) => {
|
|
134
|
+
const command = program.command("build [docs-dir]").requiredOption("--out-dir <path>", "Directory for the static site. It must be outside the docs directory.").option("--site-url <url>", "Site URL to render against.", "http://localhost").action(async (dir, options, self) => {
|
|
125
135
|
const writer = createResultWriter({ json: resolveGlobalOptions(self).json });
|
|
126
136
|
const context = { command: "build", siteId: null };
|
|
127
137
|
try {
|
|
128
|
-
const report = await exportBuild(dir
|
|
138
|
+
const report = await exportBuild(requireDocsDir(dir), options.outDir, options.siteUrl, cache, provider);
|
|
129
139
|
process.exitCode = writer.write(successResult(context, report), {
|
|
130
140
|
text: [`Built author preview at ${report.output_path}`, ...report.warnings].join("\n")
|
|
131
141
|
});
|
|
@@ -133,6 +143,7 @@ function registerBuild(program, provider, cache) {
|
|
|
133
143
|
process.exitCode = writer.write(failureResult(error, context));
|
|
134
144
|
}
|
|
135
145
|
});
|
|
146
|
+
applyCommandHelp(command, BUILD_METADATA[0]);
|
|
136
147
|
}
|
|
137
148
|
export {
|
|
138
149
|
registerBuild
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkLinks
|
|
3
|
+
} from "./chunk-AUKI4MTV.js";
|
|
4
|
+
import "./chunk-QSJHJKJP.js";
|
|
5
|
+
import "./chunk-D5WG63T5.js";
|
|
6
|
+
import {
|
|
7
|
+
RendererError
|
|
8
|
+
} from "./chunk-LDE53VKA.js";
|
|
9
|
+
import {
|
|
10
|
+
lintDocsDir
|
|
11
|
+
} from "./chunk-4D3NBTL6.js";
|
|
12
|
+
import "./chunk-YGVC4N4V.js";
|
|
13
|
+
import "./chunk-GSZ7EXCV.js";
|
|
14
|
+
import "./chunk-23HQUZXQ.js";
|
|
15
|
+
import {
|
|
16
|
+
requireDocsDir
|
|
17
|
+
} from "./chunk-SN4CWEHN.js";
|
|
18
|
+
import {
|
|
19
|
+
validateDocsDetailed
|
|
20
|
+
} from "./chunk-TAL5XRPC.js";
|
|
21
|
+
import "./chunk-ALDS7N4Q.js";
|
|
22
|
+
import "./chunk-45AKGRMZ.js";
|
|
23
|
+
import {
|
|
24
|
+
applyCommandHelp
|
|
25
|
+
} from "./chunk-FNZJHYAX.js";
|
|
26
|
+
import {
|
|
27
|
+
CliError,
|
|
28
|
+
createResultWriter,
|
|
29
|
+
failureResult,
|
|
30
|
+
invalidInput,
|
|
31
|
+
resolveGlobalOptions,
|
|
32
|
+
successResult
|
|
33
|
+
} from "./chunk-WTGIPAFR.js";
|
|
34
|
+
import {
|
|
35
|
+
CHECK_METADATA
|
|
36
|
+
} from "./chunk-QLA74ZD6.js";
|
|
37
|
+
import "./chunk-2NFN6VFP.js";
|
|
38
|
+
|
|
39
|
+
// src/commands/check.ts
|
|
40
|
+
var MISSING_ANCHOR = "No element with this id on the target page";
|
|
41
|
+
var LINK_FIX = "Link to a page in docs.json navigation, a file under public/, a docs.json redirect source, or a full URL.";
|
|
42
|
+
var ANCHOR_FIX = "Use the id of a heading on the target page. A heading's id is its text in lower case, with a hyphen for each space.";
|
|
43
|
+
function fromIssue(issue, severity) {
|
|
44
|
+
return { check: "validate", severity, path: issue.path, line: issue.line, column: issue.column, rule: issue.code, message: issue.message, fix: issue.fix };
|
|
45
|
+
}
|
|
46
|
+
function fromLink(link) {
|
|
47
|
+
const anchor = link.reason === MISSING_ANCHOR;
|
|
48
|
+
const count = link.occurrences > 1 ? ` It is on ${link.occurrences} rendered pages; the first is ${link.rendered}.` : "";
|
|
49
|
+
return {
|
|
50
|
+
check: "links",
|
|
51
|
+
severity: "error",
|
|
52
|
+
path: link.file,
|
|
53
|
+
line: link.line,
|
|
54
|
+
column: link.column,
|
|
55
|
+
rule: anchor ? "missing_anchor" : "broken_link",
|
|
56
|
+
message: `link to ${link.link} does not resolve: ${link.reason}.${count}`,
|
|
57
|
+
fix: anchor ? ANCHOR_FIX : LINK_FIX
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
var placeKey = (finding) => `${finding.path}\0${finding.line}\0${finding.column}\0${finding.rule}`;
|
|
61
|
+
function ordered(findings) {
|
|
62
|
+
return findings.map((finding, index) => ({ finding, index })).sort((left, right) => {
|
|
63
|
+
const a = left.finding;
|
|
64
|
+
const b = right.finding;
|
|
65
|
+
if (a.path !== b.path) return a.path === null ? 1 : b.path === null ? -1 : a.path < b.path ? -1 : 1;
|
|
66
|
+
const line = (a.line ?? Number.MAX_SAFE_INTEGER) - (b.line ?? Number.MAX_SAFE_INTEGER);
|
|
67
|
+
if (line !== 0) return line;
|
|
68
|
+
const column = (a.column ?? 0) - (b.column ?? 0);
|
|
69
|
+
return column !== 0 ? column : left.index - right.index;
|
|
70
|
+
}).map((entry) => entry.finding);
|
|
71
|
+
}
|
|
72
|
+
async function checkDocs(docsDir, options) {
|
|
73
|
+
const limitations = [];
|
|
74
|
+
const validation = await validateDocsDetailed(docsDir);
|
|
75
|
+
let findings = [
|
|
76
|
+
...validation.errors.map((issue) => fromIssue(issue, "error")),
|
|
77
|
+
...validation.warnings.map((issue) => fromIssue(issue, "warning"))
|
|
78
|
+
];
|
|
79
|
+
const seen = new Set(findings.map(placeKey));
|
|
80
|
+
const lint = await lintDocsDir(docsDir);
|
|
81
|
+
for (const found of lint.findings) {
|
|
82
|
+
const finding = {
|
|
83
|
+
check: "lint",
|
|
84
|
+
severity: found.severity,
|
|
85
|
+
path: found.path === "" ? null : found.path,
|
|
86
|
+
line: found.line,
|
|
87
|
+
column: found.column ?? null,
|
|
88
|
+
rule: found.rule,
|
|
89
|
+
message: found.message,
|
|
90
|
+
fix: found.fix ?? null
|
|
91
|
+
};
|
|
92
|
+
if (seen.has(placeKey(finding)) || seen.has(placeKey({ ...finding, column: null }))) continue;
|
|
93
|
+
findings.push(finding);
|
|
94
|
+
}
|
|
95
|
+
const failed = (check) => findings.some((finding) => finding.check === check && finding.severity === "error");
|
|
96
|
+
const checks = { validate: failed("validate") ? "failed" : "passed", lint: failed("lint") ? "failed" : "passed", links: "skipped" };
|
|
97
|
+
const unbuildable = validation.errors.some((issue) => issue.code !== "unresolved_link");
|
|
98
|
+
const without = (message, state) => {
|
|
99
|
+
checks.links = state;
|
|
100
|
+
limitations.push({ code: "section_unavailable", at: "checks.links", message });
|
|
101
|
+
};
|
|
102
|
+
if (!options.links) {
|
|
103
|
+
without("The rendered link and fragment check did not run, because --skip-links was passed.", "skipped");
|
|
104
|
+
} else if (unbuildable) {
|
|
105
|
+
without("The rendered link and fragment check did not run, because the site does not build until the errors are fixed. Fix them and run check again.", "skipped");
|
|
106
|
+
} else {
|
|
107
|
+
try {
|
|
108
|
+
const rendered = await checkLinks(docsDir, options.cache, options.provide, options.siteUrl);
|
|
109
|
+
findings = findings.filter((finding) => finding.rule !== "unresolved_link");
|
|
110
|
+
findings.push(...rendered.diagnostics.map(fromLink));
|
|
111
|
+
checks.links = rendered.diagnostics.length > 0 ? "failed" : "passed";
|
|
112
|
+
checks.validate = failed("validate") ? "failed" : "passed";
|
|
113
|
+
} catch (error) {
|
|
114
|
+
const issues = error instanceof CliError && error.code === "invalid_input" ? error.data?.errors : void 0;
|
|
115
|
+
if (error instanceof RendererError || issues?.every((issue) => issue.code === "preview_unsupported")) {
|
|
116
|
+
without(`The rendered link and fragment check did not run: ${error.message.split("\n")[0]}`, "unavailable");
|
|
117
|
+
} else if (issues !== void 0) {
|
|
118
|
+
findings.push(...issues.map((issue) => ({ ...fromIssue(issue, "error"), check: "links" })));
|
|
119
|
+
checks.links = "failed";
|
|
120
|
+
} else {
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
findings = ordered(findings);
|
|
126
|
+
const errors = findings.filter((finding) => finding.severity === "error").length;
|
|
127
|
+
return {
|
|
128
|
+
report: { docs_dir: docsDir, passed: errors === 0, errors, warnings: findings.length - errors, checks, findings },
|
|
129
|
+
limitations
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function checkReportText(report) {
|
|
133
|
+
const lines = report.findings.flatMap((finding) => {
|
|
134
|
+
const place = finding.path === null ? "bundle" : finding.line === null ? finding.path : finding.column === null ? `${finding.path}:${finding.line}` : `${finding.path}:${finding.line}:${finding.column}`;
|
|
135
|
+
const head = `${place} ${finding.severity} ${finding.rule} (${finding.check}): ${finding.message}`;
|
|
136
|
+
return finding.fix === null ? [head] : [head, ` fix: ${finding.fix}`];
|
|
137
|
+
});
|
|
138
|
+
const states = ["validate", "lint", "links"].map((check) => `${check} ${report.checks[check]}`).join(", ");
|
|
139
|
+
lines.push(`${report.passed ? "\u2713" : "\u2716"} ${report.errors} error(s) and ${report.warnings} warning(s) in ${report.docs_dir}: ${states}.`);
|
|
140
|
+
return lines.join("\n");
|
|
141
|
+
}
|
|
142
|
+
function registerCheck(program, provide, cache) {
|
|
143
|
+
const command = program.command("check").argument("[dir]", "The docs directory. Defaults to the current directory.").option("--skip-links", "Skip the rendered link and fragment check, which builds the site.").option("--site-url <url>", "Override the production site URL for the link check.").action(async (dir, options, self) => {
|
|
144
|
+
const writer = createResultWriter({ json: resolveGlobalOptions(self).json });
|
|
145
|
+
const context = { command: "check", siteId: null };
|
|
146
|
+
try {
|
|
147
|
+
const { report, limitations } = await checkDocs(requireDocsDir(dir), { links: options.skipLinks !== true, siteUrl: options.siteUrl, cache, provide });
|
|
148
|
+
if (!report.passed) throw invalidInput(checkReportText(report), { data: report, limitations });
|
|
149
|
+
process.exitCode = writer.write(successResult({ ...context, limitations }, report), { text: checkReportText(report) });
|
|
150
|
+
} catch (error) {
|
|
151
|
+
process.exitCode = writer.write(failureResult(error, context));
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
applyCommandHelp(command, CHECK_METADATA[0]);
|
|
155
|
+
}
|
|
156
|
+
export {
|
|
157
|
+
checkDocs,
|
|
158
|
+
checkReportText,
|
|
159
|
+
registerCheck
|
|
160
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
collectOutsideRootFiles,
|
|
3
3
|
configLocator,
|
|
4
|
-
|
|
5
|
-
} from "./chunk-
|
|
4
|
+
validateDocsDetailed
|
|
5
|
+
} from "./chunk-TAL5XRPC.js";
|
|
6
6
|
import {
|
|
7
7
|
SOURCE_ALLOWED_ROOTS,
|
|
8
8
|
SOURCE_LIMITS,
|
|
@@ -12,10 +12,13 @@ import {
|
|
|
12
12
|
frontmatterPolicy,
|
|
13
13
|
normalizeComponentMarkdown,
|
|
14
14
|
validateBundleStructure
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ALDS7N4Q.js";
|
|
16
16
|
import {
|
|
17
17
|
parseDocsConfig
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-45AKGRMZ.js";
|
|
19
|
+
import {
|
|
20
|
+
invalidInput
|
|
21
|
+
} from "./chunk-WTGIPAFR.js";
|
|
19
22
|
|
|
20
23
|
// src/lib/preview/components.ts
|
|
21
24
|
import { spawn } from "child_process";
|
|
@@ -1567,11 +1570,23 @@ async function previewFonts(config, cache, directory, signal) {
|
|
|
1567
1570
|
// src/lib/preview/generation.ts
|
|
1568
1571
|
var roots = new Map(SOURCE_ALLOWED_ROOTS.map((pattern) => [pattern.split("/")[0], pattern.includes("/")]));
|
|
1569
1572
|
var previewRoots = new Set(roots.keys());
|
|
1573
|
+
var NO_READER_PREVIEW = "Check this site with validate and lint. Local preview does not support reader sign-in.";
|
|
1574
|
+
function issueLine(issue) {
|
|
1575
|
+
const head = `${issue.path ?? "bundle"}:${issue.line ?? 1}:${issue.column ?? 1}: ${issue.message}`;
|
|
1576
|
+
return issue.fix === null || issue.message.includes(issue.fix) ? head : `${head}
|
|
1577
|
+
fix: ${issue.fix}`;
|
|
1578
|
+
}
|
|
1579
|
+
function sourceError(issues) {
|
|
1580
|
+
return invalidInput(issues.map(issueLine).join("\n"), { data: { errors: issues } });
|
|
1581
|
+
}
|
|
1582
|
+
function sourceIssue(path2, line, column, code, message, fix = null) {
|
|
1583
|
+
return { path: path2, line, column, code, message, fix };
|
|
1584
|
+
}
|
|
1570
1585
|
function checkConfig(text) {
|
|
1571
1586
|
const config = parseDocsConfig(JSON.parse(text));
|
|
1572
1587
|
if (config.type === "portal" || config.auth?.oidc) {
|
|
1573
1588
|
const loc = configLocator(text)(config.type === "portal" ? ["type"] : ["auth", "oidc"]);
|
|
1574
|
-
throw
|
|
1589
|
+
throw sourceError([sourceIssue("docs.json", loc?.line ?? 1, loc?.column ?? 1, "preview_unsupported", "Reader sign-in cannot be previewed on this computer.", NO_READER_PREVIEW)]);
|
|
1575
1590
|
}
|
|
1576
1591
|
return config;
|
|
1577
1592
|
}
|
|
@@ -1579,10 +1594,13 @@ function checkPage(file, bytes) {
|
|
|
1579
1594
|
try {
|
|
1580
1595
|
if (!frontmatterPolicy(bytes).grouped) return;
|
|
1581
1596
|
} catch (error) {
|
|
1582
|
-
throw
|
|
1597
|
+
throw sourceError([sourceIssue(file, 1, 1, "invalid_frontmatter", `Cannot read reader policy. Correct the page frontmatter. ${error}`)]);
|
|
1583
1598
|
}
|
|
1584
1599
|
const line = new TextDecoder().decode(bytes).split("\n").findIndex((l) => /^groups\s*:/.test(l));
|
|
1585
|
-
throw
|
|
1600
|
+
throw sourceError([sourceIssue(file, Math.max(1, line + 1), 1, "preview_unsupported", "Reader groups cannot be previewed on this computer.", NO_READER_PREVIEW)]);
|
|
1601
|
+
}
|
|
1602
|
+
function isSourceError(error) {
|
|
1603
|
+
return error instanceof Error && error.name === "CliError" && error.code === "invalid_input";
|
|
1586
1604
|
}
|
|
1587
1605
|
async function buildGeneration(docs, dir, cache, renderer, siteUrl, policyChecked, signal, linkCheck = "source") {
|
|
1588
1606
|
const started = performance.now();
|
|
@@ -1593,7 +1611,8 @@ async function buildGeneration(docs, dir, cache, renderer, siteUrl, policyChecke
|
|
|
1593
1611
|
try {
|
|
1594
1612
|
config = checkConfig(readFileSync2(join4(source, "docs.json"), "utf8"));
|
|
1595
1613
|
} catch (error) {
|
|
1596
|
-
|
|
1614
|
+
if (isSourceError(error)) throw error;
|
|
1615
|
+
throw sourceError([sourceIssue("docs.json", 1, 1, "invalid_docs_json", `Cannot admit docs.json. Check the site configuration. ${error}`)]);
|
|
1597
1616
|
}
|
|
1598
1617
|
for (const file of paths.filter((file2) => file2.startsWith("pages/"))) checkPage(file, readFileSync2(join4(source, file)));
|
|
1599
1618
|
policyChecked?.(true);
|
|
@@ -1605,12 +1624,18 @@ async function buildGeneration(docs, dir, cache, renderer, siteUrl, policyChecke
|
|
|
1605
1624
|
hash.update(JSON.stringify([path2, bytes.length])).update(bytes);
|
|
1606
1625
|
}
|
|
1607
1626
|
const invalid = validateBundleStructure(inventory).filter((v) => v.severity === "error");
|
|
1608
|
-
if (invalid.length)
|
|
1609
|
-
|
|
1610
|
-
|
|
1627
|
+
if (invalid.length) {
|
|
1628
|
+
throw sourceError(invalid.map((v) => ({ path: v.path ?? null, line: v.line ?? null, column: v.column ?? null, code: v.code, message: v.message, fix: v.fix ?? null })));
|
|
1629
|
+
}
|
|
1630
|
+
const validation = await validateDocsDetailed(source, new Set(paths));
|
|
1631
|
+
const deadLinks = validation.errors.filter((e) => e.code === "unresolved_link");
|
|
1632
|
+
const errors = validation.errors.filter((e) => e.code !== "unresolved_link");
|
|
1633
|
+
if (errors.length) throw sourceError(errors);
|
|
1611
1634
|
const site = new URL(siteUrl ?? config.siteUrl ?? "http://localhost/");
|
|
1612
|
-
if (!["https:", "http:"].includes(site.protocol) || site.username || site.password) throw
|
|
1635
|
+
if (!["https:", "http:"].includes(site.protocol) || site.username || site.password) throw invalidInput("Expected an HTTP(S) site URL");
|
|
1613
1636
|
const { fonts, warnings } = await previewFonts(config, cache, join4(dir, "fonts"), signal);
|
|
1637
|
+
warnings.push(...validation.warnings.map((issue) => `${issue.path ?? "bundle"}: ${issue.message}`));
|
|
1638
|
+
if (linkCheck === "source") warnings.push(...deadLinks.map((issue) => `${issue.path}:${issue.line ?? 1}:${issue.column ?? 1}: ${issue.message}`));
|
|
1614
1639
|
signal?.throwIfAborted();
|
|
1615
1640
|
const components = await previewComponents(source, paths, dir, renderer.root, signal);
|
|
1616
1641
|
const out = join4(dir, "site");
|
|
@@ -1622,11 +1647,11 @@ async function buildGeneration(docs, dir, cache, renderer, siteUrl, policyChecke
|
|
|
1622
1647
|
policy = JSON.parse(readFileSync2(join4(worker, "auth-manifest.json"), "utf8"));
|
|
1623
1648
|
} catch {
|
|
1624
1649
|
policyChecked?.(false);
|
|
1625
|
-
throw new Error("worker/auth-manifest.json:1:1: Cannot read reader policy.
|
|
1650
|
+
throw new Error("worker/auth-manifest.json:1:1: Cannot read reader policy.");
|
|
1626
1651
|
}
|
|
1627
1652
|
if (!isAuthzManifest(policy) || policy.requireAuth || policy.routes.length || policy.oidc) {
|
|
1628
1653
|
policyChecked?.(false);
|
|
1629
|
-
throw
|
|
1654
|
+
throw sourceError([sourceIssue("docs.json", 1, 1, "preview_unsupported", "The rendered site restricts reader access, which cannot be previewed on this computer.", NO_READER_PREVIEW)]);
|
|
1630
1655
|
}
|
|
1631
1656
|
return { out, worker, policy, report: {
|
|
1632
1657
|
author_preview: true,
|
|
@@ -843,6 +843,7 @@ var PrPreviewRecord = z2.object({
|
|
|
843
843
|
host: z2.string(),
|
|
844
844
|
url: nullableString,
|
|
845
845
|
pr_url: nullableString,
|
|
846
|
+
comment_url: nullableString.optional(),
|
|
846
847
|
head_ref: nullableString,
|
|
847
848
|
head_sha: nullableString,
|
|
848
849
|
built_sha: nullableString,
|
|
@@ -1919,6 +1920,7 @@ var SESSION_MESSAGE_LIMIT = 2e3;
|
|
|
1919
1920
|
var REVISION_NOTE_LIMIT = 4e3;
|
|
1920
1921
|
var cursor = { name: "--cursor", value: "string", required: false, description: "The next_cursor of the preceding page. One page is read per invocation." };
|
|
1921
1922
|
var limit = { name: "--limit", value: "integer", required: false, description: "Page size, within the operation's server ceiling." };
|
|
1923
|
+
var LOCAL_BUILD_EXITS = Object.freeze([EXIT.success, EXIT.invalid_input, EXIT.service_failure, EXIT.interrupted]);
|
|
1922
1924
|
var P0_COMMANDS = [
|
|
1923
1925
|
{ name: "auth status", operation: "sites.list", operations: ["sites.list"], permission: "manage:read", mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [], exits: READ_EXITS, summary: "Verify read access and report the credential's own site. Says nothing about scopes the server did not return." },
|
|
1924
1926
|
{ name: "login", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [{ name: "--new-site", value: "string", required: false, description: "Propose a new site address; the person creates the site while approving." }, { name: "--scope", value: "string", required: false, description: "Comma-separated permissions to request: read, draft, build, publish. Omit to let the person choose from the defaults." }, { name: "--no-wait", value: "boolean", required: false, description: "Print the approval link and exit; finish later with --resume." }, { name: "--resume", value: "boolean", required: false, description: "Wait for the approval started by an earlier --no-wait." }, { name: "--open", value: "boolean", required: false, description: "Open the approval link in the default browser." }], exits: WAIT_EXITS, summary: "Ask a person to approve this agent for one site in the browser, then save the resulting login." },
|
|
@@ -1932,6 +1934,13 @@ var P0_COMMANDS = [
|
|
|
1932
1934
|
{ name: "nav", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [{ name: "--outline", value: "string", required: true, description: "Path to the approved outline JSON." }], exits: [EXIT.success, EXIT.invalid_input, EXIT.interrupted], summary: "Rewrite docs.json navigation from an approved outline. Local; no credential and no network." },
|
|
1933
1935
|
{ name: "lint", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [], exits: [EXIT.success, EXIT.invalid_input, EXIT.interrupted], summary: "Content lint and the known-pitfalls catalog over every page; exits 2 when any finding is an error. Local." },
|
|
1934
1936
|
{ name: "coverage", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [{ name: "--outline", value: "string", required: true, description: "Path to the approved outline JSON." }], exits: [EXIT.success, EXIT.invalid_input, EXIT.interrupted], summary: "Compare the pages on disk with an approved outline. Local." },
|
|
1937
|
+
{ name: "check", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [{ name: "--skip-links", value: "boolean", required: false, description: "Skip the rendered link and fragment check, which builds the site." }, { name: "--site-url", value: "string", required: false, description: "Override the production site URL for the link check." }], exits: LOCAL_BUILD_EXITS, summary: "Run every local check before a push: validate, lint, and rendered links. Exits 2 when any finding is an error." },
|
|
1938
|
+
{ name: "init", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [{ name: "--name", value: "string", required: false, description: "Site name. Defaults to the directory name." }, { name: "--primary", value: "string", required: false, description: "Primary brand color, as a CSS color." }, { name: "--from-url", value: "string", required: false, description: "Read the name and brand color from a website." }, { name: "--yes", value: "boolean", required: false, description: "Accepted for scripts. The command asks no question." }], exits: LOCAL_BUILD_EXITS, summary: "Scaffold a docs project: docs.json, two starter pages, and AGENTS.md." },
|
|
1939
|
+
{ name: "validate", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [], exits: [EXIT.success, EXIT.invalid_input, EXIT.interrupted], summary: "Validate docs.json, page files, assets, links, and OpenAPI specs; exits 2 on any error. Local." },
|
|
1940
|
+
{ name: "openapi-check", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [], exits: [EXIT.success, EXIT.invalid_input, EXIT.interrupted], summary: "Parse the OpenAPI specs that docs.json references and print an operation table. Local." },
|
|
1941
|
+
{ name: "dev", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [{ name: "--port", value: "integer", required: false, description: "Loopback port. Defaults to a free port." }, { name: "--open", value: "boolean", required: false, description: "Open the author preview in the default browser and sign it in." }], exits: LOCAL_BUILD_EXITS, summary: "Preview the docs on this computer with the production renderer, rebuilding on each change. Use this preview on single-user machines." },
|
|
1942
|
+
{ name: "build", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [{ name: "--out-dir", value: "string", required: true, description: "Directory for the static site. It must be outside the docs directory." }, { name: "--site-url", value: "string", required: false, description: "Site URL to render against. Defaults to http://localhost." }], exits: LOCAL_BUILD_EXITS, summary: "Build the docs into a static site with the production renderer." },
|
|
1943
|
+
{ name: "broken-links", operation: null, operations: [], permission: null, mutation: false, requires_site: false, text_input: "none", text_limit: null, flags: [{ name: "--site-url", value: "string", required: false, description: "Override the production site URL." }], exits: LOCAL_BUILD_EXITS, summary: "Build the docs and report every link and fragment that does not resolve; exits 2 when any does not." },
|
|
1935
1944
|
{ name: "manage", operation: null, operations: [], permission: null, mutation: false, requires_site: true, text_input: "optional", text_limit: null, flags: [{ name: "--data", value: "string", required: false, description: "JSON body, or @path to read one." }, { name: "--file", value: "string", required: false, description: "A multipart file part, repeatable." }, { name: "--revision", value: "string", required: false, description: "The quoted settings revision for If-Match." }], exits: WRITE_EXITS, summary: "One existing management operation chosen by the caller, under the same target and precondition rules as every other command." },
|
|
1936
1945
|
{ name: "requests create", operation: "requests.create", operations: ["requests.create"], permission: "manage:write", mutation: true, requires_site: true, text_input: "required", text_limit: REQUEST_TEXT_LIMIT, flags: [...TEXT, { name: "--submission-id", value: "string", required: true, description: "A UUID the caller keeps. Replaying it with the same payload recovers the same job." }, { name: "--page", value: "string", required: false, description: "The page the request is about." }], exits: WRITE_EXITS, summary: "Submit a documentation request and return its queued job and root thread." },
|
|
1937
1946
|
{ name: "requests reply", operation: "requests.create", operations: ["requests.create"], permission: "manage:write", mutation: true, requires_site: true, text_input: "required", text_limit: REQUEST_TEXT_LIMIT, flags: [...TEXT, { name: "--thread", value: "string", required: true, description: "The root job of the conversation being answered." }, { name: "--submission-id", value: "string", required: true, description: "A UUID the caller keeps, so a lost answer replays instead of duplicating." }], exits: WRITE_EXITS, summary: "Answer a clarification. The root thread is kept; a new job comes back." },
|
|
@@ -4040,178 +4049,6 @@ function requestChangesIds(result) {
|
|
|
4040
4049
|
return { suggestion_id: result.suggestion_id, pr_number: result.pr_number };
|
|
4041
4050
|
}
|
|
4042
4051
|
|
|
4043
|
-
// src/adapter/globals.ts
|
|
4044
|
-
import { InvalidArgumentError } from "commander";
|
|
4045
|
-
var GLOBAL_OPTION_KEYS = ["json", "site", "api", "input", "timeout"];
|
|
4046
|
-
var GLOBAL_DEFAULTS = { json: false, site: null, api: null, input: true, timeout: null };
|
|
4047
|
-
function positiveSeconds(value) {
|
|
4048
|
-
const seconds = Number(value);
|
|
4049
|
-
if (!Number.isInteger(seconds) || seconds <= 0) {
|
|
4050
|
-
throw new InvalidArgumentError("Give a positive whole number of seconds.");
|
|
4051
|
-
}
|
|
4052
|
-
return seconds;
|
|
4053
|
-
}
|
|
4054
|
-
var GLOBAL_FLAGS2 = [
|
|
4055
|
-
["--json", "One result object and a newline on stdout. Diagnostics stay on stderr."],
|
|
4056
|
-
["--site <site-id>", "The site to act on. Required for every remote mutation."],
|
|
4057
|
-
["--api <origin>", "Management API origin."],
|
|
4058
|
-
["--no-input", "Never read from a terminal."],
|
|
4059
|
-
["--timeout <seconds>", "Seconds a wait or a request may take.", positiveSeconds]
|
|
4060
|
-
];
|
|
4061
|
-
function longOf(flags) {
|
|
4062
|
-
return flags.split(/[ ,|]/)[0] ?? flags;
|
|
4063
|
-
}
|
|
4064
|
-
function applyGlobalFlags(command) {
|
|
4065
|
-
const declared = new Set(command.options.map((option) => option.long));
|
|
4066
|
-
for (const [flags, description, parser] of GLOBAL_FLAGS2) {
|
|
4067
|
-
const long = longOf(flags);
|
|
4068
|
-
if (declared.has(long) || long === "--no-input" && declared.has("--input")) continue;
|
|
4069
|
-
if (parser === void 0) command.option(flags, description);
|
|
4070
|
-
else command.option(flags, description, parser);
|
|
4071
|
-
}
|
|
4072
|
-
return command;
|
|
4073
|
-
}
|
|
4074
|
-
function applyGlobalFlagsDeep(command) {
|
|
4075
|
-
applyGlobalFlags(command);
|
|
4076
|
-
for (const child of command.commands) applyGlobalFlagsDeep(child);
|
|
4077
|
-
}
|
|
4078
|
-
function resolveGlobalOptions(command) {
|
|
4079
|
-
const chain = [];
|
|
4080
|
-
for (let node = command; node !== null; node = node.parent) chain.unshift(node);
|
|
4081
|
-
const resolved = { ...GLOBAL_DEFAULTS };
|
|
4082
|
-
for (const node of chain) {
|
|
4083
|
-
for (const key of GLOBAL_OPTION_KEYS) {
|
|
4084
|
-
const source = node.getOptionValueSource(key);
|
|
4085
|
-
if (source === void 0 || source === "default") continue;
|
|
4086
|
-
const value = node.getOptionValue(key);
|
|
4087
|
-
if (value === void 0) continue;
|
|
4088
|
-
resolved[key] = value;
|
|
4089
|
-
}
|
|
4090
|
-
}
|
|
4091
|
-
return {
|
|
4092
|
-
json: resolved.json === true,
|
|
4093
|
-
site: typeof resolved.site === "string" ? resolved.site : null,
|
|
4094
|
-
api: typeof resolved.api === "string" ? resolved.api : null,
|
|
4095
|
-
input: resolved.input !== false,
|
|
4096
|
-
timeout: typeof resolved.timeout === "number" ? resolved.timeout : null
|
|
4097
|
-
};
|
|
4098
|
-
}
|
|
4099
|
-
|
|
4100
|
-
// src/adapter/errors.ts
|
|
4101
|
-
var CliError = class extends Error {
|
|
4102
|
-
code;
|
|
4103
|
-
server;
|
|
4104
|
-
retryable;
|
|
4105
|
-
mutation;
|
|
4106
|
-
exit;
|
|
4107
|
-
limitations;
|
|
4108
|
-
recovery;
|
|
4109
|
-
data;
|
|
4110
|
-
constructor(code, message, options = {}) {
|
|
4111
|
-
super(message, options.cause === void 0 ? void 0 : { cause: options.cause });
|
|
4112
|
-
this.name = "CliError";
|
|
4113
|
-
this.code = code;
|
|
4114
|
-
this.server = options.server ?? null;
|
|
4115
|
-
this.retryable = options.retryable ?? CLIENT_ERROR_CATEGORIES[code].retryable;
|
|
4116
|
-
this.mutation = options.mutation ?? CLIENT_ERROR_CATEGORIES[code].mutation;
|
|
4117
|
-
this.exit = options.exit ?? CLIENT_ERROR_CATEGORIES[code].exit;
|
|
4118
|
-
this.limitations = options.limitations ?? [];
|
|
4119
|
-
this.recovery = options.recovery ?? null;
|
|
4120
|
-
this.data = options.data;
|
|
4121
|
-
}
|
|
4122
|
-
};
|
|
4123
|
-
function invalidInput2(message, options = {}) {
|
|
4124
|
-
return new CliError("invalid_input", message, options);
|
|
4125
|
-
}
|
|
4126
|
-
function interrupted2(message = CLIENT_ERROR_CATEGORIES.interrupted.meaning, options = {}) {
|
|
4127
|
-
return new CliError("interrupted", message, options);
|
|
4128
|
-
}
|
|
4129
|
-
function clientError2(code, message, server = null) {
|
|
4130
|
-
const category = CLIENT_ERROR_CATEGORIES[code];
|
|
4131
|
-
return { code, message, retryable: category.retryable, mutation: category.mutation, exit: category.exit, server };
|
|
4132
|
-
}
|
|
4133
|
-
function envelope2(context) {
|
|
4134
|
-
return {
|
|
4135
|
-
schema_version: CLIENT_SCHEMA_VERSION,
|
|
4136
|
-
command: context.command,
|
|
4137
|
-
site_id: context.siteId ?? null,
|
|
4138
|
-
ids: context.ids ?? {},
|
|
4139
|
-
limitations: [...context.limitations ?? []],
|
|
4140
|
-
recovery: context.recovery ?? null
|
|
4141
|
-
};
|
|
4142
|
-
}
|
|
4143
|
-
function successResult(context, data) {
|
|
4144
|
-
return { ...envelope2(context), ok: true, data };
|
|
4145
|
-
}
|
|
4146
|
-
function messageOf(error) {
|
|
4147
|
-
if (error instanceof Error && error.message !== "") return error.message;
|
|
4148
|
-
const text = String(error);
|
|
4149
|
-
return text === "" ? "The command failed and said nothing." : text;
|
|
4150
|
-
}
|
|
4151
|
-
var UNCLASSIFIED = "service_unavailable";
|
|
4152
|
-
function failureResult(error, context) {
|
|
4153
|
-
const classified = error instanceof CliError;
|
|
4154
|
-
const code = classified ? error.code : UNCLASSIFIED;
|
|
4155
|
-
const base = envelope2({
|
|
4156
|
-
...context,
|
|
4157
|
-
limitations: [...context.limitations ?? [], ...classified ? error.limitations : []],
|
|
4158
|
-
recovery: (classified ? error.recovery : null) ?? context.recovery ?? null
|
|
4159
|
-
});
|
|
4160
|
-
const failure = {
|
|
4161
|
-
...base,
|
|
4162
|
-
ok: false,
|
|
4163
|
-
error: classified ? {
|
|
4164
|
-
code,
|
|
4165
|
-
message: messageOf(error),
|
|
4166
|
-
retryable: error.retryable,
|
|
4167
|
-
mutation: error.mutation,
|
|
4168
|
-
exit: error.exit,
|
|
4169
|
-
server: error.server
|
|
4170
|
-
} : clientError2(code, messageOf(error))
|
|
4171
|
-
};
|
|
4172
|
-
if (classified && error.data !== void 0) failure.data = error.data;
|
|
4173
|
-
return failure;
|
|
4174
|
-
}
|
|
4175
|
-
|
|
4176
|
-
// src/adapter/output.ts
|
|
4177
|
-
function createResultWriter(options) {
|
|
4178
|
-
const stdout = options.stdout ?? process.stdout;
|
|
4179
|
-
const stderr = options.stderr ?? process.stderr;
|
|
4180
|
-
let written = false;
|
|
4181
|
-
let exit = 0;
|
|
4182
|
-
return {
|
|
4183
|
-
json: options.json,
|
|
4184
|
-
get written() {
|
|
4185
|
-
return written;
|
|
4186
|
-
},
|
|
4187
|
-
write(result, writeOptions = {}) {
|
|
4188
|
-
if (written) return exit;
|
|
4189
|
-
written = true;
|
|
4190
|
-
exit = exitForResult(result);
|
|
4191
|
-
if (options.json) {
|
|
4192
|
-
stdout.write(`${JSON.stringify(result)}
|
|
4193
|
-
`);
|
|
4194
|
-
return exit;
|
|
4195
|
-
}
|
|
4196
|
-
if (result.ok) {
|
|
4197
|
-
if (writeOptions.text !== void 0) stdout.write(`${writeOptions.text}
|
|
4198
|
-
`);
|
|
4199
|
-
} else {
|
|
4200
|
-
stderr.write(`error: ${result.error.message}
|
|
4201
|
-
`);
|
|
4202
|
-
}
|
|
4203
|
-
for (const limitation of result.limitations) {
|
|
4204
|
-
stderr.write(`note: ${limitation.message}
|
|
4205
|
-
`);
|
|
4206
|
-
}
|
|
4207
|
-
return exit;
|
|
4208
|
-
}
|
|
4209
|
-
};
|
|
4210
|
-
}
|
|
4211
|
-
function wantsJson(argv) {
|
|
4212
|
-
return argv.includes("--json");
|
|
4213
|
-
}
|
|
4214
|
-
|
|
4215
4052
|
export {
|
|
4216
4053
|
SUGGESTION_TABS,
|
|
4217
4054
|
EXIT,
|
|
@@ -4219,6 +4056,7 @@ export {
|
|
|
4219
4056
|
CLIENT_ERROR_CODES,
|
|
4220
4057
|
CLIENT_ERROR_CATEGORIES,
|
|
4221
4058
|
CLIENT_SCHEMA_VERSION,
|
|
4059
|
+
exitForResult,
|
|
4222
4060
|
requiresManagementReceipt,
|
|
4223
4061
|
invalidInput,
|
|
4224
4062
|
isManagementError,
|
|
@@ -4294,17 +4132,5 @@ export {
|
|
|
4294
4132
|
sendSessionMessage,
|
|
4295
4133
|
conversationIds,
|
|
4296
4134
|
requestSuggestionChanges,
|
|
4297
|
-
requestChangesIds
|
|
4298
|
-
applyGlobalFlags,
|
|
4299
|
-
applyGlobalFlagsDeep,
|
|
4300
|
-
resolveGlobalOptions,
|
|
4301
|
-
CliError,
|
|
4302
|
-
invalidInput2,
|
|
4303
|
-
interrupted2 as interrupted,
|
|
4304
|
-
clientError2 as clientError,
|
|
4305
|
-
successResult,
|
|
4306
|
-
messageOf,
|
|
4307
|
-
failureResult,
|
|
4308
|
-
createResultWriter,
|
|
4309
|
-
wantsJson
|
|
4135
|
+
requestChangesIds
|
|
4310
4136
|
};
|