ardent-cli 0.0.22 → 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 +34 -1
- 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
|
}
|