Files
TimeTracker/desktop/scripts/build-all-platforms.js
T
Dries Peeters bd5d4d0cc7 fix: client portal projects layout and desktop app refresh
Client portal: add min-w-0, break-words, and flex gap/shrink utilities on
the projects grid cards so long project names no longer force horizontal
overflow and clip against the viewport edge.

Desktop: add app and tray icons, adjust Electron main process (window,
tray, lifecycle), renderer connection and API client updates, build script
and package metadata, and regenerate the bundled renderer script.
2026-04-25 08:07:16 +02:00

84 lines
3.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
/**
* Platform-aware build script for electron-builder
* Builds for all platforms supported on the current OS
*/
const { execSync } = require('child_process');
const os = require('os');
const platform = os.platform();
let buildCommand = 'electron-builder';
console.log(`\n🔨 Building for all supported platforms on ${platform}\n`);
console.log('📦 Building renderer bundle...');
execSync('npm run build:renderer', { stdio: 'inherit' });
console.log('');
// Determine which platforms can be built on the current OS
switch (platform) {
case 'win32':
// Windows can technically build Linux, but requires admin privileges for symlinks
// For better UX, only build Windows on Windows by default
// Use --linux flag explicitly if admin privileges are available
const buildLinux = process.env.BUILD_LINUX_ON_WINDOWS === 'true';
if (buildLinux) {
console.log('📦 Building for Windows and Linux...');
console.log('⚠️ Linux builds on Windows require administrator privileges for symlinks.');
console.log(' If this fails, run as administrator or use: npm run build:win\n');
buildCommand += ' --win --linux';
} else {
console.log('📦 Building for Windows only...');
console.log('️ Linux builds on Windows require admin privileges (symlinks).');
console.log(' To build Linux too, set BUILD_LINUX_ON_WINDOWS=true and run as admin.\n');
buildCommand += ' --win';
}
break;
case 'darwin':
// macOS can build: Windows, macOS, Linux
console.log('📦 Building for Windows, macOS, and Linux...');
console.log('️ All platforms supported on macOS!\n');
buildCommand += ' --win --mac --linux';
break;
case 'linux':
// Linux can build: Windows, Linux
console.log('📦 Building for Windows and Linux...');
console.log('️ macOS builds require macOS. Skipping macOS build.\n');
buildCommand += ' --win --linux';
break;
default:
console.error(`❌ Unknown platform: ${platform}`);
console.log('📦 Building for current platform only...\n');
// Just build for current platform
break;
}
// Disable code signing for Windows unless certificate is explicitly provided
if (platform === 'win32') {
if (process.env.CSC_LINK || process.env.CSC_LINK_FILE) {
console.log('️ Code signing will be enabled (certificate detected)\n');
} else {
console.log('️ No signing certificate configured; building unsigned Windows artifacts.\n');
}
}
try {
execSync(buildCommand, { stdio: 'inherit' });
console.log('\n✅ Build completed successfully!');
} catch (error) {
if (platform === 'win32') {
console.error('\n❌ Build failed!');
console.error('\n💡 Troubleshooting tips for Windows:');
console.error(' 1. Try running as Administrator');
console.error(' 2. Clear electron-builder cache: rmdir /s /q "%LOCALAPPDATA%\\electron-builder\\Cache"');
console.error(' 3. Build Windows only: npm run build:win');
console.error(' 4. Disable OneDrive sync for the desktop folder');
} else {
console.error('\n❌ Build failed!');
}
process.exit(1);
}