Fixed linux and macOS builds.
Some checks failed
farmcontrol/farmcontrol-server/pipeline/head There was a failure building this commit

This commit is contained in:
Tom Butcher 2025-12-29 01:32:51 +00:00
parent c9c59c2bff
commit d01355bee1
2 changed files with 24 additions and 12 deletions

View File

@ -20,9 +20,6 @@
"author": "Tom Butcher", "author": "Tom Butcher",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@ant-design/icons": "^6.1.0",
"ant-design": "^1.0.0",
"antd": "^5.28.0",
"axios": "^1.13.2", "axios": "^1.13.2",
"canvas": "^3.2.0", "canvas": "^3.2.0",
"etcd3": "^1.1.2", "etcd3": "^1.1.2",
@ -36,13 +33,14 @@
"node-cache": "^5.1.2", "node-cache": "^5.1.2",
"node-thermal-printer": "^4.5.0", "node-thermal-printer": "^4.5.0",
"pdf-to-img": "^5.0.0", "pdf-to-img": "^5.0.0",
"prop-types": "^15.8.1",
"sharp": "^0.34.5", "sharp": "^0.34.5",
"socket.io": "^4.8.1", "socket.io": "^4.8.1",
"socket.io-client": "^4.8.1", "socket.io-client": "^4.8.1",
"ws": "^8.18.3" "ws": "^8.18.3"
}, },
"devDependencies": { "devDependencies": {
"@ant-design/icons": "^6.1.0",
"antd": "^5.28.0",
"@electron/rebuild": "^4.0.1", "@electron/rebuild": "^4.0.1",
"@vitejs/plugin-react": "^5.1.1", "@vitejs/plugin-react": "^5.1.1",
"concurrently": "^9.2.1", "concurrently": "^9.2.1",
@ -52,6 +50,7 @@
"jest": "^30.2.0", "jest": "^30.2.0",
"nodemon": "^3.1.11", "nodemon": "^3.1.11",
"pkg": "^5.8.1", "pkg": "^5.8.1",
"prop-types": "^15.8.1",
"react": "^19.2.0", "react": "^19.2.0",
"react-dom": "^19.2.0", "react-dom": "^19.2.0",
"rimraf": "^6.1.2", "rimraf": "^6.1.2",

View File

@ -36,9 +36,22 @@ export async function createElectronWindow() {
const __filename = fileURLToPath(import.meta.url); const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename); const __dirname = path.dirname(__filename);
// Determine if we are running from the build directory or src
const isRunningFromBuild =
__dirname.includes(path.sep + "build") || __dirname.includes("app.asar");
return new Promise((resolve) => { return new Promise((resolve) => {
function createWindow() { function createWindow() {
logger.debug("Creating browser window..."); logger.debug("Creating browser window...");
// Resolve paths correctly based on environment
const preloadPath =
process.env.NODE_ENV === "development"
? path.join(__dirname, "preload.js")
: isRunningFromBuild
? path.join(__dirname, "preload.js")
: path.join(__dirname, "..", "build", "electron", "preload.js");
const win = new BrowserWindow({ const win = new BrowserWindow({
width: 900, width: 900,
height: 600, height: 600,
@ -49,25 +62,25 @@ export async function createElectronWindow() {
webPreferences: { webPreferences: {
nodeIntegration: true, nodeIntegration: true,
contextIsolation: true, contextIsolation: true,
preload: preload: preloadPath,
process.env.NODE_ENV === "development"
? path.join(__dirname, "preload.js")
: path.join(__dirname, "..", "build", "electron", "preload.js"),
}, },
}); });
// Make the window globally accessible for IPC // Make the window globally accessible for IPC
global.mainWindow = win; global.mainWindow = win;
logger.info("Preload Script", path.join(__dirname, "preload.js")); logger.info("Preload Script", preloadPath);
if (process.env.NODE_ENV === "development") { if (process.env.NODE_ENV === "development") {
logger.info("Loading development url..."); logger.info("Loading development url...");
win.loadURL("http://localhost:5287"); // Vite dev server win.loadURL("http://localhost:5287"); // Vite dev server
} else { } else {
// In production, the built files will be in the build/electron directory // In production, the built files will be in the build/electron directory
win.loadFile( const htmlPath = isRunningFromBuild
path.join(__dirname, "..", "build", "electron", "index.html") ? path.join(__dirname, "index.html")
); : path.join(__dirname, "..", "build", "electron", "index.html");
logger.info("Loading production file:", htmlPath);
win.loadFile(htmlPath);
} }
// Resolve the promise when the window is ready // Resolve the promise when the window is ready