diff options
Diffstat (limited to '.electron-builder.config.js')
-rw-r--r-- | .electron-builder.config.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/.electron-builder.config.js b/.electron-builder.config.js index e0f59e7..4ff94d7 100644 --- a/.electron-builder.config.js +++ b/.electron-builder.config.js | |||
@@ -1,5 +1,9 @@ | |||
1 | // @ts-check | 1 | // @ts-check |
2 | 2 | ||
3 | const { Arch } = require('electron-builder'); | ||
4 | const { flipFuses, FuseV1Options, FuseVersion } = require('@electron/fuses'); | ||
5 | const { join } = require('path'); | ||
6 | |||
3 | if (process.env.VITE_APP_VERSION === undefined) { | 7 | if (process.env.VITE_APP_VERSION === undefined) { |
4 | const now = new Date; | 8 | const now = new Date; |
5 | process.env.VITE_APP_VERSION = `${now.getUTCFullYear() - 2000}.${now.getUTCMonth() + 1}.${now.getUTCDate()}-${now.getUTCHours() * 60 + now.getUTCMinutes()}`; | 9 | process.env.VITE_APP_VERSION = `${now.getUTCFullYear() - 2000}.${now.getUTCMonth() + 1}.${now.getUTCDate()}-${now.getUTCHours() * 60 + now.getUTCMinutes()}`; |
@@ -20,6 +24,34 @@ const config = { | |||
20 | extraMetadata: { | 24 | extraMetadata: { |
21 | version: process.env.VITE_APP_VERSION, | 25 | version: process.env.VITE_APP_VERSION, |
22 | }, | 26 | }, |
27 | /** | ||
28 | * @param {import('electron-builder').AfterPackContext} context The `electron-builder` context. | ||
29 | * @return {Promise<void>} The promise to flip the fuses. | ||
30 | * @see https://github.com/electron-userland/electron-builder/issues/6365 | ||
31 | */ | ||
32 | afterPack(context) { | ||
33 | /** @type {string} */ | ||
34 | const ext = { | ||
35 | darwin: '.app', | ||
36 | win32: '.exe', | ||
37 | }[context.electronPlatformName] || ''; | ||
38 | const electronBinaryPath = join( | ||
39 | context.appOutDir, | ||
40 | `${context.packager.appInfo.productFilename}${ext}` | ||
41 | ); | ||
42 | /** @type {import('@electron/fuses').FuseConfig<boolean>} */ | ||
43 | const fuseConfig = { | ||
44 | version: FuseVersion.V1, | ||
45 | resetAdHocDarwinSignature: context.electronPlatformName === 'darwin' && context.arch === Arch.arm64, | ||
46 | [FuseV1Options.RunAsNode]: false, | ||
47 | [FuseV1Options.EnableCookieEncryption]: true, | ||
48 | [FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false, | ||
49 | [FuseV1Options.EnableNodeCliInspectArguments]: false, | ||
50 | [FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true, | ||
51 | [FuseV1Options.OnlyLoadAppFromAsar]: true, | ||
52 | }; | ||
53 | return flipFuses(electronBinaryPath, fuseConfig); | ||
54 | }, | ||
23 | }; | 55 | }; |
24 | 56 | ||
25 | module.exports = config; | 57 | module.exports = config; |