i18n: Upgrade translations from crowdin (12cfeda5). (verify)
[ProtonMail-WebClient.git] / applications / inbox-desktop / forge.config.ts
blobe7e343ec267d4184d9c4b31d341703b1290c0a5f
1 // eslint-disable-next-line @typescript-eslint/no-var-requires
2 import { config as dotenvConf } from "dotenv";
3 dotenvConf({ path: [".env", ".env.default"] });
5 import { AutoUnpackNativesPlugin } from "@electron-forge/plugin-auto-unpack-natives";
6 import { FusesPlugin } from "@electron-forge/plugin-fuses";
7 import { WebpackPlugin } from "@electron-forge/plugin-webpack";
8 import type { ForgeConfig } from "@electron-forge/shared-types";
9 import { getAppTransportSecuity, getExtraResource, getIco, getIcon, getName, isBetaRelease } from "./src/utils/config";
11 import { FuseV1Options, FuseVersion } from "@electron/fuses";
12 import { mainConfig } from "./webpack.main.config";
13 import { rendererConfig } from "./webpack.renderer.config";
14 import pkg from "./package.json";
16 let currentArch = "";
18 const config: ForgeConfig = {
19     hooks: {
20         generateAssets: async (_x, _y, arch) => {
21             if (arch === "all") {
22                 currentArch = "universal";
23                 return;
24             }
25             currentArch = arch;
26         },
27     },
28     packagerConfig: {
29         icon: `${__dirname}/assets/icons/${getIcon()}`,
30         asar: true,
31         name: getName(),
32         executableName: getName(),
33         extraResource: getExtraResource(),
34         appVersion: pkg.version,
35         appCopyright: pkg.config.copyright,
36         // Required for macOS mailto protocol
37         protocols: [
38             {
39                 name: "mailto",
40                 schemes: ["mailto"],
41             },
42         ],
43         // Change category type of the application on macOS
44         appCategoryType: "public.app-category.productivity",
45         appBundleId: pkg.config.appBundleId,
46         osxSign: {},
47         osxNotarize: {
48             appleId: process.env.APPLE_ID!,
49             appleIdPassword: process.env.APPLE_PASSWORD!,
50             teamId: process.env.APPLE_TEAM_ID!,
51         },
52         extendInfo: {
53             ...getAppTransportSecuity(),
54         },
55     },
56     rebuildConfig: {},
57     makers: [
58         {
59             name: "@electron-forge/maker-squirrel",
60             config: {
61                 name: "proton_mail", // Avoids clash with ProtonMail folder used by Bridge in appData
62                 iconUrl: `${__dirname}/assets/icons/${getIco()}`,
63                 setupIcon: `${__dirname}/assets/icons/${getIco()}`,
64                 loadingGif: `${__dirname}/assets/windows/install-spinner.gif`,
65                 vendorDirectory: `${__dirname}/../../packages/shared/lib/squirrel/assets`,
66                 signWithParams:
67                     process.env.WINDOWS_PACKAGE_SIGNING === "yes"
68                         ? `/a /d "Proton Mail Desktop" /t "http://timestamp.sectigo.com" /fd SHA256`
69                         : undefined,
70             },
71         },
72         {
73             name: "@electron-forge/maker-dmg",
74             config: {
75                 background: `${__dirname}/assets/macos/background.png`,
76                 icon: `${__dirname}/assets/macos/volume.icns`,
77                 contents: () => {
78                     return [
79                         {
80                             x: 229,
81                             y: 250,
82                             type: "file",
83                             path: `${process.cwd()}/out/${getName()}-darwin-${currentArch}/${getName()}.app`,
84                         },
85                         { x: 429, y: 250, type: "link", path: "/Applications" },
86                     ];
87                 },
88                 additionalDMGOptions: {
89                     window: {
90                         size: {
91                             width: 658,
92                             height: 490,
93                         },
94                     },
95                 },
96             },
97         },
98         {
99             name: "@electron-forge/maker-rpm",
100             config: {
101                 options: {
102                     name: "proton-mail",
103                     bin: getName(),
104                     icon: `${__dirname}/assets/linux/${getIcon()}.svg`,
105                     homepage: pkg.author.url,
106                     categories: ["Network", "Email"],
107                     mimeType: ["x-scheme-handler/mailto"],
108                 },
109             },
110         },
111         {
112             name: "@electron-forge/maker-deb",
113             config: {
114                 options: {
115                     name: "proton-mail",
116                     bin: getName(),
117                     icon: `${__dirname}/assets/linux/${getIcon()}.svg`,
118                     maintainer: pkg.author.name,
119                     homepage: pkg.author.url,
120                     categories: ["Network", "Email"],
121                     mimeType: ["x-scheme-handler/mailto"],
122                 },
123             },
124         },
125         {
126             name: "@electron-forge/maker-zip",
127             platforms: ["win32", "darwin", "linux"],
128             config: {},
129         },
130     ],
131     publishers: [
132         {
133             name: "@electron-forge/publisher-github",
134             config: {
135                 prerelase: isBetaRelease,
136                 repository: {
137                     owner: pkg.config.githubUser,
138                     name: pkg.config.githubRepo,
139                 },
140             },
141         },
142     ],
143     plugins: [
144         new AutoUnpackNativesPlugin({}),
145         new WebpackPlugin({
146             mainConfig,
147             renderer: {
148                 config: rendererConfig,
149                 entryPoints: [
150                     {
151                         html: "./src/index.html",
152                         js: "./src/renderer.ts",
153                         name: "main_window",
154                         preload: {
155                             js: "./src/preload.ts",
156                         },
157                     },
158                 ],
159             },
160         }),
161         new FusesPlugin({
162             version: FuseVersion.V1,
163             // Disables ELECTRON_RUN_AS_NODE
164             [FuseV1Options.RunAsNode]: false,
165             // Disables the NODE_OPTIONS environment variable
166             [FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
167             // Disables the --inspect and --inspect-brk family of CLI options
168             [FuseV1Options.EnableNodeCliInspectArguments]: false,
169             // Enables validation of the app.asar archive on macOS
170             [FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
171             // Enforces that Electron will only load your app from "app.asar" instead of its normal search paths
172             [FuseV1Options.OnlyLoadAppFromAsar]: true,
173             // Encrypt cookies to avoid session hijacking
174             [FuseV1Options.EnableCookieEncryption]: true,
175         }),
176     ],
179 export default config;