@techninja/clearstack 0.4.32 → 0.4.34
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/watch-ui.js +17 -8
- package/package.json +1 -1
package/lib/watch-ui.js
CHANGED
|
@@ -40,9 +40,11 @@ const rowLine = (r, w) => {
|
|
|
40
40
|
const n = (r.label ?? r.name ?? r.key).padEnd(w);
|
|
41
41
|
const isIdle = r.pass === false && r.keyBinding;
|
|
42
42
|
const name = (!isIdle && r.pass === false) ? `{red-fg}${n}{/}` : n;
|
|
43
|
-
const
|
|
44
|
-
?
|
|
45
|
-
: (r.detail
|
|
43
|
+
const rawDetail = isIdle
|
|
44
|
+
? (r.ranAt ? timeAgo(r.ranAt) : `press ${r.keyBinding} to run`)
|
|
45
|
+
: (r.detail ?? '');
|
|
46
|
+
const isError = r.key === 'server' && /error/i.test(rawDetail);
|
|
47
|
+
const detail = rawDetail ? `{${isError ? 'red' : 'grey'}-fg}${rawDetail}{/}` : '';
|
|
46
48
|
return ` ${rowIcon(r)} ${name} ${detail}`;
|
|
47
49
|
};
|
|
48
50
|
|
|
@@ -51,8 +53,12 @@ const rowLine = (r, w) => {
|
|
|
51
53
|
/** @param {object[]} rows @param {string} lastCheck @param {string[]} watchDirs */
|
|
52
54
|
function statusContent(rows, lastCheck, watchDirs) {
|
|
53
55
|
const w = Math.max(...rows.map((r) => (r.label ?? r.name ?? r.key).length));
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
const server = rows.filter((r) => r.key === 'server');
|
|
57
|
+
const failing = rows.filter((r) => r.key !== 'server' && r.pass === false);
|
|
58
|
+
const rest = rows.filter((r) => r.key !== 'server' && r.pass !== false);
|
|
59
|
+
const sorted = [...server, ...failing, ...rest];
|
|
60
|
+
const footer = `{grey-fg} watching ${watchDirs.join(', ')} last check: ${lastCheck}{/}${getCopyNote()}`;
|
|
61
|
+
return [...sorted.map((r) => rowLine(r, w)), '', footer];
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
// ── Public API ────────────────────────────────────────────────────────────────
|
|
@@ -66,10 +72,13 @@ function statusContent(rows, lastCheck, watchDirs) {
|
|
|
66
72
|
*/
|
|
67
73
|
export function render(rows, lastCheck, watchDirs, violations) {
|
|
68
74
|
const lines = statusContent(rows, lastCheck, watchDirs);
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
const termH = (screen.height ?? 24) - 2; // subtract outer border
|
|
76
|
+
const maxStatus = Math.max(1, termH - (violations.length ? Math.floor(termH / 2) : 0));
|
|
77
|
+
const visible = lines.slice(0, maxStatus);
|
|
78
|
+
statusBox.setContent(visible.join('\n'));
|
|
79
|
+
statusBox.height = visible.length;
|
|
71
80
|
|
|
72
|
-
const statusHeight =
|
|
81
|
+
const statusHeight = visible.length + 1;
|
|
73
82
|
divider.top = statusHeight;
|
|
74
83
|
logBox.top = statusHeight + 1;
|
|
75
84
|
|
package/package.json
CHANGED