ssqch 0.9.0 → 0.10.1
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/README.md +1 -1
- package/bundled/completions/bash +1 -1
- package/bundled/completions/elvish +1 -0
- package/bundled/completions/fish +1 -0
- package/bundled/completions/powershell +1 -0
- package/bundled/completions/zsh +1 -0
- package/bundled/docs/agents.md +70 -0
- package/bundled/docs/benchmarks.md +29 -0
- package/bundled/docs/build-summary.md +57 -0
- package/bundled/docs/comparing-builds.md +51 -0
- package/bundled/docs/configuring.md +138 -0
- package/bundled/docs/content-schemas.md +54 -0
- package/bundled/docs/css-and-javascript.md +33 -0
- package/bundled/docs/data-files.md +55 -0
- package/bundled/docs/deploying.md +47 -0
- package/bundled/docs/field-guide.md +144 -0
- package/bundled/docs/footprint.md +27 -0
- package/bundled/docs/github-pages.md +41 -0
- package/bundled/docs/index.md +26 -0
- package/bundled/docs/install.md +27 -0
- package/bundled/docs/known-gaps.md +18 -0
- package/bundled/docs/markdown.md +114 -0
- package/bundled/docs/multilingual.md +14 -0
- package/bundled/docs/nav.yml +50 -0
- package/bundled/docs/netlify.md +30 -0
- package/bundled/docs/new-pages.md +42 -0
- package/bundled/docs/plugins.md +13 -0
- package/bundled/docs/rust-plugins.md +32 -0
- package/bundled/docs/seo.md +19 -0
- package/bundled/docs/template-languages.md +106 -0
- package/bundled/docs/templates.md +37 -0
- package/bundled/docs/themes.md +31 -0
- package/bundled/{trailheads → docs/trailheads}/from-component-frameworks.md +7 -3
- package/bundled/{trailheads → docs/trailheads}/from-docusaurus.md +7 -4
- package/bundled/{trailheads → docs/trailheads}/from-eleventy.md +7 -4
- package/bundled/{trailheads → docs/trailheads}/from-hexo.md +7 -4
- package/bundled/{trailheads → docs/trailheads}/from-jekyll.md +6 -3
- package/bundled/{trailheads → docs/trailheads}/from-mkdocs.md +8 -5
- package/bundled/{trailheads → docs/trailheads}/from-zola.md +6 -3
- package/bundled/docs/trailheads.md +38 -0
- package/bundled/docs/where-values-come-from.md +57 -0
- package/bundled/ssqch.d.ts +10 -3
- package/lib/assets.js +18 -12
- package/lib/{chunk-7PWCYHTJ.js → chunk-26SHWRC6.js} +6 -8
- package/lib/{chunk-GUKSZ2XM.js → chunk-3BQJY6GF.js} +4 -6
- package/lib/{chunk-TICWN55Z.js → chunk-3LODFCCH.js} +2 -3
- package/lib/{chunk-TVU3OPPK.js → chunk-3NDFUMV2.js} +3 -3
- package/lib/{chunk-YTHQBMDJ.js → chunk-6OUT5VFK.js} +3 -6
- package/lib/{chunk-HXCLCXRT.js → chunk-6RSZV5O2.js} +5 -3
- package/lib/{chunk-4Q6WMTER.js → chunk-7JGYYAKI.js} +1 -1
- package/lib/{chunk-MI6EJWA2.js → chunk-BT3NVQOD.js} +1 -1
- package/lib/{chunk-DDV6JEC2.js → chunk-BXARVN5Z.js} +1 -1
- package/lib/{chunk-RNJFPFXE.js → chunk-CXRHH5P5.js} +5 -6
- package/lib/{chunk-HPXAZ2HU.js → chunk-DNWA7WNO.js} +1 -1
- package/lib/{chunk-SURPOAW7.js → chunk-DTSTCVRX.js} +8 -9
- package/lib/{chunk-7SD7K567.js → chunk-DUGGZ4EE.js} +1 -1
- package/lib/{chunk-7XLK2GEG.js → chunk-ERNVEZOK.js} +1 -1
- package/lib/{chunk-3A647I3N.js → chunk-FYRC2HBU.js} +4 -6
- package/lib/{chunk-IJWHOFRP.js → chunk-FYU22VDK.js} +12 -13
- package/lib/{chunk-II5DEH3Q.js → chunk-FZGJUJAL.js} +5 -7
- package/lib/{chunk-BEGC7YP6.js → chunk-G67W2FTJ.js} +9 -11
- package/lib/{chunk-7RDRZHJD.js → chunk-HMVYNV6M.js} +13 -15
- package/lib/{chunk-DELWRJAO.js → chunk-HNG372DW.js} +143 -74
- package/lib/{chunk-47P4YREZ.js → chunk-II7ZRIAC.js} +11 -13
- package/lib/{chunk-NCWFYT74.js → chunk-IOXCGMSF.js} +5 -7
- package/lib/{chunk-GRWMGC7D.js → chunk-JFPLNHEQ.js} +2410 -2298
- package/lib/{chunk-LPHNACE4.js → chunk-LU73FTIR.js} +10 -11
- package/lib/{chunk-D2XE2GTY.js → chunk-LYPKL524.js} +9 -10
- package/lib/{chunk-NKXEPHRZ.js → chunk-MDB3D3LP.js} +106 -4
- package/lib/{chunk-CZ4XQC56.js → chunk-MDG5A4NI.js} +15 -13
- package/lib/{chunk-SXMJ52IK.js → chunk-MUYWL4ZX.js} +58 -19
- package/lib/{chunk-R7K3D5W5.js → chunk-P2TRR6XK.js} +83 -24
- package/lib/{chunk-SF4I6Z7S.js → chunk-R2YGC3VE.js} +2 -3
- package/lib/{chunk-76NTVE34.js → chunk-RFNLZM7W.js} +2 -4
- package/lib/{chunk-3K3ANWZ2.js → chunk-X7C6GFUM.js} +4 -4
- package/lib/{chunk-XMXBHXZR.js → chunk-XR7GFL4B.js} +12 -13
- package/lib/{chunk-NNUKIGOO.js → chunk-ZZBHBLDB.js} +16 -18
- package/lib/cli.js +25 -25
- package/lib/elements.js +10 -12
- package/lib/image.js +10 -11
- package/lib/links.js +13 -15
- package/lib/minify.js +9 -10
- package/lib/redirects.js +11 -13
- package/lib/rss.js +22 -22
- package/lib/sass.js +10 -12
- package/lib/sitemap.js +10 -12
- package/lib/ssqch.js +4 -5
- package/package.json +2 -2
- package/types/index.d.ts +9 -2
- package/types/rss.d.ts +1 -1
- package/bundled/README.md +0 -1314
- package/lib/chunk-VJWQSYEG.js +0 -119
- package/lib/{chunk-DELWRJAO.js.LEGAL.txt → chunk-HNG372DW.js.LEGAL.txt} +0 -0
- package/lib/{chunk-GRWMGC7D.js.LEGAL.txt → chunk-JFPLNHEQ.js.LEGAL.txt} +3 -3
|
@@ -5,21 +5,20 @@ import {
|
|
|
5
5
|
capabilities,
|
|
6
6
|
modules,
|
|
7
7
|
runCapabilities
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-X7C6GFUM.js";
|
|
9
|
+
import "./chunk-6OUT5VFK.js";
|
|
10
|
+
import "./chunk-P2TRR6XK.js";
|
|
11
|
+
import "./chunk-ERNVEZOK.js";
|
|
12
|
+
import "./chunk-MDB3D3LP.js";
|
|
13
13
|
import "./chunk-AD3HAW3W.js";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-BXARVN5Z.js";
|
|
15
|
+
import "./chunk-IOXCGMSF.js";
|
|
16
16
|
import "./chunk-FVZ5JBRI.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-DNWA7WNO.js";
|
|
18
18
|
import "./chunk-UU43WIZG.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-RFNLZM7W.js";
|
|
20
20
|
import "./chunk-CMUWRPSQ.js";
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-VJWQSYEG.js";
|
|
21
|
+
import "./chunk-JFPLNHEQ.js";
|
|
23
22
|
import "./chunk-I3PS26CI.js";
|
|
24
23
|
export {
|
|
25
24
|
MODULE_EXPORTS,
|
|
@@ -3,26 +3,25 @@ const require = __ssqchCreateRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
types,
|
|
5
5
|
write
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6OUT5VFK.js";
|
|
7
7
|
import {
|
|
8
8
|
loadConfig,
|
|
9
9
|
schemaTypes
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-P2TRR6XK.js";
|
|
11
|
+
import "./chunk-ERNVEZOK.js";
|
|
12
|
+
import "./chunk-MDB3D3LP.js";
|
|
13
13
|
import "./chunk-AD3HAW3W.js";
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-BXARVN5Z.js";
|
|
15
|
+
import "./chunk-IOXCGMSF.js";
|
|
16
16
|
import "./chunk-FVZ5JBRI.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-DNWA7WNO.js";
|
|
18
18
|
import "./chunk-UU43WIZG.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-RFNLZM7W.js";
|
|
20
20
|
import "./chunk-CMUWRPSQ.js";
|
|
21
21
|
import {
|
|
22
22
|
messageOf,
|
|
23
23
|
red
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-VJWQSYEG.js";
|
|
24
|
+
} from "./chunk-JFPLNHEQ.js";
|
|
26
25
|
import "./chunk-I3PS26CI.js";
|
|
27
26
|
|
|
28
27
|
// src/commands/types.ts
|
|
@@ -3,19 +3,96 @@ const require = __ssqchCreateRequire(import.meta.url);
|
|
|
3
3
|
import {
|
|
4
4
|
dirsOf,
|
|
5
5
|
shownOutput
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BXARVN5Z.js";
|
|
7
7
|
import {
|
|
8
8
|
FIRST_SITING,
|
|
9
9
|
LEFT_NO_TRACE,
|
|
10
10
|
RECOVERED
|
|
11
11
|
} from "./chunk-UU43WIZG.js";
|
|
12
12
|
import {
|
|
13
|
-
relative
|
|
14
|
-
|
|
13
|
+
relative,
|
|
14
|
+
warning
|
|
15
|
+
} from "./chunk-JFPLNHEQ.js";
|
|
15
16
|
|
|
16
17
|
// src/report.ts
|
|
17
18
|
import fs from "node:fs";
|
|
18
19
|
import path from "node:path";
|
|
20
|
+
|
|
21
|
+
// src/profile.ts
|
|
22
|
+
var SLOW_MS = 1e3;
|
|
23
|
+
var KINDS = ["pages", "templates", "layouts", "engines", "filters", "transforms", "data", "collections", "hooks"];
|
|
24
|
+
var SINGULAR = { pages: "page", templates: "template", layouts: "layout", engines: "template engine", filters: "filter", transforms: "transform", data: "data", collections: "collection", hooks: "hook" };
|
|
25
|
+
var isPromise = (v) => typeof v?.then === "function";
|
|
26
|
+
var Profile = class {
|
|
27
|
+
/** `--profile`: time everything. Otherwise only the site's own functions, for `slow-call`. */
|
|
28
|
+
detailed;
|
|
29
|
+
/** The page being rendered, which a slow call is said to be working on (pages render one at a time). */
|
|
30
|
+
at;
|
|
31
|
+
stats = new Map(KINDS.map((k) => [k, /* @__PURE__ */ new Map()]));
|
|
32
|
+
constructor(detailed) {
|
|
33
|
+
this.detailed = detailed;
|
|
34
|
+
}
|
|
35
|
+
/** Records one call of `name`, which took `ms`. */
|
|
36
|
+
add(kind, name, ms, own, from, at = this.at, async = false) {
|
|
37
|
+
if (!this.detailed && !(own && ms >= SLOW_MS)) return;
|
|
38
|
+
const of = this.stats.get(kind);
|
|
39
|
+
let stat = of.get(name);
|
|
40
|
+
if (!stat) of.set(name, stat = { calls: 0, ms: 0, own, from, slowCalls: 0, async: false });
|
|
41
|
+
stat.calls++;
|
|
42
|
+
if (async) stat.async = true;
|
|
43
|
+
stat.ms += ms;
|
|
44
|
+
if (ms >= SLOW_MS && stat.slowCalls++ === 0) [stat.firstSlow, stat.firstSlowAt] = [ms, at];
|
|
45
|
+
}
|
|
46
|
+
/** Runs `call` and records its time, until it returns or, for a promise, settles. */
|
|
47
|
+
time(kind, name, own, call, from) {
|
|
48
|
+
const at = this.at;
|
|
49
|
+
const start = performance.now();
|
|
50
|
+
const out = call();
|
|
51
|
+
if (isPromise(out)) {
|
|
52
|
+
const done = () => this.add(kind, name, performance.now() - start, own, from, at, true);
|
|
53
|
+
out.then(done, done);
|
|
54
|
+
} else this.add(kind, name, performance.now() - start, own, from, at);
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
/** `fn`, timed whenever it's called (with the `this` it's called with: Nunjucks passes its context). */
|
|
58
|
+
wrap(kind, name, fn, own, from) {
|
|
59
|
+
const profile = this;
|
|
60
|
+
return function(...args) {
|
|
61
|
+
return profile.time(kind, name, own, () => fn.apply(this, args), from);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** Whether a function of this kind is timed: every one with `--profile`, the site's own without. */
|
|
65
|
+
times(own) {
|
|
66
|
+
return this.detailed || own;
|
|
67
|
+
}
|
|
68
|
+
/** The `slow-call` warnings: one for each of the site's own functions with a call of a second or more. */
|
|
69
|
+
slowCalls() {
|
|
70
|
+
const out = [];
|
|
71
|
+
for (const kind of KINDS) {
|
|
72
|
+
for (const [name, s] of this.stats.get(kind)) {
|
|
73
|
+
if (!s.own || s.slowCalls === 0) continue;
|
|
74
|
+
const what = kind === "hooks" ? name : `${SINGULAR[kind]} \`${name}\``;
|
|
75
|
+
const from = s.from ? ` (from ${s.from})` : "";
|
|
76
|
+
const at = s.firstSlowAt ? ` working on ${s.firstSlowAt}` : "";
|
|
77
|
+
const more = s.slowCalls > 1 ? `, the first of ${s.slowCalls} calls that took over a second` : "";
|
|
78
|
+
out.push(warning("slow-call", `${what}${from} took ${seconds(s.firstSlow)}${at}${more}. \`ssqch build --profile\` shows where a build's time goes`));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
/** Every kind's list, slowest first (by total time, then name). Empty without `--profile`. */
|
|
84
|
+
report() {
|
|
85
|
+
const out = {};
|
|
86
|
+
for (const kind of KINDS) {
|
|
87
|
+
const list = this.detailed ? [...this.stats.get(kind)].map(([name, s]) => ({ name, calls: s.calls, ms: s.ms, async: s.async })) : [];
|
|
88
|
+
out[kind] = list.sort((a, b) => b.ms - a.ms || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
var seconds = (ms) => `${(ms / 1e3).toFixed(1)} s`;
|
|
94
|
+
|
|
95
|
+
// src/report.ts
|
|
19
96
|
function summary(config, report, recovered = false) {
|
|
20
97
|
const dirs = dirsOf(config);
|
|
21
98
|
const nothing = report.templates === 0 && report.drafts === 0 && report.pagesWritten === 0;
|
|
@@ -126,11 +203,36 @@ function fixed(v, digits) {
|
|
|
126
203
|
if (last % 2 === 0) return down;
|
|
127
204
|
return v.toFixed(digits);
|
|
128
205
|
}
|
|
206
|
+
var PROFILE_TOP = 10;
|
|
207
|
+
function profileText(profile) {
|
|
208
|
+
const titles = { pages: "Pages", templates: "Templates (pages)", layouts: "Layouts (renders)", engines: "Template engines (renders)", filters: "Filters (calls)", transforms: "Transforms (pages)", data: "Data", collections: "Collections", hooks: "Hooks" };
|
|
209
|
+
const withCalls = /* @__PURE__ */ new Set(["templates", "layouts", "engines", "filters", "transforms"]);
|
|
210
|
+
let out = "Profile: where the time went, slowest first (a call's time includes the calls it makes)\n";
|
|
211
|
+
if (KINDS.some((kind) => profile[kind].some((e) => e.async))) out += "Async ones are timed until they settle, and overlap: their totals can add up to more than the build took\n";
|
|
212
|
+
for (const kind of KINDS) {
|
|
213
|
+
const list = profile[kind];
|
|
214
|
+
if (!list.length) continue;
|
|
215
|
+
out += ` ${titles[kind]}
|
|
216
|
+
`;
|
|
217
|
+
const shown = list.slice(0, PROFILE_TOP);
|
|
218
|
+
const width = Math.max(...shown.map((e) => duration(e.ms).length));
|
|
219
|
+
for (const e of shown) {
|
|
220
|
+
const notes = [...withCalls.has(kind) ? [count(e.calls)] : [], ...e.async ? ["async"] : []];
|
|
221
|
+
out += ` ${duration(e.ms).padStart(width)} ${e.name}${notes.length ? ` (${notes.join(", ")})` : ""}
|
|
222
|
+
`;
|
|
223
|
+
}
|
|
224
|
+
if (list.length > PROFILE_TOP) out += ` ...and ${count(list.length - PROFILE_TOP)} more (--format json lists them all)
|
|
225
|
+
`;
|
|
226
|
+
}
|
|
227
|
+
return out;
|
|
228
|
+
}
|
|
129
229
|
|
|
130
230
|
export {
|
|
231
|
+
Profile,
|
|
131
232
|
summary,
|
|
132
233
|
count,
|
|
133
234
|
bytes,
|
|
134
235
|
duration,
|
|
135
|
-
fixed
|
|
236
|
+
fixed,
|
|
237
|
+
profileText
|
|
136
238
|
};
|
|
@@ -6,18 +6,18 @@ import {
|
|
|
6
6
|
fingerprint,
|
|
7
7
|
isAsset,
|
|
8
8
|
sameStamps
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-3BQJY6GF.js";
|
|
10
10
|
import {
|
|
11
11
|
commandLine
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-7JGYYAKI.js";
|
|
13
13
|
import {
|
|
14
14
|
Builder,
|
|
15
15
|
stopBuilders
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-BT3NVQOD.js";
|
|
17
17
|
import {
|
|
18
18
|
CONFIG_FILES,
|
|
19
19
|
dirsOf
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-BXARVN5Z.js";
|
|
21
21
|
import {
|
|
22
22
|
closestPath
|
|
23
23
|
} from "./chunk-FVZ5JBRI.js";
|
|
@@ -29,19 +29,17 @@ import {
|
|
|
29
29
|
import {
|
|
30
30
|
BuildError,
|
|
31
31
|
aliasesUsed,
|
|
32
|
+
isInside,
|
|
32
33
|
messageOf,
|
|
33
34
|
progress,
|
|
34
|
-
red,
|
|
35
|
-
warn,
|
|
36
|
-
warning
|
|
37
|
-
} from "./chunk-GRWMGC7D.js";
|
|
38
|
-
import {
|
|
39
|
-
isInside,
|
|
40
35
|
realPath,
|
|
36
|
+
red,
|
|
41
37
|
relative,
|
|
42
38
|
slashes,
|
|
43
|
-
walkFiles
|
|
44
|
-
|
|
39
|
+
walkFiles,
|
|
40
|
+
warn,
|
|
41
|
+
warning
|
|
42
|
+
} from "./chunk-JFPLNHEQ.js";
|
|
45
43
|
import "./chunk-I3PS26CI.js";
|
|
46
44
|
|
|
47
45
|
// src/serve/server.ts
|
|
@@ -850,7 +848,11 @@ async function watch({ builder, live, args, quiet, startedTools, firstBuild, say
|
|
|
850
848
|
firstBuild(ok);
|
|
851
849
|
sayWhere();
|
|
852
850
|
const contents = /* @__PURE__ */ new Map();
|
|
853
|
-
const show = (file) =>
|
|
851
|
+
const show = (file) => {
|
|
852
|
+
if (file === site.root) return file;
|
|
853
|
+
const rel = path3.relative(site.root, file);
|
|
854
|
+
return path3.isAbsolute(rel) ? file : rel;
|
|
855
|
+
};
|
|
854
856
|
const own = (file) => isInside(site.root, file) && path3.relative(site.root, file).split(path3.sep).some((part) => part === ".cache" || part === ".git" || part === "node_modules");
|
|
855
857
|
for (; ; ) {
|
|
856
858
|
const paths = carried.length ? carried.splice(0) : await rx.recv();
|
|
@@ -2,10 +2,10 @@ import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
|
2
2
|
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
modules
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-X7C6GFUM.js";
|
|
6
6
|
import {
|
|
7
7
|
BUILTIN_FILTERS
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-FYRC2HBU.js";
|
|
9
9
|
import {
|
|
10
10
|
longHelp
|
|
11
11
|
} from "./chunk-F65YUXZ7.js";
|
|
@@ -14,39 +14,71 @@ import {
|
|
|
14
14
|
bundled,
|
|
15
15
|
bundledNames,
|
|
16
16
|
types
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-6OUT5VFK.js";
|
|
18
18
|
import {
|
|
19
19
|
configOptions
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
22
|
-
import "./chunk-
|
|
20
|
+
} from "./chunk-P2TRR6XK.js";
|
|
21
|
+
import "./chunk-ERNVEZOK.js";
|
|
22
|
+
import "./chunk-MDB3D3LP.js";
|
|
23
23
|
import {
|
|
24
24
|
VERSION
|
|
25
25
|
} from "./chunk-AD3HAW3W.js";
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-BXARVN5Z.js";
|
|
27
|
+
import "./chunk-IOXCGMSF.js";
|
|
28
28
|
import {
|
|
29
29
|
closest
|
|
30
30
|
} from "./chunk-FVZ5JBRI.js";
|
|
31
|
-
import "./chunk-
|
|
31
|
+
import "./chunk-DNWA7WNO.js";
|
|
32
32
|
import "./chunk-UU43WIZG.js";
|
|
33
|
-
import "./chunk-
|
|
33
|
+
import "./chunk-RFNLZM7W.js";
|
|
34
34
|
import "./chunk-CMUWRPSQ.js";
|
|
35
35
|
import {
|
|
36
36
|
OTHER_CONFIGS,
|
|
37
37
|
TABLE,
|
|
38
|
+
jsYaml,
|
|
38
39
|
red,
|
|
39
40
|
toJson
|
|
40
|
-
} from "./chunk-
|
|
41
|
-
import "./chunk-VJWQSYEG.js";
|
|
41
|
+
} from "./chunk-JFPLNHEQ.js";
|
|
42
42
|
import "./chunk-I3PS26CI.js";
|
|
43
43
|
|
|
44
44
|
// src/commands/docs.ts
|
|
45
|
-
var
|
|
45
|
+
var SITE_URL = "https://sitesquatch.dev";
|
|
46
|
+
function docsPage(text) {
|
|
47
|
+
const front = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
|
|
48
|
+
const data = front ? jsYaml.load(front[1]) ?? {} : {};
|
|
49
|
+
return { title: String(data.title ?? ""), body: front ? text.slice(front[0].length) : text };
|
|
50
|
+
}
|
|
51
|
+
function headingsDown(body) {
|
|
52
|
+
let fence = null;
|
|
53
|
+
return body.split(/\r?\n/).map((line) => {
|
|
54
|
+
const trimmed = line.trimStart();
|
|
55
|
+
const marker = ["```", "~~~"].find((m) => trimmed.startsWith(m));
|
|
56
|
+
if (marker !== void 0) {
|
|
57
|
+
if (fence === null) fence = marker;
|
|
58
|
+
else if (fence === marker && trimmed.trimEnd().replace(new RegExp(`^\\${marker[0]}+`), "") === "") fence = null;
|
|
59
|
+
return line;
|
|
60
|
+
}
|
|
61
|
+
return fence === null && /^#{1,5} /.test(line) ? `#${line}` : line;
|
|
62
|
+
}).join("\n");
|
|
63
|
+
}
|
|
64
|
+
function docsText() {
|
|
65
|
+
const nav = jsYaml.load(bundled("docs/nav.yml")) ?? [];
|
|
66
|
+
const files = nav.flatMap((group) => group.pages).filter((p) => typeof p === "string" && !p.startsWith("trailheads/"));
|
|
67
|
+
return files.map((file, i) => {
|
|
68
|
+
const { title, body } = docsPage(bundled(`docs/${file}`));
|
|
69
|
+
return i === 0 ? `# ${title}
|
|
70
|
+
|
|
71
|
+
${body.trim()}
|
|
72
|
+
` : `## ${title}
|
|
73
|
+
|
|
74
|
+
${headingsDown(body).trim()}
|
|
75
|
+
`;
|
|
76
|
+
}).join("\n");
|
|
77
|
+
}
|
|
46
78
|
var byteLength = (text) => Buffer.byteLength(text);
|
|
47
79
|
var ALNUM = /[\p{Alphabetic}\p{N}]/u;
|
|
48
80
|
var IMAGE_LINE = /^\s*(<p\b[^>]*>\s*)?<img\b[^>]*>(\s*<\/p>)?\s*$/i;
|
|
49
|
-
function sections(readme =
|
|
81
|
+
function sections(readme = docsText()) {
|
|
50
82
|
const out = [];
|
|
51
83
|
let fence = null;
|
|
52
84
|
for (const line of readme.split(/\r?\n/)) {
|
|
@@ -468,12 +500,17 @@ function nextStep(grammar, all, known, query) {
|
|
|
468
500
|
}
|
|
469
501
|
function guide(generator) {
|
|
470
502
|
const configured = OTHER_CONFIGS.find(([, g]) => g === generator)?.[3] ?? null;
|
|
471
|
-
const available = bundledNames("trailheads");
|
|
503
|
+
const available = bundledNames("docs/trailheads");
|
|
472
504
|
const file = configured ?? (available.includes(`from-${generator.toLowerCase()}.md`) ? `from-${generator.toLowerCase()}.md` : void 0);
|
|
473
505
|
if (file === void 0) return void 0;
|
|
474
|
-
|
|
506
|
+
if (!available.includes(file)) return { file, text: null };
|
|
507
|
+
const { title, body } = docsPage(bundled(`docs/trailheads/${file}`));
|
|
508
|
+
return { file, text: `# ${title}
|
|
509
|
+
|
|
510
|
+
${body.trim()}
|
|
511
|
+
` };
|
|
475
512
|
}
|
|
476
|
-
var guideUrl = (file) => `${
|
|
513
|
+
var guideUrl = (file) => `${SITE_URL}/docs/trailheads/${file.replace(/\.md$/, "")}/`;
|
|
477
514
|
function from(generator, json) {
|
|
478
515
|
const known = generators();
|
|
479
516
|
const found = known.find((g2) => g2.toLowerCase() === generator.toLowerCase() || g2.replace(/\./g, "").toLowerCase() === generator.toLowerCase());
|
|
@@ -486,7 +523,7 @@ function from(generator, json) {
|
|
|
486
523
|
const g = guide(found);
|
|
487
524
|
if (json) {
|
|
488
525
|
const rows2 = (list) => list.map((e) => ({ ...toJson(e), say: e.say }));
|
|
489
|
-
const value = { generator: found, words: rows2(theirs), common: rows2(everyone), trailhead: g ? { file: `docs/trailheads/${g.file}`, url: guideUrl(g.file), text: g.text } : null };
|
|
526
|
+
const value = { generator: found, words: rows2(theirs), common: rows2(everyone), trailhead: g ? { file: `site/src/docs/trailheads/${g.file}`, url: guideUrl(g.file), text: g.text } : null };
|
|
490
527
|
return JSON.stringify(value, null, 2) + "\n";
|
|
491
528
|
}
|
|
492
529
|
let out = `${found}'s words, and ssqch's names for them. The ones marked (works) are aliases: they do the same as ssqch's name, and say it once. The others are refused with this hint.
|
|
@@ -511,7 +548,7 @@ ${rows(list)}`;
|
|
|
511
548
|
Words most generators use
|
|
512
549
|
${rows(everyone)}`;
|
|
513
550
|
if (g && g.text !== null) out += `
|
|
514
|
-
The trailhead (
|
|
551
|
+
The trailhead (${guideUrl(g.file)}):
|
|
515
552
|
|
|
516
553
|
${g.text.trimEnd()}
|
|
517
554
|
`;
|
|
@@ -564,6 +601,8 @@ function runDocs(grammar, command) {
|
|
|
564
601
|
}
|
|
565
602
|
export {
|
|
566
603
|
answer,
|
|
604
|
+
docsPage,
|
|
605
|
+
docsText,
|
|
567
606
|
names,
|
|
568
607
|
runDocs,
|
|
569
608
|
sections,
|