ssqch 0.7.1 → 0.9.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.
Files changed (155) hide show
  1. package/README.md +8 -4
  2. package/bin/ssqch.js +14 -48
  3. package/bundled/README.md +1314 -0
  4. package/bundled/completions/bash +840 -0
  5. package/bundled/completions/elvish +286 -0
  6. package/bundled/completions/fish +182 -0
  7. package/bundled/completions/powershell +318 -0
  8. package/bundled/completions/zsh +510 -0
  9. package/bundled/ssqch.d.ts +540 -0
  10. package/bundled/starter/engines/index.edge +11 -0
  11. package/bundled/starter/engines/index.ejs +11 -0
  12. package/bundled/starter/engines/index.hbs +11 -0
  13. package/bundled/starter/engines/index.liquid +11 -0
  14. package/bundled/starter/engines/layout.edge +35 -0
  15. package/bundled/starter/engines/layout.ejs +35 -0
  16. package/bundled/starter/engines/layout.hbs +35 -0
  17. package/bundled/starter/engines/layout.liquid +35 -0
  18. package/bundled/starter/gitignore +3 -0
  19. package/bundled/starter/jsconfig.json +11 -0
  20. package/bundled/starter/src/404.md +8 -0
  21. package/bundled/starter/src/_blueprints/posts.md +5 -0
  22. package/bundled/starter/src/_data/site.json +4 -0
  23. package/bundled/starter/src/_includes/layout.jinja +35 -0
  24. package/bundled/starter/src/index.jinja +11 -0
  25. package/bundled/starter/src/posts/i-know-what-i-saw.md +11 -0
  26. package/bundled/starter/src/posts/posts.json +4 -0
  27. package/bundled/starter/src/posts/raiders-of-the-lost-path.md +27 -0
  28. package/bundled/starter/src/posts/the-cache-of-the-wild.md +26 -0
  29. package/bundled/starter/src/posts/the-stump-has-moved.md +15 -0
  30. package/bundled/starter/src/posts/upon-further-review-a-stump.md +18 -0
  31. package/bundled/starter/ssqch.config.js +29 -0
  32. package/bundled/starter-docs/engines/edge/base.edge +41 -0
  33. package/bundled/starter-docs/engines/edge/containers/details.edge +5 -0
  34. package/bundled/starter-docs/engines/edge/containers/tab.edge +4 -0
  35. package/bundled/starter-docs/engines/edge/containers/tabs.edge +5 -0
  36. package/bundled/starter-docs/engines/edge/doc.edge +59 -0
  37. package/bundled/starter-docs/engines/edge/hooks/heading.edge +2 -0
  38. package/bundled/starter-docs/engines/ejs/base.ejs +41 -0
  39. package/bundled/starter-docs/engines/ejs/containers/details.ejs +5 -0
  40. package/bundled/starter-docs/engines/ejs/containers/tab.ejs +4 -0
  41. package/bundled/starter-docs/engines/ejs/containers/tabs.ejs +5 -0
  42. package/bundled/starter-docs/engines/ejs/doc.ejs +59 -0
  43. package/bundled/starter-docs/engines/ejs/hooks/heading.ejs +2 -0
  44. package/bundled/starter-docs/engines/hbs/base.hbs +41 -0
  45. package/bundled/starter-docs/engines/hbs/containers/details.hbs +5 -0
  46. package/bundled/starter-docs/engines/hbs/containers/tab.hbs +4 -0
  47. package/bundled/starter-docs/engines/hbs/containers/tabs.hbs +5 -0
  48. package/bundled/starter-docs/engines/hbs/doc.hbs +58 -0
  49. package/bundled/starter-docs/engines/hbs/hooks/heading.hbs +2 -0
  50. package/bundled/starter-docs/engines/liquid/base.liquid +41 -0
  51. package/bundled/starter-docs/engines/liquid/containers/details.liquid +5 -0
  52. package/bundled/starter-docs/engines/liquid/containers/tab.liquid +4 -0
  53. package/bundled/starter-docs/engines/liquid/containers/tabs.liquid +5 -0
  54. package/bundled/starter-docs/engines/liquid/doc.liquid +60 -0
  55. package/bundled/starter-docs/engines/liquid/hooks/heading.liquid +2 -0
  56. package/bundled/starter-docs/gitignore +4 -0
  57. package/bundled/starter-docs/src/404.md +12 -0
  58. package/bundled/starter-docs/src/_blueprints/docs.md +5 -0
  59. package/bundled/starter-docs/src/_data/nav.yml +10 -0
  60. package/bundled/starter-docs/src/_data/site.json +5 -0
  61. package/bundled/starter-docs/src/_includes/base.jinja +41 -0
  62. package/bundled/starter-docs/src/_includes/containers/details.jinja +5 -0
  63. package/bundled/starter-docs/src/_includes/containers/tab.jinja +4 -0
  64. package/bundled/starter-docs/src/_includes/containers/tabs.jinja +5 -0
  65. package/bundled/starter-docs/src/_includes/doc.jinja +59 -0
  66. package/bundled/starter-docs/src/_includes/hooks/heading.jinja +2 -0
  67. package/bundled/starter-docs/src/assets/docs.css +257 -0
  68. package/bundled/starter-docs/src/assets/docs.js +67 -0
  69. package/bundled/starter-docs/src/docs/docs.json +1 -0
  70. package/bundled/starter-docs/src/docs/guides/deploying.md +77 -0
  71. package/bundled/starter-docs/src/docs/guides/writing.md +65 -0
  72. package/bundled/starter-docs/src/docs/index.md +29 -0
  73. package/bundled/starter-docs/src/docs/install.md +42 -0
  74. package/bundled/starter-docs/src/index.md +13 -0
  75. package/bundled/starter-docs/ssqch.config.js +40 -0
  76. package/bundled/trailheads/from-component-frameworks.md +116 -0
  77. package/bundled/trailheads/from-docusaurus.md +55 -0
  78. package/bundled/trailheads/from-eleventy.md +140 -0
  79. package/bundled/trailheads/from-hexo.md +92 -0
  80. package/bundled/trailheads/from-jekyll.md +79 -0
  81. package/bundled/trailheads/from-mkdocs.md +45 -0
  82. package/bundled/trailheads/from-zola.md +71 -0
  83. package/lib/assets.js +235 -3
  84. package/lib/chunk-3A647I3N.js +384 -0
  85. package/lib/chunk-3GYLOC6Y.js +1017 -0
  86. package/lib/chunk-3K3ANWZ2.js +118 -0
  87. package/lib/chunk-3NYSSA2C.js +22 -0
  88. package/lib/chunk-47P4YREZ.js +1287 -0
  89. package/lib/chunk-4Q6WMTER.js +32 -0
  90. package/lib/chunk-76NTVE34.js +338 -0
  91. package/lib/chunk-7PWCYHTJ.js +1350 -0
  92. package/lib/chunk-7RDRZHJD.js +217 -0
  93. package/lib/chunk-7SD7K567.js +57 -0
  94. package/lib/chunk-7XLK2GEG.js +54 -0
  95. package/lib/chunk-AD3HAW3W.js +10 -0
  96. package/lib/chunk-BEGC7YP6.js +502 -0
  97. package/lib/chunk-CMUWRPSQ.js +113 -0
  98. package/lib/chunk-CZ4XQC56.js +999 -0
  99. package/lib/chunk-D2XE2GTY.js +71 -0
  100. package/lib/chunk-DDV6JEC2.js +46 -0
  101. package/lib/chunk-DELWRJAO.js +37409 -0
  102. package/lib/chunk-DELWRJAO.js.LEGAL.txt +27 -0
  103. package/lib/chunk-F65YUXZ7.js +334 -0
  104. package/lib/chunk-FVZ5JBRI.js +115 -0
  105. package/lib/chunk-GRWMGC7D.js +4435 -0
  106. package/lib/chunk-GRWMGC7D.js.LEGAL.txt +41 -0
  107. package/lib/chunk-GUKSZ2XM.js +207 -0
  108. package/lib/chunk-HPXAZ2HU.js +251 -0
  109. package/lib/chunk-HXCLCXRT.js +20 -0
  110. package/lib/chunk-I3PS26CI.js +48 -0
  111. package/lib/chunk-IAFM5ITE.js +11 -0
  112. package/lib/chunk-II5DEH3Q.js +209 -0
  113. package/lib/chunk-IJWHOFRP.js +44 -0
  114. package/lib/chunk-LPHNACE4.js +29 -0
  115. package/lib/chunk-MI6EJWA2.js +175 -0
  116. package/lib/chunk-NCWFYT74.js +1541 -0
  117. package/lib/chunk-NKXEPHRZ.js +136 -0
  118. package/lib/chunk-NNUKIGOO.js +160 -0
  119. package/lib/chunk-R7K3D5W5.js +3957 -0
  120. package/lib/chunk-RNJFPFXE.js +29 -0
  121. package/lib/chunk-SF4I6Z7S.js +25 -0
  122. package/lib/chunk-SURPOAW7.js +44 -0
  123. package/lib/chunk-SXMJ52IK.js +572 -0
  124. package/lib/chunk-TICWN55Z.js +20 -0
  125. package/lib/chunk-TVU3OPPK.js +146 -0
  126. package/lib/chunk-UU43WIZG.js +29 -0
  127. package/lib/chunk-VJWQSYEG.js +119 -0
  128. package/lib/chunk-XMXBHXZR.js +75 -0
  129. package/lib/chunk-YTHQBMDJ.js +211 -0
  130. package/lib/cli.js +547 -0
  131. package/lib/elements.js +180 -3
  132. package/lib/image.js +27 -3
  133. package/lib/links.js +464 -3
  134. package/lib/minify.js +69 -3
  135. package/lib/redirects.js +152 -3
  136. package/lib/rss.js +139 -3
  137. package/lib/sass.js +256 -3
  138. package/lib/sitemap.js +113 -3
  139. package/lib/ssqch.js +28 -0
  140. package/package.json +83 -80
  141. package/src/serve/live.js +174 -0
  142. package/src/serve/not-found.html +31 -0
  143. package/types/globals.d.ts +3 -2
  144. package/types/image.d.ts +7 -3
  145. package/types/index.d.ts +28 -9
  146. package/types/links.d.ts +1 -1
  147. package/types/minify.d.ts +1 -1
  148. package/types/rss.d.ts +1 -1
  149. package/types/sass.d.ts +1 -1
  150. package/types/sitemap.d.ts +2 -0
  151. package/wasm/markdown.wasm +0 -0
  152. package/wasm/minify.wasm +0 -0
  153. package/wasm/sass.wasm +0 -0
  154. package/lib/index.js +0 -3
  155. package/platforms.json +0 -6
@@ -0,0 +1,136 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ dirsOf,
5
+ shownOutput
6
+ } from "./chunk-DDV6JEC2.js";
7
+ import {
8
+ FIRST_SITING,
9
+ LEFT_NO_TRACE,
10
+ RECOVERED
11
+ } from "./chunk-UU43WIZG.js";
12
+ import {
13
+ relative
14
+ } from "./chunk-VJWQSYEG.js";
15
+
16
+ // src/report.ts
17
+ import fs from "node:fs";
18
+ import path from "node:path";
19
+ function summary(config, report, recovered = false) {
20
+ const dirs = dirsOf(config);
21
+ const nothing = report.templates === 0 && report.drafts === 0 && report.pagesWritten === 0;
22
+ const asides = [
23
+ [recovered, "recovered"],
24
+ [nothing, "nothingSighted"],
25
+ [report.firstBuild, "firstSiting"],
26
+ [report.filesRemoved > 0, "leftNoTrace"],
27
+ [report.drafts > 0, "unconfirmed"],
28
+ [report.unused.length > 0, "uninhabited"]
29
+ ];
30
+ const aside = asides.find(([happened]) => happened)?.[1];
31
+ const lines = [];
32
+ let pages = `${count(report.pagesWritten)} written`;
33
+ if (report.templates > 0) pages += ` from ${count(report.templates)} template${plural(report.templates)}`;
34
+ if (report.pagesWritten > 0) pages += `, ${bytes(report.pageBytes)}`;
35
+ const since = [];
36
+ if (report.pagesNew) since.push(`${count(report.pagesNew)} new`);
37
+ if (report.pagesGone) since.push(`${count(report.pagesGone)} gone`);
38
+ if (report.pagesChanged !== void 0) since.push(`${count(report.pagesChanged)} changed`);
39
+ if (since.length) pages += ` (${since.join(", ")})`;
40
+ lines.push(["Pages", pages]);
41
+ if (report.drafts > 0) lines.push(["Drafts", `${count(report.drafts)}${aside === "unconfirmed" ? " unconfirmed" : " left out"} (built in development only)`]);
42
+ if (report.filesCopied + report.filesUnchanged > 0) {
43
+ let copied = `${count(report.filesCopied)} file${plural(report.filesCopied)}`;
44
+ if (report.filesUnchanged > 0) copied += `, ${count(report.filesUnchanged)} unchanged`;
45
+ lines.push(["Copied", `${copied}, ${bytes(report.passthroughBytes)}`]);
46
+ }
47
+ if (report.filesRemoved > 0) lines.push(["Removed", `${count(report.filesRemoved)} stale file${plural(report.filesRemoved)}${aside === "leftNoTrace" ? `, ${LEFT_NO_TRACE}` : ""}`]);
48
+ lines.push(...report.summary);
49
+ const [files, size] = dirSize(dirs.output);
50
+ const output = shownOutput(config, true);
51
+ lines.push(["Output", `${output}: ${count(files)} file${plural(files)}, ${bytes(size)}`]);
52
+ if (report.timings.length) lines.push(["Time", report.timings.map(([label, ms]) => `${label} ${duration(ms)}`).join(", ")]);
53
+ const width = Math.max(0, ...lines.map(([label]) => label.length));
54
+ const first = aside === "firstSiting" ? `${FIRST_SITING} ` : aside === "recovered" ? `${RECOVERED} ` : "";
55
+ let out = `${first}Built in ${duration(report.durationMs)} (${config.env})
56
+ `;
57
+ for (const [label, text] of lines) out += ` ${label.padEnd(width)} ${text}
58
+ `;
59
+ if (report.unused.length) {
60
+ const n = report.unused.length;
61
+ out += `${aside === "uninhabited" ? "Uninhabited" : "Unused"}: ${count(n)} template${plural(n)} that nothing used in this build (${report.unused.join(", ")}).
62
+ `;
63
+ }
64
+ if (nothing) {
65
+ const folder = relative(dirs.root, dirs.input) || ".";
66
+ out += `Nothing sighted: no file in ${folder} matches templateFormats (${config.templateFormats.join(", ")}).
67
+ `;
68
+ }
69
+ return out;
70
+ }
71
+ function dirSize(dir) {
72
+ let files = 0, size = 0;
73
+ const walk = (folder) => {
74
+ let entries;
75
+ try {
76
+ entries = fs.readdirSync(folder, { withFileTypes: true });
77
+ } catch {
78
+ return;
79
+ }
80
+ for (const entry of entries) {
81
+ const p = path.join(folder, entry.name);
82
+ if (entry.isDirectory()) walk(p);
83
+ else if (entry.isFile()) {
84
+ files++;
85
+ size += fs.statSync(p, { throwIfNoEntry: false })?.size ?? 0;
86
+ }
87
+ }
88
+ };
89
+ walk(dir);
90
+ return [files, size];
91
+ }
92
+ var plural = (n) => n === 1 ? "" : "s";
93
+ function count(n) {
94
+ return String(Math.trunc(n)).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
95
+ }
96
+ function bytes(n) {
97
+ if (n < 1e3) return `${n} B`;
98
+ let value = n;
99
+ let unit = "";
100
+ for (const u of ["KB", "MB", "GB", "TB"]) {
101
+ value /= 1e3;
102
+ unit = u;
103
+ if (value < 999.5) break;
104
+ }
105
+ return `${threeDigits(value)} ${unit}`;
106
+ }
107
+ function duration(ms) {
108
+ const secs = ms / 1e3;
109
+ if (secs >= 60) {
110
+ const whole = Math.round(secs);
111
+ return `${Math.floor(whole / 60)}m ${String(whole % 60).padStart(2, "0")}s`;
112
+ }
113
+ if (secs >= 1) return `${threeDigits(secs)} s`;
114
+ if (secs >= 1e-3) return `${threeDigits(secs * 1e3)} ms`;
115
+ return `${Math.round(secs * 1e6)} \xB5s`;
116
+ }
117
+ function threeDigits(v) {
118
+ return fixed(v, v >= 99.95 ? 0 : v >= 9.995 ? 1 : 2);
119
+ }
120
+ function fixed(v, digits) {
121
+ const exact = v.toFixed(digits + 30);
122
+ const kept = exact.slice(0, exact.length - 30);
123
+ if (!/^50*$/.test(exact.slice(-30))) return v.toFixed(digits);
124
+ const last = Number(kept[kept.length - 1] === "." ? kept[kept.length - 2] : kept[kept.length - 1]);
125
+ const down = digits === 0 ? kept.slice(0, -1) : kept;
126
+ if (last % 2 === 0) return down;
127
+ return v.toFixed(digits);
128
+ }
129
+
130
+ export {
131
+ summary,
132
+ count,
133
+ bytes,
134
+ duration,
135
+ fixed
136
+ };
@@ -0,0 +1,160 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ isAsset
5
+ } from "./chunk-GUKSZ2XM.js";
6
+ import {
7
+ build
8
+ } from "./chunk-DELWRJAO.js";
9
+ import "./chunk-4Q6WMTER.js";
10
+ import "./chunk-3A647I3N.js";
11
+ import "./chunk-II5DEH3Q.js";
12
+ import {
13
+ filesRead
14
+ } from "./chunk-3NYSSA2C.js";
15
+ import {
16
+ fileHash
17
+ } from "./chunk-MI6EJWA2.js";
18
+ import "./chunk-R7K3D5W5.js";
19
+ import "./chunk-7XLK2GEG.js";
20
+ import {
21
+ summary
22
+ } from "./chunk-NKXEPHRZ.js";
23
+ import "./chunk-AD3HAW3W.js";
24
+ import {
25
+ dirsOf
26
+ } from "./chunk-DDV6JEC2.js";
27
+ import "./chunk-NCWFYT74.js";
28
+ import "./chunk-FVZ5JBRI.js";
29
+ import "./chunk-HPXAZ2HU.js";
30
+ import "./chunk-UU43WIZG.js";
31
+ import {
32
+ describeThrown,
33
+ loadedFiles
34
+ } from "./chunk-76NTVE34.js";
35
+ import "./chunk-CMUWRPSQ.js";
36
+ import {
37
+ BuildError,
38
+ Locator,
39
+ TABLE,
40
+ aliasesKnown,
41
+ aliasesUsed,
42
+ describe,
43
+ messageOf,
44
+ printError,
45
+ red
46
+ } from "./chunk-GRWMGC7D.js";
47
+ import {
48
+ isInside,
49
+ realPath,
50
+ relative,
51
+ slashes
52
+ } from "./chunk-VJWQSYEG.js";
53
+ import "./chunk-I3PS26CI.js";
54
+
55
+ // src/serve/build-process.ts
56
+ import path from "node:path";
57
+ var key = (row) => `${row.kind}:${row.word}`;
58
+ function locatorDirs(config) {
59
+ const dirs = dirsOf(config);
60
+ return [dirs.input, dirs.includes, dirs.data, ...config.themes.flatMap((theme) => [theme, path.join(theme, "_includes")])];
61
+ }
62
+ function siteInfo(config) {
63
+ const dirs = dirsOf(config);
64
+ return {
65
+ root: dirs.root,
66
+ env: config.env,
67
+ input: dirs.input,
68
+ output: dirs.output,
69
+ outputName: isInside(dirs.root, dirs.output) ? relative(dirs.root, dirs.output) : slashes(dirs.output),
70
+ base: config.base,
71
+ serveRun: config.serveRun,
72
+ watch: [dirs.input, ...config.watch.map((target) => path.resolve(dirs.root, target))],
73
+ locate: locatorDirs(config)
74
+ };
75
+ }
76
+ var flushed = () => Promise.all([process.stdout, process.stderr].map((stream) => new Promise((resolve) => {
77
+ stream.write("", () => resolve());
78
+ })));
79
+ async function runBuilder(start, makeConfig, root) {
80
+ const send = (message) => new Promise((resolve) => {
81
+ process.send(message, void 0, void 0, () => resolve());
82
+ });
83
+ const loadedAs = /* @__PURE__ */ new Map();
84
+ const state = (config2) => {
85
+ const files = [...loadedFiles].map(realPath);
86
+ for (const file of files) if (!loadedAs.has(file)) loadedAs.set(file, fileHash(file));
87
+ return { files, loadedAs: Object.fromEntries(loadedAs), read: filesRead(config2), said: aliasesUsed().map(key) };
88
+ };
89
+ aliasesKnown(TABLE.filter((row) => start.said.includes(key(row))));
90
+ process.on("disconnect", () => process.exit(0));
91
+ for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) process.on(signal, () => {
92
+ });
93
+ const working = async (work) => {
94
+ process.channel?.unref();
95
+ try {
96
+ return await work();
97
+ } finally {
98
+ process.channel?.ref();
99
+ }
100
+ };
101
+ let config;
102
+ try {
103
+ config = await working(makeConfig);
104
+ } catch (e) {
105
+ if (!start.reload) printError("error:", e, "config", new Locator(root));
106
+ else if (start.fallback === false) process.stderr.write(`${red("Config error:")} ${messageOf(e)}
107
+ (nothing builds until it loads: the process that built with the last configuration that loaded has ended)
108
+ `);
109
+ else process.stderr.write(`${red("Config error:")} ${messageOf(e)}
110
+ (still serving with the last configuration that loaded)
111
+ `);
112
+ await flushed();
113
+ await send({ type: "failed" });
114
+ return 1;
115
+ }
116
+ const at = new Locator(config.root, locatorDirs(config));
117
+ let crashing = false;
118
+ const crash = (e) => {
119
+ if (crashing) return;
120
+ crashing = true;
121
+ const said = describe(new BuildError(describeThrown(e, config.root)), "build", at);
122
+ const end = () => process.exit(1);
123
+ setTimeout(end, 2e3).unref();
124
+ void send({ type: "crashed", error: said }).then(flushed).then(end, end);
125
+ };
126
+ process.removeAllListeners("uncaughtException");
127
+ process.removeAllListeners("unhandledRejection");
128
+ process.on("uncaughtException", crash);
129
+ process.on("unhandledRejection", crash);
130
+ const asked = [];
131
+ let wake;
132
+ process.on("message", (message) => {
133
+ asked.push(message);
134
+ wake?.();
135
+ });
136
+ await send({ type: "loaded", site: siteInfo(config), ...state(config) });
137
+ for (; ; ) {
138
+ while (!asked.length) await new Promise((resolve) => {
139
+ wake = resolve;
140
+ });
141
+ wake = void 0;
142
+ const { recovered } = asked.shift();
143
+ let result;
144
+ try {
145
+ const report = await working(() => build(config));
146
+ if (!config.quiet) process.stdout.write(summary(config, report, recovered));
147
+ result = { ok: true, assets: report.outputs.filter(isAsset) };
148
+ } catch (e) {
149
+ const said = describe(e, "build", at);
150
+ process.stderr.write(`${red("Build failed:")} ${said}
151
+ `);
152
+ result = { ok: false, error: said, assets: [] };
153
+ }
154
+ await flushed();
155
+ await send({ type: "built", ...result, ...state(config) });
156
+ }
157
+ }
158
+ export {
159
+ runBuilder
160
+ };