Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.

Commit 96143c4

Browse files
committed
feat: use electron forge as build tool
1 parent eda2ff6 commit 96143c4

File tree

4 files changed

+2269
-593
lines changed

4 files changed

+2269
-593
lines changed

forge.config.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module.exports = {
2+
packagerConfig: {
3+
icon: "./assets/icon",
4+
},
5+
rebuildConfig: {},
6+
makers: [
7+
{
8+
name: "@electron-forge/maker-squirrel",
9+
config: {},
10+
},
11+
{
12+
name: "@electron-forge/maker-dmg",
13+
},
14+
{
15+
name: "@electron-forge/maker-deb",
16+
config: {
17+
options: {
18+
icon: "./assets/icon.png",
19+
},
20+
},
21+
},
22+
{
23+
name: "@electron-forge/maker-rpm",
24+
config: {
25+
options: {
26+
icon: "./assets/icon.png",
27+
},
28+
},
29+
},
30+
],
31+
};

main.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// libappindicator-gtk3 on Arch as req
2+
23
const {
34
app,
45
BrowserWindow,
@@ -12,7 +13,10 @@ const fs = require("fs");
1213
const os = require("os");
1314
const RPC = require("discord-rpc");
1415
const EventEmitter = require("events");
16+
17+
if (require("electron-squirrel-startup")) app.quit();
1518
require("@electron/remote/main").initialize();
19+
1620
const iconpath = path.join(__dirname, "/assets/icon.png");
1721
const loadingEvents = new EventEmitter();
1822
const slash = os.platform() == "win32" ? "\\" : "/";
@@ -57,7 +61,7 @@ if (id !== undefined) {
5761
// Same applies with assets.large_text
5862
activity.smallImageText = "https://drpcm.t1c.dev/";
5963
}
60-
64+
6165
if (assets !== {}) activity.assets = assets;
6266

6367
if (options.description !== "") activity.details = options.description;
@@ -238,10 +242,9 @@ if (id !== undefined) {
238242
}
239243

240244
app.on("window-all-closed", () => {
241-
if (process.platform !== "darwin") {
242-
app.quit();
243-
}
245+
if (process.platform !== "darwin") app.quit();
244246
});
247+
245248
app.on("before-quit", () => {
246249
win.removeAllListeners("close");
247250
win.close();
@@ -266,6 +269,11 @@ if (id !== undefined) {
266269
app.whenReady().then(() => {
267270
console.log("App ready");
268271
createWindow();
272+
273+
app.on("activate", () => {
274+
if (BrowserWindow.getAllWindows().length === 0) createWindow();
275+
});
276+
269277
win = BrowserWindow.getAllWindows()[0];
270278
if (os.platform() == "darwin") {
271279
appIcon = new Tray(path.join(__dirname, "/assets/iconTemplate.png"));
@@ -294,10 +302,4 @@ if (id !== undefined) {
294302
appIcon.setToolTip("Discord RPC Maker");
295303
});
296304
}
297-
298-
app.on("activate", () => {
299-
if (BrowserWindow.getAllWindows().length === 0) {
300-
createWindow();
301-
}
302-
});
303305
}

package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
"rpcmaker": "./main.js"
88
},
99
"scripts": {
10-
"run": "node ./main.js && exit 1",
11-
"start": "electron main.js"
10+
"start": "electron-forge start",
11+
"package": "electron-forge package",
12+
"make": "electron-forge make"
1213
},
1314
"keywords": [
1415
"discord",
@@ -41,19 +42,19 @@
4142
"@electron/remote": "^2.0.8",
4243
"copy-to-clipboard": "^3.3.3",
4344
"discord-rpc": "^4.0.1",
45+
"electron-squirrel-startup": "^1.0.0",
4446
"latest-version": "5.1.0",
4547
"open-file-explorer": "^1.0.2"
4648
},
4749
"devDependencies": {
50+
"@electron-forge/cli": "^6.0.3",
51+
"@electron-forge/maker-deb": "^6.0.3",
52+
"@electron-forge/maker-dmg": "^6.0.3",
53+
"@electron-forge/maker-rpm": "^6.0.3",
54+
"@electron-forge/maker-squirrel": "^6.0.3",
4855
"@types/discord-rpc": "^4.0.3",
4956
"@types/node": "^18.11.9",
50-
"electron": "^21.2.3",
51-
"electron-builder": "^23.6.0"
52-
},
53-
"pkg": {
54-
"assets": [
55-
"./node_modules/"
56-
]
57+
"electron": "^21.2.3"
5758
},
5859
"packageManager": "[email protected]"
5960
}

0 commit comments

Comments
 (0)