forgepress 0.0.0 → 0.0.1

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.
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env node
2
+ import { errorMessage } from "../_chunks/error.mjs";
3
+ import { findRoot, loadConfig, resolveConfig } from "../_chunks/config.mjs";
4
+ import { ContentError, formatIssue } from "../_chunks/validate.mjs";
5
+ import { buildOutput, checkContent } from "../_chunks/output2.mjs";
6
+ import process from "node:process";
7
+ const USAGE = `Usage: forgepress <command>
8
+
9
+ Commands:
10
+ check Check the schema and all content the way the build does
11
+ build Check the content, then write the content output`;
12
+ function report(issues, terminal) {
13
+ terminal.error(`${issues.map(formatIssue).join("\n")}\n\n${issues.length} ${issues.length === 1 ? "problem" : "problems"} found`);
14
+ return 1;
15
+ }
16
+ async function check(root, terminal) {
17
+ const config = resolveConfig(await loadConfig(root));
18
+ const issues = await checkContent(root, config.paths);
19
+ if (issues.length > 0) return report(issues, terminal);
20
+ terminal.log("No problems found");
21
+ return 0;
22
+ }
23
+ async function build(root, terminal) {
24
+ const result = await buildOutput(root, resolveConfig(await loadConfig(root)));
25
+ terminal.log(`Wrote the content output to ${result.dir} (${result.files} files, ${result.commit ? `commit ${result.commit.slice(0, 7)}` : "no commit found"})`);
26
+ return 0;
27
+ }
28
+ async function run(args, cwd, terminal) {
29
+ const [command, ...rest] = args;
30
+ if (command === void 0 || command === "help" || command === "--help" || command === "-h") {
31
+ terminal.log(USAGE);
32
+ return 0;
33
+ }
34
+ if (command !== "check" && command !== "build" || rest.length > 0) {
35
+ terminal.error(`${command !== "check" && command !== "build" ? `Unknown command ${JSON.stringify(command)}` : `${command} takes no arguments`}\n\n${USAGE}`);
36
+ return 1;
37
+ }
38
+ try {
39
+ const root = findRoot(cwd);
40
+ return command === "check" ? await check(root, terminal) : await build(root, terminal);
41
+ } catch (error) {
42
+ if (error instanceof ContentError) return report(error.issues, terminal);
43
+ terminal.error(errorMessage(error));
44
+ return 1;
45
+ }
46
+ }
47
+ process.exitCode = await run(process.argv.slice(2), process.cwd(), console);
48
+ export {};
@@ -0,0 +1,4 @@
1
+ import { ContentReader } from "../_chunks/client.mjs";
2
+ export declare const OUTPUT_VARIABLE = "FORGEPRESS_OUTPUT";
3
+ export declare function diskReader(dir: () => Promise<string>): ContentReader;
4
+ export declare const reader: ContentReader;
@@ -0,0 +1,2 @@
1
+ import { OUTPUT_VARIABLE, diskReader, reader } from "../_chunks/reader.mjs";
2
+ export { OUTPUT_VARIABLE, diskReader, reader };
@@ -0,0 +1,3 @@
1
+ export type MountEditor = (target?: Element | string | null) => () => void
2
+
3
+ export declare const mountEditor: MountEditor