25 lines
874 B
JavaScript
25 lines
874 B
JavaScript
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
import { spawnSync } from "node:child_process";
|
|
import { dirname, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
const bun = process.env.BUN_BIN || "bun";
|
|
|
|
function run(args) {
|
|
const result = spawnSync(bun, args, {
|
|
cwd: root,
|
|
stdio: "inherit"
|
|
});
|
|
if (result.error) throw result.error;
|
|
if (result.status !== 0) {
|
|
throw new Error(`${bun} ${args.join(" ")} failed with status ${result.status}`);
|
|
}
|
|
}
|
|
|
|
const mcpOutput = resolve(root, "dist/mcp/server.js");
|
|
mkdirSync(dirname(mcpOutput), { recursive: true });
|
|
run(["build", "src/server.ts", "--target=node", "--outfile", mcpOutput]);
|
|
writeFileSync(mcpOutput, readFileSync(mcpOutput, "utf8").replace(/[ \t]+$/gm, ""));
|
|
run(["run", "build:binary"]);
|