-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforge.config.ts
More file actions
177 lines (169 loc) · 5 KB
/
forge.config.ts
File metadata and controls
177 lines (169 loc) · 5 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import fs from "node:fs";
import path from "node:path";
import { FuseV1Options, FuseVersion } from "@electron/fuses";
import { MakerDeb } from "@electron-forge/maker-deb";
import { MakerDMG, type MakerDMGConfig } from "@electron-forge/maker-dmg";
import { MakerRpm } from "@electron-forge/maker-rpm";
import { MakerSquirrel } from "@electron-forge/maker-squirrel";
import { MakerZIP } from "@electron-forge/maker-zip";
import { FusesPlugin } from "@electron-forge/plugin-fuses";
import { VitePlugin } from "@electron-forge/plugin-vite";
import type { ForgeConfig } from "@electron-forge/shared-types";
import { version } from "./package.json";
import { PROJECT_FILE_EXTENSION } from "./src/constants";
let signingConfig = {};
if (process.env.APPLE_CERTIFICATE) {
signingConfig = {
osxSign: {
"hardened-runtime": true,
"gatekeeper-assess": false,
"signature-flags": "library",
entitlements: "entitlements.mac.plist",
"entitlements-inherit": "entitlements.mac.plist",
},
osxNotarize: {
keychainProfile: process.env.APPLE_KEYCHAIN_PROFILE,
},
};
}
/**
* Windows: Azure Artifact Signing via `signtool /dlib` extension. The signing tools and
* `metadata.json` are installed by the CI workflow before the build. Authentication uses the Azure
* CLI session established via OIDC in the workflow.
*/
let windowsSignConfig: object | undefined;
if (process.env.AZURE_CODE_SIGNING_DLIB) {
windowsSignConfig = {
signToolPath: process.env.AZURE_CODE_SIGNING_SIGNTOOL,
signWithParams: [
"/dlib",
process.env.AZURE_CODE_SIGNING_DLIB,
"/dmdf",
process.env.AZURE_CODE_SIGNING_METADATA,
],
timestampServer: "http://timestamp.acs.microsoft.com",
hashes: ["sha256"],
automaticallySelectCertificate: false,
};
}
const dmgOptions: MakerDMGConfig = {
name: `Photo.ID-${version}`,
format: "ULFO",
icon: "resources/icon.icns",
background: "resources/dmg-background.png",
iconSize: 100,
contents: (options) => [
{
x: 140,
y: 125,
type: "file",
path: options.appPath,
},
{
x: 520,
y: 125,
type: "link",
path: "/Applications",
},
],
};
const config: ForgeConfig = {
packagerConfig: {
appBundleId: "uk.org.crru.photo-id",
asar: {
unpack: "**/@napi-rs/canvas*/**",
},
icon: path.join(__dirname, "resources", "icon"),
executableName: "photo-id",
extraResource: process.env.CI === "true" ? [path.resolve(__dirname, "./.env")] : [],
extendInfo: {
CFBundleDocumentTypes: [
{
CFBundleTypeName: "Photo ID Project",
CFBundleTypeRole: "Editor",
CFBundleTypeExtensions: [PROJECT_FILE_EXTENSION],
},
],
},
...signingConfig,
...(windowsSignConfig ? { windowsSign: windowsSignConfig } : {}),
},
rebuildConfig: {},
makers: [
new MakerSquirrel(windowsSignConfig ? { windowsSign: windowsSignConfig } : {}),
new MakerDMG(dmgOptions),
new MakerZIP({}, ["darwin"]),
new MakerRpm({ options: { mimeType: ["application/x-photoid"] } }),
new MakerDeb({ options: { mimeType: ["application/x-photoid"] } }),
],
plugins: [
new VitePlugin({
build: [
{
entry: "src/main.ts",
config: "vite.main.config.mts",
target: "main",
},
{
entry: "src/preload.ts",
config: "vite.preload.config.mts",
target: "preload",
},
],
renderer: [
{
name: "main_window",
config: "vite.renderer.config.mts",
},
],
}),
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
[FuseV1Options.EnableNodeCliInspectArguments]: false,
// Disabled on Windows because code signing modifies the binary after ASAR integrity checksums
// are embedded, which causes validation errors during Squirrel update events.
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: process.platform !== "win32",
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
{
name: "@timfish/forge-externals-plugin",
config: {
externals: ["@napi-rs/canvas"],
includeDeps: true,
},
},
],
hooks: {
generateAssets: async () => {
// Only write .env file in CI/CD (i.e. published builds)
if (process.env.CI === "true") {
await fs.promises.writeFile(
".env",
[
`NODE_ENV=production`,
`SENTRY_DSN=${process.env.SENTRY_DSN || ""}`,
`VITE_SENTRY_DSN=${process.env.SENTRY_DSN || ""}`,
].join("\n"),
);
}
},
},
publishers: [
{
name: "@electron-forge/publisher-github",
config: {
repository: {
owner: "CRRU-UK",
name: "photo-id-app",
},
draft: true,
force: true,
generateReleaseNotes: true,
},
},
],
};
export default config;