ssqch 0.7.1 → 0.8.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 +6 -4
- package/bin/ssqch.js +14 -48
- package/bundled/README.md +1247 -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 +532 -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-mkdocs.md +45 -0
- package/bundled/trailheads/from-zola.md +71 -0
- package/lib/assets.js +235 -3
- package/lib/chunk-37KSIVNY.js +29 -0
- package/lib/chunk-3GYLOC6Y.js +1017 -0
- package/lib/chunk-3NYSSA2C.js +22 -0
- package/lib/chunk-3PHCFZEU.js +209 -0
- package/lib/chunk-4Q6WMTER.js +32 -0
- package/lib/chunk-6XYSFG6V.js +4423 -0
- package/lib/chunk-6XYSFG6V.js.LEGAL.txt +41 -0
- package/lib/chunk-AD3HAW3W.js +10 -0
- package/lib/chunk-AMBFWPZ4.js +118 -0
- package/lib/chunk-BOBPVAX2.js +37088 -0
- package/lib/chunk-BOBPVAX2.js.LEGAL.txt +27 -0
- package/lib/chunk-BRK4MXXO.js +565 -0
- package/lib/chunk-C35KIPAR.js +247 -0
- package/lib/chunk-CDEPYU7W.js +25 -0
- package/lib/chunk-CMUWRPSQ.js +113 -0
- package/lib/chunk-DDV6JEC2.js +46 -0
- package/lib/chunk-DHHQKW4F.js +71 -0
- package/lib/chunk-EIT4ZDT4.js +1485 -0
- package/lib/chunk-EZZUUPI4.js +20 -0
- package/lib/chunk-F65YUXZ7.js +334 -0
- package/lib/chunk-FVZ5JBRI.js +115 -0
- package/lib/chunk-FYGE634X.js +44 -0
- package/lib/chunk-GOE4ZSAB.js +75 -0
- package/lib/chunk-GSKVRAHF.js +44 -0
- package/lib/chunk-HR2RU2LY.js +999 -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-IRHRK7XB.js +54 -0
- package/lib/chunk-JRT7TQQP.js +57 -0
- package/lib/chunk-JSPSMIJ2.js +217 -0
- package/lib/chunk-KBGE5MCY.js +175 -0
- package/lib/chunk-N5QTGQ5N.js +207 -0
- package/lib/chunk-NKXEPHRZ.js +136 -0
- package/lib/chunk-NUKCUDC4.js +146 -0
- package/lib/chunk-RI2L3VGO.js +376 -0
- package/lib/chunk-TDGBQNGW.js +251 -0
- package/lib/chunk-TN6EEDX2.js +3935 -0
- package/lib/chunk-TWCVHOKO.js +1229 -0
- package/lib/chunk-UGEGUUBT.js +29 -0
- package/lib/chunk-UU43WIZG.js +29 -0
- package/lib/chunk-VJWQSYEG.js +119 -0
- package/lib/chunk-VVPZ5PDP.js +160 -0
- package/lib/chunk-WMOVCQO6.js +1287 -0
- package/lib/chunk-WP3RPVUM.js +211 -0
- package/lib/chunk-YSH2NMIE.js +502 -0
- package/lib/cli.js +540 -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 +221 -3
- package/lib/sitemap.js +88 -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 +18 -5
- 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/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,29 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
MODULE_EXPORTS,
|
|
5
|
+
capabilities,
|
|
6
|
+
modules,
|
|
7
|
+
runCapabilities
|
|
8
|
+
} from "./chunk-AMBFWPZ4.js";
|
|
9
|
+
import "./chunk-WP3RPVUM.js";
|
|
10
|
+
import "./chunk-TN6EEDX2.js";
|
|
11
|
+
import "./chunk-IRHRK7XB.js";
|
|
12
|
+
import "./chunk-NKXEPHRZ.js";
|
|
13
|
+
import "./chunk-AD3HAW3W.js";
|
|
14
|
+
import "./chunk-DDV6JEC2.js";
|
|
15
|
+
import "./chunk-EIT4ZDT4.js";
|
|
16
|
+
import "./chunk-FVZ5JBRI.js";
|
|
17
|
+
import "./chunk-TDGBQNGW.js";
|
|
18
|
+
import "./chunk-UU43WIZG.js";
|
|
19
|
+
import "./chunk-C35KIPAR.js";
|
|
20
|
+
import "./chunk-CMUWRPSQ.js";
|
|
21
|
+
import "./chunk-6XYSFG6V.js";
|
|
22
|
+
import "./chunk-VJWQSYEG.js";
|
|
23
|
+
import "./chunk-I3PS26CI.js";
|
|
24
|
+
export {
|
|
25
|
+
MODULE_EXPORTS,
|
|
26
|
+
capabilities,
|
|
27
|
+
modules,
|
|
28
|
+
runCapabilities
|
|
29
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/voice.ts
|
|
5
|
+
var SQUATCH_WATCH = "Squatch Watch is on.";
|
|
6
|
+
var FRESH_TRACKS = "Fresh tracks in";
|
|
7
|
+
var FIRST_SITING = "First confirmed siting.";
|
|
8
|
+
var RECOVERED = "Build recovered. Back on the trail.";
|
|
9
|
+
var FIELD_NOTES = "Field notes started.";
|
|
10
|
+
var LEFT_NO_TRACE = "left no trace";
|
|
11
|
+
var CAMPSITE_DISTURBED = "Campsite disturbed:";
|
|
12
|
+
var PASSED_THIS_TREE = "we've passed this tree before";
|
|
13
|
+
var TRAIL_GOES_COLD = "the trail goes cold";
|
|
14
|
+
var SOMETHING_LARGE = "something large walked through the build";
|
|
15
|
+
var ISSUES_URL = "https://github.com/reverentgeek/sitesquatch/issues";
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
SQUATCH_WATCH,
|
|
19
|
+
FRESH_TRACKS,
|
|
20
|
+
FIRST_SITING,
|
|
21
|
+
RECOVERED,
|
|
22
|
+
FIELD_NOTES,
|
|
23
|
+
LEFT_NO_TRACE,
|
|
24
|
+
CAMPSITE_DISTURBED,
|
|
25
|
+
PASSED_THIS_TREE,
|
|
26
|
+
TRAIL_GOES_COLD,
|
|
27
|
+
SOMETHING_LARGE,
|
|
28
|
+
ISSUES_URL
|
|
29
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/paths.ts
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
var slashes = (p) => path.sep === "/" ? p : p.split(path.sep).join("/");
|
|
8
|
+
function displayPath(root, file) {
|
|
9
|
+
if (file === root) return "./";
|
|
10
|
+
return file.startsWith(root + path.sep) ? `./${slashes(file.slice(root.length + 1))}` : file;
|
|
11
|
+
}
|
|
12
|
+
var shown = (root, file) => displayPath(root, file).replace(/^\.\//, "");
|
|
13
|
+
var relative = (dir, file) => slashes(path.relative(dir, file));
|
|
14
|
+
var joinAsGiven = (base, rel) => path.isAbsolute(rel) || base === "" ? rel : /[\\/]$/.test(base) ? base + rel : base + path.sep + rel;
|
|
15
|
+
function parentAsGiven(p) {
|
|
16
|
+
const separators = path.sep === "/" ? "/" : "\\/";
|
|
17
|
+
let end = p.length;
|
|
18
|
+
while (end > 1 && separators.includes(p[end - 1])) end--;
|
|
19
|
+
let at = end - 1;
|
|
20
|
+
while (at >= 0 && !separators.includes(p[at])) at--;
|
|
21
|
+
if (at < 0) return "";
|
|
22
|
+
let parent = at;
|
|
23
|
+
while (parent > 0 && separators.includes(p[parent - 1])) parent--;
|
|
24
|
+
return parent === 0 ? p.slice(0, 1) : p.slice(0, parent);
|
|
25
|
+
}
|
|
26
|
+
var realPath = (p) => {
|
|
27
|
+
try {
|
|
28
|
+
return fs.realpathSync.native(p);
|
|
29
|
+
} catch {
|
|
30
|
+
return p;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var isFile = (p) => fs.statSync(p, { throwIfNoEntry: false })?.isFile() ?? false;
|
|
34
|
+
var isDir = (p) => fs.statSync(p, { throwIfNoEntry: false })?.isDirectory() ?? false;
|
|
35
|
+
var isInside = (dir, file) => file === dir || file.startsWith(dir.endsWith(path.sep) ? dir : dir + path.sep);
|
|
36
|
+
function compareText(a, b) {
|
|
37
|
+
const n = Math.min(a.length, b.length);
|
|
38
|
+
for (let i = 0; i < n; i++) {
|
|
39
|
+
let x = a.charCodeAt(i), y = b.charCodeAt(i);
|
|
40
|
+
if (x === y) continue;
|
|
41
|
+
if (x >= 55296 && y >= 55296) {
|
|
42
|
+
x = x >= 57344 ? x - 2048 : x + 8192;
|
|
43
|
+
y = y >= 57344 ? y - 2048 : y + 8192;
|
|
44
|
+
}
|
|
45
|
+
return x - y;
|
|
46
|
+
}
|
|
47
|
+
return a.length - b.length;
|
|
48
|
+
}
|
|
49
|
+
function comparePaths(a, b) {
|
|
50
|
+
if (a === b) return 0;
|
|
51
|
+
const x = a.split(path.sep), y = b.split(path.sep);
|
|
52
|
+
const n = Math.min(x.length, y.length);
|
|
53
|
+
for (let i = 0; i < n; i++) {
|
|
54
|
+
if (x[i] === y[i]) continue;
|
|
55
|
+
return compareText(x[i], y[i]);
|
|
56
|
+
}
|
|
57
|
+
return x.length - y.length;
|
|
58
|
+
}
|
|
59
|
+
function walkFiles(dir) {
|
|
60
|
+
const out = [];
|
|
61
|
+
const walk = (d) => {
|
|
62
|
+
let entries;
|
|
63
|
+
try {
|
|
64
|
+
entries = fs.readdirSync(d, { withFileTypes: true });
|
|
65
|
+
} catch {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
for (const entry of entries) {
|
|
69
|
+
const p = path.join(d, entry.name);
|
|
70
|
+
if (entry.isDirectory()) walk(p);
|
|
71
|
+
else if (entry.isFile()) out.push(p);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
walk(dir);
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
function readFollowing(dir, above, onError) {
|
|
78
|
+
const out = [];
|
|
79
|
+
const here = above[above.length - 1] ?? realPath(dir);
|
|
80
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
81
|
+
const file = path.join(dir, entry.name);
|
|
82
|
+
if (!entry.isSymbolicLink()) {
|
|
83
|
+
out.push({ name: entry.name, path: file, isDirectory: entry.isDirectory(), isFile: entry.isFile(), real: path.join(here, entry.name) });
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const stat = fs.statSync(file, { throwIfNoEntry: false });
|
|
87
|
+
if (!stat) {
|
|
88
|
+
onError({ path: file, broken: true });
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const real = realPath(file);
|
|
92
|
+
if (stat.isDirectory()) {
|
|
93
|
+
const at = above.indexOf(real);
|
|
94
|
+
if (at !== -1) {
|
|
95
|
+
onError({ path: file, loop: above[at] });
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
out.push({ name: entry.name, path: file, isDirectory: stat.isDirectory(), isFile: stat.isFile(), real });
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
slashes,
|
|
106
|
+
displayPath,
|
|
107
|
+
shown,
|
|
108
|
+
relative,
|
|
109
|
+
joinAsGiven,
|
|
110
|
+
parentAsGiven,
|
|
111
|
+
realPath,
|
|
112
|
+
isFile,
|
|
113
|
+
isDir,
|
|
114
|
+
isInside,
|
|
115
|
+
compareText,
|
|
116
|
+
comparePaths,
|
|
117
|
+
walkFiles,
|
|
118
|
+
readFollowing
|
|
119
|
+
};
|
|
@@ -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-N5QTGQ5N.js";
|
|
6
|
+
import {
|
|
7
|
+
build
|
|
8
|
+
} from "./chunk-BOBPVAX2.js";
|
|
9
|
+
import "./chunk-4Q6WMTER.js";
|
|
10
|
+
import "./chunk-RI2L3VGO.js";
|
|
11
|
+
import "./chunk-3PHCFZEU.js";
|
|
12
|
+
import {
|
|
13
|
+
filesRead
|
|
14
|
+
} from "./chunk-3NYSSA2C.js";
|
|
15
|
+
import {
|
|
16
|
+
fileHash
|
|
17
|
+
} from "./chunk-KBGE5MCY.js";
|
|
18
|
+
import "./chunk-TN6EEDX2.js";
|
|
19
|
+
import "./chunk-IRHRK7XB.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-EIT4ZDT4.js";
|
|
28
|
+
import "./chunk-FVZ5JBRI.js";
|
|
29
|
+
import "./chunk-TDGBQNGW.js";
|
|
30
|
+
import "./chunk-UU43WIZG.js";
|
|
31
|
+
import {
|
|
32
|
+
describeThrown,
|
|
33
|
+
loadedFiles
|
|
34
|
+
} from "./chunk-C35KIPAR.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-6XYSFG6V.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
|
+
};
|