saturndocs 0.2.0 → 0.3.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-OIEL34E4.js +16 -0
- package/dist/{chunk-GGGL4O7Z.js → chunk-32ATWMIS.js} +3 -3
- package/dist/{chunk-QF2ADHQZ.js → chunk-3EW6ZPL6.js} +5 -5
- package/dist/{chunk-ADZOBRZE.js → chunk-3KCCCMQY.js} +325 -35
- package/dist/{chunk-2RZEC3VH.js → chunk-3X2NBWZN.js} +123 -35
- package/dist/{chunk-EB7RWFQA.js → chunk-5ZYUBLEH.js} +1463 -130
- package/dist/{chunk-WBI4EI3D.js → chunk-6EKGBIUR.js} +2 -2
- package/dist/{chunk-W3GKH5DY.js → chunk-BOWRQKXR.js} +12 -6
- package/dist/{chunk-FGKHDJOC.js → chunk-E3G56DR2.js} +287 -35
- package/dist/chunk-FUZE54DG.js +905 -0
- package/dist/chunk-HBSJ4Z4S.js +53 -0
- package/dist/{chunk-DBMFJXKP.js → chunk-IJOYWJVM.js} +5 -5
- package/dist/chunk-IWIVHHZI.js +426 -0
- package/dist/{chunk-Z5CBPJ2L.js → chunk-PU37LVIF.js} +3 -3
- package/dist/{chunk-4ORVQCHY.js → chunk-RKM7YWPD.js} +25 -6
- package/dist/{chunk-2YTD2XNI.js → chunk-T3MCJYSF.js} +1 -1
- package/dist/{chunk-YSFP37B7.js → chunk-TEYHAN2L.js} +20 -6
- package/dist/{chunk-WUPP3THV.js → chunk-VDGVERLX.js} +5 -5
- package/dist/{chunk-SVDVBZPA.js → chunk-W3FZTCKV.js} +6 -4
- package/dist/chunk-WMS6FUKK.js +414 -0
- package/dist/chunk-WXLJZ7RD.js +115 -0
- package/dist/{chunk-56U46JVN.js → chunk-YGVC4N4V.js} +2 -1
- package/dist/{chunk-6JGAA5TF.js → chunk-YPWPLIEZ.js} +4 -4
- package/dist/cli.js +6 -6
- package/dist/{coverage-EBWULNQQ.js → coverage-SRIA65FT.js} +5 -5
- package/dist/{dist-XISZDQTR.js → dist-LJSALT4X.js} +33 -3
- package/dist/index.d.ts +69 -37
- package/dist/index.js +112 -47
- package/dist/{init-PI4VTG7V.js → init-Y3GDNDWW.js} +5 -3
- package/dist/{lint-SXBP37G3.js → lint-XM26WIGE.js} +3 -3
- package/dist/login-HIXLPRUI.js +22 -0
- package/dist/{manage-OB6DQK3Q.js → manage-3HEBB3EQ.js} +6 -2
- package/dist/{nav-R4OORY2G.js → nav-K43WZJ4J.js} +4 -4
- package/dist/openapiCheck-CL2AH3YC.js +105 -0
- package/dist/pages-4VWB7Z4S.js +16 -0
- package/dist/{read-VECMKHBW.js → read-DYGYUOFK.js} +5 -4
- package/dist/{read-WWOMA67R.js → read-RKT6HUZ7.js} +41 -7
- package/dist/requests-CZYE6GI3.js +13 -0
- package/dist/{schema-NKOXZHQH.js → schema-QMJMGD5P.js} +3 -3
- package/dist/{sites-XMMGWPY2.js → sites-JKS25SEM.js} +5 -4
- package/dist/{status-SYIUUSSU.js → status-FM2ALQUJ.js} +4 -4
- package/dist/{suggestions-GX5CQK26.js → suggestions-Z6XIHMFN.js} +13 -7
- package/dist/unavailable-DVPNUO3J.js +40 -0
- package/dist/validate-X42T4TJ6.js +12 -0
- package/package.json +15 -9
- 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-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-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
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
messageOf
|
|
3
|
-
} from "./chunk-VNYDYHXM.js";
|
|
4
1
|
import {
|
|
5
2
|
loadDocsConfig
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-E3G56DR2.js";
|
|
4
|
+
import {
|
|
5
|
+
createResultWriter,
|
|
6
|
+
failureResult,
|
|
7
|
+
invalidInput2 as invalidInput,
|
|
8
|
+
resolveGlobalOptions,
|
|
9
|
+
successResult
|
|
10
|
+
} from "./chunk-3KCCCMQY.js";
|
|
7
11
|
|
|
8
12
|
// src/commands/init.ts
|
|
9
13
|
import { existsSync } from "fs";
|
|
@@ -1382,7 +1386,7 @@ async function probeGoogleFonts(fetcher, family) {
|
|
|
1382
1386
|
);
|
|
1383
1387
|
return response.status === 200 ? "available" : "inconclusive";
|
|
1384
1388
|
} catch (error) {
|
|
1385
|
-
return /HTTP 400\b/.test(
|
|
1389
|
+
return /HTTP 400\b/.test(messageOf(error)) ? "unavailable" : "inconclusive";
|
|
1386
1390
|
}
|
|
1387
1391
|
}
|
|
1388
1392
|
function googleFontForSlot(signal, assumption) {
|
|
@@ -1396,7 +1400,7 @@ function googleFontForSlot(signal, assumption) {
|
|
|
1396
1400
|
function stripCssComments(css) {
|
|
1397
1401
|
return css.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
1398
1402
|
}
|
|
1399
|
-
function
|
|
1403
|
+
function messageOf(error) {
|
|
1400
1404
|
return error instanceof Error ? error.message : String(error);
|
|
1401
1405
|
}
|
|
1402
1406
|
var CONFIDENCE_FIELDS = [
|
|
@@ -1861,7 +1865,7 @@ async function extractBrandFromUrl(inputUrl, options = {}) {
|
|
|
1861
1865
|
maxBytes: DEFAULT_PAGE_MAX_BYTES
|
|
1862
1866
|
});
|
|
1863
1867
|
} catch (error) {
|
|
1864
|
-
warnings.push(`Could not fetch page ${sourceUrl}: ${
|
|
1868
|
+
warnings.push(`Could not fetch page ${sourceUrl}: ${messageOf2(error)}`);
|
|
1865
1869
|
warnings.push(
|
|
1866
1870
|
`No usable brand color found; using ${defaultPrimaryColor}.`
|
|
1867
1871
|
);
|
|
@@ -1923,7 +1927,7 @@ async function extractBrandFromUrl(inputUrl, options = {}) {
|
|
|
1923
1927
|
});
|
|
1924
1928
|
} catch (error) {
|
|
1925
1929
|
warnings.push(
|
|
1926
|
-
`Could not fetch stylesheet ${stylesheetUrl}: ${
|
|
1930
|
+
`Could not fetch stylesheet ${stylesheetUrl}: ${messageOf2(error)}`
|
|
1927
1931
|
);
|
|
1928
1932
|
}
|
|
1929
1933
|
}
|
|
@@ -1961,7 +1965,7 @@ async function extractBrandFromUrl(inputUrl, options = {}) {
|
|
|
1961
1965
|
});
|
|
1962
1966
|
}
|
|
1963
1967
|
} catch (error) {
|
|
1964
|
-
warnings.push(`Rendered brand fallback failed: ${
|
|
1968
|
+
warnings.push(`Rendered brand fallback failed: ${messageOf2(error)}`);
|
|
1965
1969
|
}
|
|
1966
1970
|
}
|
|
1967
1971
|
const text = extractBrandText(analyzedHtml, pageUrl);
|
|
@@ -2106,7 +2110,7 @@ async function fetchManifestThemeColor(fetcher, manifestUrl, warnings) {
|
|
|
2106
2110
|
const parsed = JSON.parse(manifest.text);
|
|
2107
2111
|
return typeof parsed.theme_color === "string" ? parsed.theme_color : void 0;
|
|
2108
2112
|
} catch (error) {
|
|
2109
|
-
warnings.push(`Could not fetch manifest ${manifestUrl}: ${
|
|
2113
|
+
warnings.push(`Could not fetch manifest ${manifestUrl}: ${messageOf2(error)}`);
|
|
2110
2114
|
return void 0;
|
|
2111
2115
|
}
|
|
2112
2116
|
}
|
|
@@ -2116,7 +2120,7 @@ async function maybeFetchAsset(fetcher, candidate, kind, warnings) {
|
|
|
2116
2120
|
return { ...downloaded, source: candidate.source };
|
|
2117
2121
|
} catch (error) {
|
|
2118
2122
|
warnings.push(
|
|
2119
|
-
`Could not download ${kind} ${candidate.url}: ${
|
|
2123
|
+
`Could not download ${kind} ${candidate.url}: ${messageOf2(error)}`
|
|
2120
2124
|
);
|
|
2121
2125
|
return void 0;
|
|
2122
2126
|
}
|
|
@@ -2128,7 +2132,7 @@ function cleanOption(value) {
|
|
|
2128
2132
|
const cleaned = value?.trim();
|
|
2129
2133
|
return cleaned && cleaned.length > 0 ? cleaned : void 0;
|
|
2130
2134
|
}
|
|
2131
|
-
function
|
|
2135
|
+
function messageOf2(error) {
|
|
2132
2136
|
return error instanceof Error ? error.message : String(error);
|
|
2133
2137
|
}
|
|
2134
2138
|
function starterFonts() {
|
|
@@ -2155,8 +2159,8 @@ description: ${yamlString(description)}
|
|
|
2155
2159
|
<Card title="Write pages" icon="file-text">
|
|
2156
2160
|
Add MDX files under \`pages/\`, then list them in \`docs.json\`.
|
|
2157
2161
|
</Card>
|
|
2158
|
-
<Card title="
|
|
2159
|
-
Run \`saturndocs
|
|
2162
|
+
<Card title="Check your changes" icon="circle-check">
|
|
2163
|
+
Run \`saturndocs validate\` and \`saturndocs lint\` before you push.
|
|
2160
2164
|
</Card>
|
|
2161
2165
|
</Columns>
|
|
2162
2166
|
`;
|
|
@@ -2167,10 +2171,13 @@ title: Quickstart
|
|
|
2167
2171
|
description: ${yamlString(`Start editing ${name}.`)}
|
|
2168
2172
|
---
|
|
2169
2173
|
|
|
2170
|
-
##
|
|
2174
|
+
## Check the site
|
|
2175
|
+
|
|
2176
|
+
Run both checks from the docs folder before you push.
|
|
2171
2177
|
|
|
2172
2178
|
\`\`\`sh
|
|
2173
|
-
saturndocs
|
|
2179
|
+
saturndocs validate
|
|
2180
|
+
saturndocs lint
|
|
2174
2181
|
\`\`\`
|
|
2175
2182
|
|
|
2176
2183
|
## Edit content
|
|
@@ -2214,15 +2221,26 @@ function starterPages(name, description) {
|
|
|
2214
2221
|
|
|
2215
2222
|
// src/commands/init.ts
|
|
2216
2223
|
import pc from "picocolors";
|
|
2224
|
+
var DocsJsonExistsError = class extends Error {
|
|
2225
|
+
};
|
|
2217
2226
|
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) => {
|
|
2227
|
+
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) => {
|
|
2228
|
+
const globals = resolveGlobalOptions(self);
|
|
2229
|
+
const writer = createResultWriter({ json: globals.json });
|
|
2230
|
+
const context = { command: "init", siteId: null };
|
|
2219
2231
|
try {
|
|
2220
|
-
const result = await scaffoldDocsProject(dir, options)
|
|
2221
|
-
|
|
2222
|
-
|
|
2232
|
+
const result = await scaffoldDocsProject(dir, options).catch((error) => {
|
|
2233
|
+
throw error instanceof DocsJsonExistsError ? invalidInput(error.message) : error;
|
|
2234
|
+
});
|
|
2235
|
+
const steps = nextSteps(result.docsDir);
|
|
2236
|
+
if (!globals.json) {
|
|
2237
|
+
if (result.extraction) printExtractionReport(result);
|
|
2238
|
+
printNextSteps(result.docsDir, steps);
|
|
2239
|
+
return;
|
|
2240
|
+
}
|
|
2241
|
+
process.exitCode = writer.write(successResult(context, initReport(result, steps)));
|
|
2223
2242
|
} catch (error) {
|
|
2224
|
-
|
|
2225
|
-
process.exit(1);
|
|
2243
|
+
process.exitCode = writer.write(failureResult(error, context));
|
|
2226
2244
|
}
|
|
2227
2245
|
});
|
|
2228
2246
|
}
|
|
@@ -2230,12 +2248,12 @@ async function scaffoldDocsProject(dir = ".", options = {}, dependencies = {}) {
|
|
|
2230
2248
|
const docsDir = resolve(dir);
|
|
2231
2249
|
const docsJsonPath = join(docsDir, "docs.json");
|
|
2232
2250
|
if (existsSync(docsJsonPath)) {
|
|
2233
|
-
throw new
|
|
2251
|
+
throw new DocsJsonExistsError(`docs.json already exists in ${docsDir}`);
|
|
2234
2252
|
}
|
|
2235
2253
|
await mkdir(docsDir, { recursive: true });
|
|
2236
2254
|
const extractBrand = dependencies.extractBrand ?? extractBrandFromUrl;
|
|
2237
2255
|
const extraction = options.fromUrl ? await extractBrand(options.fromUrl) : void 0;
|
|
2238
|
-
|
|
2256
|
+
const files = extraction ? await writeExtractedAssets(docsDir, extraction) : [];
|
|
2239
2257
|
const defaultName = basename(docsDir) || "docs";
|
|
2240
2258
|
const name = cleanOption2(options.name) ?? extraction?.name ?? defaultName;
|
|
2241
2259
|
const primary = cleanOption2(options.primary) ?? extraction?.primaryColor ?? DEFAULT_PRIMARY_COLOR;
|
|
@@ -2247,8 +2265,8 @@ async function scaffoldDocsProject(dir = ".", options = {}, dependencies = {}) {
|
|
|
2247
2265
|
}
|
|
2248
2266
|
);
|
|
2249
2267
|
config.fonts = extraction ? mergeExtractedFonts(extraction) : starterFonts();
|
|
2250
|
-
await writeScaffoldFiles(docsDir, config);
|
|
2251
|
-
return { docsDir, config: await loadDocsConfig(docsJsonPath), extraction };
|
|
2268
|
+
files.push(...await writeScaffoldFiles(docsDir, config));
|
|
2269
|
+
return { docsDir, config: await loadDocsConfig(docsJsonPath), extraction, files };
|
|
2252
2270
|
}
|
|
2253
2271
|
function buildDocsConfig(input) {
|
|
2254
2272
|
const config = deriveDocsJson(
|
|
@@ -2313,20 +2331,76 @@ async function writeScaffoldFiles(docsDir, config) {
|
|
|
2313
2331
|
`,
|
|
2314
2332
|
"utf8"
|
|
2315
2333
|
);
|
|
2334
|
+
const written = ["docs.json"];
|
|
2316
2335
|
for (const file of starterPages(config.name, config.description ?? "")) {
|
|
2317
2336
|
await writeFile(join(docsDir, file.path), file.content, "utf8");
|
|
2337
|
+
written.push(file.path);
|
|
2318
2338
|
}
|
|
2339
|
+
try {
|
|
2340
|
+
await writeFile(join(docsDir, "AGENTS.md"), AGENT_INSTRUCTIONS, { encoding: "utf8", flag: "wx" });
|
|
2341
|
+
written.push("AGENTS.md");
|
|
2342
|
+
} catch (error) {
|
|
2343
|
+
if (error.code !== "EEXIST") throw error;
|
|
2344
|
+
}
|
|
2345
|
+
return written;
|
|
2319
2346
|
}
|
|
2347
|
+
var AGENT_INSTRUCTIONS = `# Instructions for coding agents
|
|
2348
|
+
|
|
2349
|
+
This directory is the source of a SaturnDocs site. SaturnDocs builds and publishes the site from Git: a push to the connected repository starts a build.
|
|
2350
|
+
|
|
2351
|
+
## Layout
|
|
2352
|
+
|
|
2353
|
+
- \`docs.json\`: site settings and navigation.
|
|
2354
|
+
- \`pages/\`: one \`.md\` or \`.mdx\` file per page. Each page needs a \`title\` in its frontmatter.
|
|
2355
|
+
- \`public/\`: images and other files, served from the site root.
|
|
2356
|
+
- \`openapi/\`: OpenAPI specifications.
|
|
2357
|
+
|
|
2358
|
+
Any other file in this directory stops the publish. This file and \`CLAUDE.md\` are the exceptions: SaturnDocs accepts them and never publishes them.
|
|
2359
|
+
|
|
2360
|
+
## Before every commit
|
|
2361
|
+
|
|
2362
|
+
Run both checks from this directory and fix every error they report. Each error names a file, a line, a rule, and a fix.
|
|
2363
|
+
|
|
2364
|
+
\`\`\`sh
|
|
2365
|
+
npx saturndocs validate . --json
|
|
2366
|
+
npx saturndocs lint . --json
|
|
2367
|
+
\`\`\`
|
|
2368
|
+
`;
|
|
2320
2369
|
async function writeExtractedAssets(docsDir, extraction) {
|
|
2321
2370
|
const assets = [extraction.logo, extraction.favicon].filter(
|
|
2322
2371
|
(asset) => asset !== void 0
|
|
2323
2372
|
);
|
|
2324
|
-
if (assets.length === 0) return;
|
|
2373
|
+
if (assets.length === 0) return [];
|
|
2325
2374
|
const publicDir = join(docsDir, "public");
|
|
2326
2375
|
await mkdir(publicDir, { recursive: true });
|
|
2376
|
+
const written = [];
|
|
2327
2377
|
for (const asset of assets) {
|
|
2328
2378
|
await writeFile(join(publicDir, asset.suggestedFilename), asset.bytes);
|
|
2379
|
+
written.push(`public/${asset.suggestedFilename}`);
|
|
2329
2380
|
}
|
|
2381
|
+
return written;
|
|
2382
|
+
}
|
|
2383
|
+
function initReport(result, steps) {
|
|
2384
|
+
const extraction = result.extraction;
|
|
2385
|
+
const fonts = {};
|
|
2386
|
+
for (const slot of ["body", "heading", "mono"]) {
|
|
2387
|
+
const font = extraction?.fonts?.[slot];
|
|
2388
|
+
if (font) fonts[slot] = font.family;
|
|
2389
|
+
}
|
|
2390
|
+
return {
|
|
2391
|
+
docs_dir: result.docsDir,
|
|
2392
|
+
files: result.files,
|
|
2393
|
+
name: result.config.name,
|
|
2394
|
+
primary: result.config.colors.primary,
|
|
2395
|
+
extraction: extraction ? {
|
|
2396
|
+
description: result.config.description ?? null,
|
|
2397
|
+
logo: result.config.logo ?? null,
|
|
2398
|
+
favicon: result.config.favicon ?? null,
|
|
2399
|
+
fonts,
|
|
2400
|
+
warnings: [...extraction.warnings]
|
|
2401
|
+
} : null,
|
|
2402
|
+
next_steps: steps
|
|
2403
|
+
};
|
|
2330
2404
|
}
|
|
2331
2405
|
function printExtractionReport(result) {
|
|
2332
2406
|
const extraction = result.extraction;
|
|
@@ -2399,18 +2473,31 @@ function printThemeReport(candidate, theme) {
|
|
|
2399
2473
|
console.log(` omitted (not high confidence): ${omitted.join(", ")}`);
|
|
2400
2474
|
}
|
|
2401
2475
|
}
|
|
2402
|
-
function
|
|
2476
|
+
function nextSteps(docsDir) {
|
|
2477
|
+
const rel = relative(process.cwd(), docsDir);
|
|
2478
|
+
const cdTarget = !rel || rel === "." ? "" : rel.startsWith("..") ? docsDir : rel;
|
|
2479
|
+
return [
|
|
2480
|
+
...cdTarget ? [`cd ${cdTarget}`] : [],
|
|
2481
|
+
"Edit pages/index.mdx and pages/quickstart.mdx to start writing.",
|
|
2482
|
+
"Edit docs.json to adjust navigation and site metadata.",
|
|
2483
|
+
"saturndocs validate",
|
|
2484
|
+
"saturndocs lint"
|
|
2485
|
+
];
|
|
2486
|
+
}
|
|
2487
|
+
var STEP_NOTES = {
|
|
2488
|
+
"saturndocs validate": "Check docs.json, pages, and links.",
|
|
2489
|
+
"saturndocs lint": "Check page content."
|
|
2490
|
+
};
|
|
2491
|
+
function printNextSteps(docsDir, steps) {
|
|
2403
2492
|
console.log(pc.green(`
|
|
2404
2493
|
Created SaturnDocs docs in ${docsDir}`));
|
|
2405
2494
|
console.log(pc.bold("Next steps"));
|
|
2406
|
-
const
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
console.log(` ${pc.cyan(
|
|
2495
|
+
for (const step of steps) {
|
|
2496
|
+
const note = STEP_NOTES[step];
|
|
2497
|
+
if (note !== void 0) console.log(` ${pc.cyan(step.padEnd(20))} ${note}`);
|
|
2498
|
+
else if (step.startsWith("cd ")) console.log(` ${pc.cyan(step)}`);
|
|
2499
|
+
else console.log(` ${step}`);
|
|
2410
2500
|
}
|
|
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
2501
|
}
|
|
2415
2502
|
function truncate(value, maxLength) {
|
|
2416
2503
|
if (value.length <= maxLength) return value;
|
|
@@ -2444,5 +2531,6 @@ export {
|
|
|
2444
2531
|
registerInit,
|
|
2445
2532
|
scaffoldDocsProject,
|
|
2446
2533
|
buildDocsConfig,
|
|
2534
|
+
AGENT_INSTRUCTIONS,
|
|
2447
2535
|
printExtractionReport
|
|
2448
2536
|
};
|