import path from "node:path";
import { fileURLToPath } from "node:url";

const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const buildNumber =
  process.env.BUILD_NUMBER || process.env.VITE_BUILD_NUMBER || "dev";

const buildInfoPath = path.join(rootDir, "src/buildInfo.json");

await Bun.write(
  buildInfoPath,
  `${JSON.stringify({ buildNumber }, null, 2)}\n`,
);

console.log(`write-build-info: ${buildInfoPath} (buildNumber=${buildNumber})`);
