-
Notifications
You must be signed in to change notification settings - Fork 14
/
forge.config.js
265 lines (238 loc) · 8.14 KB
/
forge.config.js
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
/**
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
const path = require('node:path')
const fs = require('node:fs')
const semver = require('semver')
const { MakerSquirrel } = require('@electron-forge/maker-squirrel')
const { MakerDMG } = require('@electron-forge/maker-dmg')
const { MakerFlatpak } = require('@electron-forge/maker-flatpak')
const { MakerZIP } = require('@electron-forge/maker-zip')
const packageJSON = require('./package.json')
const { MIN_REQUIRED_BUILT_IN_TALK_VERSION } = require('./src/constants.js')
require('dotenv').config()
const CONFIG = {
// General
applicationName: packageJSON.productName,
applicationNameSanitized: packageJSON.productName.replaceAll(' ', '-'),
companyName: 'Nextcloud GmbH',
description: packageJSON.description,
// macOS
appleAppBundleId: 'com.nextcloud.talk.mac',
// Windows
winAppId: 'NextcloudTalk',
// Linux
linuxAppId: 'com.nextcloud.talk',
}
const YEAR = new Date().getFullYear()
const TALK_PATH = path.resolve(__dirname, process.env.TALK_PATH ?? 'spreed')
let talkPackageJson
module.exports = {
hooks: {
generateAssets() {
if (!fs.existsSync(process.env.TALK_PATH)) {
throw new Error(`Path does not exist TALK_PATH=${TALK_PATH}`)
}
try {
talkPackageJson = require(path.join(TALK_PATH, 'package.json'))
} catch {
throw new Error(`No Nextcloud Talk (spreed repository) has been found in TALK_PATH=${TALK_PATH}`)
}
if (talkPackageJson.name !== 'talk') {
throw new Error(`No Nextcloud Talk (spreed repository) but "${talkPackageJson.name}" has been found in TALK_PATH=${TALK_PATH}`)
}
if (semver.lte(talkPackageJson.version, MIN_REQUIRED_BUILT_IN_TALK_VERSION)) {
throw new Error(`The minimum supported version of built-in Nextcloud Talk is ${MIN_REQUIRED_BUILT_IN_TALK_VERSION}, but ${talkPackageJson.version} has been found in TALK_PATH=${TALK_PATH}`)
}
if (!fs.existsSync(path.join(TALK_PATH, 'node_modules'))) {
throw new Error(`No Nextcloud Talk (spreed repository) dependencies are installed.\nTry to execute \`cd ${TALK_PATH} && npm ci\``)
}
},
postStart() {
console.log(`Started with built-in Nextcloud Talk v${talkPackageJson.version} on path: ${TALK_PATH}`)
},
postPackage() {
console.log(`Packaged with built-in Nextcloud Talk v${talkPackageJson.version} on path: ${TALK_PATH}`)
},
},
// https://electron.github.io/packager/main/interfaces/Options.html
packagerConfig: {
// Common
name: CONFIG.applicationName,
icon: path.join(__dirname, './img/icons/icon'),
appCopyright: `Copyright © ${YEAR} ${CONFIG.companyName}`,
asar: true,
// Windows
win32metadata: {
CompanyName: CONFIG.companyName,
},
// macOS
appBundleId: CONFIG.appleAppBundleId,
darwinDarkModeSupport: true,
// https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8
appCategoryType: 'public.app-category.business',
},
makers: [
// https://github.com/squirrel/squirrel.windows
// https://js.electronforge.io/interfaces/_electron_forge_maker_squirrel.InternalOptions.SquirrelWindowsOptions.html#setupExe
new MakerSquirrel({
// App/Filenames
name: CONFIG.winAppId,
setupExe: `${CONFIG.applicationNameSanitized}-v${packageJSON.version}-win-x64.exe`,
exe: `${CONFIG.applicationName}.exe`,
// Meta
title: CONFIG.applicationName,
authors: CONFIG.companyName,
owners: CONFIG.companyName,
description: CONFIG.description,
// Icons
setupIcon: path.join(__dirname, './img/icons/icon.ico'),
iconUrl: 'https://raw.githubusercontent.com/nextcloud/talk-desktop/refs/heads/main/img/icons/icon.ico',
// Install/Update Loading
loadingGif: path.join(__dirname, './img/squirrel-install-loading.gif'),
}),
// https://js.electronforge.io/interfaces/_electron_forge_maker_dmg.MakerDMGConfig.html
new MakerDMG({
icon: path.join(__dirname, 'img/icons/icon.icns'),
background: path.join(__dirname, 'img/dmg-background.png'),
// https://github.com/LinusU/node-appdmg?tab=readme-ov-file#specification
additionalDMGOptions: {
// Background does not work when the title has spaces or special characters
title: 'NextcloudTalk',
},
}),
// Linux
new MakerFlatpak({
// https://js.electronforge.io/classes/_electron_forge_maker_flatpak.MakerFlatpak-1.html#config
options: {
id: CONFIG.linuxAppId,
// The default binary name in flatpak builder is packageJSON.name while the actual binary name from packager is applicationName
// Requires to be set explicitly
bin: CONFIG.applicationName,
productName: CONFIG.applicationName,
description: CONFIG.description,
genericName: 'Video and Chat Communication',
branch: 'stable',
// https://specifications.freedesktop.org/icon-theme-spec/latest/
icon: {
scalable: path.resolve(__dirname, 'img/talk-icon-rounded.svg'),
},
// https://specifications.freedesktop.org/menu-spec/latest/category-registry.html
categories: [
// Main Category
'Network',
// Additional Categories
'InstantMessaging',
'Chat',
'VideoConference',
],
// Available versions: https://freedesktop-sdk.gitlab.io/documentation/updating-sdk/release-notes/
runtimeVersion: '24.08',
// Available versions: https://github.com/flathub/org.electronjs.Electron2.BaseApp/
baseVersion: '24.08',
// Based on https://github.com/malept/electron-installer-flatpak/blob/main/src/installer.js
// Available versions: https://github.com/refi64/zypak/releases
modules: [{
name: 'zypak',
sources: [{
type: 'git',
url: 'https://github.com/refi64/zypak',
tag: 'v2024.01.17',
}],
}],
finishArgs: [
/**
* Default Electron args
* https://github.com/malept/electron-installer-flatpak/blob/main/src/installer.js
*/
// X Rendering
'--socket=x11',
'--share=ipc',
// OpenGL
'--device=dri',
// Audio output
'--socket=pulseaudio',
// Read/write home directory access
'--filesystem=home',
// Chromium uses a socket in tmp for its singleton check
'--env=TMPDIR=/var/tmp',
// Allow communication with network
'--share=network',
// System notifications with libnotify
'--talk-name=org.freedesktop.Notifications',
/**
* Additional args
*/
// Enable webcam access
'--device=all',
// Enable screensharing access in Wayland
'--socket=wayland',
],
},
}),
// Portable, all platforms
new MakerZIP(),
],
plugins: [
{
name: '@electron-forge/plugin-webpack',
config: {
mainConfig: './webpack.main.config.js',
devContentSecurityPolicy: `default-src 'self' 'unsafe-inline' data: blob: ${process.env.NEXTCLOUD_DEV_SERVER_HOSTS}; script-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob:`,
port: 3000, // The default for this plugin
loggerPort: 9005, // The default is 9000, but it conflicts with Talk API
devServer: {
client: {
overlay: false,
},
},
renderer: {
config: './webpack.renderer.config.js',
entryPoints: [
{
name: 'welcome_window',
html: './src/welcome/welcome.html',
js: './src/welcome/welcome.js',
preload: {
js: './src/preload.js',
},
},
{
name: 'authentication_window',
html: './src/authentication/renderer/authentication.html',
js: './src/authentication/renderer/authentication.main.js',
preload: {
js: './src/preload.js',
},
},
{
name: 'talk_window',
html: './src/talk/renderer/talk.html',
js: './src/talk/renderer/talk.main.js',
preload: {
js: './src/preload.js',
},
},
{
name: 'help_window',
html: './src/help/renderer/help.html',
js: './src/help/renderer/help.app.js',
preload: {
js: './src/preload.js',
},
},
{
name: 'upgrade_window',
html: './src/upgrade/renderer/upgrade.html',
js: './src/upgrade/renderer/upgrade.app.js',
preload: {
js: './src/preload.js',
},
},
],
},
},
},
],
}