fastclaw-cli 0.3.2 → 0.3.3
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/dist/index.js +30 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -899,6 +899,30 @@ function registerBotCrudCommands(bot) {
|
|
|
899
899
|
|
|
900
900
|
// src/commands/bot/lifecycle.ts
|
|
901
901
|
import chalk6 from "chalk";
|
|
902
|
+
function formatCpu(v) {
|
|
903
|
+
if (v.endsWith("n")) {
|
|
904
|
+
const n = parseInt(v, 10);
|
|
905
|
+
const millis = Math.round(n / 1e6);
|
|
906
|
+
if (millis < 1e3) return `${millis}m`;
|
|
907
|
+
return `${(millis / 1e3).toFixed(1)}`;
|
|
908
|
+
}
|
|
909
|
+
return v;
|
|
910
|
+
}
|
|
911
|
+
function formatMem(v) {
|
|
912
|
+
if (v.endsWith("Ki")) {
|
|
913
|
+
const ki = parseInt(v, 10);
|
|
914
|
+
if (ki < 1024) return `${ki}Ki`;
|
|
915
|
+
if (ki < 1024 * 1024) return `${Math.round(ki / 1024)}Mi`;
|
|
916
|
+
return `${(ki / 1024 / 1024).toFixed(1)}Gi`;
|
|
917
|
+
}
|
|
918
|
+
return v;
|
|
919
|
+
}
|
|
920
|
+
function fmtCpu(v) {
|
|
921
|
+
return v ? formatCpu(v) : "-";
|
|
922
|
+
}
|
|
923
|
+
function fmtMem(v) {
|
|
924
|
+
return v ? formatMem(v) : "-";
|
|
925
|
+
}
|
|
902
926
|
function buildBotUrls(baseUrl, slug, accessToken) {
|
|
903
927
|
const { hostname } = new URL(baseUrl);
|
|
904
928
|
const webchatUrl = `https://${slug}.${hostname}#token=${accessToken}`;
|
|
@@ -1012,12 +1036,12 @@ function registerBotLifecycleCommands(bot) {
|
|
|
1012
1036
|
const headers = ["Container", "CPU Req", "CPU Limit", "CPU Usage", "Mem Req", "Mem Limit", "Mem Usage"];
|
|
1013
1037
|
const rows = Object.entries(res.containers).map(([name, c]) => [
|
|
1014
1038
|
name,
|
|
1015
|
-
c.requests?.cpu
|
|
1016
|
-
c.limits?.cpu
|
|
1017
|
-
c.usage?.cpu
|
|
1018
|
-
c.requests?.memory
|
|
1019
|
-
c.limits?.memory
|
|
1020
|
-
c.usage?.memory
|
|
1039
|
+
fmtCpu(c.requests?.cpu),
|
|
1040
|
+
fmtCpu(c.limits?.cpu),
|
|
1041
|
+
fmtCpu(c.usage?.cpu),
|
|
1042
|
+
fmtMem(c.requests?.memory),
|
|
1043
|
+
fmtMem(c.limits?.memory),
|
|
1044
|
+
fmtMem(c.usage?.memory)
|
|
1021
1045
|
]);
|
|
1022
1046
|
printTable(headers, rows);
|
|
1023
1047
|
}
|