-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathforge.config.cjs
153 lines (143 loc) · 4.95 KB
/
forge.config.cjs
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
const path = require("path");
const fs = require("fs-extra");
const APP_NAME = "TriliumNext Notes";
const extraResourcesForPlatform = getExtraResourcesForPlatform();
const baseLinuxMakerConfigOptions = {
icon: "./images/app-icons/png/128x128.png",
desktopTemplate: path.resolve("./bin/electron-forge/desktop.ejs"),
categories: ["Office", "Utility"]
};
module.exports = {
packagerConfig: {
executableName: "trilium",
name: APP_NAME,
overwrite: true,
asar: true,
icon: "./images/app-icons/icon",
osxSign: {},
osxNotarize: {
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_ID_PASSWORD,
teamId: process.env.APPLE_TEAM_ID
},
extraResource: [
// All resources should stay in Resources directory for macOS
...(process.platform === "darwin" ? [] : extraResourcesForPlatform),
// These always go in Resources
"translations/",
"node_modules/@highlightjs/cdn-assets/styles"
],
afterComplete: [
(buildPath, _electronVersion, platform, _arch, callback) => {
// Only move resources on non-macOS platforms
if (platform !== "darwin") {
for (const resource of extraResourcesForPlatform) {
const baseName = path.basename(resource);
const sourcePath = path.join(buildPath, "resources", baseName);
// prettier-ignore
const destPath = (baseName !== "256x256.png")
? path.join(buildPath, baseName)
: path.join(buildPath, "icon.png");
fs.move(sourcePath, destPath)
.then(() => callback())
.catch((err) => callback(err));
}
} else {
callback();
}
}
]
},
rebuildConfig: {
force: true
},
makers: [
{
name: "@electron-forge/maker-deb",
config: {
options: {
...baseLinuxMakerConfigOptions
}
}
},
{
name: "@electron-forge/maker-flatpak",
config: {
options: {
...baseLinuxMakerConfigOptions,
id: "com.triliumnext.notes",
runtimeVersion: "24.08",
base: "org.electronjs.Electron2.BaseApp",
baseVersion: "24.08",
baseFlatpakref: "https://flathub.org/repo/flathub.flatpakrepo",
modules: [
{
name: "zypak",
sources: {
type: "git",
url: "https://github.com/refi64/zypak",
tag: "v2024.01.17"
}
}
]
},
}
},
{
name: "@electron-forge/maker-rpm",
config: {
options: {
...baseLinuxMakerConfigOptions
}
}
},
{
name: "@electron-forge/maker-squirrel",
config: {
iconUrl: "https://raw.githubusercontent.com/TriliumNext/Notes/develop/images/app-icons/icon.ico",
setupIcon: "./images/app-icons/win/setup.ico",
loadingGif: "./images/app-icons/win/setup-banner.gif"
}
},
{
name: "@electron-forge/maker-dmg",
config: {
icon: "./images/app-icons/icon.icns"
}
},
{
name: "@electron-forge/maker-zip",
config: {
options: {
iconUrl: "https://raw.githubusercontent.com/TriliumNext/Notes/develop/images/app-icons/icon.ico",
icon: "./images/app-icons/icon.ico"
}
}
}
],
plugins: [
{
name: "@electron-forge/plugin-auto-unpack-natives",
config: {}
}
]
};
function getExtraResourcesForPlatform() {
const resources = ["dump-db/", "./bin/tpl/anonymize-database.sql"];
const getScriptRessources = () => {
const scripts = ["trilium-portable", "trilium-safe-mode", "trilium-no-cert-check"];
const scriptExt = (process.platform === "win32") ? "bat" : "sh";
return scripts.map(script => `./bin/tpl/${script}.${scriptExt}`);
}
switch (process.platform) {
case "win32":
resources.push(...getScriptRessources())
break;
case "linux":
resources.push(...getScriptRessources(), "images/app-icons/png/256x256.png");
break;
default:
break;
}
return resources;
}