@olenbetong/appframe-vite 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +0 -3
- package/lib/proxy.js +17 -6
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import bodyParser from "body-parser";
|
|
|
2
2
|
import { watch } from "chokidar";
|
|
3
3
|
import { addAppframeBuildConfig } from "./build.js";
|
|
4
4
|
import { createDevMiddleware, getLoginInfo, getProxyRoutes } from "./devServer.js";
|
|
5
|
-
import { importJson } from "./importJson.js";
|
|
6
5
|
import { getLastSession, login } from "./proxy.js";
|
|
7
6
|
let interval;
|
|
8
7
|
let server;
|
|
@@ -11,8 +10,6 @@ try {
|
|
|
11
10
|
let appPkgUrl = `file://${process.cwd()}/package.json`;
|
|
12
11
|
watch(appPkgUrl).on("all", async () => {
|
|
13
12
|
if (server) {
|
|
14
|
-
let appPkg = await importJson("./package.json", true);
|
|
15
|
-
let config = appPkg.appframe;
|
|
16
13
|
let { hostname } = await getLoginInfo();
|
|
17
14
|
if (lastHostname !== hostname) {
|
|
18
15
|
server.restart(false);
|
package/lib/proxy.js
CHANGED
|
@@ -2,6 +2,15 @@ import chalk from "chalk";
|
|
|
2
2
|
import https from "node:https";
|
|
3
3
|
const lastLogin = new Map();
|
|
4
4
|
let currentLogin = null;
|
|
5
|
+
const isInteractive = process.stdout.isTTY;
|
|
6
|
+
function write(text) {
|
|
7
|
+
if (isInteractive) {
|
|
8
|
+
process.stdout.write?.(text);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
console.log(text);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
5
14
|
export function getLastSession(hostname) {
|
|
6
15
|
return lastLogin.get(hostname);
|
|
7
16
|
}
|
|
@@ -17,7 +26,7 @@ export async function login(hostname, username, password) {
|
|
|
17
26
|
return;
|
|
18
27
|
}
|
|
19
28
|
else {
|
|
20
|
-
|
|
29
|
+
write(`${chalk.bgBlueBright(hostname)}: Renewing authentication cookies...`);
|
|
21
30
|
lastLogin.delete(hostname);
|
|
22
31
|
}
|
|
23
32
|
}
|
|
@@ -33,11 +42,13 @@ export async function login(hostname, username, password) {
|
|
|
33
42
|
"Content-Length": data.length,
|
|
34
43
|
},
|
|
35
44
|
};
|
|
36
|
-
process.stdout.clearLine(0);
|
|
37
|
-
|
|
45
|
+
process.stdout.clearLine?.(0);
|
|
46
|
+
write(`\r${chalk.bgBlueBright(hostname)}: Authenticating`);
|
|
38
47
|
let start = performance.now();
|
|
39
48
|
let interval = setInterval(() => {
|
|
40
|
-
|
|
49
|
+
if (isInteractive) {
|
|
50
|
+
write(`.`);
|
|
51
|
+
}
|
|
41
52
|
}, 100);
|
|
42
53
|
let request = https.request(options, (response) => {
|
|
43
54
|
clearInterval(interval);
|
|
@@ -52,8 +63,8 @@ export async function login(hostname, username, password) {
|
|
|
52
63
|
cookieObj[key] = value;
|
|
53
64
|
}
|
|
54
65
|
}
|
|
55
|
-
process.stdout.clearLine(0);
|
|
56
|
-
|
|
66
|
+
process.stdout.clearLine?.(0);
|
|
67
|
+
write(`${chalk.bgBlueBright(hostname)}: Authenticated (${Math.floor(performance.now() - start)}ms)\n`);
|
|
57
68
|
lastLogin.set(hostname, {
|
|
58
69
|
timestamp: Date.now(),
|
|
59
70
|
authCookies: cookieObj,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olenbetong/appframe-vite",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Tools to use and deploy Vite applications to Appframe",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"author": "Bjørnar Vister Hansen <bvh@olenbetong.no>",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@olenbetong/appframe-data": "^0.
|
|
22
|
+
"@olenbetong/appframe-data": "^0.9.0",
|
|
23
23
|
"chalk": "^5.3.0",
|
|
24
24
|
"chokidar": "^3.5.3",
|
|
25
25
|
"dotenv": "^16.3.1",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"open": "^9.1.0",
|
|
44
44
|
"tcp-port-used": "^1.0.2"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "61bcfff5dd6ef273708619b792fe9b8ece68c5d3"
|
|
47
47
|
}
|