ardent-cli 0.0.21 → 0.0.23
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 +44 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -72,6 +72,32 @@ function getCacheEntry(key) {
|
|
|
72
72
|
const config = loadConfig();
|
|
73
73
|
return config.cache?.[key];
|
|
74
74
|
}
|
|
75
|
+
function formatIdle(lastActivityIso) {
|
|
76
|
+
if (!lastActivityIso) {
|
|
77
|
+
return "unknown";
|
|
78
|
+
}
|
|
79
|
+
const last = new Date(lastActivityIso).getTime();
|
|
80
|
+
if (Number.isNaN(last)) {
|
|
81
|
+
return "unknown";
|
|
82
|
+
}
|
|
83
|
+
const diffMs = Date.now() - last;
|
|
84
|
+
const diffSec = Math.floor(diffMs / 1e3);
|
|
85
|
+
if (diffSec < 60) {
|
|
86
|
+
return "just now";
|
|
87
|
+
}
|
|
88
|
+
const minutes = Math.floor(diffSec / 60);
|
|
89
|
+
if (minutes < 60) {
|
|
90
|
+
return `${minutes}m`;
|
|
91
|
+
}
|
|
92
|
+
const hours = Math.floor(minutes / 60);
|
|
93
|
+
if (hours < 24) {
|
|
94
|
+
const remMinutes = minutes - hours * 60;
|
|
95
|
+
return `${hours}h ${remMinutes}m`;
|
|
96
|
+
}
|
|
97
|
+
const days = Math.floor(hours / 24);
|
|
98
|
+
const remHours = hours - days * 24;
|
|
99
|
+
return `${days}d ${remHours}h`;
|
|
100
|
+
}
|
|
75
101
|
function formatCacheTime(isoString) {
|
|
76
102
|
const date = new Date(isoString);
|
|
77
103
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -404,7 +430,8 @@ async function createAction(name, options) {
|
|
|
404
430
|
service_type: apiBranch.service_type,
|
|
405
431
|
branch_url: apiBranch.branch_url || "",
|
|
406
432
|
status: apiBranch.status,
|
|
407
|
-
created_at: apiBranch.created_at
|
|
433
|
+
created_at: apiBranch.created_at,
|
|
434
|
+
last_branch_activity: apiBranch.last_branch_activity
|
|
408
435
|
};
|
|
409
436
|
const cached = getCacheEntry("branches");
|
|
410
437
|
const cachedBranches = cached?.data || [];
|
|
@@ -431,6 +458,9 @@ ${branch.branch_url}`);
|
|
|
431
458
|
}
|
|
432
459
|
|
|
433
460
|
// src/commands/branch/list.ts
|
|
461
|
+
function formatCreatedDate(createdAtIso) {
|
|
462
|
+
return new Date(createdAtIso).toISOString().slice(0, 10);
|
|
463
|
+
}
|
|
434
464
|
async function listAction() {
|
|
435
465
|
let branches = [];
|
|
436
466
|
let fromCache = false;
|
|
@@ -484,13 +514,16 @@ async function listAction() {
|
|
|
484
514
|
for (const branch of branches) {
|
|
485
515
|
const isCurrent = branch.name === current;
|
|
486
516
|
const icon = branch.status === "active" ? "\u25CF" : "\u25CB";
|
|
517
|
+
const metadataLine = `${branch.service_type} \xB7 created ${formatCreatedDate(branch.created_at)} \xB7 idle ${formatIdle(branch.last_branch_activity)} (${branch.status})`;
|
|
487
518
|
if (isCurrent) {
|
|
488
519
|
console.log(`${green2}* ${icon} ${branch.name}${reset2}`);
|
|
520
|
+
console.log(`${green2} ${metadataLine}${reset2}`);
|
|
489
521
|
if (branch.branch_url) {
|
|
490
522
|
console.log(`${green2} ${branch.branch_url}${reset2}`);
|
|
491
523
|
}
|
|
492
524
|
} else {
|
|
493
525
|
console.log(` ${icon} ${branch.name}`);
|
|
526
|
+
console.log(`${dim2} ${metadataLine}${reset2}`);
|
|
494
527
|
if (branch.branch_url) {
|
|
495
528
|
console.log(`${dim2} ${branch.branch_url}${reset2}`);
|
|
496
529
|
}
|
|
@@ -1037,19 +1070,27 @@ async function listAction2() {
|
|
|
1037
1070
|
const dim2 = "\x1B[2m";
|
|
1038
1071
|
const yellow = "\x1B[33m";
|
|
1039
1072
|
const reset2 = "\x1B[0m";
|
|
1073
|
+
const red = "\x1B[31m";
|
|
1040
1074
|
console.log("Connectors:\n");
|
|
1041
1075
|
for (const connector of connectors) {
|
|
1042
1076
|
const isCurrent = connector.id === currentConnectorId;
|
|
1043
1077
|
const icon = connector.status === "healthy" ? "\u25CF" : "\u25CB";
|
|
1044
1078
|
const warnings = connector.warnings ?? [];
|
|
1045
1079
|
const warningSuffix = warnings.length > 0 ? ` ${yellow}\u26A0 ${warnings.length}${reset2}` : "";
|
|
1080
|
+
const statusSuffix = connector.status === "healthy" ? "" : ` ${red}[${connector.status}]${reset2}`;
|
|
1046
1081
|
if (isCurrent) {
|
|
1047
|
-
console.log(`${green2}* ${icon} ${connector.name}${reset2}${warningSuffix}`);
|
|
1082
|
+
console.log(`${green2}* ${icon} ${connector.name}${reset2}${warningSuffix}${statusSuffix}`);
|
|
1048
1083
|
console.log(`${green2} ${connector.service_name}${reset2}`);
|
|
1049
1084
|
} else {
|
|
1050
|
-
console.log(` ${icon} ${connector.name}${warningSuffix}`);
|
|
1085
|
+
console.log(` ${icon} ${connector.name}${warningSuffix}${statusSuffix}`);
|
|
1051
1086
|
console.log(`${dim2} ${connector.service_name}${reset2}`);
|
|
1052
1087
|
}
|
|
1088
|
+
if (connector.status !== "healthy" && connector.connection_error) {
|
|
1089
|
+
for (const line of connector.connection_error.split("\n")) {
|
|
1090
|
+
if (line.trim().length === 0) continue;
|
|
1091
|
+
console.log(`${red} ${line}${reset2}`);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1053
1094
|
for (const warning of warnings) {
|
|
1054
1095
|
console.log(`${yellow} \u26A0 ${warning}${reset2}`);
|
|
1055
1096
|
}
|