-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathelectron-builder.js
118 lines (114 loc) · 3.27 KB
/
electron-builder.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
const { notarize } = require('@electron/notarize');
const binary = require('binary-info');
const { Arch } = require('electron-builder');
const { fdir } = require('fdir');
const { execSync } = require('node:child_process');
const { unlinkSync } = require('node:fs');
const Path = require('path');
module.exports = {
appId: 'dev.ulixee.desktop',
productName: 'Ulixee',
directories: {
buildResources: 'build-resources',
},
files: [
'package.json',
'!packages/**',
'!dist',
'main/**',
'ui/**',
'resources/*',
'!.vscode',
'!**/node_modules/*/{CHANGELOG.md,README.md,README,readme.md,readme}',
'!**/node_modules/*/{test,__tests__,tests,powered-test,example,examples}',
'!**/node_modules/*.d.ts',
'!**/node_modules/.bin',
],
// asar: false,
asarUnpack: ['resources/**', 'ui/**', '**/*.node', '**/connect'],
npmRebuild: true,
nativeRebuilder: 'parallel',
mac: {
defaultArch: 'arm64',
category: 'public.app-category.developer-tools',
target: {
target: 'default',
arch: ['x64', 'arm64'],
},
hardenedRuntime: true,
gatekeeperAssess: false,
entitlements: 'build-resources/entitlements.mac.plist',
entitlementsInherit: 'build-resources/entitlements.mac.plist',
notarize: false, // do this manually
},
win: {
target: 'NSIS',
},
linux: {
category: 'Development',
target: 'AppImage',
},
publish: {
provider: 'github',
releaseType: 'release',
},
fileAssociations: [
{
ext: 'argon',
name: 'ARGON',
description: 'Argon Cash',
icon: 'arg',
rank: 'Owner',
},
],
async beforePack(context) {
const path = require.resolve('@ulixee/unblocked-agent-mitm-socket/install.js');
console.log('Running install script', path);
execSync(`node install.js`, {
cwd: Path.dirname(path),
stdio: 'inherit',
env: {
...process.env,
npm_config_target_arch: Arch[context.arch],
npm_config_target_platform: context.electronPlatformName,
npm_config_cpu: Arch[context.arch],
npm_config_os: context.electronPlatformName,
},
});
},
async afterPack(context) {
console.log('Removing incompatible binaries', context.appOutDir);
const dirs = new fdir()
.withFullPaths()
.filter(path => binary.isIncompatible(path, context.electronPlatformName, Arch[context.arch]))
.crawl(context.appOutDir)
.sync();
for (const file of dirs) {
try {
unlinkSync(file);
console.log('Deleted incompatible binary', file.split(Path.sep).slice(-2).join(Path.sep));
} catch (e) {
console.error('Unable to delete file', file, e);
}
}
},
async afterSign(context) {
const { electronPlatformName, appOutDir } = context;
if (
electronPlatformName !== 'darwin' ||
process.env.SKIP_NOTARIZE ||
process.env.CSC_IDENTITY_AUTO_DISCOVERY === 'false'
) {
return;
}
const appName = context.packager.appInfo.productFilename;
return await notarize({
tool: 'notarytool',
appPath: `${appOutDir}/${appName}.app`,
appleApiKey: '~/.private_keys/AuthKey_27VRA75WCS.p8',
appleApiKeyId: '27VRA75WCS',
appleApiIssuer: 'a89474ed-637f-4cf0-8429-da45ef388882',
// teamId: 'DY8K483XWV',
});
},
};