mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
74cda378f8
This will take the latest artifact from the waveterm-docs repo and embed it in the app binary. When the help view is launched, it will be served from our backend. If the embedded copy doesn't exist, such as in unpackaged versions of the app or in locally packaged versions, it will use the hosted site instead. There is a sibling PR in the docs repository to build the embedded version of the app (strips out some external links, removes Algolia DocSearch, updates the baseUrl) https://github.com/wavetermdev/waveterm-docs/pull/46
118 lines
4.1 KiB
JavaScript
118 lines
4.1 KiB
JavaScript
const { Arch } = require("electron-builder");
|
|
const pkg = require("./package.json");
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
/**
|
|
* @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: [
|
|
{
|
|
from: "./dist",
|
|
to: "./dist",
|
|
filter: ["**/*", "!bin/*", "bin/wavesrv.${arch}*", "bin/wsh*"],
|
|
},
|
|
{
|
|
from: ".",
|
|
to: ".",
|
|
filter: ["package.json"],
|
|
},
|
|
"!node_modules", // We don't need electron-builder to package in Node modules as Vite has already bundled any code that our program is using.
|
|
],
|
|
directories: {
|
|
output: "make",
|
|
},
|
|
asarUnpack: [
|
|
"dist/bin/**/*", // wavesrv and wsh binaries
|
|
"dist/docsite/**/*", // the static docsite
|
|
],
|
|
mac: {
|
|
target: [
|
|
{
|
|
target: "zip",
|
|
arch: ["universal", "arm64", "x64"],
|
|
},
|
|
{
|
|
target: "dmg",
|
|
arch: ["universal", "arm64", "x64"],
|
|
},
|
|
],
|
|
icon: "build/icons.icns",
|
|
category: "public.app-category.developer-tools",
|
|
minimumSystemVersion: "10.15.0",
|
|
mergeASARs: true,
|
|
singleArchFiles: "dist/bin/wavesrv.*",
|
|
},
|
|
linux: {
|
|
artifactName: "${name}-${platform}-${arch}-${version}.${ext}",
|
|
category: "TerminalEmulator",
|
|
executableName: pkg.name,
|
|
icon: "build/icons.icns",
|
|
target: ["zip", "deb", "rpm", "AppImage", "pacman"],
|
|
synopsis: pkg.description,
|
|
description: null,
|
|
desktop: {
|
|
Name: pkg.productName,
|
|
Comment: pkg.description,
|
|
Keywords: "developer;terminal;emulator;",
|
|
category: "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: {
|
|
icon: "build/icons.icns",
|
|
publisherName: "Command Line Inc",
|
|
target: ["nsis", "msi", "zip"],
|
|
certificateSubjectName: "Command Line Inc",
|
|
certificateSha1: process.env.SM_CODE_SIGNING_CERT_SHA1_HASH,
|
|
signingHashAlgorithms: ["sha256"],
|
|
},
|
|
appImage: {
|
|
license: "LICENSE",
|
|
},
|
|
publish: {
|
|
provider: "generic",
|
|
url: "https://dl.waveterm.dev/releases-w2",
|
|
},
|
|
beforePack: () => {
|
|
const staticSourcePath = process.env.STATIC_DOCSITE_PATH;
|
|
const staticDestPath = "dist/docsite";
|
|
if (staticSourcePath) {
|
|
console.log(`Static docsite path is specified, copying from "${staticSourcePath}" to "${staticDestPath}"`);
|
|
fs.cpSync(staticSourcePath, staticDestPath, { recursive: true });
|
|
}
|
|
},
|
|
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;
|