Some checks failed
farmcontrol/farmcontrol-ui/pipeline/head There was a failure building this commit
- Updated electrobun.config.ts to include environment-based settings for macOS builds. - Added new build scripts for Windows and macOS, including support for architecture-specific builds. - Introduced scripts for cleaning build artifacts, managing dependencies, and ensuring core binaries are present. - Enhanced Jenkinsfile to integrate new build processes and improve artifact management. - Added new assets for application icons and installer configurations. - Implemented NSIS and MSI packaging scripts for Windows installer creation. - Updated package.json with new scripts for development and build processes, including post-installation tasks.
102 lines
2.6 KiB
JavaScript
102 lines
2.6 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",
|
|
"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.`,
|
|
);
|
|
}
|
|
}
|
|
|
|
const prepareIcons = spawnSync(
|
|
"bun",
|
|
[
|
|
path.join(rootDir, "scripts/prepare-app-icons.mjs"),
|
|
"assets/logos/farmcontrolicon.png",
|
|
],
|
|
{ cwd: rootDir, stdio: "inherit", env: process.env },
|
|
);
|
|
|
|
if (prepareIcons.status !== 0) {
|
|
process.exit(prepareIcons.status ?? 1);
|
|
}
|
|
|
|
const windowsIconPath = path.join(rootDir, "assets/icon.ico");
|
|
if (!existsSync(windowsIconPath)) {
|
|
console.error(
|
|
"pre-build: assets/icon.ico not found after prepare-app-icons (required for build.win.icon)",
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
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})`);
|