import { existsSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); const buildEnv = process.env.ELECTROBUN_BUILD_ENV || "dev"; const requiredFiles = [ "src/bun/index.js", "electrobun.config.ts", "package.json", ]; for (const relativePath of requiredFiles) { const filePath = path.join(rootDir, relativePath); if (!existsSync(filePath)) { console.error(`pre-build: required file not found: ${relativePath}`); process.exit(1); } } if (buildEnv === "stable" && process.env.ELECTROBUN_OS === "macos") { const codesignVars = [ "ELECTROBUN_DEVELOPER_ID", "ELECTROBUN_APPLEID", "ELECTROBUN_APPLEIDPASS", "ELECTROBUN_TEAMID", ]; const missing = codesignVars.filter((name) => !process.env[name]); if (missing.length > 0) { console.warn( `pre-build: stable macOS build without code signing credentials (${missing.join(", ")}); Electrobun will skip signing.`, ); } } console.log(`pre-build: validation passed (${buildEnv})`);