forked from wavetermdev/waveterm
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathelectron-builder.config.cjs
More file actions
173 lines (162 loc) · 6.39 KB
/
electron-builder.config.cjs
File metadata and controls
173 lines (162 loc) · 6.39 KB
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
const { Arch } = require("electron-builder");
const pkg = require("./package.json");
const fs = require("fs");
const path = require("path");
const windowsShouldSign = !!process.env.SM_CODE_SIGNING_CERT_SHA1_HASH;
/**
* Verify that required build artifacts exist before packaging
* @throws {Error} if required files are missing
*/
function verifyRequiredArtifacts() {
const version = pkg.version;
const requiredFiles = [
"dist/main/index.js",
"dist/bin/wavesrv.x64.exe", // Windows wavesrv
`dist/bin/wsh-${version}-windows.x64.exe`, // Windows wsh (versioned)
];
const missingFiles = [];
for (const file of requiredFiles) {
if (!fs.existsSync(path.resolve(__dirname, file))) {
missingFiles.push(file);
}
}
if (missingFiles.length > 0) {
const errorMsg = `
❌ BUILD FAILED: Required artifacts are missing!
Missing files:
${missingFiles.map((f) => ` - ${f}`).join("\n")}
Before packaging, you must:
1. Build the frontend: npm run build:prod
2. Build the Go binaries: task build (or go build the wavesrv/wsh binaries)
The package cannot be created without these critical files.
`;
throw new Error(errorMsg);
}
}
// Run verification before configuration is used
verifyRequiredArtifacts();
/**
* @type {import('electron-builder').Configuration}
* @see https://www.electron.build/configuration/configuration
*/
const config = {
appId: pkg.build.appId,
productName: pkg.productName,
executableName: pkg.productName,
artifactName: "${productName}-${platform}-${arch}-${version}.${ext}",
generateUpdatesFilesForAllChannels: true,
npmRebuild: false,
nodeGypRebuild: false,
electronCompile: false,
files: [
"dist/**/*",
"package.json",
// Exclude unnecessary locale files to reduce build size (~35-40MB savings)
"!**/locales/**/*",
"**/locales/en-US.pak", // Only include English locale
// Exclude cross-platform wsh binaries to reduce build size (~84MB savings)
"!dist/bin/wsh-*-darwin.*",
"!dist/bin/wsh-*-linux.*",
],
directories: {
output: "make",
},
asarUnpack: [
"dist/bin/**/*", // wavesrv and wsh binaries (Windows only after filtering)
"dist/docsite/**/*", // the static docsite
],
mac: {
target: [
{
target: "zip",
arch: ["arm64", "x64"],
},
{
target: "dmg",
arch: ["arm64", "x64"],
},
],
category: "public.app-category.developer-tools",
minimumSystemVersion: "10.15.0",
mergeASARs: true,
singleArchFiles: "**/dist/bin/wavesrv.*",
entitlements: "build/entitlements.mac.plist",
entitlementsInherit: "build/entitlements.mac.plist",
extendInfo: {
NSContactsUsageDescription: "A CLI application running in Wave wants to use your contacts.",
NSRemindersUsageDescription: "A CLI application running in Wave wants to use your reminders.",
NSLocationWhenInUseUsageDescription:
"A CLI application running in Wave wants to use your location information while active.",
NSLocationAlwaysUsageDescription:
"A CLI application running in Wave wants to use your location information, even in the background.",
NSCameraUsageDescription: "A CLI application running in Wave wants to use the camera.",
NSMicrophoneUsageDescription: "A CLI application running in Wave wants to use your microphone.",
NSCalendarsUsageDescription: "A CLI application running in Wave wants to use Calendar data.",
NSLocationUsageDescription: "A CLI application running in Wave wants to use your location information.",
NSAppleEventsUsageDescription: "A CLI application running in Wave wants to use AppleScript.",
},
},
linux: {
artifactName: "${name}-${platform}-${arch}-${version}.${ext}",
category: "TerminalEmulator",
executableName: pkg.name,
target: ["zip", "deb", "rpm", "snap", "AppImage", "pacman"],
synopsis: pkg.description,
description: null,
desktop: {
entry: {
Name: pkg.productName,
Comment: pkg.description,
Keywords: "developer;terminal;emulator;",
Categories: "Development;Utility;",
},
},
executableArgs: ["--enable-features", "UseOzonePlatform", "--ozone-platform-hint", "auto"], // Hint Electron to use Ozone abstraction layer for native Wayland support
},
deb: {
afterInstall: "build/deb-postinstall.tpl",
},
win: {
target: ["nsis", "msi", "zip"],
signtoolOptions: windowsShouldSign && {
signingHashAlgorithms: ["sha256"],
publisherName: "Command Line Inc",
certificateSubjectName: "Command Line Inc",
certificateSha1: process.env.SM_CODE_SIGNING_CERT_SHA1_HASH,
},
},
appImage: {
license: "LICENSE",
},
snap: {
base: "core22",
confinement: "classic",
allowNativeWayland: true,
artifactName: "${name}_${version}_${arch}.${ext}",
},
rpm: {
// this should remove /usr/lib/.build-id/ links which can conflict with other electron apps like slack
fpm: ["--rpm-rpmbuild-define", "_build_id_links none"],
},
publish: {
provider: "generic",
url: "https://dl.waveterm.dev/releases-w2",
},
afterPack: (context) => {
// This is a workaround to restore file permissions to the wavesrv binaries on macOS after packaging the universal binary.
if (context.electronPlatformName === "darwin" && context.arch === Arch.universal) {
const packageBinDir = path.resolve(
context.appOutDir,
`${pkg.productName}.app/Contents/Resources/app.asar.unpacked/dist/bin`
);
// Reapply file permissions to the wavesrv binaries in the final app package
fs.readdirSync(packageBinDir, {
recursive: true,
withFileTypes: true,
})
.filter((f) => f.isFile() && f.name.startsWith("wavesrv"))
.forEach((f) => fs.chmodSync(path.resolve(f.parentPath ?? f.path, f.name), 0o755)); // 0o755 corresponds to -rwxr-xr-x
}
},
};
module.exports = config;