Files
scrollsmith/index.js
Madison Grubb 1e1d745e55
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
rework to allow for image gen
2025-09-04 16:52:13 -04:00

36 lines
1.1 KiB
JavaScript

import 'dotenv/config';
import { generateDungeon } from "./dungeonGenerator.js";
import { generateDungeonImages } from "./imageGenerator.js";
import { generatePDF } from "./generatePDF.js";
// Utility to create a filesystem-safe filename from the dungeon title
function slugify(text) {
return text
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-') // replace non-alphanumeric with hyphens
.replace(/^-+|-+$/g, ''); // trim leading/trailing hyphens
}
(async () => {
try {
// Generate the dungeon data
const dungeonData = await generateDungeon();
// Generate dungeon map image (uses dungeonData.flavor)
console.log("🖼️ Generating dungeon map image...");
const mapPath = await generateDungeonImages(dungeonData);
dungeonData.map = mapPath;
// Generate PDF filename based on the title
const filename = `${slugify(dungeonData.title)}.pdf`;
// Generate the PDF using full dungeon data (including map)
await generatePDF(dungeonData, filename);
console.log(`Dungeon PDF successfully generated: ${filename}`);
} catch (err) {
console.error("Error generating dungeon:", err);
}
})();