From 7ad3602969e6cb8fb223aff46ff666b6f5378463 Mon Sep 17 00:00:00 2001 From: Nicole Rappe Date: Sun, 10 Aug 2025 01:54:37 -0600 Subject: [PATCH] Removed Electron Testing Code --- Data/Electron/main.js | 108 ----------------------------------- Data/Electron/package.json | 40 ------------- Data/Electron/vite.config.ts | 16 ------ 3 files changed, 164 deletions(-) delete mode 100644 Data/Electron/main.js delete mode 100644 Data/Electron/package.json delete mode 100644 Data/Electron/vite.config.ts diff --git a/Data/Electron/main.js b/Data/Electron/main.js deleted file mode 100644 index add151e..0000000 --- a/Data/Electron/main.js +++ /dev/null @@ -1,108 +0,0 @@ -////////// PROJECT FILE SEPARATION LINE ////////// CODE AFTER THIS LINE ARE FROM: /Data/Electron/main.js -const { app, BrowserWindow } = require('electron') -const path = require('path') -const { spawn } = require('child_process') -const http = require('http') - -function startBackend() { - // In dev, __dirname is ElectronApp/, so base= one level up (project root). - // In prod, process.resourcesPath points at the unpacked resources folder. - const base = app.isPackaged - ? process.resourcesPath - : path.resolve(__dirname, '..') - - // Path to your bundled venv python.exe (or python3 on Unix) - const pythonExe = path.join( - base, - 'Server', - 'Scripts', - process.platform === 'win32' ? 'python.exe' : 'python3' - ) - - // Path to the Flask server entrypoint - const serverScript = path.join(base, 'Server', 'Borealis', 'server.py') - - console.log(`[backend] Launching: ${pythonExe} ${serverScript}`) - const proc = spawn(pythonExe, [serverScript], { - cwd: path.dirname(serverScript), - stdio: ['ignore', 'pipe', 'pipe'] - }) - - proc.stdout.on('data', (data) => { - console.log(`[backend stdout] ${data.toString().trim()}`) - }) - proc.stderr.on('data', (data) => { - console.error(`[backend stderr] ${data.toString().trim()}`) - }) - proc.on('exit', (code) => { - console.log(`[backend] exited with code ${code}`) - }) - - return proc -} - -function waitForServer(url, timeout = 10000) { - return new Promise((resolve, reject) => { - const start = Date.now() - ;(function attempt() { - http.get(url, (res) => { - if (res.statusCode >= 200 && res.statusCode < 400) { - resolve() - } else if (Date.now() - start > timeout) { - reject(new Error('Server did not start in time')) - } else { - setTimeout(attempt, 200) - } - }).on('error', () => { - if (Date.now() - start > timeout) { - reject(new Error('Server did not start in time')) - } else { - setTimeout(attempt, 200) - } - }) - })() - }) -} - -async function createWindow() { - const win = new BrowserWindow({ - width: 1280, - height: 800, - webPreferences: { nodeIntegration: false } - }) - - if (process.env.NODE_ENV === 'development') { - // If you still run CRA dev server for debugging - win.loadURL('http://localhost:3000') - } else { - // Load the built CRA files - const indexPath = path.join(__dirname, 'renderer', 'index.html') - win.loadFile(indexPath) - } -} - -app.whenReady().then(async () => { - const backend = startBackend() - - try { - // Wait for Flask (default port 5000) - await waitForServer('http://localhost:5000') - await createWindow() - } catch (err) { - console.error(err) - app.quit() - return - } - - app.on('activate', () => { - if (BrowserWindow.getAllWindows().length === 0) { - createWindow() - } - }) -}) - -app.on('window-all-closed', () => { - if (process.platform !== 'darwin') { - app.quit() - } -}) diff --git a/Data/Electron/package.json b/Data/Electron/package.json deleted file mode 100644 index 701b1eb..0000000 --- a/Data/Electron/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "borealis", - "version": "0.1.0", - "description": "Borealis Desktop", - "author": "Nicole Rappe", - "main": "main.js", - "scripts": { - "dev": "electron .", - "dist": "electron-builder" - }, - "dependencies": { - "electron": "26.0.0" - }, - "devDependencies": { - "electron-builder": "26.0.12" - }, - "build": { - "appId": "io.bunny-lab.borealis", - "directories": { - "buildResources": "assets", - "output": "dist_electron" - }, - "files": [ - "Server/**", - "renderer/**", - "main.js" - ], - "extraResources": [ - { - "from": "Server/", - "to": "Server", - "filter": ["**/*"] - } - ], - "win": { "target": "nsis" }, - "mac": { "target": "dmg" }, - "linux": { "target": "AppImage" } - } - } - \ No newline at end of file diff --git a/Data/Electron/vite.config.ts b/Data/Electron/vite.config.ts deleted file mode 100644 index 927f95e..0000000 --- a/Data/Electron/vite.config.ts +++ /dev/null @@ -1,16 +0,0 @@ -////////// PROJECT FILE SEPARATION LINE ////////// CODE AFTER THIS LINE ARE FROM: /Data/Electron/vite.config.ts - -import { defineConfig } from 'vite' -import react from '@vitejs/plugin-react' -import path from 'path' - -export default defineConfig({ - root: path.resolve(__dirname, 'renderer'), - build: { - outDir: path.resolve(__dirname, 'dist/renderer') - }, - server: { - port: 5173 - }, - plugins: [react()] -})