-
Notifications
You must be signed in to change notification settings - Fork 14
/
forge.config.js
176 lines (154 loc) · 5.28 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
/**
* 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 { 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
macAppId: 'com.nextcloud.NextcloudTalk',
// Windows
winAppId: 'NextcloudTalk',
}
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.macAppId,
darwinDarkModeSupport: true,
appCategoryType: 'public.app-category.social-networking', // LSApplicationCategoryType | https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html
},
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'),
}),
// 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',
},
},
],
},
},
},
],
}