mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +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
83 lines
2.1 KiB
TypeScript
83 lines
2.1 KiB
TypeScript
// Copyright 2024, Command Line Inc.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import { app, ipcMain } from "electron";
|
|
import os from "os";
|
|
import path from "path";
|
|
import { WaveDevVarName, WaveDevViteVarName } from "../frontend/util/isdev";
|
|
import * as keyutil from "../frontend/util/keyutil";
|
|
|
|
const WaveHomeVarName = "WAVETERM_HOME";
|
|
|
|
const isDev = !app.isPackaged;
|
|
const isDevVite = isDev && process.env.ELECTRON_RENDERER_URL;
|
|
if (isDev) {
|
|
process.env[WaveDevVarName] = "1";
|
|
}
|
|
if (isDevVite) {
|
|
process.env[WaveDevViteVarName] = "1";
|
|
}
|
|
|
|
app.setName(isDev ? "Wave (Dev)" : "Wave");
|
|
const unamePlatform = process.platform;
|
|
const unameArch: string = process.arch;
|
|
keyutil.setKeyUtilPlatform(unamePlatform);
|
|
|
|
ipcMain.on("get-is-dev", (event) => {
|
|
event.returnValue = isDev;
|
|
});
|
|
ipcMain.on("get-platform", (event, url) => {
|
|
event.returnValue = unamePlatform;
|
|
});
|
|
ipcMain.on("get-user-name", (event) => {
|
|
const userInfo = os.userInfo();
|
|
event.returnValue = userInfo.username;
|
|
});
|
|
ipcMain.on("get-host-name", (event) => {
|
|
event.returnValue = os.hostname();
|
|
});
|
|
|
|
// must match golang
|
|
function getWaveHomeDir() {
|
|
const override = process.env[WaveHomeVarName];
|
|
if (override) {
|
|
return override;
|
|
}
|
|
return path.join(os.homedir(), isDev ? ".waveterm-dev" : ".waveterm");
|
|
}
|
|
|
|
function getElectronAppBasePath(): string {
|
|
return path.dirname(import.meta.dirname);
|
|
}
|
|
|
|
function getElectronAppUnpackedBasePath(): string {
|
|
return getElectronAppBasePath().replace("app.asar", "app.asar.unpacked");
|
|
}
|
|
|
|
const wavesrvBinName = `wavesrv.${unameArch}`;
|
|
|
|
function getWaveSrvPath(): string {
|
|
if (process.platform === "win32") {
|
|
const winBinName = `${wavesrvBinName}.exe`;
|
|
const appPath = path.join(getElectronAppUnpackedBasePath(), "bin", winBinName);
|
|
return `${appPath}`;
|
|
}
|
|
return path.join(getElectronAppUnpackedBasePath(), "bin", wavesrvBinName);
|
|
}
|
|
|
|
function getWaveSrvCwd(): string {
|
|
return getWaveHomeDir();
|
|
}
|
|
|
|
export {
|
|
getElectronAppBasePath,
|
|
getElectronAppUnpackedBasePath,
|
|
getWaveHomeDir,
|
|
getWaveSrvCwd,
|
|
getWaveSrvPath,
|
|
isDev,
|
|
isDevVite,
|
|
unameArch,
|
|
unamePlatform,
|
|
};
|