runtime/entrypoints/chapter.entrypoint.ts
runtime/entrypoints/chapter.entrypoint.ts is a file in Bane's Lab Content. 39 lines of code and 4 definitions.
import {
CHAPTERS_DONE,
CHAPTER_REMOVED,
CHAPTER_WRITTEN,
RENDER_STABLE,
SHAPE_UNKNOWN,
} from "#configuration/strings/derivation.strings";
import { CHAPTER_SUMMARY, OUT_DESCRIBE, SHAPE_DESCRIBE } from "#configuration/strings/contract.strings";
import { OUT_FLAG, SHAPE_FLAG } from "#configuration/constants/chapter.constants";
import { flagValue, resolveArgv } from "@govlab/argv";
import { refuse, say } from "#core/reporters/derivation.reporter";
import { CHAPTER_COMMAND } from "#configuration/constants/contract.constants";
import { renderSurface } from "#core/coordinators/chapter.coordinator";
import { shapeOf } from "#core/loaders/chapter.loader";
const argv = resolveArgv({
command: CHAPTER_COMMAND,
flags: [
{ describe: OUT_DESCRIBE, name: OUT_FLAG, takesValue: true },
{ describe: SHAPE_DESCRIBE, name: SHAPE_FLAG, takesValue: true },
],
summary: CHAPTER_SUMMARY,
});
const requested = flagValue(argv, SHAPE_FLAG) ?? null;
const shape = shapeOf(requested);
if (shape === null) {
refuse(`${SHAPE_UNKNOWN}${requested ?? ""}`);
}
const result = await renderSurface(shape, flagValue(argv, OUT_FLAG) ?? null);
if (!result.ok) {
refuse(result.reason);
}
say(RENDER_STABLE);
for (const name of result.removed) {
say(`${CHAPTER_REMOVED}${name}`);
}
for (const chapter of result.chapters) {
say(`${CHAPTER_WRITTEN}${chapter.file}`);
}
say(`${String(result.chapters.length)}${CHAPTERS_DONE}${result.out}`);