@dogsbay/ssg-cli 0.2.0-beta.186 → 0.2.0-beta.188
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/AGENTS.md +168 -0
- package/README.md +3 -1
- package/THIRD-PARTY-NOTICES.txt +23 -17
- package/chunks/{build-command-X76EICE4.mjs → build-command-NJATVOUY.mjs} +34 -25
- package/chunks/check-command-FL5O3AXB.mjs +577 -0
- package/chunks/chunk-2EM7IEQT.mjs +95 -0
- package/chunks/{chunk-JABACD5T.mjs → chunk-5A2QPRCV.mjs} +1 -30
- package/chunks/chunk-5NQOUB5I.mjs +4534 -0
- package/chunks/{chunk-YQ2K646L.mjs → chunk-CYJ6GFVM.mjs} +32 -3
- package/chunks/{chunk-XQORVEL6.mjs → chunk-FFIXBXHD.mjs} +60 -233
- package/chunks/chunk-GFG5I7WI.mjs +807 -0
- package/chunks/{chunk-AOHGXC4D.mjs → chunk-GZ3E45TE.mjs} +518 -240
- package/chunks/chunk-IAAKV7V2.mjs +37 -0
- package/chunks/{chunk-YA6TJOAM.mjs → chunk-VJ6AESSJ.mjs} +216 -24
- package/chunks/chunk-X3UPCLX5.mjs +503 -0
- package/chunks/{chunk-TRECVC6H.mjs → chunk-ZDH4JRVX.mjs} +1041 -4051
- package/chunks/{chunk-FNP5PNJW.mjs → chunk-ZRGJHNES.mjs} +6 -0
- package/chunks/compare-W4DJYVHT.mjs +239 -0
- package/chunks/compare-command-U36H55IE.mjs +144 -0
- package/chunks/{css-build-VKKTSP6P.mjs → css-build-MKIHYHCX.mjs} +2 -1
- package/chunks/{dev-DXMZPST7.mjs → dev-X3PKN4G3.mjs} +77 -26
- package/chunks/{menu-W7ZXME4A.mjs → menu-J3CLVADF.mjs} +5 -3
- package/chunks/{publish-command-AVMRM4UZ.mjs → publish-command-SAPICGGM.mjs} +15 -8
- package/chunks/{release-diff-3OZOYBXR.mjs → release-diff-Y7X63MT3.mjs} +13 -7
- package/chunks/{serve-U2YV7AQH.mjs → serve-7DR4WSYA.mjs} +2 -2
- package/cli.mjs +17 -10
- package/package.json +4 -3
- package/chunks/check-command-SXDUKSAZ.mjs +0 -256
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
} from "./chunk-CMGKSS45.mjs";
|
|
6
6
|
import {
|
|
7
7
|
sitePolicy
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-CYJ6GFVM.mjs";
|
|
9
|
+
import "./chunk-VJ6AESSJ.mjs";
|
|
10
10
|
import "./chunk-O3R3MASP.mjs";
|
|
11
11
|
import "./chunk-STRHO6SY.mjs";
|
|
12
12
|
|
package/cli.mjs
CHANGED
|
@@ -7,16 +7,18 @@ import {
|
|
|
7
7
|
option,
|
|
8
8
|
positional,
|
|
9
9
|
wantsHelp
|
|
10
|
-
} from "./chunks/chunk-
|
|
10
|
+
} from "./chunks/chunk-ZRGJHNES.mjs";
|
|
11
11
|
import "./chunks/chunk-STRHO6SY.mjs";
|
|
12
12
|
|
|
13
13
|
// src/node/cli.ts
|
|
14
14
|
import { resolve } from "node:path";
|
|
15
|
+
var VERSION = true ? "0.2.0-beta.188" : "unbundled";
|
|
15
16
|
var HIGHLIGHT_WORKER = new URL("./highlight-worker.mjs", import.meta.url);
|
|
16
17
|
var USAGE = {
|
|
17
18
|
build: BUILD_USAGE,
|
|
18
19
|
assemble: "assemble [project] [-o site] [--quiet]",
|
|
19
|
-
check: "check [project] [--json] [--strict] [--source|--dist] [--category <c>] [--rule <id>] [--skip <id>] [--include-drafts] [--untrusted] [--low-memory] [--no-diagrams] [--quiet]",
|
|
20
|
+
check: "check [project] [--json] [--strict] [--source|--dist] [--category <c>] [--rule <id>] [--skip <id>] [--artifact] [--include-drafts] [--untrusted] [--low-memory] [--no-diagrams] [--quiet]",
|
|
21
|
+
compare: "compare <old> <new> [-o out] [--labels <old>,<new>] [--ignore [links|text|code|all:]<pattern>]... [--no-search] [--no-diagrams] [--force] [--quiet] [--all-warnings] [--as-worker]",
|
|
20
22
|
"release-diff": "release-diff [project] [--from <version>] [--json] [--write] [--candidates] [--strict] [--git-from <ref>]",
|
|
21
23
|
dev: "dev [project] [-p port] [--lazy] [--no-search] [--llms] [--no-diagrams]",
|
|
22
24
|
serve: "serve [dir] [-p port] [--csp]",
|
|
@@ -24,7 +26,7 @@ var USAGE = {
|
|
|
24
26
|
};
|
|
25
27
|
function usage(code = 0, cmd2) {
|
|
26
28
|
const lines = cmd2 && Object.hasOwn(USAGE, cmd2) ? [USAGE[cmd2]] : Object.values(USAGE);
|
|
27
|
-
console.log(lines.map((l) => `dogsbay-ssg ${l}`).join("\n"));
|
|
29
|
+
console.log([...lines.map((l) => `dogsbay-ssg ${l}`), ...cmd2 ? [] : ["dogsbay-ssg --version"]].join("\n"));
|
|
28
30
|
process.exit(code);
|
|
29
31
|
}
|
|
30
32
|
var cmd;
|
|
@@ -32,21 +34,26 @@ async function main() {
|
|
|
32
34
|
const args = process.argv.slice(2);
|
|
33
35
|
cmd = args.shift();
|
|
34
36
|
if (!cmd || cmd === "-h" || cmd === "--help") usage();
|
|
37
|
+
if (cmd === "-v" || cmd === "--version") {
|
|
38
|
+
console.log(VERSION);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
35
41
|
if (!Object.hasOwn(USAGE, cmd)) {
|
|
36
42
|
console.error(`unknown command: ${cmd}`);
|
|
37
43
|
usage(1);
|
|
38
44
|
}
|
|
39
45
|
if (wantsHelp(args)) usage(0, cmd);
|
|
40
|
-
if (cmd === "build") return (await import("./chunks/build-command-
|
|
41
|
-
if (cmd === "assemble") return (await import("./chunks/build-command-
|
|
42
|
-
if (cmd === "
|
|
43
|
-
if (cmd === "
|
|
46
|
+
if (cmd === "build") return (await import("./chunks/build-command-NJATVOUY.mjs")).runBuild(args, HIGHLIGHT_WORKER);
|
|
47
|
+
if (cmd === "assemble") return (await import("./chunks/build-command-NJATVOUY.mjs")).runBuild(args, HIGHLIGHT_WORKER, { assemble: true });
|
|
48
|
+
if (cmd === "compare") return (await import("./chunks/compare-command-U36H55IE.mjs")).runCompare(args, HIGHLIGHT_WORKER);
|
|
49
|
+
if (cmd === "check") return (await import("./chunks/check-command-FL5O3AXB.mjs")).runCheck(args);
|
|
50
|
+
if (cmd === "publish") return (await import("./chunks/publish-command-SAPICGGM.mjs")).runPublish(args);
|
|
44
51
|
if (cmd === "release-diff") {
|
|
45
52
|
const from = option(args, "--from")[0];
|
|
46
53
|
const gitFrom = option(args, "--git-from")[0];
|
|
47
54
|
const o = { from, gitFrom, json: flag(args, "--json"), write: flag(args, "--write"), candidates: flag(args, "--candidates"), strict: flag(args, "--strict") };
|
|
48
55
|
const project = resolve(positional(args, "."));
|
|
49
|
-
const { runReleaseDiff } = await import("./chunks/release-diff-
|
|
56
|
+
const { runReleaseDiff } = await import("./chunks/release-diff-Y7X63MT3.mjs");
|
|
50
57
|
process.exitCode = await runReleaseDiff(project, o);
|
|
51
58
|
return;
|
|
52
59
|
}
|
|
@@ -58,7 +65,7 @@ async function main() {
|
|
|
58
65
|
const llms = flag(args, "--llms");
|
|
59
66
|
const project = resolve(positional(args, "."));
|
|
60
67
|
const t0 = performance.now();
|
|
61
|
-
const { dev, readyLine, serverUrl } = await import("./chunks/dev-
|
|
68
|
+
const { dev, readyLine, serverUrl } = await import("./chunks/dev-X3PKN4G3.mjs");
|
|
62
69
|
const { server } = await dev(project, port, { diagrams: !noDiagrams, lazy, search: noSearchDev ? false : void 0, llms, token: process.env.DOGSBAY_DEV_TOKEN || void 0, listening: (s) => console.log(readyLine(s)) });
|
|
63
70
|
console.log(`dev server for ${project} at ${serverUrl(server)} (ready in ${Math.round(performance.now() - t0)} ms); watching for changes`);
|
|
64
71
|
return;
|
|
@@ -67,7 +74,7 @@ async function main() {
|
|
|
67
74
|
const port = Number(option(args, "-p", "--port")[0] ?? 4400);
|
|
68
75
|
const csp = flag(args, "--csp");
|
|
69
76
|
const dir = resolve(positional(args, "out"));
|
|
70
|
-
const { serve } = await import("./chunks/serve-
|
|
77
|
+
const { serve } = await import("./chunks/serve-7DR4WSYA.mjs");
|
|
71
78
|
await serve(dir, port, void 0, { csp });
|
|
72
79
|
console.log(`serving ${dir} at http://127.0.0.1:${port}/${csp ? " with the Worker's Content-Security-Policy" : ""}`);
|
|
73
80
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dogsbay/ssg-cli",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.188",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The dogsbay-ssg command: build, check, preview and publish Dogsbay-MD documentation sites that work offline",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
"highlight-worker.mjs",
|
|
16
16
|
"chunks",
|
|
17
17
|
"THIRD-PARTY-NOTICES.txt",
|
|
18
|
-
"NOTICE"
|
|
18
|
+
"NOTICE",
|
|
19
|
+
"AGENTS.md"
|
|
19
20
|
],
|
|
20
21
|
"dependencies": {
|
|
21
|
-
"@dogsbay/icons": "0.2.0-beta.
|
|
22
|
+
"@dogsbay/icons": "0.2.0-beta.188",
|
|
22
23
|
"@mermanjs/web-render": "0.9.3"
|
|
23
24
|
},
|
|
24
25
|
"publishConfig": {
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
createAuditSession,
|
|
5
|
-
filterRules,
|
|
6
|
-
formatJson,
|
|
7
|
-
formatText,
|
|
8
|
-
getRule,
|
|
9
|
-
registerRule,
|
|
10
|
-
registerSharedRules,
|
|
11
|
-
releaseCollector,
|
|
12
|
-
reportExitCode,
|
|
13
|
-
toReport
|
|
14
|
-
} from "./chunk-XQORVEL6.mjs";
|
|
15
|
-
import {
|
|
16
|
-
cliMemorySettings,
|
|
17
|
-
diagramRenderers,
|
|
18
|
-
iconResolver
|
|
19
|
-
} from "./chunk-OBUK53NJ.mjs";
|
|
20
|
-
import {
|
|
21
|
-
ConfigError,
|
|
22
|
-
build,
|
|
23
|
-
htmlIsText,
|
|
24
|
-
loadYaml,
|
|
25
|
-
parseConfig,
|
|
26
|
-
readBuildFiles,
|
|
27
|
-
siteBase
|
|
28
|
-
} from "./chunk-TRECVC6H.mjs";
|
|
29
|
-
import "./chunk-YQ2K646L.mjs";
|
|
30
|
-
import "./chunk-AOHGXC4D.mjs";
|
|
31
|
-
import {
|
|
32
|
-
DATA_DIRECTIVES,
|
|
33
|
-
frontmatterPolicyFromConfig
|
|
34
|
-
} from "./chunk-YA6TJOAM.mjs";
|
|
35
|
-
import {
|
|
36
|
-
FAILING_CODES,
|
|
37
|
-
UsageError,
|
|
38
|
-
flag,
|
|
39
|
-
option,
|
|
40
|
-
positional
|
|
41
|
-
} from "./chunk-FNP5PNJW.mjs";
|
|
42
|
-
import "./chunk-YVSP26OS.mjs";
|
|
43
|
-
import "./chunk-O3R3MASP.mjs";
|
|
44
|
-
import {
|
|
45
|
-
isStream
|
|
46
|
-
} from "./chunk-JABACD5T.mjs";
|
|
47
|
-
import "./chunk-G6OTOD3B.mjs";
|
|
48
|
-
import "./chunk-STRHO6SY.mjs";
|
|
49
|
-
|
|
50
|
-
// src/node/check-command.ts
|
|
51
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
52
|
-
import { join, resolve } from "node:path";
|
|
53
|
-
|
|
54
|
-
// src/core/check.ts
|
|
55
|
-
var KEPT = /(^|\/)(robots\.txt|sitemap[^/]*\.xml)$/;
|
|
56
|
-
var BUILD_DIAGNOSTICS = /* @__PURE__ */ new Set(["front-matter", "template", "template-tag", "data", "example", "choice", "parse"]);
|
|
57
|
-
var DATA_NODES = new Set(DATA_DIRECTIVES);
|
|
58
|
-
function withoutDataNodes(tree) {
|
|
59
|
-
let changed = false;
|
|
60
|
-
const out = [];
|
|
61
|
-
for (const n of tree) {
|
|
62
|
-
if (DATA_NODES.has(n.type)) {
|
|
63
|
-
changed = true;
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
const children = n.children && withoutDataNodes(n.children);
|
|
67
|
-
if (children !== n.children) changed = true;
|
|
68
|
-
out.push(children === n.children ? n : { ...n, children });
|
|
69
|
-
}
|
|
70
|
-
return changed ? out : tree;
|
|
71
|
-
}
|
|
72
|
-
function refsOf(tree, visit) {
|
|
73
|
-
const inline = (nodes) => {
|
|
74
|
-
if (!Array.isArray(nodes)) return;
|
|
75
|
-
for (const n of nodes) {
|
|
76
|
-
if (n.type === "link" && typeof n.href === "string") visit(`l ${n.href}`, { type: "paragraph", inline: [{ type: "link", href: n.href, children: [] }] });
|
|
77
|
-
else if (n.type === "image" && typeof n.src === "string") visit(`i ${n.src}`, { type: "paragraph", inline: [{ type: "image", src: n.src, alt: "" }] });
|
|
78
|
-
inline(n.children);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
const blocks = (nodes) => {
|
|
82
|
-
for (const n of nodes ?? []) {
|
|
83
|
-
const o = n;
|
|
84
|
-
inline(o.inline);
|
|
85
|
-
if (typeof o.html === "string" && !htmlIsText(n)) visit(`h ${o.html}`, { type: "html", html: o.html });
|
|
86
|
-
for (const k of ["href", "src"]) {
|
|
87
|
-
const v = n.props?.[k];
|
|
88
|
-
if (typeof v === "string") visit(`${k} ${v}`, { type: "div", props: { [k]: v }, children: [] });
|
|
89
|
-
}
|
|
90
|
-
blocks(n.children);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
blocks(tree);
|
|
94
|
-
}
|
|
95
|
-
function withAgentsRefs(tree, agents) {
|
|
96
|
-
if (!agents) return tree;
|
|
97
|
-
const seen = /* @__PURE__ */ new Set();
|
|
98
|
-
refsOf(tree, (k) => seen.add(k));
|
|
99
|
-
const extra = [];
|
|
100
|
-
refsOf(agents, (k, n) => {
|
|
101
|
-
if (seen.has(k)) return;
|
|
102
|
-
seen.add(k);
|
|
103
|
-
extra.push(n);
|
|
104
|
-
});
|
|
105
|
-
return extra.length ? [...tree, ...extra] : tree;
|
|
106
|
-
}
|
|
107
|
-
var markdownSyntax = {
|
|
108
|
-
id: "markdown/syntax",
|
|
109
|
-
category: "markdown",
|
|
110
|
-
stage: "source-corpus",
|
|
111
|
-
severity: "warning",
|
|
112
|
-
description: "Dogsbay Markdown the parser recovers from silently: an unclosed or stray `:::`, an unknown `:::name` or `:name[]`, a prop a directive does not take, an unreadable `{\u2026}` attribute block.",
|
|
113
|
-
run: () => []
|
|
114
|
-
};
|
|
115
|
-
async function check(input) {
|
|
116
|
-
const { configText, filter, releaseFrom, ...rest } = input;
|
|
117
|
-
const parsed = input.config ?? parseConfig(configText);
|
|
118
|
-
const raw = parseRaw(configText);
|
|
119
|
-
const site = raw.site ?? {};
|
|
120
|
-
const policy = frontmatterPolicyFromConfig(raw, parsed.sources.map((s) => s.path === "." ? "" : s.path.replace(/\/+$/, "")));
|
|
121
|
-
if (policy.invalid) throw new ConfigError(policy.invalid);
|
|
122
|
-
registerSharedRules();
|
|
123
|
-
if (!getRule(markdownSyntax.id)) registerRule(markdownSyntax);
|
|
124
|
-
const rules = filterRules(filter ?? {});
|
|
125
|
-
const releaseRule = rules.find((r) => r.id === "structure/release-moves");
|
|
126
|
-
const corpusRules = rules.filter((r) => r.stage === "source-corpus" && r !== releaseRule && r.id !== markdownSyntax.id);
|
|
127
|
-
const otherRules = rules.filter((r) => r.stage !== "source-corpus");
|
|
128
|
-
const wantDist = rules.some((r) => r.stage === "dist");
|
|
129
|
-
const cfg = { ...parsed, search: false, llmsTxt: false };
|
|
130
|
-
const auditConfig = {
|
|
131
|
-
siteName: cfg.name,
|
|
132
|
-
// The sitemap lists URLs under url + basePath; the sitemap rules strip siteUrl's path.
|
|
133
|
-
siteUrl: siteBase(cfg) ?? cfg.url,
|
|
134
|
-
brandKeywords: Array.isArray(site.brandKeywords) ? site.brandKeywords.filter((k) => typeof k === "string") : void 0
|
|
135
|
-
};
|
|
136
|
-
const session = createAuditSession({ rules: otherRules, nav: [], config: auditConfig, frontmatterPolicy: policy });
|
|
137
|
-
const release = releaseRule ? releaseCollector(cfg, releaseFrom) : void 0;
|
|
138
|
-
const units = /* @__PURE__ */ new Map();
|
|
139
|
-
const unitOf = (prefix) => {
|
|
140
|
-
let u = units.get(prefix);
|
|
141
|
-
if (!u) {
|
|
142
|
-
const assets = /* @__PURE__ */ new Set();
|
|
143
|
-
u = { assets, session: createAuditSession({ rules: corpusRules, nav: [], config: auditConfig, basePath: cfg.basePath ? `/${cfg.basePath}` : "", knownAssets: assets }) };
|
|
144
|
-
units.set(prefix, u);
|
|
145
|
-
}
|
|
146
|
-
return u;
|
|
147
|
-
};
|
|
148
|
-
const named = (slug) => slug || "index";
|
|
149
|
-
const kept = /* @__PURE__ */ new Map();
|
|
150
|
-
const decoder = new TextDecoder();
|
|
151
|
-
const syntax = [];
|
|
152
|
-
const hooks = rules.some((r) => r.id === markdownSyntax.id) ? {
|
|
153
|
-
diagnostics: (file, list) => {
|
|
154
|
-
for (const d of list) if (!BUILD_DIAGNOSTICS.has(d.code)) syntax.push({ ruleId: markdownSyntax.id, severity: markdownSyntax.severity, file, ...d.line ? { line: d.line } : {}, message: d.message, context: d.code });
|
|
155
|
-
}
|
|
156
|
-
} : {};
|
|
157
|
-
const result = await build({
|
|
158
|
-
...rest,
|
|
159
|
-
config: cfg,
|
|
160
|
-
onRedirects: (r) => release?.onRedirects(r),
|
|
161
|
-
onPageBuilt: (p) => {
|
|
162
|
-
release?.onPage(p);
|
|
163
|
-
const local = p.unit && p.slug.startsWith(p.unit) ? p.slug.slice(p.unit.length).replace(/^\//, "") : p.slug;
|
|
164
|
-
const page = { slug: p.slug, title: p.title, tree: withAgentsRefs(withoutDataNodes(p.tree), p.agentsTree && withoutDataNodes(p.agentsTree)), headings: [], frontmatter: p.frontmatter };
|
|
165
|
-
session.page({ ...page, slug: [p.unit, named(local)].filter(Boolean).join("/") }, { path: p.source, text: p.text });
|
|
166
|
-
if (corpusRules.length) unitOf(p.unit).session.page({ ...page, slug: named(local), sourcePath: p.contentPath });
|
|
167
|
-
},
|
|
168
|
-
onUnitAssets: (prefix, assets) => {
|
|
169
|
-
if (!corpusRules.length) return;
|
|
170
|
-
const u = unitOf(prefix);
|
|
171
|
-
for (const a of assets) u.assets.add(`/${a}`);
|
|
172
|
-
},
|
|
173
|
-
sink: async (path, content) => {
|
|
174
|
-
if (!wantDist || isStream(content)) return;
|
|
175
|
-
const html = path.endsWith(".html");
|
|
176
|
-
if (!html && !KEPT.test(path)) return;
|
|
177
|
-
const text = typeof content === "string" ? content : content instanceof Uint8Array ? decoder.decode(content) : decoder.decode(await content.read());
|
|
178
|
-
if (html) session.dist(path, text);
|
|
179
|
-
else kept.set(path, text);
|
|
180
|
-
}
|
|
181
|
-
}, hooks);
|
|
182
|
-
const issues = session.finish((p) => kept.get(p.replace(/^\/+/, ""))).issues;
|
|
183
|
-
issues.push(...syntax);
|
|
184
|
-
for (const p of result.problems) {
|
|
185
|
-
if (p.code === "data") issues.push({ ruleId: "data/files", severity: "error", file: p.file ?? "dogsbay.config.yml", ...p.line ? { line: p.line } : {}, message: p.message });
|
|
186
|
-
if (p.code === "example") issues.push({ ruleId: "examples/files", severity: "error", file: p.file ?? "dogsbay.config.yml", ...p.line ? { line: p.line } : {}, message: p.message });
|
|
187
|
-
if (p.code === "choice") issues.push({ ruleId: "choices/valid", severity: "error", file: p.file ?? "dogsbay.config.yml", ...p.line ? { line: p.line } : {}, message: p.message });
|
|
188
|
-
if (p.code === "menu") issues.push({ ruleId: "structure/menu-valid", severity: "warning", file: p.file ?? "dogsbay.config.yml", ...p.line ? { line: p.line } : {}, message: p.message });
|
|
189
|
-
}
|
|
190
|
-
if (releaseRule && release) issues.push(...releaseRule.run({ pages: [], nav: [], config: auditConfig, release: release.finish() }));
|
|
191
|
-
for (const [prefix, u] of units) {
|
|
192
|
-
for (const i of u.session.finish().issues) issues.push(prefix ? { ...i, file: `${prefix}/${i.file}` } : i);
|
|
193
|
-
}
|
|
194
|
-
return { report: toReport(issues, rules.length), build: result };
|
|
195
|
-
}
|
|
196
|
-
function parseRaw(text) {
|
|
197
|
-
if (!text) return {};
|
|
198
|
-
try {
|
|
199
|
-
const v = loadYaml(text);
|
|
200
|
-
return v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
201
|
-
} catch {
|
|
202
|
-
return {};
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// src/node/check-command.ts
|
|
207
|
-
async function runCheck(args) {
|
|
208
|
-
const json = flag(args, "--json");
|
|
209
|
-
const strict = flag(args, "--strict");
|
|
210
|
-
const sourceOnly = flag(args, "--source");
|
|
211
|
-
const distOnly = flag(args, "--dist");
|
|
212
|
-
const noDiagrams = flag(args, "--no-diagrams");
|
|
213
|
-
const quiet = flag(args, "--quiet", "-q");
|
|
214
|
-
const categories = option(args, "--category");
|
|
215
|
-
const rules = option(args, "--rule");
|
|
216
|
-
const skip = option(args, "--skip");
|
|
217
|
-
const includeDraftsCheck = flag(args, "--include-drafts");
|
|
218
|
-
const untrusted = flag(args, "--untrusted");
|
|
219
|
-
const memory = cliMemorySettings(flag(args, "--low-memory"));
|
|
220
|
-
if (sourceOnly && distOnly) throw new UsageError("--source and --dist cannot be used together");
|
|
221
|
-
const project = resolve(positional(args, "."));
|
|
222
|
-
const cfgPath = ["dogsbay.config.yml", "dogsbay.config.yaml"].map((f) => join(project, f)).find(existsSync);
|
|
223
|
-
const cfgText = cfgPath ? readFileSync(cfgPath, "utf8") : void 0;
|
|
224
|
-
const cfg = parseConfig(cfgText);
|
|
225
|
-
if (!cfgPath && !existsSync(join(project, "content"))) cfg.sources = [{ path: "." }];
|
|
226
|
-
const { files } = await readBuildFiles(project, cfg, [join(project, "out")], untrusted);
|
|
227
|
-
const stages = sourceOnly ? ["source", "source-corpus"] : distOnly ? ["dist"] : [];
|
|
228
|
-
const { report, build: result } = await check({
|
|
229
|
-
...memory,
|
|
230
|
-
files,
|
|
231
|
-
config: cfg,
|
|
232
|
-
configText: cfgText,
|
|
233
|
-
includeDrafts: includeDraftsCheck,
|
|
234
|
-
untrusted,
|
|
235
|
-
diagrams: noDiagrams ? void 0 : diagramRenderers(),
|
|
236
|
-
icons: await iconResolver(),
|
|
237
|
-
filter: {
|
|
238
|
-
categories: categories.length ? categories : void 0,
|
|
239
|
-
stages: stages.length ? stages : void 0,
|
|
240
|
-
rules: rules.length ? rules : void 0,
|
|
241
|
-
skip: skip.length ? skip : void 0
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
if (report.summary.rulesRun === 0) {
|
|
245
|
-
console.error("no rules matched --category/--rule/--skip; nothing was checked");
|
|
246
|
-
process.exitCode = 1;
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
const warnings = result.warnings.filter((_, i) => !FAILING_CODES.has(result.problems[i].code));
|
|
250
|
-
if (!quiet && !json) for (const w of warnings.slice(0, 20)) console.warn(`warn ${w}`);
|
|
251
|
-
process.stdout.write(json ? formatJson(report) : formatText(report));
|
|
252
|
-
process.exitCode = reportExitCode(report, strict);
|
|
253
|
-
}
|
|
254
|
-
export {
|
|
255
|
-
runCheck
|
|
256
|
-
};
|