saturndocs 0.2.0 → 0.4.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-NKYU6ZSC.js +16 -0
- package/dist/{chunk-QF2ADHQZ.js → chunk-22WNRYB7.js} +17 -19
- package/dist/{chunk-2RZEC3VH.js → chunk-2GBM6W4I.js} +102 -34
- package/dist/{chunk-4ORVQCHY.js → chunk-3JUP4HIA.js} +34 -9
- package/dist/chunk-4B6PUKF5.js +915 -0
- package/dist/{chunk-GGGL4O7Z.js → chunk-6JJEMNSP.js} +8 -7
- package/dist/{chunk-Z5CBPJ2L.js → chunk-BB32XQJB.js} +9 -5
- package/dist/chunk-BRC7CU3J.js +427 -0
- package/dist/{chunk-ADZOBRZE.js → chunk-EH6E45H4.js} +805 -146
- package/dist/{chunk-DBMFJXKP.js → chunk-GLB47CSE.js} +5 -5
- package/dist/{chunk-EB7RWFQA.js → chunk-HHRZ3Y55.js} +1594 -140
- package/dist/{chunk-2YTD2XNI.js → chunk-HJ7HRIAT.js} +1 -1
- package/dist/{chunk-WBI4EI3D.js → chunk-KEZAO7P5.js} +2 -2
- package/dist/chunk-KWEWL4MJ.js +53 -0
- package/dist/{chunk-W3GKH5DY.js → chunk-N66SXAI5.js} +19 -11
- package/dist/chunk-QF5ELRAU.js +421 -0
- package/dist/{chunk-WUPP3THV.js → chunk-QMA7433F.js} +5 -5
- package/dist/{chunk-YSFP37B7.js → chunk-TRQCW5CZ.js} +20 -6
- package/dist/{chunk-6JGAA5TF.js → chunk-UXCORL5H.js} +4 -4
- package/dist/{chunk-56U46JVN.js → chunk-YGVC4N4V.js} +2 -1
- package/dist/chunk-ZHYL7FYA.js +1537 -0
- package/dist/chunk-ZXJ3Z3PR.js +115 -0
- package/dist/cli.js +6 -6
- package/dist/{coverage-EBWULNQQ.js → coverage-IUQLC2H6.js} +5 -5
- package/dist/{dist-XISZDQTR.js → dist-LZ5BC7HG.js} +38 -3
- package/dist/index.d.ts +69 -37
- package/dist/index.js +111 -47
- package/dist/{init-PI4VTG7V.js → init-EFZZRZZM.js} +4 -3
- package/dist/{lint-SXBP37G3.js → lint-N7ENEJVU.js} +3 -3
- package/dist/login-34OM3PJ2.js +22 -0
- package/dist/{manage-OB6DQK3Q.js → manage-2AOOCZE2.js} +6 -2
- package/dist/{nav-R4OORY2G.js → nav-DKCGLENP.js} +4 -4
- package/dist/openapiCheck-KEHPUZOD.js +103 -0
- package/dist/pages-E73CUM6I.js +16 -0
- package/dist/{read-WWOMA67R.js → read-TQSSS7EJ.js} +60 -12
- package/dist/{read-VECMKHBW.js → read-UGXFNEGJ.js} +11 -9
- package/dist/requests-OLCBRUAW.js +13 -0
- package/dist/{schema-NKOXZHQH.js → schema-3I6XJSCY.js} +3 -3
- package/dist/{sites-XMMGWPY2.js → sites-6HKU6JP7.js} +5 -4
- package/dist/{status-SYIUUSSU.js → status-DFAYOCC4.js} +4 -4
- package/dist/{suggestions-GX5CQK26.js → suggestions-JSTWOWRY.js} +35 -20
- package/dist/unavailable-HVN65Q7D.js +40 -0
- package/dist/validate-6RIKQWMI.js +11 -0
- package/package.json +14 -8
- package/dist/auth-DUYYFNEZ.js +0 -14
- package/dist/brokenLinks-E364XYH3.js +0 -48
- package/dist/build-F5PWGP57.js +0 -39
- package/dist/chunk-4J33CCAC.js +0 -49
- package/dist/chunk-D3CLXV7D.js +0 -131
- package/dist/chunk-FGKHDJOC.js +0 -697
- package/dist/chunk-GLI3OUYL.js +0 -637
- package/dist/chunk-K5YY6NSF.js +0 -71
- package/dist/chunk-KOJJUISB.js +0 -39
- package/dist/chunk-O72DR5FK.js +0 -152
- package/dist/chunk-SVDVBZPA.js +0 -588
- package/dist/chunk-VNYDYHXM.js +0 -22
- package/dist/chunk-VXEUNRVA.js +0 -26
- package/dist/chunk-WHNL6UYJ.js +0 -57
- package/dist/deploy-QUVLOGII.js +0 -13
- package/dist/dev-VDSDCBO2.js +0 -43
- package/dist/openapiCheck-X2QQGETY.js +0 -66
- package/dist/pages-MKFZAVGI.js +0 -15
- package/dist/requests-A7WC3B4M.js +0 -13
- package/dist/validate-D4I3DY2W.js +0 -32
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AUTH_METADATA,
|
|
3
|
+
authStatusOf,
|
|
4
|
+
registerAuth,
|
|
5
|
+
savedLoginStatusOf
|
|
6
|
+
} from "./chunk-ZXJ3Z3PR.js";
|
|
7
|
+
import "./chunk-4B6PUKF5.js";
|
|
8
|
+
import "./chunk-HJ7HRIAT.js";
|
|
9
|
+
import "./chunk-M2BZEDAS.js";
|
|
10
|
+
import "./chunk-EH6E45H4.js";
|
|
11
|
+
export {
|
|
12
|
+
AUTH_METADATA,
|
|
13
|
+
authStatusOf,
|
|
14
|
+
registerAuth,
|
|
15
|
+
savedLoginStatusOf
|
|
16
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
readTextInput
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KEZAO7P5.js";
|
|
4
4
|
import {
|
|
5
5
|
asCliError,
|
|
6
6
|
clientFor
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-4B6PUKF5.js";
|
|
8
8
|
import {
|
|
9
9
|
interruptSignal
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-HJ7HRIAT.js";
|
|
11
11
|
import {
|
|
12
12
|
applyCommandHelp
|
|
13
13
|
} from "./chunk-M2BZEDAS.js";
|
|
@@ -16,22 +16,24 @@ import {
|
|
|
16
16
|
DEFAULT_REQUEST_WAIT_MS,
|
|
17
17
|
REQUEST_TEXT_LIMIT,
|
|
18
18
|
checkedRequestText,
|
|
19
|
+
checkedRequestThreadLimit,
|
|
19
20
|
checkedSubmissionId,
|
|
20
21
|
commandMetadata,
|
|
21
22
|
createRequest,
|
|
22
23
|
createResultWriter,
|
|
23
24
|
failureResult,
|
|
24
|
-
invalidInput,
|
|
25
|
+
invalidInput2 as invalidInput,
|
|
25
26
|
listRequestThreads,
|
|
26
27
|
readRequestThread,
|
|
27
28
|
replyToRequest,
|
|
29
|
+
requestGrantLimitations,
|
|
28
30
|
requestWaitErrorCode,
|
|
29
31
|
resolveGlobalOptions,
|
|
30
32
|
resolveTarget,
|
|
31
33
|
retryRequest,
|
|
32
34
|
successResult,
|
|
33
35
|
waitForRequest
|
|
34
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-EH6E45H4.js";
|
|
35
37
|
|
|
36
38
|
// src/commands/requests/create.ts
|
|
37
39
|
var REQUESTS_CREATE_METADATA = Object.freeze([
|
|
@@ -117,7 +119,7 @@ var REQUESTS_READ_METADATA = Object.freeze([
|
|
|
117
119
|
output: {
|
|
118
120
|
fields: ["threads", "page_cursor", "next_cursor", "has_newer", "failed", "waiting"],
|
|
119
121
|
ids: [],
|
|
120
|
-
limitations: ["page_bounded"]
|
|
122
|
+
limitations: ["page_bounded", "field_omitted", "actor_relabeled", "row_visibility"]
|
|
121
123
|
},
|
|
122
124
|
errors: ["invalid_input", "unauthorized", "forbidden", "not_found", "rate_limited", "service_unavailable", "transport_failure", "interrupted"],
|
|
123
125
|
examples: [
|
|
@@ -133,7 +135,7 @@ var REQUESTS_READ_METADATA = Object.freeze([
|
|
|
133
135
|
output: {
|
|
134
136
|
fields: ["root", "thread_id", "site_id", "open", "latest_job", "entries"],
|
|
135
137
|
ids: ["thread_id", "job_id", "attempt", "suggestion_id"],
|
|
136
|
-
limitations: ["page_bounded"]
|
|
138
|
+
limitations: ["page_bounded", "field_omitted", "actor_relabeled"]
|
|
137
139
|
},
|
|
138
140
|
errors: ["invalid_input", "unauthorized", "forbidden", "not_found", "rate_limited", "service_unavailable", "transport_failure", "interrupted"],
|
|
139
141
|
examples: [
|
|
@@ -147,21 +149,16 @@ async function prepare(globals, environment) {
|
|
|
147
149
|
const target = await resolveTarget(client, globals.site === null ? {} : { site: globals.site });
|
|
148
150
|
return { client, siteId: target.site_id };
|
|
149
151
|
}
|
|
150
|
-
function integerFlag(value, name) {
|
|
151
|
-
if (value === void 0) return void 0;
|
|
152
|
-
const parsed = Number(value);
|
|
153
|
-
if (!Number.isInteger(parsed)) throw invalidInput(`${name} takes a whole number.`);
|
|
154
|
-
return parsed;
|
|
155
|
-
}
|
|
156
152
|
function registerList(group, environment) {
|
|
157
153
|
const metadata = REQUESTS_READ_METADATA[0];
|
|
158
154
|
const command = group.command("list").action(async (_options, self) => {
|
|
159
155
|
const globals = resolveGlobalOptions(self);
|
|
160
156
|
const writer = createResultWriter({ json: globals.json });
|
|
161
|
-
const context = { command: "requests list", siteId:
|
|
157
|
+
const context = { command: "requests list", siteId: globals.site };
|
|
162
158
|
try {
|
|
163
159
|
const flags = self.opts();
|
|
164
|
-
const limit =
|
|
160
|
+
const limit = checkedRequestThreadLimit(flags.limit === void 0 ? void 0 : Number(flags.limit));
|
|
161
|
+
context.siteId = null;
|
|
165
162
|
const run = await prepare(globals, environment);
|
|
166
163
|
context.siteId = run.siteId;
|
|
167
164
|
const page = await listRequestThreads(run.client, {
|
|
@@ -172,7 +169,7 @@ function registerList(group, environment) {
|
|
|
172
169
|
const bounded = {
|
|
173
170
|
...context,
|
|
174
171
|
siteId: run.siteId,
|
|
175
|
-
limitations: [{
|
|
172
|
+
limitations: [...run.client.grantAuthenticated ? requestGrantLimitations(page) : [], {
|
|
176
173
|
code: "page_bounded",
|
|
177
174
|
message: page.next_cursor === null ? "One page was read. The server reported no page after it." : "One page was read. Pass its next_cursor to read the page after it.",
|
|
178
175
|
at: "threads"
|
|
@@ -194,7 +191,7 @@ function idsOf(thread) {
|
|
|
194
191
|
attempt: thread.latest_job.attempt
|
|
195
192
|
};
|
|
196
193
|
if (thread.latest_job.suggestion_id !== null) ids.suggestion_id = thread.latest_job.suggestion_id;
|
|
197
|
-
if (thread.latest_job.pr_number
|
|
194
|
+
if (thread.latest_job.pr_number != null) ids.pr_number = thread.latest_job.pr_number;
|
|
198
195
|
return ids;
|
|
199
196
|
}
|
|
200
197
|
function registerGet(group, environment) {
|
|
@@ -212,7 +209,7 @@ function registerGet(group, environment) {
|
|
|
212
209
|
});
|
|
213
210
|
context.siteId = thread.site_id;
|
|
214
211
|
context.ids = idsOf(thread);
|
|
215
|
-
context.limitations = [{
|
|
212
|
+
context.limitations = [...run.client.grantAuthenticated ? requestGrantLimitations(thread) : [], {
|
|
216
213
|
code: "page_bounded",
|
|
217
214
|
message: "The server bounds this read to the newest 100 entries and supplies no total or cursor, so older entries may not be present.",
|
|
218
215
|
at: "entries"
|
|
@@ -362,7 +359,7 @@ var REQUESTS_WAIT_METADATA = Object.freeze([
|
|
|
362
359
|
output: {
|
|
363
360
|
fields: ["outcome", "state", "job_id", "attempt", "suggestion_id", "thread", "polls", "elapsed_ms"],
|
|
364
361
|
ids: ["thread_id", "job_id", "attempt", "suggestion_id"],
|
|
365
|
-
limitations: []
|
|
362
|
+
limitations: ["section_unavailable", "field_omitted", "actor_relabeled"]
|
|
366
363
|
},
|
|
367
364
|
errors: ["invalid_input", "unauthorized", "forbidden", "not_found", "rate_limited", "service_unavailable", "transport_failure", "remote_failure", "wait_timeout", "interrupted"],
|
|
368
365
|
examples: [
|
|
@@ -430,6 +427,7 @@ function registerRequestsWait(group, environment = {}) {
|
|
|
430
427
|
const resolved = {
|
|
431
428
|
...context,
|
|
432
429
|
ids: idsOf2(result),
|
|
430
|
+
limitations: result.thread && client.grantAuthenticated ? requestGrantLimitations(result.thread) : [],
|
|
433
431
|
recovery: recoveryFor3(result, job, target.site_id)
|
|
434
432
|
};
|
|
435
433
|
const code = requestWaitErrorCode(result.outcome);
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
AGENT_INSTRUCTIONS
|
|
3
|
+
} from "./chunk-HHRZ3Y55.js";
|
|
4
4
|
import {
|
|
5
5
|
loadDocsConfig
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-ZHYL7FYA.js";
|
|
7
|
+
import {
|
|
8
|
+
createResultWriter,
|
|
9
|
+
failureResult,
|
|
10
|
+
invalidInput2 as invalidInput,
|
|
11
|
+
resolveGlobalOptions,
|
|
12
|
+
successResult
|
|
13
|
+
} from "./chunk-EH6E45H4.js";
|
|
7
14
|
|
|
8
15
|
// src/commands/init.ts
|
|
9
16
|
import { existsSync } from "fs";
|
|
@@ -1382,7 +1389,7 @@ async function probeGoogleFonts(fetcher, family) {
|
|
|
1382
1389
|
);
|
|
1383
1390
|
return response.status === 200 ? "available" : "inconclusive";
|
|
1384
1391
|
} catch (error) {
|
|
1385
|
-
return /HTTP 400\b/.test(
|
|
1392
|
+
return /HTTP 400\b/.test(messageOf(error)) ? "unavailable" : "inconclusive";
|
|
1386
1393
|
}
|
|
1387
1394
|
}
|
|
1388
1395
|
function googleFontForSlot(signal, assumption) {
|
|
@@ -1396,7 +1403,7 @@ function googleFontForSlot(signal, assumption) {
|
|
|
1396
1403
|
function stripCssComments(css) {
|
|
1397
1404
|
return css.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
1398
1405
|
}
|
|
1399
|
-
function
|
|
1406
|
+
function messageOf(error) {
|
|
1400
1407
|
return error instanceof Error ? error.message : String(error);
|
|
1401
1408
|
}
|
|
1402
1409
|
var CONFIDENCE_FIELDS = [
|
|
@@ -1861,7 +1868,7 @@ async function extractBrandFromUrl(inputUrl, options = {}) {
|
|
|
1861
1868
|
maxBytes: DEFAULT_PAGE_MAX_BYTES
|
|
1862
1869
|
});
|
|
1863
1870
|
} catch (error) {
|
|
1864
|
-
warnings.push(`Could not fetch page ${sourceUrl}: ${
|
|
1871
|
+
warnings.push(`Could not fetch page ${sourceUrl}: ${messageOf2(error)}`);
|
|
1865
1872
|
warnings.push(
|
|
1866
1873
|
`No usable brand color found; using ${defaultPrimaryColor}.`
|
|
1867
1874
|
);
|
|
@@ -1923,7 +1930,7 @@ async function extractBrandFromUrl(inputUrl, options = {}) {
|
|
|
1923
1930
|
});
|
|
1924
1931
|
} catch (error) {
|
|
1925
1932
|
warnings.push(
|
|
1926
|
-
`Could not fetch stylesheet ${stylesheetUrl}: ${
|
|
1933
|
+
`Could not fetch stylesheet ${stylesheetUrl}: ${messageOf2(error)}`
|
|
1927
1934
|
);
|
|
1928
1935
|
}
|
|
1929
1936
|
}
|
|
@@ -1961,7 +1968,7 @@ async function extractBrandFromUrl(inputUrl, options = {}) {
|
|
|
1961
1968
|
});
|
|
1962
1969
|
}
|
|
1963
1970
|
} catch (error) {
|
|
1964
|
-
warnings.push(`Rendered brand fallback failed: ${
|
|
1971
|
+
warnings.push(`Rendered brand fallback failed: ${messageOf2(error)}`);
|
|
1965
1972
|
}
|
|
1966
1973
|
}
|
|
1967
1974
|
const text = extractBrandText(analyzedHtml, pageUrl);
|
|
@@ -2106,7 +2113,7 @@ async function fetchManifestThemeColor(fetcher, manifestUrl, warnings) {
|
|
|
2106
2113
|
const parsed = JSON.parse(manifest.text);
|
|
2107
2114
|
return typeof parsed.theme_color === "string" ? parsed.theme_color : void 0;
|
|
2108
2115
|
} catch (error) {
|
|
2109
|
-
warnings.push(`Could not fetch manifest ${manifestUrl}: ${
|
|
2116
|
+
warnings.push(`Could not fetch manifest ${manifestUrl}: ${messageOf2(error)}`);
|
|
2110
2117
|
return void 0;
|
|
2111
2118
|
}
|
|
2112
2119
|
}
|
|
@@ -2116,7 +2123,7 @@ async function maybeFetchAsset(fetcher, candidate, kind, warnings) {
|
|
|
2116
2123
|
return { ...downloaded, source: candidate.source };
|
|
2117
2124
|
} catch (error) {
|
|
2118
2125
|
warnings.push(
|
|
2119
|
-
`Could not download ${kind} ${candidate.url}: ${
|
|
2126
|
+
`Could not download ${kind} ${candidate.url}: ${messageOf2(error)}`
|
|
2120
2127
|
);
|
|
2121
2128
|
return void 0;
|
|
2122
2129
|
}
|
|
@@ -2128,7 +2135,7 @@ function cleanOption(value) {
|
|
|
2128
2135
|
const cleaned = value?.trim();
|
|
2129
2136
|
return cleaned && cleaned.length > 0 ? cleaned : void 0;
|
|
2130
2137
|
}
|
|
2131
|
-
function
|
|
2138
|
+
function messageOf2(error) {
|
|
2132
2139
|
return error instanceof Error ? error.message : String(error);
|
|
2133
2140
|
}
|
|
2134
2141
|
function starterFonts() {
|
|
@@ -2155,8 +2162,8 @@ description: ${yamlString(description)}
|
|
|
2155
2162
|
<Card title="Write pages" icon="file-text">
|
|
2156
2163
|
Add MDX files under \`pages/\`, then list them in \`docs.json\`.
|
|
2157
2164
|
</Card>
|
|
2158
|
-
<Card title="
|
|
2159
|
-
Run \`saturndocs
|
|
2165
|
+
<Card title="Check your changes" icon="circle-check">
|
|
2166
|
+
Run \`saturndocs validate\` and \`saturndocs lint\` before you push.
|
|
2160
2167
|
</Card>
|
|
2161
2168
|
</Columns>
|
|
2162
2169
|
`;
|
|
@@ -2167,10 +2174,13 @@ title: Quickstart
|
|
|
2167
2174
|
description: ${yamlString(`Start editing ${name}.`)}
|
|
2168
2175
|
---
|
|
2169
2176
|
|
|
2170
|
-
##
|
|
2177
|
+
## Check the site
|
|
2178
|
+
|
|
2179
|
+
Run both checks from the docs folder before you push.
|
|
2171
2180
|
|
|
2172
2181
|
\`\`\`sh
|
|
2173
|
-
saturndocs
|
|
2182
|
+
saturndocs validate
|
|
2183
|
+
saturndocs lint
|
|
2174
2184
|
\`\`\`
|
|
2175
2185
|
|
|
2176
2186
|
## Edit content
|
|
@@ -2214,15 +2224,26 @@ function starterPages(name, description) {
|
|
|
2214
2224
|
|
|
2215
2225
|
// src/commands/init.ts
|
|
2216
2226
|
import pc from "picocolors";
|
|
2227
|
+
var DocsJsonExistsError = class extends Error {
|
|
2228
|
+
};
|
|
2217
2229
|
function registerInit(program) {
|
|
2218
|
-
program.command("init").description("Scaffold a new SaturnDocs docs project").argument("[dir]", "directory to scaffold", ".").option("--name <name>", "site name").option("--primary <css-color>", "primary brand color").option("--from-url <url>", "extract brand details from a website").option("--yes", "accepted for future interactive prompts").action(async (dir, options) => {
|
|
2230
|
+
program.command("init").description("Scaffold a new SaturnDocs docs project").argument("[dir]", "directory to scaffold", ".").option("--name <name>", "site name").option("--primary <css-color>", "primary brand color").option("--from-url <url>", "extract brand details from a website").option("--yes", "accepted for future interactive prompts").action(async (dir, options, self) => {
|
|
2231
|
+
const globals = resolveGlobalOptions(self);
|
|
2232
|
+
const writer = createResultWriter({ json: globals.json });
|
|
2233
|
+
const context = { command: "init", siteId: null };
|
|
2219
2234
|
try {
|
|
2220
|
-
const result = await scaffoldDocsProject(dir, options)
|
|
2221
|
-
|
|
2222
|
-
|
|
2235
|
+
const result = await scaffoldDocsProject(dir, options).catch((error) => {
|
|
2236
|
+
throw error instanceof DocsJsonExistsError ? invalidInput(error.message) : error;
|
|
2237
|
+
});
|
|
2238
|
+
const steps = nextSteps(result.docsDir);
|
|
2239
|
+
if (!globals.json) {
|
|
2240
|
+
if (result.extraction) printExtractionReport(result);
|
|
2241
|
+
printNextSteps(result.docsDir, steps);
|
|
2242
|
+
return;
|
|
2243
|
+
}
|
|
2244
|
+
process.exitCode = writer.write(successResult(context, initReport(result, steps)));
|
|
2223
2245
|
} catch (error) {
|
|
2224
|
-
|
|
2225
|
-
process.exit(1);
|
|
2246
|
+
process.exitCode = writer.write(failureResult(error, context));
|
|
2226
2247
|
}
|
|
2227
2248
|
});
|
|
2228
2249
|
}
|
|
@@ -2230,12 +2251,12 @@ async function scaffoldDocsProject(dir = ".", options = {}, dependencies = {}) {
|
|
|
2230
2251
|
const docsDir = resolve(dir);
|
|
2231
2252
|
const docsJsonPath = join(docsDir, "docs.json");
|
|
2232
2253
|
if (existsSync(docsJsonPath)) {
|
|
2233
|
-
throw new
|
|
2254
|
+
throw new DocsJsonExistsError(`docs.json already exists in ${docsDir}`);
|
|
2234
2255
|
}
|
|
2235
2256
|
await mkdir(docsDir, { recursive: true });
|
|
2236
2257
|
const extractBrand = dependencies.extractBrand ?? extractBrandFromUrl;
|
|
2237
2258
|
const extraction = options.fromUrl ? await extractBrand(options.fromUrl) : void 0;
|
|
2238
|
-
|
|
2259
|
+
const files = extraction ? await writeExtractedAssets(docsDir, extraction) : [];
|
|
2239
2260
|
const defaultName = basename(docsDir) || "docs";
|
|
2240
2261
|
const name = cleanOption2(options.name) ?? extraction?.name ?? defaultName;
|
|
2241
2262
|
const primary = cleanOption2(options.primary) ?? extraction?.primaryColor ?? DEFAULT_PRIMARY_COLOR;
|
|
@@ -2247,8 +2268,8 @@ async function scaffoldDocsProject(dir = ".", options = {}, dependencies = {}) {
|
|
|
2247
2268
|
}
|
|
2248
2269
|
);
|
|
2249
2270
|
config.fonts = extraction ? mergeExtractedFonts(extraction) : starterFonts();
|
|
2250
|
-
await writeScaffoldFiles(docsDir, config);
|
|
2251
|
-
return { docsDir, config: await loadDocsConfig(docsJsonPath), extraction };
|
|
2271
|
+
files.push(...await writeScaffoldFiles(docsDir, config));
|
|
2272
|
+
return { docsDir, config: await loadDocsConfig(docsJsonPath), extraction, files };
|
|
2252
2273
|
}
|
|
2253
2274
|
function buildDocsConfig(input) {
|
|
2254
2275
|
const config = deriveDocsJson(
|
|
@@ -2313,20 +2334,54 @@ async function writeScaffoldFiles(docsDir, config) {
|
|
|
2313
2334
|
`,
|
|
2314
2335
|
"utf8"
|
|
2315
2336
|
);
|
|
2337
|
+
const written = ["docs.json"];
|
|
2316
2338
|
for (const file of starterPages(config.name, config.description ?? "")) {
|
|
2317
2339
|
await writeFile(join(docsDir, file.path), file.content, "utf8");
|
|
2340
|
+
written.push(file.path);
|
|
2341
|
+
}
|
|
2342
|
+
try {
|
|
2343
|
+
await writeFile(join(docsDir, "AGENTS.md"), AGENT_INSTRUCTIONS, { encoding: "utf8", flag: "wx" });
|
|
2344
|
+
written.push("AGENTS.md");
|
|
2345
|
+
} catch (error) {
|
|
2346
|
+
if (error.code !== "EEXIST") throw error;
|
|
2318
2347
|
}
|
|
2348
|
+
return written;
|
|
2319
2349
|
}
|
|
2320
2350
|
async function writeExtractedAssets(docsDir, extraction) {
|
|
2321
2351
|
const assets = [extraction.logo, extraction.favicon].filter(
|
|
2322
2352
|
(asset) => asset !== void 0
|
|
2323
2353
|
);
|
|
2324
|
-
if (assets.length === 0) return;
|
|
2354
|
+
if (assets.length === 0) return [];
|
|
2325
2355
|
const publicDir = join(docsDir, "public");
|
|
2326
2356
|
await mkdir(publicDir, { recursive: true });
|
|
2357
|
+
const written = [];
|
|
2327
2358
|
for (const asset of assets) {
|
|
2328
2359
|
await writeFile(join(publicDir, asset.suggestedFilename), asset.bytes);
|
|
2360
|
+
written.push(`public/${asset.suggestedFilename}`);
|
|
2361
|
+
}
|
|
2362
|
+
return written;
|
|
2363
|
+
}
|
|
2364
|
+
function initReport(result, steps) {
|
|
2365
|
+
const extraction = result.extraction;
|
|
2366
|
+
const fonts = {};
|
|
2367
|
+
for (const slot of ["body", "heading", "mono"]) {
|
|
2368
|
+
const font = extraction?.fonts?.[slot];
|
|
2369
|
+
if (font) fonts[slot] = font.family;
|
|
2329
2370
|
}
|
|
2371
|
+
return {
|
|
2372
|
+
docs_dir: result.docsDir,
|
|
2373
|
+
files: result.files,
|
|
2374
|
+
name: result.config.name,
|
|
2375
|
+
primary: result.config.colors.primary,
|
|
2376
|
+
extraction: extraction ? {
|
|
2377
|
+
description: result.config.description ?? null,
|
|
2378
|
+
logo: result.config.logo ?? null,
|
|
2379
|
+
favicon: result.config.favicon ?? null,
|
|
2380
|
+
fonts,
|
|
2381
|
+
warnings: [...extraction.warnings]
|
|
2382
|
+
} : null,
|
|
2383
|
+
next_steps: steps
|
|
2384
|
+
};
|
|
2330
2385
|
}
|
|
2331
2386
|
function printExtractionReport(result) {
|
|
2332
2387
|
const extraction = result.extraction;
|
|
@@ -2399,18 +2454,31 @@ function printThemeReport(candidate, theme) {
|
|
|
2399
2454
|
console.log(` omitted (not high confidence): ${omitted.join(", ")}`);
|
|
2400
2455
|
}
|
|
2401
2456
|
}
|
|
2402
|
-
function
|
|
2457
|
+
function nextSteps(docsDir) {
|
|
2458
|
+
const rel = relative(process.cwd(), docsDir);
|
|
2459
|
+
const cdTarget = !rel || rel === "." ? "" : rel.startsWith("..") ? docsDir : rel;
|
|
2460
|
+
return [
|
|
2461
|
+
...cdTarget ? [`cd ${cdTarget}`] : [],
|
|
2462
|
+
"Edit pages/index.mdx and pages/quickstart.mdx to start writing.",
|
|
2463
|
+
"Edit docs.json to adjust navigation and site metadata.",
|
|
2464
|
+
"saturndocs validate",
|
|
2465
|
+
"saturndocs lint"
|
|
2466
|
+
];
|
|
2467
|
+
}
|
|
2468
|
+
var STEP_NOTES = {
|
|
2469
|
+
"saturndocs validate": "Check docs.json, pages, and links.",
|
|
2470
|
+
"saturndocs lint": "Check page content."
|
|
2471
|
+
};
|
|
2472
|
+
function printNextSteps(docsDir, steps) {
|
|
2403
2473
|
console.log(pc.green(`
|
|
2404
2474
|
Created SaturnDocs docs in ${docsDir}`));
|
|
2405
2475
|
console.log(pc.bold("Next steps"));
|
|
2406
|
-
const
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
console.log(` ${pc.cyan(
|
|
2476
|
+
for (const step of steps) {
|
|
2477
|
+
const note = STEP_NOTES[step];
|
|
2478
|
+
if (note !== void 0) console.log(` ${pc.cyan(step.padEnd(20))} ${note}`);
|
|
2479
|
+
else if (step.startsWith("cd ")) console.log(` ${pc.cyan(step)}`);
|
|
2480
|
+
else console.log(` ${step}`);
|
|
2410
2481
|
}
|
|
2411
|
-
console.log(` ${pc.cyan("saturndocs dev")}`);
|
|
2412
|
-
console.log(" Edit docs.json to adjust navigation and site metadata.");
|
|
2413
|
-
console.log(" Edit pages/index.mdx and pages/quickstart.mdx to start writing.");
|
|
2414
2482
|
}
|
|
2415
2483
|
function truncate(value, maxLength) {
|
|
2416
2484
|
if (value.length <= maxLength) return value;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
asCliError,
|
|
3
|
+
environmentToken,
|
|
4
|
+
loginEnvironment,
|
|
5
|
+
resolveSavedLogin
|
|
6
|
+
} from "./chunk-4B6PUKF5.js";
|
|
1
7
|
import {
|
|
2
8
|
applyCommandHelp
|
|
3
9
|
} from "./chunk-M2BZEDAS.js";
|
|
@@ -7,18 +13,28 @@ import {
|
|
|
7
13
|
createClient,
|
|
8
14
|
createResultWriter,
|
|
9
15
|
failureResult,
|
|
10
|
-
invalidInput,
|
|
16
|
+
invalidInput2 as invalidInput,
|
|
11
17
|
isManagementError,
|
|
18
|
+
parseOrigin,
|
|
12
19
|
requireCommitSha,
|
|
20
|
+
requiresManagementReceipt,
|
|
13
21
|
resolveGlobalOptions,
|
|
14
22
|
resolveTarget,
|
|
15
23
|
successResult
|
|
16
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-EH6E45H4.js";
|
|
17
25
|
|
|
18
26
|
// src/commands/manage.ts
|
|
19
27
|
import { readFile } from "fs/promises";
|
|
20
28
|
var METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
21
29
|
var PUBLIC_READS = /* @__PURE__ */ new Set(["", "openapi.json"]);
|
|
30
|
+
function isPublicRead(method, path, site) {
|
|
31
|
+
if (method.toUpperCase() !== "GET" || site !== void 0) return false;
|
|
32
|
+
try {
|
|
33
|
+
return PUBLIC_READS.has(routeOf(path));
|
|
34
|
+
} catch {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
22
38
|
var SITELESS_READS = /* @__PURE__ */ new Set(["", "openapi.json", "sites"]);
|
|
23
39
|
var SIDE_EFFECTING_GETS = [
|
|
24
40
|
/^suggestions\/[^/]+\/session\/ws$/u,
|
|
@@ -144,9 +160,10 @@ async function buildBody(current, options) {
|
|
|
144
160
|
if (data === null) return {};
|
|
145
161
|
return { body: data.value };
|
|
146
162
|
}
|
|
147
|
-
function requireJsonMedia(headers) {
|
|
163
|
+
function requireJsonMedia(headers, mutation) {
|
|
148
164
|
const media = (headers.get("content-type") ?? "").split(";")[0]?.trim().toLowerCase() ?? "";
|
|
149
165
|
if (media === "" || media === "application/json" || media.endsWith("+json")) return;
|
|
166
|
+
if (mutation) throw new CliError("unknown_outcome", `The write was accepted but its receipt uses unsupported media ${media}. Read the site state before writing again.`);
|
|
150
167
|
throw new CliError("transport_failure", `The management API answered ${media}, which this command does not read. Only JSON operations are supported here.`);
|
|
151
168
|
}
|
|
152
169
|
function classify(error) {
|
|
@@ -178,7 +195,11 @@ async function callManagement(method, path, options, token, fetchImpl = fetch) {
|
|
|
178
195
|
mutation: current.mutation,
|
|
179
196
|
anonymous: current.anonymous
|
|
180
197
|
});
|
|
181
|
-
|
|
198
|
+
if (response.emptyBody && current.mutation && requiresManagementReceipt(current.verb, current.route)) {
|
|
199
|
+
const read = current.route === "requests" ? "saturndocs requests list --site " + options.site : "the site's " + current.route.split("/")[0] + " state";
|
|
200
|
+
throw new CliError("unknown_outcome", `The service accepted the write and returned an empty receipt. Read ${read} before writing again.`);
|
|
201
|
+
}
|
|
202
|
+
requireJsonMedia(response.headers, current.mutation);
|
|
182
203
|
return response.data;
|
|
183
204
|
} catch (error) {
|
|
184
205
|
throw classify(error);
|
|
@@ -197,7 +218,7 @@ var MANAGE_METADATA = Object.freeze([
|
|
|
197
218
|
idempotency: "expected_review",
|
|
198
219
|
text_sources: ["--data"],
|
|
199
220
|
output: { fields: [], ids: [], limitations: [] },
|
|
200
|
-
errors: ["invalid_input", "unauthorized", "forbidden", "not_found", "stale_review", "conflict", "rate_limited", "service_unavailable", "transport_failure", "interrupted"],
|
|
221
|
+
errors: ["invalid_input", "unauthorized", "forbidden", "not_found", "stale_review", "conflict", "rate_limited", "service_unavailable", "transport_failure", "unknown_outcome", "interrupted"],
|
|
201
222
|
examples: [
|
|
202
223
|
{ command: "saturndocs manage GET requests --site acme", description: "Read one site's requests through the raw operation." },
|
|
203
224
|
{ command: "saturndocs manage POST requests --site acme --data @request.json --json", description: "Send a body read from a file and take the shared result envelope." },
|
|
@@ -213,15 +234,18 @@ function registerManage(program) {
|
|
|
213
234
|
const site = globals.site ?? options.site;
|
|
214
235
|
const context = { command: "manage", siteId: site ?? null };
|
|
215
236
|
try {
|
|
237
|
+
const api = globals.api ?? options.api;
|
|
238
|
+
const login = loginEnvironment();
|
|
239
|
+
const token = environmentToken(login.env) ?? (isPublicRead(method, path ?? "", site) ? void 0 : (await resolveSavedLogin(parseOrigin(api), site ?? null, login))?.token);
|
|
216
240
|
const data = await callManagement(method, path ?? "", {
|
|
217
241
|
...options,
|
|
218
242
|
site,
|
|
219
|
-
|
|
243
|
+
api,
|
|
220
244
|
...globals.timeout === null ? {} : { timeout: globals.timeout }
|
|
221
|
-
},
|
|
245
|
+
}, token);
|
|
222
246
|
process.exitCode = writer.write(successResult(context, data), { text: JSON.stringify(data, null, 2) });
|
|
223
247
|
} catch (error) {
|
|
224
|
-
process.exitCode = writer.write(failureResult(error, context));
|
|
248
|
+
process.exitCode = writer.write(failureResult(asCliError(error), context));
|
|
225
249
|
}
|
|
226
250
|
});
|
|
227
251
|
applyCommandHelp(command, metadata);
|
|
@@ -233,13 +257,14 @@ function registerManage(program) {
|
|
|
233
257
|
" Every non-GET, and GET on credentials, github/install, slack/install, or a suggestion session stream, needs --site.",
|
|
234
258
|
" A raw approve or dismiss needs --base and --head, or expected_base_sha and expected_head_sha in --data.",
|
|
235
259
|
" Without --site only GET, GET openapi.json, and GET sites answer; the first two need no credential.",
|
|
236
|
-
" Authentication: SATURNDOCS_MANAGEMENT_TOKEN. Provider installation returns an authorization URL.",
|
|
260
|
+
" Authentication: SATURNDOCS_MANAGEMENT_TOKEN, or the saved login from saturndocs login. Provider installation returns an authorization URL.",
|
|
237
261
|
""
|
|
238
262
|
].join("\n")
|
|
239
263
|
);
|
|
240
264
|
}
|
|
241
265
|
|
|
242
266
|
export {
|
|
267
|
+
isPublicRead,
|
|
243
268
|
callManagement,
|
|
244
269
|
MANAGE_METADATA,
|
|
245
270
|
registerManage
|