tr200 2.0.1 → 2.0.3

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/README.md CHANGED
@@ -80,45 +80,55 @@ If your system is different, things might break. Look up the offending line and
80
80
  npm install -g tr200
81
81
  ```
82
82
 
83
- **That's it!** Now you can run:
84
-
83
+ **Run on-demand:**
85
84
  ```bash
86
85
  tr200
87
86
  # or
88
87
  report
89
88
  ```
90
89
 
91
- **Requirements:**
92
- - Node.js 14.0.0 or later
93
- - bash (Linux/macOS) or PowerShell (Windows)
90
+ **Set up auto-run on terminal startup:**
91
+ ```bash
92
+ tr200 --install
93
+ ```
94
+
95
+ **Remove auto-run:**
96
+ ```bash
97
+ tr200 --uninstall
98
+ ```
99
+
100
+ **Completely uninstall:**
101
+ ```bash
102
+ tr200 --uninstall
103
+ npm uninstall -g tr200
104
+ ```
94
105
 
95
- **What this does:**
96
- - Downloads the TR-200 package from npm
97
- - Creates global `tr200` and `report` commands
98
- - Automatically detects your OS and runs the appropriate script
106
+ **Requirements:** Node.js 14.0.0 or later
107
+
108
+ ---
99
109
 
100
- **Note:** The npm version is for on-demand use. If you want TR-200 to auto-run on terminal startup, use one of the install scripts below instead.
110
+ ## Quick Reference
111
+
112
+ | Command | Description |
113
+ |---------|-------------|
114
+ | `tr200` | Run the machine report |
115
+ | `tr200 --help` | Show help |
116
+ | `tr200 --version` | Show version |
117
+ | `tr200 --install` | Set up auto-run on terminal startup |
118
+ | `tr200 --uninstall` | Remove auto-run configuration |
101
119
 
102
120
  ---
103
121
 
104
- ## ⚡ Super Quick Install (install.sh)
122
+ ## ⚡ Alternative: install.sh (No Node.js Required)
105
123
 
106
- **Simplest method - fully automated!**
124
+ **For users without Node.js:**
107
125
 
108
126
  ```bash
109
127
  cd ~/git-projects && gh repo clone RealEmmettS/usgc-machine-report && \
110
128
  cd RealEmmettS-usgc-machine-report && ./install.sh
111
129
  ```
112
130
 
113
- The `install.sh` script handles everything:
114
- - Detects your OS and architecture
115
- - Installs dependencies (lastlog2)
116
- - Backs up existing installations
117
- - Copies and configures the script
118
- - Tests everything works
119
- - Sets up the `report` alias
120
-
121
- **That's it! Type `report` or open a new terminal to see it in action.**
131
+ The `install.sh` script handles everything: OS detection, dependency installation, backup, configuration, and auto-run setup.
122
132
 
123
133
  ---
124
134
 
@@ -146,194 +156,16 @@ The script creates `dist/tr-200-machine-report.zip` containing the launchers, `m
146
156
 
147
157
  ---
148
158
 
149
- ## 🤖 Claude Code Automated Installation
150
-
151
- **Best for:** Using with [Claude Code](https://claude.ai/code) AI assistant
159
+ ## 🤖 Claude Code Installation
152
160
 
153
161
  Ask Claude Code:
154
162
 
155
163
  ```
156
- Install usgc-machine-report from RealEmmettS/usgc-machine-report using install.sh
157
- ```
158
-
159
- Or provide these specific instructions:
160
-
161
- ```bash
162
- cd ~/git-projects && \
163
- gh repo clone RealEmmettS/usgc-machine-report && \
164
- cd RealEmmettS-usgc-machine-report && \
165
- ./install.sh
166
- ```
167
-
168
- Claude Code will automatically:
169
- 1. Clone this repository
170
- 2. Install `lastlog2` if on Debian/Raspberry Pi OS
171
- 3. Copy script to `~/.machine_report.sh`
172
- 4. Add to `.bashrc` with automatic run on login
173
- 5. Create convenient `report` alias
174
-
175
- **Or provide these specific instructions to Claude Code:**
176
-
177
- ```bash
178
- # 1. Clone the repository
179
- cd ~/git-projects
180
- gh repo clone RealEmmettS/usgc-machine-report
181
-
182
- # 2. Install dependencies (Debian/Ubuntu/Raspberry Pi OS)
183
- sudo apt install -y lastlog2
184
-
185
- # 3. Install the script
186
- cp ~/git-projects/RealEmmettS-usgc-machine-report/machine_report.sh ~/.machine_report.sh
187
- chmod +x ~/.machine_report.sh
188
-
189
- # 4. Add to .bashrc
190
- cat >> ~/.bashrc << 'EOF'
191
-
192
- # Machine Report alias - run anytime with 'report' command
193
- alias report='~/.machine_report.sh'
194
-
195
- # Run Machine Report only when in interactive mode
196
- if [[ $- == *i* ]]; then
197
- ~/.machine_report.sh
198
- fi
199
- EOF
200
-
201
- # 5. Test installation
202
- ~/.machine_report.sh
164
+ npm install -g tr200 && tr200 --install
203
165
  ```
204
166
 
205
167
  ---
206
168
 
207
- ## 🍎 macOS Installation
208
-
209
- **Requirements:**
210
- - macOS 10.13 (High Sierra) or later
211
- - Bash 4.0+ recommended (install via `brew install bash`)
212
-
213
- **Quick Install:**
214
-
215
- ```bash
216
- cd ~/git-projects && gh repo clone RealEmmettS/usgc-machine-report && \
217
- cd RealEmmettS-usgc-machine-report && ./install.sh
218
- ```
219
-
220
- **What works on macOS:**
221
- - ✅ OS version detection (via `sw_vers`)
222
- - ✅ CPU info (via `sysctl`)
223
- - ✅ Memory usage (via `vm_stat`)
224
- - ✅ Disk usage (via `df`)
225
- - ✅ Network info (via `scutil`)
226
- - ✅ System uptime (calculated from boot time)
227
- - ⚠️ Last login may show "unavailable" (macOS limitation)
228
-
229
- **macOS-Specific Notes:**
230
- - No package installation needed - uses built-in commands
231
- - Default Bash 3.2 works but Bash 4+ recommended
232
- - To install newer Bash: `brew install bash`
233
- - Script automatically detects macOS and uses appropriate commands
234
-
235
- ### 🐚 zsh Installation (macOS Default Shell)
236
-
237
- **Modern macOS (Catalina 10.15+) uses zsh by default**, not bash. If you're using zsh, follow these instructions:
238
-
239
- **Quick Install for zsh:**
240
-
241
- ```bash
242
- # Clone and install the script
243
- cd ~/Downloads && git clone https://github.com/RealEmmettS/usgc-machine-report.git && \
244
- cp ~/Downloads/usgc-machine-report/machine_report.sh ~/.machine_report.sh && \
245
- chmod +x ~/.machine_report.sh
246
-
247
- # Add to .zshrc (not .bashrc!)
248
- cat >> ~/.zshrc << 'EOF'
249
-
250
- # Machine Report alias - run anytime with 'report' command
251
- alias report='~/.machine_report.sh'
252
-
253
- # Run Machine Report only when in interactive mode
254
- if [[ $- == *i* ]]; then
255
- ~/.machine_report.sh
256
- fi
257
- EOF
258
-
259
- # Clean up cloned repo (optional)
260
- rm -rf ~/Downloads/usgc-machine-report
261
-
262
- echo "✅ Installation complete! Open a new terminal or type: source ~/.zshrc"
263
- ```
264
-
265
- **Important zsh Notes:**
266
- - ✅ Use `~/.zshrc` instead of `~/.bashrc`
267
- - ✅ The script works identically in zsh - no code changes needed
268
- - ✅ Test with: `zsh -c "source ~/.zshrc && report"`
269
- - ℹ️ To check your shell: `echo $SHELL` (should show `/bin/zsh`)
270
-
271
- ---
272
-
273
- ## 📦 Quick Install (Manual - Raspberry Pi OS / Debian)
274
-
275
- **One-liner installation:**
276
-
277
- ```bash
278
- cd ~/git-projects && gh repo clone RealEmmettS/usgc-machine-report && \
279
- sudo apt install -y lastlog2 && \
280
- cp ~/git-projects/RealEmmettS-usgc-machine-report/machine_report.sh ~/.machine_report.sh && \
281
- chmod +x ~/.machine_report.sh && \
282
- cat >> ~/.bashrc << 'EOF'
283
-
284
- # Machine Report alias - run anytime with 'report' command
285
- alias report='~/.machine_report.sh'
286
-
287
- # Run Machine Report only when in interactive mode
288
- if [[ $- == *i* ]]; then
289
- ~/.machine_report.sh
290
- fi
291
- EOF
292
- echo "✅ Installation complete! Type 'report' or open a new terminal."
293
- ```
294
-
295
- **Step-by-step installation:**
296
-
297
- 1. **Clone the repository**:
298
- ```bash
299
- cd ~/git-projects
300
- gh repo clone RealEmmettS/usgc-machine-report
301
- ```
302
-
303
- 2. **Install dependencies** (for modern Debian/Raspberry Pi OS):
304
- ```bash
305
- sudo apt install -y lastlog2
306
- ```
307
-
308
- *Note: On systems with the legacy `lastlog` command, this step is optional. The script automatically detects and uses whichever is available.*
309
-
310
- 3. **Copy the script to your home directory**:
311
- ```bash
312
- cp ~/git-projects/RealEmmettS-usgc-machine-report/machine_report.sh ~/.machine_report.sh
313
- chmod +x ~/.machine_report.sh
314
- ```
315
-
316
- 4. **Add to `.bashrc` for automatic display on login**:
317
- ```bash
318
- cat >> ~/.bashrc << 'EOF'
319
-
320
- # Machine Report alias - run anytime with 'report' command
321
- alias report='~/.machine_report.sh'
322
-
323
- # Run Machine Report only when in interactive mode
324
- if [[ $- == *i* ]]; then
325
- ~/.machine_report.sh
326
- fi
327
- EOF
328
- ```
329
-
330
- 5. **Test the installation**:
331
- ```bash
332
- ~/.machine_report.sh
333
- ```
334
-
335
- ---
336
-
337
169
  ## 🛠️ Manual Installation (Advanced)
338
170
 
339
171
  For login sessions over ssh, reference the script `~/.machine_report.sh` in your `.bashrc` file. Make sure the script is executable by running `chmod +x ~/.machine_report.sh`.
@@ -432,6 +264,24 @@ For ZFS systems, edit:
432
264
 
433
265
  ## 📝 Changelog (Fork-specific)
434
266
 
267
+ ### v2.0.1 (2026-01-30) - **INSTALL FLAGS + PS 5.1 FIXES**
268
+ **New CLI Flags + PowerShell Compatibility**
269
+
270
+ - ✨ **`--install` flag**: Set up auto-run on terminal startup via npm
271
+ - ✨ **`--uninstall` flag**: Remove auto-run configuration cleanly
272
+ - ✨ **`--help` flag**: Show usage information (all scripts)
273
+ - ✨ **`--version` flag**: Show version information (all scripts)
274
+ - 🔧 **PowerShell 5.1 compatibility**: Fixed `[System.Net.Dns]::GetHostName()` and null-conditional operators
275
+ - 📚 **Simplified README**: npm + `--install` promoted as primary installation method
276
+
277
+ **Upgrade path:**
278
+ ```bash
279
+ npm update -g tr200
280
+ tr200 --install # Re-run to update shell config if needed
281
+ ```
282
+
283
+ ---
284
+
435
285
  ### v2.0.0 (2026-01-30) - **SHAUGHV REBRAND + NPM RELEASE**
436
286
  **Complete Rebrand + Auto-Run Enhancements + npm Publishing**
437
287
 
@@ -460,7 +460,9 @@ function Show-TR200Report {
460
460
  }
461
461
 
462
462
  # Total inner width of table (excluding outer borders)
463
- $innerWidth = 2 + $labelWidth + 3 + $dataWidth + 2 # "│ <label> │ <value> │"
463
+ # Row format: "│ <label> │ <value> │" = 1+1+label+1+1+1+data+1+1 = label+data+7
464
+ # Inner width is between outer │ chars: " <label> │ <value> " = label+data+5
465
+ $innerWidth = $labelWidth + $dataWidth + 5
464
466
 
465
467
  # Convert chars to strings for multiplication (PS 5.1 compatibility)
466
468
  $hzLine = [string]$TR200Chars.Horizontal
package/bin/tr200.js CHANGED
@@ -35,6 +35,63 @@ if (Get-Command tr200 -ErrorAction SilentlyContinue) {
35
35
  }
36
36
  `;
37
37
 
38
+ // All patterns to detect (TR-100 and TR-200 variants)
39
+ const ALL_MARKERS = [
40
+ 'TR-200 Machine Report (npm)', // npm-installed
41
+ 'TR-200 Machine Report configuration', // install.sh installed
42
+ 'TR-200 Machine Report - run on login', // .profile/.zprofile
43
+ 'TR-200 Machine Report - run on bash login', // .bash_profile
44
+ 'Run Machine Report only when in interactive mode', // TR-100 (original upstream)
45
+ 'TR-100 Machine Report', // TR-100 header
46
+ '# Machine Report alias', // TR-100 alias marker
47
+ ];
48
+
49
+ // Clean a profile file of ALL TR-100/TR-200 entries
50
+ function cleanProfileFile(filePath) {
51
+ if (!fs.existsSync(filePath)) return false;
52
+
53
+ let content = fs.readFileSync(filePath, 'utf8');
54
+ const originalContent = content;
55
+
56
+ // Check if any markers exist
57
+ const hasMarkers = ALL_MARKERS.some(marker => content.includes(marker));
58
+ if (!hasMarkers && !content.includes('machine_report')) {
59
+ return false;
60
+ }
61
+
62
+ // Remove npm-style TR-200 blocks (Unix)
63
+ content = content.replace(/\n?# TR-200 Machine Report \(npm\) - auto-run\nif command -v tr200 &> \/dev\/null; then\n tr200\nfi\n?/g, '');
64
+
65
+ // Remove npm-style TR-200 blocks (PowerShell)
66
+ content = content.replace(/\n?# TR-200 Machine Report \(npm\) - auto-run\nif \(Get-Command tr200 -ErrorAction SilentlyContinue\) \{\n tr200\n\}\n?/g, '');
67
+
68
+ // Remove install.sh TR-200 blocks (matches the full block including aliases)
69
+ content = content.replace(/\n?# TR-200 Machine Report configuration\nalias report=.*\nalias uninstall=.*\n\n?# Auto-run on interactive (?:bash|zsh) shell.*\nif \[\[.*\]\]; then\n clear\n ~\/.machine_report\.sh\nfi\n?/g, '');
70
+
71
+ // Remove TR-200 login blocks (.profile/.zprofile/.bash_profile)
72
+ content = content.replace(/\n?# TR-200 Machine Report - run on (?:login|bash login).*\nif \[ -x "\$HOME\/.machine_report\.sh" \]; then\n clear\n "\$HOME\/.machine_report\.sh"\nfi\n?/g, '');
73
+
74
+ // Remove TR-100 blocks (original upstream pattern)
75
+ content = content.replace(/\n?# Run Machine Report only when in interactive mode\nif \[\[ \$- == \*i\* \]\]; then\n ~\/.machine_report\.sh\nfi\n?/g, '');
76
+
77
+ // Remove any stray alias lines
78
+ content = content.replace(/\n?alias report=.*machine_report.*\n?/g, '\n');
79
+ content = content.replace(/\n?alias uninstall=.*machine_report.*\n?/g, '\n');
80
+
81
+ // Remove TR-100 alias marker
82
+ content = content.replace(/\n?# Machine Report alias\n?/g, '\n');
83
+
84
+ // Clean up excessive blank lines (more than 2 consecutive)
85
+ content = content.replace(/\n{3,}/g, '\n\n');
86
+ content = content.trim();
87
+
88
+ if (content !== originalContent.trim()) {
89
+ fs.writeFileSync(filePath, content + '\n', 'utf8');
90
+ return true;
91
+ }
92
+ return false;
93
+ }
94
+
38
95
  // Shell profile paths
39
96
  function getProfilePaths() {
40
97
  if (isWindows) {
@@ -70,13 +127,21 @@ function askConfirmation(question) {
70
127
  });
71
128
  }
72
129
 
73
- // Check if config already exists in file
130
+ // Check if npm config already exists in file
74
131
  function hasConfig(filePath) {
75
132
  if (!fs.existsSync(filePath)) return false;
76
133
  const content = fs.readFileSync(filePath, 'utf8');
77
134
  return content.includes(CONFIG_MARKER);
78
135
  }
79
136
 
137
+ // Check if ANY TR-100/TR-200 config exists (for cleanup detection)
138
+ function hasAnyConfig(filePath) {
139
+ if (!fs.existsSync(filePath)) return false;
140
+ const content = fs.readFileSync(filePath, 'utf8');
141
+ return ALL_MARKERS.some(marker => content.includes(marker)) ||
142
+ content.includes('machine_report');
143
+ }
144
+
80
145
  // Install auto-run to shell profiles
81
146
  async function installAutoRun() {
82
147
  const profiles = getProfilePaths();
@@ -94,11 +159,25 @@ async function installAutoRun() {
94
159
  process.exit(0);
95
160
  }
96
161
 
162
+ // First, clean up any existing TR-100/TR-200 configurations
163
+ console.log('Cleaning previous installations...');
164
+ let cleaned = 0;
165
+ for (const profilePath of profiles) {
166
+ if (cleanProfileFile(profilePath)) {
167
+ console.log(` [cleaned] ${profilePath}`);
168
+ cleaned++;
169
+ }
170
+ }
171
+ if (cleaned > 0) {
172
+ console.log(` Cleaned ${cleaned} profile(s)`);
173
+ }
174
+ console.log('');
175
+
97
176
  let installed = 0;
98
177
  let skipped = 0;
99
178
 
100
179
  for (const profilePath of profiles) {
101
- // Check if already configured
180
+ // Check if already configured (with npm marker specifically)
102
181
  if (hasConfig(profilePath)) {
103
182
  console.log(` [skip] ${profilePath} - already configured`);
104
183
  skipped++;
@@ -136,7 +215,7 @@ async function uninstallAutoRun() {
136
215
  const profiles = getProfilePaths();
137
216
 
138
217
  console.log('\nTR-200 Machine Report - Remove Auto-Run\n');
139
- console.log('This will remove the auto-run configuration from your shell profile(s).');
218
+ console.log('This will remove ALL TR-100/TR-200 configurations from your shell profile(s).');
140
219
  console.log('Profile(s) to check:');
141
220
  profiles.forEach(p => console.log(` - ${p}`));
142
221
  console.log('');
@@ -154,27 +233,10 @@ async function uninstallAutoRun() {
154
233
  continue;
155
234
  }
156
235
 
157
- const content = fs.readFileSync(profilePath, 'utf8');
158
- if (!content.includes(CONFIG_MARKER)) {
159
- continue;
160
- }
161
-
162
- // Remove the config block (handles both Unix and PowerShell formats)
163
- // Match from the comment line through the closing fi/}
164
- const unixPattern = /\n?# TR-200 Machine Report \(npm\) - auto-run\nif command -v tr200 &> \/dev\/null; then\n tr200\nfi\n?/g;
165
- const psPattern = /\n?# TR-200 Machine Report \(npm\) - auto-run\nif \(Get-Command tr200 -ErrorAction SilentlyContinue\) \{\n tr200\n\}\n?/g;
166
-
167
- let newContent = content.replace(unixPattern, '');
168
- newContent = newContent.replace(psPattern, '');
169
-
170
- if (newContent !== content) {
171
- try {
172
- fs.writeFileSync(profilePath, newContent, 'utf8');
173
- console.log(` [done] ${profilePath}`);
174
- removed++;
175
- } catch (err) {
176
- console.error(` [error] ${profilePath}: ${err.message}`);
177
- }
236
+ // Use the comprehensive cleanup function
237
+ if (cleanProfileFile(profilePath)) {
238
+ console.log(` [done] ${profilePath}`);
239
+ removed++;
178
240
  }
179
241
  }
180
242
 
@@ -280,7 +342,7 @@ function runReport() {
280
342
  // Handle help flag
281
343
  if (process.argv.includes('--help') || process.argv.includes('-h')) {
282
344
  console.log(`
283
- TR-200 Machine Report v2.0.1
345
+ TR-200 Machine Report v2.0.3
284
346
 
285
347
  Usage: tr200 [options]
286
348
  report [options]
@@ -300,7 +362,7 @@ More info: https://github.com/RealEmmettS/usgc-machine-report
300
362
 
301
363
  // Handle version flag
302
364
  if (process.argv.includes('--version') || process.argv.includes('-v')) {
303
- console.log('2.0.1');
365
+ console.log('2.0.3');
304
366
  process.exit(0);
305
367
  }
306
368
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tr200",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Cross-platform system information report with Unicode box-drawing display",
5
5
  "author": "shaughv",
6
6
  "license": "BSD-3-Clause",