Some checks failed
farmcontrol/farmcontrol-server/pipeline/head There was a failure building this commit
- Updated electrobun.config.ts to include environment-based settings for stability and external dependencies. - Refactored package.json scripts for improved build processes and streamlined commands. - Added new build scripts for Linux and renderer, while removing the obsolete build-server script. - Enhanced pre-build validation to ensure required files are present and added logging for better visibility. - Updated clean-build script to remove additional artifact directories for thorough cleanup.
84 lines
2.2 KiB
JavaScript
84 lines
2.2 KiB
JavaScript
import { existsSync } from "node:fs";
|
|
import path from "node:path";
|
|
import { spawnSync } from "node:child_process";
|
|
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",
|
|
"src/app/index.html",
|
|
"src/app/main.jsx",
|
|
"electrobun.config.ts",
|
|
"package.json",
|
|
"config.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.`,
|
|
);
|
|
}
|
|
}
|
|
|
|
const writeBuildInfo = spawnSync(
|
|
"bun",
|
|
[path.join(rootDir, "scripts/write-build-info.mjs")],
|
|
{ cwd: rootDir, stdio: "inherit", env: process.env },
|
|
);
|
|
|
|
if (writeBuildInfo.status !== 0) {
|
|
process.exit(writeBuildInfo.status ?? 1);
|
|
}
|
|
|
|
if (buildEnv === "dev") {
|
|
console.log(
|
|
"pre-build: dev environment — skipping production renderer build (use dev:renderer for Vite)",
|
|
);
|
|
console.log(`pre-build: validation passed (${buildEnv})`);
|
|
process.exit(0);
|
|
}
|
|
|
|
const buildRenderer = spawnSync(
|
|
"bun",
|
|
[path.join(rootDir, "scripts/build-renderer.mjs")],
|
|
{
|
|
cwd: rootDir,
|
|
stdio: "inherit",
|
|
env: {
|
|
...process.env,
|
|
NODE_ENV: "production",
|
|
},
|
|
},
|
|
);
|
|
|
|
if (buildRenderer.status !== 0) {
|
|
process.exit(buildRenderer.status ?? 1);
|
|
}
|
|
|
|
const rendererIndex = path.join(rootDir, "dist/mainview/index.html");
|
|
if (!existsSync(rendererIndex)) {
|
|
console.error(`pre-build: renderer output not found: dist/mainview/index.html`);
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log(`pre-build: validation and renderer build passed (${buildEnv})`);
|