48 lines
1.9 KiB
JavaScript
48 lines
1.9 KiB
JavaScript
#!/usr/bin/env node
|
|
import {
|
|
buildDungeonPack,
|
|
discoverDungeon,
|
|
enableDungeon,
|
|
validateDungeonPack,
|
|
} from "./lib.mjs";
|
|
import { bakeConversionNavigation, bakeDungeonNavigation } from "./recast-bake.mjs";
|
|
import { convertDungeonEnvironment } from "./convert-environment.mjs";
|
|
import { optimizeDungeonEnvironment } from "./optimize-environment.mjs";
|
|
import { exportClientDiscoveryTables, exportCreatureSource, exportDungeonSource } from "./export-source.mjs";
|
|
|
|
const [, , command, slug] = process.argv;
|
|
if (!command || !slug) {
|
|
console.error("Usage: node scripts/dungeon-pipeline/cli.mjs <discover|extract|creatures|convert|optimize|build|navmesh|navmesh-conversion|validate|enable> <slug>");
|
|
process.exitCode = 2;
|
|
} else {
|
|
try {
|
|
const result = command === "discover"
|
|
? (await exportClientDiscoveryTables(slug), await discoverDungeon(slug))
|
|
: command === "extract"
|
|
? await exportDungeonSource(slug)
|
|
: command === "creatures"
|
|
? await exportCreatureSource(slug)
|
|
: command === "convert"
|
|
? await convertDungeonEnvironment(slug)
|
|
: command === "optimize"
|
|
? await optimizeDungeonEnvironment(slug)
|
|
: command === "build"
|
|
? await buildDungeonPack(slug)
|
|
: command === "navmesh"
|
|
? await bakeDungeonNavigation(slug)
|
|
: command === "navmesh-conversion"
|
|
? await bakeConversionNavigation(slug)
|
|
: command === "validate"
|
|
? await validateDungeonPack(slug)
|
|
: command === "enable"
|
|
? await enableDungeon(slug)
|
|
: null;
|
|
if (!result) throw new Error(`Unknown dungeon pipeline command: ${command}`);
|
|
console.log(JSON.stringify(result, null, 2));
|
|
if (result.status === "blocked") process.exitCode = 1;
|
|
} catch (error) {
|
|
console.error(JSON.stringify({ status: "error", command, slug, error: error.message }, null, 2));
|
|
process.exitCode = 1;
|
|
}
|
|
}
|