-
Notifications
You must be signed in to change notification settings - Fork 45
/
forge.config.js
127 lines (121 loc) · 3.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
const util = require('node:util');
const fs = require('node:fs');
const path = require('node:path');
const exec = util.promisify(require('node:child_process').exec);
const { globSync } = require('glob');
const awsaml = require('./package.json');
let includeFiles = [
// we need to make sure the project root directory is included
'',
...globSync('src/**'),
'LICENSE.md',
'package.json',
// per electron-packager's docs, a set of files in the node_modules directory are always ignored
// unless we are providing an IgnoreFunction. Because we want to ignore a lot more files than
// packager does by default, we need to ensure that we're including the relevant node_modules
// while ignoring what packager normally would.
// See https://electron.github.io/electron-packager/main/interfaces/electronpackager.options.html#ignore.
...globSync('node_modules/**', {
ignore: [
'node_modules/.bin/**',
'node_modules/electron/**',
'node_modules/electron-prebuilt/**',
'node_modules/electron-prebuilt-compile/**',
],
}),
];
const outDirName = path.join(__dirname, 'out');
const outDirStat = fs.statSync(outDirName, {
throwIfNoEntry: false,
});
const buildDirName = path.join(__dirname, 'build');
const buildDirStat = fs.statSync(buildDirName, {
throwIfNoEntry: false,
});
const config = {
packagerConfig: {
appBundleId: 'com.rapid7.awsaml',
asar: true,
helperBundleId: 'com.rapid7.awsaml.helper',
prune: true,
ignore: (p) => !includeFiles.includes(p.replace('/', '')),
name: 'Awsaml',
darwinDarkModeSupport: true,
icon: 'images/icon',
},
rebuildConfig: {},
hooks: {
generateAssets: async () => {
// Clear the build directory if it exists
if (buildDirStat && buildDirStat.isDirectory()) {
fs.rmSync(buildDirName, {
force: true,
recursive: true,
});
}
await exec('yarn react-build');
// Update the files we want to include with generated build artifacts
includeFiles = [
...includeFiles,
...globSync('build/**'),
];
},
prePackage: () => {
// Clear the out directory if it exists
if (outDirStat && outDirStat.isDirectory()) {
fs.rmSync(outDirName, {
force: true,
recursive: true,
});
}
},
},
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {
authors: awsaml.contributors.join(', '),
setupIcon: path.join(__dirname, 'images', 'icon.ico'),
},
},
{
name: '@electron-forge/maker-zip',
platforms: ['darwin'],
},
{
name: '@electron-forge/maker-deb',
config: {
options: {
homepage: awsaml.repository.url.replace('.git', ''),
maintainer: awsaml.contributors.join(', '),
icon: 'images/icon.png',
},
},
},
],
publishers: [
{
name: '@electron-forge/publisher-github',
config: {
repository: {
owner: 'rapid7',
name: 'awsaml',
},
draft: true,
prerelease: false,
},
},
],
};
// If we're running in Jenkins (or the env indicates we are) attempt to
// code sign.
if (process.env.BUILD_NUMBER && process.env.BUILD_NUMBER !== '') {
config.packagerConfig.osxSign = {};
config.packagerConfig.osxNotarize = {
tool: 'notarytool',
appleId: process.env.NOTARIZE_CREDS_USR,
appleIdPassword: process.env.NOTARIZE_CREDS_PSW,
teamId: process.env.MAC_TEAM_ID,
};
}
module.exports = config;