-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathelectron-builder.js
More file actions
99 lines (94 loc) · 3.38 KB
/
Copy pathelectron-builder.js
File metadata and controls
99 lines (94 loc) · 3.38 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
* electron-builder configuration.
*
* JS config (rather than package.json) so we can:
* - Conditionally skip Windows code signing without a certificate (local dev)
* - Use afterPack hook to rename vendor/ -> node_modules/ for ESM resolution
*/
const path = require('path');
const fs = require('fs');
const hasWindowsCert = !!process.env.WIN_CSC_LINK;
module.exports = {
appId: 'com.elisa.app',
productName: 'Elisa',
directories: {
output: 'release',
},
files: [
'electron/dist/**/*',
'electron/settings.html',
],
extraResources: [
{
from: 'frontend/dist',
to: 'frontend-dist',
},
{
from: 'backend/dist',
to: 'backend-dist',
filter: ['**/*'],
},
{
from: 'devices/_shared',
to: 'devices/_shared',
},
// Game/graphics framework libraries (Phaser, p5.js, Three.js)
...(fs.existsSync(path.join(__dirname, 'build', 'frameworks', 'manifest.json'))
? [{ from: 'build/frameworks', to: 'frameworks' }]
: []),
// MinGit: bundled Git + bash for Windows (Claude Code CLI requires git-bash)
...(process.platform === 'win32' && fs.existsSync(path.join(__dirname, 'build', 'mingit', 'cmd', 'git.exe'))
? [{ from: 'build/mingit', to: 'mingit' }]
: []),
],
win: {
target: 'nsis',
icon: 'build/icon.ico',
// Skip signing when no certificate is available (local dev).
// With a cert (CI), omit signExts so the default (.exe) applies.
...(hasWindowsCert ? {} : { signAndEditExecutable: false }),
},
mac: {
target: ['dmg', 'zip'],
category: 'public.app-category.developer-tools',
hardenedRuntime: true,
gatekeeperAssess: false,
},
nsis: {
oneClick: false,
perMachine: false,
allowToChangeInstallationDirectory: true,
},
publish: {
provider: 'github',
owner: 'zoidbergclawd',
repo: 'elisa',
},
afterPack(context) {
// Rename vendor/ back to node_modules/ so ESM import resolution works.
// We use "vendor" during build to prevent electron-builder from filtering
// out the directory (it strips node_modules from extraResources).
//
// On macOS, appOutDir is e.g. release/mac-arm64 and resources live inside
// Elisa.app/Contents/Resources/. On Windows/Linux, they're at appOutDir/resources/.
const appName = context.packager.appInfo.productFilename;
const isMac = process.platform === 'darwin';
const resourcesDir = isMac
? path.join(context.appOutDir, `${appName}.app`, 'Contents', 'Resources')
: path.join(context.appOutDir, 'resources');
const vendor = path.join(resourcesDir, 'backend-dist', 'vendor');
const nodeModules = path.join(resourcesDir, 'backend-dist', 'node_modules');
console.log(`afterPack: renaming ${vendor} -> ${nodeModules} (exists: ${fs.existsSync(vendor)})`);
if (fs.existsSync(vendor)) {
fs.renameSync(vendor, nodeModules);
}
// Verify critical files exist after rename
const cliJs = path.join(nodeModules, '@anthropic-ai', 'claude-agent-sdk', 'cli.js');
const sdkMjs = path.join(nodeModules, '@anthropic-ai', 'claude-agent-sdk', 'sdk.mjs');
console.log(`afterPack: cli.js exists: ${fs.existsSync(cliJs)}`);
console.log(`afterPack: sdk.mjs exists: ${fs.existsSync(sdkMjs)}`);
if (!fs.existsSync(cliJs)) {
console.error(`afterPack: CRITICAL -- cli.js missing at ${cliJs}. Agent builds will fail in production.`);
}
},
};