Organize into folders

This commit is contained in:
Endeavorance 2025-03-10 20:58:11 -04:00
parent 84b8f1c9d6
commit 2e0d4b45ea
12 changed files with 121 additions and 64 deletions

View file

@ -1,15 +1,32 @@
import { watch } from "node:fs/promises";
import {
serializePlaybill,
ValidatedPlaybillSchema,
serializePlaybill,
} from "@proscenium/playbill";
import chalk from "chalk";
import { watch } from "node:fs/promises";
import { loadFromBinding, resolveBindingPath } from "./filetypes/binding";
import { usage } from "./usage";
import { CLIError, MuseError } from "./errors";
import { renderAsHTML } from "./renderers/html";
import { parseCLIArguments, type CLIArguments } from "./args";
import { fullDirname } from "./util/files";
import { loadFromBinding, resolveBindingPath } from "#filetypes/binding";
import { CLIError, MuseError } from "#lib/errors";
import { renderAsHTML } from "#renderers/html";
import { type CLIArguments, parseCLIArguments } from "#util/args";
import { getAbsoluteDirname } from "#util/files";
import { version } from "../package.json" with { type: "json" };
const usage = `
${chalk.bold("muse")} - Compile and validate Playbills for Proscenium
${chalk.dim(`v${version}`)}
Usage:
muse [/path/to/binding.yaml] <options>
Options:
--check Only load and check the current binding and resources, but do not compile
--write Write the output to a file. If not specified, outputs to stdout
--outfile Specify the output file path [default: playbill.json]
--verbose, -v Verbose output
--minify, -m Minify the output JSON
--watch Watch the directory for changes and recompile
--help, -h Show this help message
`.trim();
enum ExitCode {
Success = 0,
@ -71,17 +88,14 @@ async function main(): Promise<number> {
return ExitCode.Success;
}
// -- ARG VALIDATION -- //
if (options.check && options.write) {
throw new CLIError("Cannot use --check and --write together");
}
console.log(`Processing ${cliArguments.inputFilePath}`);
let lastProcessResult = await processBinding(cliArguments);
if (options.watch) {
const watchDir = fullDirname(cliArguments.inputFilePath);
const watchDir = getAbsoluteDirname(cliArguments.inputFilePath);
console.log(`Watching ${watchDir} for changes`);
const watcher = watch(watchDir, {
recursive: true,
});