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.
- package/README.md +8 -4
- package/bin/ssqch.js +14 -48
- package/bundled/README.md +1314 -0
- package/bundled/completions/bash +840 -0
- package/bundled/completions/elvish +286 -0
- package/bundled/completions/fish +182 -0
- package/bundled/completions/powershell +318 -0
- package/bundled/completions/zsh +510 -0
- package/bundled/ssqch.d.ts +540 -0
- package/bundled/starter/engines/index.edge +11 -0
- package/bundled/starter/engines/index.ejs +11 -0
- package/bundled/starter/engines/index.hbs +11 -0
- package/bundled/starter/engines/index.liquid +11 -0
- package/bundled/starter/engines/layout.edge +35 -0
- package/bundled/starter/engines/layout.ejs +35 -0
- package/bundled/starter/engines/layout.hbs +35 -0
- package/bundled/starter/engines/layout.liquid +35 -0
- package/bundled/starter/gitignore +3 -0
- package/bundled/starter/jsconfig.json +11 -0
- package/bundled/starter/src/404.md +8 -0
- package/bundled/starter/src/_blueprints/posts.md +5 -0
- package/bundled/starter/src/_data/site.json +4 -0
- package/bundled/starter/src/_includes/layout.jinja +35 -0
- package/bundled/starter/src/index.jinja +11 -0
- package/bundled/starter/src/posts/i-know-what-i-saw.md +11 -0
- package/bundled/starter/src/posts/posts.json +4 -0
- package/bundled/starter/src/posts/raiders-of-the-lost-path.md +27 -0
- package/bundled/starter/src/posts/the-cache-of-the-wild.md +26 -0
- package/bundled/starter/src/posts/the-stump-has-moved.md +15 -0
- package/bundled/starter/src/posts/upon-further-review-a-stump.md +18 -0
- package/bundled/starter/ssqch.config.js +29 -0
- package/bundled/starter-docs/engines/edge/base.edge +41 -0
- package/bundled/starter-docs/engines/edge/containers/details.edge +5 -0
- package/bundled/starter-docs/engines/edge/containers/tab.edge +4 -0
- package/bundled/starter-docs/engines/edge/containers/tabs.edge +5 -0
- package/bundled/starter-docs/engines/edge/doc.edge +59 -0
- package/bundled/starter-docs/engines/edge/hooks/heading.edge +2 -0
- package/bundled/starter-docs/engines/ejs/base.ejs +41 -0
- package/bundled/starter-docs/engines/ejs/containers/details.ejs +5 -0
- package/bundled/starter-docs/engines/ejs/containers/tab.ejs +4 -0
- package/bundled/starter-docs/engines/ejs/containers/tabs.ejs +5 -0
- package/bundled/starter-docs/engines/ejs/doc.ejs +59 -0
- package/bundled/starter-docs/engines/ejs/hooks/heading.ejs +2 -0
- package/bundled/starter-docs/engines/hbs/base.hbs +41 -0
- package/bundled/starter-docs/engines/hbs/containers/details.hbs +5 -0
- package/bundled/starter-docs/engines/hbs/containers/tab.hbs +4 -0
- package/bundled/starter-docs/engines/hbs/containers/tabs.hbs +5 -0
- package/bundled/starter-docs/engines/hbs/doc.hbs +58 -0
- package/bundled/starter-docs/engines/hbs/hooks/heading.hbs +2 -0
- package/bundled/starter-docs/engines/liquid/base.liquid +41 -0
- package/bundled/starter-docs/engines/liquid/containers/details.liquid +5 -0
- package/bundled/starter-docs/engines/liquid/containers/tab.liquid +4 -0
- package/bundled/starter-docs/engines/liquid/containers/tabs.liquid +5 -0
- package/bundled/starter-docs/engines/liquid/doc.liquid +60 -0
- package/bundled/starter-docs/engines/liquid/hooks/heading.liquid +2 -0
- package/bundled/starter-docs/gitignore +4 -0
- package/bundled/starter-docs/src/404.md +12 -0
- package/bundled/starter-docs/src/_blueprints/docs.md +5 -0
- package/bundled/starter-docs/src/_data/nav.yml +10 -0
- package/bundled/starter-docs/src/_data/site.json +5 -0
- package/bundled/starter-docs/src/_includes/base.jinja +41 -0
- package/bundled/starter-docs/src/_includes/containers/details.jinja +5 -0
- package/bundled/starter-docs/src/_includes/containers/tab.jinja +4 -0
- package/bundled/starter-docs/src/_includes/containers/tabs.jinja +5 -0
- package/bundled/starter-docs/src/_includes/doc.jinja +59 -0
- package/bundled/starter-docs/src/_includes/hooks/heading.jinja +2 -0
- package/bundled/starter-docs/src/assets/docs.css +257 -0
- package/bundled/starter-docs/src/assets/docs.js +67 -0
- package/bundled/starter-docs/src/docs/docs.json +1 -0
- package/bundled/starter-docs/src/docs/guides/deploying.md +77 -0
- package/bundled/starter-docs/src/docs/guides/writing.md +65 -0
- package/bundled/starter-docs/src/docs/index.md +29 -0
- package/bundled/starter-docs/src/docs/install.md +42 -0
- package/bundled/starter-docs/src/index.md +13 -0
- package/bundled/starter-docs/ssqch.config.js +40 -0
- package/bundled/trailheads/from-component-frameworks.md +116 -0
- package/bundled/trailheads/from-docusaurus.md +55 -0
- package/bundled/trailheads/from-eleventy.md +140 -0
- package/bundled/trailheads/from-hexo.md +92 -0
- package/bundled/trailheads/from-jekyll.md +79 -0
- package/bundled/trailheads/from-mkdocs.md +45 -0
- package/bundled/trailheads/from-zola.md +71 -0
- package/lib/assets.js +235 -3
- package/lib/chunk-3A647I3N.js +384 -0
- package/lib/chunk-3GYLOC6Y.js +1017 -0
- package/lib/chunk-3K3ANWZ2.js +118 -0
- package/lib/chunk-3NYSSA2C.js +22 -0
- package/lib/chunk-47P4YREZ.js +1287 -0
- package/lib/chunk-4Q6WMTER.js +32 -0
- package/lib/chunk-76NTVE34.js +338 -0
- package/lib/chunk-7PWCYHTJ.js +1350 -0
- package/lib/chunk-7RDRZHJD.js +217 -0
- package/lib/chunk-7SD7K567.js +57 -0
- package/lib/chunk-7XLK2GEG.js +54 -0
- package/lib/chunk-AD3HAW3W.js +10 -0
- package/lib/chunk-BEGC7YP6.js +502 -0
- package/lib/chunk-CMUWRPSQ.js +113 -0
- package/lib/chunk-CZ4XQC56.js +999 -0
- package/lib/chunk-D2XE2GTY.js +71 -0
- package/lib/chunk-DDV6JEC2.js +46 -0
- package/lib/chunk-DELWRJAO.js +37409 -0
- package/lib/chunk-DELWRJAO.js.LEGAL.txt +27 -0
- package/lib/chunk-F65YUXZ7.js +334 -0
- package/lib/chunk-FVZ5JBRI.js +115 -0
- package/lib/chunk-GRWMGC7D.js +4435 -0
- package/lib/chunk-GRWMGC7D.js.LEGAL.txt +41 -0
- package/lib/chunk-GUKSZ2XM.js +207 -0
- package/lib/chunk-HPXAZ2HU.js +251 -0
- package/lib/chunk-HXCLCXRT.js +20 -0
- package/lib/chunk-I3PS26CI.js +48 -0
- package/lib/chunk-IAFM5ITE.js +11 -0
- package/lib/chunk-II5DEH3Q.js +209 -0
- package/lib/chunk-IJWHOFRP.js +44 -0
- package/lib/chunk-LPHNACE4.js +29 -0
- package/lib/chunk-MI6EJWA2.js +175 -0
- package/lib/chunk-NCWFYT74.js +1541 -0
- package/lib/chunk-NKXEPHRZ.js +136 -0
- package/lib/chunk-NNUKIGOO.js +160 -0
- package/lib/chunk-R7K3D5W5.js +3957 -0
- package/lib/chunk-RNJFPFXE.js +29 -0
- package/lib/chunk-SF4I6Z7S.js +25 -0
- package/lib/chunk-SURPOAW7.js +44 -0
- package/lib/chunk-SXMJ52IK.js +572 -0
- package/lib/chunk-TICWN55Z.js +20 -0
- package/lib/chunk-TVU3OPPK.js +146 -0
- package/lib/chunk-UU43WIZG.js +29 -0
- package/lib/chunk-VJWQSYEG.js +119 -0
- package/lib/chunk-XMXBHXZR.js +75 -0
- package/lib/chunk-YTHQBMDJ.js +211 -0
- package/lib/cli.js +547 -0
- package/lib/elements.js +180 -3
- package/lib/image.js +27 -3
- package/lib/links.js +464 -3
- package/lib/minify.js +69 -3
- package/lib/redirects.js +152 -3
- package/lib/rss.js +139 -3
- package/lib/sass.js +256 -3
- package/lib/sitemap.js +113 -3
- package/lib/ssqch.js +28 -0
- package/package.json +83 -80
- package/src/serve/live.js +174 -0
- package/src/serve/not-found.html +31 -0
- package/types/globals.d.ts +3 -2
- package/types/image.d.ts +7 -3
- package/types/index.d.ts +28 -9
- package/types/links.d.ts +1 -1
- package/types/minify.d.ts +1 -1
- package/types/rss.d.ts +1 -1
- package/types/sass.d.ts +1 -1
- package/types/sitemap.d.ts +2 -0
- package/wasm/markdown.wasm +0 -0
- package/wasm/minify.wasm +0 -0
- package/wasm/sass.wasm +0 -0
- package/lib/index.js +0 -3
- 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
|
+
};
|