feat(FN-1073): add desktop CLI workflow and packaging support
- Add new `fn desktop` CLI command with argument handling and comprehensive command/bin tests - Implement desktop build and hot-reload dev scripts and wire package scripts/dependencies for Electron workflows - Add electron-builder configuration and desktop main-process/integration test coverage to stabilize packaging behavior - Document desktop development and usage in README files and include a changeset for the published CLI package
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { app, BrowserWindow, nativeImage, Tray } from "electron";
|
||||
import { join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
import { setupDeepLinkHandler, registerDeepLinkProtocol } from "./deep-link.js";
|
||||
import { registerIpcHandlers } from "./ipc.js";
|
||||
import { buildAppMenu } from "./menu.js";
|
||||
@@ -17,11 +17,33 @@ interface AppWithQuitFlag {
|
||||
isQuitting?: boolean;
|
||||
}
|
||||
|
||||
const DEFAULT_DEV_DASHBOARD_URL = "http://localhost:5173";
|
||||
|
||||
function isDevelopmentMode(): boolean {
|
||||
return process.env.NODE_ENV === "development" || process.argv.includes("--dev");
|
||||
}
|
||||
|
||||
const PRODUCTION_DASHBOARD_URL = pathToFileURL(
|
||||
join(import.meta.dirname, "client", "index.html"),
|
||||
).toString();
|
||||
|
||||
export const IS_DEVELOPMENT = isDevelopmentMode();
|
||||
export const DASHBOARD_URL = process.env.FUSION_DASHBOARD_URL ?? (
|
||||
IS_DEVELOPMENT ? DEFAULT_DEV_DASHBOARD_URL : PRODUCTION_DASHBOARD_URL
|
||||
);
|
||||
|
||||
function enableSourceMaps(): void {
|
||||
const processWithSourceMaps = process as NodeJS.Process & {
|
||||
setSourceMapsEnabled?: (enabled: boolean) => void;
|
||||
};
|
||||
processWithSourceMaps.setSourceMapsEnabled?.(true);
|
||||
}
|
||||
|
||||
enableSourceMaps();
|
||||
|
||||
let mainWindow: BrowserWindow | null = null;
|
||||
let tray: Tray | null = null;
|
||||
|
||||
export const DASHBOARD_URL = process.env.FUSION_DASHBOARD_URL || "http://localhost:4040";
|
||||
|
||||
function getAppWithQuitFlag(): Electron.App & AppWithQuitFlag {
|
||||
return app as Electron.App & AppWithQuitFlag;
|
||||
}
|
||||
@@ -35,7 +57,7 @@ export function createMainWindow(state?: WindowState): BrowserWindow {
|
||||
...(hasValidPosition ? { x: state.x, y: state.y } : {}),
|
||||
title: "Fusion",
|
||||
webPreferences: {
|
||||
preload: join(import.meta.dirname, "preload.ts"),
|
||||
preload: join(import.meta.dirname, "preload.js"),
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user