feat: add module build service with nasher compile and pack

This commit is contained in:
plenarius
2026-04-20 19:50:07 -04:00
parent b7177a8fd7
commit 59909a7b48
3 changed files with 71 additions and 0 deletions
@@ -0,0 +1,43 @@
import { runEphemeralContainer } from "./docker.service.js";
import {
getWorkspacePath,
getServerPath,
} from "./workspace.service.js";
import { broadcast } from "./ws.service.js";
export async function buildModule(
target: string = "bare",
mode: "compile" | "pack" = "compile",
): Promise<{ success: boolean; output: string }> {
const workspacePath = getWorkspacePath();
const cmd =
mode === "compile"
? ["nasher", "compile", target, "--yes"]
: ["nasher", "pack", target, "--yes"];
broadcast("build", "start", { type: "module", target, mode });
const result = await runEphemeralContainer({
image: "layonara-builder",
cmd,
binds: [
`${workspacePath}/repos/nwn-module:/build/nwn-module`,
`${workspacePath}/server/modules:/output/modules`,
],
workingDir: "/build/nwn-module",
});
const success = result.statusCode === 0;
broadcast("build", success ? "complete" : "failed", {
type: "module",
target,
mode,
exitCode: result.statusCode,
});
if (success && mode === "pack") {
broadcast("build", "info", { message: "Module packed successfully" });
}
return { success, output: result.output };
}