@johnhenry/sitefile 0.0.2 → 0.0.4
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/CHANGELOG.md +516 -0
- package/README.md +59 -9
- package/lib/src/archive-writers.d.ts +12 -2
- package/lib/src/archive-writers.js +53 -10
- package/lib/src/bake.d.ts +2 -0
- package/lib/src/bake.js +30 -1
- package/lib/src/bcrypt.d.ts +25 -0
- package/lib/src/bcrypt.js +201 -0
- package/lib/src/canonical.d.ts +19 -0
- package/lib/src/canonical.js +60 -0
- package/lib/src/car.d.ts +34 -0
- package/lib/src/car.js +203 -0
- package/lib/src/checklinks.js +8 -2
- package/lib/src/cli/bake.js +4 -3
- package/lib/src/cli/build-image.d.ts +1 -0
- package/lib/src/cli/build-image.js +1 -0
- package/lib/src/cli/common.js +4 -1
- package/lib/src/cli/hosts.d.ts +5 -0
- package/lib/src/cli/hosts.js +78 -0
- package/lib/src/cli/images.js +23 -5
- package/lib/src/cli/import-config.d.ts +2 -0
- package/lib/src/cli/import-config.js +56 -0
- package/lib/src/cli/index.d.ts +6 -1
- package/lib/src/cli/index.js +34 -2
- package/lib/src/cli/integrity.d.ts +2 -0
- package/lib/src/cli/integrity.js +77 -0
- package/lib/src/cli/network.d.ts +7 -0
- package/lib/src/cli/network.js +14 -3
- package/lib/src/cli/serve-keys.d.ts +39 -0
- package/lib/src/cli/serve-keys.js +106 -0
- package/lib/src/cli/serve-worker.js +119 -8
- package/lib/src/cli/servers.d.ts +130 -1
- package/lib/src/cli/servers.js +754 -72
- package/lib/src/cli/up.d.ts +2 -0
- package/lib/src/cli/up.js +193 -0
- package/lib/src/cli/watch.d.ts +14 -1
- package/lib/src/cli/watch.js +20 -3
- package/lib/src/cli.js +138 -18
- package/lib/src/csp.d.ts +17 -0
- package/lib/src/csp.js +52 -0
- package/lib/src/dictionary.d.ts +16 -0
- package/lib/src/dictionary.js +89 -0
- package/lib/src/epub.d.ts +5 -0
- package/lib/src/epub.js +113 -0
- package/lib/src/errors.d.ts +22 -9
- package/lib/src/errors.js +20 -1
- package/lib/src/executor.d.ts +31 -1
- package/lib/src/executor.js +231 -24
- package/lib/src/explain.js +33 -3
- package/lib/src/export-for.d.ts +42 -0
- package/lib/src/export-for.js +466 -0
- package/lib/src/export-formats.d.ts +2 -2
- package/lib/src/export-formats.js +52 -2
- package/lib/src/fingerprint.d.ts +3 -1
- package/lib/src/fingerprint.js +32 -5
- package/lib/src/host-config.d.ts +34 -0
- package/lib/src/host-config.js +645 -0
- package/lib/src/hosts.d.ts +47 -0
- package/lib/src/hosts.js +106 -0
- package/lib/src/hreflang.d.ts +25 -0
- package/lib/src/hreflang.js +72 -0
- package/lib/src/index.d.ts +1 -1
- package/lib/src/index.js +1 -1
- package/lib/src/integrity.d.ts +115 -0
- package/lib/src/integrity.js +273 -0
- package/lib/src/language/ast.d.ts +126 -3
- package/lib/src/language/ast.js +7 -1
- package/lib/src/language/parser.js +189 -7
- package/lib/src/language/validate.js +24 -0
- package/lib/src/links.d.ts +47 -0
- package/lib/src/links.js +289 -3
- package/lib/src/lint.d.ts +1 -1
- package/lib/src/lint.js +26 -1
- package/lib/src/mime-data.d.ts +2 -0
- package/lib/src/mime-data.js +92 -0
- package/lib/src/oci.d.ts +20 -2
- package/lib/src/oci.js +70 -28
- package/lib/src/outdated.d.ts +3 -0
- package/lib/src/outdated.js +4 -4
- package/lib/src/planner.d.ts +87 -2
- package/lib/src/planner.js +189 -8
- package/lib/src/plugins/cache.d.ts +11 -0
- package/lib/src/plugins/cache.js +29 -0
- package/lib/src/plugins/host.d.ts +51 -2
- package/lib/src/plugins/host.js +141 -16
- package/lib/src/plugins/wasm.js +1 -3
- package/lib/src/portable.d.ts +8 -0
- package/lib/src/portable.js +47 -0
- package/lib/src/precache.d.ts +33 -0
- package/lib/src/precache.js +75 -0
- package/lib/src/precompress.d.ts +19 -0
- package/lib/src/precompress.js +35 -0
- package/lib/src/qr.d.ts +18 -0
- package/lib/src/qr.js +372 -0
- package/lib/src/registry-ops.js +4 -2
- package/lib/src/reload-client.d.ts +2 -0
- package/lib/src/reload-client.js +419 -0
- package/lib/src/resources/archive.d.ts +37 -1
- package/lib/src/resources/archive.js +353 -71
- package/lib/src/resources/convert.js +3 -1
- package/lib/src/resources/https.d.ts +9 -1
- package/lib/src/resources/https.js +36 -0
- package/lib/src/resources/network.d.ts +25 -3
- package/lib/src/resources/network.js +77 -6
- package/lib/src/secrets.d.ts +12 -3
- package/lib/src/secrets.js +18 -5
- package/lib/src/serve-auth.d.ts +33 -0
- package/lib/src/serve-auth.js +120 -0
- package/lib/src/serve-rules.d.ts +83 -7
- package/lib/src/serve-rules.js +264 -53
- package/lib/src/server.d.ts +529 -11
- package/lib/src/server.js +1439 -57
- package/lib/src/servers-file.d.ts +36 -0
- package/lib/src/servers-file.js +101 -0
- package/lib/src/servers.d.ts +115 -7
- package/lib/src/servers.js +151 -29
- package/lib/src/single-file.d.ts +12 -0
- package/lib/src/single-file.js +147 -0
- package/lib/src/site.d.ts +58 -0
- package/lib/src/site.js +216 -5
- package/lib/src/store.js +9 -5
- package/lib/src/swbn.d.ts +10 -0
- package/lib/src/swbn.js +86 -0
- package/lib/src/toml.d.ts +17 -0
- package/lib/src/toml.js +323 -0
- package/lib/src/wacz.d.ts +6 -0
- package/lib/src/wacz.js +96 -0
- package/lib/src/warc.d.ts +28 -0
- package/lib/src/warc.js +252 -0
- package/lib/src/watch.d.ts +12 -1
- package/lib/src/watch.js +67 -1
- package/lib/src/wbn.d.ts +9 -1
- package/lib/src/wbn.js +23 -33
- package/lib/src/zstd.d.ts +4 -0
- package/lib/src/zstd.js +328 -0
- package/package.json +1 -1
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { SitefileError } from '../errors.js';
|
|
4
|
+
import { formatUrl } from '../server.js';
|
|
5
|
+
import { isRunning, ServerRegistry } from '../servers.js';
|
|
6
|
+
import { findServersFile, loadServersFile } from '../servers-file.js';
|
|
7
|
+
import { Store } from '../store.js';
|
|
8
|
+
import { requireArgs, str, table } from './common.js';
|
|
9
|
+
import { archiveSource, graceOf, isFile, parsePublish, resolveSource, restartDetached, serveDetached, stopServer } from './servers.js';
|
|
10
|
+
/** `^(\.\.?|~.*|\.\.?\/.*|\/.*|.*\/)$`, as serve: an argument that names a path. */
|
|
11
|
+
const PATH_LIKE = /^(\.\.?|~.*|\.\.?\/.*|\/.*|.*\/)$/;
|
|
12
|
+
/**
|
|
13
|
+
* A servers-file source: a path (`./dist`, `../site.zip`, `/abs`) relative to the file's directory; otherwise
|
|
14
|
+
* an image reference or ID, else an archive file by that name next to the file.
|
|
15
|
+
*/
|
|
16
|
+
async function fileSource(store, dir, src) {
|
|
17
|
+
if (PATH_LIKE.test(src))
|
|
18
|
+
return resolveSource(store, path.resolve(dir, src));
|
|
19
|
+
try {
|
|
20
|
+
return { label: src, source: { kind: 'image', imageId: await store.resolve(src) } };
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
const file = path.resolve(dir, src);
|
|
24
|
+
if (e instanceof SitefileError && e.code === 'E_NOT_FOUND' && (await isFile(file)))
|
|
25
|
+
return archiveSource(file);
|
|
26
|
+
throw e;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** The servers file and its real path (the `project` its servers are recorded with). */
|
|
30
|
+
async function open(v) {
|
|
31
|
+
const name = await findServersFile(str(v.file));
|
|
32
|
+
const file = await loadServersFile(name);
|
|
33
|
+
return { file, project: await fs.realpath(name) };
|
|
34
|
+
}
|
|
35
|
+
const sameSource = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
36
|
+
const warn = (m) => void process.stderr.write(`warning: ${m}\n`);
|
|
37
|
+
const FILE_FLAG = '-f, --file <path> servers file (default: sitefile.servers.yaml, .yml or .json here)';
|
|
38
|
+
const up = {
|
|
39
|
+
name: 'up',
|
|
40
|
+
summary: 'start the servers of a servers file (detached; idempotent)',
|
|
41
|
+
usage: 'up [-f sitefile.servers.yaml] [--time secs]',
|
|
42
|
+
description: "Start every server of the servers file in the background, as serve -d would, named by its key. Running again\nis safe: a server that is running with the same source, address and options is left alone, an exited one is\nrestarted, and one whose entry changed is replaced. Every source is checked before anything starts. A server\nwith the same name that this file did not start is refused (remove it with \"sitefile rm <name>\").",
|
|
43
|
+
flags: [FILE_FLAG, '--time <secs> grace period before SIGKILL when a server is replaced (default 5)'],
|
|
44
|
+
options: { file: { type: 'string', short: 'f' }, time: { type: 'string' } },
|
|
45
|
+
async run(v, pos) {
|
|
46
|
+
requireArgs(pos, 0, 0, 'no arguments');
|
|
47
|
+
const grace = graceOf(v);
|
|
48
|
+
const { file, project } = await open(v);
|
|
49
|
+
const store = await Store.open();
|
|
50
|
+
// Resolve everything first: a typo or a missing directory starts nothing.
|
|
51
|
+
const wanted = [];
|
|
52
|
+
for (const s of file.servers) {
|
|
53
|
+
let resolved;
|
|
54
|
+
try {
|
|
55
|
+
resolved = await fileSource(store, file.dir, s.source);
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
if (e instanceof SitefileError)
|
|
59
|
+
throw new SitefileError(e.code, `${file.label}: server '${s.name}': ${e.detail}`, e.span, { cause: e });
|
|
60
|
+
throw e;
|
|
61
|
+
}
|
|
62
|
+
wanted.push({ ...resolved, name: s.name, bind: parsePublishFor(file, s.name, s.publish), spa: s.spa, project });
|
|
63
|
+
}
|
|
64
|
+
const reg = await ServerRegistry.open(store);
|
|
65
|
+
const all = await reg.all();
|
|
66
|
+
for (const w of wanted) {
|
|
67
|
+
const other = all.find((s) => s.name === w.name && s.project !== project);
|
|
68
|
+
if (other)
|
|
69
|
+
throw new SitefileError('E_SERVER', `${file.label}: a server named '${w.name}' already exists and was not started from this file; remove it with "sitefile rm ${w.name}"`);
|
|
70
|
+
}
|
|
71
|
+
let failed = false;
|
|
72
|
+
for (const w of wanted) {
|
|
73
|
+
try {
|
|
74
|
+
const cur = all.find((s) => s.name === w.name);
|
|
75
|
+
if (cur && sameSource(cur.source, w.source) && cur.spa === w.spa && !cur.keepOsMetadata && cur.bind.host === w.bind.host && cur.bind.port === w.bind.port) {
|
|
76
|
+
if (await isRunning(cur)) {
|
|
77
|
+
process.stdout.write(`${cur.name} (${cur.id}) is up to date at ${formatUrl(cur.host, cur.port)}\n`);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const again = await restartDetached(reg, cur, grace);
|
|
81
|
+
process.stdout.write(`Restarted ${again.name} (${again.id}) serving ${again.image} at ${formatUrl(again.host, again.port)}\n`);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (cur) {
|
|
85
|
+
await stopServer(reg, cur, grace);
|
|
86
|
+
await reg.remove(cur.id);
|
|
87
|
+
}
|
|
88
|
+
const started = await serveDetached(reg, w, warn);
|
|
89
|
+
process.stdout.write(`${cur ? 'Recreated' : 'Started'} ${started.name} (${started.id}) serving ${w.label} at ${formatUrl(started.host, started.port)}\n`);
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
if (!(e instanceof SitefileError))
|
|
93
|
+
throw e;
|
|
94
|
+
process.stderr.write(`error[${e.code}]: ${w.name}: ${e.message}\n`);
|
|
95
|
+
failed = true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
for (const s of all) {
|
|
99
|
+
if (s.project === project && !wanted.some((w) => w.name === s.name)) {
|
|
100
|
+
process.stderr.write(`warning: ${s.name} was started from ${file.label} but is no longer in it; "sitefile down" stops it\n`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return failed ? 1 : 0;
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
function parsePublishFor(file, name, publish) {
|
|
107
|
+
try {
|
|
108
|
+
return parsePublish(publish);
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
if (e instanceof SitefileError)
|
|
112
|
+
throw new SitefileError('E_DATA', `${file.label}: server '${name}': publish: ${e.detail}`);
|
|
113
|
+
throw e;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/** The records this file started: its servers in file order, then any no longer in it (oldest first). */
|
|
117
|
+
function ofProject(all, file, project) {
|
|
118
|
+
const mine = all.filter((s) => s.project === project);
|
|
119
|
+
const named = file.servers.flatMap((s) => mine.filter((m) => m.name === s.name));
|
|
120
|
+
return [...named, ...mine.filter((m) => !named.includes(m))];
|
|
121
|
+
}
|
|
122
|
+
const down = {
|
|
123
|
+
name: 'down',
|
|
124
|
+
summary: 'stop and remove the servers a servers file started',
|
|
125
|
+
usage: 'down [-f sitefile.servers.yaml] [--time secs]',
|
|
126
|
+
description: 'Stop (SIGTERM, then SIGKILL after --time seconds) and remove every server that "sitefile up" started from the\nservers file, also ones no longer listed in it. Servers started otherwise are not touched.',
|
|
127
|
+
flags: [FILE_FLAG, '--time <secs> grace period before SIGKILL (default 5)'],
|
|
128
|
+
options: { file: { type: 'string', short: 'f' }, time: { type: 'string' } },
|
|
129
|
+
async run(v, pos) {
|
|
130
|
+
requireArgs(pos, 0, 0, 'no arguments');
|
|
131
|
+
const grace = graceOf(v);
|
|
132
|
+
const { file, project } = await open(v);
|
|
133
|
+
const reg = await ServerRegistry.open();
|
|
134
|
+
let failed = false;
|
|
135
|
+
for (const s of ofProject(await reg.all(), file, project)) {
|
|
136
|
+
try {
|
|
137
|
+
await stopServer(reg, s, grace);
|
|
138
|
+
await reg.remove(s.id);
|
|
139
|
+
process.stdout.write(`Removed ${s.name} (${s.id})\n`);
|
|
140
|
+
}
|
|
141
|
+
catch (e) {
|
|
142
|
+
if (!(e instanceof SitefileError))
|
|
143
|
+
throw e;
|
|
144
|
+
process.stderr.write(`error[${e.code}]: ${s.name}: ${e.message}\n`);
|
|
145
|
+
failed = true;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return failed ? 1 : 0;
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
const ps = {
|
|
152
|
+
name: 'ps',
|
|
153
|
+
summary: 'list the servers of a servers file',
|
|
154
|
+
usage: 'ps [-f sitefile.servers.yaml] [--json]',
|
|
155
|
+
description: 'List the servers of the servers file in file order: running, exited, or not created (never started by "sitefile up"),\nthen servers it started that are no longer listed in it.',
|
|
156
|
+
flags: [FILE_FLAG, '--json machine-readable output'],
|
|
157
|
+
options: { file: { type: 'string', short: 'f' }, json: { type: 'boolean' } },
|
|
158
|
+
async run(v, pos) {
|
|
159
|
+
requireArgs(pos, 0, 0, 'no arguments');
|
|
160
|
+
const { file, project } = await open(v);
|
|
161
|
+
const reg = await ServerRegistry.open();
|
|
162
|
+
const all = await reg.all();
|
|
163
|
+
const rows = [];
|
|
164
|
+
for (const s of file.servers) {
|
|
165
|
+
const rec = all.find((x) => x.name === s.name && x.project === project);
|
|
166
|
+
if (!rec) {
|
|
167
|
+
rows.push({ name: s.name, site: s.source, url: '', status: 'not created', id: null, listed: true });
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
const view = await reg.view(rec);
|
|
171
|
+
rows.push({ name: s.name, site: rec.image, url: view.url, status: view.status, id: rec.id, listed: true });
|
|
172
|
+
}
|
|
173
|
+
for (const rec of ofProject(all, file, project).filter((r) => !file.servers.some((s) => s.name === r.name))) {
|
|
174
|
+
const view = await reg.view(rec);
|
|
175
|
+
rows.push({ name: rec.name, site: rec.image, url: view.url, status: view.status, id: rec.id, listed: false });
|
|
176
|
+
}
|
|
177
|
+
if (v.json) {
|
|
178
|
+
process.stdout.write(JSON.stringify(rows, null, 2) + '\n');
|
|
179
|
+
return 0;
|
|
180
|
+
}
|
|
181
|
+
process.stdout.write(table([
|
|
182
|
+
['NAME', 'SITE', 'URL', 'STATUS', 'ID'],
|
|
183
|
+
...rows.map((r) => [r.name, r.site, r.url || '-', r.listed ? r.status : `${r.status} (not in the file)`, r.id ?? '-']),
|
|
184
|
+
]));
|
|
185
|
+
return 0;
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
export const upCommands = new Map([
|
|
189
|
+
['up', up],
|
|
190
|
+
['down', down],
|
|
191
|
+
['ps', ps],
|
|
192
|
+
]);
|
|
193
|
+
//# sourceMappingURL=up.js.map
|
package/lib/src/cli/watch.d.ts
CHANGED
|
@@ -14,9 +14,22 @@ export interface WatchLoopOptions {
|
|
|
14
14
|
readonly build: () => Promise<BuildOutcome>;
|
|
15
15
|
/** After the first build, before the "Watching" line (serve starts listening here). */
|
|
16
16
|
readonly onStarted?: () => Promise<void>;
|
|
17
|
-
/**
|
|
17
|
+
/** `--poll`: poll every this many milliseconds instead of using file system events. */
|
|
18
|
+
readonly pollMs?: number;
|
|
19
|
+
/** `serve --watch ./dir` without a Sitefile: the directory is re-read, not built (other messages). */
|
|
20
|
+
readonly plain?: boolean;
|
|
21
|
+
/** Resolves to stop the loop (default: SIGINT or SIGTERM). */
|
|
18
22
|
readonly stop?: Promise<void>;
|
|
23
|
+
/** Filled in with `rebuild()`: build again now, as if a file had changed (`serve --watch`, key `r`). */
|
|
24
|
+
readonly control?: {
|
|
25
|
+
rebuild?: () => void;
|
|
26
|
+
};
|
|
19
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* `--poll` / `--poll-interval <ms>` (the interval implies polling): the poll interval in
|
|
30
|
+
* milliseconds, or undefined for file system events. Throws E_USAGE for a bad interval.
|
|
31
|
+
*/
|
|
32
|
+
export declare function pollOption(poll: boolean | undefined, interval: string | undefined): number | undefined;
|
|
20
33
|
/**
|
|
21
34
|
* `build --watch` / `serve --watch`: build once, then rebuild whenever a file in the
|
|
22
35
|
* context, the Sitefile or a --build-arg-file changes (debounced; changes during a build
|
package/lib/src/cli/watch.js
CHANGED
|
@@ -2,9 +2,23 @@ import { promises as fs } from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { SitefileError } from '../errors.js';
|
|
4
4
|
import { resolveStoreHome } from '../store.js';
|
|
5
|
-
import { isIgnoredChange, RebuildScheduler, resolveReal, watchPaths } from '../watch.js';
|
|
5
|
+
import { DEFAULT_POLL_MS, isIgnoredChange, RebuildScheduler, resolveReal, watchPaths } from '../watch.js';
|
|
6
|
+
/**
|
|
7
|
+
* `--poll` / `--poll-interval <ms>` (the interval implies polling): the poll interval in
|
|
8
|
+
* milliseconds, or undefined for file system events. Throws E_USAGE for a bad interval.
|
|
9
|
+
*/
|
|
10
|
+
export function pollOption(poll, interval) {
|
|
11
|
+
if (interval === undefined)
|
|
12
|
+
return poll ? DEFAULT_POLL_MS : undefined;
|
|
13
|
+
const n = /^[0-9]{1,9}$/.test(interval) ? Number(interval) : NaN;
|
|
14
|
+
if (!(n >= 10))
|
|
15
|
+
throw new SitefileError('E_USAGE', `--poll-interval expects a whole number of milliseconds (10 or more), got '${interval}'`);
|
|
16
|
+
return n;
|
|
17
|
+
}
|
|
6
18
|
const MSG_CHANGE = 'Change detected, rebuilding\n';
|
|
7
19
|
const MSG_FAILED = 'Build failed; keeping the last good output\n';
|
|
20
|
+
const MSG_CHANGE_PLAIN = 'Change detected, re-reading\n';
|
|
21
|
+
const MSG_FAILED_PLAIN = 'Read failed; serving the last good copy\n';
|
|
8
22
|
function signalled() {
|
|
9
23
|
return new Promise((resolve) => {
|
|
10
24
|
process.once('SIGINT', () => resolve());
|
|
@@ -34,7 +48,7 @@ export async function watchLoop(o) {
|
|
|
34
48
|
if (!first) {
|
|
35
49
|
if (!changed.some(relevant))
|
|
36
50
|
return; // only our own writes
|
|
37
|
-
process.stdout.write(MSG_CHANGE);
|
|
51
|
+
process.stdout.write(o.plain ? MSG_CHANGE_PLAIN : MSG_CHANGE);
|
|
38
52
|
}
|
|
39
53
|
const r = await o.build();
|
|
40
54
|
for (const w of r.wrote ?? []) {
|
|
@@ -43,7 +57,7 @@ export async function watchLoop(o) {
|
|
|
43
57
|
}
|
|
44
58
|
if (!first) {
|
|
45
59
|
if (r.code !== 0)
|
|
46
|
-
process.stderr.write(MSG_FAILED);
|
|
60
|
+
process.stderr.write(o.plain ? MSG_FAILED_PLAIN : MSG_FAILED);
|
|
47
61
|
return;
|
|
48
62
|
}
|
|
49
63
|
first = false;
|
|
@@ -60,6 +74,8 @@ export async function watchLoop(o) {
|
|
|
60
74
|
}
|
|
61
75
|
process.stdout.write(`Watching ${o.context} for changes (Ctrl-C to stop)\n`);
|
|
62
76
|
});
|
|
77
|
+
if (o.control)
|
|
78
|
+
o.control.rebuild = () => scheduler.notify(sitefile);
|
|
63
79
|
const close = watchPaths({
|
|
64
80
|
dirs: [root],
|
|
65
81
|
files: [sitefile, ...argFiles],
|
|
@@ -67,6 +83,7 @@ export async function watchLoop(o) {
|
|
|
67
83
|
if (relevant(p))
|
|
68
84
|
scheduler.notify(p);
|
|
69
85
|
},
|
|
86
|
+
...(o.pollMs !== undefined ? { pollMs: o.pollMs, ignore: (p) => !relevant(p) } : {}),
|
|
70
87
|
});
|
|
71
88
|
void (o.stop ?? signalled()).then(() => finish(0));
|
|
72
89
|
try {
|