From 31fcbe99a9a0d453b59e34545e0cfdc5c43566a6 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 29 Oct 2025 17:39:39 -0500 Subject: [PATCH] Clean up some electron config --- electron/.gitignore | 2 + electron/test-config.js | 148 -------------------------------------- electron/test-terminal.js | 84 ---------------------- package.json | 3 +- 4 files changed, 3 insertions(+), 234 deletions(-) create mode 100644 electron/.gitignore delete mode 100755 electron/test-config.js delete mode 100644 electron/test-terminal.js diff --git a/electron/.gitignore b/electron/.gitignore new file mode 100644 index 00000000..85b552e2 --- /dev/null +++ b/electron/.gitignore @@ -0,0 +1,2 @@ +resources/icons +icon.ico \ No newline at end of file diff --git a/electron/test-config.js b/electron/test-config.js deleted file mode 100755 index 7c68eb0c..00000000 --- a/electron/test-config.js +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/env node - -/** - * Test script to validate electron-builder configuration - */ - -import fs from 'fs'; -import path from 'path'; -import { fileURLToPath } from 'url'; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -console.log('šŸ” Validating Electron build configuration...\n'); - -const errors = []; -const warnings = []; - -// Check if required files exist -const requiredFiles = [ - 'electron/main.js', - 'electron/preload.js', - 'electron/builder.config.js', - 'public/shakespeare-512x512.png', - 'package.json', -]; - -console.log('šŸ“ Checking required files:'); -requiredFiles.forEach(file => { - if (fs.existsSync(file)) { - console.log(` āœ… ${file}`); - } else { - console.log(` āŒ ${file}`); - errors.push(`Missing required file: ${file}`); - } -}); - -// Check if dist directory exists -console.log('\nšŸ“¦ Checking build output:'); -if (fs.existsSync('dist')) { - const distFiles = fs.readdirSync('dist'); - if (distFiles.includes('index.html')) { - console.log(' āœ… dist/index.html exists'); - } else { - console.log(' āŒ dist/index.html missing'); - errors.push('Run "npm run build" first to create dist/index.html'); - } -} else { - console.log(' āŒ dist directory missing'); - errors.push('Run "npm run build" first to create the dist directory'); -} - -// Check package.json -console.log('\nšŸ“„ Checking package.json:'); -try { - const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); - - if (pkg.main === 'electron/main.js') { - console.log(' āœ… main entry point set correctly'); - } else { - console.log(` āš ļø main entry point is "${pkg.main}" (expected "electron/main.js")`); - warnings.push('package.json main should be "electron/main.js"'); - } - - if (pkg.devDependencies?.electron) { - console.log(' āœ… electron dependency found'); - } else { - console.log(' āŒ electron dependency missing'); - errors.push('Install electron: npm install --save-dev electron'); - } - - if (pkg.devDependencies?.['electron-builder']) { - console.log(' āœ… electron-builder dependency found'); - } else { - console.log(' āŒ electron-builder dependency missing'); - errors.push('Install electron-builder: npm install --save-dev electron-builder'); - } -} catch (e) { - console.log(' āŒ Error reading package.json'); - errors.push(`Failed to read package.json: ${e.message}`); -} - -// Check builder config -console.log('\nāš™ļø Checking builder configuration:'); -try { - const configModule = await import('./builder.config.js'); - const config = configModule.default; - - if (config.appId) { - console.log(` āœ… appId: ${config.appId}`); - } else { - console.log(' āš ļø appId not set'); - warnings.push('Consider setting appId in builder.config.js'); - } - - if (config.productName) { - console.log(` āœ… productName: ${config.productName}`); - } else { - console.log(' āš ļø productName not set'); - warnings.push('Consider setting productName in builder.config.js'); - } - - // Check icon paths - const iconPaths = []; - if (config.mac?.icon) iconPaths.push({ platform: 'macOS', path: config.mac.icon }); - if (config.win?.icon) iconPaths.push({ platform: 'Windows', path: config.win.icon }); - if (config.linux?.icon) iconPaths.push({ platform: 'Linux', path: config.linux.icon }); - - console.log('\nšŸŽØ Checking icon configuration:'); - iconPaths.forEach(({ platform, path: iconPath }) => { - if (fs.existsSync(iconPath)) { - console.log(` āœ… ${platform}: ${iconPath}`); - } else { - console.log(` āš ļø ${platform}: ${iconPath} (will be generated from PNG)`); - } - }); - -} catch (e) { - console.log(' āŒ Error reading builder.config.js'); - errors.push(`Failed to read builder.config.js: ${e.message}`); -} - -// Summary -console.log('\n' + '='.repeat(60)); -if (errors.length === 0 && warnings.length === 0) { - console.log('āœ… Configuration is valid! Ready to build.'); - console.log('\nNext steps:'); - console.log(' Development: npm run electron:dev'); - console.log(' Build: npm run electron:build'); - process.exit(0); -} else { - if (errors.length > 0) { - console.log('āŒ Errors found:'); - errors.forEach(err => console.log(` - ${err}`)); - } - if (warnings.length > 0) { - console.log('\nāš ļø Warnings:'); - warnings.forEach(warn => console.log(` - ${warn}`)); - } - - if (errors.length > 0) { - console.log('\nāŒ Fix errors before building.'); - process.exit(1); - } else { - console.log('\nāœ… Configuration is valid (with warnings).'); - process.exit(0); - } -} diff --git a/electron/test-terminal.js b/electron/test-terminal.js deleted file mode 100644 index e52b3725..00000000 --- a/electron/test-terminal.js +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Test script to verify real terminal execution in Electron - * - * This script can be run in the Electron console to test the shell execution: - * - * 1. Start Electron: npm run electron:dev - * 2. Open DevTools - * 3. Copy and paste this code into the console - */ - -async function testElectronShell() { - console.log('Testing Electron Shell Execution...\n'); - - if (!window.electron?.shell) { - console.error('āŒ Not running in Electron or shell API not available'); - return; - } - - console.log('āœ… Electron shell API detected\n'); - - // Test 1: Simple echo command - console.log('Test 1: Echo command'); - try { - const result1 = await window.electron.shell.exec('echo "Hello from real shell!"'); - console.log('stdout:', result1.stdout); - console.log('stderr:', result1.stderr); - console.log('exitCode:', result1.exitCode); - console.log(result1.exitCode === 0 ? 'āœ… PASS\n' : 'āŒ FAIL\n'); - } catch (error) { - console.error('āŒ FAIL:', error.message, '\n'); - } - - // Test 2: List files - console.log('Test 2: List files'); - try { - const listCmd = process.platform === 'win32' ? 'dir' : 'ls -la'; - const result2 = await window.electron.shell.exec(listCmd); - console.log('stdout:', result2.stdout.substring(0, 200) + '...'); - console.log('exitCode:', result2.exitCode); - console.log(result2.exitCode === 0 ? 'āœ… PASS\n' : 'āŒ FAIL\n'); - } catch (error) { - console.error('āŒ FAIL:', error.message, '\n'); - } - - // Test 3: Check Node.js version - console.log('Test 3: Node.js version'); - try { - const result3 = await window.electron.shell.exec('node --version'); - console.log('stdout:', result3.stdout); - console.log('exitCode:', result3.exitCode); - console.log(result3.exitCode === 0 ? 'āœ… PASS\n' : 'āŒ FAIL\n'); - } catch (error) { - console.error('āŒ FAIL:', error.message, '\n'); - } - - // Test 4: Error handling (non-existent command) - console.log('Test 4: Non-existent command'); - try { - const result4 = await window.electron.shell.exec('this-command-does-not-exist'); - console.log('stdout:', result4.stdout); - console.log('stderr:', result4.stderr); - console.log('exitCode:', result4.exitCode); - console.log(result4.exitCode !== 0 ? 'āœ… PASS (expected failure)\n' : 'āŒ FAIL\n'); - } catch (error) { - console.log('āœ… PASS (error caught as expected)\n'); - } - - // Test 5: Working directory - console.log('Test 5: Working directory'); - try { - const pwdCmd = process.platform === 'win32' ? 'cd' : 'pwd'; - const result5 = await window.electron.shell.exec(pwdCmd); - console.log('stdout:', result5.stdout); - console.log('Should contain "shakespeare":', result5.stdout.includes('shakespeare')); - console.log(result5.stdout.includes('shakespeare') ? 'āœ… PASS\n' : 'āŒ FAIL\n'); - } catch (error) { - console.error('āŒ FAIL:', error.message, '\n'); - } - - console.log('All tests completed!'); -} - -// Run the tests -testElectronShell(); diff --git a/package.json b/package.json index fedb8a5a..a02df255 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,7 @@ "electron:build:win": "npm run build && electron-builder --win --config electron/builder.config.js", "electron:build:linux": "npm run build && electron-builder --linux --config electron/builder.config.js", "electron:build:all": "npm run build && electron-builder --mac --win --linux --config electron/builder.config.js", - "electron:icons": "bash electron/generate-icons.sh", - "electron:validate": "node electron/test-config.js" + "electron:icons": "./electron/generate-icons.sh" }, "dependencies": { "@dnd-kit/core": "^6.3.1",