blogger-hbs 0.0.5 → 0.0.6
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 +5 -3
- package/dist/cli/index.js +164 -14
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,9 +29,11 @@ export default defineConfig({
|
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
```sh
|
|
32
|
-
blogger-hbs
|
|
33
|
-
blogger-hbs --watch
|
|
34
|
-
blogger-hbs
|
|
32
|
+
blogger-hbs # build to dist/theme.xml
|
|
33
|
+
blogger-hbs --watch # build again on changes
|
|
34
|
+
blogger-hbs validate theme.xml # validate a theme
|
|
35
|
+
blogger-hbs format theme.xml -o out.xml # format it
|
|
36
|
+
blogger-hbs --help # all the options
|
|
35
37
|
```
|
|
36
38
|
|
|
37
39
|
The same is available from JavaScript with `compileTemplate`, `watchTemplate` and `renderTemplate`.
|
package/dist/cli/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { CompileError } from "../compiler/errors.js";
|
|
|
2
2
|
import { withLocation } from "../plugins/index.js";
|
|
3
3
|
import { didYouMean } from "../utils/suggest.js";
|
|
4
4
|
import { COMPILE_OPTION_KEYS, assertCompileOptions, assertDirectories, assertEntry, resolvePaths } from "../compiler/options.js";
|
|
5
|
-
import { processXml } from "../xml/process.js";
|
|
5
|
+
import { XmlError, processXml } from "../xml/process.js";
|
|
6
6
|
import { compileTemplate } from "../compiler/compile.js";
|
|
7
7
|
import { watchTemplate } from "../compiler/watch.js";
|
|
8
8
|
import { loadConfig } from "../config.js";
|
|
@@ -14,13 +14,18 @@ import { watch } from "node:fs";
|
|
|
14
14
|
import { styleText } from "node:util";
|
|
15
15
|
import { cac } from "cac";
|
|
16
16
|
//#region src/cli/index.ts
|
|
17
|
-
const { version } = JSON.parse(await fs.readFile(new URL("../../package.json", import.meta.url), "utf-8"));
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
17
|
+
const { version, license, repository } = JSON.parse(await fs.readFile(new URL("../../package.json", import.meta.url), "utf-8"));
|
|
18
|
+
/** What the CLI prints, with `write`, warnings and errors on stderr. */
|
|
19
|
+
function logTo(write) {
|
|
20
|
+
return {
|
|
21
|
+
write,
|
|
22
|
+
success: (message) => write(`${styleText("green", "✓")} ${message}`),
|
|
23
|
+
info: (message) => write(`${styleText("cyan", "●")} ${message}`),
|
|
24
|
+
warn: (message) => console.warn(`${styleText("yellow", "⚠")} ${message}`),
|
|
25
|
+
error: (error) => console.error(`${styleText("red", "✗")} ${formatError(error)}`)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const log = logTo(console.log);
|
|
24
29
|
const cli = cac("blogger-hbs");
|
|
25
30
|
cli.command("[root]", "Compile the template and render it").alias("build").option("-c, --config <file>", "Path of the config file").option("--entry <file>", "Entry template, relative to the root").option("-o, --out-dir <dir>", "Output directory, relative to the root").option("--context <file>", "JSON file with the context to render with").option("-w, --watch", "Build again when a file changes").option("--no-clean", "Keep the files in the output directory").option("--no-validate", "Do not validate the rendered template as XML, nor format it (templates are always validated when compiling)").option("--no-format", "Do not format the rendered template").example("blogger-hbs").example("blogger-hbs --watch").example("blogger-hbs ./theme --entry src/index.hbs --context context.json").action(async (rootArg, rawFlags) => {
|
|
26
31
|
printHeader();
|
|
@@ -36,22 +41,45 @@ cli.command("[root]", "Compile the template and render it").alias("build").optio
|
|
|
36
41
|
if (flags.watch) await watchBuild(root, flags);
|
|
37
42
|
else await build(root, flags);
|
|
38
43
|
});
|
|
44
|
+
cli.command("validate <file>", "Validate a theme as Blogger reads it").option("--json", "Print the result as JSON").example("blogger-hbs validate dist/theme.xml").example("blogger-hbs validate dist/theme.xml --json").action(async (file, flags) => {
|
|
45
|
+
await processFile(String(file), {
|
|
46
|
+
format: false,
|
|
47
|
+
json: flags.json
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
cli.command("format <file>", "Format a theme as Blogger saves it, written to stdout, or to --out").option("-o, --out <file>", "Write it to this file instead of stdout").option("--json", "Print the result as JSON, the theme in it without --out").example("blogger-hbs format theme.xml").example("blogger-hbs format theme.xml -o theme.formatted.xml").action(async (file, flags) => {
|
|
51
|
+
const out = flags.out === void 0 ? void 0 : String(flags.out);
|
|
52
|
+
await processFile(String(file), {
|
|
53
|
+
format: true,
|
|
54
|
+
out,
|
|
55
|
+
json: flags.json
|
|
56
|
+
});
|
|
57
|
+
});
|
|
39
58
|
cli.help();
|
|
40
|
-
cli.version
|
|
59
|
+
cli.globalCommand.versionNumber = version;
|
|
60
|
+
cli.option("-v, --version", "Display the version, the copyright and the license");
|
|
61
|
+
/** Whether the header is printed, so that an error before a command runs prints it too. */
|
|
62
|
+
let headerPrinted = false;
|
|
41
63
|
try {
|
|
42
64
|
cli.parse(process.argv, { run: false });
|
|
43
|
-
|
|
65
|
+
if (cli.options.version) await printVersion();
|
|
66
|
+
else await cli.runMatchedCommand();
|
|
44
67
|
} catch (error) {
|
|
68
|
+
if (!headerPrinted && !cli.options.json) printHeader(formatsToStdout() ? console.error : console.log);
|
|
45
69
|
log.error(describeCliError(error));
|
|
46
70
|
process.exitCode = 1;
|
|
47
71
|
}
|
|
72
|
+
/** Whether the command formats a theme to stdout, which has nothing else on it. */
|
|
73
|
+
function formatsToStdout() {
|
|
74
|
+
return cli.matchedCommandName === "format" && cli.options.out === void 0;
|
|
75
|
+
}
|
|
48
76
|
/** Adds a suggestion and a pointer to `--help` to the errors of the arguments. */
|
|
49
77
|
function describeCliError(error) {
|
|
50
78
|
if (!(error instanceof Error) || error.name !== "CACError") return error;
|
|
51
79
|
const flags = [...cli.commands, cli.globalCommand].flatMap((command) => command.options.flatMap((option) => option.rawName.match(/--[\w-]+/g) ?? []));
|
|
52
80
|
const unknown = /^Unknown option `(.+)`$/.exec(error.message)?.[1];
|
|
53
81
|
const hint = unknown ? didYouMean(unknown, flags, "`") : "";
|
|
54
|
-
return /* @__PURE__ */ new Error(`${error.message}${hint}\nRun 'blogger-hbs --help' to see the available options`);
|
|
82
|
+
return /* @__PURE__ */ new Error(`${error.message}${hint}\nRun 'blogger-hbs ${cli.matchedCommandName ? `${cli.matchedCommandName} ` : ""}--help' to see the available options`);
|
|
55
83
|
}
|
|
56
84
|
async function setup(root, flags) {
|
|
57
85
|
const cwd = process.cwd();
|
|
@@ -352,13 +380,135 @@ async function writeTheme(current, compiled, templateFile) {
|
|
|
352
380
|
};
|
|
353
381
|
}
|
|
354
382
|
/**
|
|
383
|
+
* Validates the theme in `file`, and with `format` formats it, written to
|
|
384
|
+
* `out` or to stdout. Warnings are placed in what is written, errors in
|
|
385
|
+
* `file`, and nothing is written when it is not valid.
|
|
386
|
+
*/
|
|
387
|
+
async function processFile(file, { format, out, json }) {
|
|
388
|
+
if (json) {
|
|
389
|
+
const report = await reportOf(file, {
|
|
390
|
+
format,
|
|
391
|
+
out
|
|
392
|
+
});
|
|
393
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
394
|
+
if (!report.valid) process.exitCode = 1;
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
const toStdout = format && out === void 0;
|
|
398
|
+
const print = toStdout ? logTo(console.error) : log;
|
|
399
|
+
if (!toStdout) printHeader(print.write);
|
|
400
|
+
const start = performance.now();
|
|
401
|
+
const { result, written } = await processTheme(file, {
|
|
402
|
+
format,
|
|
403
|
+
out
|
|
404
|
+
});
|
|
405
|
+
for (const { message, loc } of result.warnings) print.warn(withLocation(message, loc));
|
|
406
|
+
if (!format) print.success(`Validated in ${elapsed(start)}`);
|
|
407
|
+
else if (out === void 0) process.stdout.write(result.xml);
|
|
408
|
+
else print.success(`Formatted in ${elapsed(start)}, written to ${written}`);
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Reads, processes and, with `out`, writes the theme in `file`. Its
|
|
412
|
+
* warnings and info are placed in what is written, and an error throws.
|
|
413
|
+
*/
|
|
414
|
+
async function processTheme(file, { format, out }) {
|
|
415
|
+
const shown = path.relative(process.cwd(), path.resolve(file));
|
|
416
|
+
const xml = await readTheme(file, shown);
|
|
417
|
+
let result;
|
|
418
|
+
try {
|
|
419
|
+
result = processXml(xml, {
|
|
420
|
+
path: shown,
|
|
421
|
+
format
|
|
422
|
+
});
|
|
423
|
+
} catch (error) {
|
|
424
|
+
throw new Error(`${shown} is not valid XML`, { cause: error });
|
|
425
|
+
}
|
|
426
|
+
const written = !format ? shown : out === void 0 ? "<stdout>" : path.relative(process.cwd(), path.resolve(out));
|
|
427
|
+
const at = (item) => ({
|
|
428
|
+
...item,
|
|
429
|
+
loc: {
|
|
430
|
+
...item.loc,
|
|
431
|
+
path: written
|
|
432
|
+
}
|
|
433
|
+
});
|
|
434
|
+
result = {
|
|
435
|
+
...result,
|
|
436
|
+
warnings: result.warnings.map(at),
|
|
437
|
+
info: {
|
|
438
|
+
...result.info,
|
|
439
|
+
sections: result.info.sections.map(at),
|
|
440
|
+
widgets: result.info.widgets.map(at)
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
if (format && out !== void 0) {
|
|
444
|
+
await fs.mkdir(path.dirname(path.resolve(out)), { recursive: true });
|
|
445
|
+
await fs.writeFile(out, result.xml);
|
|
446
|
+
}
|
|
447
|
+
return {
|
|
448
|
+
result,
|
|
449
|
+
written
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
async function reportOf(file, { format, out }) {
|
|
453
|
+
try {
|
|
454
|
+
const { result, written } = await processTheme(file, {
|
|
455
|
+
format,
|
|
456
|
+
out
|
|
457
|
+
});
|
|
458
|
+
return {
|
|
459
|
+
valid: true,
|
|
460
|
+
warnings: result.warnings,
|
|
461
|
+
info: result.info,
|
|
462
|
+
...format && out === void 0 && { xml: result.xml },
|
|
463
|
+
...format && out !== void 0 && { written }
|
|
464
|
+
};
|
|
465
|
+
} catch (error) {
|
|
466
|
+
const cause = error instanceof Error ? error.cause : void 0;
|
|
467
|
+
return {
|
|
468
|
+
valid: false,
|
|
469
|
+
errors: cause instanceof XmlError ? [...cause.errors] : [{ message: messageOf(error) }]
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
/** The message of an error and of what caused it, on one line. */
|
|
474
|
+
function messageOf(error) {
|
|
475
|
+
const messages = [];
|
|
476
|
+
for (let current = error; current !== void 0;) {
|
|
477
|
+
messages.push(current instanceof Error ? current.message : String(current));
|
|
478
|
+
current = current instanceof Error ? current.cause : void 0;
|
|
479
|
+
}
|
|
480
|
+
return messages.join(": ");
|
|
481
|
+
}
|
|
482
|
+
/** The text of the theme in `file`, an error saying so when it can not be read. */
|
|
483
|
+
async function readTheme(file, shown) {
|
|
484
|
+
try {
|
|
485
|
+
return await fs.readFile(file, "utf-8");
|
|
486
|
+
} catch (error) {
|
|
487
|
+
throw new Error(`Can not read ${shown}`, { cause: error });
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
/** The version, the copyright and the license, where the project is, and the runtime. */
|
|
491
|
+
async function printVersion() {
|
|
492
|
+
printHeader();
|
|
493
|
+
const notice = await fs.readFile(new URL("../../LICENSE.md", import.meta.url), "utf-8").catch(() => "");
|
|
494
|
+
const copyright = /^Copyright .*$/m.exec(notice)?.[0];
|
|
495
|
+
console.log([
|
|
496
|
+
copyright,
|
|
497
|
+
`Released under the ${license} License, provided as is, without warranty.`,
|
|
498
|
+
repository.url,
|
|
499
|
+
"",
|
|
500
|
+
`Node.js ${process.version} on ${process.platform}-${process.arch}`
|
|
501
|
+
].filter((line) => line !== void 0).join("\n"));
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
355
504
|
* A blank line, `blogger-hbs v0.0.4` right-aligned on a cyan line under it,
|
|
356
|
-
* before what a
|
|
505
|
+
* before what a command prints, with `write`.
|
|
357
506
|
*/
|
|
358
|
-
function printHeader() {
|
|
507
|
+
function printHeader(write = console.log) {
|
|
508
|
+
headerPrinted = true;
|
|
359
509
|
const text = `blogger-hbs v${version}`;
|
|
360
510
|
const width = text.length + 2;
|
|
361
|
-
|
|
511
|
+
write(`\n${" ".repeat(width - text.length)}${styleText("bold", "blogger-hbs")} ${styleText("dim", `v${version}`)}\n${styleText("cyan", "─".repeat(width))}`);
|
|
362
512
|
}
|
|
363
513
|
function elapsed(start) {
|
|
364
514
|
return styleText("yellow", `${Math.round(performance.now() - start)}ms`);
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/cli/index.ts"],"sourcesContent":["import { type FSWatcher, watch } from 'node:fs';\nimport * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { styleText } from 'node:util';\nimport { cac } from 'cac';\nimport {\n\ttype CompiledTemplate,\n\tCompileError,\n\ttype CompileTemplateOptions,\n\tcompileTemplate,\n\ttype TemplateWatcher,\n\twatchTemplate,\n} from '../compiler';\nimport {\n\tassertCompileOptions,\n\tassertDirectories,\n\tassertEntry,\n\tCOMPILE_OPTION_KEYS,\n\tresolvePaths,\n} from '../compiler/options';\nimport { type LoadedConfig, loadConfig } from '../config';\nimport { withLocation } from '../plugins';\nimport { createRenderer } from '../runtime';\nimport { didYouMean } from '../utils/suggest';\nimport {\n\tprocessXml,\n\ttype XmlError,\n\ttype XmlInfo,\n\ttype XmlResult,\n} from '../xml';\nimport {\n\ttype BuildStats,\n\tcollectStats,\n\tformatStats,\n\ttype WrittenFile,\n} from './stats';\n\nconst { version } = JSON.parse(\n\tawait fs.readFile(new URL('../../package.json', import.meta.url), 'utf-8'),\n) as { version: string };\n\ninterface BuildFlags {\n\tconfig?: string;\n\tentry?: string;\n\toutDir?: string;\n\tcontext?: string;\n\twatch?: boolean;\n\tclean?: boolean;\n\tvalidate?: boolean;\n\tformat?: boolean;\n}\n\n/** Everything a build needs, from the config file and the flags. */\ninterface BuildSetup {\n\toptions: CompileTemplateOptions;\n\tloaded: LoadedConfig;\n\toutDir: string;\n\tmoduleFile: string | false;\n\ttemplateFile: string | false;\n\tclean: boolean;\n\tcontext: unknown;\n\t/** Whether the rendered template is validated. */\n\tvalidate: boolean;\n\t/** Whether the rendered template is formatted, only when it is validated. */\n\tformat: boolean;\n\t/** Absolute path of the public directory, undefined when nothing is copied. */\n\tpublicDir?: string;\n\t/** Sizes of the files written last, by path, to show their changes when watching. */\n\tsizes: Map<string, number>;\n\t/** What the theme was made of at the last build, when watching. */\n\ttheme?: BuildStats['theme'];\n}\n\nconst log = {\n\tsuccess: (message: string) =>\n\t\tconsole.log(`${styleText('green', '✓')} ${message}`),\n\tinfo: (message: string) =>\n\t\tconsole.log(`${styleText('cyan', '●')} ${message}`),\n\twarn: (message: string) =>\n\t\tconsole.warn(`${styleText('yellow', '⚠')} ${message}`),\n\terror: (error: unknown) =>\n\t\tconsole.error(`${styleText('red', '✗')} ${formatError(error)}`),\n};\n\nconst cli = cac('blogger-hbs');\n\ncli\n\t.command('[root]', 'Compile the template and render it')\n\t.alias('build')\n\t.option('-c, --config <file>', 'Path of the config file')\n\t.option('--entry <file>', 'Entry template, relative to the root')\n\t.option('-o, --out-dir <dir>', 'Output directory, relative to the root')\n\t.option('--context <file>', 'JSON file with the context to render with')\n\t.option('-w, --watch', 'Build again when a file changes')\n\t.option('--no-clean', 'Keep the files in the output directory')\n\t.option(\n\t\t'--no-validate',\n\t\t'Do not validate the rendered template as XML, nor format it (templates are always validated when compiling)',\n\t)\n\t.option('--no-format', 'Do not format the rendered template')\n\t.example('blogger-hbs')\n\t.example('blogger-hbs --watch')\n\t.example('blogger-hbs ./theme --entry src/index.hbs --context context.json')\n\t.action(async (rootArg: unknown, rawFlags: BuildFlags) => {\n\t\tprintHeader();\n\t\t// cac turns values that look like numbers into numbers, `-o 2024`\n\t\tconst text = (value: unknown) =>\n\t\t\tvalue === undefined ? undefined : String(value);\n\t\tconst root = text(rootArg);\n\t\tconst flags: BuildFlags = {\n\t\t\t...rawFlags,\n\t\t\tconfig: text(rawFlags.config),\n\t\t\tentry: text(rawFlags.entry),\n\t\t\toutDir: text(rawFlags.outDir),\n\t\t\tcontext: text(rawFlags.context),\n\t\t};\n\n\t\tif (flags.watch) {\n\t\t\tawait watchBuild(root, flags);\n\t\t} else {\n\t\t\tawait build(root, flags);\n\t\t}\n\t});\n\ncli.help();\ncli.version(version);\n\ntry {\n\tcli.parse(process.argv, { run: false });\n\tawait cli.runMatchedCommand();\n} catch (error) {\n\tlog.error(describeCliError(error));\n\tprocess.exitCode = 1;\n}\n\n/** Adds a suggestion and a pointer to `--help` to the errors of the arguments. */\nfunction describeCliError(error: unknown): unknown {\n\tif (!(error instanceof Error) || error.name !== 'CACError') {\n\t\treturn error;\n\t}\n\n\tconst flags = [...cli.commands, cli.globalCommand].flatMap((command) =>\n\t\tcommand.options.flatMap(\n\t\t\t(option) => option.rawName.match(/--[\\w-]+/g) ?? [],\n\t\t),\n\t);\n\tconst unknown = /^Unknown option `(.+)`$/.exec(error.message)?.[1];\n\tconst hint = unknown ? didYouMean(unknown, flags, '`') : '';\n\n\treturn new Error(\n\t\t`${error.message}${hint}\\nRun 'blogger-hbs --help' to see the available options`,\n\t);\n}\n\nasync function setup(\n\troot: string | undefined,\n\tflags: BuildFlags,\n): Promise<BuildSetup> {\n\tconst cwd = process.cwd();\n\tconst rootFlag = root === undefined ? undefined : path.resolve(cwd, root);\n\n\t// the config is looked for in the root, which has to exist for that\n\tif (rootFlag !== undefined && !(await isDirectory(rootFlag))) {\n\t\tthrow new CompileError(\n\t\t\t(await exists(rootFlag))\n\t\t\t\t? `Root '${root}' is not a directory`\n\t\t\t\t: `Root directory '${root}' does not exist`,\n\t\t);\n\t}\n\n\tconst loaded = await loadConfig({\n\t\tcwd: rootFlag ?? cwd,\n\t\tconfigFile: flags.config && path.resolve(cwd, flags.config),\n\t\twatch: flags.watch,\n\t});\n\tconst { config } = loaded;\n\n\tconst resolvedRoot = rootFlag ?? config.root ?? cwd;\n\tconst output = config.output ?? {};\n\n\t// the config has more than the compile options\n\tconst options: CompileTemplateOptions = {};\n\tfor (const key of COMPILE_OPTION_KEYS) {\n\t\tif (key in config) {\n\t\t\tObject.assign(options, { [key]: config[key as keyof typeof config] });\n\t\t}\n\t}\n\toptions.root = resolvedRoot;\n\toptions.entry = flags.entry ?? config.entry;\n\toptions.onWarn ??= log.warn;\n\n\tassertCompileOptions(options);\n\tawait assertDirectories(options);\n\n\tconst outDir = path.resolve(\n\t\tresolvedRoot,\n\t\tflags.outDir ?? output.dir ?? 'dist',\n\t);\n\tconst clean = flags.clean === false ? false : (output.clean ?? true);\n\tif (clean) {\n\t\tassertCleanable(outDir, options);\n\t}\n\n\treturn {\n\t\toptions,\n\t\tloaded,\n\t\toutDir,\n\t\tmoduleFile: output.module ?? 'compiled.js',\n\t\ttemplateFile: output.template ?? 'theme.xml',\n\t\tvalidate: flags.validate === false ? false : (output.validate ?? true),\n\t\tformat: flags.format === false ? false : (output.format ?? true),\n\t\tclean,\n\t\tcontext: flags.context\n\t\t\t? await readContext(path.resolve(cwd, flags.context), flags.context)\n\t\t\t: (config.context ?? {}),\n\t\tpublicDir: await resolvePublicDir(resolvedRoot, config.publicDir, outDir),\n\t\tsizes: new Map(),\n\t};\n}\n\n/** The public directory, `public` when it exists unless set otherwise. */\nasync function resolvePublicDir(\n\troot: string,\n\tvalue: string | false | undefined,\n\toutDir: string,\n): Promise<string | undefined> {\n\tif (value === false) {\n\t\treturn;\n\t}\n\n\tconst directory = path.resolve(root, value ?? 'public');\n\tconst shown = path.relative(process.cwd(), directory) || '.';\n\n\tif (!(await isDirectory(directory))) {\n\t\tif (value === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tthrow new CompileError(\n\t\t\t(await exists(directory))\n\t\t\t\t? `Public directory '${shown}' is not a directory`\n\t\t\t\t: `Public directory '${shown}' does not exist, set 'publicDir: false' to not copy anything`,\n\t\t);\n\t}\n\n\tif (isInside(outDir, directory) || isInside(directory, outDir)) {\n\t\tthrow new CompileError(\n\t\t\t`Public directory '${shown}' and output directory '${path.relative(process.cwd(), outDir) || '.'}' overlap, they must be separate`,\n\t\t);\n\t}\n\n\treturn directory;\n}\n\n/** Copies the public directory into the output directory. */\nasync function copyPublic({\n\tpublicDir,\n\toutDir,\n\tmoduleFile,\n\ttemplateFile,\n}: BuildSetup): Promise<void> {\n\tif (publicDir === undefined) {\n\t\treturn;\n\t}\n\n\tfor (const name of await fs.readdir(publicDir)) {\n\t\tif (name === moduleFile || name === templateFile) {\n\t\t\tthrow new CompileError(\n\t\t\t\t`'${name}' in the public directory has the same name as the ${name === moduleFile ? 'compiled module' : 'rendered template'} and would be overwritten, rename it or set 'output.${name === moduleFile ? 'module' : 'template'}'`,\n\t\t\t);\n\t\t}\n\t}\n\n\tawait fs.cp(publicDir, outDir, { recursive: true, force: true });\n}\n\n/**\n * Cleaning removes everything in the output directory, which must not hold the\n * project: the root, the working directory, the templates or an alias target.\n */\nfunction assertCleanable(outDir: string, options: CompileTemplateOptions) {\n\tconst { root, entry } = resolvePaths(options);\n\tconst shown = path.relative(process.cwd(), outDir) || '.';\n\tconst kept: [string, string][] = [\n\t\t[root, 'the root'],\n\t\t[process.cwd(), 'the working directory'],\n\t\t[path.dirname(entry), 'the entry template'],\n\t\t...Object.entries(options.alias ?? {}).map(\n\t\t\t([name, target]): [string, string] => [\n\t\t\t\tpath.resolve(root, target),\n\t\t\t\t`the target of the alias '${name}'`,\n\t\t\t],\n\t\t),\n\t];\n\n\tfor (const [directory, what] of kept) {\n\t\tif (isInside(directory, outDir)) {\n\t\t\tthrow new CompileError(\n\t\t\t\t`Refusing to clean the output directory '${shown}', it contains ${what}. Use another output directory, or --no-clean / 'output.clean: false' to keep its files`,\n\t\t\t);\n\t\t}\n\t}\n}\n\nasync function readContext(file: string, shown: string): Promise<unknown> {\n\tlet text: string;\n\ttry {\n\t\ttext = await fs.readFile(file, 'utf-8');\n\t} catch (cause) {\n\t\tif ((cause as NodeJS.ErrnoException).code === 'ENOENT') {\n\t\t\tthrow new CompileError(`Context file '${shown}' not found`);\n\t\t}\n\t\tthrow new CompileError(`Failed to read the context file '${shown}'`, {\n\t\t\tcause,\n\t\t});\n\t}\n\n\ttry {\n\t\treturn JSON.parse(text);\n\t} catch (cause) {\n\t\tthrow new CompileError(\n\t\t\t`Context file '${shown}' is not valid JSON: ${(cause as Error).message}`,\n\t\t);\n\t}\n}\n\n/** Whether `child` is `parent` or inside of it. */\nfunction isInside(child: string, parent: string): boolean {\n\tconst relative = path.relative(parent, child);\n\treturn (\n\t\trelative === '' ||\n\t\t(!relative.startsWith('..') && !path.isAbsolute(relative))\n\t);\n}\n\nasync function exists(file: string): Promise<boolean> {\n\treturn fs.stat(file).then(\n\t\t() => true,\n\t\t() => false,\n\t);\n}\n\nasync function isDirectory(file: string): Promise<boolean> {\n\treturn fs.stat(file).then(\n\t\t(stats) => stats.isDirectory(),\n\t\t() => false,\n\t);\n}\n\nasync function build(root: string | undefined, flags: BuildFlags) {\n\tconst current = await setup(root, flags);\n\t// nothing is written when there is nothing to build, the watcher waits\n\t// for the entry instead\n\tawait assertEntry(current.options);\n\tawait prepareOutDir(current);\n\tawait copyPublic(current);\n\n\tconst start = performance.now();\n\tconst compiled = await compileTemplate(current.options);\n\tlog.success(`Compiled in ${elapsed(start)}`);\n\n\tawait write(current, compiled, start);\n}\n\n/** Watches the template and restarts when the config file changes. */\nasync function watchBuild(root: string | undefined, flags: BuildFlags) {\n\tlet current = await setup(root, flags);\n\tawait prepareOutDir(current);\n\n\tlet watcher: TemplateWatcher | undefined;\n\tlet watchers: FSWatcher[] = [];\n\tlet restarting = false;\n\n\tconst start = async () => {\n\t\tlet begin = performance.now();\n\t\tlet first = true;\n\t\t/** Shown before what a rebuild prints, after the first build. */\n\t\tlet divider = '';\n\n\t\t/** Once, before the first thing a rebuild prints, its output can be the same. */\n\t\tconst printDivider = () => {\n\t\t\tif (divider) {\n\t\t\t\tconsole.log(divider);\n\t\t\t\tdivider = '';\n\t\t\t}\n\t\t};\n\n\t\ttry {\n\t\t\tawait copyPublic(current);\n\t\t} catch (error) {\n\t\t\tlog.error(error);\n\t\t}\n\n\t\twatcher = await watchTemplate({\n\t\t\t...current.options,\n\t\t\tonStart({ files }) {\n\t\t\t\tbegin = performance.now();\n\t\t\t\tdivider = first ? '' : formatDivider(files);\n\t\t\t},\n\t\t\tasync onCompile(compiled) {\n\t\t\t\tprintDivider();\n\t\t\t\tlog.success(`${first ? 'Compiled' : 'Rebuilt'} in ${elapsed(begin)}`);\n\t\t\t\tawait write(current, compiled, begin);\n\t\t\t\tfirst = false;\n\t\t\t},\n\t\t\tonError(error) {\n\t\t\t\tprintDivider();\n\t\t\t\tlog.error(error);\n\t\t\t},\n\t\t});\n\n\t\tfor (const file of current.loaded.dependencies) {\n\t\t\ttry {\n\t\t\t\tconst configWatcher = watch(file, () => {\n\t\t\t\t\t// saving fires more than once, a restart is enough\n\t\t\t\t\tif (!restarting) {\n\t\t\t\t\t\trestarting = true;\n\t\t\t\t\t\trestart().finally(() => {\n\t\t\t\t\t\t\trestarting = false;\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tconfigWatcher.on('error', () => configWatcher.close());\n\t\t\t\twatchers.push(configWatcher);\n\t\t\t} catch {\n\t\t\t\t// a dependency that can not be watched does not restart\n\t\t\t}\n\t\t}\n\n\t\tif (current.publicDir !== undefined) {\n\t\t\twatchers.push(watchPublic(current));\n\t\t}\n\t};\n\n\tconst stopWatchers = () => {\n\t\tfor (const fileWatcher of watchers) {\n\t\t\tfileWatcher.close();\n\t\t}\n\t\twatchers = [];\n\t};\n\n\tconst restart = async () => {\n\t\tlog.info(\n\t\t\t`Config changed, restarting ${styleText('dim', path.relative(process.cwd(), current.loaded.file ?? ''))}`,\n\t\t);\n\t\tstopWatchers();\n\t\tawait watcher?.close();\n\t\ttry {\n\t\t\tcurrent = await setup(root, flags);\n\t\t} catch (error) {\n\t\t\tlog.error(error);\n\t\t}\n\t\tawait start();\n\t};\n\n\tawait start();\n\tlog.info(\n\t\t`Watching for changes ${styleText('dim', '(press Ctrl+C to stop)')}`,\n\t);\n\n\tconst stop = async () => {\n\t\tstopWatchers();\n\t\tawait watcher?.close();\n\t\t// the process ends once nothing is left running: `process.exit` would skip\n\t\t// the cleanup of rspack's native bindings, which then warn about leaks,\n\t\t// so it is only a fallback for something left running, a plugin's timer\n\t\tsetTimeout(() => process.exit(0), 3000).unref();\n\t};\n\tprocess.once('SIGINT', stop);\n\tprocess.once('SIGTERM', stop);\n}\n\n/** Copies the public directory again when something in it changes. */\nfunction watchPublic(current: BuildSetup): FSWatcher {\n\tconst publicDir = current.publicDir as string;\n\tconst changed = new Set<string>();\n\tlet timer: NodeJS.Timeout | undefined;\n\n\tconst sync = async () => {\n\t\tconst names = [...changed];\n\t\tchanged.clear();\n\t\ttry {\n\t\t\t// what was deleted from the public directory goes from the output too\n\t\t\tfor (const name of names) {\n\t\t\t\tif (!(await exists(path.join(publicDir, name)))) {\n\t\t\t\t\tawait fs.rm(path.join(current.outDir, name), {\n\t\t\t\t\t\trecursive: true,\n\t\t\t\t\t\tforce: true,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait copyPublic(current);\n\t\t\tlog.success(\n\t\t\t\t`Copied ${styleText('dim', path.relative(process.cwd(), publicDir))}`,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tlog.error(error);\n\t\t}\n\t};\n\n\tconst publicWatcher = watch(\n\t\tpublicDir,\n\t\t{ recursive: true },\n\t\t(_event, name) => {\n\t\t\tif (name) {\n\t\t\t\tchanged.add(name);\n\t\t\t}\n\t\t\tclearTimeout(timer);\n\t\t\ttimer = setTimeout(sync, 50);\n\t\t},\n\t);\n\tpublicWatcher.on('error', () => publicWatcher.close());\n\tpublicWatcher.on('close', () => clearTimeout(timer));\n\treturn publicWatcher;\n}\n\nasync function prepareOutDir({ outDir, clean }: BuildSetup) {\n\tif (clean) {\n\t\tawait fs.rm(outDir, { recursive: true, force: true });\n\t}\n\tawait fs.mkdir(outDir, { recursive: true });\n}\n\n/**\n * Writes the compiled module and the rendered template, validated and\n * formatted after rendering when enabled.\n */\nasync function write(\n\tcurrent: BuildSetup,\n\tcompiled: CompiledTemplate,\n\tbegin: number,\n) {\n\tconst { outDir, moduleFile, templateFile } = current;\n\tconst written: WrittenFile[] = [];\n\tlet theme: WrittenTheme | undefined;\n\n\tif (moduleFile) {\n\t\tconst file = path.join(outDir, moduleFile);\n\t\tawait fs.writeFile(file, compiled.source);\n\t\twritten.push({\n\t\t\tpath: path.relative(process.cwd(), file),\n\t\t\tcontent: compiled.source,\n\t\t});\n\t}\n\tif (templateFile) {\n\t\ttheme = await writeTheme(current, compiled, templateFile);\n\t\twritten.unshift(theme.file);\n\t}\n\n\tconst stats = await collectStats(\n\t\tcompiled,\n\t\twritten,\n\t\ttheme?.info && { ...theme.file, info: theme.info },\n\t);\n\tconsole.log(\n\t\tformatStats(stats, current.sizes, { previousTheme: current.theme }),\n\t);\n\tcurrent.sizes = new Map(stats.files.map(({ path, size }) => [path, size]));\n\tcurrent.theme = stats.theme;\n\tlog.success(`Built in ${elapsed(begin)}`);\n}\n\n/** `─── 14:32:05 · src/header.hbs +2 ───────`, dim. */\nfunction formatDivider(files: readonly string[]): string {\n\tconst time = new Date().toLocaleTimeString('en-GB', { hour12: false });\n\tconst [file, ...others] = files.map((item) =>\n\t\tpath.relative(process.cwd(), item),\n\t);\n\tconst what = file\n\t\t? ` · ${file}${others.length > 0 ? ` +${others.length}` : ''}`\n\t\t: '';\n\tconst text = `─── ${time}${what} `;\n\treturn `\\n${styleText('dim', text + '─'.repeat(Math.max(3, 50 - text.length)))}`;\n}\n\ninterface WrittenTheme {\n\tfile: WrittenFile;\n\t/** What it is made of, when it is validated. */\n\tinfo?: XmlInfo;\n}\n\n/** Renders, validates and formats the theme, as enabled, and writes it. */\nasync function writeTheme(\n\tcurrent: BuildSetup,\n\tcompiled: CompiledTemplate,\n\ttemplateFile: string,\n): Promise<WrittenTheme> {\n\tconst { outDir, context } = current;\n\tconst file = path.join(outDir, templateFile);\n\tconst shown = path.relative(process.cwd(), file);\n\n\t// the same as anywhere else the compiled module is rendered\n\tlet start = performance.now();\n\tconst renderer = createRenderer(compiled);\n\tconst rendered = await renderer.render(context);\n\tlog.success(`Rendered in ${elapsed(start)}`);\n\n\tif (!current.validate) {\n\t\tawait fs.writeFile(file, rendered);\n\t\treturn { file: { path: shown, content: rendered } };\n\t}\n\n\tstart = performance.now();\n\tlet result: XmlResult;\n\ttry {\n\t\tresult = processXml(rendered, { path: shown, format: current.format });\n\t} catch (error) {\n\t\t// written anyway, to look at where it is invalid\n\t\tawait fs.writeFile(file, rendered);\n\t\tthrow new CompileError('The rendered template is not valid XML', {\n\t\t\tcause: error,\n\t\t\tloc: (error as XmlError).loc,\n\t\t});\n\t}\n\tfor (const { message, loc } of result.warnings) {\n\t\tlog.warn(withLocation(message, loc));\n\t}\n\tlog.success(\n\t\t`${current.format ? 'Formatted' : 'Validated'} in ${elapsed(start)}`,\n\t);\n\n\tawait fs.writeFile(file, result.xml);\n\treturn { file: { path: shown, content: result.xml }, info: result.info };\n}\n\n/**\n * A blank line, `blogger-hbs v0.0.4` right-aligned on a cyan line under it,\n * before what a build prints.\n */\nfunction printHeader(): void {\n\tconst text = `blogger-hbs v${version}`;\n\tconst width = text.length + 2;\n\tconsole.log(\n\t\t`\\n${' '.repeat(width - text.length)}${styleText('bold', 'blogger-hbs')} ${styleText('dim', `v${version}`)}\\n${styleText('cyan', '─'.repeat(width))}`,\n\t);\n}\n\nfunction elapsed(start: number): string {\n\treturn styleText('yellow', `${Math.round(performance.now() - start)}ms`);\n}\n\n/**\n * The message of the error and of everything that caused it, a cause whose\n * message is already in the one before is not repeated. The lines of a\n * message are indented under its first.\n */\nfunction formatError(error: unknown): string {\n\tconst lines: string[] = [];\n\tlet previous = '';\n\tlet current: unknown = error;\n\n\twhile (current !== undefined) {\n\t\tconst message =\n\t\t\tcurrent instanceof Error ? current.message : String(current);\n\t\tif (lines.length === 0 || !previous.includes(message)) {\n\t\t\tlines.push(\n\t\t\t\t`${lines.length === 0 ? '' : 'Caused by: '}${message.replaceAll('\\n', '\\n ')}`,\n\t\t\t);\n\t\t}\n\t\tprevious = message;\n\t\tcurrent = current instanceof Error ? current.cause : undefined;\n\t}\n\n\treturn lines.join('\\n ');\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,MAAM,EAAE,YAAY,KAAK,MACxB,MAAM,GAAG,SAAS,IAAI,IAAI,sBAAsB,YAAY,GAAG,GAAG,OAAO,CAC1E;AAkCA,MAAM,MAAM;CACX,UAAU,YACT,QAAQ,IAAI,GAAG,UAAU,SAAS,GAAG,EAAE,GAAG,SAAS;CACpD,OAAO,YACN,QAAQ,IAAI,GAAG,UAAU,QAAQ,GAAG,EAAE,GAAG,SAAS;CACnD,OAAO,YACN,QAAQ,KAAK,GAAG,UAAU,UAAU,GAAG,EAAE,GAAG,SAAS;CACtD,QAAQ,UACP,QAAQ,MAAM,GAAG,UAAU,OAAO,GAAG,EAAE,GAAG,YAAY,KAAK,GAAG;AAChE;AAEA,MAAM,MAAM,IAAI,aAAa;AAE7B,IACE,QAAQ,UAAU,oCAAoC,CAAC,CACvD,MAAM,OAAO,CAAC,CACd,OAAO,uBAAuB,yBAAyB,CAAC,CACxD,OAAO,kBAAkB,sCAAsC,CAAC,CAChE,OAAO,uBAAuB,wCAAwC,CAAC,CACvE,OAAO,oBAAoB,2CAA2C,CAAC,CACvE,OAAO,eAAe,iCAAiC,CAAC,CACxD,OAAO,cAAc,wCAAwC,CAAC,CAC9D,OACA,iBACA,6GACD,CAAC,CACA,OAAO,eAAe,qCAAqC,CAAC,CAC5D,QAAQ,aAAa,CAAC,CACtB,QAAQ,qBAAqB,CAAC,CAC9B,QAAQ,kEAAkE,CAAC,CAC3E,OAAO,OAAO,SAAkB,aAAyB;CACzD,YAAY;CAEZ,MAAM,QAAQ,UACb,UAAU,KAAA,IAAY,KAAA,IAAY,OAAO,KAAK;CAC/C,MAAM,OAAO,KAAK,OAAO;CACzB,MA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;AAEA,SAAS,QAAQ,OAAuB;CACvC,OAAO,UAAU,UAAU,GAAG,KAAK,MAAM,YAAY,IAAI,IAAI,KAAK,EAAE,GAAG;AACxE;;;;;;AAOA,SAAS,YAAY,OAAwB;CAC5C,MAAM,QAAkB,CAAC;CACzB,IAAI,WAAW;CACf,IAAI,UAAmB;CAEvB,OAAO,YAAY,KAAA,GAAW;EAC7B,MAAM,UACL,mBAAmB,QAAQ,QAAQ,UAAU,OAAO,OAAO;EAC5D,IAAI,MAAM,WAAW,KAAK,CAAC,SAAS,SAAS,OAAO,GACnD,MAAM,KACL,GAAG,MAAM,WAAW,IAAI,KAAK,gBAAgB,QAAQ,WAAW,MAAM,MAAM,GAC7E;EAED,WAAW;EACX,UAAU,mBAAmB,QAAQ,QAAQ,QAAQ,KAAA;CACtD;CAEA,OAAO,MAAM,KAAK,MAAM;AACzB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/cli/index.ts"],"sourcesContent":["import { type FSWatcher, watch } from 'node:fs';\nimport * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { styleText } from 'node:util';\nimport { cac } from 'cac';\nimport {\n\ttype CompiledTemplate,\n\tCompileError,\n\ttype CompileTemplateOptions,\n\tcompileTemplate,\n\ttype TemplateWatcher,\n\twatchTemplate,\n} from '../compiler';\nimport {\n\tassertCompileOptions,\n\tassertDirectories,\n\tassertEntry,\n\tCOMPILE_OPTION_KEYS,\n\tresolvePaths,\n} from '../compiler/options';\nimport { type LoadedConfig, loadConfig } from '../config';\nimport { type Location, withLocation } from '../plugins';\nimport { createRenderer } from '../runtime';\nimport { didYouMean } from '../utils/suggest';\nimport { processXml, XmlError, type XmlInfo, type XmlResult } from '../xml';\nimport {\n\ttype BuildStats,\n\tcollectStats,\n\tformatStats,\n\ttype WrittenFile,\n} from './stats';\n\nconst { version, license, repository } = JSON.parse(\n\tawait fs.readFile(new URL('../../package.json', import.meta.url), 'utf-8'),\n) as { version: string; license: string; repository: { url: string } };\n\ninterface BuildFlags {\n\tconfig?: string;\n\tentry?: string;\n\toutDir?: string;\n\tcontext?: string;\n\twatch?: boolean;\n\tclean?: boolean;\n\tvalidate?: boolean;\n\tformat?: boolean;\n}\n\n/** Everything a build needs, from the config file and the flags. */\ninterface BuildSetup {\n\toptions: CompileTemplateOptions;\n\tloaded: LoadedConfig;\n\toutDir: string;\n\tmoduleFile: string | false;\n\ttemplateFile: string | false;\n\tclean: boolean;\n\tcontext: unknown;\n\t/** Whether the rendered template is validated. */\n\tvalidate: boolean;\n\t/** Whether the rendered template is formatted, only when it is validated. */\n\tformat: boolean;\n\t/** Absolute path of the public directory, undefined when nothing is copied. */\n\tpublicDir?: string;\n\t/** Sizes of the files written last, by path, to show their changes when watching. */\n\tsizes: Map<string, number>;\n\t/** What the theme was made of at the last build, when watching. */\n\ttheme?: BuildStats['theme'];\n}\n\n/** What the CLI prints, with `write`, warnings and errors on stderr. */\nfunction logTo(write: (text: string) => void) {\n\treturn {\n\t\twrite,\n\t\tsuccess: (message: string) =>\n\t\t\twrite(`${styleText('green', '✓')} ${message}`),\n\t\tinfo: (message: string) => write(`${styleText('cyan', '●')} ${message}`),\n\t\twarn: (message: string) =>\n\t\t\tconsole.warn(`${styleText('yellow', '⚠')} ${message}`),\n\t\terror: (error: unknown) =>\n\t\t\tconsole.error(`${styleText('red', '✗')} ${formatError(error)}`),\n\t};\n}\n\nconst log = logTo(console.log);\n\nconst cli = cac('blogger-hbs');\n\ncli\n\t.command('[root]', 'Compile the template and render it')\n\t.alias('build')\n\t.option('-c, --config <file>', 'Path of the config file')\n\t.option('--entry <file>', 'Entry template, relative to the root')\n\t.option('-o, --out-dir <dir>', 'Output directory, relative to the root')\n\t.option('--context <file>', 'JSON file with the context to render with')\n\t.option('-w, --watch', 'Build again when a file changes')\n\t.option('--no-clean', 'Keep the files in the output directory')\n\t.option(\n\t\t'--no-validate',\n\t\t'Do not validate the rendered template as XML, nor format it (templates are always validated when compiling)',\n\t)\n\t.option('--no-format', 'Do not format the rendered template')\n\t.example('blogger-hbs')\n\t.example('blogger-hbs --watch')\n\t.example('blogger-hbs ./theme --entry src/index.hbs --context context.json')\n\t.action(async (rootArg: unknown, rawFlags: BuildFlags) => {\n\t\tprintHeader();\n\t\t// cac turns values that look like numbers into numbers, `-o 2024`\n\t\tconst text = (value: unknown) =>\n\t\t\tvalue === undefined ? undefined : String(value);\n\t\tconst root = text(rootArg);\n\t\tconst flags: BuildFlags = {\n\t\t\t...rawFlags,\n\t\t\tconfig: text(rawFlags.config),\n\t\t\tentry: text(rawFlags.entry),\n\t\t\toutDir: text(rawFlags.outDir),\n\t\t\tcontext: text(rawFlags.context),\n\t\t};\n\n\t\tif (flags.watch) {\n\t\t\tawait watchBuild(root, flags);\n\t\t} else {\n\t\t\tawait build(root, flags);\n\t\t}\n\t});\n\ncli\n\t.command('validate <file>', 'Validate a theme as Blogger reads it')\n\t.option('--json', 'Print the result as JSON')\n\t.example('blogger-hbs validate dist/theme.xml')\n\t.example('blogger-hbs validate dist/theme.xml --json')\n\t.action(async (file: unknown, flags: { json?: boolean }) => {\n\t\tawait processFile(String(file), { format: false, json: flags.json });\n\t});\n\ncli\n\t.command(\n\t\t'format <file>',\n\t\t'Format a theme as Blogger saves it, written to stdout, or to --out',\n\t)\n\t.option('-o, --out <file>', 'Write it to this file instead of stdout')\n\t.option('--json', 'Print the result as JSON, the theme in it without --out')\n\t.example('blogger-hbs format theme.xml')\n\t.example('blogger-hbs format theme.xml -o theme.formatted.xml')\n\t.action(async (file: unknown, flags: { out?: unknown; json?: boolean }) => {\n\t\tconst out = flags.out === undefined ? undefined : String(flags.out);\n\t\tawait processFile(String(file), { format: true, out, json: flags.json });\n\t});\n\ncli.help();\n// cac's own `--version` prints `name/version platform`, this one says more,\n// and the help still has the version in its heading\ncli.globalCommand.versionNumber = version;\ncli.option(\n\t'-v, --version',\n\t'Display the version, the copyright and the license',\n);\n\n/** Whether the header is printed, so that an error before a command runs prints it too. */\nlet headerPrinted = false;\n\ntry {\n\tcli.parse(process.argv, { run: false });\n\tif (cli.options.version) {\n\t\tawait printVersion();\n\t} else {\n\t\tawait cli.runMatchedCommand();\n\t}\n} catch (error) {\n\t// with the theme on stdout, the header of an error is on stderr with it\n\tif (!headerPrinted && !cli.options.json) {\n\t\tprintHeader(formatsToStdout() ? console.error : console.log);\n\t}\n\tlog.error(describeCliError(error));\n\tprocess.exitCode = 1;\n}\n\n/** Whether the command formats a theme to stdout, which has nothing else on it. */\nfunction formatsToStdout(): boolean {\n\treturn cli.matchedCommandName === 'format' && cli.options.out === undefined;\n}\n\n/** Adds a suggestion and a pointer to `--help` to the errors of the arguments. */\nfunction describeCliError(error: unknown): unknown {\n\tif (!(error instanceof Error) || error.name !== 'CACError') {\n\t\treturn error;\n\t}\n\n\tconst flags = [...cli.commands, cli.globalCommand].flatMap((command) =>\n\t\tcommand.options.flatMap(\n\t\t\t(option) => option.rawName.match(/--[\\w-]+/g) ?? [],\n\t\t),\n\t);\n\tconst unknown = /^Unknown option `(.+)`$/.exec(error.message)?.[1];\n\tconst hint = unknown ? didYouMean(unknown, flags, '`') : '';\n\n\treturn new Error(\n\t\t`${error.message}${hint}\\nRun 'blogger-hbs ${cli.matchedCommandName ? `${cli.matchedCommandName} ` : ''}--help' to see the available options`,\n\t);\n}\n\nasync function setup(\n\troot: string | undefined,\n\tflags: BuildFlags,\n): Promise<BuildSetup> {\n\tconst cwd = process.cwd();\n\tconst rootFlag = root === undefined ? undefined : path.resolve(cwd, root);\n\n\t// the config is looked for in the root, which has to exist for that\n\tif (rootFlag !== undefined && !(await isDirectory(rootFlag))) {\n\t\tthrow new CompileError(\n\t\t\t(await exists(rootFlag))\n\t\t\t\t? `Root '${root}' is not a directory`\n\t\t\t\t: `Root directory '${root}' does not exist`,\n\t\t);\n\t}\n\n\tconst loaded = await loadConfig({\n\t\tcwd: rootFlag ?? cwd,\n\t\tconfigFile: flags.config && path.resolve(cwd, flags.config),\n\t\twatch: flags.watch,\n\t});\n\tconst { config } = loaded;\n\n\tconst resolvedRoot = rootFlag ?? config.root ?? cwd;\n\tconst output = config.output ?? {};\n\n\t// the config has more than the compile options\n\tconst options: CompileTemplateOptions = {};\n\tfor (const key of COMPILE_OPTION_KEYS) {\n\t\tif (key in config) {\n\t\t\tObject.assign(options, { [key]: config[key as keyof typeof config] });\n\t\t}\n\t}\n\toptions.root = resolvedRoot;\n\toptions.entry = flags.entry ?? config.entry;\n\toptions.onWarn ??= log.warn;\n\n\tassertCompileOptions(options);\n\tawait assertDirectories(options);\n\n\tconst outDir = path.resolve(\n\t\tresolvedRoot,\n\t\tflags.outDir ?? output.dir ?? 'dist',\n\t);\n\tconst clean = flags.clean === false ? false : (output.clean ?? true);\n\tif (clean) {\n\t\tassertCleanable(outDir, options);\n\t}\n\n\treturn {\n\t\toptions,\n\t\tloaded,\n\t\toutDir,\n\t\tmoduleFile: output.module ?? 'compiled.js',\n\t\ttemplateFile: output.template ?? 'theme.xml',\n\t\tvalidate: flags.validate === false ? false : (output.validate ?? true),\n\t\tformat: flags.format === false ? false : (output.format ?? true),\n\t\tclean,\n\t\tcontext: flags.context\n\t\t\t? await readContext(path.resolve(cwd, flags.context), flags.context)\n\t\t\t: (config.context ?? {}),\n\t\tpublicDir: await resolvePublicDir(resolvedRoot, config.publicDir, outDir),\n\t\tsizes: new Map(),\n\t};\n}\n\n/** The public directory, `public` when it exists unless set otherwise. */\nasync function resolvePublicDir(\n\troot: string,\n\tvalue: string | false | undefined,\n\toutDir: string,\n): Promise<string | undefined> {\n\tif (value === false) {\n\t\treturn;\n\t}\n\n\tconst directory = path.resolve(root, value ?? 'public');\n\tconst shown = path.relative(process.cwd(), directory) || '.';\n\n\tif (!(await isDirectory(directory))) {\n\t\tif (value === undefined) {\n\t\t\treturn;\n\t\t}\n\t\tthrow new CompileError(\n\t\t\t(await exists(directory))\n\t\t\t\t? `Public directory '${shown}' is not a directory`\n\t\t\t\t: `Public directory '${shown}' does not exist, set 'publicDir: false' to not copy anything`,\n\t\t);\n\t}\n\n\tif (isInside(outDir, directory) || isInside(directory, outDir)) {\n\t\tthrow new CompileError(\n\t\t\t`Public directory '${shown}' and output directory '${path.relative(process.cwd(), outDir) || '.'}' overlap, they must be separate`,\n\t\t);\n\t}\n\n\treturn directory;\n}\n\n/** Copies the public directory into the output directory. */\nasync function copyPublic({\n\tpublicDir,\n\toutDir,\n\tmoduleFile,\n\ttemplateFile,\n}: BuildSetup): Promise<void> {\n\tif (publicDir === undefined) {\n\t\treturn;\n\t}\n\n\tfor (const name of await fs.readdir(publicDir)) {\n\t\tif (name === moduleFile || name === templateFile) {\n\t\t\tthrow new CompileError(\n\t\t\t\t`'${name}' in the public directory has the same name as the ${name === moduleFile ? 'compiled module' : 'rendered template'} and would be overwritten, rename it or set 'output.${name === moduleFile ? 'module' : 'template'}'`,\n\t\t\t);\n\t\t}\n\t}\n\n\tawait fs.cp(publicDir, outDir, { recursive: true, force: true });\n}\n\n/**\n * Cleaning removes everything in the output directory, which must not hold the\n * project: the root, the working directory, the templates or an alias target.\n */\nfunction assertCleanable(outDir: string, options: CompileTemplateOptions) {\n\tconst { root, entry } = resolvePaths(options);\n\tconst shown = path.relative(process.cwd(), outDir) || '.';\n\tconst kept: [string, string][] = [\n\t\t[root, 'the root'],\n\t\t[process.cwd(), 'the working directory'],\n\t\t[path.dirname(entry), 'the entry template'],\n\t\t...Object.entries(options.alias ?? {}).map(\n\t\t\t([name, target]): [string, string] => [\n\t\t\t\tpath.resolve(root, target),\n\t\t\t\t`the target of the alias '${name}'`,\n\t\t\t],\n\t\t),\n\t];\n\n\tfor (const [directory, what] of kept) {\n\t\tif (isInside(directory, outDir)) {\n\t\t\tthrow new CompileError(\n\t\t\t\t`Refusing to clean the output directory '${shown}', it contains ${what}. Use another output directory, or --no-clean / 'output.clean: false' to keep its files`,\n\t\t\t);\n\t\t}\n\t}\n}\n\nasync function readContext(file: string, shown: string): Promise<unknown> {\n\tlet text: string;\n\ttry {\n\t\ttext = await fs.readFile(file, 'utf-8');\n\t} catch (cause) {\n\t\tif ((cause as NodeJS.ErrnoException).code === 'ENOENT') {\n\t\t\tthrow new CompileError(`Context file '${shown}' not found`);\n\t\t}\n\t\tthrow new CompileError(`Failed to read the context file '${shown}'`, {\n\t\t\tcause,\n\t\t});\n\t}\n\n\ttry {\n\t\treturn JSON.parse(text);\n\t} catch (cause) {\n\t\tthrow new CompileError(\n\t\t\t`Context file '${shown}' is not valid JSON: ${(cause as Error).message}`,\n\t\t);\n\t}\n}\n\n/** Whether `child` is `parent` or inside of it. */\nfunction isInside(child: string, parent: string): boolean {\n\tconst relative = path.relative(parent, child);\n\treturn (\n\t\trelative === '' ||\n\t\t(!relative.startsWith('..') && !path.isAbsolute(relative))\n\t);\n}\n\nasync function exists(file: string): Promise<boolean> {\n\treturn fs.stat(file).then(\n\t\t() => true,\n\t\t() => false,\n\t);\n}\n\nasync function isDirectory(file: string): Promise<boolean> {\n\treturn fs.stat(file).then(\n\t\t(stats) => stats.isDirectory(),\n\t\t() => false,\n\t);\n}\n\nasync function build(root: string | undefined, flags: BuildFlags) {\n\tconst current = await setup(root, flags);\n\t// nothing is written when there is nothing to build, the watcher waits\n\t// for the entry instead\n\tawait assertEntry(current.options);\n\tawait prepareOutDir(current);\n\tawait copyPublic(current);\n\n\tconst start = performance.now();\n\tconst compiled = await compileTemplate(current.options);\n\tlog.success(`Compiled in ${elapsed(start)}`);\n\n\tawait write(current, compiled, start);\n}\n\n/** Watches the template and restarts when the config file changes. */\nasync function watchBuild(root: string | undefined, flags: BuildFlags) {\n\tlet current = await setup(root, flags);\n\tawait prepareOutDir(current);\n\n\tlet watcher: TemplateWatcher | undefined;\n\tlet watchers: FSWatcher[] = [];\n\tlet restarting = false;\n\n\tconst start = async () => {\n\t\tlet begin = performance.now();\n\t\tlet first = true;\n\t\t/** Shown before what a rebuild prints, after the first build. */\n\t\tlet divider = '';\n\n\t\t/** Once, before the first thing a rebuild prints, its output can be the same. */\n\t\tconst printDivider = () => {\n\t\t\tif (divider) {\n\t\t\t\tconsole.log(divider);\n\t\t\t\tdivider = '';\n\t\t\t}\n\t\t};\n\n\t\ttry {\n\t\t\tawait copyPublic(current);\n\t\t} catch (error) {\n\t\t\tlog.error(error);\n\t\t}\n\n\t\twatcher = await watchTemplate({\n\t\t\t...current.options,\n\t\t\tonStart({ files }) {\n\t\t\t\tbegin = performance.now();\n\t\t\t\tdivider = first ? '' : formatDivider(files);\n\t\t\t},\n\t\t\tasync onCompile(compiled) {\n\t\t\t\tprintDivider();\n\t\t\t\tlog.success(`${first ? 'Compiled' : 'Rebuilt'} in ${elapsed(begin)}`);\n\t\t\t\tawait write(current, compiled, begin);\n\t\t\t\tfirst = false;\n\t\t\t},\n\t\t\tonError(error) {\n\t\t\t\tprintDivider();\n\t\t\t\tlog.error(error);\n\t\t\t},\n\t\t});\n\n\t\tfor (const file of current.loaded.dependencies) {\n\t\t\ttry {\n\t\t\t\tconst configWatcher = watch(file, () => {\n\t\t\t\t\t// saving fires more than once, a restart is enough\n\t\t\t\t\tif (!restarting) {\n\t\t\t\t\t\trestarting = true;\n\t\t\t\t\t\trestart().finally(() => {\n\t\t\t\t\t\t\trestarting = false;\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tconfigWatcher.on('error', () => configWatcher.close());\n\t\t\t\twatchers.push(configWatcher);\n\t\t\t} catch {\n\t\t\t\t// a dependency that can not be watched does not restart\n\t\t\t}\n\t\t}\n\n\t\tif (current.publicDir !== undefined) {\n\t\t\twatchers.push(watchPublic(current));\n\t\t}\n\t};\n\n\tconst stopWatchers = () => {\n\t\tfor (const fileWatcher of watchers) {\n\t\t\tfileWatcher.close();\n\t\t}\n\t\twatchers = [];\n\t};\n\n\tconst restart = async () => {\n\t\tlog.info(\n\t\t\t`Config changed, restarting ${styleText('dim', path.relative(process.cwd(), current.loaded.file ?? ''))}`,\n\t\t);\n\t\tstopWatchers();\n\t\tawait watcher?.close();\n\t\ttry {\n\t\t\tcurrent = await setup(root, flags);\n\t\t} catch (error) {\n\t\t\tlog.error(error);\n\t\t}\n\t\tawait start();\n\t};\n\n\tawait start();\n\tlog.info(\n\t\t`Watching for changes ${styleText('dim', '(press Ctrl+C to stop)')}`,\n\t);\n\n\tconst stop = async () => {\n\t\tstopWatchers();\n\t\tawait watcher?.close();\n\t\t// the process ends once nothing is left running: `process.exit` would skip\n\t\t// the cleanup of rspack's native bindings, which then warn about leaks,\n\t\t// so it is only a fallback for something left running, a plugin's timer\n\t\tsetTimeout(() => process.exit(0), 3000).unref();\n\t};\n\tprocess.once('SIGINT', stop);\n\tprocess.once('SIGTERM', stop);\n}\n\n/** Copies the public directory again when something in it changes. */\nfunction watchPublic(current: BuildSetup): FSWatcher {\n\tconst publicDir = current.publicDir as string;\n\tconst changed = new Set<string>();\n\tlet timer: NodeJS.Timeout | undefined;\n\n\tconst sync = async () => {\n\t\tconst names = [...changed];\n\t\tchanged.clear();\n\t\ttry {\n\t\t\t// what was deleted from the public directory goes from the output too\n\t\t\tfor (const name of names) {\n\t\t\t\tif (!(await exists(path.join(publicDir, name)))) {\n\t\t\t\t\tawait fs.rm(path.join(current.outDir, name), {\n\t\t\t\t\t\trecursive: true,\n\t\t\t\t\t\tforce: true,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait copyPublic(current);\n\t\t\tlog.success(\n\t\t\t\t`Copied ${styleText('dim', path.relative(process.cwd(), publicDir))}`,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tlog.error(error);\n\t\t}\n\t};\n\n\tconst publicWatcher = watch(\n\t\tpublicDir,\n\t\t{ recursive: true },\n\t\t(_event, name) => {\n\t\t\tif (name) {\n\t\t\t\tchanged.add(name);\n\t\t\t}\n\t\t\tclearTimeout(timer);\n\t\t\ttimer = setTimeout(sync, 50);\n\t\t},\n\t);\n\tpublicWatcher.on('error', () => publicWatcher.close());\n\tpublicWatcher.on('close', () => clearTimeout(timer));\n\treturn publicWatcher;\n}\n\nasync function prepareOutDir({ outDir, clean }: BuildSetup) {\n\tif (clean) {\n\t\tawait fs.rm(outDir, { recursive: true, force: true });\n\t}\n\tawait fs.mkdir(outDir, { recursive: true });\n}\n\n/**\n * Writes the compiled module and the rendered template, validated and\n * formatted after rendering when enabled.\n */\nasync function write(\n\tcurrent: BuildSetup,\n\tcompiled: CompiledTemplate,\n\tbegin: number,\n) {\n\tconst { outDir, moduleFile, templateFile } = current;\n\tconst written: WrittenFile[] = [];\n\tlet theme: WrittenTheme | undefined;\n\n\tif (moduleFile) {\n\t\tconst file = path.join(outDir, moduleFile);\n\t\tawait fs.writeFile(file, compiled.source);\n\t\twritten.push({\n\t\t\tpath: path.relative(process.cwd(), file),\n\t\t\tcontent: compiled.source,\n\t\t});\n\t}\n\tif (templateFile) {\n\t\ttheme = await writeTheme(current, compiled, templateFile);\n\t\twritten.unshift(theme.file);\n\t}\n\n\tconst stats = await collectStats(\n\t\tcompiled,\n\t\twritten,\n\t\ttheme?.info && { ...theme.file, info: theme.info },\n\t);\n\tconsole.log(\n\t\tformatStats(stats, current.sizes, { previousTheme: current.theme }),\n\t);\n\tcurrent.sizes = new Map(stats.files.map(({ path, size }) => [path, size]));\n\tcurrent.theme = stats.theme;\n\tlog.success(`Built in ${elapsed(begin)}`);\n}\n\n/** `─── 14:32:05 · src/header.hbs +2 ───────`, dim. */\nfunction formatDivider(files: readonly string[]): string {\n\tconst time = new Date().toLocaleTimeString('en-GB', { hour12: false });\n\tconst [file, ...others] = files.map((item) =>\n\t\tpath.relative(process.cwd(), item),\n\t);\n\tconst what = file\n\t\t? ` · ${file}${others.length > 0 ? ` +${others.length}` : ''}`\n\t\t: '';\n\tconst text = `─── ${time}${what} `;\n\treturn `\\n${styleText('dim', text + '─'.repeat(Math.max(3, 50 - text.length)))}`;\n}\n\ninterface WrittenTheme {\n\tfile: WrittenFile;\n\t/** What it is made of, when it is validated. */\n\tinfo?: XmlInfo;\n}\n\n/** Renders, validates and formats the theme, as enabled, and writes it. */\nasync function writeTheme(\n\tcurrent: BuildSetup,\n\tcompiled: CompiledTemplate,\n\ttemplateFile: string,\n): Promise<WrittenTheme> {\n\tconst { outDir, context } = current;\n\tconst file = path.join(outDir, templateFile);\n\tconst shown = path.relative(process.cwd(), file);\n\n\t// the same as anywhere else the compiled module is rendered\n\tlet start = performance.now();\n\tconst renderer = createRenderer(compiled);\n\tconst rendered = await renderer.render(context);\n\tlog.success(`Rendered in ${elapsed(start)}`);\n\n\tif (!current.validate) {\n\t\tawait fs.writeFile(file, rendered);\n\t\treturn { file: { path: shown, content: rendered } };\n\t}\n\n\tstart = performance.now();\n\tlet result: XmlResult;\n\ttry {\n\t\tresult = processXml(rendered, { path: shown, format: current.format });\n\t} catch (error) {\n\t\t// written anyway, to look at where it is invalid\n\t\tawait fs.writeFile(file, rendered);\n\t\tthrow new CompileError('The rendered template is not valid XML', {\n\t\t\tcause: error,\n\t\t\tloc: (error as XmlError).loc,\n\t\t});\n\t}\n\tfor (const { message, loc } of result.warnings) {\n\t\tlog.warn(withLocation(message, loc));\n\t}\n\tlog.success(\n\t\t`${current.format ? 'Formatted' : 'Validated'} in ${elapsed(start)}`,\n\t);\n\n\tawait fs.writeFile(file, result.xml);\n\treturn { file: { path: shown, content: result.xml }, info: result.info };\n}\n\ninterface ProcessFileOptions {\n\tformat: boolean;\n\t/** The file to write the formatted theme to, stdout without it. */\n\tout?: string;\n\t/** Whether to print the result as JSON, alone on stdout. */\n\tjson?: boolean;\n}\n\n/**\n * Validates the theme in `file`, and with `format` formats it, written to\n * `out` or to stdout. Warnings are placed in what is written, errors in\n * `file`, and nothing is written when it is not valid.\n */\nasync function processFile(\n\tfile: string,\n\t{ format, out, json }: ProcessFileOptions,\n): Promise<void> {\n\tif (json) {\n\t\tconst report = await reportOf(file, { format, out });\n\t\tprocess.stdout.write(`${JSON.stringify(report, null, 2)}\\n`);\n\t\tif (!report.valid) {\n\t\t\tprocess.exitCode = 1;\n\t\t}\n\t\treturn;\n\t}\n\n\t// a formatted theme on stdout has it to itself\n\tconst toStdout = format && out === undefined;\n\tconst print = toStdout ? logTo(console.error) : log;\n\t// on stdout, only the theme, with warnings and errors besides it\n\tif (!toStdout) {\n\t\tprintHeader(print.write);\n\t}\n\n\tconst start = performance.now();\n\tconst { result, written } = await processTheme(file, { format, out });\n\tfor (const { message, loc } of result.warnings) {\n\t\tprint.warn(withLocation(message, loc));\n\t}\n\n\tif (!format) {\n\t\tprint.success(`Validated in ${elapsed(start)}`);\n\t} else if (out === undefined) {\n\t\tprocess.stdout.write(result.xml);\n\t} else {\n\t\tprint.success(`Formatted in ${elapsed(start)}, written to ${written}`);\n\t}\n}\n\n/**\n * Reads, processes and, with `out`, writes the theme in `file`. Its\n * warnings and info are placed in what is written, and an error throws.\n */\nasync function processTheme(\n\tfile: string,\n\t{ format, out }: ProcessFileOptions,\n): Promise<{ result: XmlResult; written: string }> {\n\tconst shown = path.relative(process.cwd(), path.resolve(file));\n\tconst xml = await readTheme(file, shown);\n\n\tlet result: XmlResult;\n\ttry {\n\t\tresult = processXml(xml, { path: shown, format });\n\t} catch (error) {\n\t\tthrow new Error(`${shown} is not valid XML`, { cause: error });\n\t}\n\n\tconst written = !format\n\t\t? shown\n\t\t: out === undefined\n\t\t\t? '<stdout>'\n\t\t\t: path.relative(process.cwd(), path.resolve(out));\n\tconst at = <T extends { loc: Location }>(item: T): T => ({\n\t\t...item,\n\t\tloc: { ...item.loc, path: written },\n\t});\n\tresult = {\n\t\t...result,\n\t\twarnings: result.warnings.map(at),\n\t\tinfo: {\n\t\t\t...result.info,\n\t\t\tsections: result.info.sections.map(at),\n\t\t\twidgets: result.info.widgets.map(at),\n\t\t},\n\t};\n\n\tif (format && out !== undefined) {\n\t\tawait fs.mkdir(path.dirname(path.resolve(out)), { recursive: true });\n\t\tawait fs.writeFile(out, result.xml);\n\t}\n\treturn { result, written };\n}\n\n/** What `--json` prints: the result of a valid theme, or every error. */\ntype Report =\n\t| {\n\t\t\tvalid: true;\n\t\t\twarnings: XmlResult['warnings'];\n\t\t\tinfo: XmlResult['info'];\n\t\t\t/** The formatted theme, without `--out`. */\n\t\t\txml?: string;\n\t\t\t/** Where the formatted theme is written, with `--out`. */\n\t\t\twritten?: string;\n\t }\n\t| { valid: false; errors: { message: string; loc?: Location }[] };\n\nasync function reportOf(\n\tfile: string,\n\t{ format, out }: ProcessFileOptions,\n): Promise<Report> {\n\ttry {\n\t\tconst { result, written } = await processTheme(file, { format, out });\n\t\treturn {\n\t\t\tvalid: true,\n\t\t\twarnings: result.warnings,\n\t\t\tinfo: result.info,\n\t\t\t...(format && out === undefined && { xml: result.xml }),\n\t\t\t...(format && out !== undefined && { written }),\n\t\t};\n\t} catch (error) {\n\t\tconst cause = error instanceof Error ? error.cause : undefined;\n\t\treturn {\n\t\t\tvalid: false,\n\t\t\terrors:\n\t\t\t\tcause instanceof XmlError\n\t\t\t\t\t? [...cause.errors]\n\t\t\t\t\t: [{ message: messageOf(error) }],\n\t\t};\n\t}\n}\n\n/** The message of an error and of what caused it, on one line. */\nfunction messageOf(error: unknown): string {\n\tconst messages: string[] = [];\n\tfor (let current: unknown = error; current !== undefined; ) {\n\t\tmessages.push(current instanceof Error ? current.message : String(current));\n\t\tcurrent = current instanceof Error ? current.cause : undefined;\n\t}\n\treturn messages.join(': ');\n}\n\n/** The text of the theme in `file`, an error saying so when it can not be read. */\nasync function readTheme(file: string, shown: string): Promise<string> {\n\ttry {\n\t\treturn await fs.readFile(file, 'utf-8');\n\t} catch (error) {\n\t\tthrow new Error(`Can not read ${shown}`, { cause: error });\n\t}\n}\n\n/** The version, the copyright and the license, where the project is, and the runtime. */\nasync function printVersion(): Promise<void> {\n\tprintHeader();\n\t// the copyright of the license, npm publishing it with the package\n\tconst notice = await fs\n\t\t.readFile(new URL('../../LICENSE.md', import.meta.url), 'utf-8')\n\t\t.catch(() => '');\n\tconst copyright = /^Copyright .*$/m.exec(notice)?.[0];\n\tconsole.log(\n\t\t[\n\t\t\tcopyright,\n\t\t\t`Released under the ${license} License, provided as is, without warranty.`,\n\t\t\trepository.url,\n\t\t\t'',\n\t\t\t`Node.js ${process.version} on ${process.platform}-${process.arch}`,\n\t\t]\n\t\t\t.filter((line) => line !== undefined)\n\t\t\t.join('\\n'),\n\t);\n}\n\n/**\n * A blank line, `blogger-hbs v0.0.4` right-aligned on a cyan line under it,\n * before what a command prints, with `write`.\n */\nfunction printHeader(write: (text: string) => void = console.log): void {\n\theaderPrinted = true;\n\tconst text = `blogger-hbs v${version}`;\n\tconst width = text.length + 2;\n\twrite(\n\t\t`\\n${' '.repeat(width - text.length)}${styleText('bold', 'blogger-hbs')} ${styleText('dim', `v${version}`)}\\n${styleText('cyan', '─'.repeat(width))}`,\n\t);\n}\n\nfunction elapsed(start: number): string {\n\treturn styleText('yellow', `${Math.round(performance.now() - start)}ms`);\n}\n\n/**\n * The message of the error and of everything that caused it, a cause whose\n * message is already in the one before is not repeated. The lines of a\n * message are indented under its first.\n */\nfunction formatError(error: unknown): string {\n\tconst lines: string[] = [];\n\tlet previous = '';\n\tlet current: unknown = error;\n\n\twhile (current !== undefined) {\n\t\tconst message =\n\t\t\tcurrent instanceof Error ? current.message : String(current);\n\t\tif (lines.length === 0 || !previous.includes(message)) {\n\t\t\tlines.push(\n\t\t\t\t`${lines.length === 0 ? '' : 'Caused by: '}${message.replaceAll('\\n', '\\n ')}`,\n\t\t\t);\n\t\t}\n\t\tprevious = message;\n\t\tcurrent = current instanceof Error ? current.cause : undefined;\n\t}\n\n\treturn lines.join('\\n ');\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,MAAM,EAAE,SAAS,SAAS,eAAe,KAAK,MAC7C,MAAM,GAAG,SAAS,IAAI,IAAI,sBAAsB,YAAY,GAAG,GAAG,OAAO,CAC1E;;AAmCA,SAAS,MAAM,OAA+B;CAC7C,OAAO;EACN;EACA,UAAU,YACT,MAAM,GAAG,UAAU,SAAS,GAAG,EAAE,GAAG,SAAS;EAC9C,OAAO,YAAoB,MAAM,GAAG,UAAU,QAAQ,GA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