diff --git a/BUILDING.md b/BUILDING.md index f0d68eb..e3b1086 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -42,24 +42,46 @@ To build for web deployment: ## Desktop Build (Electron) -To build the desktop application: +### Building for Linux -0. You must web build first: +1. First build the web assets: ```bash npm run build ``` -1. Run the Electron build: +2. Package the Electron app for Linux: ```bash - npm run build:electron + # For AppImage (recommended) + npm run electron:build-linux + + # For .deb package + npm run electron:build-linux-deb ``` -2. The built files will be in `dist-electron`. +2. The packaged applications will be in `dist-electron-packages/`: + - AppImage: `dist-electron-packages/TimeSafari-x.x.x.AppImage` + - DEB: `dist-electron-packages/timesafari_x.x.x_amd64.deb` -3. To run the desktop app: - ```bash - npx electron dist-electron - ``` +### Running the Packaged App + +- AppImage: Make executable and run + ```bash + chmod +x dist-electron-packages/TimeSafari-*.AppImage + ./dist-electron-packages/TimeSafari-*.AppImage + ``` + +- DEB: Install and run + ```bash + sudo dpkg -i dist-electron-packages/timesafari_*_amd64.deb + timesafari + ``` + +### Development Testing + +For testing the Electron build before packaging: +```bash +npm run electron:dev +``` ## Mobile Builds (Capacitor) diff --git a/package.json b/package.json index b9b8e32..447ffe3 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,12 @@ "build:electron": "npm run clean:electron && vite build --mode electron && node scripts/build-electron.js", "build:capacitor": "vite build --mode capacitor", "build:web": "vite build", - "electron:dev": "npm run build:electron && electron dist-electron --inspect", - "electron:start": "electron dist-electron" + "electron:dev": "npm run build && electron dist-electron", + "electron:start": "electron dist-electron", + "electron:build-linux": "electron-builder --linux AppImage", + "electron:build-linux-deb": "electron-builder --linux deb", + "build:electron-prod": "NODE_ENV=production npm run build:electron", + "electron:build-linux-prod": "npm run build:electron-prod && electron-builder --linux AppImage" }, "dependencies": { "@capacitor/android": "^6.2.0", @@ -122,13 +126,14 @@ }, "main": "./dist-electron/main.js", "build": { - "appId": "app.timesafari.app", + "appId": "org.timesafari.app", "productName": "TimeSafari", "directories": { - "output": "dist-electron-build" + "output": "dist-electron-packages" }, "files": [ - "dist-electron/**/*" + "dist-electron/**/*", + "src/electron/**/*" ], "extraResources": [ { @@ -137,11 +142,9 @@ } ], "linux": { - "target": [ - "AppImage" - ], - "category": "Utility", - "icon": "build/icons" + "target": ["AppImage", "deb"], + "category": "Office", + "icon": "build/icon.png" }, "asar": true } diff --git a/src/electron/main.js b/src/electron/main.js index de80700..02d01b2 100644 --- a/src/electron/main.js +++ b/src/electron/main.js @@ -39,7 +39,6 @@ function createWindow() { }, (details, callback) => { let url = details.url; - console.log("Intercepting asset request:", url); // Handle paths that don't start with file:// if (!url.startsWith("file://") && url.includes("/assets/")) { @@ -56,7 +55,6 @@ function createWindow() { : `file://${__dirname}`; const assetPath = url.split("/assets/")[1]; const newUrl = `${baseDir}/www/assets/${assetPath}`; - console.log("Redirecting to:", newUrl); callback({ redirectURL: newUrl }); return; } @@ -64,19 +62,25 @@ function createWindow() { callback({}); // No redirect for other URLs }, ); - // Debug info - console.log("Debug Info:"); - console.log("Running in dev mode:", isDev); - console.log("App is packaged:", app.isPackaged); - console.log("Process resource path:", process.resourcesPath); - console.log("App path:", app.getAppPath()); - console.log("__dirname:", __dirname); - console.log("process.cwd():", process.cwd()); + + if (isDev) { + // Debug info + console.log("Debug Info:"); + console.log("Running in dev mode:", isDev); + console.log("App is packaged:", app.isPackaged); + console.log("Process resource path:", process.resourcesPath); + console.log("App path:", app.getAppPath()); + console.log("__dirname:", __dirname); + console.log("process.cwd():", process.cwd()); + } const indexPath = path.join(__dirname, "www", "index.html"); - console.log("Loading index from:", indexPath); - console.log("www path:", path.join(__dirname, "www")); - console.log("www assets path:", path.join(__dirname, "www", "assets")); + + if (isDev) { + console.log("Loading index from:", indexPath); + console.log("www path:", path.join(__dirname, "www")); + console.log("www assets path:", path.join(__dirname, "www", "assets")); + } if (!fs.existsSync(indexPath)) { console.error(`Index file not found at: ${indexPath}`);