45 lines
1.5 KiB
JavaScript
45 lines
1.5 KiB
JavaScript
#!/usr/bin/env node
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { discoverDungeon, readJson } from "./lib.mjs";
|
|
|
|
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
const serverData = path.join(projectRoot, "..", "HealerMan-Storage", "pipeline-work", "dungeons", "server-data");
|
|
const campaignFile = path.join(projectRoot, "dungeon-pipeline", "dungeon-campaign.json");
|
|
|
|
async function campaignSlugs() {
|
|
const campaign = await readJson(campaignFile);
|
|
return campaign.dungeons.map((entry) => entry.slug);
|
|
}
|
|
|
|
const requested = process.argv.slice(2);
|
|
const slugs = requested.length ? requested : await campaignSlugs();
|
|
if (!process.env.WOW_SERVER_DATA) process.env.WOW_SERVER_DATA = serverData;
|
|
|
|
const reports = [];
|
|
for (const slug of slugs) {
|
|
try {
|
|
const report = await discoverDungeon(slug);
|
|
reports.push({
|
|
slug,
|
|
status: report.status,
|
|
blockers: report.blockers.length,
|
|
});
|
|
} catch (error) {
|
|
reports.push({
|
|
slug,
|
|
status: "error",
|
|
blockers: 1,
|
|
error: error instanceof Error ? error.message : String(error),
|
|
});
|
|
}
|
|
}
|
|
|
|
console.log(JSON.stringify({
|
|
status: reports.some((report) => report.status === "error") ? "error" : "complete",
|
|
serverData: path.relative(projectRoot, process.env.WOW_SERVER_DATA).replace(/\\/g, "/"),
|
|
dungeons: reports.length,
|
|
reports,
|
|
}, null, 2));
|
|
if (reports.some((report) => report.status === "error")) process.exitCode = 1;
|