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,53 @@
|
|
|
1
|
+
// src/adapter/registry.ts
|
|
2
|
+
var UNAVAILABLE_SUMMARY = "Not available in this release. Use validate and lint to check pages.";
|
|
3
|
+
var COMMAND_GROUPS = Object.freeze([
|
|
4
|
+
{ name: "manage", summary: "Call one management operation through the dashboard API", renderer: false, load: () => import("./manage-2AOOCZE2.js").then((m) => m.registerManage), metadata: () => import("./manage-2AOOCZE2.js").then((m) => m.MANAGE_METADATA) },
|
|
5
|
+
{ name: "requests", summary: "Documentation requests and the conversations behind them", renderer: false, load: () => import("./requests-OLCBRUAW.js").then((m) => m.registerRequests), metadata: () => import("./requests-OLCBRUAW.js").then((m) => m.REQUESTS_METADATA) },
|
|
6
|
+
{ name: "suggestions", summary: "Read a site's suggestions and diff the content they carry", renderer: false, load: () => import("./suggestions-JSTWOWRY.js").then((m) => m.registerSuggestions), metadata: () => import("./suggestions-JSTWOWRY.js").then((m) => m.SUGGESTIONS_METADATA) },
|
|
7
|
+
{ name: "schema", summary: "Print this CLI's own command metadata, locally", renderer: false, load: () => import("./schema-3I6XJSCY.js").then((m) => m.registerSchema), metadata: () => import("./schema-3I6XJSCY.js").then((m) => m.SCHEMA_METADATA) },
|
|
8
|
+
{ name: "login", summary: "Ask a person to approve this agent for one site, then save the login", renderer: false, load: () => import("./login-34OM3PJ2.js").then((m) => m.registerLogin), metadata: () => import("./login-34OM3PJ2.js").then((m) => m.LOGIN_METADATA) },
|
|
9
|
+
{ name: "logout", summary: "Revoke a saved login and delete it from this computer", renderer: false, load: () => import("./login-34OM3PJ2.js").then((m) => m.registerLogout), metadata: () => import("./login-34OM3PJ2.js").then((m) => m.LOGOUT_METADATA) },
|
|
10
|
+
{ name: "auth", summary: "Check the credential this CLI will use", renderer: false, load: () => import("./auth-NKYU6ZSC.js").then((m) => m.registerAuth), metadata: () => import("./auth-NKYU6ZSC.js").then((m) => m.AUTH_METADATA) },
|
|
11
|
+
{ name: "sites", summary: "Create a site, or discover and inspect the sites this credential reaches", renderer: false, load: () => import("./sites-6HKU6JP7.js").then((m) => m.registerSites), metadata: () => import("./sites-6HKU6JP7.js").then((m) => m.SITES_METADATA) },
|
|
12
|
+
{ name: "pages", summary: "Read the published pages of the release readers are seeing", renderer: false, load: () => import("./pages-E73CUM6I.js").then((m) => m.registerPages), metadata: () => import("./pages-E73CUM6I.js").then((m) => m.PAGES_METADATA) },
|
|
13
|
+
{ name: "releases", summary: "Read this site's release history and one release by id", renderer: false, load: () => import("./read-TQSSS7EJ.js").then((m) => m.registerReleases), metadata: () => import("./read-TQSSS7EJ.js").then((m) => m.RELEASES_METADATA) },
|
|
14
|
+
{ name: "status", summary: "One bounded briefing on a site, section by section", renderer: false, load: () => import("./status-DFAYOCC4.js").then((m) => m.registerStatus), metadata: () => import("./status-DFAYOCC4.js").then((m) => m.STATUS_METADATA) },
|
|
15
|
+
{ name: "activity", summary: "Read what the platform did, and one job by id", renderer: false, load: () => import("./read-UGXFNEGJ.js").then((m) => m.registerActivity), metadata: () => import("./read-UGXFNEGJ.js").then((m) => m.ACTIVITY_METADATA) },
|
|
16
|
+
{ name: "nav", summary: "Rewrite docs.json navigation from an approved outline", renderer: false, load: () => import("./nav-DKCGLENP.js").then((m) => m.registerNav), metadata: () => import("./nav-DKCGLENP.js").then((m) => m.NAV_METADATA) },
|
|
17
|
+
{ name: "lint", summary: "Content lint and the known-pitfalls catalog over every page; exits 2 when any finding is an error", renderer: false, load: () => import("./lint-N7ENEJVU.js").then((m) => m.registerLint), metadata: () => import("./lint-N7ENEJVU.js").then((m) => m.LINT_METADATA) },
|
|
18
|
+
{ name: "coverage", summary: "Check local pages against an approved outline", renderer: false, load: () => import("./coverage-IUQLC2H6.js").then((m) => m.registerCoverage), metadata: () => import("./coverage-IUQLC2H6.js").then((m) => m.COVERAGE_METADATA) },
|
|
19
|
+
{ name: "init", summary: "Scaffold a docs project", renderer: true, load: () => import("./init-EFZZRZZM.js").then((m) => m.registerInit) },
|
|
20
|
+
{ name: "validate", summary: "Validate docs.json, models.toml, page files, and OpenAPI specs", renderer: true, load: () => import("./validate-6RIKQWMI.js").then((m) => m.registerValidate) },
|
|
21
|
+
{ name: "dev", summary: UNAVAILABLE_SUMMARY, renderer: true, hidden: true, load: () => import("./unavailable-HVN65Q7D.js").then((m) => m.registerUnavailable("dev")) },
|
|
22
|
+
{ name: "build", summary: UNAVAILABLE_SUMMARY, renderer: true, hidden: true, load: () => import("./unavailable-HVN65Q7D.js").then((m) => m.registerUnavailable("build")) },
|
|
23
|
+
{ name: "broken-links", summary: UNAVAILABLE_SUMMARY, renderer: true, hidden: true, load: () => import("./unavailable-HVN65Q7D.js").then((m) => m.registerUnavailable("broken-links")) },
|
|
24
|
+
{ name: "openapi-check", summary: "Parse OpenAPI specs and print an operation table", renderer: true, load: () => import("./openapiCheck-KEHPUZOD.js").then((m) => m.registerOpenapiCheck) }
|
|
25
|
+
]);
|
|
26
|
+
var COMMAND_GROUP_NAMES = Object.freeze(COMMAND_GROUPS.map((group) => group.name));
|
|
27
|
+
var LISTED_COMMAND_GROUPS = Object.freeze(COMMAND_GROUPS.filter((group) => group.hidden !== true));
|
|
28
|
+
function findCommandGroup(name) {
|
|
29
|
+
return COMMAND_GROUPS.find((group) => group.name === name);
|
|
30
|
+
}
|
|
31
|
+
var VALUE_FLAGS = /* @__PURE__ */ new Set(["--site", "--api", "--timeout"]);
|
|
32
|
+
function selectCommandGroup(argv) {
|
|
33
|
+
for (let index = 2; index < argv.length; index += 1) {
|
|
34
|
+
const token = argv[index];
|
|
35
|
+
if (token === "--") break;
|
|
36
|
+
if (VALUE_FLAGS.has(token)) {
|
|
37
|
+
index += 1;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (token.startsWith("-")) continue;
|
|
41
|
+
const group = findCommandGroup(token);
|
|
42
|
+
if (group !== void 0) return group;
|
|
43
|
+
}
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
UNAVAILABLE_SUMMARY,
|
|
49
|
+
COMMAND_GROUPS,
|
|
50
|
+
COMMAND_GROUP_NAMES,
|
|
51
|
+
findCommandGroup,
|
|
52
|
+
selectCommandGroup
|
|
53
|
+
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SITES_CREATE_METADATA,
|
|
3
|
+
registerSitesCreate
|
|
4
|
+
} from "./chunk-BRC7CU3J.js";
|
|
1
5
|
import {
|
|
2
6
|
asCliError,
|
|
3
7
|
clientFor
|
|
4
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4B6PUKF5.js";
|
|
5
9
|
import {
|
|
6
10
|
applyCommandHelp
|
|
7
11
|
} from "./chunk-M2BZEDAS.js";
|
|
@@ -9,13 +13,15 @@ import {
|
|
|
9
13
|
commandMetadata,
|
|
10
14
|
createResultWriter,
|
|
11
15
|
failureResult,
|
|
12
|
-
|
|
16
|
+
grantFields,
|
|
17
|
+
grantLimitation,
|
|
18
|
+
invalidInput2 as invalidInput,
|
|
13
19
|
listSites,
|
|
14
20
|
readSiteDetail,
|
|
15
21
|
resolveGlobalOptions,
|
|
16
22
|
resolveTarget,
|
|
17
23
|
successResult
|
|
18
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-EH6E45H4.js";
|
|
19
25
|
|
|
20
26
|
// src/commands/sites.ts
|
|
21
27
|
var SITES_METADATA = Object.freeze([
|
|
@@ -37,7 +43,7 @@ var SITES_METADATA = Object.freeze([
|
|
|
37
43
|
output: {
|
|
38
44
|
fields: ["site_id", "site.hostnames", "site.active_release", "site.reader_status", "site.latest_job", "site.usage", "connections.docs_repo", "connections.product_connections"],
|
|
39
45
|
ids: ["release_id"],
|
|
40
|
-
limitations: []
|
|
46
|
+
limitations: ["section_unavailable", "field_omitted"]
|
|
41
47
|
},
|
|
42
48
|
errors: ["invalid_input", "unauthorized", "forbidden", "not_found", "rate_limited", "service_unavailable", "transport_failure", "interrupted"],
|
|
43
49
|
examples: [
|
|
@@ -45,7 +51,8 @@ var SITES_METADATA = Object.freeze([
|
|
|
45
51
|
{ command: "saturndocs sites get acme --connections", description: "One site with its documentation repository and watched repositories." },
|
|
46
52
|
{ command: "saturndocs sites get --json", description: "The site read as one result object, with the resolved site_id in the envelope." }
|
|
47
53
|
]
|
|
48
|
-
})
|
|
54
|
+
}),
|
|
55
|
+
SITES_CREATE_METADATA
|
|
49
56
|
]);
|
|
50
57
|
function requestedSite(positional, flag) {
|
|
51
58
|
const named = positional ?? flag ?? void 0;
|
|
@@ -63,11 +70,11 @@ function detailText(detail) {
|
|
|
63
70
|
const release = site.active_release;
|
|
64
71
|
const lines = [
|
|
65
72
|
`site: ${detail.site_id}`,
|
|
66
|
-
`hostnames: ${site.hostnames.length === 0 ? "none returned" : site.hostnames.join(", ")}
|
|
73
|
+
...site.hostnames === void 0 ? [] : [`hostnames: ${site.hostnames.length === 0 ? "none returned" : site.hostnames.join(", ")}`],
|
|
67
74
|
`reader status: ${site.reader_status ?? "not reported"}`,
|
|
68
75
|
release === null ? "active release: none" : `active release: ${release.release_id} (${release.state}), activated ${release.activated_at ?? "at an unrecorded time"}`,
|
|
69
|
-
site.latest_job === null ? "latest job: none" : `latest job: ${site.latest_job.state}${site.latest_job.error_code
|
|
70
|
-
`usage: ${site.usage === void 0 || Object.keys(site.usage).length === 0 ? "nothing measured" : Object.entries(site.usage).map(([name, meter]) => `${name} ${JSON.stringify(meter)}`).join("; ")}`
|
|
76
|
+
site.latest_job === null ? "latest job: none" : `latest job: ${site.latest_job.state}${site.latest_job.error_code == null ? "" : ` (${site.latest_job.error_code})`}`,
|
|
77
|
+
...site.hostnames === void 0 ? [] : [`usage: ${site.usage === void 0 || Object.keys(site.usage).length === 0 ? "nothing measured" : Object.entries(site.usage).map(([name, meter]) => `${name} ${JSON.stringify(meter)}`).join("; ")}`]
|
|
71
78
|
];
|
|
72
79
|
if (detail.connections !== null) {
|
|
73
80
|
const docs = detail.connections.docs_repo;
|
|
@@ -79,7 +86,8 @@ function detailText(detail) {
|
|
|
79
86
|
return lines.join("\n");
|
|
80
87
|
}
|
|
81
88
|
function registerSites(program, _cliDir, environment = {}) {
|
|
82
|
-
const sites = program.command("sites").description("
|
|
89
|
+
const sites = program.command("sites").description("Create a site, or discover and inspect the sites this credential reaches");
|
|
90
|
+
registerSitesCreate(sites, environment);
|
|
83
91
|
const list = sites.command("list").action(async (_options, self) => {
|
|
84
92
|
const globals = resolveGlobalOptions(self);
|
|
85
93
|
const writer = createResultWriter({ json: globals.json });
|
|
@@ -98,13 +106,13 @@ function registerSites(program, _cliDir, environment = {}) {
|
|
|
98
106
|
const writer = createResultWriter({ json: globals.json });
|
|
99
107
|
const context = { command: "sites get", siteId: null };
|
|
100
108
|
try {
|
|
101
|
-
const client = clientFor(globals, environment);
|
|
102
109
|
const named = requestedSite(siteId, globals.site);
|
|
110
|
+
const client = clientFor(named === void 0 ? globals : { ...globals, site: named }, environment);
|
|
103
111
|
const target = await resolveTarget(client, named === void 0 ? {} : { site: named });
|
|
104
112
|
context.siteId = target.site_id;
|
|
105
113
|
const detail = await readSiteDetail(client, target.site_id, { connections: options.connections === true });
|
|
106
114
|
if (detail.site.active_release !== null) context.ids = { release_id: detail.site.active_release.release_id };
|
|
107
|
-
process.exitCode = writer.write(successResult(context, detail), { text: detailText(detail) });
|
|
115
|
+
process.exitCode = writer.write(successResult({ ...context, limitations: detail.site.hostnames === void 0 ? [grantLimitation("site", grantFields.site)] : [] }, detail), { text: detailText(detail) });
|
|
108
116
|
} catch (error) {
|
|
109
117
|
process.exitCode = writer.write(failureResult(asCliError(error), context));
|
|
110
118
|
}
|
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RESERVED_URL_PREFIXES,
|
|
3
|
+
findUnresolvedLinks,
|
|
4
|
+
isIgnoredSourceFile,
|
|
5
|
+
outlineDocId,
|
|
6
|
+
pageAssetReferences,
|
|
7
|
+
resolveHref,
|
|
8
|
+
stripPage,
|
|
9
|
+
validateBundleSemanticsAsync,
|
|
10
|
+
validateBundleStructure,
|
|
11
|
+
violationGuidance
|
|
12
|
+
} from "./chunk-HHRZ3Y55.js";
|
|
13
|
+
import {
|
|
14
|
+
assetPathname,
|
|
15
|
+
configuredAssetHref,
|
|
16
|
+
loadDocsConfig,
|
|
17
|
+
loadModelsConfig,
|
|
18
|
+
navigationGroups,
|
|
19
|
+
navigationIconRefs,
|
|
20
|
+
parseOpenApiFile
|
|
21
|
+
} from "./chunk-ZHYL7FYA.js";
|
|
22
|
+
import {
|
|
23
|
+
createResultWriter,
|
|
24
|
+
failureResult,
|
|
25
|
+
invalidInput2 as invalidInput,
|
|
26
|
+
resolveGlobalOptions,
|
|
27
|
+
successResult
|
|
28
|
+
} from "./chunk-EH6E45H4.js";
|
|
29
|
+
|
|
30
|
+
// src/commands/validate.ts
|
|
31
|
+
import { existsSync as existsSync3 } from "fs";
|
|
32
|
+
import { resolve } from "path";
|
|
33
|
+
|
|
34
|
+
// src/lib/validate.ts
|
|
35
|
+
import { existsSync as existsSync2 } from "fs";
|
|
36
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
37
|
+
import { join as join3, relative, sep } from "path";
|
|
38
|
+
|
|
39
|
+
// src/lib/assets.ts
|
|
40
|
+
import { posix } from "path";
|
|
41
|
+
import { LineCounter, isNode, parseDocument } from "yaml";
|
|
42
|
+
|
|
43
|
+
// ../components/src/icon-resolver.ts
|
|
44
|
+
import { getIconData, iconToSVG } from "@iconify/utils";
|
|
45
|
+
import { icons as lucideIcons } from "@iconify-json/lucide";
|
|
46
|
+
import { icons as tablerIcons } from "@iconify-json/tabler";
|
|
47
|
+
import { icons as fa6SolidIcons } from "@iconify-json/fa6-solid";
|
|
48
|
+
var ICON_SETS = [
|
|
49
|
+
["lucide", lucideIcons],
|
|
50
|
+
["tabler", tablerIcons],
|
|
51
|
+
["fa6-solid", fa6SolidIcons]
|
|
52
|
+
];
|
|
53
|
+
function resolveIconSet(name) {
|
|
54
|
+
const trimmed = name.trim();
|
|
55
|
+
if (trimmed.length === 0) return null;
|
|
56
|
+
for (const [setName, set] of ICON_SETS) {
|
|
57
|
+
if (getIconData(set, trimmed) !== null) return setName;
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/lib/assets.ts
|
|
63
|
+
function configLocator(source) {
|
|
64
|
+
const lines = new LineCounter();
|
|
65
|
+
const document = parseDocument(source, { schema: "json", lineCounter: lines });
|
|
66
|
+
return (keys) => {
|
|
67
|
+
const node = document.getIn(keys, true);
|
|
68
|
+
if (!isNode(node) || !node.range) return void 0;
|
|
69
|
+
const { line, col } = lines.linePos(node.range[0]);
|
|
70
|
+
return { line, column: col };
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function validateAssets(config, locate, pages, files) {
|
|
74
|
+
const issues = [];
|
|
75
|
+
const checkIcon = (path, value, place2) => {
|
|
76
|
+
if (resolveIconSet(value) === null) issues.push({
|
|
77
|
+
path,
|
|
78
|
+
...place2,
|
|
79
|
+
severity: "error",
|
|
80
|
+
code: "unknown_icon",
|
|
81
|
+
message: `Unknown icon "${value}".`,
|
|
82
|
+
fix: "Use an icon name from lucide, tabler, or fa6-solid."
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
const checkImage = (path, value, href, place2, sourceRelative = false) => {
|
|
86
|
+
if (href && /^[a-z][a-z0-9+.-]*:/i.test(href)) return;
|
|
87
|
+
let file;
|
|
88
|
+
try {
|
|
89
|
+
if (href !== void 0) {
|
|
90
|
+
const pathname = assetPathname(href);
|
|
91
|
+
if (pathname.startsWith("/")) file = `public${posix.normalize(pathname)}`;
|
|
92
|
+
else if (sourceRelative) file = posix.join(posix.dirname(path), pathname);
|
|
93
|
+
else file = posix.join("public", posix.dirname(outlineDocId(path)), pathname);
|
|
94
|
+
}
|
|
95
|
+
} catch (error) {
|
|
96
|
+
if (!(error instanceof URIError)) throw error;
|
|
97
|
+
}
|
|
98
|
+
if (file !== void 0 && files.has(file)) return;
|
|
99
|
+
const fix = file?.startsWith("public/") ? `Add ${file} or correct the image path.` : "Use a root-relative path to an image under public/.";
|
|
100
|
+
issues.push({
|
|
101
|
+
path,
|
|
102
|
+
...place2,
|
|
103
|
+
severity: "error",
|
|
104
|
+
code: "missing_image",
|
|
105
|
+
message: `Image "${value}" does not resolve to a file.`,
|
|
106
|
+
fix
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
for (const ref of navigationIconRefs(config)) {
|
|
110
|
+
if (!ref.icon.startsWith("/")) checkIcon("docs.json", ref.icon, locate(ref.keys));
|
|
111
|
+
}
|
|
112
|
+
const configured = (keys, value) => {
|
|
113
|
+
if (!value) return;
|
|
114
|
+
const href = configuredAssetHref(value, (file) => files.has(`public/${file}`));
|
|
115
|
+
checkImage("docs.json", value, href, locate(keys));
|
|
116
|
+
};
|
|
117
|
+
if (typeof config.logo === "string") configured(["logo"], config.logo);
|
|
118
|
+
else {
|
|
119
|
+
configured(["logo", "light"], config.logo?.light);
|
|
120
|
+
configured(["logo", "dark"], config.logo?.dark);
|
|
121
|
+
}
|
|
122
|
+
configured(["favicon"], config.favicon);
|
|
123
|
+
configured(["ai", "triggerIcon"], config.ai?.triggerIcon);
|
|
124
|
+
for (const path of pages) {
|
|
125
|
+
for (const ref of pageAssetReferences(path, files.get(path))) {
|
|
126
|
+
const { line, column, value } = ref;
|
|
127
|
+
if (ref.kind === "icon") checkIcon(path, value, { line, column });
|
|
128
|
+
else checkImage(path, value, value, { line, column }, ref.kind === "markdown-image");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return issues;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/lib/bundle.ts
|
|
135
|
+
import { lstat, readFile, readdir } from "fs/promises";
|
|
136
|
+
import { join, posix as posix2 } from "path";
|
|
137
|
+
var isLocalNoise = (entry) => entry.name.startsWith(".") || entry.isDirectory() && entry.name === "node_modules";
|
|
138
|
+
async function collectDirectory(root, relative2, files) {
|
|
139
|
+
const skillTree = relative2 === "skills" || relative2.startsWith("skills/");
|
|
140
|
+
const absolute = join(root, ...relative2.split("/"));
|
|
141
|
+
const entries = await readdir(absolute, { withFileTypes: true });
|
|
142
|
+
for (const entry of entries.sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0)) {
|
|
143
|
+
if (!skillTree && isLocalNoise(entry)) continue;
|
|
144
|
+
const path = posix2.join(relative2, entry.name);
|
|
145
|
+
const absolutePath = join(root, ...path.split("/"));
|
|
146
|
+
if (entry.isSymbolicLink()) throw new Error(`source bundle cannot contain a symbolic link: ${path}`);
|
|
147
|
+
if (entry.isDirectory()) await collectDirectory(root, path, files);
|
|
148
|
+
else if (entry.isFile()) files.push({ path, absolutePath, bytes: new Uint8Array(await readFile(absolutePath)) });
|
|
149
|
+
else throw new Error(`source bundle contains an unsupported filesystem entry: ${path}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
var SOURCE_FILES = ["docs.json", "models.toml"];
|
|
153
|
+
var SOURCE_ROOTS = ["pages", "public", "openapi", "skills"];
|
|
154
|
+
async function collectSourceFiles(docsDir) {
|
|
155
|
+
const files = [];
|
|
156
|
+
for (const [legacy, replacement] of [["assets", "public"], ["api-reference", "openapi"]]) {
|
|
157
|
+
if (await lstat(join(docsDir, legacy)).catch(() => null) !== null) {
|
|
158
|
+
throw new Error(`legacy ${legacy}/ source is not publishable; move it to ${replacement}/`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
for (const name of SOURCE_FILES) {
|
|
162
|
+
const absolutePath = join(docsDir, name);
|
|
163
|
+
const info = await lstat(absolutePath).catch(() => null);
|
|
164
|
+
if (info === null) continue;
|
|
165
|
+
if (info.isSymbolicLink() || !info.isFile()) throw new Error(`${name} must be a regular file`);
|
|
166
|
+
files.push({ path: name, absolutePath, bytes: new Uint8Array(await readFile(absolutePath)) });
|
|
167
|
+
}
|
|
168
|
+
for (const name of SOURCE_ROOTS) {
|
|
169
|
+
const absolutePath = join(docsDir, name);
|
|
170
|
+
const info = await lstat(absolutePath).catch(() => null);
|
|
171
|
+
if (info === null) continue;
|
|
172
|
+
if (info.isSymbolicLink() || !info.isDirectory()) throw new Error(`${name} must be a regular directory`);
|
|
173
|
+
await collectDirectory(docsDir, name, files);
|
|
174
|
+
}
|
|
175
|
+
return files.sort((left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0);
|
|
176
|
+
}
|
|
177
|
+
async function collectOutsideRootFiles(docsDir) {
|
|
178
|
+
const inRoots = /* @__PURE__ */ new Set([...SOURCE_FILES, ...SOURCE_ROOTS]);
|
|
179
|
+
const files = [];
|
|
180
|
+
const walk = async (relative2) => {
|
|
181
|
+
for (const entry of await readdir(join(docsDir, ...relative2.split("/")), { withFileTypes: true })) {
|
|
182
|
+
const path = posix2.join(relative2, entry.name);
|
|
183
|
+
if (isLocalNoise(entry) || relative2 === "" && inRoots.has(entry.name)) continue;
|
|
184
|
+
if (entry.isDirectory()) {
|
|
185
|
+
await walk(path);
|
|
186
|
+
} else if (entry.isFile() && !isIgnoredSourceFile(path)) {
|
|
187
|
+
files.push({ path, size: (await lstat(join(docsDir, ...path.split("/")))).size });
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
await walk("");
|
|
192
|
+
return files;
|
|
193
|
+
}
|
|
194
|
+
function pageSourcePaths(files) {
|
|
195
|
+
return files.map((file) => file.path).filter((path) => path.startsWith("pages/") && /\.(?:md|mdx)$/i.test(path));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// src/lib/pages.ts
|
|
199
|
+
import { existsSync } from "fs";
|
|
200
|
+
import { join as join2 } from "path";
|
|
201
|
+
function resolvePageFile(docsDir, entry) {
|
|
202
|
+
const mdxPath = join2(docsDir, "pages", `${entry}.mdx`);
|
|
203
|
+
const mdPath = join2(docsDir, "pages", `${entry}.md`);
|
|
204
|
+
const hasMdx = existsSync(mdxPath);
|
|
205
|
+
const hasMd = existsSync(mdPath);
|
|
206
|
+
if (hasMdx && hasMd) {
|
|
207
|
+
throw new Error(
|
|
208
|
+
`Page "${entry}" resolves to both pages/${entry}.mdx and pages/${entry}.md; keep only one.`
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
if (hasMdx) return { entry, file: mdxPath, ext: ".mdx" };
|
|
212
|
+
if (hasMd) return { entry, file: mdPath, ext: ".md" };
|
|
213
|
+
throw new Error(
|
|
214
|
+
`Page "${entry}" not found: expected pages/${entry}.mdx or pages/${entry}.md.`
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
function pageUrl(entry) {
|
|
218
|
+
return entry === "index" ? "/" : `/${entry}`;
|
|
219
|
+
}
|
|
220
|
+
function collectPageEntries(config) {
|
|
221
|
+
return navigationGroups(config).flatMap((group) => group.pages);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// src/lib/validate.ts
|
|
225
|
+
function messageOf(error) {
|
|
226
|
+
return error instanceof Error ? error.message : String(error);
|
|
227
|
+
}
|
|
228
|
+
function finding(code, message, text, place2 = {}) {
|
|
229
|
+
return {
|
|
230
|
+
issue: {
|
|
231
|
+
path: place2.path ?? null,
|
|
232
|
+
line: place2.line ?? null,
|
|
233
|
+
column: place2.column ?? null,
|
|
234
|
+
code,
|
|
235
|
+
message,
|
|
236
|
+
fix: place2.fix ?? violationGuidance(code)?.requirement ?? null
|
|
237
|
+
},
|
|
238
|
+
text
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function violationFindings(violations) {
|
|
242
|
+
return violations.filter((violation) => violation.severity === "error").map((violation) => finding(violation.code, violation.message, `${violation.path ?? "bundle"}: ${violation.message}`, violation));
|
|
243
|
+
}
|
|
244
|
+
function docsRelative(docsDir, file) {
|
|
245
|
+
return relative(docsDir, file).split(sep).join("/");
|
|
246
|
+
}
|
|
247
|
+
var isSiteRoot = (href) => (href.split("#")[0] ?? "").split("?")[0] === "/";
|
|
248
|
+
var RESERVED_SEGMENTS = new Set(RESERVED_URL_PREFIXES.map((prefix) => prefix.replace(/^\//, "").replace(/\/\*$/, "")));
|
|
249
|
+
var isReservedRoute = (target) => target !== null && RESERVED_SEGMENTS.has(target.split("/")[0] ?? "");
|
|
250
|
+
async function validateBundle(docsDir, config, routeDocIds) {
|
|
251
|
+
let files;
|
|
252
|
+
let outsideRoots;
|
|
253
|
+
try {
|
|
254
|
+
files = await collectSourceFiles(docsDir);
|
|
255
|
+
outsideRoots = await collectOutsideRootFiles(docsDir);
|
|
256
|
+
} catch (error) {
|
|
257
|
+
return [finding("read_error", messageOf(error), messageOf(error))];
|
|
258
|
+
}
|
|
259
|
+
const errors = violationFindings(validateBundleStructure([
|
|
260
|
+
...files.map((file) => ({ path: file.path, size: file.bytes.byteLength })),
|
|
261
|
+
...outsideRoots
|
|
262
|
+
]));
|
|
263
|
+
const byPath = new Map(files.map((file) => [file.path, file.bytes]));
|
|
264
|
+
const pagePaths = pageSourcePaths(files);
|
|
265
|
+
const docsJson = byPath.get("docs.json") ?? new Uint8Array();
|
|
266
|
+
const locate = configLocator(new TextDecoder().decode(docsJson));
|
|
267
|
+
if (errors.length === 0) {
|
|
268
|
+
errors.push(...violationFindings(await validateBundleSemanticsAsync({
|
|
269
|
+
docsJson,
|
|
270
|
+
configLocation: locate,
|
|
271
|
+
modelsToml: byPath.get("models.toml"),
|
|
272
|
+
skillPaths: files.map((file) => file.path).filter((path) => path.startsWith("skills/")),
|
|
273
|
+
pagePaths,
|
|
274
|
+
readFile: async (path) => byPath.get(path) ?? null,
|
|
275
|
+
pageIssues: "all"
|
|
276
|
+
})));
|
|
277
|
+
}
|
|
278
|
+
if (config === null) return errors;
|
|
279
|
+
const decoder = new TextDecoder();
|
|
280
|
+
const pages = pagePaths.map((path) => ({ path, docId: outlineDocId(path), source: decoder.decode(byPath.get(path)) }));
|
|
281
|
+
errors.push(...violationFindings(validateAssets(config, locate, pagePaths, byPath)));
|
|
282
|
+
const docIds = /* @__PURE__ */ new Set([...pages.map((page) => page.docId), ...routeDocIds]);
|
|
283
|
+
for (const miss of findUnresolvedLinks(pages, docIds)) {
|
|
284
|
+
if (isSiteRoot(miss.href) && docIds.has("index")) continue;
|
|
285
|
+
if (isReservedRoute(resolveHref(miss.href, outlineDocId(miss.path)))) continue;
|
|
286
|
+
const message = `link to ${miss.href} does not resolve to a page`;
|
|
287
|
+
errors.push(finding("unresolved_link", message, `${miss.path}: ${message}`, {
|
|
288
|
+
path: miss.path,
|
|
289
|
+
fix: "link to a page listed in docs.json navigation, an OpenAPI operation page, or a full URL"
|
|
290
|
+
}));
|
|
291
|
+
}
|
|
292
|
+
return errors;
|
|
293
|
+
}
|
|
294
|
+
async function validateDocsReport(docsDir) {
|
|
295
|
+
return sortIssues((await validateFindings(docsDir)).map((entry) => entry.issue));
|
|
296
|
+
}
|
|
297
|
+
async function validateDocs(docsDir) {
|
|
298
|
+
return (await validateFindings(docsDir)).map((entry) => entry.text);
|
|
299
|
+
}
|
|
300
|
+
function sortIssues(issues) {
|
|
301
|
+
return issues.map((issue, index) => ({ issue, index })).sort((left, right) => {
|
|
302
|
+
const leftPath = left.issue.path ?? "";
|
|
303
|
+
const rightPath = right.issue.path ?? "";
|
|
304
|
+
if (leftPath !== rightPath) return leftPath < rightPath ? -1 : 1;
|
|
305
|
+
const lineOrder = (left.issue.line ?? Number.MAX_SAFE_INTEGER) - (right.issue.line ?? Number.MAX_SAFE_INTEGER);
|
|
306
|
+
if (lineOrder !== 0) return lineOrder;
|
|
307
|
+
const columnOrder = (left.issue.column ?? 0) - (right.issue.column ?? 0);
|
|
308
|
+
return columnOrder !== 0 ? columnOrder : left.index - right.index;
|
|
309
|
+
}).map((entry) => entry.issue);
|
|
310
|
+
}
|
|
311
|
+
async function preflightErrors(docsDir, errors) {
|
|
312
|
+
if (!existsSync2(join3(docsDir, "skills"))) return errors;
|
|
313
|
+
const findings = await validateBundle(docsDir, null, []);
|
|
314
|
+
return [...errors, ...findings.filter(({ issue }) => issue.path?.startsWith("skills/"))];
|
|
315
|
+
}
|
|
316
|
+
async function validateFindings(docsDir) {
|
|
317
|
+
const errors = [];
|
|
318
|
+
const docsJsonPath = join3(docsDir, "docs.json");
|
|
319
|
+
if (!existsSync2(docsJsonPath)) {
|
|
320
|
+
const message = `docs.json not found in ${docsDir}.`;
|
|
321
|
+
return preflightErrors(docsDir, [finding("missing_docs_json", message, message, { path: "docs.json" })]);
|
|
322
|
+
}
|
|
323
|
+
let config;
|
|
324
|
+
try {
|
|
325
|
+
config = await loadDocsConfig(docsJsonPath);
|
|
326
|
+
} catch (error) {
|
|
327
|
+
return preflightErrors(docsDir, [finding("invalid_docs_json", messageOf(error), `docs.json: ${messageOf(error)}`, { path: "docs.json" })]);
|
|
328
|
+
}
|
|
329
|
+
const modelsTomlPath = join3(docsDir, "models.toml");
|
|
330
|
+
if (existsSync2(modelsTomlPath)) {
|
|
331
|
+
try {
|
|
332
|
+
await loadModelsConfig(modelsTomlPath);
|
|
333
|
+
} catch (error) {
|
|
334
|
+
errors.push(finding("invalid_models_toml", messageOf(error), `models.toml: ${messageOf(error)}`, { path: "models.toml" }));
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
for (const entry of collectPageEntries(config)) {
|
|
338
|
+
let resolved;
|
|
339
|
+
try {
|
|
340
|
+
resolved = resolvePageFile(docsDir, entry);
|
|
341
|
+
} catch (error) {
|
|
342
|
+
errors.push(finding("missing_page", messageOf(error), messageOf(error), { path: "docs.json" }));
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
const pagePath = docsRelative(docsDir, resolved.file);
|
|
346
|
+
try {
|
|
347
|
+
const { frontmatter } = stripPage(await readFile2(resolved.file, "utf8"), resolved.file);
|
|
348
|
+
const groups = frontmatter.groups;
|
|
349
|
+
const grouped = Array.isArray(groups) && groups.length > 0;
|
|
350
|
+
if (grouped && frontmatter.pagefind !== false) {
|
|
351
|
+
const message = `Page "${entry}" restricts access with \`groups\` but is missing \`pagefind: false\`; gated content must stay out of the shared search index.`;
|
|
352
|
+
errors.push(finding("pagefind_required", message, message, { path: pagePath }));
|
|
353
|
+
}
|
|
354
|
+
} catch (error) {
|
|
355
|
+
errors.push(finding("invalid_frontmatter", messageOf(error), `Page "${entry}": ${messageOf(error)}`, { path: pagePath }));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
const operationDocIds = [];
|
|
359
|
+
for (const group of navigationGroups(config)) {
|
|
360
|
+
if (!group.openapi) continue;
|
|
361
|
+
const openapiPath = join3(docsDir, group.openapi);
|
|
362
|
+
if (!existsSync2(openapiPath)) {
|
|
363
|
+
const message = `OpenAPI file not found: ${group.openapi}`;
|
|
364
|
+
errors.push(finding("missing_openapi", message, message, { path: group.openapi }));
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
try {
|
|
368
|
+
const spec = await parseOpenApiFile(openapiPath);
|
|
369
|
+
operationDocIds.push(...spec.operations.map((operation) => `api-reference/${operation.slug}`));
|
|
370
|
+
} catch (error) {
|
|
371
|
+
errors.push(finding("invalid_openapi", messageOf(error), `OpenAPI ${group.openapi}: ${messageOf(error)}`, { path: group.openapi }));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
if (errors.length > 0) return preflightErrors(docsDir, errors);
|
|
375
|
+
return validateBundle(docsDir, config, operationDocIds);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// src/commands/validate.ts
|
|
379
|
+
function place(issue) {
|
|
380
|
+
if (issue.path === null) return "bundle";
|
|
381
|
+
if (issue.line === null) return issue.path;
|
|
382
|
+
return issue.column === null ? `${issue.path}:${issue.line}` : `${issue.path}:${issue.line}:${issue.column}`;
|
|
383
|
+
}
|
|
384
|
+
function validateReportText(report) {
|
|
385
|
+
if (report.valid) return `\u2713 ${report.docs_dir} is valid.`;
|
|
386
|
+
const lines = [`\u2716 ${report.errors.length} validation error(s) in ${report.docs_dir}:`];
|
|
387
|
+
for (const issue of report.errors) {
|
|
388
|
+
lines.push(` - ${place(issue)} ${issue.code}: ${issue.message}`);
|
|
389
|
+
if (issue.fix !== null) lines.push(` fix: ${issue.fix}`);
|
|
390
|
+
}
|
|
391
|
+
return lines.join("\n");
|
|
392
|
+
}
|
|
393
|
+
function registerValidate(program) {
|
|
394
|
+
program.command("validate").description("Validate docs.json, models.toml, page files, and OpenAPI specs").argument("[dir]", "docs directory (contains docs.json)").action(async (dir, _options, self) => {
|
|
395
|
+
const globals = resolveGlobalOptions(self);
|
|
396
|
+
const writer = createResultWriter({ json: globals.json });
|
|
397
|
+
const context = { command: "validate", siteId: null };
|
|
398
|
+
try {
|
|
399
|
+
const docsDir = resolve(dir ?? process.cwd());
|
|
400
|
+
if (!existsSync3(resolve(docsDir, "docs.json"))) {
|
|
401
|
+
throw invalidInput(`No docs.json found in ${docsDir}. Pass a docs directory.`);
|
|
402
|
+
}
|
|
403
|
+
const errors = await validateDocsReport(docsDir);
|
|
404
|
+
const report = { docs_dir: docsDir, valid: errors.length === 0, errors };
|
|
405
|
+
if (!report.valid) throw invalidInput(validateReportText(report), { data: report });
|
|
406
|
+
process.exitCode = writer.write(successResult(context, report), { text: validateReportText(report) });
|
|
407
|
+
} catch (error) {
|
|
408
|
+
process.exitCode = writer.write(failureResult(error, context));
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
export {
|
|
414
|
+
resolvePageFile,
|
|
415
|
+
pageUrl,
|
|
416
|
+
collectPageEntries,
|
|
417
|
+
validateDocsReport,
|
|
418
|
+
validateDocs,
|
|
419
|
+
validateReportText,
|
|
420
|
+
registerValidate
|
|
421
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
readPageFiles
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YGVC4N4V.js";
|
|
4
4
|
import {
|
|
5
5
|
asCliError
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4B6PUKF5.js";
|
|
7
7
|
import {
|
|
8
8
|
applyCommandHelp
|
|
9
9
|
} from "./chunk-M2BZEDAS.js";
|
|
@@ -11,11 +11,11 @@ import {
|
|
|
11
11
|
commandMetadata,
|
|
12
12
|
createResultWriter,
|
|
13
13
|
failureResult,
|
|
14
|
-
invalidInput,
|
|
14
|
+
invalidInput2 as invalidInput,
|
|
15
15
|
messageOf,
|
|
16
16
|
resolveGlobalOptions,
|
|
17
17
|
successResult
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-EH6E45H4.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-
|
|
52
|
+
const { parseOutline, outlineCoverage } = await import("./dist-LZ5BC7HG.js");
|
|
53
53
|
let outline;
|
|
54
54
|
try {
|
|
55
55
|
outline = parseOutline(JSON.parse(raw));
|