mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-03 07:57:22 +00:00
Clean up some electron config
This commit is contained in:
4 files changed
+3
-234
No files matched your search
@@ -0,0 +1,2 @@
|
||||
resources/icons
|
||||
icon.ico
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
+1
-2
@@ -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",
|
||||
|
||||
Reference in new issue
Block a user