bug fixes and updates to get prod version of webshare working

This commit is contained in:
sawka 2023-04-05 15:11:37 -07:00
parent 96640bf761
commit f9544546fc
6 changed files with 68 additions and 3 deletions

View File

@ -55,6 +55,12 @@ node_modules/.bin/webpack-dev-server --config webpack.share.dev.js --host 127.0.
node_modules/.bin/webpack --config webpack.share.dev.js
```
```bash
# @scripthaus command webshare-build-prod
# @scripthaus cd :playbook
node_modules/.bin/webpack --config webpack.share.prod.js
```
```bash
# @scripthaus command typecheck
# @scripthaus cd :playbook
@ -135,3 +141,11 @@ rm *.dmg
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'
```

View File

@ -285,7 +285,7 @@ class Screen {
if (GlobalModel.isDev) {
return sprintf("http://devtest.getprompt.com:9001/static/index-dev.html?screenid=%s&viewkey=%s", this.screenId, viewKey);
}
return sprintf("https://share.getprompt.dev/s/%s?viewkey=%s", this.screenId, viewKey);
return sprintf("https://share.getprompt.dev/share/%s?viewkey=%s", this.screenId, viewKey);
}
mergeData(data : ScreenDataType) {

View File

@ -9,6 +9,12 @@ import * as util from "./util";
import {windowWidthToCols, windowHeightToRows, termWidthFromCols, termHeightFromRows} from "./textmeasure";
import {WebShareWSControl} from "./webshare-ws";
let PROMPT_DEV = __PROMPT_DEV__;
let PROMPT_VERSION = __PROMPT_VERSION__;
let PROMPT_BULILD = __PROMPT_BUILD__;
let PROMPT_API_ENDPOINT = __PROMPT_API_ENDPOINT__;
let PROMPT_WSAPI_ENDPOINT = __PROMPT_WSAPI_ENDPOINT__;
type OV<V> = mobx.IObservableValue<V>;
type OArr<V> = mobx.IObservableArray<V>;
type OMap<K,V> = mobx.ObservableMap<K,V>;
@ -23,11 +29,11 @@ function isBlank(s : string) {
}
function getBaseUrl() {
return "https://ot2e112zx5.execute-api.us-west-2.amazonaws.com/dev";
return PROMPT_API_ENDPOINT;
}
function getBaseWSUrl() {
return "wss://5lfzlg5crl.execute-api.us-west-2.amazonaws.com/dev";
return PROMPT_WSAPI_ENDPOINT;
}
class WebShareModelClass {
@ -48,6 +54,7 @@ class WebShareModelClass {
remotePtyOffsetMap : Record<string, number> = {};
activeUpdateFetch : boolean = false;
remoteScreenVts : number = 0;
isDev : boolean = PROMPT_DEV;
constructor() {
let pathName = window.location.pathname;

View File

@ -7,6 +7,10 @@ import {loadFonts} from "./util";
import {WebShareModel} from "./webshare-model";
import * as textmeasure from "./textmeasure";
let PROMPT_DEV = __PROMPT_DEV__;
let PROMPT_VERSION = __PROMPT_VERSION__;
let PROMPT_BULILD = __PROMPT_BUILD__;
loadFonts();
document.addEventListener("DOMContentLoaded", () => {
@ -27,3 +31,5 @@ document.addEventListener("DOMContentLoaded", () => {
(window as any).textmeasure = textmeasure;
(window as any).mobx = mobx;
(window as any).sprintf = sprintf;
console.log("PROMPT webshare", PROMPT_VERSION, PROMPT_BUILD);

View File

@ -36,6 +36,8 @@ var definePlugin = new webpack.DefinePlugin({
__PROMPT_DEV__: "true",
__PROMPT_VERSION__: JSON.stringify(VERSION),
__PROMPT_BUILD__: JSON.stringify("devbuild"),
__PROMPT_API_ENDPOINT__: JSON.stringify("https://ot2e112zx5.execute-api.us-west-2.amazonaws.com/dev"),
__PROMPT_WSAPI_ENDPOINT__: JSON.stringify("wss://5lfzlg5crl.execute-api.us-west-2.amazonaws.com/dev"),
});
merged.plugins.push(definePlugin);

36
webpack.share.prod.js Normal file
View File

@ -0,0 +1,36 @@
const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.share.js');
const moment = require("dayjs");
const path = require("path");
const VERSION = require("./version.js");
function makeBuildStr() {
let buildStr = moment().format("YYYYMMDD-HHmmss");
console.log("Prompt " + VERSION + " build " + buildStr);
return buildStr;
}
const BUILD = makeBuildStr();
let merged = merge.merge(common, {
mode: "production",
output: {
path: path.resolve(__dirname, "webshare/dist"),
filename: "[name].js",
},
devtool: false,
optimization: {
minimize: true,
},
});
merged.plugins.push(new webpack.DefinePlugin({
__PROMPT_DEV__: "false",
__PROMPT_VERSION__: JSON.stringify(VERSION),
__PROMPT_BUILD__: JSON.stringify(BUILD),
__PROMPT_API_ENDPOINT__: JSON.stringify("https://share.getprompt.dev/api"),
__PROMPT_WSAPI_ENDPOINT__: JSON.stringify("wss://wsapi.getprompt.dev"),
}));
module.exports = merged;