-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
forge.config.js
150 lines (141 loc) · 4.96 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
const os = require('os');
const path = require('path');
const platform = os.platform();
const architecture = os.arch();
const applicationNames = {
'darwin': 'MicroPython-Package-Installer',
'win32': 'MicroPython-Package-Installer',
'linux': 'micropython-package-installer'
};
const applicationName = applicationNames[platform];
let filesToExclude = [];
switch (platform) {
case 'win32':
filesToExclude = ["(\/bin\/linux$)",
"(\/bin\/darwin$)",
"(\/@serialport\/bindings-cpp\/prebuilds\/android.*)",
"(\/@serialport\/bindings-cpp\/prebuilds\/darwin.*)",
"(\/@serialport\/bindings-cpp\/prebuilds\/linux.*)"
];
break;
case 'darwin':
filesToExclude = ["\/bin\/linux$",
"\/bin\/win32$",
"\/@serialport\/bindings-cpp\/prebuilds\/android.*",
"\/@serialport\/bindings-cpp\/prebuilds\/linux.*",
"\/@serialport\/bindings-cpp\/prebuilds\/win32.*",
];
break;
default:
filesToExclude = ["(\/bin\/darwin$)",
"(\/bin\/win32$)",
"(\/@serialport\/bindings-cpp\/prebuilds\/darwin.*)",
"(\/@serialport\/bindings-cpp\/prebuilds\/android.*)",
"(\/@serialport\/bindings-cpp\/prebuilds\/win32.*)",
];
break;
}
const distributableRenamingRules = {
"darwin": { from: 'darwin', to: 'macOS' },
"win32": { from: 'Setup', to: 'Windows-Setup' },
"linux": { from: 'amd64', to: 'Linux' }
};
// Check options at https://electron.github.io/electron-packager/main/interfaces/electronpackager.options.html
module.exports = {
hooks: {
postMake: async (forgeConfig, results) => {
const fs = require('fs');
for(let result of results) {
result.artifacts.forEach((artifact, index) => {
const fileName = path.basename(artifact);
const renameRule = distributableRenamingRules[result.platform];
if(!fileName.includes(renameRule.from)) {
return;
}
const targetName = fileName.replace(renameRule.from, renameRule.to);
console.log(`Renaming ${fileName} to ${targetName}`);
const targetPath = path.join(path.dirname(artifact), targetName);
try {
fs.renameSync(artifact, targetPath);
result.artifacts[index] = targetPath;
} catch (err) {
console.error(err);
}
});
}
return results;
}
},
packagerConfig: {
icon: './assets/app-icon',
name: applicationName, // Name cannot contain spaces because gyp doesn't support them
arch: 'all',
ignore: filesToExclude,
prune: true,
derefSymlinks: true,
protocols: [ {
name: 'micropython-package-installer',
schemes: ['micropython-package-installer']
}],
// osxUniversal: {
// outAppPath: './out/' + applicationName + '-darwin-universal.app',
// },
osxSign: {
app: './out/' + applicationName + '-darwin-' + architecture + '/' + applicationName + '.app',
optionsForFile: (filePath) => {
return {
entitlements: './config/entitlements.plist'
}
},
keychain: process.env.KEYCHAIN_PATH
},
osxNotarize: process.env.APPLE_API_KEY_PATH ? {
tool: 'notarytool',
appPath: './out/' + applicationName + '-darwin-' + architecture + '/' + applicationName + '.app',
appleApiKey: process.env.APPLE_API_KEY_PATH,
appleApiKeyId: process.env.APPLE_API_KEY_ID,
appleApiIssuer: process.env.APPLE_API_ISSUER,
} : undefined,
},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-squirrel',
platforms: ['win32'],
config: {
loadingGif: './assets/installer.gif',
// See: https://js.electronforge.io/interfaces/_electron_forge_maker_squirrel.InternalOptions.WindowsSignOptions.html
// See: https://www.npmjs.com/package/@electron/windows-sign
signWithParams : process.env.WINDOWS_CERTIFICATE_FILE ? [
'/d', '\"MicroPython Package Installer\"',
'/f', `\"${process.env.WINDOWS_CERTIFICATE_FILE}\"`,
'/csp', '\"eToken Base Cryptographic Provider\"',
'/kc', `\"[{{${process.env.WINDOWS_CERTIFICATE_PASSWORD}}}]=${process.env.WINDOWS_CERTIFICATE_CONTAINER}\"`,
'/fd', '\"sha256\"',
'/tr', '\"http://timestamp.digicert.com\"',
'/td', '\"SHA256\"',
// '/v' // Verbose output
].join(' ') : undefined
},
},
{
name: '@electron-forge/maker-zip',
platforms: ['darwin'],
},
{
name: '@electron-forge/maker-deb',
platforms: ['linux'],
},
],
publishers: [
{
"name": "@electron-forge/publisher-github",
"config": {
"repository": {
"owner": "arduino",
"name": "lab-micropython-package-installer"
}
}
}
]
};