Repository navigation
Expand file tree
/
Copy pathforge.config.js
More file actions
169 lines (164 loc) · 7.04 KB
/
Copy pathforge.config.js
File metadata and controls
169 lines (164 loc) · 7.04 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
const fs = require('fs');
const path = require('path');
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
const { FuseV1Options, FuseVersion } = require('@electron/fuses');
const buildMode = process.env.EMUCFG_BUILD_MODE || 'release';
// Linux icon path constant for makers (deb, rpm)
const LINUX_ICON = path.resolve(__dirname, 'assets/linux/icon/emu_icon_128.png');
// Handle graceful shutdown in development mode
// When yarn dev receives Ctrl+C, exit cleanly.
// The Electron process will be terminated automatically when this parent exits.
// Avoid using killall/taskkill as they can kill unrelated Electron apps (VSCode, Slack, etc.).
if (process.env.NODE_ENV !== 'production') {
process.on('SIGINT', () => {
console.log('[forge.config.js] SIGINT received, exiting gracefully...');
process.exit(0);
});
}
module.exports = {
packagerConfig: {
asar: true,
// Platform-specific icons: Electron Forge uses icon for executable, installer, etc.
icon: (() => {
switch (process.platform) {
case 'win32':
return path.resolve(__dirname, 'assets/windows/emu_installer');
case 'darwin':
return path.resolve(__dirname, 'assets/osx/app-icon');
case 'linux':
return path.resolve(__dirname, 'assets/linux/icon/emu_icon_128');
default:
return path.resolve(__dirname, 'assets/osx/app-icon');
}
})(),
// Specify architecture: defaults to current platform arch, override with EMUCFG_ARCH env var
// Valid values: x64, ia32 (for Windows), x64, arm64 (for macOS), x64, arm64 (for Linux)
arch: process.env.EMUCFG_ARCH || undefined,
// Ensure the binary is named as expected for Linux makers
executableName: 'emuflight-configurator',
// macOS signing: ad-hoc by default (works without certs)
// To use certificate: set APPLE_SIGNING_IDENTITY environment variable
...(process.platform === 'darwin' ? {
osxSign: {
...(process.env.APPLE_SIGNING_IDENTITY ? { identity: process.env.APPLE_SIGNING_IDENTITY } : {}),
hardenedRuntime: true,
entitlements: path.resolve(__dirname, 'sign/entitlements.plist'),
entitlementsInherit: path.resolve(__dirname, 'sign/entitlements.plist'),
},
} : {}),
},
hooks: {
packageAfterCopy: async (_forgeConfig, buildPath) => {
const packageJsonPath = path.join(buildPath, 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
packageJson.buildMode = buildMode;
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
// Defense in depth for the usb/glibc issue documented in rebuildConfig below:
// ignoreModules prevents @electron/rebuild from creating a broken build/Release,
// but it can't undo one that already exists in a contributor's node_modules
// (e.g. left over from before this exclusion was added, or from an interrupted
// install). node-gyp-build always prefers a local build/Release over the correct
// prebuilt, so a stale one silently ships a binary that crashes with
// "undefined symbol: __pthread_cond_timedwait64" during real USB/DFU use.
// Strip it from the copied output so packaging is self-healing regardless of
// the source tree's node_modules state.
if (process.platform === 'linux') {
const usbBuildDir = path.join(buildPath, 'node_modules', 'usb', 'build');
if (fs.existsSync(usbBuildDir)) {
fs.rmSync(usbBuildDir, { recursive: true, force: true });
}
}
},
},
rebuildConfig: {
// On Linux, @electron/rebuild looks for `node.napi.node` prebuilts but usb@2.x
// ships `node.napi.glibc.node` (prebuildify libc-variant naming). The mismatch
// causes a source rebuild that references __pthread_cond_timedwait64, an internal
// glibc symbol not exported on Debian glibc 2.34+. Skip the rebuild so node-gyp-build
// falls through to the clean prebuilt at runtime. usb is NAPI so no ABI concern.
//
// exe-icon-extractor is an optionalDependency of electron-wix-msi (maker-wix).
// Rebuilding it fails on Linux/macOS (node-gyp) and on Windows with the
// windows-2025 runner (MSVC C2664: string literals passed as char* rejected).
// It provides icon extraction only; maker-wix degrades gracefully without it.
// Versions 1.0.9 and 1.0.10 both fail; no upstream fix yet.
// Track: https://github.com/bitdisaster/exe-icon-extractor
ignoreModules: [
'@bitdisaster/exe-icon-extractor',
...(process.platform === 'linux' ? ['usb'] : []),
],
},
makers: [
{
name: '@electron-forge/maker-wix',
platforms: ['win32'],
config: {
exe: 'emuflight-configurator',
icon: './assets/windows/emu_installer.ico',
certificateFile: process.env.WINDOWS_CERT_FILE,
certificatePassword: process.env.WINDOWS_CERT_PASSWORD,
},
},
{
name: '@electron-forge/maker-zip',
platforms: ['darwin', 'linux', 'win32'],
// Portable ZIP for all platforms: extract and run, no installer needed.
},
{
name: '@electron-forge/maker-deb',
platforms: ['linux'],
config: {
options: {
maintainer: 'EmuFlight',
homepage: 'https://github.com/EmuFlight/EmuConfigurator',
icon: LINUX_ICON,
// Debian lifecycle scripts: install/remove the icon from the hicolor XDG
// icon theme so desktop environments resolve Icon=emuflight-configurator
// by name (XFCE panel, GNOME, KDE). /usr/share/pixmaps is legacy only.
scripts: {
postinst: path.resolve(__dirname, 'scripts/deb-postinst.sh'),
prerm: path.resolve(__dirname, 'scripts/deb-prerm.sh'),
},
},
},
},
{
name: '@electron-forge/maker-rpm',
platforms: ['linux'],
config: {
options: {
homepage: 'https://github.com/EmuFlight/EmuConfigurator',
icon: LINUX_ICON,
},
},
},
// DMG maker: Skip in CI (macos-alias native module doesn't build reliably in CI)
// Users can build DMG locally with: yarn make (macOS only)
// ZIP is sufficient for distribution on macOS
...(!process.env.CI && process.platform === 'darwin' ? [{
name: '@electron-forge/maker-dmg',
platforms: ['darwin'],
config: {
format: 'UDZO',
background: path.resolve(__dirname, 'assets/osx/dmg-background.png'),
},
}] : []),
],
plugins: [
{
name: '@electron-forge/plugin-auto-unpack-natives',
config: {},
},
// Fuses are used to enable/disable various Electron functionality
// at package time, before code signing the application
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
[FuseV1Options.EnableNodeCliInspectArguments]: false,
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
],
};