2023-10-18 09:13:47 +03:00
|
|
|
import cp from 'node:child_process';
|
|
|
|
import { rm, symlink } from 'node:fs/promises';
|
|
|
|
import path from 'node:path';
|
|
|
|
import { fileURLToPath } from 'node:url';
|
2023-06-14 13:40:13 +03:00
|
|
|
|
2023-10-18 09:13:47 +03:00
|
|
|
import { utils } from '@electron-forge/core';
|
2023-09-29 06:02:26 +03:00
|
|
|
|
2023-10-18 09:13:47 +03:00
|
|
|
import {
|
2024-04-25 06:30:04 +03:00
|
|
|
appIdMap,
|
2023-08-22 18:16:26 +03:00
|
|
|
arch,
|
|
|
|
buildType,
|
|
|
|
icnsPath,
|
2024-10-10 12:51:32 +03:00
|
|
|
iconPngPath,
|
2023-10-18 09:13:47 +03:00
|
|
|
iconUrl,
|
2024-03-21 17:29:02 +03:00
|
|
|
iconX64PngPath,
|
2023-10-18 09:13:47 +03:00
|
|
|
icoPath,
|
2023-08-22 18:16:26 +03:00
|
|
|
platform,
|
|
|
|
productName,
|
2023-10-18 09:13:47 +03:00
|
|
|
} from './scripts/make-env.js';
|
2023-07-12 17:35:45 +03:00
|
|
|
|
2023-10-18 09:13:47 +03:00
|
|
|
const fromBuildIdentifier = utils.fromBuildIdentifier;
|
|
|
|
|
2024-10-10 12:51:32 +03:00
|
|
|
const linuxMimeTypes = [`x-scheme-handler/${productName.toLowerCase()}`];
|
|
|
|
|
2023-10-18 09:13:47 +03:00
|
|
|
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
2023-08-02 18:56:00 +03:00
|
|
|
const makers = [
|
2023-08-04 04:11:09 +03:00
|
|
|
!process.env.SKIP_BUNDLE &&
|
|
|
|
platform === 'darwin' && {
|
|
|
|
name: '@electron-forge/maker-dmg',
|
|
|
|
config: {
|
|
|
|
format: 'ULFO',
|
|
|
|
icon: icnsPath,
|
|
|
|
name: 'AFFiNE',
|
|
|
|
'icon-size': 128,
|
2023-09-29 06:02:26 +03:00
|
|
|
background: path.join(
|
2023-08-04 04:11:09 +03:00
|
|
|
__dirname,
|
|
|
|
'./resources/icons/dmg-background.png'
|
|
|
|
),
|
|
|
|
contents: [
|
|
|
|
{
|
|
|
|
x: 176,
|
|
|
|
y: 192,
|
|
|
|
type: 'file',
|
2023-09-29 06:02:26 +03:00
|
|
|
path: path.join(
|
2023-08-04 04:11:09 +03:00
|
|
|
__dirname,
|
|
|
|
'out',
|
|
|
|
buildType,
|
|
|
|
`${productName}-darwin-${arch}`,
|
|
|
|
`${productName}.app`
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{ x: 432, y: 192, type: 'link', path: '/Applications' },
|
|
|
|
],
|
2023-08-30 07:30:45 +03:00
|
|
|
iconSize: 118,
|
2023-09-29 06:02:26 +03:00
|
|
|
file: path.join(
|
2023-08-04 04:11:09 +03:00
|
|
|
__dirname,
|
|
|
|
'out',
|
|
|
|
buildType,
|
|
|
|
`${productName}-darwin-${arch}`,
|
|
|
|
`${productName}.app`
|
|
|
|
),
|
|
|
|
},
|
2023-08-02 18:56:00 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: '@electron-forge/maker-zip',
|
|
|
|
config: {
|
|
|
|
name: 'affine',
|
|
|
|
iconUrl: icoPath,
|
|
|
|
setupIcon: icoPath,
|
|
|
|
platforms: ['darwin', 'linux', 'win32'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
!process.env.SKIP_BUNDLE && {
|
|
|
|
name: '@electron-forge/maker-squirrel',
|
|
|
|
config: {
|
2023-08-14 18:40:00 +03:00
|
|
|
name: productName,
|
2023-08-02 18:56:00 +03:00
|
|
|
setupIcon: icoPath,
|
2023-08-22 18:16:26 +03:00
|
|
|
iconUrl: iconUrl,
|
2023-08-02 18:56:00 +03:00
|
|
|
loadingGif: './resources/icons/affine_installing.gif',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
!process.env.SKIP_BUNDLE && {
|
2024-02-19 17:24:59 +03:00
|
|
|
name: '@pengx17/electron-forge-maker-appimage',
|
|
|
|
platforms: ['linux'],
|
2024-03-21 17:29:02 +03:00
|
|
|
config: {
|
|
|
|
icons: [
|
|
|
|
{
|
|
|
|
file: iconX64PngPath,
|
|
|
|
size: 64,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-08-02 18:56:00 +03:00
|
|
|
},
|
2024-10-10 12:51:32 +03:00
|
|
|
!process.env.SKIP_BUNDLE && {
|
|
|
|
name: '@electron-forge/maker-deb',
|
|
|
|
config: {
|
|
|
|
bin: productName,
|
|
|
|
options: {
|
|
|
|
name: productName,
|
|
|
|
productName,
|
|
|
|
icon: iconX64PngPath,
|
2024-10-10 12:51:32 +03:00
|
|
|
mimeType: linuxMimeTypes,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
!process.env.SKIP_BUNDLE && {
|
|
|
|
name: '@electron-forge/maker-flatpak',
|
|
|
|
platforms: ['linux'],
|
|
|
|
/** @type {import('@electron-forge/maker-flatpak').MakerFlatpakConfig} */
|
|
|
|
config: {
|
|
|
|
options: {
|
|
|
|
mimeType: linuxMimeTypes,
|
|
|
|
productName,
|
|
|
|
bin: productName,
|
|
|
|
id: fromBuildIdentifier(appIdMap),
|
|
|
|
icon: iconPngPath, // not working yet
|
|
|
|
branch: buildType,
|
|
|
|
runtimeVersion: '20.08',
|
|
|
|
finishArgs: [
|
|
|
|
// Wayland/X11 Rendering
|
|
|
|
'--socket=wayland',
|
|
|
|
'--socket=x11',
|
|
|
|
'--share=ipc',
|
|
|
|
// Open GL
|
|
|
|
'--device=dri',
|
|
|
|
// Audio output
|
|
|
|
'--socket=pulseaudio',
|
|
|
|
// Read/write home directory access
|
|
|
|
'--filesystem=home',
|
|
|
|
// Allow communication with network
|
|
|
|
'--share=network',
|
|
|
|
// System notifications with libnotify
|
|
|
|
'--talk-name=org.freedesktop.Notifications',
|
|
|
|
],
|
2024-10-10 12:51:32 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-08-02 18:56:00 +03:00
|
|
|
].filter(Boolean);
|
|
|
|
|
2023-04-17 19:32:10 +03:00
|
|
|
/**
|
|
|
|
* @type {import('@electron-forge/shared-types').ForgeConfig}
|
|
|
|
*/
|
2023-10-18 09:13:47 +03:00
|
|
|
export default {
|
2023-04-21 19:52:55 +03:00
|
|
|
buildIdentifier: buildType,
|
2023-03-16 17:58:21 +03:00
|
|
|
packagerConfig: {
|
2023-04-17 19:32:10 +03:00
|
|
|
name: productName,
|
2024-04-25 06:30:04 +03:00
|
|
|
appBundleId: fromBuildIdentifier(appIdMap),
|
2023-04-17 19:32:10 +03:00
|
|
|
icon: icnsPath,
|
2023-04-21 13:25:46 +03:00
|
|
|
osxSign: {
|
|
|
|
identity: 'Developer ID Application: TOEVERYTHING PTE. LTD.',
|
|
|
|
'hardened-runtime': true,
|
|
|
|
},
|
2024-12-02 16:55:45 +03:00
|
|
|
electronZipDir: process.env.ELECTRON_FORGE_ELECTRON_ZIP_DIR,
|
2023-04-09 04:44:47 +03:00
|
|
|
osxNotarize: process.env.APPLE_ID
|
|
|
|
? {
|
|
|
|
tool: 'notarytool',
|
|
|
|
appleId: process.env.APPLE_ID,
|
|
|
|
appleIdPassword: process.env.APPLE_PASSWORD,
|
|
|
|
teamId: process.env.APPLE_TEAM_ID,
|
|
|
|
}
|
|
|
|
: undefined,
|
2023-06-15 15:48:10 +03:00
|
|
|
// We need the following line for updater
|
|
|
|
extraResource: ['./resources/app-update.yml'],
|
2023-08-29 13:07:05 +03:00
|
|
|
protocols: [
|
|
|
|
{
|
|
|
|
name: productName,
|
|
|
|
schemes: [productName.toLowerCase()],
|
|
|
|
},
|
|
|
|
],
|
2024-10-10 12:51:32 +03:00
|
|
|
executableName: productName,
|
2023-11-21 20:44:29 +03:00
|
|
|
asar: true,
|
2023-03-16 17:58:21 +03:00
|
|
|
},
|
2023-08-02 18:56:00 +03:00
|
|
|
makers,
|
2023-11-21 20:44:29 +03:00
|
|
|
plugins: [{ name: '@electron-forge/plugin-auto-unpack-natives', config: {} }],
|
2023-04-04 15:40:07 +03:00
|
|
|
hooks: {
|
2023-04-17 19:32:10 +03:00
|
|
|
readPackageJson: async (_, packageJson) => {
|
|
|
|
// we want different package name for canary build
|
|
|
|
// so stable and canary will not share the same app data
|
|
|
|
packageJson.productName = productName;
|
|
|
|
},
|
2023-06-14 13:40:13 +03:00
|
|
|
prePackage: async () => {
|
2023-10-17 09:15:55 +03:00
|
|
|
if (!process.env.HOIST_NODE_MODULES) {
|
|
|
|
await rm(path.join(__dirname, 'node_modules'), {
|
|
|
|
recursive: true,
|
|
|
|
force: true,
|
|
|
|
});
|
2023-06-14 13:40:13 +03:00
|
|
|
|
2023-10-17 09:15:55 +03:00
|
|
|
await symlink(
|
2023-10-18 18:30:08 +03:00
|
|
|
path.join(__dirname, '..', '..', '..', 'node_modules'),
|
2023-10-17 09:15:55 +03:00
|
|
|
path.join(__dirname, 'node_modules')
|
|
|
|
);
|
|
|
|
}
|
2023-06-14 13:40:13 +03:00
|
|
|
},
|
2023-04-04 15:40:07 +03:00
|
|
|
generateAssets: async (_, platform, arch) => {
|
2023-04-18 12:50:29 +03:00
|
|
|
if (process.env.SKIP_GENERATE_ASSETS) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-06-21 10:54:14 +03:00
|
|
|
// TODO(@Peng): right now we do not need the following
|
2023-04-18 12:50:29 +03:00
|
|
|
// it is for octobase-node, but we dont use it for now.
|
2023-04-04 15:40:07 +03:00
|
|
|
if (platform === 'darwin' && arch === 'arm64') {
|
|
|
|
// In GitHub Actions runner, MacOS is always x64
|
|
|
|
// we need to manually set TARGET to aarch64-apple-darwin
|
|
|
|
process.env.TARGET = 'aarch64-apple-darwin';
|
|
|
|
}
|
|
|
|
|
2023-10-18 09:13:47 +03:00
|
|
|
cp.spawnSync('yarn', ['generate-assets'], {
|
|
|
|
stdio: 'inherit',
|
|
|
|
env: {
|
|
|
|
...process.env,
|
|
|
|
NODE_OPTIONS: (process.env.NODE_OPTIONS ?? '').replace(
|
|
|
|
'--loader ts-node/esm',
|
|
|
|
''
|
|
|
|
),
|
|
|
|
},
|
|
|
|
cwd: __dirname,
|
|
|
|
});
|
2023-04-04 15:40:07 +03:00
|
|
|
},
|
|
|
|
},
|
2023-03-16 17:58:21 +03:00
|
|
|
};
|