forked from FrogAddict/emusak-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforge.config.js
116 lines (109 loc) · 3.31 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
const fs = require("fs-extra");
const path = require("path");
const Zip = require("adm-zip");
module.exports = {
"forge": "./forge.config.js",
"packagerConfig": {
"icon": "./icons/win/icon.ico",
"executableName": "EmuSAK"
},
"publishers": [
{
"name": "@electron-forge/publisher-github",
"config": {
"repository": {
"owner": "CapitaineJSparrow",
"name": "emusak-ui"
}
}
}
],
"makers": [
{
"name": "@electron-forge/maker-squirrel",
"config": {
"name": "emusak_ui"
}
},
{
"name": "@electron-forge/maker-zip",
"platforms": [
"win32"
]
},
{
"name": "@electron-forge/maker-deb",
"config": {}
},
{
"name": "@electron-forge/maker-rpm",
"config": {}
},
{
"name": "electron-forge-maker-appimage",
"platforms": [
"linux"
],
"config": {}
}
],
"plugins": [
[
"@electron-forge/plugin-webpack",
{
"mainConfig": "./webpack.main.config.js",
"renderer": {
"config": "./webpack.renderer.config.js",
"entryPoints": [
{
"html": "./src/index.html",
"js": "./src/renderer.ts",
"name": "main_window"
}
]
}
}
]
],
"hooks": {
"postMake": async (_, makeResults) => {
const version = makeResults[0].packageJSON.version;
const portablePath = makeResults.map(b => b.artifacts).flat().find(i => i.includes(".zip") && i.includes("win32"));
const exePath = makeResults.map(b => b.artifacts).flat().find(i => i.includes("Setup.exe"));
try {
if (portablePath) {
const filename = path.basename(portablePath);
await fs.move(portablePath, portablePath.replace(filename, `EmuSAK-win32-x64-${version}-portable.zip`));
}
} catch(e) {
// fs.move is launched twice, first for dry run and second time by make from dry-run causing an exception, so ignore and assume it exists
}
try {
if (exePath) {
const filename = path.basename(exePath);
await fs.move(exePath, exePath.replace(filename, `EmuSAK-win32-x64-${version}-installer-recommended.exe`));
}
} catch(e) {}
return makeResults.map(r => ({
...r,
...{
artifacts:
r.artifacts.map(fullPath => {
const filename = path.basename(fullPath);
if (fullPath.includes(".zip") && fullPath.includes("win32")) {
const archive = new Zip(fullPath.replace(filename, `EmuSAK-win32-x64-${version}-portable.zip`));
archive.addFile("portable", Buffer.from("portable", "utf8"), "EmuSAK is portable");
fs.removeSync(fullPath.replace(filename, `EmuSAK-win32-x64-${version}-portable.zip`));
archive.writeZip(fullPath.replace(filename, `EmuSAK-win32-x64-${version}-portable.zip`));
return fullPath.replace(filename, `EmuSAK-win32-x64-${version}-portable.zip`);
}
if (fullPath.includes(".exe")) {
return fullPath.replace(filename, `EmuSAK-win32-x64-${version}-installer-recommended.exe`);
}
return fullPath;
})
}
}));
}
}
};