Files
max-index/forge.config.ts

117 lines
3.2 KiB
TypeScript

import fs from 'node:fs/promises';
import path from 'node:path';
import type { ForgeConfig } from '@electron-forge/shared-types';
import { MakerDeb } from '@electron-forge/maker-deb';
import { MakerDMG } 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 { VitePlugin } from '@electron-forge/plugin-vite';
import { FusesPlugin } from '@electron-forge/plugin-fuses';
import { FuseV1Options, FuseVersion } from '@electron/fuses';
import plist from 'plist';
const unusedMacPermissionDescriptions = [
'NSAudioCaptureUsageDescription',
'NSBluetoothAlwaysUsageDescription',
'NSBluetoothPeripheralUsageDescription',
'NSCameraUsageDescription',
] as const;
const stripUnusedMacPermissionDescriptions = (
buildPath: string,
_electronVersion: string,
platform: string,
_arch: string,
callback: (error?: Error | null) => void,
): void => {
if (platform !== 'darwin') {
callback();
return;
}
const infoPath = path.join(
buildPath,
'Electron.app',
'Contents',
'Info.plist',
);
void (async () => {
const info = plist.parse(await fs.readFile(infoPath, 'utf8'));
for (const key of unusedMacPermissionDescriptions) {
delete info[key];
}
await fs.writeFile(infoPath, plist.build(info), 'utf8');
})().then(
() => callback(),
(error: unknown) =>
callback(error instanceof Error ? error : new Error(String(error))),
);
};
const config: ForgeConfig = {
packagerConfig: {
appBundleId: 'dev.dokril.max-index',
appCategoryType: 'public.app-category.productivity',
asar: true,
afterExtract: [stripUnusedMacPermissionDescriptions],
extendInfo: {
NSAppTransportSecurity: {
NSAllowsArbitraryLoads: false,
},
},
usageDescription: {
Microphone:
'Max Index использует микрофон для локального распознавания речи.',
},
},
rebuildConfig: {},
makers: [
new MakerSquirrel({}, ['win32']),
new MakerDMG({}, ['darwin']),
new MakerZIP({}, ['darwin']),
new MakerDeb({}, ['linux']),
new MakerRpm({}, ['linux']),
],
plugins: [
new VitePlugin({
build: [
{
entry: 'src/main/main.ts',
config: 'vite.main.config.ts',
target: 'main',
},
{
entry: 'src/preload/preload.ts',
config: 'vite.preload.config.ts',
target: 'preload',
},
],
renderer: [
{
name: 'main_window',
config: 'vite.renderer.config.ts',
},
],
}),
{
name: '@electron-forge/plugin-auto-unpack-natives',
config: {},
},
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;