-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.js
More file actions
85 lines (73 loc) · 2.68 KB
/
build.js
File metadata and controls
85 lines (73 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// node build.js to build
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
console.log(' Starting FlowState Build Process...\n');
function runCommand(command, description) {
console.log(` ${description}...`);
try {
execSync(command, { stdio: 'inherit' });
console.log(` ${description} completed\n`);
return true;
} catch (error) {
console.error(` ${description} failed:`, error.message);
return false;
}
}
function checkFile(filePath, description) {
if (fs.existsSync(filePath)) {
console.log(` ${description} found`);
return true;
} else {
console.log(` ${description} missing at: ${filePath}`);
return false;
}
}
// Pre-build checks
console.log('🔍 Pre-build Checks:\n');
const checks = [
checkFile('build/icon.ico', 'Icon file'),
checkFile('backend/Backend.csproj', 'Backend project'),
checkFile('electron/main.js', 'Electron main'),
checkFile('electron/preload.js', 'Electron preload')
];
if (checks.includes(false)) {
console.error('\n Pre-build checks failed. Please fix the issues above.\n');
process.exit(1);
}
console.log('\n All pre-build checks passed!\n');
// Step 1: Build Frontend (Vite)
if (!runCommand('npm run build --prefix frontend', 'Building frontend with Vite')) {
process.exit(1);
}
// Step 2: Build Backend (.NET)
const backendCommand = 'dotnet publish backend/Backend.csproj -c Release -o backend/bin/Release/net8.0/publish --self-contained false';
if (!runCommand(backendCommand, 'Building .NET backend')) {
process.exit(1);
}
// Step 3: Verify backend output
if (!checkFile('backend/bin/Release/net8.0/publish/Backend.exe', 'Backend executable')) {
console.error('❌ Backend build succeeded but .exe not found');
process.exit(1);
}
// Step 4: Install electron dependencies
console.log('Installing Electron dependencies...');
try {
if (fs.existsSync('electron/package.json')) {
execSync('cd electron && npm install', { stdio: 'inherit' });
console.log(' Electron dependencies installed\n');
}
} catch (error) {
console.error(' Failed to install electron dependencies');
}
// Step 5: Build Electron App
if (!runCommand('npx electron-builder --win', 'Building Electron installer')) {
process.exit(1);
}
console.log('\n Build Complete!\n');
console.log('Your installer is ready in: dist-electron/');
console.log('Installer name: FlowState Setup 1.0.0.exe\n');
console.log('Next steps:');
console.log(' 1. Test the installer on a clean Windows machine');
console.log(' 2. Share the .exe file with users');
console.log(' 3. Users run the installer to install FlowState\n');