trx 1.2.0 → 1.4.0

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/package.json +1 -1
  2. package/trx.js +25 -36
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trx",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "Professional terminal command tracer",
5
5
  "main": "trx.js",
6
6
  "bin": {
package/trx.js CHANGED
@@ -32,10 +32,22 @@ const C = useColor ? {
32
32
  "PROC","OUT","ERR","TIME","OK","FAIL"].map(k => [k, ""])
33
33
  );
34
34
 
35
- /* ─────────────── UTILS ─────────────── */
36
-
37
- const now = () =>
38
- new Date().toISOString().split("T")[1].replace("Z", "");
35
+ /* ─────────────── TIME ─────────────── */
36
+
37
+ function now() {
38
+ const d = new Date();
39
+ const date = d.toLocaleDateString("en-GB", {
40
+ day: "numeric",
41
+ month: "short",
42
+ year: "numeric"
43
+ });
44
+ const time = d.toLocaleTimeString("en-US", {
45
+ hour: "numeric",
46
+ minute: "2-digit",
47
+ hour12: true
48
+ });
49
+ return `${date}, ${time}`;
50
+ }
39
51
 
40
52
  function formatElapsed(sec) {
41
53
  if (sec < 60) return `${sec}s`;
@@ -44,9 +56,11 @@ function formatElapsed(sec) {
44
56
  return `${m}m ${s}s`;
45
57
  }
46
58
 
59
+ /* ─────────────── UI ─────────────── */
60
+
47
61
  function banner(cmd) {
48
62
  console.log(`
49
- ${C.cyan}${C.bold}┌─[ TERMTTRACE ]────────────────────────────────────────┐${C.reset}
63
+ ${C.cyan}${C.bold}┌─[ TRX ]────────────────────────────────────────┐${C.reset}
50
64
  ${C.cyan}│${C.reset} ${C.gray}Command:${C.reset} ${C.bold}${cmd}${C.reset}
51
65
  ${C.cyan}└────────────────────────────────────────────────────────┘${C.reset}
52
66
  `.trim());
@@ -54,14 +68,7 @@ ${C.cyan}└──────────────────────
54
68
 
55
69
  function log(type, icon, message) {
56
70
  clearSpinner();
57
- console.log(
58
- `${C.dim}[${now()}]${C.reset} ${C[type]}${icon} ${message}${C.reset}`
59
- );
60
- }
61
-
62
- function die(msg) {
63
- console.error(`${C.FAIL}${msg}${C.reset}`);
64
- process.exit(1);
71
+ console.log(`${C.dim}[${now()}]${C.reset} ${C[type]}${icon} ${message}${C.reset}`);
65
72
  }
66
73
 
67
74
  /* ─────────────── SPINNER ─────────────── */
@@ -77,10 +84,7 @@ function startSpinner() {
77
84
  const elapsedSec = Math.floor((Date.now() - startTime) / 1000);
78
85
  const frame = frames[spinnerIndex++ % frames.length];
79
86
  const time = formatElapsed(elapsedSec);
80
-
81
- process.stdout.write(
82
- `\r${C.cyan}${frame}${C.reset} ${C.gray}running…${C.reset} ${C.magenta}${time}${C.reset} `
83
- );
87
+ process.stdout.write(`\r${C.cyan}${frame}${C.reset} ${C.gray}running…${C.reset} ${C.magenta}${time}${C.reset} `);
84
88
  }, 120);
85
89
  }
86
90
 
@@ -96,7 +100,8 @@ function clearSpinner() {
96
100
 
97
101
  const args = process.argv.slice(2);
98
102
  if (!args.length) {
99
- die("Usage: termtrace <command> [args...]");
103
+ console.error(`${C.FAIL}Usage: trx <command> [args...]${C.reset}`);
104
+ process.exit(1);
100
105
  }
101
106
 
102
107
  const command = args.join(" ");
@@ -108,30 +113,14 @@ log("PROC", "⚡", "process spawned");
108
113
 
109
114
  startSpinner();
110
115
 
116
+ // Use full inherit for interactive commands like npm publish/login
111
117
  const child = spawn(command, {
112
- stdio: ["inherit", "pipe", "pipe"],
118
+ stdio: "inherit",
113
119
  shell: true
114
120
  });
115
121
 
116
- child.stdout.on("data", (data) => {
117
- data
118
- .toString()
119
- .split("\n")
120
- .filter(Boolean)
121
- .forEach(line => log("OUT", "›", line));
122
- });
123
-
124
- child.stderr.on("data", (data) => {
125
- data
126
- .toString()
127
- .split("\n")
128
- .filter(Boolean)
129
- .forEach(line => log("ERR", "✖", line));
130
- });
131
-
132
122
  child.on("exit", (code, signal) => {
133
123
  clearSpinner();
134
-
135
124
  const elapsedSec = Math.floor((Date.now() - startTime) / 1000);
136
125
  const elapsed = formatElapsed(elapsedSec);
137
126