farmcontrol-server/scripts/pre-build.mjs
Tom Butcher d867d017bb
Some checks reported errors
farmcontrol/farmcontrol-server/pipeline/head Something is wrong with the build of this commit
Enhance Electrobun configuration and build scripts
- Updated electrobun.config.ts to dynamically set the application version from package.json and added a release configuration for base URL.
- Modified Jenkinsfile to include the ELECTROBUN_RELEASE_BASE_URL environment variable during the build process.
- Refactored build-macos.mjs to streamline the build command execution for different architectures.
- Enhanced finalize-desktop-artifacts.mjs to improve artifact handling and introduced a new pre-build script for validation of required files and environment variables.
- Improved error handling and logging for better build process visibility.
2026-08-01 20:12:30 +01:00

39 lines
1.1 KiB
JavaScript

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})`);