Add basic support for markdown sources
This commit is contained in:
parent
1848d3cfb6
commit
1c64a941cd
9 changed files with 118 additions and 50 deletions
24
src/index.ts
24
src/index.ts
|
@ -10,7 +10,7 @@ import {
|
|||
import { loadResourceFile } from "./resource";
|
||||
import { usage } from "./usage";
|
||||
|
||||
class CLIError extends Error { }
|
||||
class CLIError extends Error {}
|
||||
|
||||
async function main(): Promise<boolean> {
|
||||
// Parse command line arguments
|
||||
|
@ -67,7 +67,7 @@ async function main(): Promise<boolean> {
|
|||
* Log a message if the vervose flag has been set
|
||||
* @param msg - The message to log
|
||||
*/
|
||||
function v(msg: string) {
|
||||
function verboseLog(msg: string) {
|
||||
if (VERBOSE) {
|
||||
console.log(chalk.dim(msg));
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ async function main(): Promise<boolean> {
|
|||
|
||||
const bindingPath = args[0] ?? "./binding.yaml";
|
||||
|
||||
v(`Building Playbill with binding: ${bindingPath}`);
|
||||
verboseLog(`Building Playbill with binding: ${bindingPath}`);
|
||||
|
||||
// Check if the binding file exists
|
||||
const bindingFileCheck = Bun.file(bindingPath);
|
||||
|
@ -87,21 +87,23 @@ async function main(): Promise<boolean> {
|
|||
|
||||
const binding = await loadBindingFile(bindingPath);
|
||||
|
||||
v(`↳ Binding loaded with ${binding.files.length} associated resources`);
|
||||
verboseLog(
|
||||
`↳ Binding loaded with ${binding.files.length} associated resources`,
|
||||
);
|
||||
|
||||
const loadedResources: AnyResource[] = [];
|
||||
|
||||
v("Loading resources");
|
||||
verboseLog("Loading resources");
|
||||
|
||||
// Load resources listed in the binding file
|
||||
for (const filepath of binding.files) {
|
||||
v(`↳ Loading ${filepath}`);
|
||||
verboseLog(`↳ Loading ${filepath}`);
|
||||
const loaded = await loadResourceFile(filepath);
|
||||
v(` ↳ Loaded ${loaded.length} resources`);
|
||||
verboseLog(` ↳ Loaded ${loaded.length} resources`);
|
||||
loadedResources.push(...loaded);
|
||||
}
|
||||
|
||||
v("Constructing playbill");
|
||||
verboseLog("Constructing playbill");
|
||||
|
||||
// Consjtruct the playbill object
|
||||
const playbill = getEmptyPlaybill();
|
||||
|
@ -143,7 +145,7 @@ async function main(): Promise<boolean> {
|
|||
}
|
||||
|
||||
// Evaluate directives in descriptions for all resources
|
||||
v("Processing descriptions");
|
||||
verboseLog("Processing descriptions");
|
||||
for (const resource of loadedResources) {
|
||||
try {
|
||||
resource.description = await processLang(resource.description, playbill);
|
||||
|
@ -161,7 +163,7 @@ async function main(): Promise<boolean> {
|
|||
}
|
||||
|
||||
// Validate the playbill object
|
||||
v("Validating playbill");
|
||||
verboseLog("Validating playbill");
|
||||
const validatedPlaybill = ValidatedPlaybillSchema.safeParse(playbill);
|
||||
|
||||
if (!validatedPlaybill.success) {
|
||||
|
@ -170,7 +172,7 @@ async function main(): Promise<boolean> {
|
|||
return false;
|
||||
}
|
||||
|
||||
v("Playbill validated");
|
||||
verboseLog("Playbill validated");
|
||||
|
||||
// If --check is set, exit here
|
||||
if (options.check) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue