start-command 0.7.1 → 0.7.2
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/CHANGELOG.md +10 -0
- package/README.md +11 -17
- package/REQUIREMENTS.md +0 -1
- package/docs/case-studies/issue-22/analysis.md +215 -0
- package/package.json +2 -2
- package/src/bin/cli.js +73 -18
- package/test/version.test.js +46 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# start-command
|
|
2
2
|
|
|
3
|
+
## 0.7.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fa0fb23: docs: Update documentation to Bun-first approach
|
|
8
|
+
- Remove npm installation option from README.md
|
|
9
|
+
- Update examples to use bun commands instead of npm
|
|
10
|
+
- Change package.json engines from node to bun
|
|
11
|
+
- Update REQUIREMENTS.md to remove Node.js alternative
|
|
12
|
+
|
|
3
13
|
## 0.7.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -4,18 +4,12 @@ Gamification of coding - execute any command with automatic logging and ability
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Install using [Bun](https://bun.sh):
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
bun install -g start-command
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Or using npm:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm install -g start-command
|
|
17
|
-
```
|
|
18
|
-
|
|
19
13
|
## Usage
|
|
20
14
|
|
|
21
15
|
The `$` command acts as a wrapper for any shell command:
|
|
@@ -123,16 +117,16 @@ Run commands in isolated environments using terminal multiplexers or containers:
|
|
|
123
117
|
|
|
124
118
|
```bash
|
|
125
119
|
# Run in tmux (attached by default)
|
|
126
|
-
$ --isolated tmux --
|
|
120
|
+
$ --isolated tmux -- bun start
|
|
127
121
|
|
|
128
122
|
# Run in screen detached
|
|
129
|
-
$ --isolated screen --detached --
|
|
123
|
+
$ --isolated screen --detached -- bun start
|
|
130
124
|
|
|
131
125
|
# Run in docker container
|
|
132
|
-
$ --isolated docker --image
|
|
126
|
+
$ --isolated docker --image oven/bun:latest -- bun install
|
|
133
127
|
|
|
134
128
|
# Short form with custom session name
|
|
135
|
-
$ -i tmux -s my-session -d
|
|
129
|
+
$ -i tmux -s my-session -d bun start
|
|
136
130
|
```
|
|
137
131
|
|
|
138
132
|
#### Supported Backends
|
|
@@ -169,7 +163,7 @@ The tool works in any environment:
|
|
|
169
163
|
|
|
170
164
|
### Required
|
|
171
165
|
|
|
172
|
-
-
|
|
166
|
+
- [Bun](https://bun.sh) >= 1.0.0
|
|
173
167
|
|
|
174
168
|
### Optional (for full auto-reporting)
|
|
175
169
|
|
|
@@ -183,7 +177,7 @@ To set up auto-reporting:
|
|
|
183
177
|
gh auth login
|
|
184
178
|
|
|
185
179
|
# Install log uploader
|
|
186
|
-
|
|
180
|
+
bun install -g gh-upload-log
|
|
187
181
|
```
|
|
188
182
|
|
|
189
183
|
## How It Works
|
|
@@ -214,10 +208,10 @@ Example:
|
|
|
214
208
|
|
|
215
209
|
```bash
|
|
216
210
|
# Run without auto-issue creation
|
|
217
|
-
START_DISABLE_AUTO_ISSUE=1 $
|
|
211
|
+
START_DISABLE_AUTO_ISSUE=1 $ bun test
|
|
218
212
|
|
|
219
213
|
# Use custom log directory
|
|
220
|
-
START_LOG_DIR=./logs $
|
|
214
|
+
START_LOG_DIR=./logs $ bun test
|
|
221
215
|
|
|
222
216
|
# Disable substitutions (use raw command)
|
|
223
217
|
START_DISABLE_SUBSTITUTIONS=1 $ install lodash npm package
|
|
@@ -237,10 +231,10 @@ Log files are saved as `start-command-{timestamp}-{random}.log` and contain:
|
|
|
237
231
|
```
|
|
238
232
|
=== Start Command Log ===
|
|
239
233
|
Timestamp: 2024-01-15 10:30:45.123
|
|
240
|
-
Command:
|
|
234
|
+
Command: bun test
|
|
241
235
|
Shell: /bin/bash
|
|
242
236
|
Platform: linux
|
|
243
|
-
|
|
237
|
+
Bun Version: 1.2.0
|
|
244
238
|
Working Directory: /home/user/project
|
|
245
239
|
==================================================
|
|
246
240
|
|
package/REQUIREMENTS.md
CHANGED
|
@@ -210,7 +210,6 @@ Repository not detected - automatic issue creation skipped
|
|
|
210
210
|
### Required
|
|
211
211
|
|
|
212
212
|
- **Bun >= 1.0.0** (primary runtime)
|
|
213
|
-
- Alternatively: Node.js >= 20.0.0 (for compatibility)
|
|
214
213
|
- `child_process` (built-in)
|
|
215
214
|
- `os` (built-in)
|
|
216
215
|
- `fs` (built-in)
|
|
@@ -330,3 +330,218 @@ if ((args.length === 1 && hasVersionFlag) || isOnlyVersionWithSeparator) {
|
|
|
330
330
|
- ✅ CI tests pass
|
|
331
331
|
- ✅ REQUIREMENTS.md updated
|
|
332
332
|
- ✅ No npm references in documentation
|
|
333
|
+
|
|
334
|
+
## Implementation Status
|
|
335
|
+
|
|
336
|
+
**Status:** 🔄 In Progress (Second Iteration)
|
|
337
|
+
|
|
338
|
+
### First Iteration (PR #23 - Merged to Main)
|
|
339
|
+
|
|
340
|
+
The initial fixes were merged to `main` branch via PR #23, addressing:
|
|
341
|
+
|
|
342
|
+
- Version flag handling with trailing `--`
|
|
343
|
+
- Runtime detection (Bun vs Node.js)
|
|
344
|
+
- macOS version detection using `sw_vers`
|
|
345
|
+
- Basic screen detection using `2>&1`
|
|
346
|
+
|
|
347
|
+
### Second Iteration (This PR) - The Screen Detection Bug
|
|
348
|
+
|
|
349
|
+
After v0.7.1 was released, users on macOS still reported:
|
|
350
|
+
|
|
351
|
+
```
|
|
352
|
+
screen: not installed
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
Even though screen was installed:
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
$ screen -v
|
|
359
|
+
Screen version 4.00.03 (FAU) 23-Oct-06
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
#### Deep Root Cause Analysis
|
|
363
|
+
|
|
364
|
+
**The Problem:** The macOS bundled version of GNU Screen (4.00.03) returns a **non-zero exit code** when running `screen --version` or `screen -v`, even though it successfully outputs the version information.
|
|
365
|
+
|
|
366
|
+
**Discovery Process:**
|
|
367
|
+
|
|
368
|
+
1. Searched for known issues with GNU Screen version flag
|
|
369
|
+
2. Found reference to [GNU Screen v.4.8.0 release notes](https://savannah.gnu.org/forum/forum.php?forum_id=9665)
|
|
370
|
+
3. The release notes mention: "Make screen exit code be 0 when checking --version"
|
|
371
|
+
|
|
372
|
+
**Root Cause Confirmed:**
|
|
373
|
+
This was a **known bug in GNU Screen prior to version 4.8.0** where the `--version` flag would exit with a non-zero status code.
|
|
374
|
+
|
|
375
|
+
- macOS bundled version: 4.00.03 (affected by bug)
|
|
376
|
+
- Bug fix version: 4.8.0+
|
|
377
|
+
- Linux typically has newer versions via package managers
|
|
378
|
+
|
|
379
|
+
**Why Previous Fix Didn't Work:**
|
|
380
|
+
|
|
381
|
+
The previous fix used `execSync()` with `2>&1` to capture stderr:
|
|
382
|
+
|
|
383
|
+
```javascript
|
|
384
|
+
const result = execSync(`${toolName} ${versionFlag} 2>&1`, {
|
|
385
|
+
encoding: 'utf8',
|
|
386
|
+
timeout: 5000,
|
|
387
|
+
}).trim();
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
**Problem:** `execSync()` throws an exception when the command returns non-zero exit code, so even though the output was captured correctly, the `catch` block returned `null`.
|
|
391
|
+
|
|
392
|
+
#### The Solution
|
|
393
|
+
|
|
394
|
+
Use `spawnSync()` instead of `execSync()` to capture output **regardless of exit code**:
|
|
395
|
+
|
|
396
|
+
```javascript
|
|
397
|
+
function getToolVersion(toolName, versionFlag, verbose = false) {
|
|
398
|
+
const isWindows = process.platform === 'win32';
|
|
399
|
+
const whichCmd = isWindows ? 'where' : 'which';
|
|
400
|
+
|
|
401
|
+
// First, check if the tool exists in PATH
|
|
402
|
+
try {
|
|
403
|
+
execSync(`${whichCmd} ${toolName}`, {
|
|
404
|
+
encoding: 'utf8',
|
|
405
|
+
timeout: 5000,
|
|
406
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
407
|
+
});
|
|
408
|
+
} catch {
|
|
409
|
+
// Tool not found in PATH
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// Tool exists, try to get version using spawnSync
|
|
414
|
+
// This captures output regardless of exit code
|
|
415
|
+
const result = spawnSync(toolName, [versionFlag], {
|
|
416
|
+
encoding: 'utf8',
|
|
417
|
+
timeout: 5000,
|
|
418
|
+
shell: false,
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
// Combine stdout and stderr
|
|
422
|
+
const output = ((result.stdout || '') + (result.stderr || '')).trim();
|
|
423
|
+
|
|
424
|
+
if (!output) {
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
return output.split('\n')[0];
|
|
429
|
+
}
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
#### Additional Improvements
|
|
433
|
+
|
|
434
|
+
1. **`--verbose` flag support** - Users can now debug version detection:
|
|
435
|
+
|
|
436
|
+
```bash
|
|
437
|
+
$ --version --verbose
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
This shows detailed debugging information about tool detection.
|
|
441
|
+
|
|
442
|
+
2. **`-v` flag for screen** - Changed from `--version` to `-v` which is more universally supported.
|
|
443
|
+
|
|
444
|
+
3. **Comprehensive test coverage** - Added 14 tests for version detection scenarios.
|
|
445
|
+
|
|
446
|
+
### Changes Made (Second Iteration)
|
|
447
|
+
|
|
448
|
+
#### src/bin/cli.js
|
|
449
|
+
|
|
450
|
+
1. **Added `spawnSync` import:**
|
|
451
|
+
|
|
452
|
+
```javascript
|
|
453
|
+
const { spawn, execSync, spawnSync } = require('child_process');
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
2. **Enhanced version flag handling with verbose support:**
|
|
457
|
+
|
|
458
|
+
```javascript
|
|
459
|
+
const hasVerboseWithVersion =
|
|
460
|
+
hasVersionFlag &&
|
|
461
|
+
args.some((arg) => arg === '--verbose' || arg === '--debug');
|
|
462
|
+
|
|
463
|
+
if (hasVersionFlag && isVersionOnly) {
|
|
464
|
+
printVersion(hasVerboseWithVersion || config.verbose);
|
|
465
|
+
process.exit(0);
|
|
466
|
+
}
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
3. **Fixed getToolVersion to use spawnSync:**
|
|
470
|
+
- First checks if tool exists using `which`/`where`
|
|
471
|
+
- Uses `spawnSync` to capture output regardless of exit code
|
|
472
|
+
- Combines stdout and stderr
|
|
473
|
+
- Supports verbose mode for debugging
|
|
474
|
+
|
|
475
|
+
4. **Updated printVersion to accept verbose parameter:**
|
|
476
|
+
- Shows `[verbose]` messages when debugging
|
|
477
|
+
- Logs tool detection details
|
|
478
|
+
|
|
479
|
+
#### test/version.test.js
|
|
480
|
+
|
|
481
|
+
Added 3 new tests for verbose mode:
|
|
482
|
+
|
|
483
|
+
- `--version --verbose`
|
|
484
|
+
- `--version --debug`
|
|
485
|
+
- `START_VERBOSE=1` environment variable
|
|
486
|
+
|
|
487
|
+
### Test Results
|
|
488
|
+
|
|
489
|
+
All 84 tests passing across 4 test files:
|
|
490
|
+
|
|
491
|
+
- `test/version.test.js`: 14 tests
|
|
492
|
+
- `test/cli.test.js`: Passing
|
|
493
|
+
- `test/args-parser.test.js`: Passing
|
|
494
|
+
- `test/isolation.test.js`: Passing
|
|
495
|
+
- `test/substitution.test.js`: 22 tests
|
|
496
|
+
|
|
497
|
+
### Verified Behavior
|
|
498
|
+
|
|
499
|
+
```bash
|
|
500
|
+
$ --version
|
|
501
|
+
start-command version: 0.7.1
|
|
502
|
+
|
|
503
|
+
OS: linux
|
|
504
|
+
OS Version: 6.8.0-90-generic
|
|
505
|
+
Bun Version: 1.3.3
|
|
506
|
+
Architecture: x64
|
|
507
|
+
|
|
508
|
+
Isolation tools:
|
|
509
|
+
screen: Screen version 4.09.01 (GNU) 20-Aug-23
|
|
510
|
+
tmux: tmux 3.4
|
|
511
|
+
docker: not installed
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
```bash
|
|
515
|
+
$ --version --verbose
|
|
516
|
+
start-command version: 0.7.1
|
|
517
|
+
|
|
518
|
+
OS: linux
|
|
519
|
+
OS Version: 6.8.0-90-generic
|
|
520
|
+
Bun Version: 1.3.3
|
|
521
|
+
Architecture: x64
|
|
522
|
+
|
|
523
|
+
Isolation tools:
|
|
524
|
+
[verbose] Checking isolation tools...
|
|
525
|
+
[verbose] screen -v: exit=0, output="Screen version 4.09.01 (GNU) 20-Aug-23"
|
|
526
|
+
screen: Screen version 4.09.01 (GNU) 20-Aug-23
|
|
527
|
+
[verbose] tmux -V: exit=0, output="tmux 3.4"
|
|
528
|
+
tmux: tmux 3.4
|
|
529
|
+
[verbose] docker: not found in PATH
|
|
530
|
+
docker: not installed
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
## Key Learnings
|
|
534
|
+
|
|
535
|
+
1. **Exit codes matter**: Some tools return non-zero exit codes even for successful operations. Always consider using `spawnSync` when you need to capture output regardless of exit status.
|
|
536
|
+
|
|
537
|
+
2. **macOS bundled tools are often outdated**: The macOS bundled version of screen (4.00.03 from 2006) has known bugs fixed in newer versions.
|
|
538
|
+
|
|
539
|
+
3. **Testing on multiple platforms is crucial**: The bug only manifested on macOS with the bundled screen, not on Linux with modern screen versions.
|
|
540
|
+
|
|
541
|
+
4. **Verbose mode is invaluable for debugging**: Adding `--verbose` support allows users to self-diagnose issues.
|
|
542
|
+
|
|
543
|
+
## References
|
|
544
|
+
|
|
545
|
+
- [GNU Screen v.4.8.0 Release Notes](https://savannah.gnu.org/forum/forum.php?forum_id=9665) - Documents the exit code fix
|
|
546
|
+
- [screen Man Page - macOS](https://ss64.com/mac/screen.html) - macOS screen documentation
|
|
547
|
+
- [Node.js spawnSync](https://nodejs.org/api/child_process.html#child_processspawnsynccommand-args-options) - Alternative to execSync that doesn't throw on non-zero exit
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "start-command",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Gamification of coding, execute any command with ability to auto-report issues on GitHub",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"author": "",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"engines": {
|
|
33
|
-
"
|
|
33
|
+
"bun": ">=1.0.0"
|
|
34
34
|
},
|
|
35
35
|
"repository": {
|
|
36
36
|
"type": "git",
|
package/src/bin/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
-
const { spawn, execSync } = require('child_process');
|
|
3
|
+
const { spawn, execSync, spawnSync } = require('child_process');
|
|
4
4
|
const process = require('process');
|
|
5
5
|
const os = require('os');
|
|
6
6
|
const fs = require('fs');
|
|
@@ -51,13 +51,26 @@ const args = process.argv.slice(2);
|
|
|
51
51
|
// Handle --version flag
|
|
52
52
|
// Support: $ --version, $ -v, $ --version --
|
|
53
53
|
// The trailing -- should be ignored for version check
|
|
54
|
+
// Also support --verbose flag for debugging: $ --version --verbose
|
|
54
55
|
const hasVersionFlag =
|
|
55
56
|
args.length >= 1 && (args[0] === '--version' || args[0] === '-v');
|
|
57
|
+
|
|
58
|
+
// Check for --verbose flag in version context
|
|
59
|
+
const hasVerboseWithVersion =
|
|
60
|
+
hasVersionFlag &&
|
|
61
|
+
args.some((arg) => arg === '--verbose' || arg === '--debug');
|
|
62
|
+
|
|
63
|
+
// Determine if this is a version-only call
|
|
64
|
+
// Allow: --version, -v, --version --, --version --verbose, etc.
|
|
65
|
+
const versionRelatedArgs = ['--version', '-v', '--', '--verbose', '--debug'];
|
|
56
66
|
const isVersionOnly =
|
|
57
|
-
|
|
67
|
+
hasVersionFlag &&
|
|
68
|
+
args.every(
|
|
69
|
+
(arg) => versionRelatedArgs.includes(arg) || arg === args[0] // Allow the version flag itself
|
|
70
|
+
);
|
|
58
71
|
|
|
59
72
|
if (hasVersionFlag && isVersionOnly) {
|
|
60
|
-
printVersion();
|
|
73
|
+
printVersion(hasVerboseWithVersion || config.verbose);
|
|
61
74
|
process.exit(0);
|
|
62
75
|
}
|
|
63
76
|
|
|
@@ -68,8 +81,9 @@ if (args.length === 0) {
|
|
|
68
81
|
|
|
69
82
|
/**
|
|
70
83
|
* Print version information
|
|
84
|
+
* @param {boolean} verbose - Whether to show verbose debugging info
|
|
71
85
|
*/
|
|
72
|
-
function printVersion() {
|
|
86
|
+
function printVersion(verbose = false) {
|
|
73
87
|
// Get package version
|
|
74
88
|
const packageJson = require('../../package.json');
|
|
75
89
|
const startCommandVersion = packageJson.version;
|
|
@@ -93,9 +107,17 @@ function printVersion() {
|
|
|
93
107
|
encoding: 'utf8',
|
|
94
108
|
timeout: 5000,
|
|
95
109
|
}).trim();
|
|
110
|
+
if (verbose) {
|
|
111
|
+
console.log(`[verbose] macOS version from sw_vers: ${osVersion}`);
|
|
112
|
+
}
|
|
96
113
|
} catch {
|
|
97
114
|
// Fallback to kernel version if sw_vers fails
|
|
98
115
|
osVersion = os.release();
|
|
116
|
+
if (verbose) {
|
|
117
|
+
console.log(
|
|
118
|
+
`[verbose] sw_vers failed, using kernel version: ${osVersion}`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
99
121
|
}
|
|
100
122
|
}
|
|
101
123
|
|
|
@@ -107,8 +129,12 @@ function printVersion() {
|
|
|
107
129
|
// Check for installed isolation tools
|
|
108
130
|
console.log('Isolation tools:');
|
|
109
131
|
|
|
110
|
-
|
|
111
|
-
|
|
132
|
+
if (verbose) {
|
|
133
|
+
console.log('[verbose] Checking isolation tools...');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Check screen (use -v flag for compatibility with older versions)
|
|
137
|
+
const screenVersion = getToolVersion('screen', '-v', verbose);
|
|
112
138
|
if (screenVersion) {
|
|
113
139
|
console.log(` screen: ${screenVersion}`);
|
|
114
140
|
} else {
|
|
@@ -116,7 +142,7 @@ function printVersion() {
|
|
|
116
142
|
}
|
|
117
143
|
|
|
118
144
|
// Check tmux
|
|
119
|
-
const tmuxVersion = getToolVersion('tmux', '-V');
|
|
145
|
+
const tmuxVersion = getToolVersion('tmux', '-V', verbose);
|
|
120
146
|
if (tmuxVersion) {
|
|
121
147
|
console.log(` tmux: ${tmuxVersion}`);
|
|
122
148
|
} else {
|
|
@@ -124,7 +150,7 @@ function printVersion() {
|
|
|
124
150
|
}
|
|
125
151
|
|
|
126
152
|
// Check docker
|
|
127
|
-
const dockerVersion = getToolVersion('docker', '--version');
|
|
153
|
+
const dockerVersion = getToolVersion('docker', '--version', verbose);
|
|
128
154
|
if (dockerVersion) {
|
|
129
155
|
console.log(` docker: ${dockerVersion}`);
|
|
130
156
|
} else {
|
|
@@ -136,24 +162,53 @@ function printVersion() {
|
|
|
136
162
|
* Get version of an installed tool
|
|
137
163
|
* @param {string} toolName - Name of the tool
|
|
138
164
|
* @param {string} versionFlag - Flag to get version (e.g., '--version', '-V')
|
|
165
|
+
* @param {boolean} verbose - Whether to log verbose information
|
|
139
166
|
* @returns {string|null} Version string or null if not installed
|
|
140
167
|
*/
|
|
141
|
-
function getToolVersion(toolName, versionFlag) {
|
|
168
|
+
function getToolVersion(toolName, versionFlag, verbose = false) {
|
|
169
|
+
const isWindows = process.platform === 'win32';
|
|
170
|
+
const whichCmd = isWindows ? 'where' : 'which';
|
|
171
|
+
|
|
172
|
+
// First, check if the tool exists in PATH
|
|
142
173
|
try {
|
|
143
|
-
|
|
144
|
-
// Some tools like screen output version to stderr instead of stdout
|
|
145
|
-
const result = execSync(`${toolName} ${versionFlag} 2>&1`, {
|
|
174
|
+
execSync(`${whichCmd} ${toolName}`, {
|
|
146
175
|
encoding: 'utf8',
|
|
147
176
|
timeout: 5000,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
// Extract version number from output
|
|
151
|
-
// Most tools output version in various formats, so we'll return the first line
|
|
152
|
-
const firstLine = result.split('\n')[0];
|
|
153
|
-
return firstLine;
|
|
177
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
178
|
+
});
|
|
154
179
|
} catch {
|
|
180
|
+
// Tool not found in PATH
|
|
181
|
+
if (verbose) {
|
|
182
|
+
console.log(`[verbose] ${toolName}: not found in PATH`);
|
|
183
|
+
}
|
|
155
184
|
return null;
|
|
156
185
|
}
|
|
186
|
+
|
|
187
|
+
// Tool exists, try to get version using spawnSync
|
|
188
|
+
// This captures output regardless of exit code (some tools like older screen
|
|
189
|
+
// versions return non-zero exit code even when showing version successfully)
|
|
190
|
+
const result = spawnSync(toolName, [versionFlag], {
|
|
191
|
+
encoding: 'utf8',
|
|
192
|
+
timeout: 5000,
|
|
193
|
+
shell: false,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// Combine stdout and stderr (some tools output version to stderr)
|
|
197
|
+
const output = ((result.stdout || '') + (result.stderr || '')).trim();
|
|
198
|
+
|
|
199
|
+
if (verbose) {
|
|
200
|
+
console.log(
|
|
201
|
+
`[verbose] ${toolName} ${versionFlag}: exit=${result.status}, output="${output.substring(0, 100)}"`
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (!output) {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Return the first line of output
|
|
210
|
+
const firstLine = output.split('\n')[0];
|
|
211
|
+
return firstLine || null;
|
|
157
212
|
}
|
|
158
213
|
|
|
159
214
|
/**
|
package/test/version.test.js
CHANGED
|
@@ -243,6 +243,52 @@ describe('Version Flag Tests', () => {
|
|
|
243
243
|
});
|
|
244
244
|
});
|
|
245
245
|
|
|
246
|
+
describe('Verbose mode', () => {
|
|
247
|
+
it('should show verbose output with --version --verbose', () => {
|
|
248
|
+
const result = runCli(['--version', '--verbose']);
|
|
249
|
+
assert.strictEqual(result.exitCode, 0, 'Exit code should be 0');
|
|
250
|
+
assert.match(
|
|
251
|
+
result.stdout,
|
|
252
|
+
/start-command version:/,
|
|
253
|
+
'Should show start-command version'
|
|
254
|
+
);
|
|
255
|
+
assert.match(
|
|
256
|
+
result.stdout,
|
|
257
|
+
/\[verbose\]/,
|
|
258
|
+
'Should show verbose output markers'
|
|
259
|
+
);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('should show verbose output with --version --debug', () => {
|
|
263
|
+
const result = runCli(['--version', '--debug']);
|
|
264
|
+
assert.strictEqual(result.exitCode, 0, 'Exit code should be 0');
|
|
265
|
+
assert.match(
|
|
266
|
+
result.stdout,
|
|
267
|
+
/\[verbose\]/,
|
|
268
|
+
'Should show verbose output with --debug flag'
|
|
269
|
+
);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
it('should show verbose output with START_VERBOSE=1', () => {
|
|
273
|
+
const result = spawnSync('bun', [cliPath, '--version'], {
|
|
274
|
+
encoding: 'utf8',
|
|
275
|
+
timeout: 5000,
|
|
276
|
+
env: {
|
|
277
|
+
...process.env,
|
|
278
|
+
START_VERBOSE: '1',
|
|
279
|
+
START_DISABLE_AUTO_ISSUE: '1',
|
|
280
|
+
START_DISABLE_LOG_UPLOAD: '1',
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
assert.strictEqual(result.status, 0, 'Exit code should be 0');
|
|
284
|
+
assert.match(
|
|
285
|
+
result.stdout,
|
|
286
|
+
/\[verbose\]/,
|
|
287
|
+
'Should show verbose output with START_VERBOSE=1'
|
|
288
|
+
);
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
|
|
246
292
|
describe('Error cases', () => {
|
|
247
293
|
it('should error with "No command provided" for $ --', () => {
|
|
248
294
|
const result = runCli(['--']);
|