Skip to content

Commit d0845a5

Browse files
author
Curtis Gray
committed
Refactored forge config file as ES Module
1 parent c308449 commit d0845a5

File tree

1 file changed

+84
-82
lines changed

1 file changed

+84
-82
lines changed

ux/forge.config.js

+84-82
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,95 @@
1-
const path = require("path");
2-
const fs = require("fs").promises;
3-
// const winston = require("winston");
1+
import path from 'path';
2+
import fs from 'fs/promises';
43

54
// Documentation for the forge config can be found at:
65
// https://electron.github.io/packager/main/interfaces/Options.html
7-
module.exports = {
8-
packagerConfig: {
9-
asar: true,
10-
extraResource: [
11-
"server/wingman",
12-
".dist",
13-
// "assets/iq"
14-
],
6+
const packagerConfig = {
7+
asar: true,
8+
extraResource: [
9+
"server/wingman",
10+
".dist",
11+
],
12+
icon: "assets/logo-color",
13+
osxSign: {},
14+
osxNotarize: {
15+
tool: 'notarytool',
16+
appleId: process.env.APPLE_ID,
17+
appleIdPassword: process.env.APPLE_PASSWORD,
18+
teamId: process.env.APPLE_TEAM_ID
19+
}
20+
};
21+
22+
const rebuildConfig = {};
23+
24+
const makers = [
25+
{
26+
name: "@electron-forge/maker-squirrel",
1527
icon: "assets/logo-color",
16-
osxSign: {},
17-
osxNotarize: {
18-
tool: 'notarytool',
19-
appleId: process.env.APPLE_ID,
20-
appleIdPassword: process.env.APPLE_PASSWORD,
21-
teamId: process.env.APPLE_TEAM_ID
22-
}
23-
},
24-
rebuildConfig: {},
25-
makers: [
26-
{
27-
name: "@electron-forge/maker-squirrel",
28-
icon: "assets/logo-color",
29-
config: {
30-
name: "Wingman",
31-
setupIcon: "assets/logo-color.ico",
32-
signWithParams: `/a /tr http://timestamp.comodoca.com /td sha256 /fd sha256 /f \"${process.env.WINGMAN_CODESIGN_CERT_PATH}\" /n \"${process.env.WINGMAN_CODESIGN_CERT_NAME}\" /csp \"${process.env.WINGMAN_CODESIGN_CERT_CSP}\" /kc \"[{{${process.env.WINGMAN_CODESIGN_CERT_PASSWORD}}}]=${process.env.WINGMAN_CODESIGN_CERT_CONTAINER}\"`,
33-
},
34-
},
35-
{
36-
name: "@electron-forge/maker-zip",
37-
icon: "assets/logo-color.ico",
38-
platforms: ["darwin", "win32", "linux"],
28+
config: {
29+
name: "Wingman",
30+
setupIcon: "assets/logo-color.ico",
31+
signWithParams: `/a /tr http://timestamp.comodoca.com /td sha256 /fd sha256 /f \"${process.env.WINGMAN_CODESIGN_CERT_PATH}\" /n \"${process.env.WINGMAN_CODESIGN_CERT_NAME}\" /csp \"${process.env.WINGMAN_CODESIGN_CERT_CSP}\" /kc \"[{{${process.env.WINGMAN_CODESIGN_CERT_PASSWORD}}}]=${process.env.WINGMAN_CODESIGN_CERT_CONTAINER}\"`,
3932
},
40-
{
41-
name: "@electron-forge/maker-deb",
42-
icon: "assets/logo-color.png",
43-
config: {},
44-
},
45-
{
46-
name: "@electron-forge/maker-rpm",
47-
icon: "assets/logo-color",
48-
config: {},
49-
},
50-
{
51-
name: "@electron-forge/maker-dmg",
52-
config: {
53-
format: "ULFO",
54-
icon: "assets/logo-color.icns",
55-
},
33+
},
34+
{
35+
name: "@electron-forge/maker-zip",
36+
icon: "assets/logo-color.ico",
37+
platforms: ["darwin", "win32", "linux"],
38+
},
39+
{
40+
name: "@electron-forge/maker-deb",
41+
icon: "assets/logo-color.png",
42+
config: {},
43+
},
44+
{
45+
name: "@electron-forge/maker-rpm",
46+
icon: "assets/logo-color",
47+
config: {},
48+
},
49+
{
50+
name: "@electron-forge/maker-dmg",
51+
config: {
52+
format: "ULFO",
53+
icon: "assets/logo-color.icns",
5654
},
57-
],
58-
publishers: [
59-
{
60-
name: '@electron-forge/publisher-github',
61-
config: {
62-
repository: {
63-
owner: "curtisgray",
64-
name: "wingman",
65-
},
55+
},
56+
];
57+
58+
const publishers = [
59+
{
60+
name: '@electron-forge/publisher-github',
61+
config: {
62+
repository: {
63+
owner: "curtisgray",
64+
name: "wingman",
6665
},
6766
},
68-
],
69-
plugins: [
67+
},
68+
];
69+
70+
const plugins = [
71+
{
72+
name: "@electron-forge/plugin-auto-unpack-natives",
73+
config: {},
74+
},
75+
];
76+
77+
const hooks = {
78+
generateAssets: async (config, buildPath) =>
79+
{
80+
// run the next build command
81+
import('child_process').then(cp =>
7082
{
71-
name: "@electron-forge/plugin-auto-unpack-natives",
72-
config: {},
73-
},
74-
],
75-
hooks: {
76-
generateAssets: async (config, buildPath) => {
77-
// run the next build command
78-
const { execSync } = require("child_process");
79-
execSync("npm run build", { cwd: __dirname });
80-
// copy the static folder into standalone/.next. standalone/public is already copied by electron-forge
81-
// though NextJs docs say to copy the public folder, it seems to work without it
82-
// var src = path.join(__dirname, ".next", "static");
83-
// var dst = path.join(__dirname, ".next", "standalone", ".next", "static");
84-
// await fs.cp(src, dst, { recursive: true });
85-
},
86-
packageAfterCopy: async (config, buildPath, electronVersion, platform, arch) => {
87-
// files under server/wingman are already copied to
88-
// resources folder so we can delete them from the root
89-
await fs.rm(path.join(buildPath, "server", "wingman"), { recursive: true });
90-
await fs.rm(path.join(buildPath, ".dist"), { recursive: true });
91-
},
83+
cp.execSync("npm run build", { cwd: path.dirname(import.meta.url) });
84+
});
85+
},
86+
packageAfterCopy: async (config, buildPath, electronVersion, platform, arch) =>
87+
{
88+
// files under server/wingman are already copied to
89+
// resources folder so we can delete them from the root
90+
await fs.rm(path.join(buildPath, "server", "wingman"), { recursive: true });
91+
await fs.rm(path.join(buildPath, ".dist"), { recursive: true });
9292
},
9393
};
94+
95+
export { packagerConfig, rebuildConfig, makers, publishers, plugins, hooks };

0 commit comments

Comments
 (0)