numux 2.4.0 → 2.5.1

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.
Files changed (2) hide show
  1. package/dist/numux.js +29 -10
  2. package/package.json +1 -1
package/dist/numux.js CHANGED
@@ -36,7 +36,7 @@ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports,
36
36
  var require_package = __commonJS((exports, module) => {
37
37
  module.exports = {
38
38
  name: "numux",
39
- version: "2.4.0",
39
+ version: "2.5.1",
40
40
  description: "Terminal multiplexer with dependency orchestration",
41
41
  type: "module",
42
42
  license: "MIT",
@@ -2053,7 +2053,7 @@ class ProcessManager {
2053
2053
  }
2054
2054
  this.restartAttempts.set(name, 0);
2055
2055
  state.exitCode = null;
2056
- state.restartCount++;
2056
+ state.restartCount = 0;
2057
2057
  this.startTimes.set(name, Date.now());
2058
2058
  const { command, env } = this.expandDependencyCaptures(name);
2059
2059
  runner.restart(cols, rows, command, env);
@@ -2092,7 +2092,7 @@ class ProcessManager {
2092
2092
  }
2093
2093
  this.restartAttempts.set(name, 0);
2094
2094
  state.exitCode = null;
2095
- state.restartCount++;
2095
+ state.restartCount = 0;
2096
2096
  this.startTimes.set(name, Date.now());
2097
2097
  const { command, env } = this.expandDependencyCaptures(name);
2098
2098
  this.runners.get(name)?.restart(cols, rows, command, env);
@@ -3369,6 +3369,7 @@ class PrefixDisplay {
3369
3369
  timestampFormat;
3370
3370
  stopping = false;
3371
3371
  startTime = 0;
3372
+ processTimes = new Map;
3372
3373
  constructor(manager, config, options = {}) {
3373
3374
  this.manager = manager;
3374
3375
  this.logWriter = options.logWriter;
@@ -3442,7 +3443,17 @@ class PrefixDisplay {
3442
3443
  this.printLine(name, lastCr === -1 ? line : line.slice(lastCr + 1));
3443
3444
  }
3444
3445
  }
3445
- handleStatus(_name, _status) {}
3446
+ handleStatus(name, status) {
3447
+ if (status === "running" || status === "starting") {
3448
+ if (!this.processTimes.has(name)) {
3449
+ this.processTimes.set(name, { start: Date.now() });
3450
+ }
3451
+ } else if (status === "finished" || status === "failed" || status === "stopped") {
3452
+ const t = this.processTimes.get(name);
3453
+ if (t && !t.end)
3454
+ t.end = Date.now();
3455
+ }
3456
+ }
3446
3457
  printLine(name, line) {
3447
3458
  const fmt = this.timestampFormat;
3448
3459
  const ts = fmt ? `${DIM}[${formatTimestamp(new Date, fmt)}]${RESET} ` : "";
@@ -3495,8 +3506,7 @@ class PrefixDisplay {
3495
3506
  process.exit(code === 0 ? 0 : 1);
3496
3507
  });
3497
3508
  }
3498
- formatElapsed() {
3499
- const ms = Date.now() - this.startTime;
3509
+ formatDuration(ms) {
3500
3510
  if (ms < 1000)
3501
3511
  return `${ms}ms`;
3502
3512
  const s = ms / 1000;
@@ -3506,21 +3516,30 @@ class PrefixDisplay {
3506
3516
  const rem = s % 60;
3507
3517
  return `${m}m ${rem.toFixed(0)}s`;
3508
3518
  }
3519
+ formatElapsed() {
3520
+ return this.formatDuration(Date.now() - this.startTime);
3521
+ }
3509
3522
  printSummary() {
3510
3523
  const states = this.manager.getAllStates();
3511
3524
  const namePad = Math.max(...states.map((s) => s.name.length));
3525
+ const statusPad = Math.max(...states.map((s) => s.status.length));
3512
3526
  process.stdout.write(`
3513
3527
  `);
3514
3528
  for (const s of states) {
3515
3529
  const name = s.name.padEnd(namePad);
3516
- const exitStr = s.exitCode !== null ? `exit ${s.exitCode}` : "";
3530
+ const exitStr = s.exitCode !== null ? `(exit ${s.exitCode})` : "";
3531
+ const t = this.processTimes.get(s.name);
3532
+ const duration = t ? this.formatDuration((t.end ?? Date.now()) - t.start) : "";
3517
3533
  if (this.noColor) {
3518
- process.stdout.write(` ${name} ${s.status}${exitStr ? ` (${exitStr})` : ""}
3534
+ const status = s.status.padEnd(statusPad);
3535
+ process.stdout.write(` ${name} ${status} ${exitStr.padEnd(9)} ${duration}
3519
3536
  `);
3520
3537
  } else {
3521
3538
  const ansi = STATUS_ANSI[s.status] ?? "";
3522
- const statusText = ansi ? `${ansi}${s.status}${RESET}` : s.status;
3523
- process.stdout.write(` ${name} ${statusText}${exitStr ? ` ${DIM}(${exitStr})${RESET}` : ""}
3539
+ const statusPlain = s.status.padEnd(statusPad);
3540
+ const statusText = ansi ? `${ansi}${statusPlain}${RESET}` : statusPlain;
3541
+ const exitPart = exitStr ? `${DIM}${exitStr.padEnd(9)}${RESET}` : " ".repeat(9);
3542
+ process.stdout.write(` ${name} ${statusText} ${exitPart} ${DIM}${duration}${RESET}
3524
3543
  `);
3525
3544
  }
3526
3545
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "numux",
3
- "version": "2.4.0",
3
+ "version": "2.5.1",
4
4
  "description": "Terminal multiplexer with dependency orchestration",
5
5
  "type": "module",
6
6
  "license": "MIT",