From afc5bbd2123c12a193c395756a40ebe92d50c8a6 Mon Sep 17 00:00:00 2001 From: sawka Date: Wed, 1 Nov 2023 01:26:19 -0700 Subject: [PATCH] Update Data Directories and Environment Variables (#59) * phase 1 of wave runtime migration. update waveterm_dev, build vars, waveterm_app_path. fix errors with plugins readmes and screenshot directories. use asset loaders in webpack. fix window-empty styles. wave-migrate script. remove unused scripthaus commands. other fixes * waveterm_home directory. lots of internal scbase prompt names to wave * update waveterm.lock file * change wave data directories. remove welcome modal code * update waveterm.db name * fix Wave menu (add back default items). Update TOS modal words * fix typescript errors --- housekeeping/wave-migrate.sh | 18 + scripthaus.md | 21 +- src/app/app.tsx | 5 +- src/app/assets/icons/line/modals.tsx | 367 -------------------- src/app/common/modals/modals.tsx | 146 ++------ src/app/common/modals/settings.tsx | 4 +- src/app/connections/connections.tsx | 12 +- src/app/sidebar/MainSideBar.tsx | 7 - src/app/workspace/screen/screenview.less | 20 ++ src/app/workspace/screen/screenview.tsx | 26 +- src/app/workspace/workspaceview.tsx | 2 +- src/electron/emain.ts | 59 ++-- src/index.ts | 6 +- src/model/model.ts | 15 +- src/plugins/csv/readme.md | 1 + src/plugins/image/readme.md | 1 + src/plugins/markdown/readme.md | 1 + src/plugins/markdown/screenshots/.gitignore | 1 + src/plugins/mustache/readme.md | 1 + src/plugins/mustache/screenshots/.gitignore | 1 + src/plugins/openai/readme.md | 1 + src/plugins/openai/screenshots/.gitignore | 1 + versionmeta.json | 22 ++ wavesrv/cmd/main-server.go | 23 +- wavesrv/pkg/cmdrunner/cmdrunner.go | 16 +- wavesrv/pkg/remote/remote.go | 6 +- wavesrv/pkg/scbase/scbase.go | 72 ++-- wavesrv/pkg/sstore/dbops.go | 10 +- wavesrv/pkg/sstore/sstore.go | 20 +- wavesrv/scripthaus.md | 6 +- webpack/webpack.electron.js | 12 +- webpack/webpack.electron.prod.js | 36 -- webpack/webpack.web.js | 18 +- 33 files changed, 256 insertions(+), 701 deletions(-) create mode 100644 housekeeping/wave-migrate.sh delete mode 100644 src/app/assets/icons/line/modals.tsx create mode 100644 src/plugins/csv/readme.md create mode 100644 src/plugins/image/readme.md create mode 100644 src/plugins/markdown/readme.md create mode 100644 src/plugins/markdown/screenshots/.gitignore create mode 100644 src/plugins/mustache/readme.md create mode 100644 src/plugins/mustache/screenshots/.gitignore create mode 100644 src/plugins/openai/readme.md create mode 100644 src/plugins/openai/screenshots/.gitignore create mode 100644 versionmeta.json delete mode 100644 webpack/webpack.electron.prod.js diff --git a/housekeeping/wave-migrate.sh b/housekeeping/wave-migrate.sh new file mode 100644 index 00000000..569d8620 --- /dev/null +++ b/housekeeping/wave-migrate.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +if [ ! -d ~/prompt ]; then + echo "~/prompt directory does not exist, will not migrate" + exit 1; +fi +if [ -d ~/.wave ]; then + echo "~/.wave directory already exists, will not migrate" + exit 1; +fi +mv ~/prompt ~/.wave +cd ~/.wave +mv prompt.db wave.db +mv prompt.db-wal wave.db-wal +mv prompt.db-shm wave.db-shm +mv prompt.authkey wave.authkey + + diff --git a/scripthaus.md b/scripthaus.md index c3716788..05f03708 100644 --- a/scripthaus.md +++ b/scripthaus.md @@ -27,7 +27,7 @@ node_modules/.bin/electron-rebuild ```bash # @scripthaus command electron # @scripthaus cd :playbook -PROMPT_DEV=1 PCLOUD_ENDPOINT="https://ot2e112zx5.execute-api.us-west-2.amazonaws.com/dev" node_modules/.bin/electron dist-dev/emain.js +WAVETERM_DEV=1 PCLOUD_ENDPOINT="https://ot2e112zx5.execute-api.us-west-2.amazonaws.com/dev" node_modules/.bin/electron dist-dev/emain.js ``` ```bash @@ -60,8 +60,7 @@ node_modules/.bin/electron-forge make rm -rf dist/ rm -rf bin/ rm -rf build/ -node_modules/.bin/webpack --config webpack.prod.js -node_modules/.bin/webpack --config webpack.electron.prod.js +node_modules/.bin/webpack --env prod GO_LDFLAGS="-s -w -X main.BuildTime=$(date +'%Y%m%d%H%M')" (cd waveshell; GOOS=darwin GOARCH=amd64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.3-darwin.amd64 main-waveshell.go) (cd waveshell; GOOS=darwin GOARCH=arm64 go build -ldflags="$GO_LDFLAGS" -o ../bin/mshell/mshell-v0.3-darwin.arm64 main-waveshell.go) @@ -113,22 +112,6 @@ rm *.dmg "out/Wave-darwin-arm64/Wave.app" ``` -```bash -# @scripthaus command sync-webshare-dev -# @scripthaus cd :playbook -# no-cache for dev -aws --profile prompt-s3 s3 sync webshare/static s3://prompt-devshare-static/static --cache-control 'no-cache' -aws --profile prompt-s3 s3 sync webshare/dist-dev s3://prompt-devshare-static/dist-dev --cache-control 'no-cache' -``` - -```bash -# @scripthaus command sync-webshare -# @scripthaus cd :playbook -# no-cache for dev -aws --profile prompt-s3 s3 sync webshare/static s3://prompt-share-static/static --cache-control 'no-cache' -aws --profile prompt-s3 s3 sync webshare/dist s3://prompt-share-static/dist --cache-control 'no-cache' -``` - ```bash # @scripthaus command build-wavesrv cd wavesrv diff --git a/src/app/app.tsx b/src/app/app.tsx index 96ca195f..fc0728a1 100644 --- a/src/app/app.tsx +++ b/src/app/app.tsx @@ -24,7 +24,7 @@ import { import { RemotesModal } from "./connections/connections"; import { TosModal } from "./common/modals/modals"; import { MainSideBar } from "./sidebar/MainSideBar"; -import { DisconnectedModal, ClientStopModal, AlertModal, WelcomeModal, AboutModal } from "./common/modals/modals"; +import { DisconnectedModal, ClientStopModal, AlertModal, AboutModal } from "./common/modals/modals"; import { ErrorBoundary } from "./common/error/errorboundary"; import "./app.less"; @@ -124,9 +124,6 @@ class App extends React.Component<{}, {}> { - - - diff --git a/src/app/assets/icons/line/modals.tsx b/src/app/assets/icons/line/modals.tsx deleted file mode 100644 index 02bfc364..00000000 --- a/src/app/assets/icons/line/modals.tsx +++ /dev/null @@ -1,367 +0,0 @@ -// Copyright 2023, Command Line Inc. -// SPDX-License-Identifier: Apache-2.0 - -import * as React from "react"; -import * as mobxReact from "mobx-react"; -import * as mobx from "mobx"; -import { boundMethod } from "autobind-decorator"; -import { If, For } from "tsx-control-statements/components"; -import cn from "classnames"; -import dayjs from "dayjs"; -import localizedFormat from "dayjs/plugin/localizedFormat"; -import { GlobalModel, GlobalCommandRunner } from "../../../model/model"; -import { Markdown } from "../common"; -import * as util from "../../../util/util"; - -import { ReactComponent as XmarkIcon } from "../../assets/icons/line/xmark.svg"; -import { ReactComponent as WarningIcon } from "../../assets/icons/line/triangle-exclamation.svg"; -import { ReactComponent as ShieldCheck } from "../../assets/icons/line/shield_check.svg"; -import { ReactComponent as Help } from "../../assets/icons/line/help_filled.svg"; -import { ReactComponent as Github } from "../../assets/icons/line/github.svg"; - -dayjs.extend(localizedFormat); - -type OV = mobx.IObservableValue; - -@mobxReact.observer -class DisconnectedModal extends React.Component<{}, {}> { - logRef: any = React.createRef(); - showLog: mobx.IObservableValue = mobx.observable.box(false); - - @boundMethod - restartServer() { - GlobalModel.restartWaveSrv(); - } - - @boundMethod - tryReconnect() { - GlobalModel.ws.connectNow("manual"); - } - - componentDidMount() { - if (this.logRef.current != null) { - this.logRef.current.scrollTop = this.logRef.current.scrollHeight; - } - } - - componentDidUpdate() { - if (this.logRef.current != null) { - this.logRef.current.scrollTop = this.logRef.current.scrollHeight; - } - } - - @boundMethod - handleShowLog(): void { - mobx.action(() => { - this.showLog.set(!this.showLog.get()); - })(); - } - - render() { - let model = GlobalModel; - let logLine: string = null; - let idx: number = 0; - return ( -
-
-
-
-
Prompt Client Disconnected
-
- -
-
- -
- {logLine} -
-
-
-
-
-
-
- - Show Log - - - Hide Log - -
-
- - -
-
-
- ); - } -} - -@mobxReact.observer -class ClientStopModal extends React.Component<{}, {}> { - @boundMethod - refreshClient() { - GlobalModel.refreshClient(); - } - - render() { - let model = GlobalModel; - let cdata = model.clientData.get(); - let title = "Client Not Ready"; - return ( -
-
-
-
-
[prompt] {title}
-
-
- -
Cannot get client data.
-
-
-
- -
-
-
- ); - } -} - -@mobxReact.observer -class LoadingSpinner extends React.Component<{}, {}> { - render() { - return ( -
-
-
-
-
-
- ); - } -} - -@mobxReact.observer -class AlertModal extends React.Component<{}, {}> { - @boundMethod - closeModal(): void { - GlobalModel.cancelAlert(); - } - - @boundMethod - handleOK(): void { - GlobalModel.confirmAlert(); - } - - render() { - let message = GlobalModel.alertMessage.get(); - if (message == null) { - return null; - } - let title = message.title ?? (message.confirm ? "Confirm" : "Alert"); - let isConfirm = message.confirm; - return ( -
-
-
-
-

- - {title} -

-
- -
-
- - - - -
-

{message.message}

-
-
-
- -
- Cancel -
-
- OK -
-
- -
- OK -
-
-
-
-
- ); - } -} - -@mobxReact.observer -class WelcomeModal extends React.Component<{}, {}> { - totalPages: number = 3; - pageNum: OV = mobx.observable.box(1, { name: "welcome-pagenum" }); - - @boundMethod - closeModal(): void { - mobx.action(() => { - GlobalModel.welcomeModalOpen.set(false); - })(); - } - - @boundMethod - goNext(): void { - mobx.action(() => { - this.pageNum.set(this.pageNum.get() + 1); - })(); - } - - @boundMethod - goPrev(): void { - mobx.action(() => { - this.pageNum.set(this.pageNum.get() - 1); - })(); - } - - renderDot(num: number): any { - if (num == this.pageNum.get()) { - return ; - } - return ; - } - - renderDots(): any { - let elems: any = []; - for (let i = 1; i <= this.totalPages; i++) { - let elem = this.renderDot(i); - elems.push(elem); - } - return elems; - } - - render() { - let pageNum = this.pageNum.get(); - return ( -
-
-
-
-
welcome to [prompt]
-
- -
-
-
-

- Prompt is a new terminal to help save you time and keep your command-line life organized. - Here's a couple quick tips to get your started! -

-
-
- 1}> - - - -
- -
-
{this.renderDots()}
-
- - - - - - -
-
-
- ); - } -} - -@mobxReact.observer -class TosModal extends React.Component<{}, {}> { - @boundMethod - acceptTos(): void { - GlobalCommandRunner.clientAcceptTos(); - } - - render() { - return ( -
-
-
-
-
-
Welcome to Wave Terminal!
-
Lets set everything for you
-
-
-
- -
-
Telemetry
-
-
-
- -
-
-
- -
-
- {/*

- - Full Terms of Service - -

*/} -
-
-
-
- Accept Terms of Service -
-
-
-
-
- ); - } -} - -export { WelcomeModal, LoadingSpinner, ClientStopModal, AlertModal, DisconnectedModal, TosModal }; diff --git a/src/app/common/modals/modals.tsx b/src/app/common/modals/modals.tsx index 3b5d261a..3625be57 100644 --- a/src/app/common/modals/modals.tsx +++ b/src/app/common/modals/modals.tsx @@ -17,6 +17,7 @@ import { ClientDataType } from "../../../types/types"; import close from "../../assets/icons/close.svg"; import { ReactComponent as WarningIcon } from "../../assets/icons/line/triangle-exclamation.svg"; +import { ReactComponent as XmarkIcon } from "../../assets/icons/line/xmark.svg"; import shield from "../../assets/icons/shield_check.svg"; import help from "../../assets/icons/help_filled.svg"; import github from "../../assets/icons/github.svg"; @@ -25,7 +26,7 @@ import logo from "../../assets/waveterm-logo-with-bg.svg"; dayjs.extend(localizedFormat); // @ts-ignore -const VERSION = __PROMPT_VERSION__; +const VERSION = __WAVETERM_VERSION__; type OV = mobx.IObservableValue; @@ -72,7 +73,7 @@ class DisconnectedModal extends React.Component<{}, {}> {
-
Prompt Client Disconnected
+
Wave Client Disconnected
@@ -128,7 +129,7 @@ class ClientStopModal extends React.Component<{}, {}> {
-
[prompt] {title}
+
{title}
@@ -224,101 +225,6 @@ class AlertModal extends React.Component<{}, {}> { } } -@mobxReact.observer -class WelcomeModal extends React.Component<{}, {}> { - totalPages: number = 3; - pageNum: OV = mobx.observable.box(1, { name: "welcome-pagenum" }); - - @boundMethod - closeModal(): void { - mobx.action(() => { - GlobalModel.welcomeModalOpen.set(false); - })(); - } - - @boundMethod - goNext(): void { - mobx.action(() => { - this.pageNum.set(this.pageNum.get() + 1); - })(); - } - - @boundMethod - goPrev(): void { - mobx.action(() => { - this.pageNum.set(this.pageNum.get() - 1); - })(); - } - - renderDot(num: number): any { - if (num == this.pageNum.get()) { - return ; - } - return ; - } - - renderDots(): any { - let elems: any = []; - for (let i = 1; i <= this.totalPages; i++) { - let elem = this.renderDot(i); - elems.push(elem); - } - return elems; - } - - render() { - let pageNum = this.pageNum.get(); - return ( -
-
-
-
-
About
-
- -
-
-
-

- Prompt is a new terminal to help save you time and keep your command-line life organized. - Here's a couple quick tips to get your started! -

-
-
- 1}> - - - -
- -
-
{this.renderDots()}
-
- - - - - - -
-
-
- ); - } -} - @mobxReact.observer class TosModal extends React.Component<{}, {}> { state = { @@ -352,60 +258,66 @@ class TosModal extends React.Component<{}, {}> {
-
+
Welcome to Wave Terminal!
Lets set everything for you
-
+
Privacy
Telemetry
- We don’t collect any personal info, only crash logs and IP address to make Wave - better. If you like, you can disable telemetry now or late. + We only collect minimal anonymous telemetry data to help us + understand how many people are using Wave.
-
+
-
Basic Telemetry
+
Telemetry {cdata.clientopts.notelemetry ? "Disabled" : "Enabled"}
- Help + + Help +
-
Help
+
Join our Community
- If you need any help or you have feature request, you can join{" "} + Get help, submit feature requests, report bugs, + or just chat with fellow terminal enthusiasts.
- our Discord + Join the Wave Discord Channel - .
- Github + + Github +
-
Like Wave? Give us a star
+
Support us on GitHub
- Rankings are very important for small startups like us, it helps other people to - know about us. If you like Wave, please consider giving us a star on our{" "} + We're open source and committed to providing a free terminal for individual + users. Please show your support us by giving us a star on{" "} - Github Repository + Github (wavetermdev/waveterm) - .
-
+
{ } } -export { WelcomeModal, LoadingSpinner, ClientStopModal, AlertModal, DisconnectedModal, TosModal, AboutModal }; +export { LoadingSpinner, ClientStopModal, AlertModal, DisconnectedModal, TosModal, AboutModal }; diff --git a/src/app/common/modals/settings.tsx b/src/app/common/modals/settings.tsx index 44e1f505..6e5c174e 100644 --- a/src/app/common/modals/settings.tsx +++ b/src/app/common/modals/settings.tsx @@ -23,9 +23,9 @@ import "./modals.less"; type OV = mobx.IObservableValue; // @ts-ignore -const VERSION = __PROMPT_VERSION__; +const VERSION = __WAVETERM_VERSION__; // @ts-ignore -const BUILD = __PROMPT_BUILD__; +const BUILD = __WAVETERM_BUILD__; const ScreenDeleteMessage = ` Are you sure you want to delete this screen/tab? diff --git a/src/app/connections/connections.tsx b/src/app/connections/connections.tsx index 6b0c5510..34d7d61e 100644 --- a/src/app/connections/connections.tsx +++ b/src/app/connections/connections.tsx @@ -408,13 +408,13 @@ class CreateRemote extends React.Component<{ model: RemotesModalModel; remoteEdi
  • - startup - connect when [prompt] starts. + startup - Connect when Wave Terminal starts.
  • - auto - connect when you first run a command using this connection. + auto - Connect when you first run a command using this connection.
  • - manual - connect manually. Note, if your connection requires manual input, + manual - Connect manually. Note, if your connection requires manual input, like an OPT code, you must use this setting.
@@ -703,13 +703,13 @@ class EditRemoteSettings extends React.Component<
  • - startup - connect when [prompt] starts. + startup - Connect when Wave Terminal starts.
  • - auto - connect when you first run a command using this connection. + auto - Connect when you first run a command using this connection.
  • - manual - connect manually. Note, if your connection requires manual input, + manual - Connect manually. Note, if your connection requires manual input, like an OPT code, you must use this setting.
diff --git a/src/app/sidebar/MainSideBar.tsx b/src/app/sidebar/MainSideBar.tsx index 9ca76340..c318fce8 100644 --- a/src/app/sidebar/MainSideBar.tsx +++ b/src/app/sidebar/MainSideBar.tsx @@ -118,13 +118,6 @@ class MainSideBar extends React.Component<{}, {}> { GlobalModel.showWebShareView(); } - @boundMethod - handleWelcomeClick(): void { - mobx.action(() => { - GlobalModel.welcomeModalOpen.set(true); - })(); - } - @boundMethod handleSettingsClick(): void { mobx.action(() => { diff --git a/src/app/workspace/screen/screenview.less b/src/app/workspace/screen/screenview.less index 131dbae8..43f4775d 100644 --- a/src/app/workspace/screen/screenview.less +++ b/src/app/workspace/screen/screenview.less @@ -41,6 +41,26 @@ } } + .window-empty { + display: flex; + align-items: center; + justify-content: center; + width: 100%; + padding: 10px; + height: 100%; + color: #ccc; + + code { + background-color: transparent; + color: #4e9a06; + } + + &.should-fade { + opacity: 1; + animation: fade-in 2.5s; + } + } + .share-tag { color: @term-white; position: absolute; diff --git a/src/app/workspace/screen/screenview.tsx b/src/app/workspace/screen/screenview.tsx index 0ac81b4d..eaf3f589 100644 --- a/src/app/workspace/screen/screenview.tsx +++ b/src/app/workspace/screen/screenview.tsx @@ -16,7 +16,7 @@ import * as T from "../../../types/types"; import localizedFormat from "dayjs/plugin/localizedFormat"; import { InlineSettingsTextEdit, RemoteStatusLight } from "../../common/common"; import { getRemoteStr } from "../../common/prompt/prompt"; -import { GlobalModel, ScreenLines, Screen } from "../../../model/model"; +import { GlobalModel, ScreenLines, Screen, Session } from "../../../model/model"; import { Line } from "../../line/linecomps"; import { LinesView } from "../../line/linesview"; import * as util from "../../../util/util"; @@ -36,16 +36,16 @@ dayjs.extend(localizedFormat); type OV = mobx.IObservableValue; @mobxReact.observer -class ScreenView extends React.Component<{ screen: Screen }, {}> { +class ScreenView extends React.Component<{ session: Session, screen: Screen }, {}> { render() { - let { screen } = this.props; + let { session, screen } = this.props; if (screen == null) { return
(no screen found)
; } let fontSize = GlobalModel.termFontSize.get(); return (
- +
); } @@ -219,7 +219,7 @@ class NewTabSettings extends React.Component<{ screen: Screen }, {}> { // screen is not null @mobxReact.observer -class ScreenWindowView extends React.Component<{ screen: Screen }, {}> { +class ScreenWindowView extends React.Component<{ session: Session, screen: Screen }, {}> { rszObs: any; windowViewRef: React.RefObject; @@ -303,7 +303,7 @@ class ScreenWindowView extends React.Component<{ screen: Screen }, {}> {
-
{message}
+
{message}
); @@ -344,7 +344,7 @@ class ScreenWindowView extends React.Component<{ screen: Screen }, {}> { } render() { - let { screen } = this.props; + let { session, screen } = this.props; let win = this.getScreenLines(); if (win == null || !win.loaded.get()) { return this.renderError("...", true); @@ -379,7 +379,17 @@ class ScreenWindowView extends React.Component<{ screen: Screen }, {}> {
- + + + + +
+
+
+
[workspace="{session.name.get()}" screen="{screen.name.get()}"]
+
+
+
diff --git a/src/app/workspace/workspaceview.tsx b/src/app/workspace/workspaceview.tsx index d9868593..9c6f6608 100644 --- a/src/app/workspace/workspaceview.tsx +++ b/src/app/workspace/workspaceview.tsx @@ -39,7 +39,7 @@ class WorkspaceView extends React.Component<{}, {}> {
- +
diff --git a/src/electron/emain.ts b/src/electron/emain.ts index 317e6bd4..8c199068 100644 --- a/src/electron/emain.ts +++ b/src/electron/emain.ts @@ -13,15 +13,15 @@ import * as util from "util"; import { sprintf } from "sprintf-js"; import { v4 as uuidv4 } from "uuid"; -const PromptAppPathVarName = "PROMPT_APP_PATH"; -const PromptDevVarName = "PROMPT_DEV"; -const AuthKeyFile = "prompt.authkey"; +const WaveAppPathVarName = "WAVETERM_APP_PATH"; +const WaveDevVarName = "WAVETERM_DEV"; +const AuthKeyFile = "waveterm.authkey"; const DevServerEndpoint = "http://127.0.0.1:8090"; const ProdServerEndpoint = "http://127.0.0.1:1619"; -let isDev = process.env[PromptDevVarName] != null; -let scHome = getPromptHomeDir(); -ensureDir(scHome); +let isDev = process.env[WaveDevVarName] != null; +let waveHome = getWaveHomeDir(); +ensureDir(waveHome); let DistDir = isDev ? "dist-dev" : "dist"; let GlobalAuthKey = ""; let instanceId = uuidv4(); @@ -43,7 +43,7 @@ let loggerConfig = { winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), winston.format.printf((info) => `${info.timestamp} ${info.message}`) ), - transports: [new winston.transports.File({ filename: path.join(scHome, "waveterm-app.log"), level: "info" })], + transports: [new winston.transports.File({ filename: path.join(waveHome, "waveterm-app.log"), level: "info" })], }; if (isDev) { loggerConfig.transports.push(new winston.transports.Console()); @@ -59,15 +59,15 @@ function log(...msg) { console.log = log; console.log( sprintf( - "waveterm-app starting, PROMPT_HOME=%s, apppath=%s arch=%s/%s", - scHome, + "waveterm-app starting, WAVETERM_HOME=%s, apppath=%s arch=%s/%s", + waveHome, getAppBasePath(), unamePlatform, unameArch ) ); if (isDev) { - console.log("prompt-app PROMPT_DEV set"); + console.log("waveterm-app WAVETERM_DEV set"); } let app = electron.app; app.setName(isDev ? "Wave (Dev)" : "Wave"); @@ -79,20 +79,20 @@ electron.dialog.showErrorBox = (title, content) => { }; // must match golang -function getPromptHomeDir() { - let scHome = process.env.PROMPT_HOME; - if (scHome == null) { +function getWaveHomeDir() { + let waveHome = process.env.WAVETERM_HOME; + if (waveHome == null) { let homeDir = process.env.HOME; if (homeDir == null) { homeDir = "/"; } - scHome = path.join(homeDir, isDev ? "prompt-dev" : "prompt"); + waveHome = path.join(homeDir, isDev ? ".waveterm-dev" : ".waveterm"); } - return scHome; + return waveHome; } -// for dev, this is just the github.com/commandlinedev/prompt-client directory -// for prod, this is .../Prompt.app/Contents/Resources/app +// for dev, this is just the waveterm directory +// for prod, this is .../Wave.app/Contents/Resources/app function getAppBasePath() { return path.dirname(__dirname); } @@ -113,14 +113,14 @@ function getWaveSrvPath() { function getWaveSrvCmd() { let waveSrvPath = getWaveSrvPath(); - let scHome = getPromptHomeDir(); - let logFile = path.join(scHome, "wavesrv.log"); + let waveHome = getWaveHomeDir(); + let logFile = path.join(waveHome, "wavesrv.log"); return `${waveSrvPath} >> "${logFile}" 2>&1`; } function getWaveSrvCwd() { - let scHome = getPromptHomeDir(); - return scHome; + let waveHome = getWaveHomeDir(); + return waveHome; } function ensureDir(dir) { @@ -128,7 +128,7 @@ function ensureDir(dir) { } function readAuthKey() { - let homeDir = getPromptHomeDir(); + let homeDir = getWaveHomeDir(); let authKeyFileName = path.join(homeDir, AuthKeyFile); if (!fs.existsSync(authKeyFileName)) { let authKeyStr = String(uuidv4()); @@ -152,11 +152,18 @@ let menuTemplate = [ click: () => { MainWindow?.webContents.send('menu-item-about'); } - } + }, + { type: "separator" }, + { role: "services" }, + { type: "separator" }, + { role: "hide" }, + { role: "hideOthers" }, + { type: "separator" }, + { role: "quit" }, ], }, { - label: "File", + label: "Filemenu", submenu: [{ role: "close" }, { role: "forceReload" }], }, { @@ -509,9 +516,9 @@ function runWaveSrv() { pReject = argReject; }); let envCopy = Object.assign({}, process.env); - envCopy[PromptAppPathVarName] = getAppBasePath(); + envCopy[WaveAppPathVarName] = getAppBasePath(); if (isDev) { - envCopy[PromptDevVarName] = "1"; + envCopy[WaveDevVarName] = "1"; } console.log("trying to run local server", getWaveSrvPath()); let proc = child_process.spawn("/bin/bash", ["-c", getWaveSrvCmd()], { diff --git a/src/index.ts b/src/index.ts index f933174c..f4ed308e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,9 +10,9 @@ import * as DOMPurify from "dompurify"; import { loadFonts } from "./util/util"; // @ts-ignore -let VERSION = __PROMPT_VERSION__; +let VERSION = __WAVETERM_VERSION__; // @ts-ignore -let BUILD = __PROMPT_BUILD__; +let BUILD = __WAVETERM_BUILD__; loadFonts(); @@ -34,4 +34,4 @@ document.addEventListener("DOMContentLoaded", () => { (window as any).sprintf = sprintf; (window as any).DOMPurify = DOMPurify; -console.log("PROMPT", VERSION, BUILD); +console.log("WaveTerm", VERSION, BUILD); diff --git a/src/model/model.ts b/src/model/model.ts index ed19ee0f..cef089d2 100644 --- a/src/model/model.ts +++ b/src/model/model.ts @@ -97,9 +97,9 @@ const RemoteColors = ["red", "green", "yellow", "blue", "magenta", "cyan", "whit const TabColors = ["green", "blue", "yellow", "pink", "magenta", "cyan", "violet", "orange", "red", "white"]; // @ts-ignore -const VERSION = __PROMPT_VERSION__; +const VERSION = __WAVETERM_VERSION__; // @ts-ignore -const BUILD = __PROMPT_BUILD__; +const BUILD = __WAVETERM_BUILD__; type LineContainerModel = { loadTerminalRenderer: (elem: Element, line: LineType, cmd: Cmd, width: number) => void; @@ -2697,9 +2697,6 @@ class Model { name: "alertMessage", }); alertPromiseResolver: (result: boolean) => void; - welcomeModalOpen: OV = mobx.observable.box(false, { - name: "welcomeModalOpen", - }); aboutModalOpen: OV = mobx.observable.box(false, { name: "aboutModalOpen", }); @@ -2978,14 +2975,6 @@ class Model { GlobalModel.lineSettingsModal.set(null); didSomething = true; } - if (GlobalModel.welcomeModalOpen.get()) { - GlobalModel.welcomeModalOpen.set(false); - didSomething = true; - } - if (GlobalModel.welcomeModalOpen.get()) { - GlobalModel.welcomeModalOpen.set(false); - didSomething = true; - } })(); return didSomething; } diff --git a/src/plugins/csv/readme.md b/src/plugins/csv/readme.md new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/plugins/csv/readme.md @@ -0,0 +1 @@ + diff --git a/src/plugins/image/readme.md b/src/plugins/image/readme.md new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/plugins/image/readme.md @@ -0,0 +1 @@ + diff --git a/src/plugins/markdown/readme.md b/src/plugins/markdown/readme.md new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/plugins/markdown/readme.md @@ -0,0 +1 @@ + diff --git a/src/plugins/markdown/screenshots/.gitignore b/src/plugins/markdown/screenshots/.gitignore new file mode 100644 index 00000000..f4572339 --- /dev/null +++ b/src/plugins/markdown/screenshots/.gitignore @@ -0,0 +1 @@ +# placeholder \ No newline at end of file diff --git a/src/plugins/mustache/readme.md b/src/plugins/mustache/readme.md new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/plugins/mustache/readme.md @@ -0,0 +1 @@ + diff --git a/src/plugins/mustache/screenshots/.gitignore b/src/plugins/mustache/screenshots/.gitignore new file mode 100644 index 00000000..f4572339 --- /dev/null +++ b/src/plugins/mustache/screenshots/.gitignore @@ -0,0 +1 @@ +# placeholder \ No newline at end of file diff --git a/src/plugins/openai/readme.md b/src/plugins/openai/readme.md new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/src/plugins/openai/readme.md @@ -0,0 +1 @@ + diff --git a/src/plugins/openai/screenshots/.gitignore b/src/plugins/openai/screenshots/.gitignore new file mode 100644 index 00000000..f4572339 --- /dev/null +++ b/src/plugins/openai/screenshots/.gitignore @@ -0,0 +1 @@ +# placeholder \ No newline at end of file diff --git a/versionmeta.json b/versionmeta.json new file mode 100644 index 00000000..a24fc53a --- /dev/null +++ b/versionmeta.json @@ -0,0 +1,22 @@ +{ + "packages": [ + { + "type": "dmg", + "arch": "macos-arm64", + "channel": "stable", + "updated": "2023-10-31", + "version": "v0.4.0", + "sha": "016876cf3e9fb600d6798891c8566a7ac5d1446a", + "url": "https://www.getprompt.dev/download/prompt-macos-arm64-v0.4.0.dmg" + }, + { + "type": "dmg", + "arch": "macos-amd64", + "channel": "stable", + "updated": "2023-10-31", + "version": "v0.4.0", + "sha": "d0bc280e4630a716126e47e700d8d4364db966e6", + "url": "https://www.getprompt.dev/download/prompt-macos-x86-v0.4.0.dmg" + } + ] +} diff --git a/wavesrv/cmd/main-server.go b/wavesrv/cmd/main-server.go index ca9a5fdd..27ce5cc6 100644 --- a/wavesrv/cmd/main-server.go +++ b/wavesrv/cmd/main-server.go @@ -48,8 +48,8 @@ const HttpWriteTimeout = 21 * time.Second const HttpMaxHeaderBytes = 60000 const HttpTimeoutDuration = 21 * time.Second -const MainServerAddr = "127.0.0.1:1619" // PromptServer, P=16, S=19, PS=1619 -const WebSocketServerAddr = "127.0.0.1:1623" // PromptWebsock, P=16, W=23, PW=1623 +const MainServerAddr = "127.0.0.1:1619" // wavesrv, P=16, S=19, PS=1619 +const WebSocketServerAddr = "127.0.0.1:1623" // wavesrv:websocket, P=16, W=23, PW=1623 const MainServerDevAddr = "127.0.0.1:8090" const WebSocketServerDevAddr = "127.0.0.1:8091" const WSStateReconnectTime = 30 * time.Second @@ -763,11 +763,11 @@ func installSignalHandlers() { func doShutdown(reason string) { shutdownOnce.Do(func() { - log.Printf("[prompt] local server %v, start shutdown\n", reason) + log.Printf("[wave] local server %v, start shutdown\n", reason) sendTelemetryWrapper() - log.Printf("[prompt] closing db connection\n") + log.Printf("[wave] closing db connection\n") sstore.CloseDB() - log.Printf("[prompt] *** shutting down local server\n") + log.Printf("[wave] *** shutting down local server\n") time.Sleep(1 * time.Second) syscall.Kill(syscall.Getpid(), syscall.SIGINT) time.Sleep(5 * time.Second) @@ -787,14 +787,13 @@ func main() { return } - scHomeDir := scbase.GetPromptHomeDir() - log.Printf("[prompt] *** starting local server\n") - log.Printf("[prompt] local server version %s+%s\n", scbase.PromptVersion, scbase.BuildTime) - log.Printf("[prompt] homedir = %q\n", scHomeDir) + scHomeDir := scbase.GetWaveHomeDir() + log.Printf("[wave] *** starting wavesrv version %s+%s\n", scbase.WaveVersion, scbase.BuildTime) + log.Printf("[wave] homedir = %q\n", scHomeDir) - scLock, err := scbase.AcquirePromptLock() + scLock, err := scbase.AcquireWaveLock() if err != nil || scLock == nil { - log.Printf("[error] cannot acquire prompt lock: %v\n", err) + log.Printf("[error] cannot acquire wave lock: %v\n", err) return } if len(os.Args) >= 2 && strings.HasPrefix(os.Args[1], "--migrate") { @@ -804,7 +803,7 @@ func main() { } return } - authKey, err := scbase.ReadPromptAuthKey() + authKey, err := scbase.ReadWaveAuthKey() if err != nil { log.Printf("[error] %v\n", err) return diff --git a/wavesrv/pkg/cmdrunner/cmdrunner.go b/wavesrv/pkg/cmdrunner/cmdrunner.go index 316ee40e..aed03116 100644 --- a/wavesrv/pkg/cmdrunner/cmdrunner.go +++ b/wavesrv/pkg/cmdrunner/cmdrunner.go @@ -379,7 +379,7 @@ func doCmdHistoryExpansion(ctx context.Context, ids resolvedIds, cmdStr string) return doHistoryExpansion(ctx, ids, -1) } if strings.HasPrefix(cmdStr, "!-") { - return "", fmt.Errorf("prompt does not support negative history offsets, use a stable positive history offset instead: '![linenum]'") + return "", fmt.Errorf("wave does not support negative history offsets, use a stable positive history offset instead: '![linenum]'") } m := histExpansionRe.FindStringSubmatch(cmdStr) if m == nil { @@ -435,7 +435,7 @@ func SyncCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore. } runPacket := packet.MakeRunPacket() runPacket.ReqId = uuid.New().String() - runPacket.CK = base.MakeCommandKey(ids.ScreenId, scbase.GenPromptUUID()) + runPacket.CK = base.MakeCommandKey(ids.ScreenId, scbase.GenWaveUUID()) runPacket.UsePty = true ptermVal := defaultStr(pk.Kwargs["pterm"], DefaultPTERM) runPacket.TermOpts, err = GetUITermOpts(pk.UIContext.WinSize, ptermVal) @@ -531,7 +531,7 @@ func RunCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.U // runPacket.State is set in remote.RunCommand() runPacket := packet.MakeRunPacket() runPacket.ReqId = uuid.New().String() - runPacket.CK = base.MakeCommandKey(ids.ScreenId, scbase.GenPromptUUID()) + runPacket.CK = base.MakeCommandKey(ids.ScreenId, scbase.GenWaveUUID()) runPacket.UsePty = true ptermVal := defaultStr(pk.Kwargs["pterm"], DefaultPTERM) runPacket.TermOpts, err = GetUITermOpts(pk.UIContext.WinSize, ptermVal) @@ -575,7 +575,7 @@ func addToHistory(ctx context.Context, pk *scpacket.FeCommandPacketType, history return fmt.Errorf("cannot add to history, error looking up incognito status of screen: %v", err) } hitem := &sstore.HistoryItemType{ - HistoryId: scbase.GenPromptUUID(), + HistoryId: scbase.GenWaveUUID(), Ts: time.Now().UnixMilli(), UserId: DefaultUserId, SessionId: ids.SessionId, @@ -1115,7 +1115,7 @@ func RemoteNewCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (ss return nil, fmt.Errorf("/remote:new %v", err) } r := &sstore.RemoteType{ - RemoteId: scbase.GenPromptUUID(), + RemoteId: scbase.GenWaveUUID(), RemoteType: sstore.RemoteTypeSsh, RemoteAlias: editArgs.Alias, RemoteCanonicalName: editArgs.CanonicalName, @@ -1606,7 +1606,7 @@ func CrCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.Up func makeDynCmd(ctx context.Context, metaCmd string, ids resolvedIds, cmdStr string, termOpts sstore.TermOpts) (*sstore.CmdType, error) { cmd := &sstore.CmdType{ ScreenId: ids.ScreenId, - LineId: scbase.GenPromptUUID(), + LineId: scbase.GenWaveUUID(), CmdStr: cmdStr, RawCmdStr: cmdStr, Remote: ids.Remote.RemotePtr, @@ -1631,7 +1631,7 @@ func makeDynCmd(ctx context.Context, metaCmd string, ids resolvedIds, cmdStr str func makeStaticCmd(ctx context.Context, metaCmd string, ids resolvedIds, cmdStr string, cmdOutput []byte) (*sstore.CmdType, error) { cmd := &sstore.CmdType{ ScreenId: ids.ScreenId, - LineId: scbase.GenPromptUUID(), + LineId: scbase.GenWaveUUID(), CmdStr: cmdStr, RawCmdStr: cmdStr, Remote: ids.Remote.RemotePtr, @@ -3654,7 +3654,7 @@ func ClientShowCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (s buf.WriteString(fmt.Sprintf(" %-15s %s\n", "telemetry", boolToStr(clientData.ClientOpts.NoTelemetry, "off", "on"))) buf.WriteString(fmt.Sprintf(" %-15s %d\n", "db-version", dbVersion)) buf.WriteString(fmt.Sprintf(" %-15s %s\n", "client-version", clientVersion)) - buf.WriteString(fmt.Sprintf(" %-15s %s %s\n", "server-version", scbase.PromptVersion, scbase.BuildTime)) + buf.WriteString(fmt.Sprintf(" %-15s %s %s\n", "server-version", scbase.WaveVersion, scbase.BuildTime)) buf.WriteString(fmt.Sprintf(" %-15s %s (%s)\n", "arch", scbase.ClientArch(), scbase.MacOSRelease())) update := &sstore.ModelUpdate{ Info: &sstore.InfoMsgType{ diff --git a/wavesrv/pkg/remote/remote.go b/wavesrv/pkg/remote/remote.go index c9106c2b..a3496fa1 100644 --- a/wavesrv/pkg/remote/remote.go +++ b/wavesrv/pkg/remote/remote.go @@ -22,6 +22,8 @@ import ( "time" "github.com/armon/circbuf" + "github.com/creack/pty" + "github.com/google/uuid" "github.com/wavetermdev/waveterm/waveshell/pkg/base" "github.com/wavetermdev/waveterm/waveshell/pkg/packet" "github.com/wavetermdev/waveterm/waveshell/pkg/shexec" @@ -29,8 +31,6 @@ import ( "github.com/wavetermdev/waveterm/wavesrv/pkg/scbase" "github.com/wavetermdev/waveterm/wavesrv/pkg/scpacket" "github.com/wavetermdev/waveterm/wavesrv/pkg/sstore" - "github.com/creack/pty" - "github.com/google/uuid" "golang.org/x/mod/semver" ) @@ -1133,7 +1133,7 @@ func addScVarsToState(state *packet.ShellState) *packet.ShellState { rtn := *state envMap := shexec.DeclMapFromState(&rtn) envMap["PROMPT"] = &shexec.DeclareDeclType{Name: "PROMPT", Value: "1", Args: "x"} - envMap["PROMPT_VERSION"] = &shexec.DeclareDeclType{Name: "PROMPT_VERSION", Value: scbase.PromptVersion, Args: "x"} + envMap["PROMPT_VERSION"] = &shexec.DeclareDeclType{Name: "PROMPT_VERSION", Value: scbase.WaveVersion, Args: "x"} rtn.ShellVars = shexec.SerializeDeclMap(envMap) return &rtn } diff --git a/wavesrv/pkg/scbase/scbase.go b/wavesrv/pkg/scbase/scbase.go index b4508aeb..382238ab 100644 --- a/wavesrv/pkg/scbase/scbase.go +++ b/wavesrv/pkg/scbase/scbase.go @@ -28,16 +28,16 @@ import ( ) const HomeVarName = "HOME" -const PromptHomeVarName = "PROMPT_HOME" -const PromptDevVarName = "PROMPT_DEV" +const WaveHomeVarName = "WAVETERM_HOME" +const WaveDevVarName = "WAVETERM_DEV" const SessionsDirBaseName = "sessions" const ScreensDirBaseName = "screens" -const PromptLockFile = "prompt.lock" -const PromptDirName = "prompt" -const PromptDevDirName = "prompt-dev" -const PromptAppPathVarName = "PROMPT_APP_PATH" -const PromptVersion = "v0.5.0" -const PromptAuthKeyFileName = "prompt.authkey" +const WaveLockFile = "waveterm.lock" +const WaveDirName = ".waveterm" // must match emain.ts +const WaveDevDirName = ".waveterm-dev" // must match emain.ts +const WaveAppPathVarName = "WAVETERM_APP_PATH" +const WaveVersion = "v0.5.0" +const WaveAuthKeyFileName = "waveterm.authkey" const MShellVersion = "v0.3.0" const DefaultMacOSShell = "/bin/bash" @@ -47,23 +47,23 @@ var BaseLock = &sync.Mutex{} var BuildTime = "-" func IsDevMode() bool { - pdev := os.Getenv(PromptDevVarName) + pdev := os.Getenv(WaveDevVarName) return pdev != "" } // must match js -func GetPromptHomeDir() string { - scHome := os.Getenv(PromptHomeVarName) +func GetWaveHomeDir() string { + scHome := os.Getenv(WaveHomeVarName) if scHome == "" { homeVar := os.Getenv(HomeVarName) if homeVar == "" { homeVar = "/" } - pdev := os.Getenv(PromptDevVarName) + pdev := os.Getenv(WaveDevVarName) if pdev != "" { - scHome = path.Join(homeVar, PromptDevDirName) + scHome = path.Join(homeVar, WaveDevDirName) } else { - scHome = path.Join(homeVar, PromptDirName) + scHome = path.Join(homeVar, WaveDirName) } } @@ -71,7 +71,7 @@ func GetPromptHomeDir() string { } func MShellBinaryDir() string { - appPath := os.Getenv(PromptAppPathVarName) + appPath := os.Getenv(WaveAppPathVarName) if appPath == "" { appPath = "." } @@ -111,13 +111,13 @@ func MShellBinaryReader(version string, goos string, goarch string) (io.ReadClos return fd, nil } -func createPromptAuthKeyFile(fileName string) (string, error) { +func createWaveAuthKeyFile(fileName string) (string, error) { fd, err := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { return "", err } defer fd.Close() - keyStr := GenPromptUUID() + keyStr := GenWaveUUID() _, err = fd.Write([]byte(keyStr)) if err != nil { return "", err @@ -125,24 +125,24 @@ func createPromptAuthKeyFile(fileName string) (string, error) { return keyStr, nil } -func ReadPromptAuthKey() (string, error) { - homeDir := GetPromptHomeDir() +func ReadWaveAuthKey() (string, error) { + homeDir := GetWaveHomeDir() err := ensureDir(homeDir) if err != nil { - return "", fmt.Errorf("cannot find/create PROMPT_HOME directory %q", homeDir) + return "", fmt.Errorf("cannot find/create WAVETERM_HOME directory %q", homeDir) } - fileName := path.Join(homeDir, PromptAuthKeyFileName) + fileName := path.Join(homeDir, WaveAuthKeyFileName) fd, err := os.Open(fileName) if err != nil && errors.Is(err, fs.ErrNotExist) { - return createPromptAuthKeyFile(fileName) + return createWaveAuthKeyFile(fileName) } if err != nil { - return "", fmt.Errorf("error opening prompt authkey:%s: %v", fileName, err) + return "", fmt.Errorf("error opening wave authkey:%s: %v", fileName, err) } defer fd.Close() buf, err := io.ReadAll(fd) if err != nil { - return "", fmt.Errorf("error reading prompt authkey:%s: %v", fileName, err) + return "", fmt.Errorf("error reading wave authkey:%s: %v", fileName, err) } keyStr := string(buf) _, err = uuid.Parse(keyStr) @@ -152,13 +152,13 @@ func ReadPromptAuthKey() (string, error) { return keyStr, nil } -func AcquirePromptLock() (*os.File, error) { - homeDir := GetPromptHomeDir() +func AcquireWaveLock() (*os.File, error) { + homeDir := GetWaveHomeDir() err := ensureDir(homeDir) if err != nil { - return nil, fmt.Errorf("cannot find/create PROMPT_HOME directory %q", homeDir) + return nil, fmt.Errorf("cannot find/create WAVETERM_HOME directory %q", homeDir) } - lockFileName := path.Join(homeDir, PromptLockFile) + lockFileName := path.Join(homeDir, WaveLockFile) fd, err := os.Create(lockFileName) if err != nil { return nil, err @@ -182,7 +182,7 @@ func EnsureSessionDir(sessionId string) (string, error) { if ok { return sdir, nil } - scHome := GetPromptHomeDir() + scHome := GetWaveHomeDir() sdir = path.Join(scHome, SessionsDirBaseName, sessionId) err := ensureDir(sdir) if err != nil { @@ -196,8 +196,8 @@ func EnsureSessionDir(sessionId string) (string, error) { // deprecated (v0.1.8) func GetSessionsDir() string { - promptHome := GetPromptHomeDir() - sdir := path.Join(promptHome, SessionsDirBaseName) + waveHome := GetWaveHomeDir() + sdir := path.Join(waveHome, SessionsDirBaseName) return sdir } @@ -211,7 +211,7 @@ func EnsureScreenDir(screenId string) (string, error) { if ok { return sdir, nil } - scHome := GetPromptHomeDir() + scHome := GetWaveHomeDir() sdir = path.Join(scHome, ScreensDirBaseName, screenId) err := ensureDir(sdir) if err != nil { @@ -224,8 +224,8 @@ func EnsureScreenDir(screenId string) (string, error) { } func GetScreensDir() string { - promptHome := GetPromptHomeDir() - sdir := path.Join(promptHome, ScreensDirBaseName) + waveHome := GetWaveHomeDir() + sdir := path.Join(waveHome, ScreensDirBaseName) return sdir } @@ -236,7 +236,7 @@ func ensureDir(dirName string) error { if err != nil { return err } - log.Printf("[prompt] created directory %q\n", dirName) + log.Printf("[wave] created directory %q\n", dirName) info, err = os.Stat(dirName) } if err != nil { @@ -277,7 +277,7 @@ func PtyOutFile(screenId string, lineId string) (string, error) { return fmt.Sprintf("%s/%s.ptyout.cf", sdir, lineId), nil } -func GenPromptUUID() string { +func GenWaveUUID() string { for { rtn := uuid.New().String() _, err := strconv.Atoi(rtn[0:8]) diff --git a/wavesrv/pkg/sstore/dbops.go b/wavesrv/pkg/sstore/dbops.go index 361d74a4..1062dd0e 100644 --- a/wavesrv/pkg/sstore/dbops.go +++ b/wavesrv/pkg/sstore/dbops.go @@ -532,7 +532,7 @@ func GetSessionByName(ctx context.Context, name string) (*SessionType, error) { // if sessionName == "", it will be generated func InsertSessionWithName(ctx context.Context, sessionName string, activate bool) (*ModelUpdate, error) { var newScreen *ScreenType - newSessionId := scbase.GenPromptUUID() + newSessionId := scbase.GenWaveUUID() txErr := WithTx(ctx, func(tx *TxWrap) error { names := tx.SelectStrings(`SELECT name FROM session`) sessionName = fmtUniqueName(sessionName, "workspace-%d", len(names)+1, names) @@ -684,7 +684,7 @@ func InsertScreen(ctx context.Context, sessionId string, origScreenName string, return fmt.Errorf("cannot create screen, base screen not found") } } - newScreenId = scbase.GenPromptUUID() + newScreenId = scbase.GenWaveUUID() screen := &ScreenType{ SessionId: sessionId, ScreenId: newScreenId, @@ -1258,7 +1258,7 @@ func UpdateRemoteState(ctx context.Context, sessionId string, screenId string, r ri = dbutil.GetMapGen[*RemoteInstance](tx, query, sessionId, screenId, remotePtr.OwnerId, remotePtr.RemoteId, remotePtr.Name) if ri == nil { ri = &RemoteInstance{ - RIId: scbase.GenPromptUUID(), + RIId: scbase.GenWaveUUID(), Name: remotePtr.Name, SessionId: sessionId, ScreenId: screenId, @@ -2035,7 +2035,7 @@ func UpdateCurrentActivity(ctx context.Context, update ActivityUpdate) error { if len(tzName) > MaxTzNameLen { tzName = tzName[0:MaxTzNameLen] } - tx.Exec(query, dayStr, tdata, tzName, tzOffset, scbase.PromptVersion, scbase.ClientArch(), scbase.BuildTime, scbase.MacOSRelease()) + tx.Exec(query, dayStr, tdata, tzName, tzOffset, scbase.WaveVersion, scbase.ClientArch(), scbase.BuildTime, scbase.MacOSRelease()) } tdata.NumCommands += update.NumCommands tdata.FgMinutes += update.FgMinutes @@ -2052,7 +2052,7 @@ func UpdateCurrentActivity(ctx context.Context, update ActivityUpdate) error { clientversion = ?, buildtime = ? WHERE day = ?` - tx.Exec(query, tdata, scbase.PromptVersion, scbase.BuildTime, dayStr) + tx.Exec(query, tdata, scbase.WaveVersion, scbase.BuildTime, dayStr) return nil }) if txErr != nil { diff --git a/wavesrv/pkg/sstore/sstore.go b/wavesrv/pkg/sstore/sstore.go index 84c2cc2f..a1421b1d 100644 --- a/wavesrv/pkg/sstore/sstore.go +++ b/wavesrv/pkg/sstore/sstore.go @@ -20,21 +20,21 @@ import ( "sync" "time" + "github.com/google/uuid" + "github.com/jmoiron/sqlx" + "github.com/sawka/txwrap" "github.com/wavetermdev/waveterm/waveshell/pkg/base" "github.com/wavetermdev/waveterm/waveshell/pkg/packet" "github.com/wavetermdev/waveterm/waveshell/pkg/shexec" "github.com/wavetermdev/waveterm/wavesrv/pkg/dbutil" "github.com/wavetermdev/waveterm/wavesrv/pkg/scbase" - "github.com/google/uuid" - "github.com/jmoiron/sqlx" - "github.com/sawka/txwrap" _ "github.com/mattn/go-sqlite3" ) const LineNoHeight = -1 -const DBFileName = "prompt.db" -const DBFileNameBackup = "backup.prompt.db" +const DBFileName = "waveterm.db" +const DBFileNameBackup = "backup.waveterm.db" const MaxWebShareLineCount = 50 const MaxWebShareScreenCount = 3 const MaxLineStateSize = 4 * 1024 // 4k for now, can raise if needed @@ -145,12 +145,12 @@ func lineIdFromCK(ck base.CommandKey) string { } func GetDBName() string { - scHome := scbase.GetPromptHomeDir() + scHome := scbase.GetWaveHomeDir() return path.Join(scHome, DBFileName) } func GetDBBackupName() string { - scHome := scbase.GetPromptHomeDir() + scHome := scbase.GetWaveHomeDir() return path.Join(scHome, DBFileNameBackup) } @@ -1091,7 +1091,7 @@ func makeNewLineText(screenId string, userId string, text string) *LineType { rtn := &LineType{} rtn.ScreenId = screenId rtn.UserId = userId - rtn.LineId = scbase.GenPromptUUID() + rtn.LineId = scbase.GenWaveUUID() rtn.Ts = time.Now().UnixMilli() rtn.LineLocal = true rtn.LineType = LineTypeText @@ -1160,7 +1160,7 @@ func EnsureLocalRemote(ctx context.Context) error { } // create the local remote localRemote := &RemoteType{ - RemoteId: scbase.GenPromptUUID(), + RemoteId: scbase.GenWaveUUID(), RemoteType: RemoteTypeSsh, RemoteAlias: LocalRemoteAlias, RemoteCanonicalName: fmt.Sprintf("%s@%s", user.Username, hostName), @@ -1177,7 +1177,7 @@ func EnsureLocalRemote(ctx context.Context) error { } log.Printf("[db] added local remote '%s', id=%s\n", localRemote.RemoteCanonicalName, localRemote.RemoteId) sudoRemote := &RemoteType{ - RemoteId: scbase.GenPromptUUID(), + RemoteId: scbase.GenWaveUUID(), RemoteType: RemoteTypeSsh, RemoteAlias: "sudo", RemoteCanonicalName: fmt.Sprintf("sudo@%s@%s", user.Username, hostName), diff --git a/wavesrv/scripthaus.md b/wavesrv/scripthaus.md index 2f9ec41c..a3a18227 100644 --- a/wavesrv/scripthaus.md +++ b/wavesrv/scripthaus.md @@ -2,15 +2,15 @@ ```bash # @scripthaus command dump-schema-dev -sqlite3 /Users/mike/prompt-dev/prompt.db .schema > db/schema.sql +sqlite3 ~/.waveterm-dev/waveterm.db .schema > db/schema.sql ``` ```bash # @scripthaus command opendb-dev -sqlite3 /Users/mike/prompt-dev/prompt.db +sqlite3 ~/.waveterm-dev/waveterm.db ``` ```bash # @scripthaus command build -go build -ldflags "-X main.BuildTime=$(date +'%Y%m%d%H%M')" -o bin/local-server ./cmd +go build -ldflags "-X main.BuildTime=$(date +'%Y%m%d%H%M')" -o bin/wavesrv ./cmd ``` diff --git a/webpack/webpack.electron.js b/webpack/webpack.electron.js index 771fd714..e1fcd343 100644 --- a/webpack/webpack.electron.js +++ b/webpack/webpack.electron.js @@ -72,9 +72,9 @@ var electronDev = webpackMerge.merge(electronCommon, { patterns: [{ from: "src/electron/preload.js", to: "preload.js" }], }), new webpack.DefinePlugin({ - __PROMPT_DEV__: "true", - __PROMPT_VERSION__: JSON.stringify(VERSION), - __PROMPT_BUILD__: JSON.stringify("devbuild"), + __WAVETERM_DEV__: "true", + __WAVETERM_VERSION__: JSON.stringify(VERSION), + __WAVETERM_BUILD__: JSON.stringify("devbuild"), }), ], }); @@ -90,9 +90,9 @@ var electronProd = webpackMerge.merge(electronCommon, { patterns: [{ from: "src/electron/preload.js", to: "preload.js" }], }), new webpack.DefinePlugin({ - __PROMPT_DEV__: "false", - __PROMPT_VERSION__: JSON.stringify(VERSION), - __PROMPT_BUILD__: JSON.stringify(BUILD), + __WAVETERM_DEV__: "false", + __WAVETERM_VERSION__: JSON.stringify(VERSION), + __WAVETERM_BUILD__: JSON.stringify(BUILD), }), ], optimization: { diff --git a/webpack/webpack.electron.prod.js b/webpack/webpack.electron.prod.js deleted file mode 100644 index daaea669..00000000 --- a/webpack/webpack.electron.prod.js +++ /dev/null @@ -1,36 +0,0 @@ -const webpack = require("webpack"); -const merge = require("webpack-merge"); -const common = require("./webpack.electron.js"); -const moment = require("dayjs"); -const VERSION = require("../version.js"); -const path = require("path"); - -function makeBuildStr() { - let buildStr = moment().format("YYYYMMDD-HHmmss"); - console.log("Prompt Electron " + VERSION + " build " + buildStr); - return buildStr; -} - -const BUILD = makeBuildStr(); - -let merged = merge.merge(common, { - mode: "production", - output: { - path: path.resolve(__dirname, "../dist"), - filename: "[name].js", - }, - devtool: "source-map", - optimization: { - minimize: true, - }, -}); - -merged.plugins.push( - new webpack.DefinePlugin({ - __PROMPT_DEV__: "false", - __PROMPT_VERSION__: JSON.stringify(VERSION), - __PROMPT_BUILD__: JSON.stringify(BUILD), - }) -); - -module.exports = merged; diff --git a/webpack/webpack.web.js b/webpack/webpack.web.js index c6478a67..dbe7186f 100644 --- a/webpack/webpack.web.js +++ b/webpack/webpack.web.js @@ -69,11 +69,11 @@ var webCommon = { }, { test: /\.md$/, - use: "raw-loader", + type: "asset/source", }, { test: /\.(png|jpe?g|gif)$/i, - use: "file-loader", + type: "asset/resource", }, ], }, @@ -102,9 +102,9 @@ var webDev = webpackMerge.merge(webCommon, { new MiniCssExtractPlugin({ filename: "[name].css", ignoreOrder: true }), new LodashModuleReplacementPlugin(), new webpack.DefinePlugin({ - __PROMPT_DEV__: "true", - __PROMPT_VERSION__: JSON.stringify(VERSION), - __PROMPT_BUILD__: JSON.stringify("devbuild"), + __WAVETERM_DEV__: "true", + __WAVETERM_VERSION__: JSON.stringify(VERSION), + __WAVETERM_BUILD__: JSON.stringify("devbuild"), }), ], watchOptions: { @@ -118,14 +118,14 @@ var webProd = webpackMerge.merge(webCommon, { path: path.resolve(__dirname, "../dist"), filename: "[name].js", }, - devtool: false, + devtool: "source-map", plugins: [ new MiniCssExtractPlugin({ filename: "[name].css", ignoreOrder: true }), new LodashModuleReplacementPlugin(), new webpack.DefinePlugin({ - __PROMPT_DEV__: "false", - __PROMPT_VERSION__: JSON.stringify(VERSION), - __PROMPT_BUILD__: JSON.stringify(BUILD), + __WAVETERM_DEV__: "false", + __WAVETERM_VERSION__: JSON.stringify(VERSION), + __WAVETERM_BUILD__: JSON.stringify(BUILD), }), ], optimization: {