mirror of
https://github.com/wavetermdev/backup.git
synced 2026-08-05 13:57:07 -07:00
Set up electron-builder for new app (#113)
Adds electron-builder, which we will use to package and distribute our application, same as in the existing app. Replaces explicit port assignments with dynamic ones, which are then stored into environment variables. Adds a ~/.w2-dev folder for use when running a dev build. The build-helper pipeline from the old repo is included here too, but it is not updated yet so it will fail. Also removes some redundant utility functions and cleans up some let vs. const usage. The packaging can be run using the `package:prod` and `package:dev` tasks. --------- Co-authored-by: sawka <mike.sawka@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import { getLayoutStateAtomForTab } from "@/faraday/lib/layoutAtom";
|
||||
import { layoutTreeStateReducer } from "@/faraday/lib/layoutState";
|
||||
|
||||
import { handleIncomingRpcMessage } from "@/app/store/wshrpc";
|
||||
import { getServerWebEndpoint, getServerWSEndpoint } from "@/util/endpoints";
|
||||
import * as layoututil from "@/util/layoututil";
|
||||
import { produce } from "immer";
|
||||
import * as jotai from "jotai";
|
||||
@@ -193,15 +194,6 @@ function useBlockAtom<T>(blockId: string, name: string, makeFn: () => jotai.Atom
|
||||
return atom as jotai.Atom<T>;
|
||||
}
|
||||
|
||||
function getBackendHostPort(): string {
|
||||
// TODO deal with dev/production
|
||||
return "http://127.0.0.1:8190";
|
||||
}
|
||||
|
||||
function getBackendWSHostPort(): string {
|
||||
return "ws://127.0.0.1:8191";
|
||||
}
|
||||
|
||||
let globalWS: WSControl = null;
|
||||
|
||||
function handleWSEventMessage(msg: WSEventType) {
|
||||
@@ -278,7 +270,7 @@ function handleWSMessage(msg: any) {
|
||||
}
|
||||
|
||||
function initWS() {
|
||||
globalWS = new WSControl(getBackendWSHostPort(), globalStore, globalWindowId, "", (msg) => {
|
||||
globalWS = new WSControl(getServerWSEndpoint(), globalStore, globalWindowId, "", (msg) => {
|
||||
handleWSMessage(msg);
|
||||
});
|
||||
globalWS.connectNow("initWS");
|
||||
@@ -332,7 +324,7 @@ async function fetchWaveFile(
|
||||
if (offset != null) {
|
||||
usp.set("offset", offset.toString());
|
||||
}
|
||||
const resp = await fetch(getBackendHostPort() + "/wave/file?" + usp.toString());
|
||||
const resp = await fetch(getServerWebEndpoint() + "/wave/file?" + usp.toString());
|
||||
if (!resp.ok) {
|
||||
if (resp.status === 404) {
|
||||
return { data: null, fileInfo: null };
|
||||
@@ -375,13 +367,10 @@ function getObjectId(obj: any): number {
|
||||
}
|
||||
|
||||
export {
|
||||
PLATFORM,
|
||||
WOS,
|
||||
atoms,
|
||||
createBlock,
|
||||
fetchWaveFile,
|
||||
getApi,
|
||||
getBackendHostPort,
|
||||
getEventORefSubject,
|
||||
getEventSubject,
|
||||
getFileSubject,
|
||||
@@ -389,10 +378,12 @@ export {
|
||||
globalStore,
|
||||
globalWS,
|
||||
initWS,
|
||||
PLATFORM,
|
||||
sendWSCommand,
|
||||
setBlockFocus,
|
||||
setPlatform,
|
||||
useBlockAtom,
|
||||
useBlockCache,
|
||||
useSettingsAtom,
|
||||
WOS,
|
||||
};
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
// WaveObjectStore
|
||||
|
||||
import { sendRpcCommand } from "@/app/store/wshrpc";
|
||||
import { getServerWebEndpoint } from "@/util/endpoints";
|
||||
import * as jotai from "jotai";
|
||||
import * as React from "react";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { atoms, getBackendHostPort, globalStore } from "./global";
|
||||
import { atoms, globalStore } from "./global";
|
||||
import * as services from "./services";
|
||||
|
||||
const IsElectron = true;
|
||||
@@ -67,22 +68,23 @@ function callBackendService(service: string, method: string, args: any[], noUICo
|
||||
if (!noUIContext) {
|
||||
uiContext = globalStore.get(atoms.uiContext);
|
||||
}
|
||||
let waveCall: WebCallType = {
|
||||
const waveCall: WebCallType = {
|
||||
service: service,
|
||||
method: method,
|
||||
args: args,
|
||||
uicontext: uiContext,
|
||||
};
|
||||
// usp is just for debugging (easier to filter URLs)
|
||||
let methodName = service + "." + method;
|
||||
let usp = new URLSearchParams();
|
||||
const methodName = `${service}.${method}`;
|
||||
const usp = new URLSearchParams();
|
||||
usp.set("service", service);
|
||||
usp.set("method", method);
|
||||
let fetchPromise = fetch(getBackendHostPort() + "/wave/service?" + usp.toString(), {
|
||||
const url = getServerWebEndpoint() + "/wave/service?" + usp.toString();
|
||||
const fetchPromise = fetch(url, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(waveCall),
|
||||
});
|
||||
let prtn = fetchPromise
|
||||
const prtn = fetchPromise
|
||||
.then((resp) => {
|
||||
if (!resp.ok) {
|
||||
throw new Error(`call ${methodName} failed: ${resp.status} ${resp.statusText}`);
|
||||
|
||||
Reference in New Issue
Block a user