saturndocs 0.4.0 → 0.5.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.
Files changed (56) hide show
  1. package/dist/{auth-NKYU6ZSC.js → auth-47SI6KTG.js} +4 -4
  2. package/dist/broken-links-EOEGVH4F.js +275 -0
  3. package/dist/build-OLTD5RJQ.js +139 -0
  4. package/dist/{chunk-6JJEMNSP.js → chunk-27ARMXM2.js} +4 -4
  5. package/dist/{chunk-3JUP4HIA.js → chunk-33MGV73K.js} +2 -2
  6. package/dist/{chunk-N66SXAI5.js → chunk-4MJYA6R5.js} +3 -3
  7. package/dist/{chunk-QMA7433F.js → chunk-7QGSIPAS.js} +3 -3
  8. package/dist/{chunk-HJ7HRIAT.js → chunk-ATM2LU6H.js} +1 -1
  9. package/dist/{chunk-ZXJ3Z3PR.js → chunk-C62AROBZ.js} +2 -2
  10. package/dist/chunk-CM2ONKCQ.js +1650 -0
  11. package/dist/{chunk-EH6E45H4.js → chunk-F5G7PDQJ.js} +82 -12
  12. package/dist/{chunk-22WNRYB7.js → chunk-FIFAZLRQ.js} +7 -7
  13. package/dist/{chunk-HHRZ3Y55.js → chunk-GNR5NWNR.js} +64 -51
  14. package/dist/{chunk-2GBM6W4I.js → chunk-JFYMBFDW.js} +3 -3
  15. package/dist/{chunk-QF5ELRAU.js → chunk-JSKBT765.js} +70 -100
  16. package/dist/{chunk-GLB47CSE.js → chunk-L6EE6XS2.js} +7 -7
  17. package/dist/chunk-LDE53VKA.js +146 -0
  18. package/dist/chunk-LLRWUKIR.js +62 -0
  19. package/dist/{chunk-ZHYL7FYA.js → chunk-MXJOVTOT.js} +26 -11
  20. package/dist/chunk-NE6SDXXB.js +52 -0
  21. package/dist/chunk-OWKBGNGZ.js +72 -0
  22. package/dist/{chunk-TRQCW5CZ.js → chunk-RI5COFYL.js} +2 -2
  23. package/dist/{chunk-KEZAO7P5.js → chunk-RNRRFICE.js} +1 -1
  24. package/dist/{chunk-BB32XQJB.js → chunk-SDNJSBGO.js} +3 -3
  25. package/dist/{chunk-BRC7CU3J.js → chunk-SIGMRKFJ.js} +2 -2
  26. package/dist/{chunk-UXCORL5H.js → chunk-UJCRJ4XU.js} +3 -3
  27. package/dist/chunk-WDOLOQAV.js +259 -0
  28. package/dist/{chunk-4B6PUKF5.js → chunk-X2YU7MAC.js} +3 -3
  29. package/dist/cli.js +3 -3
  30. package/dist/{coverage-IUQLC2H6.js → coverage-I3FWCRWG.js} +4 -4
  31. package/dist/dev-PXZCETLB.js +243 -0
  32. package/dist/{dist-LZ5BC7HG.js → dist-RJ3HLSC7.js} +2 -2
  33. package/dist/index.d.ts +1 -1
  34. package/dist/index.js +60 -109
  35. package/dist/{init-EFZZRZZM.js → init-GQELTILS.js} +4 -4
  36. package/dist/{lint-N7ENEJVU.js → lint-MR7LHMLU.js} +2 -2
  37. package/dist/{login-34OM3PJ2.js → login-QW5GZLWK.js} +4 -4
  38. package/dist/{manage-2AOOCZE2.js → manage-OTGX2SGZ.js} +4 -4
  39. package/dist/{nav-DKCGLENP.js → nav-3GHG5U5B.js} +4 -4
  40. package/dist/{openapiCheck-KEHPUZOD.js → openapiCheck-XAZ6FOF2.js} +2 -2
  41. package/dist/pages-BA3MMNSL.js +16 -0
  42. package/dist/{read-TQSSS7EJ.js → read-6RAHFNPS.js} +5 -5
  43. package/dist/{read-UGXFNEGJ.js → read-UCTHVWS2.js} +5 -5
  44. package/dist/renderer-76D7VFQ3.js +441 -0
  45. package/dist/requests-6OIP4LGE.js +13 -0
  46. package/dist/{schema-3I6XJSCY.js → schema-OEKCGF6Y.js} +3 -3
  47. package/dist/{sites-6HKU6JP7.js → sites-L6DPTMX6.js} +5 -5
  48. package/dist/{status-DFAYOCC4.js → status-PMVNHRK6.js} +4 -4
  49. package/dist/{suggestions-JSTWOWRY.js → suggestions-WBWQP2UN.js} +7 -7
  50. package/dist/validate-LY3ZSHSV.js +12 -0
  51. package/package.json +9 -3
  52. package/dist/chunk-KWEWL4MJ.js +0 -53
  53. package/dist/pages-E73CUM6I.js +0 -16
  54. package/dist/requests-OLCBRUAW.js +0 -13
  55. package/dist/unavailable-HVN65Q7D.js +0 -40
  56. package/dist/validate-6RIKQWMI.js +0 -11
@@ -3,11 +3,11 @@ import {
3
3
  authStatusOf,
4
4
  registerAuth,
5
5
  savedLoginStatusOf
6
- } from "./chunk-ZXJ3Z3PR.js";
7
- import "./chunk-4B6PUKF5.js";
8
- import "./chunk-HJ7HRIAT.js";
6
+ } from "./chunk-C62AROBZ.js";
7
+ import "./chunk-X2YU7MAC.js";
9
8
  import "./chunk-M2BZEDAS.js";
10
- import "./chunk-EH6E45H4.js";
9
+ import "./chunk-ATM2LU6H.js";
10
+ import "./chunk-F5G7PDQJ.js";
11
11
  export {
12
12
  AUTH_METADATA,
13
13
  authStatusOf,
@@ -0,0 +1,275 @@
1
+ import {
2
+ documentLinks
3
+ } from "./chunk-OWKBGNGZ.js";
4
+ import {
5
+ releaseRoute,
6
+ siteRoutes
7
+ } from "./chunk-WDOLOQAV.js";
8
+ import {
9
+ buildGeneration
10
+ } from "./chunk-CM2ONKCQ.js";
11
+ import "./chunk-JSKBT765.js";
12
+ import "./chunk-GNR5NWNR.js";
13
+ import {
14
+ isRedirectPattern
15
+ } from "./chunk-MXJOVTOT.js";
16
+ import {
17
+ createResultWriter,
18
+ failureResult,
19
+ invalidInput2 as invalidInput,
20
+ resolveGlobalOptions,
21
+ successResult
22
+ } from "./chunk-F5G7PDQJ.js";
23
+
24
+ // src/lib/preview/check-links.ts
25
+ import { mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync } from "fs";
26
+ import { tmpdir } from "os";
27
+ import { join, relative, sep } from "path";
28
+
29
+ // ../release-abi/src/canonical.ts
30
+ var textEncoder = new TextEncoder();
31
+ function isWellFormedUnicode(value) {
32
+ for (let index = 0; index < value.length; index += 1) {
33
+ const code = value.charCodeAt(index);
34
+ if (code >= 55296 && code <= 56319) {
35
+ const next = value.charCodeAt(index + 1);
36
+ if (!Number.isInteger(next) || next < 56320 || next > 57343) return false;
37
+ index += 1;
38
+ } else if (code >= 56320 && code <= 57343) {
39
+ return false;
40
+ }
41
+ }
42
+ return true;
43
+ }
44
+ function utf8(value) {
45
+ const encoded = textEncoder.encode(value);
46
+ const copy = new Uint8Array(encoded.byteLength);
47
+ copy.set(encoded);
48
+ return copy;
49
+ }
50
+ function lowercaseHex(bytes) {
51
+ return Array.from(new Uint8Array(bytes), (byte) => byte.toString(16).padStart(2, "0")).join("");
52
+ }
53
+
54
+ // ../release-abi/src/nav-variant.ts
55
+ var NAV_VARIANT_DIRECTORY = "__gs-variants";
56
+ var NAV_VARIANT_INDEX_FILE = `${NAV_VARIANT_DIRECTORY}/index.json`;
57
+ var VARIANT_KEY_PATTERN = /^[0-9a-f]{64}$/;
58
+ function compareGroupNames(left, right) {
59
+ if (left < right) return -1;
60
+ if (left > right) return 1;
61
+ return 0;
62
+ }
63
+ function isSortedGroupList(groups) {
64
+ for (let index = 1; index < groups.length; index += 1) {
65
+ if (compareGroupNames(groups[index - 1], groups[index]) >= 0) return false;
66
+ }
67
+ return true;
68
+ }
69
+ async function variantKey(groups) {
70
+ const digest = await crypto.subtle.digest("SHA-256", utf8(JSON.stringify([...groups])));
71
+ return lowercaseHex(digest);
72
+ }
73
+ async function parseVariantIndex(text) {
74
+ let value;
75
+ try {
76
+ value = JSON.parse(text);
77
+ } catch {
78
+ return { error: "variant index is not valid JSON" };
79
+ }
80
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
81
+ return { error: "variant index must be an object" };
82
+ }
83
+ const record = value;
84
+ const keys = Object.keys(record).sort();
85
+ if (keys.length !== 3 || keys[0] !== "groups" || keys[1] !== "variants" || keys[2] !== "version") {
86
+ return { error: "variant index must contain exactly version, groups, and variants" };
87
+ }
88
+ if (record.version !== 1) return { error: "variant index version must be 1" };
89
+ const groups = groupList(record.groups);
90
+ if (typeof groups === "string") return { error: `variant index groups are invalid: ${groups}` };
91
+ if (!Array.isArray(record.variants)) return { error: "variant index variants must be an array" };
92
+ const known = new Set(groups);
93
+ const seen = /* @__PURE__ */ new Set();
94
+ const variants = [];
95
+ for (const entry of record.variants) {
96
+ if (entry === null || typeof entry !== "object" || Array.isArray(entry)) {
97
+ return { error: "variant index entry must be an object" };
98
+ }
99
+ const variant = entry;
100
+ const entryKeys = Object.keys(variant).sort();
101
+ if (entryKeys.length !== 2 || entryKeys[0] !== "groups" || entryKeys[1] !== "key") {
102
+ return { error: "variant index entry must contain exactly key and groups" };
103
+ }
104
+ if (typeof variant.key !== "string" || !VARIANT_KEY_PATTERN.test(variant.key)) {
105
+ return { error: "variant key must be 64 lowercase hexadecimal characters" };
106
+ }
107
+ const entryGroups = groupList(variant.groups);
108
+ if (typeof entryGroups === "string") {
109
+ return { error: `variant ${variant.key} groups are invalid: ${entryGroups}` };
110
+ }
111
+ if (entryGroups.length === 0) {
112
+ return { error: `variant ${variant.key} must name at least one group` };
113
+ }
114
+ for (const group of entryGroups) {
115
+ if (!known.has(group)) {
116
+ return { error: `variant ${variant.key} names a group the index does not declare` };
117
+ }
118
+ }
119
+ if (await variantKey(entryGroups) !== variant.key) {
120
+ return { error: `variant ${variant.key} does not hash its own groups` };
121
+ }
122
+ if (seen.has(variant.key)) return { error: `variant ${variant.key} is listed twice` };
123
+ seen.add(variant.key);
124
+ variants.push({ key: variant.key, groups: entryGroups });
125
+ }
126
+ return { version: 1, groups, variants };
127
+ }
128
+ function resolveVariantFile(relativePath, index) {
129
+ if (relativePath === "" || relativePath.startsWith("/")) {
130
+ return { error: `dist path is invalid: ${relativePath}` };
131
+ }
132
+ if (relativePath !== NAV_VARIANT_DIRECTORY && !relativePath.startsWith(`${NAV_VARIANT_DIRECTORY}/`)) {
133
+ return { canonicalPath: relativePath };
134
+ }
135
+ const rest = relativePath.slice(`${NAV_VARIANT_DIRECTORY}/`.length);
136
+ const separator = rest.indexOf("/");
137
+ const key = separator === -1 ? "" : rest.slice(0, separator);
138
+ const canonicalPath = separator === -1 ? "" : rest.slice(separator + 1);
139
+ if (!VARIANT_KEY_PATTERN.test(key) || canonicalPath === "") {
140
+ return { error: `navigation variant path is malformed: ${relativePath}` };
141
+ }
142
+ if (canonicalPath === NAV_VARIANT_DIRECTORY || canonicalPath.startsWith(`${NAV_VARIANT_DIRECTORY}/`)) {
143
+ return { error: `navigation variant path is nested: ${relativePath}` };
144
+ }
145
+ if (index === null) {
146
+ return { error: `navigation variant index is missing for ${relativePath}` };
147
+ }
148
+ const variant = index.variants.find((entry) => entry.key === key);
149
+ if (variant === void 0) {
150
+ return { error: `navigation variant key is not in the index: ${key}` };
151
+ }
152
+ return { canonicalPath, navVariant: [...variant.groups] };
153
+ }
154
+ function groupList(value) {
155
+ if (!Array.isArray(value)) return "expected an array of group names";
156
+ const groups = [];
157
+ for (const group of value) {
158
+ if (typeof group !== "string" || group === "") return "expected non-empty group names";
159
+ if (!isWellFormedUnicode(group)) return "expected well-formed Unicode without lone surrogates";
160
+ groups.push(group);
161
+ }
162
+ if (!isSortedGroupList(groups)) return "expected sorted, unique group names";
163
+ return groups;
164
+ }
165
+
166
+ // src/lib/preview/check-links.ts
167
+ function diagnostic({ source, href }, reason) {
168
+ return { file: source, link: href, reason };
169
+ }
170
+ function leavesRoot(raw, base) {
171
+ const path = decodeURIComponent(raw.split(/[?#]/, 1)[0]).replace(/^(?:[a-z][a-z0-9+.-]*:)?\/\/[^/]*/i, "");
172
+ let depth = path.startsWith("/") ? 0 : base.pathname.split("/").slice(1, -1).length;
173
+ for (const segment of path.split("/")) {
174
+ if (segment === "..") {
175
+ if (--depth < 0) return true;
176
+ } else if (segment && segment !== ".") depth++;
177
+ }
178
+ return path.includes("\\") || path.includes("\0");
179
+ }
180
+ async function scanRenderedSite(site, policy, siteUrl) {
181
+ const misses = [];
182
+ let routes;
183
+ try {
184
+ routes = siteRoutes(site, policy);
185
+ } catch (error) {
186
+ return [diagnostic({ source: "site/", href: "" }, String(error))];
187
+ }
188
+ const origin = new URL(siteUrl).origin;
189
+ const documents = [...routes.files].filter(([, f]) => f.type === "text/html").map(([route, f]) => ({ route, file: f.file, source: f.path }));
190
+ const variantDir = join(site, "__gs-variants");
191
+ let entries;
192
+ try {
193
+ entries = readdirSync(variantDir, { recursive: true, withFileTypes: true });
194
+ } catch (error) {
195
+ if (error.code !== "ENOENT") throw error;
196
+ }
197
+ if (entries) {
198
+ const index = await parseVariantIndex(readFileSync(join(site, NAV_VARIANT_INDEX_FILE), "utf8"));
199
+ if ("error" in index) return [{ file: NAV_VARIANT_INDEX_FILE, link: "", reason: index.error }];
200
+ for (const entry of entries.filter((e) => e.isFile() && e.name.endsWith(".html"))) {
201
+ const file = join(entry.parentPath, entry.name);
202
+ const source = relative(site, file).split(sep).join("/");
203
+ const variant = resolveVariantFile(source, index);
204
+ if ("error" in variant) return [{ file: source, link: "", reason: variant.error }];
205
+ const route = releaseRoute(variant.canonicalPath);
206
+ if (!routes.files.has(route)) return [{ file: source, link: route, reason: "Missing base route for variant" }];
207
+ documents.push({ route, source, file });
208
+ }
209
+ }
210
+ function check(href, base) {
211
+ if (!href || href.startsWith("#")) return;
212
+ const visited = /* @__PURE__ */ new Set();
213
+ for (; ; ) {
214
+ let target;
215
+ try {
216
+ target = new URL(href, base);
217
+ if (target.protocol === "file:") return "Target is outside the build";
218
+ if (target.origin !== origin) return;
219
+ if (leavesRoot(href, base)) return "Target is outside the build";
220
+ } catch {
221
+ return "Invalid URL";
222
+ }
223
+ if (visited.has(target.pathname)) return "Redirect cycle";
224
+ visited.add(target.pathname);
225
+ const hit = routes.resolve(target.pathname, target.search);
226
+ if (!hit) return "No generated route, asset, or Worker handler";
227
+ if (!hit.redirect) return;
228
+ href = hit.redirect.headers.get("location");
229
+ base = target;
230
+ }
231
+ }
232
+ for (const { source, destination } of policy.redirects) {
233
+ if (isRedirectPattern(source)) continue;
234
+ const reason = check(destination, new URL(source, origin));
235
+ if (reason) misses.push(diagnostic({ source, href: destination }, reason));
236
+ }
237
+ for (const { source, route, file } of documents) {
238
+ for (const href of documentLinks(readFileSync(file, "utf8"))) {
239
+ const reason = check(href, new URL(route, origin));
240
+ if (reason) misses.push(diagnostic({ source, href }, reason));
241
+ }
242
+ }
243
+ return misses;
244
+ }
245
+ async function checkLinks(docs, cache, provide, siteUrl) {
246
+ const dir = mkdtempSync(join(tmpdir(), "saturndocs-links-"));
247
+ try {
248
+ const generation = await buildGeneration(realpathSync(docs), dir, cache, await provide({}), siteUrl, void 0, void 0, "rendered");
249
+ const diagnostics = await scanRenderedSite(generation.out, generation.policy, generation.report.site_url);
250
+ return { ...generation.report, diagnostics };
251
+ } finally {
252
+ rmSync(dir, { recursive: true, force: true });
253
+ }
254
+ }
255
+
256
+ // src/commands/broken-links.ts
257
+ function registerBrokenLinks(program, provide, cache) {
258
+ program.command("broken-links [docs-dir]").option("--site-url <url>", "Override the production site URL").action(async (dir, options, self) => {
259
+ const writer = createResultWriter({ json: resolveGlobalOptions(self).json });
260
+ const context = { command: "broken-links", siteId: null };
261
+ try {
262
+ const report = await checkLinks(dir ?? process.cwd(), cache, provide, options.siteUrl);
263
+ if (report.diagnostics.length) {
264
+ const message = report.diagnostics.map((d) => `${d.file}: ${d.link} \u2014 ${d.reason}`).join("\n");
265
+ throw invalidInput(message, { data: report });
266
+ }
267
+ process.exitCode = writer.write(successResult(context, report), { text: "Author preview has no broken internal links." });
268
+ } catch (error) {
269
+ process.exitCode = writer.write(failureResult(error, context));
270
+ }
271
+ });
272
+ }
273
+ export {
274
+ registerBrokenLinks
275
+ };
@@ -0,0 +1,139 @@
1
+ import {
2
+ cachePath
3
+ } from "./chunk-LDE53VKA.js";
4
+ import {
5
+ buildGeneration
6
+ } from "./chunk-CM2ONKCQ.js";
7
+ import "./chunk-JSKBT765.js";
8
+ import "./chunk-GNR5NWNR.js";
9
+ import "./chunk-MXJOVTOT.js";
10
+ import {
11
+ createResultWriter,
12
+ failureResult,
13
+ resolveGlobalOptions,
14
+ successResult
15
+ } from "./chunk-F5G7PDQJ.js";
16
+
17
+ // src/lib/preview/output.ts
18
+ import { createHash, randomUUID } from "crypto";
19
+ import { lstatSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, renameSync, rmdirSync, rmSync, writeFileSync } from "fs";
20
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "path";
21
+ var marker = ".saturndocs-author-preview";
22
+ function canonical(file) {
23
+ try {
24
+ return realpathSync(file);
25
+ } catch (error) {
26
+ if (error.code !== "ENOENT") throw error;
27
+ return join(canonical(dirname(file)), basename(file));
28
+ }
29
+ }
30
+ function contains(left, right) {
31
+ const path = relative(left.toLowerCase(), right.toLowerCase());
32
+ return path === "" || !isAbsolute(path) && path !== ".." && !path.startsWith(".." + sep);
33
+ }
34
+ function identity(path, out) {
35
+ const info = lstatSync(path, { bigint: true });
36
+ return JSON.stringify({ out, dev: String(info.dev), ino: String(info.ino), birth: String(info.birthtimeNs) });
37
+ }
38
+ function owned(out, record, directory = out) {
39
+ const info = lstatSync(directory, { throwIfNoEntry: false });
40
+ if (!info) return false;
41
+ if (info.isDirectory() && lstatSync(record, { throwIfNoEntry: false })?.isFile() && readFileSync(record, "utf8") === identity(directory, out)) return true;
42
+ throw new Error(`Output is not owned by the CLI: ${out}. Choose a new directory.`);
43
+ }
44
+ function repositoryRoot(start) {
45
+ for (let dir = start; ; dir = dirname(dir)) {
46
+ if (lstatSync(join(dir, ".git"), { throwIfNoEntry: false })) return dir;
47
+ if (dirname(dir) === dir) return null;
48
+ }
49
+ }
50
+ function rejectProjectSymlinks(requested, docs) {
51
+ const repository = repositoryRoot(docs);
52
+ const roots = [docs, realpathSync(process.cwd()), ...repository ? [repository] : []];
53
+ for (let path = requested; dirname(path) !== path; path = dirname(path)) {
54
+ if (lstatSync(path, { throwIfNoEntry: false })?.isSymbolicLink() && roots.some((root) => contains(root, canonical(dirname(path))))) {
55
+ throw new Error(`Output crosses a project symlink: ${path}`);
56
+ }
57
+ }
58
+ }
59
+ async function exportBuild(docsDir, outDir, siteUrl, cacheDir, provide) {
60
+ const docs = realpathSync(resolve(docsDir));
61
+ const requested = resolve(outDir);
62
+ rejectProjectSymlinks(requested, docs);
63
+ const out = join(canonical(dirname(requested)), basename(requested));
64
+ const destinations = [requested, out, canonical(requested)];
65
+ const site = new URL(siteUrl);
66
+ if (!["https:", "http:"].includes(site.protocol) || site.username || site.password) throw new Error("Expected an HTTP(S) site URL");
67
+ const renderer = await provide({});
68
+ for (const dir of [resolve(docsDir), docs, resolve(cacheDir), canonical(resolve(cacheDir)), resolve(renderer.root), realpathSync(renderer.root)]) {
69
+ if (destinations.some((path) => contains(dir, path) || contains(path, dir))) throw new Error(`Output overlaps protected directory: ${dir}`);
70
+ }
71
+ if (contains(docs, canonical(resolve(cacheDir)))) throw new Error("Preview cache overlaps the docs directory.");
72
+ const state = await cachePath(cacheDir, ["output-ownership"]);
73
+ const record = join(state, createHash("sha256").update(out).digest("hex"));
74
+ owned(out, record);
75
+ mkdirSync(dirname(out), { recursive: true });
76
+ const controller = new AbortController();
77
+ const interrupt = () => controller.abort(new Error("Build interrupted"));
78
+ process.on("SIGTERM", interrupt);
79
+ process.on("SIGINT", interrupt);
80
+ const stage = mkdtempSync(join(dirname(out), ".saturndocs-build-"));
81
+ try {
82
+ const { report, out: siteDir } = await buildGeneration(docs, stage, cacheDir, renderer, site.href, void 0, controller.signal);
83
+ controller.signal.throwIfAborted();
84
+ writeFileSync(join(siteDir, marker), JSON.stringify({ version: 1, out }), { flag: "wx" });
85
+ const lock = out + ".saturndocs-lock";
86
+ mkdirSync(lock, { mode: 448 });
87
+ try {
88
+ const backup = join(lock, "previous");
89
+ const replace = owned(out, record);
90
+ const pending = record + "." + randomUUID();
91
+ writeFileSync(pending, identity(siteDir, out), { flag: "wx", mode: 384 });
92
+ try {
93
+ if (replace) {
94
+ renameSync(out, backup);
95
+ owned(out, record, backup);
96
+ }
97
+ renameSync(siteDir, out);
98
+ try {
99
+ renameSync(pending, record);
100
+ } catch (error) {
101
+ renameSync(out, siteDir);
102
+ throw error;
103
+ }
104
+ } catch (error) {
105
+ if (lstatSync(backup, { throwIfNoEntry: false })) renameSync(backup, out);
106
+ throw error;
107
+ } finally {
108
+ rmSync(pending, { force: true });
109
+ }
110
+ if (replace) rmSync(backup, { recursive: true });
111
+ } finally {
112
+ if (!lstatSync(join(lock, "previous"), { throwIfNoEntry: false })) rmdirSync(lock);
113
+ }
114
+ return { ...report, output_path: out };
115
+ } finally {
116
+ process.off("SIGTERM", interrupt);
117
+ process.off("SIGINT", interrupt);
118
+ rmSync(stage, { recursive: true, force: true });
119
+ }
120
+ }
121
+
122
+ // src/commands/build.ts
123
+ 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) => {
125
+ const writer = createResultWriter({ json: resolveGlobalOptions(self).json });
126
+ const context = { command: "build", siteId: null };
127
+ try {
128
+ const report = await exportBuild(dir ?? process.cwd(), options.outDir, options.siteUrl, cache, provider);
129
+ process.exitCode = writer.write(successResult(context, report), {
130
+ text: [`Built author preview at ${report.output_path}`, ...report.warnings].join("\n")
131
+ });
132
+ } catch (error) {
133
+ process.exitCode = writer.write(failureResult(error, context));
134
+ }
135
+ });
136
+ }
137
+ export {
138
+ registerBuild
139
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  asCliError,
3
3
  clientFor
4
- } from "./chunk-4B6PUKF5.js";
4
+ } from "./chunk-X2YU7MAC.js";
5
5
  import {
6
6
  applyCommandHelp
7
7
  } from "./chunk-M2BZEDAS.js";
@@ -20,18 +20,18 @@ import {
20
20
  statusRecovery,
21
21
  statusSections,
22
22
  successResult
23
- } from "./chunk-EH6E45H4.js";
23
+ } from "./chunk-F5G7PDQJ.js";
24
24
 
25
25
  // src/commands/status.ts
26
26
  var STATUS_METADATA = Object.freeze([
27
27
  commandMetadata("status", {
28
- description: "A bounded briefing on one site, composed from the reads that already exist: the site itself, one page of conversations, one page of the pending suggestion tab, and one page of activity. There is no status route on the server and nothing here pages on your behalf. Each section reports available, empty, unavailable, or not_granted on its own, so a route that answered 503 leaves the other sections' data and identities untouched instead of blanking them. Every number comes from a field the server sent \u2014 the request failed and waiting tallies and the suggestion counts \u2014 and never from the length of a page. A credential the server refuses fails the command rather than being reported as a quiet site.",
28
+ description: "A bounded briefing on one site, composed from the reads that already exist: the site itself, one page of conversations, one page of the pending suggestion tab, and one page of activity. There is no status route on the server and nothing here pages on your behalf. Each section reports available, empty, beta_off, unavailable, or not_granted on its own, so a route that answered 503 leaves the other sections' data and identities untouched instead of blanking them. Every number comes from a field the server sent \u2014 the request failed and waiting tallies and the suggestion counts \u2014 and never from the length of a page. A credential the server refuses fails the command rather than being reported as a quiet site.",
29
29
  target: { arguments: [] },
30
30
  effect: "Nothing. Four independent reads of one site.",
31
31
  output: {
32
32
  fields: ["site", "requests", "suggestions", "activity", "counts", "attention"],
33
33
  ids: ["thread_id", "job_id", "attempt"],
34
- limitations: ["section_unavailable", "page_bounded", "field_omitted", "actor_relabeled", "row_visibility", "value_redacted"]
34
+ limitations: ["beta_off", "section_unavailable", "page_bounded", "field_omitted", "actor_relabeled", "row_visibility", "value_redacted"]
35
35
  },
36
36
  errors: ["invalid_input", "unauthorized", "forbidden", "not_found", "rate_limited", "service_unavailable", "transport_failure", "interrupted"],
37
37
  examples: [
@@ -3,7 +3,7 @@ import {
3
3
  environmentToken,
4
4
  loginEnvironment,
5
5
  resolveSavedLogin
6
- } from "./chunk-4B6PUKF5.js";
6
+ } from "./chunk-X2YU7MAC.js";
7
7
  import {
8
8
  applyCommandHelp
9
9
  } from "./chunk-M2BZEDAS.js";
@@ -21,7 +21,7 @@ import {
21
21
  resolveGlobalOptions,
22
22
  resolveTarget,
23
23
  successResult
24
- } from "./chunk-EH6E45H4.js";
24
+ } from "./chunk-F5G7PDQJ.js";
25
25
 
26
26
  // src/commands/manage.ts
27
27
  import { readFile } from "fs/promises";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  SITES_CREATE_METADATA,
3
3
  registerSitesCreate
4
- } from "./chunk-BRC7CU3J.js";
4
+ } from "./chunk-SIGMRKFJ.js";
5
5
  import {
6
6
  asCliError,
7
7
  clientFor
8
- } from "./chunk-4B6PUKF5.js";
8
+ } from "./chunk-X2YU7MAC.js";
9
9
  import {
10
10
  applyCommandHelp
11
11
  } from "./chunk-M2BZEDAS.js";
@@ -21,7 +21,7 @@ import {
21
21
  resolveGlobalOptions,
22
22
  resolveTarget,
23
23
  successResult
24
- } from "./chunk-EH6E45H4.js";
24
+ } from "./chunk-F5G7PDQJ.js";
25
25
 
26
26
  // src/commands/sites.ts
27
27
  var SITES_METADATA = Object.freeze([
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-YGVC4N4V.js";
4
4
  import {
5
5
  asCliError
6
- } from "./chunk-4B6PUKF5.js";
6
+ } from "./chunk-X2YU7MAC.js";
7
7
  import {
8
8
  applyCommandHelp
9
9
  } from "./chunk-M2BZEDAS.js";
@@ -15,7 +15,7 @@ import {
15
15
  messageOf,
16
16
  resolveGlobalOptions,
17
17
  successResult
18
- } from "./chunk-EH6E45H4.js";
18
+ } from "./chunk-F5G7PDQJ.js";
19
19
 
20
20
  // src/commands/coverage.ts
21
21
  import { existsSync } from "fs";
@@ -49,7 +49,7 @@ async function runCoverage(docsDir, outlinePath) {
49
49
  } catch (error) {
50
50
  throw invalidInput(`Cannot read the outline file ${outlinePath}: ${messageOf(error)}`);
51
51
  }
52
- const { parseOutline, outlineCoverage } = await import("./dist-LZ5BC7HG.js");
52
+ const { parseOutline, outlineCoverage } = await import("./dist-RJ3HLSC7.js");
53
53
  let outline;
54
54
  try {
55
55
  outline = parseOutline(JSON.parse(raw));
@@ -2,7 +2,7 @@ import {
2
2
  EXIT,
3
3
  failureResult,
4
4
  interrupted
5
- } from "./chunk-EH6E45H4.js";
5
+ } from "./chunk-F5G7PDQJ.js";
6
6
 
7
7
  // src/adapter/signals.ts
8
8
  var active = null;
@@ -7,7 +7,7 @@ import {
7
7
  loginAgainRecovery,
8
8
  loginEnvironment,
9
9
  resolveSavedLogin
10
- } from "./chunk-4B6PUKF5.js";
10
+ } from "./chunk-X2YU7MAC.js";
11
11
  import {
12
12
  applyCommandHelp
13
13
  } from "./chunk-M2BZEDAS.js";
@@ -21,7 +21,7 @@ import {
21
21
  parseOrigin,
22
22
  resolveGlobalOptions,
23
23
  successResult
24
- } from "./chunk-EH6E45H4.js";
24
+ } from "./chunk-F5G7PDQJ.js";
25
25
 
26
26
  // src/commands/auth.ts
27
27
  var AUTH_METADATA = Object.freeze([