import { renderMermaidSVG } from "beautiful-mermaid"; const args = process.argv.slice(2); if (args.length < 2) { console.error("Usage: bun index.ts "); console.error("Example: bun index.ts diagram.mmd output.svg"); process.exit(1); } const [inputPath, outputPath] = args; try { // Read the .mmd file const diagramText = await Bun.file(inputPath).text(); // Render to SVG const svg = renderMermaidSVG(diagramText); // Write to output file await Bun.write(outputPath, svg); console.log(`✓ Generated SVG: ${outputPath}`); } catch (error) { if (error instanceof Error && "code" in error && error.code === "ENOENT") { console.error(`✗ Input file not found: ${inputPath}`); } else { console.error(`✗ Error: ${error instanceof Error ? error.message : String(error)}`); } process.exit(1); }