-
Notifications
You must be signed in to change notification settings - Fork 14
/
forge.config.js
151 lines (139 loc) · 4.49 KB
/
forge.config.js
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
const package = require('./package.json');
const hash = require('child_process')
.execSync('git rev-parse --short HEAD')
.toString().trim()
/**
* This is the base electron-forge config
*/
const config = {
packagerConfig: {
name: process.platform === 'linux' ? 'aeon' : 'Aeon',
icon: './src/icon',
executableName: process.platform === 'linux' ? 'aeon' : 'Aeon',
asar: false,
buildVersion: `${package.version}-${hash}`,
protocols: [
{
name: "Aeon",
schemes: ["aeon"]
}
]
},
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {
iconUrl: 'https://raw.githubusercontent.com/leinelissen/aeon/master/src/icon.ico',
setupIcon: './src/icon.ico'
}
},
{
name: '@electron-forge/maker-dmg',
config: {
// background: './assets/dmg-background.png',
format: 'ULFO'
}
},
{
name: "@electron-forge/maker-zip",
platforms: [ "darwin" ],
},
{
name: '@electron-forge/maker-deb',
config: {}
},
{
name: '@electron-forge/maker-rpm',
config: {}
}
],
plugins: [
{
name: '@electron-forge/plugin-webpack',
config: {
// HMR Woes: https://github.com/electron-userland/electron-forge/issues/2560
devServer: {
liveReload: false,
},
mainConfig: './webpack.main.config.js',
renderer: {
config: './webpack.renderer.config.js',
entryPoints: [
{
html: './src/app/index.ejs',
js: './src/app/index.tsx',
name: 'main_window',
preload: {
js: './src/app/preload.ts',
},
}
]
},
loggerPort: 9001
}
},
],
};
/**
* This function inserts config for notarizing applications.
* Idea stolen from: https://github.com/electron/fiddle/blob/master/forge.config.js
*/
function notarizeMaybe() {
// GUARD: Only notarize macOS-based applications
if (process.platform !== 'darwin') {
return;
}
// Only notarize in CI
if (!process.env.CI) {
console.log(`Not in CI, skipping notarization`);
return;
}
// GUARD: Credentials are required
if (!process.env.APPLE_ID || !process.env.APPLE_ID_PASSWORD) {
console.warn(
'Should be notarizing, but environment variables APPLE_ID or APPLE_ID_PASSWORD are missing!',
);
return;
}
// Inject the notarization config if everything is right
config.packagerConfig.osxNotarize = {
appBundleId: 'nl.leinelissen.aeon',
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_ID_PASSWORD,
ascProvider: '238P3C58WC',
};
// Also inject signing config
config.packagerConfig.osxSign = {
identity: 'Developer ID Application: Bureau Moeilijke Dingen BV (238P3C58WC)',
'hardened-runtime': true,
entitlements: 'entitlements.plist',
'entitlements-inherit': 'entitlements.plist',
'signature-flags': 'library',
};
}
notarizeMaybe();
/**
* For some reason OpenSSL isn't compiled directly into the NodeGit native module. We
* thus have to include manually on Windows only.
*/
function bundleOpenSSLMaybe() {
if (process.platform !== 'win32') {
return;
}
// Add a hook to include the file
config.hooks = {
postPackage: async () => {
const fs = require('fs');
const path = require('path');
await fs.promises.copyFile(
// TODO: It's probably a bad idea to hardcode the DLL location here. Maybe it
// is a good idea to pull it from some side of config or environment variable.
'C:\\WINDOWS\\system32\\libcrypto-1_1-x64.dll',
path.join(__dirname, 'out', 'Aeon-win32-x64', 'resources', 'app', '.webpack', 'main', 'native_modules', 'build', 'Release', 'libcrypto-1_1-x64.dll'),
);
}
};
}
bundleOpenSSLMaybe();
// Finally, export it
module.exports = config;