@dogsbay/ssg-cli 0.2.0-beta.183 → 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-QLNZ5BNK.mjs → build-command-NJATVOUY.mjs} +37 -26
- 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-CYJ6GFVM.mjs +77 -0
- package/chunks/{chunk-KE6N5RFA.mjs → chunk-FFIXBXHD.mjs} +63 -234
- package/chunks/chunk-GFG5I7WI.mjs +807 -0
- package/chunks/chunk-GZ3E45TE.mjs +2290 -0
- package/chunks/chunk-IAAKV7V2.mjs +37 -0
- package/chunks/{chunk-IERF2DNL.mjs → chunk-VJ6AESSJ.mjs} +8072 -8555
- package/chunks/chunk-X3UPCLX5.mjs +503 -0
- package/chunks/{chunk-QDXUP47M.mjs → chunk-ZDH4JRVX.mjs} +1203 -4035
- package/chunks/{chunk-LNWQN7K7.mjs → chunk-ZRGJHNES.mjs} +7 -1
- 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-HXLVZ7MF.mjs → dev-X3PKN4G3.mjs} +77 -25
- package/chunks/{menu-N2AZSZKS.mjs → menu-J3CLVADF.mjs} +9 -5
- package/chunks/{publish-command-UFHG6PJN.mjs → publish-command-SAPICGGM.mjs} +15 -7
- package/chunks/{release-diff-LFDQIFEF.mjs → release-diff-Y7X63MT3.mjs} +13 -6
- package/chunks/{serve-WGWRM7JQ.mjs → serve-7DR4WSYA.mjs} +3 -1
- package/cli.mjs +17 -10
- package/package.json +4 -3
- package/chunks/check-command-5U7VSMDO.mjs +0 -218
- package/chunks/chunk-KFYMG4VB.mjs +0 -45
|
@@ -30,7 +30,12 @@ function positional(args, fallback) {
|
|
|
30
30
|
if (args.length > 1) throw new UsageError(`unexpected arguments: ${args.slice(1).join(" ")}`);
|
|
31
31
|
return args[0] ?? fallback;
|
|
32
32
|
}
|
|
33
|
-
var FAILING_CODES = /* @__PURE__ */ new Set(["data", "example"]);
|
|
33
|
+
var FAILING_CODES = /* @__PURE__ */ new Set(["data", "example", "choice"]);
|
|
34
|
+
function warningsToShow(warnings, codes) {
|
|
35
|
+
const kept = warnings.map((w, i) => [w, codes[i]]).filter(([, code]) => !FAILING_CODES.has(code));
|
|
36
|
+
const site = kept.filter(([, c]) => c === "compare");
|
|
37
|
+
return { warnings: [...site, ...kept.filter(([, c]) => c !== "compare")].map(([w]) => w), siteWide: site.length };
|
|
38
|
+
}
|
|
34
39
|
function dataProblemLines(problems) {
|
|
35
40
|
return problems.filter((p) => FAILING_CODES.has(p.code)).map((p) => p.file ? `${p.file}${p.line ? `:${p.line}` : ""}: ${p.message}` : p.text);
|
|
36
41
|
}
|
|
@@ -43,5 +48,6 @@ export {
|
|
|
43
48
|
wantsHelp,
|
|
44
49
|
positional,
|
|
45
50
|
FAILING_CODES,
|
|
51
|
+
warningsToShow,
|
|
46
52
|
dataProblemLines
|
|
47
53
|
};
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
diffTrees
|
|
5
|
+
} from "./chunk-GFG5I7WI.mjs";
|
|
6
|
+
import {
|
|
7
|
+
buildUnits,
|
|
8
|
+
changeMarks,
|
|
9
|
+
compareRelease,
|
|
10
|
+
compileIgnoreRules,
|
|
11
|
+
createSummary,
|
|
12
|
+
declaresCompare,
|
|
13
|
+
matchPages,
|
|
14
|
+
pairVersions,
|
|
15
|
+
releasePage,
|
|
16
|
+
sameProduct,
|
|
17
|
+
versionsOf
|
|
18
|
+
} from "./chunk-5NQOUB5I.mjs";
|
|
19
|
+
import "./chunk-GZ3E45TE.mjs";
|
|
20
|
+
import "./chunk-VJ6AESSJ.mjs";
|
|
21
|
+
import "./chunk-YVSP26OS.mjs";
|
|
22
|
+
import "./chunk-O3R3MASP.mjs";
|
|
23
|
+
import {
|
|
24
|
+
detach
|
|
25
|
+
} from "./chunk-5A2QPRCV.mjs";
|
|
26
|
+
import "./chunk-G6OTOD3B.mjs";
|
|
27
|
+
import "./chunk-STRHO6SY.mjs";
|
|
28
|
+
|
|
29
|
+
// src/core/compare.ts
|
|
30
|
+
function compareCollector(cfg, o = {}) {
|
|
31
|
+
if (!declaresCompare(cfg)) return void 0;
|
|
32
|
+
const warn = o.warn ?? (() => {
|
|
33
|
+
});
|
|
34
|
+
const units = buildUnits(cfg);
|
|
35
|
+
const built = new Set((o.built ?? units).map((u) => u.prefix));
|
|
36
|
+
const sides = /* @__PURE__ */ new Map();
|
|
37
|
+
const side = (unit) => {
|
|
38
|
+
let s = sides.get(unit.prefix);
|
|
39
|
+
if (!s) sides.set(unit.prefix, s = { unit, pages: /* @__PURE__ */ new Map(), release: /* @__PURE__ */ new Map(), done: false, uses: 0 });
|
|
40
|
+
s.uses++;
|
|
41
|
+
return s;
|
|
42
|
+
};
|
|
43
|
+
const pairs = [];
|
|
44
|
+
for (const to of units) {
|
|
45
|
+
const { versions, compare } = versionsOf(cfg, to.product);
|
|
46
|
+
if (!compare) continue;
|
|
47
|
+
const { pairs: declared, errors } = pairVersions(versions, compare.pairs);
|
|
48
|
+
if (errors.length) continue;
|
|
49
|
+
for (const p of declared) {
|
|
50
|
+
if (typeof p.old !== "string" || typeof p.new !== "string" || p.new !== to.version) continue;
|
|
51
|
+
const from = units.find((u) => u.version === p.old && u.locale === to.locale && sameProduct(u, to));
|
|
52
|
+
if (!from) continue;
|
|
53
|
+
const name = `${p.old}..${p.new}`;
|
|
54
|
+
if (!built.has(from.prefix) || !built.has(to.prefix)) {
|
|
55
|
+
if (built.has(to.prefix)) warn(`[compare] ${to.prefix}: ${name} is not written: this build does not build ${from.prefix}`);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const removed = versions.find((v) => v.id === to.version)?.removed;
|
|
59
|
+
const limited = /* @__PURE__ */ new Set();
|
|
60
|
+
const rules = compileIgnoreRules(compare.ignore, { old: p.old, new: p.new }, {
|
|
61
|
+
onLimit: (rule, why) => {
|
|
62
|
+
if (limited.has(rule)) return;
|
|
63
|
+
limited.add(rule);
|
|
64
|
+
warn(`[compare] ${name}: the ignore rule "${rule}" ${why}; that value is compared as written`);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const info = { name, old: p.old, new: p.new, ...p.label ? { label: p.label } : {}, ...to.locale ? { locale: to.locale } : {}, oldPrefix: from.prefix, newPrefix: to.prefix };
|
|
68
|
+
pairs.push({ info, old: side(from), new: side(to), rules, ...removed ? { removed } : {}, diffed: /* @__PURE__ */ new Map() });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (!pairs.length) return void 0;
|
|
72
|
+
let zipped = 0;
|
|
73
|
+
let overBudget = false;
|
|
74
|
+
const budget = o.zipBytes ?? 24e6;
|
|
75
|
+
const budgetText = budget >= 1e6 ? `${Math.round(budget / 1e6)} MB` : `${Math.round(budget / 1e3)} KB`;
|
|
76
|
+
const keep = (bytes) => bytes.then((z) => {
|
|
77
|
+
zipped += z.byteLength;
|
|
78
|
+
if (zipped > budget && !overBudget) {
|
|
79
|
+
overBudget = true;
|
|
80
|
+
warn(`[compare] the pages kept for comparing versions passed ${budgetText} compressed: the comparisons not yet written are skipped`);
|
|
81
|
+
}
|
|
82
|
+
return z;
|
|
83
|
+
});
|
|
84
|
+
const drop = (s) => {
|
|
85
|
+
if (--s.uses > 0) return;
|
|
86
|
+
for (const z of s.pages.values()) void z.then((b) => zipped -= b.byteLength);
|
|
87
|
+
s.pages.clear();
|
|
88
|
+
zipped -= s.release.size * RELEASE_ROW_BYTES;
|
|
89
|
+
s.release.clear();
|
|
90
|
+
};
|
|
91
|
+
const local = (unit, slug) => (unit ? slug === unit ? "" : slug.slice(unit.length + 1) : slug) || "index";
|
|
92
|
+
const byInfo = new Map(pairs.map((p) => [p.info, p]));
|
|
93
|
+
return {
|
|
94
|
+
pairs: pairs.map((p) => p.info),
|
|
95
|
+
order(list) {
|
|
96
|
+
const out = [...list];
|
|
97
|
+
for (let round = 0; round < out.length; round++) {
|
|
98
|
+
let moved = false;
|
|
99
|
+
for (const p of pairs) {
|
|
100
|
+
const i = out.findIndex((u) => u.prefix === p.new.unit.prefix);
|
|
101
|
+
const j = out.findIndex((u) => u.prefix === p.old.unit.prefix);
|
|
102
|
+
if (i < 0 || j < 0 || j < i) continue;
|
|
103
|
+
out.splice(i, 0, ...out.splice(j, 1));
|
|
104
|
+
moved = true;
|
|
105
|
+
}
|
|
106
|
+
if (!moved) break;
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
},
|
|
110
|
+
pairsOf(prefix) {
|
|
111
|
+
return pairs.filter((p) => p.new.unit.prefix === prefix).map((p) => p.info);
|
|
112
|
+
},
|
|
113
|
+
nav(prefix, nav) {
|
|
114
|
+
const s = sides.get(prefix);
|
|
115
|
+
if (s) s.nav = changeNav(nav);
|
|
116
|
+
},
|
|
117
|
+
async page(page) {
|
|
118
|
+
const s = sides.get(page.unit);
|
|
119
|
+
if (!s || page.frontmatter?.status === "draft" || overBudget) return [];
|
|
120
|
+
const path = local(page.unit, page.slug);
|
|
121
|
+
zipped += RELEASE_ROW_BYTES;
|
|
122
|
+
const id = page.frontmatter?.id;
|
|
123
|
+
const fmTitle = page.frontmatter?.title;
|
|
124
|
+
s.release.set(detach(path), { title: detach(typeof fmTitle === "string" && fmTitle.trim() ? fmTitle : page.title), ...typeof id === "string" ? { id: detach(id) } : {}, source: detach(page.source), index: /(^|\/)index\.(md|markdown)$/i.test(page.source) });
|
|
125
|
+
const kept = keep(gzip(JSON.stringify(page.tree)));
|
|
126
|
+
s.pages.set(path, kept);
|
|
127
|
+
await kept;
|
|
128
|
+
const changed = [];
|
|
129
|
+
for (const p of pairs) {
|
|
130
|
+
if (overBudget || p.new !== s || !p.old.done || !p.old.pages.has(path)) continue;
|
|
131
|
+
const diff = diffTrees(await tree(p.old, path), page.tree, p.rules.compareValue ? { compareValue: p.rules.compareValue } : void 0);
|
|
132
|
+
const stats = { unchanged: diff.unchanged, ...diff.stats };
|
|
133
|
+
if (diff.unchanged || overBudget) {
|
|
134
|
+
p.diffed.set(path, { stats });
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
p.diffed.set(path, { stats, zip: keep(gzip(JSON.stringify(diff.tree))) });
|
|
138
|
+
changed.push({ pair: p.info, path });
|
|
139
|
+
}
|
|
140
|
+
return changed;
|
|
141
|
+
},
|
|
142
|
+
unitDone(prefix) {
|
|
143
|
+
const s = sides.get(prefix);
|
|
144
|
+
if (s) s.done = true;
|
|
145
|
+
},
|
|
146
|
+
async run(info, onPage) {
|
|
147
|
+
const p = byInfo.get(info);
|
|
148
|
+
try {
|
|
149
|
+
if (!p.old.done) return { skipped: `${p.old.unit.prefix || "/"} was not built before ${p.new.unit.prefix || "/"}` };
|
|
150
|
+
if (overBudget) {
|
|
151
|
+
for (const [path, d] of p.diffed) if (d.zip) await onPage?.({ path, row: { status: "both", old: path, new: path, stats: d.stats }, tree: JSON.parse(await gunzip(await d.zip)) });
|
|
152
|
+
return { skipped: `the pages kept for comparing versions passed ${budgetText} compressed` };
|
|
153
|
+
}
|
|
154
|
+
await Promise.all([...p.old.pages.values(), ...p.new.pages.values()]);
|
|
155
|
+
const release = {
|
|
156
|
+
from: info.old,
|
|
157
|
+
to: info.new,
|
|
158
|
+
fromPrefix: info.oldPrefix,
|
|
159
|
+
toPrefix: info.newPrefix,
|
|
160
|
+
entries: compareRelease({ from: await releaseRows(p.old, p.new), to: await releaseRows(p.new, p.old), removed: p.removed })
|
|
161
|
+
};
|
|
162
|
+
const summary = createSummary();
|
|
163
|
+
const changes = /* @__PURE__ */ new Map();
|
|
164
|
+
const rows = [];
|
|
165
|
+
const pending = [];
|
|
166
|
+
for (const match of matchPages(p.old.pages.keys(), p.new.pages.keys(), { release, removed: p.removed })) {
|
|
167
|
+
let stats;
|
|
168
|
+
let zip;
|
|
169
|
+
const known = match.status === "both" ? p.diffed.get(match.new) : void 0;
|
|
170
|
+
if (known) {
|
|
171
|
+
stats = known.stats;
|
|
172
|
+
zip = known.zip;
|
|
173
|
+
} else if ((match.status === "both" || match.status === "moved") && match.old !== void 0 && match.new !== void 0) {
|
|
174
|
+
const [a, b] = await Promise.all([tree(p.old, match.old), tree(p.new, match.new)]);
|
|
175
|
+
const diff = diffTrees(a, b, p.rules.compareValue ? { compareValue: p.rules.compareValue } : void 0);
|
|
176
|
+
stats = { unchanged: diff.unchanged, ...diff.stats };
|
|
177
|
+
if (!diff.unchanged && !overBudget) {
|
|
178
|
+
zip = keep(gzip(JSON.stringify(diff.tree)));
|
|
179
|
+
p.diffed.set(`\0moved\0${match.new}`, { stats, zip });
|
|
180
|
+
await zip;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const row = { ...match, ...stats ? { stats } : {} };
|
|
184
|
+
if (zip) pending.push({ row, zip });
|
|
185
|
+
const kind = summary.add(row);
|
|
186
|
+
if (kind) changes.set(kind === "removed" ? match.old : match.new, kind);
|
|
187
|
+
rows.push(row);
|
|
188
|
+
}
|
|
189
|
+
const moved = new Map(rows.filter((r) => r.status === "moved").map((r) => [r.old, r.new]));
|
|
190
|
+
const outcome = { rows, summary: summary.result(), nav: changeMarks(p.new.nav ?? [], p.old.nav ?? [], changes, { moved }), diffed: new Set(pending.map((x) => x.row.new)) };
|
|
191
|
+
for (const { row, zip } of pending) await onPage?.({ path: row.new, row, tree: JSON.parse(await gunzip(await zip)) }, outcome);
|
|
192
|
+
return { outcome };
|
|
193
|
+
} finally {
|
|
194
|
+
for (const d of p.diffed.values()) if (d.zip) void d.zip.then((b) => zipped -= b.byteLength);
|
|
195
|
+
p.diffed.clear();
|
|
196
|
+
drop(p.old);
|
|
197
|
+
drop(p.new);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
var RELEASE_ROW_BYTES = 256;
|
|
203
|
+
async function releaseRows(s, other) {
|
|
204
|
+
const rows = [];
|
|
205
|
+
for (const [path, m] of s.release) {
|
|
206
|
+
if (other.release.has(path)) {
|
|
207
|
+
rows.push({ path, title: m.title, signature: [], shingles: 0 });
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
rows.push(releasePage({ slug: path, title: m.title, headings: [], tree: await tree(s, path), frontmatter: m.id !== void 0 ? { id: m.id } : {} }, path, { source: m.source, index: m.index }));
|
|
211
|
+
}
|
|
212
|
+
return rows;
|
|
213
|
+
}
|
|
214
|
+
async function tree(s, path) {
|
|
215
|
+
const z = s.pages.get(path);
|
|
216
|
+
if (!z) return [];
|
|
217
|
+
return JSON.parse(await gunzip(await z));
|
|
218
|
+
}
|
|
219
|
+
function changeNav(nav) {
|
|
220
|
+
return nav.map((n) => ({
|
|
221
|
+
label: n.label,
|
|
222
|
+
...n.slug !== void 0 ? { href: `/${n.slug}` } : n.href ? { href: n.href } : {},
|
|
223
|
+
...n.children?.length ? { children: changeNav(n.children) } : {}
|
|
224
|
+
}));
|
|
225
|
+
}
|
|
226
|
+
function navPath(href) {
|
|
227
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("//") || !href.startsWith("/")) return void 0;
|
|
228
|
+
return href.replace(/[?#].*$/, "").replace(/^\/+|\/+$/g, "") || "index";
|
|
229
|
+
}
|
|
230
|
+
async function gzip(text) {
|
|
231
|
+
return new Uint8Array(await new Response(new Response(text).body.pipeThrough(new CompressionStream("gzip"))).arrayBuffer());
|
|
232
|
+
}
|
|
233
|
+
async function gunzip(bytes) {
|
|
234
|
+
return new Response(new Response(bytes).body.pipeThrough(new DecompressionStream("gzip"))).text();
|
|
235
|
+
}
|
|
236
|
+
export {
|
|
237
|
+
compareCollector,
|
|
238
|
+
navPath
|
|
239
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
readProject
|
|
5
|
+
} from "./chunk-X3UPCLX5.mjs";
|
|
6
|
+
import {
|
|
7
|
+
parseConfig
|
|
8
|
+
} from "./chunk-5NQOUB5I.mjs";
|
|
9
|
+
import "./chunk-GZ3E45TE.mjs";
|
|
10
|
+
import "./chunk-VJ6AESSJ.mjs";
|
|
11
|
+
import {
|
|
12
|
+
UsageError,
|
|
13
|
+
flag,
|
|
14
|
+
option
|
|
15
|
+
} from "./chunk-ZRGJHNES.mjs";
|
|
16
|
+
import "./chunk-YVSP26OS.mjs";
|
|
17
|
+
import "./chunk-O3R3MASP.mjs";
|
|
18
|
+
import "./chunk-5A2QPRCV.mjs";
|
|
19
|
+
import "./chunk-G6OTOD3B.mjs";
|
|
20
|
+
import "./chunk-STRHO6SY.mjs";
|
|
21
|
+
|
|
22
|
+
// src/node/compare-command.ts
|
|
23
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
24
|
+
import { basename, join, relative, resolve, isAbsolute } from "node:path";
|
|
25
|
+
import { posix } from "node:path";
|
|
26
|
+
var DEFAULT_TAGLINE = "Documentation";
|
|
27
|
+
var DOWNLOAD_FILES = ["README.md", "about.json", "import-report.json"];
|
|
28
|
+
function readSide(folder, key, files, exclude = []) {
|
|
29
|
+
if (!existsSync(folder) || !statSync(folder).isDirectory()) throw new UsageError(`${folder} is not a folder`);
|
|
30
|
+
const cfgFile = ["dogsbay.config.yml", "dogsbay.config.yaml"].map((f) => join(folder, f)).find(existsSync);
|
|
31
|
+
const cfg = cfgFile ? parseConfig(readFileSync(cfgFile, "utf8")) : void 0;
|
|
32
|
+
const sources = cfg ? cfg.sources : [{ path: existsSync(join(folder, "content")) ? "content" : "." }];
|
|
33
|
+
if (sources.length !== 1) throw new UsageError(`${folder}: compare reads a project with one content folder; this one has ${sources.length}`);
|
|
34
|
+
const src = sources[0];
|
|
35
|
+
const root = posix.normalize(src.path.replace(/\\/g, "/")).replace(/^\.\/|\/+$/g, "").replace(/^\.$/, "");
|
|
36
|
+
const navDir = src.nav ? posix.dirname(src.nav) : void 0;
|
|
37
|
+
const data = typeof src.data === "string" ? src.data : cfg?.dataDir ?? "data";
|
|
38
|
+
const hasData = existsSync(join(folder, data));
|
|
39
|
+
const read = readProject(folder, [root, ...navDir && navDir !== "." ? [navDir] : src.nav ? [src.nav] : [], ...hasData ? [data] : []], exclude);
|
|
40
|
+
const about = readAbout(folder, root);
|
|
41
|
+
const wrapper = new Set(about?.format === "dogsbay-book" ? DOWNLOAD_FILES.map((f) => root ? `${root}/${f}` : f) : []);
|
|
42
|
+
for (const [p, c] of read) if (!wrapper.has(p)) files.set(`${key}/${p}`, c);
|
|
43
|
+
const { version: _v, locale: _l, name: _n, mount: _m, data: _d, attributes: own, ...rest } = src;
|
|
44
|
+
const attributes = { ...cfg?.attributes ?? {}, ...own ?? {} };
|
|
45
|
+
const source = {
|
|
46
|
+
...rest,
|
|
47
|
+
path: root ? `${key}/${root}` : key,
|
|
48
|
+
...src.nav ? { nav: `${key}/${src.nav}` } : {},
|
|
49
|
+
...hasData ? { data: `${key}/${data}` } : {},
|
|
50
|
+
...Object.keys(attributes).length ? { attributes } : {}
|
|
51
|
+
};
|
|
52
|
+
const version = typeof about?.book?.version === "string" && about.book.version.trim() ? about.book.version.trim() : void 0;
|
|
53
|
+
const tagline = cfg && cfg.tagline !== DEFAULT_TAGLINE ? cfg.tagline : void 0;
|
|
54
|
+
const title = typeof about?.book?.title === "string" ? about.book.title : void 0;
|
|
55
|
+
return {
|
|
56
|
+
label: version ?? tagline ?? basename(resolve(folder)),
|
|
57
|
+
source,
|
|
58
|
+
...cfg && cfg.name !== "Documentation" ? { name: cfg.name } : title ? { name: title } : {},
|
|
59
|
+
...cfg?.excludeFromRoutes.length ? { excludeFromRoutes: cfg.excludeFromRoutes } : {},
|
|
60
|
+
...cfg?.routablesFrom === "nav" ? { routablesFrom: "nav" } : {}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function readAbout(folder, root) {
|
|
64
|
+
for (const dir of [folder, join(folder, root)]) {
|
|
65
|
+
try {
|
|
66
|
+
return JSON.parse(readFileSync(join(dir, "about.json"), "utf8"));
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return void 0;
|
|
71
|
+
}
|
|
72
|
+
function versionId(label) {
|
|
73
|
+
return label.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/\.{2,}/g, "-").replace(/^[-._]+|[-.]+$/g, "") || "version";
|
|
74
|
+
}
|
|
75
|
+
function ignoreRule(arg) {
|
|
76
|
+
const m = /^(links|text|code|all):(.+)$/s.exec(arg);
|
|
77
|
+
return m ? { in: m[1], pattern: m[2] } : { in: "all", pattern: arg };
|
|
78
|
+
}
|
|
79
|
+
function compareConfig(older, newer, ignore) {
|
|
80
|
+
const oldId = versionId(older.label);
|
|
81
|
+
const newId = versionId(newer.label);
|
|
82
|
+
if (oldId === newId) throw new UsageError(`the two folders' labels ("${older.label}", "${newer.label}") give the same version, "${newId}": name them with --labels <old>,<new>`);
|
|
83
|
+
const warnings = [];
|
|
84
|
+
const excludeFromRoutes = [.../* @__PURE__ */ new Set([...older.excludeFromRoutes ?? [], ...newer.excludeFromRoutes ?? []])];
|
|
85
|
+
const fromNav = [older, newer].map((s) => s.routablesFrom === "nav");
|
|
86
|
+
const differ = [older, newer].map((s) => new Set(s.excludeFromRoutes ?? [])).map((own, i, both) => [...both[1 - i]].filter((d) => !own.has(d)));
|
|
87
|
+
if (differ.some((d) => d.length)) warnings.push(`excludeFromRoutes differs between the folders, so both leave out ${[...differ[1], ...differ[0]].join(", ")}`);
|
|
88
|
+
if (fromNav[0] !== fromNav[1]) warnings.push(`only the ${fromNav[0] ? "older" : "newer"} folder's config says routablesFrom: nav, so every page of both is built and compared`);
|
|
89
|
+
const config = {
|
|
90
|
+
schemaVersion: 1,
|
|
91
|
+
site: { name: newer.name ?? older.name ?? "Comparison" },
|
|
92
|
+
content: {
|
|
93
|
+
defaultVersion: newId,
|
|
94
|
+
versions: [
|
|
95
|
+
{ id: newId, ...newId !== newer.label ? { label: newer.label } : {} },
|
|
96
|
+
{ id: oldId, ...oldId !== older.label ? { label: older.label } : {} }
|
|
97
|
+
],
|
|
98
|
+
sources: [
|
|
99
|
+
{ ...newer.source, version: newId },
|
|
100
|
+
{ ...older.source, version: oldId }
|
|
101
|
+
],
|
|
102
|
+
compare: { pairs: "previous", ...ignore.length ? { ignore: ignore.map(ignoreRule) } : {} },
|
|
103
|
+
...excludeFromRoutes.length ? { excludeFromRoutes } : {},
|
|
104
|
+
...fromNav[0] && fromNav[1] ? { routablesFrom: "nav" } : {}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
return { config: JSON.stringify(config, null, 1), oldId, newId, warnings };
|
|
108
|
+
}
|
|
109
|
+
async function runCompare(args, highlightWorker) {
|
|
110
|
+
const labels = option(args, "--labels")[0];
|
|
111
|
+
const ignore = option(args, "--ignore");
|
|
112
|
+
const out = resolve(option(args, "-o", "--out")[0] ?? "compare-out");
|
|
113
|
+
const passed = ["--no-search", "--no-diagrams", "--force", "--all-warnings", "--as-worker"].filter((f) => flag(args, f));
|
|
114
|
+
const inside = (a, b) => {
|
|
115
|
+
const r = relative(b, a);
|
|
116
|
+
return r === "" || !r.startsWith("..") && !isAbsolute(r);
|
|
117
|
+
};
|
|
118
|
+
if (flag(args, "--quiet", "-q")) passed.push("--quiet");
|
|
119
|
+
const unknown = args.filter((a) => a.startsWith("-"));
|
|
120
|
+
if (unknown.length) throw new UsageError(`unknown option: ${unknown.join(" ")}`);
|
|
121
|
+
if (args.length !== 2) throw new UsageError("compare takes two folders: the older version, then the newer one");
|
|
122
|
+
const files = /* @__PURE__ */ new Map();
|
|
123
|
+
for (const f of args.map((a) => resolve(a))) if (inside(f, out)) throw new UsageError(`-o ${out}: holds ${f}, which is being compared; give an output folder of its own`);
|
|
124
|
+
const older = readSide(resolve(args[0]), "_old", files, [out]);
|
|
125
|
+
const newer = readSide(resolve(args[1]), "_new", files, [out]);
|
|
126
|
+
if (labels !== void 0) {
|
|
127
|
+
const [a, b, ...more] = labels.split(",").map((l) => l.trim());
|
|
128
|
+
if (!a || !b || more.length) throw new UsageError("--labels takes two labels: <old>,<new>");
|
|
129
|
+
older.label = a;
|
|
130
|
+
newer.label = b;
|
|
131
|
+
}
|
|
132
|
+
const { config, oldId, newId, warnings } = compareConfig(older, newer, ignore);
|
|
133
|
+
if (!passed.includes("--quiet")) for (const w of warnings) console.warn(`warn ${w}`);
|
|
134
|
+
const { runBuild } = await import("./build-command-NJATVOUY.mjs");
|
|
135
|
+
await runBuild(["-o", out, ...passed], highlightWorker, { prepared: { config, files, root: process.cwd() } });
|
|
136
|
+
if (!process.exitCode) console.log(`comparison: ${join(out, newId, "compare", `${oldId}..${newId}`, "index.html")}`);
|
|
137
|
+
}
|
|
138
|
+
export {
|
|
139
|
+
compareConfig,
|
|
140
|
+
ignoreRule,
|
|
141
|
+
readSide,
|
|
142
|
+
runCompare,
|
|
143
|
+
versionId
|
|
144
|
+
};
|
|
@@ -1,52 +1,61 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
contentType
|
|
5
|
+
} from "./chunk-CMGKSS45.mjs";
|
|
3
6
|
import {
|
|
4
7
|
cliMemorySettings,
|
|
5
8
|
diagramRenderers,
|
|
6
9
|
iconResolver
|
|
7
10
|
} from "./chunk-OBUK53NJ.mjs";
|
|
8
11
|
import {
|
|
9
|
-
ConfigError,
|
|
10
|
-
MENU_FILE,
|
|
11
12
|
PageClashError,
|
|
12
13
|
assetVerdict,
|
|
13
14
|
build,
|
|
14
15
|
copiedPath,
|
|
15
|
-
dataDirOf,
|
|
16
16
|
defaultTables,
|
|
17
|
-
insideProject,
|
|
18
17
|
languageTables,
|
|
19
|
-
memberPaths,
|
|
20
|
-
parseConfig,
|
|
21
|
-
projectFile,
|
|
22
|
-
projectRoots,
|
|
23
|
-
readMenus,
|
|
24
|
-
readProject,
|
|
25
18
|
readText,
|
|
26
19
|
rebuildUnitLazy,
|
|
27
20
|
servedRoot,
|
|
28
21
|
siteCssBuilder,
|
|
29
22
|
siteFileFor,
|
|
30
|
-
sourceRoot,
|
|
31
|
-
staticPathServed,
|
|
32
23
|
translationTables,
|
|
33
|
-
versionsOf,
|
|
34
24
|
writeTranslationStubs
|
|
35
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-ZDH4JRVX.mjs";
|
|
26
|
+
import "./chunk-CYJ6GFVM.mjs";
|
|
27
|
+
import "./chunk-2EM7IEQT.mjs";
|
|
36
28
|
import {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
insideProject,
|
|
30
|
+
projectFile,
|
|
31
|
+
readMenus,
|
|
32
|
+
readProject
|
|
33
|
+
} from "./chunk-X3UPCLX5.mjs";
|
|
34
|
+
import "./chunk-GFG5I7WI.mjs";
|
|
35
|
+
import {
|
|
36
|
+
ConfigError,
|
|
37
|
+
MENU_FILE,
|
|
38
|
+
dataDirOf,
|
|
39
|
+
memberPaths,
|
|
40
|
+
parseConfig,
|
|
41
|
+
projectRoots,
|
|
42
|
+
sourceRoot,
|
|
43
|
+
staticPathServed,
|
|
44
|
+
versionsOf
|
|
45
|
+
} from "./chunk-5NQOUB5I.mjs";
|
|
46
|
+
import "./chunk-GZ3E45TE.mjs";
|
|
40
47
|
import {
|
|
41
48
|
filePagesIndex
|
|
42
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-VJ6AESSJ.mjs";
|
|
43
50
|
import "./chunk-YVSP26OS.mjs";
|
|
44
51
|
import "./chunk-O3R3MASP.mjs";
|
|
45
52
|
import {
|
|
46
|
-
collectClasses
|
|
53
|
+
collectClasses
|
|
54
|
+
} from "./chunk-IAAKV7V2.mjs";
|
|
55
|
+
import {
|
|
47
56
|
isRef,
|
|
48
57
|
isStream
|
|
49
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-5A2QPRCV.mjs";
|
|
50
59
|
import "./chunk-G6OTOD3B.mjs";
|
|
51
60
|
import "./chunk-STRHO6SY.mjs";
|
|
52
61
|
|
|
@@ -59,9 +68,20 @@ import { extname, join, resolve, sep } from "node:path";
|
|
|
59
68
|
// src/core/dev.ts
|
|
60
69
|
var CONFIG_FILES = /* @__PURE__ */ new Set(["dogsbay.config.yml", "dogsbay.config.yaml"]);
|
|
61
70
|
var NAV_FILES = /(^|\/)nav\.(ya?ml|json)$/;
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
var patternsByFolder = /* @__PURE__ */ new Map();
|
|
72
|
+
function patterns(folder) {
|
|
73
|
+
let p = patternsByFolder.get(folder);
|
|
74
|
+
if (!p) {
|
|
75
|
+
const f = folder.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
76
|
+
p = {
|
|
77
|
+
START_ONLY: new RegExp(`(^|/)(${f}/search/|llms(-full)?\\.txt$)`),
|
|
78
|
+
SITE_WIDE: new RegExp(`^(${f}/assets/|${f}/(site|versions)\\.js$|robots\\.txt$|_headers$|_redirects$|sitemap-index\\.xml$)`),
|
|
79
|
+
UNIT_CSS: new RegExp(`(^|/)${f}/site\\.css$`)
|
|
80
|
+
};
|
|
81
|
+
patternsByFolder.set(folder, p);
|
|
82
|
+
}
|
|
83
|
+
return p;
|
|
84
|
+
}
|
|
65
85
|
async function openDevSession(input, o = {}) {
|
|
66
86
|
let out = /* @__PURE__ */ new Map();
|
|
67
87
|
let units = /* @__PURE__ */ new Map();
|
|
@@ -168,7 +188,7 @@ async function openDevSession(input, o = {}) {
|
|
|
168
188
|
};
|
|
169
189
|
const restyle = async (u) => {
|
|
170
190
|
const css = await (await siteCssBuilder(input))({ theme: config.theme, themeCss: ctx.theme.themeCss, extra: ctx.theme.extraCss, candidates: u.classes });
|
|
171
|
-
out.set(`${u.unit.prefix ? u.unit.prefix + "/" : ""}
|
|
191
|
+
out.set(`${u.unit.prefix ? u.unit.prefix + "/" : ""}${config.assetsFolder}/site.css`, css);
|
|
172
192
|
};
|
|
173
193
|
let requests = Promise.resolve();
|
|
174
194
|
const budgeted = (work) => {
|
|
@@ -456,11 +476,43 @@ async function openDevSession(input, o = {}) {
|
|
|
456
476
|
}
|
|
457
477
|
}
|
|
458
478
|
}
|
|
479
|
+
if (ctx.state.fallbackNavs) {
|
|
480
|
+
const def = config.defaultLocale;
|
|
481
|
+
for (const p of paths) {
|
|
482
|
+
if (CONFIG_FILES.has(p)) continue;
|
|
483
|
+
const u = unitOf(p);
|
|
484
|
+
for (const x of units.values()) {
|
|
485
|
+
if (x === u || x.unit.locale === def) continue;
|
|
486
|
+
const shown = x.handle.pagesForSource(p);
|
|
487
|
+
const reads = (x.handle.included(p) ? x.handle.includeReaders(p) : void 0) ?? [];
|
|
488
|
+
if (!shown.length && !reads.length) continue;
|
|
489
|
+
if (u && lazy.has(u.unit.prefix)) lazy.add(x.unit.prefix);
|
|
490
|
+
else {
|
|
491
|
+
x.handle.forget(p);
|
|
492
|
+
for (const o2 of [...shown, ...reads]) markStale(o2, x);
|
|
493
|
+
}
|
|
494
|
+
mark("page");
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
for (const prefix of [...lazy]) {
|
|
498
|
+
const d = units.get(prefix)?.unit;
|
|
499
|
+
if (!d || d.locale !== def) continue;
|
|
500
|
+
for (const x of units.values()) if (x.unit.locale !== def && x.unit.version === d.version && !x.unit.product) lazy.add(x.unit.prefix);
|
|
501
|
+
}
|
|
502
|
+
if (lazy.size) {
|
|
503
|
+
const all = [...units.values()].map((u) => u.unit);
|
|
504
|
+
ctx.state.translations = await translationTables(config, all, input.files, readText, true);
|
|
505
|
+
const order = [...lazy].sort((a, b) => Number(units.get(a)?.unit.locale !== def) - Number(units.get(b)?.unit.locale !== def));
|
|
506
|
+
lazy.clear();
|
|
507
|
+
for (const prefix of order) lazy.add(prefix);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
459
510
|
if (lazy.size) for (const s of ctx.state.stubs) out.delete(s);
|
|
460
511
|
const pagesBefore = new Map([...lazy].map((prefix) => [prefix, [...units.get(prefix).handle.pageOuts].sort().join("\n")]));
|
|
461
512
|
for (const prefix of lazy) {
|
|
462
513
|
const u = units.get(prefix);
|
|
463
514
|
for (const key of [...out.keys()]) {
|
|
515
|
+
const { START_ONLY, SITE_WIDE, UNIT_CSS } = patterns(config.assetsFolder);
|
|
464
516
|
if (START_ONLY.test(key) || SITE_WIDE.test(key) || UNIT_CSS.test(key) || ctx.state.staticFiles?.has(key)) continue;
|
|
465
517
|
if (unitForSitePath(key) === u) out.delete(key);
|
|
466
518
|
}
|
|
@@ -538,7 +590,7 @@ async function openDevSession(input, o = {}) {
|
|
|
538
590
|
return rest(next) === rest(parsedConfig) ? next : void 0;
|
|
539
591
|
}
|
|
540
592
|
async function emitInto(path, content) {
|
|
541
|
-
if (START_ONLY.test(path)) return;
|
|
593
|
+
if (patterns(config.assetsFolder).START_ONLY.test(path)) return;
|
|
542
594
|
if (path.split("/").some((s) => s === ".." || s === "." || s === "") || path.startsWith("/")) return;
|
|
543
595
|
const c = await resolveContent(content);
|
|
544
596
|
out.set(path, c);
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
navFromMenu,
|
|
5
|
+
slugFromPath
|
|
6
|
+
} from "./chunk-2EM7IEQT.mjs";
|
|
7
|
+
import {
|
|
8
|
+
normalize
|
|
9
|
+
} from "./chunk-GZ3E45TE.mjs";
|
|
3
10
|
import {
|
|
4
11
|
NOT_A_MENU_CODES,
|
|
5
12
|
menuToNav,
|
|
6
|
-
navFromMenu,
|
|
7
|
-
normalize,
|
|
8
13
|
oldStylePaths,
|
|
9
14
|
parseMenu,
|
|
10
|
-
resolveMenuFile
|
|
11
|
-
|
|
12
|
-
} from "./chunk-IERF2DNL.mjs";
|
|
15
|
+
resolveMenuFile
|
|
16
|
+
} from "./chunk-VJ6AESSJ.mjs";
|
|
13
17
|
import "./chunk-YVSP26OS.mjs";
|
|
14
18
|
import "./chunk-O3R3MASP.mjs";
|
|
15
19
|
import "./chunk-G6OTOD3B.mjs";
|
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
|
|
3
3
|
import {
|
|
4
|
-
copiedPath
|
|
5
|
-
|
|
4
|
+
copiedPath
|
|
5
|
+
} from "./chunk-ZDH4JRVX.mjs";
|
|
6
|
+
import "./chunk-CYJ6GFVM.mjs";
|
|
7
|
+
import "./chunk-2EM7IEQT.mjs";
|
|
8
|
+
import {
|
|
6
9
|
readBuildFiles
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import
|
|
10
|
+
} from "./chunk-X3UPCLX5.mjs";
|
|
11
|
+
import "./chunk-GFG5I7WI.mjs";
|
|
12
|
+
import {
|
|
13
|
+
parseConfig
|
|
14
|
+
} from "./chunk-5NQOUB5I.mjs";
|
|
15
|
+
import "./chunk-GZ3E45TE.mjs";
|
|
16
|
+
import "./chunk-VJ6AESSJ.mjs";
|
|
10
17
|
import {
|
|
11
18
|
UsageError,
|
|
12
19
|
flag,
|
|
13
20
|
option,
|
|
14
21
|
positional
|
|
15
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-ZRGJHNES.mjs";
|
|
16
23
|
import "./chunk-YVSP26OS.mjs";
|
|
17
24
|
import "./chunk-O3R3MASP.mjs";
|
|
25
|
+
import "./chunk-IAAKV7V2.mjs";
|
|
18
26
|
import {
|
|
19
27
|
TEXT_FILE,
|
|
20
28
|
isLazyText,
|
|
21
29
|
isRef
|
|
22
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-5A2QPRCV.mjs";
|
|
23
31
|
import "./chunk-G6OTOD3B.mjs";
|
|
24
32
|
import "./chunk-STRHO6SY.mjs";
|
|
25
33
|
|
|
@@ -9,18 +9,25 @@ import {
|
|
|
9
9
|
releaseDiff,
|
|
10
10
|
releaseExitCode,
|
|
11
11
|
releaseRedirects
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-FFIXBXHD.mjs";
|
|
13
|
+
import "./chunk-ZDH4JRVX.mjs";
|
|
14
|
+
import "./chunk-CYJ6GFVM.mjs";
|
|
15
|
+
import "./chunk-2EM7IEQT.mjs";
|
|
16
|
+
import {
|
|
17
|
+
readBuildFiles
|
|
18
|
+
} from "./chunk-X3UPCLX5.mjs";
|
|
19
|
+
import "./chunk-GFG5I7WI.mjs";
|
|
13
20
|
import {
|
|
14
21
|
buildUnits,
|
|
15
22
|
parseConfig,
|
|
16
|
-
readBuildFiles,
|
|
17
23
|
versionsOf
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-5NQOUB5I.mjs";
|
|
25
|
+
import "./chunk-GZ3E45TE.mjs";
|
|
26
|
+
import "./chunk-VJ6AESSJ.mjs";
|
|
21
27
|
import "./chunk-YVSP26OS.mjs";
|
|
22
28
|
import "./chunk-O3R3MASP.mjs";
|
|
23
|
-
import "./chunk-
|
|
29
|
+
import "./chunk-IAAKV7V2.mjs";
|
|
30
|
+
import "./chunk-5A2QPRCV.mjs";
|
|
24
31
|
import "./chunk-G6OTOD3B.mjs";
|
|
25
32
|
import "./chunk-STRHO6SY.mjs";
|
|
26
33
|
|