-
Notifications
You must be signed in to change notification settings - Fork 2
/
forge.config.ts
161 lines (155 loc) · 4.88 KB
/
forge.config.ts
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
import { utils } from '@electron-forge/core';
import { MakerDMG } from '@electron-forge/maker-dmg';
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 { PublisherGithub } from '@electron-forge/publisher-github';
import type { ForgeConfig } from '@electron-forge/shared-types';
import { FuseV1Options, FuseVersion } from '@electron/fuses';
import dotenv from 'dotenv';
import path from 'path';
import packageJson from './package.json';
if (process.env.NODE_ENV !== 'production') {
// skip loading any local env files in production
dotenv.config();
}
const fromBuildIdentifier = utils.fromBuildIdentifier;
const { version } = packageJson;
const assets = path.resolve(__dirname, 'src', 'assets');
const config: ForgeConfig = {
buildIdentifier: process.env.VITE_IS_BETA === 'true' ? 'beta' : 'prod',
packagerConfig: {
// @ts-expect-error expect string
name: fromBuildIdentifier({
beta: 'UGRC API Client Beta',
prod: 'UGRC API Client',
}),
executableName: 'ugrc-api-client',
asar: true,
icon: path.resolve(assets, 'logo.icns'),
// @ts-expect-error expect string
appBundleId: fromBuildIdentifier({
beta: 'com.beta.electron.ugrc-api-client',
prod: 'com.electron.ugrc-api-client',
}),
appCategoryType: 'public.app-category.developer-tools',
win32metadata: {
CompanyName: 'UGRC',
OriginalFilename: 'UGRC API Client',
},
osxSign:
process.env.NODE_ENV !== 'production'
? {}
: {
identity: process.env.APPLE_IDENTITY,
// hardenedRuntime: true,
// 'gatekeeper-assess': false,
// entitlements: 'build/entitlements.plist',
// 'entitlements-inherit': 'build/entitlements.plist',
},
osxNotarize: {
appleId: process.env.APPLE_USER_ID,
appleIdPassword: process.env.APPLE_PASSWORD,
teamId: process.env.APPLE_TEAM_ID,
},
},
rebuildConfig: {},
makers: [
new MakerSquirrel({
name: 'ugrc-api-client',
authors: 'UGRC Developers',
exe: 'ugrc-api-client.exe',
iconUrl:
'https://raw.githubusercontent.com/agrc/api-client/dac3554721f3ef6341910e5eee5c5395820ec8f1/src/assets/logo.ico',
loadingGif: './src/assets/loading.gif',
noMsi: true,
setupExe: `ugrc-api-client-${version}-win32-setup.exe`,
setupIcon: path.resolve(assets, 'logo.ico'),
certificateFile: './build/cert/windows.p12',
certificatePassword: process.env.WINDOWS_CERTIFICATE_PASSWORD,
}),
new MakerZIP({}, ['darwin']),
// @ts-expect-error expect missing appPath
new MakerDMG({
title: '${productName} ${version}',
additionalDMGOptions: {
window: {
size: {
width: 400,
height: 274,
},
},
},
background: './src/assets/dmg-background.png',
icon: './src/assets/logo.icns',
// appPath: '',
contents: (options) => {
return [
{
x: 75,
y: 140,
type: 'file',
path: options.appPath,
},
{
x: 300,
y: 140,
type: 'link',
path: '/Applications',
},
];
},
}),
],
publishers: [
new PublisherGithub({
repository: {
owner: 'agrc',
name: 'api-client',
},
draft: true,
prerelease: !!fromBuildIdentifier({
beta: true,
prod: false,
}),
}),
],
plugins: [
new VitePlugin({
// `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc.
// If you are familiar with Vite configuration, it will look really familiar.
build: [
{
// `entry` is just an alias for `build.lib.entry` in the corresponding file of `config`.
entry: 'src/main.ts',
config: 'vite.main.config.ts',
target: 'main',
},
{
entry: 'src/preload.ts',
config: 'vite.preload.config.ts',
target: 'preload',
},
],
renderer: [
{
name: 'main_window',
config: 'vite.renderer.config.ts',
},
],
}),
// Fuses are used to enable/disable various Electron functionality
// at package time, before code signing the application
new FusesPlugin({
version: FuseVersion.V1,
[FuseV1Options.RunAsNode]: false,
[FuseV1Options.EnableCookieEncryption]: true,
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
[FuseV1Options.EnableNodeCliInspectArguments]: false,
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
[FuseV1Options.OnlyLoadAppFromAsar]: true,
}),
],
};
export default config;