-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored forge config file as ES Module
- Loading branch information
Curtis Gray
committed
May 9, 2024
1 parent
c308449
commit d0845a5
Showing
1 changed file
with
84 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,95 @@ | ||
const path = require("path"); | ||
const fs = require("fs").promises; | ||
// const winston = require("winston"); | ||
import path from 'path'; | ||
import fs from 'fs/promises'; | ||
|
||
// Documentation for the forge config can be found at: | ||
// https://electron.github.io/packager/main/interfaces/Options.html | ||
module.exports = { | ||
packagerConfig: { | ||
asar: true, | ||
extraResource: [ | ||
"server/wingman", | ||
".dist", | ||
// "assets/iq" | ||
], | ||
const packagerConfig = { | ||
asar: true, | ||
extraResource: [ | ||
"server/wingman", | ||
".dist", | ||
], | ||
icon: "assets/logo-color", | ||
osxSign: {}, | ||
osxNotarize: { | ||
tool: 'notarytool', | ||
appleId: process.env.APPLE_ID, | ||
appleIdPassword: process.env.APPLE_PASSWORD, | ||
teamId: process.env.APPLE_TEAM_ID | ||
} | ||
}; | ||
|
||
const rebuildConfig = {}; | ||
|
||
const makers = [ | ||
{ | ||
name: "@electron-forge/maker-squirrel", | ||
icon: "assets/logo-color", | ||
osxSign: {}, | ||
osxNotarize: { | ||
tool: 'notarytool', | ||
appleId: process.env.APPLE_ID, | ||
appleIdPassword: process.env.APPLE_PASSWORD, | ||
teamId: process.env.APPLE_TEAM_ID | ||
} | ||
}, | ||
rebuildConfig: {}, | ||
makers: [ | ||
{ | ||
name: "@electron-forge/maker-squirrel", | ||
icon: "assets/logo-color", | ||
config: { | ||
name: "Wingman", | ||
setupIcon: "assets/logo-color.ico", | ||
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}\"`, | ||
}, | ||
}, | ||
{ | ||
name: "@electron-forge/maker-zip", | ||
icon: "assets/logo-color.ico", | ||
platforms: ["darwin", "win32", "linux"], | ||
config: { | ||
name: "Wingman", | ||
setupIcon: "assets/logo-color.ico", | ||
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}\"`, | ||
}, | ||
{ | ||
name: "@electron-forge/maker-deb", | ||
icon: "assets/logo-color.png", | ||
config: {}, | ||
}, | ||
{ | ||
name: "@electron-forge/maker-rpm", | ||
icon: "assets/logo-color", | ||
config: {}, | ||
}, | ||
{ | ||
name: "@electron-forge/maker-dmg", | ||
config: { | ||
format: "ULFO", | ||
icon: "assets/logo-color.icns", | ||
}, | ||
}, | ||
{ | ||
name: "@electron-forge/maker-zip", | ||
icon: "assets/logo-color.ico", | ||
platforms: ["darwin", "win32", "linux"], | ||
}, | ||
{ | ||
name: "@electron-forge/maker-deb", | ||
icon: "assets/logo-color.png", | ||
config: {}, | ||
}, | ||
{ | ||
name: "@electron-forge/maker-rpm", | ||
icon: "assets/logo-color", | ||
config: {}, | ||
}, | ||
{ | ||
name: "@electron-forge/maker-dmg", | ||
config: { | ||
format: "ULFO", | ||
icon: "assets/logo-color.icns", | ||
}, | ||
], | ||
publishers: [ | ||
{ | ||
name: '@electron-forge/publisher-github', | ||
config: { | ||
repository: { | ||
owner: "curtisgray", | ||
name: "wingman", | ||
}, | ||
}, | ||
]; | ||
|
||
const publishers = [ | ||
{ | ||
name: '@electron-forge/publisher-github', | ||
config: { | ||
repository: { | ||
owner: "curtisgray", | ||
name: "wingman", | ||
}, | ||
}, | ||
], | ||
plugins: [ | ||
}, | ||
]; | ||
|
||
const plugins = [ | ||
{ | ||
name: "@electron-forge/plugin-auto-unpack-natives", | ||
config: {}, | ||
}, | ||
]; | ||
|
||
const hooks = { | ||
generateAssets: async (config, buildPath) => | ||
{ | ||
// run the next build command | ||
import('child_process').then(cp => | ||
{ | ||
name: "@electron-forge/plugin-auto-unpack-natives", | ||
config: {}, | ||
}, | ||
], | ||
hooks: { | ||
generateAssets: async (config, buildPath) => { | ||
// run the next build command | ||
const { execSync } = require("child_process"); | ||
execSync("npm run build", { cwd: __dirname }); | ||
// copy the static folder into standalone/.next. standalone/public is already copied by electron-forge | ||
// though NextJs docs say to copy the public folder, it seems to work without it | ||
// var src = path.join(__dirname, ".next", "static"); | ||
// var dst = path.join(__dirname, ".next", "standalone", ".next", "static"); | ||
// await fs.cp(src, dst, { recursive: true }); | ||
}, | ||
packageAfterCopy: async (config, buildPath, electronVersion, platform, arch) => { | ||
// files under server/wingman are already copied to | ||
// resources folder so we can delete them from the root | ||
await fs.rm(path.join(buildPath, "server", "wingman"), { recursive: true }); | ||
await fs.rm(path.join(buildPath, ".dist"), { recursive: true }); | ||
}, | ||
cp.execSync("npm run build", { cwd: path.dirname(import.meta.url) }); | ||
}); | ||
}, | ||
packageAfterCopy: async (config, buildPath, electronVersion, platform, arch) => | ||
{ | ||
// files under server/wingman are already copied to | ||
// resources folder so we can delete them from the root | ||
await fs.rm(path.join(buildPath, "server", "wingman"), { recursive: true }); | ||
await fs.rm(path.join(buildPath, ".dist"), { recursive: true }); | ||
}, | ||
}; | ||
|
||
export { packagerConfig, rebuildConfig, makers, publishers, plugins, hooks }; |