WIP! A BB-style forum, on the ATmosphere! We're still working... we'll be back soon when we have something to show off!
node typescript hono htmx atproto
at root/atb-56-theme-caching-layer 33 lines 1.1 kB view raw
1import { readFileSync, writeFileSync, mkdirSync } from "node:fs"; 2import { dirname, join, relative } from "node:path"; 3import { parse as parseYaml } from "yaml"; 4import { glob } from "glob"; 5 6const LEXICONS_DIR = join(import.meta.dirname, "..", "lexicons"); 7const OUTPUT_DIR = join(import.meta.dirname, "..", "dist", "json"); 8 9async function main() { 10 const yamlFiles = await glob("**/*.yaml", { cwd: LEXICONS_DIR }); 11 12 for (const yamlFile of yamlFiles) { 13 const inputPath = join(LEXICONS_DIR, yamlFile); 14 const outputPath = join(OUTPUT_DIR, yamlFile.replace(/\.yaml$/, ".json")); 15 16 mkdirSync(dirname(outputPath), { recursive: true }); 17 18 const yamlContent = readFileSync(inputPath, "utf-8"); 19 const parsed = parseYaml(yamlContent); 20 writeFileSync(outputPath, JSON.stringify(parsed, null, 2) + "\n"); 21 22 console.log( 23 ` ${yamlFile} -> ${relative(join(import.meta.dirname, ".."), outputPath)}` 24 ); 25 } 26 27 console.log(`\nConverted ${yamlFiles.length} lexicon files.`); 28} 29 30main().catch((err) => { 31 console.error(err); 32 process.exit(1); 33});