-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathforge.config.js
107 lines (105 loc) · 3.77 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
const os = require('os');
const path = require('path');
const fs = require('fs');
require('dotenv').config({
path: path.join(os.homedir(), ".env")
});
let baseConfig = {
packagerConfig: {
icon: "./src/icons/icon.icns",
appBundleId: "com.bensresearch.assessmentdisaggregation",
appCategoryType: "public.app-category.education",
osxSign: {
identity: process.env.APPLE_CERT,
hardenedRuntime: true,
entitlements: "entitlements.plist",
"entitlements-inherit": "entitlements.plist",
"gatekeeper-assess": false
},
osxNotarize: {
appleId: process.env.APPLEID,
appleIdPassword: process.env.APPLEID_PASSWORD,
teamId: process.env.APPLE_TEAMID
}
},
makers: [{
name: "@electron-forge/maker-squirrel",
config: {
signWithParams: '/a /tr http://timestamp.sectigo.com /td sha256 /fd sha256'
},
platforms: [
"win32"
]
},
{
name: "@electron-forge/maker-zip",
platforms: [
"darwin"
]
},
],
hooks: {
postMake: async (config, makeResults) => {
let fileRenameList = [];
for (const result of makeResults) {
for (const artifact of result.artifacts) {
const dirname = path.dirname(artifact);
const filename = path.basename(artifact);
let newFilename = filename.replace(/\s/, "_");
if(!(newFilename.includes(result.arch))){
const dashIndex = newFilename.indexOf("-");
if (dashIndex !== -1) {
newFilename = newFilename.substring(0, dashIndex) + "-" + result.arch + newFilename.substring(dashIndex);
}
}
if (!(newFilename.includes(result.platform))) {
const archIndex = newFilename.indexOf(result.arch);
if (archIndex !== -1) {
newFilename = newFilename.substring(0, archIndex) + result.platform + "-" + newFilename.substring(archIndex);
}
}
const newArtifact = path.join(dirname, newFilename);
fileRenameList.push({
artifact,
newArtifact,
arch: result.arch,
platform: result.platform
});
if (artifact !== newArtifact){
fs.renameSync(artifact, newArtifact);
}
}
}
let releaseFileList = [];
for (const fileRename of fileRenameList) {
if (path.basename(fileRename.newArtifact) == "RELEASES") {
let releaseFile = fs.readFileSync(fileRename.newArtifact, 'utf8');
const filFileRenameList = fileRenameList.filter(fR => fR.arch == fileRename.arch && fR.platform == fileRename.platform);
for (const fR of filFileRenameList){
if (fR.artifact != fR.newArtifact){
releaseFile = releaseFile.replace(path.basename(fR.artifact), path.basename(fR.newArtifact));
}
}
releaseFileList.push({
artifact: fileRename.newArtifact,
content: releaseFile,
arch: fileRename.arch,
platform: fileRename.platform
});
fs.writeFileSync(fileRename.newArtifact, releaseFile);
}
}
if (releaseFileList.length > 0){
const releaseContent = releaseFileList.map(file => file.content).join("\n");
const releaseFilePath = path.join(path.dirname(releaseFileList[0].artifact), "..", "RELEASES");
fs.writeFileSync(releaseFilePath, releaseContent);
}
const filteredFileRenameList = fileRenameList.filter(fR => path.basename(fR.newArtifact) != "RELEASES");
for (const fR of filteredFileRenameList){
const newLocation = path.join(path.dirname(fR.newArtifact), "..", path.basename(fR.newArtifact));
fs.renameSync(fR.newArtifact, newLocation);
}
}
}
};
module.exports = baseConfig;