start-command 0.13.0 → 0.15.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.
- package/CHANGELOG.md +28 -231
- package/bun.lock +5 -0
- package/eslint.config.mjs +1 -1
- package/package.json +11 -6
- package/src/bin/cli.js +275 -137
- package/src/lib/args-parser.js +118 -0
- package/src/lib/execution-store.js +722 -0
- package/src/lib/isolation.js +51 -0
- package/src/lib/status-formatter.js +121 -0
- package/src/lib/version.js +143 -0
- package/test/args-parser.test.js +107 -0
- package/test/cli.test.js +11 -1
- package/test/docker-autoremove.test.js +11 -16
- package/test/execution-store.test.js +483 -0
- package/test/isolation-cleanup.test.js +11 -16
- package/test/isolation.test.js +11 -17
- package/test/public-exports.test.js +105 -0
- package/test/status-query.test.js +195 -0
- package/.github/workflows/release.yml +0 -352
- package/.husky/pre-commit +0 -1
- package/ARCHITECTURE.md +0 -297
- package/LICENSE +0 -24
- package/README.md +0 -339
- package/REQUIREMENTS.md +0 -299
- package/docs/PIPES.md +0 -243
- package/docs/USAGE.md +0 -194
- package/docs/case-studies/issue-15/README.md +0 -208
- package/docs/case-studies/issue-18/README.md +0 -343
- package/docs/case-studies/issue-18/issue-comments.json +0 -1
- package/docs/case-studies/issue-18/issue-data.json +0 -7
- package/docs/case-studies/issue-22/analysis.md +0 -547
- package/docs/case-studies/issue-22/issue-data.json +0 -12
- package/docs/case-studies/issue-25/README.md +0 -232
- package/docs/case-studies/issue-25/issue-data.json +0 -21
- package/docs/case-studies/issue-28/README.md +0 -405
- package/docs/case-studies/issue-28/issue-data.json +0 -105
- package/docs/case-studies/issue-28/raw-issue-data.md +0 -92
- package/experiments/debug-regex.js +0 -49
- package/experiments/isolation-design.md +0 -131
- package/experiments/screen-output-test.js +0 -265
- package/experiments/test-cli.sh +0 -42
- package/experiments/test-command-stream-cjs.cjs +0 -30
- package/experiments/test-command-stream-wrapper.js +0 -54
- package/experiments/test-command-stream.mjs +0 -56
- package/experiments/test-screen-attached.js +0 -126
- package/experiments/test-screen-logfile.js +0 -286
- package/experiments/test-screen-modes.js +0 -128
- package/experiments/test-screen-output.sh +0 -27
- package/experiments/test-screen-tee-debug.js +0 -237
- package/experiments/test-screen-tee-fallback.js +0 -230
- package/experiments/test-substitution.js +0 -143
- package/experiments/user-isolation-research.md +0 -83
- package/scripts/changeset-version.mjs +0 -38
- package/scripts/check-file-size.mjs +0 -103
- package/scripts/create-github-release.mjs +0 -93
- package/scripts/create-manual-changeset.mjs +0 -89
- package/scripts/format-github-release.mjs +0 -83
- package/scripts/format-release-notes.mjs +0 -219
- package/scripts/instant-version-bump.mjs +0 -121
- package/scripts/publish-to-npm.mjs +0 -129
- package/scripts/setup-npm.mjs +0 -37
- package/scripts/validate-changeset.mjs +0 -107
- package/scripts/version-and-commit.mjs +0 -237
|
@@ -1,547 +0,0 @@
|
|
|
1
|
-
# Case Study: Issue #22 - Version Detection Issues
|
|
2
|
-
|
|
3
|
-
## Issue Overview
|
|
4
|
-
|
|
5
|
-
**Issue ID:** #22
|
|
6
|
-
**Title:** --version issues
|
|
7
|
-
**Reported By:** konard
|
|
8
|
-
**Created:** 2025-12-23T17:55:53Z
|
|
9
|
-
**Status:** Open
|
|
10
|
-
|
|
11
|
-
## Problem Summary
|
|
12
|
-
|
|
13
|
-
The `$ --version` command exhibited multiple issues when run on macOS:
|
|
14
|
-
|
|
15
|
-
1. **Screen version not detected** - Despite screen being installed, it showed "not installed"
|
|
16
|
-
2. **Wrong runtime displayed** - Showed Node.js version instead of Bun version
|
|
17
|
-
3. **Incorrect OS version format** - Showed OS Release (kernel version) instead of macOS version
|
|
18
|
-
4. **Argument parsing issue** - `$ --version --` resulted in "No command provided" error
|
|
19
|
-
|
|
20
|
-
## Timeline of Events
|
|
21
|
-
|
|
22
|
-
### User Environment
|
|
23
|
-
|
|
24
|
-
- **System:** macOS 15.7.2 (ProductVersion)
|
|
25
|
-
- **Kernel:** 24.6.0 (OS Release)
|
|
26
|
-
- **Bun Version:** 1.2.20
|
|
27
|
-
- **Node.js Emulation:** v24.3.0 (provided by Bun)
|
|
28
|
-
- **Architecture:** arm64
|
|
29
|
-
- **Package:** start-command@0.7.0
|
|
30
|
-
|
|
31
|
-
### Observed Behavior
|
|
32
|
-
|
|
33
|
-
#### Command 1: `$ --version --`
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
Error: No command provided
|
|
37
|
-
Usage: $ [options] [--] <command> [args...]
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
**Expected:** Should display version information (same as `$ --version`)
|
|
41
|
-
**Actual:** Treated `--` as command separator and found no command after it
|
|
42
|
-
|
|
43
|
-
#### Command 2: `$ --version`
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
start-command version: 0.7.0
|
|
47
|
-
|
|
48
|
-
OS: darwin
|
|
49
|
-
OS Release: 24.6.0
|
|
50
|
-
Node Version: v24.3.0
|
|
51
|
-
Architecture: arm64
|
|
52
|
-
|
|
53
|
-
Isolation tools:
|
|
54
|
-
screen: not installed
|
|
55
|
-
tmux: not installed
|
|
56
|
-
docker: Docker version 28.5.1, build e180ab8
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
**Issues Identified:**
|
|
60
|
-
|
|
61
|
-
1. Screen shown as "not installed" despite being present
|
|
62
|
-
2. "Node Version: v24.3.0" when using Bun
|
|
63
|
-
3. "OS Release: 24.6.0" (kernel) instead of "15.7.2" (macOS version)
|
|
64
|
-
|
|
65
|
-
#### Verification Commands
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
screen -v
|
|
69
|
-
# Output: Screen version 4.00.03 (FAU) 23-Oct-06
|
|
70
|
-
|
|
71
|
-
sw_vers
|
|
72
|
-
# Output:
|
|
73
|
-
# ProductName: macOS
|
|
74
|
-
# ProductVersion: 15.7.2
|
|
75
|
-
# BuildVersion: 24G325
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Root Cause Analysis
|
|
79
|
-
|
|
80
|
-
### Issue 1: Screen Version Not Detected
|
|
81
|
-
|
|
82
|
-
**Location:** `src/bin/cli.js:84`
|
|
83
|
-
|
|
84
|
-
**Root Cause:**
|
|
85
|
-
|
|
86
|
-
- Screen outputs version to stderr, not stdout
|
|
87
|
-
- Current implementation uses `execSync()` with default stdio configuration
|
|
88
|
-
- On some systems/versions, screen sends output to stderr
|
|
89
|
-
|
|
90
|
-
**Code Analysis:**
|
|
91
|
-
|
|
92
|
-
```javascript
|
|
93
|
-
const screenVersion = getToolVersion('screen', '--version');
|
|
94
|
-
|
|
95
|
-
function getToolVersion(toolName, versionFlag) {
|
|
96
|
-
try {
|
|
97
|
-
const result = execSync(`${toolName} ${versionFlag}`, {
|
|
98
|
-
encoding: 'utf8',
|
|
99
|
-
stdio: ['pipe', 'pipe', 'pipe'], // stderr is piped but not captured
|
|
100
|
-
timeout: 5000,
|
|
101
|
-
}).trim();
|
|
102
|
-
// ...
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
The `execSync()` call captures stdout but the function doesn't merge stderr into the result. On macOS, screen may output to stderr.
|
|
106
|
-
|
|
107
|
-
### Issue 2: Node.js Version Instead of Bun Version
|
|
108
|
-
|
|
109
|
-
**Location:** `src/bin/cli.js:76`
|
|
110
|
-
|
|
111
|
-
**Root Cause:**
|
|
112
|
-
|
|
113
|
-
- Code uses `process.version` which returns Node.js compatibility version in Bun
|
|
114
|
-
- Bun emulates Node.js v24.3.0 for compatibility
|
|
115
|
-
- Should use `process.versions.bun` or `Bun.version` instead
|
|
116
|
-
|
|
117
|
-
**Code Analysis:**
|
|
118
|
-
|
|
119
|
-
```javascript
|
|
120
|
-
console.log(`Node Version: ${process.version}`);
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
**Research Findings:**
|
|
124
|
-
|
|
125
|
-
- `process.version` in Bun → Returns emulated Node.js version (v24.3.0)
|
|
126
|
-
- `process.versions.bun` → Returns actual Bun version (1.2.20)
|
|
127
|
-
- `Bun.version` → Bun-specific API for version
|
|
128
|
-
|
|
129
|
-
**Sources:**
|
|
130
|
-
|
|
131
|
-
- [Bun — Detect the Version at Runtime](https://futurestud.io/tutorials/bun-detect-the-version-at-runtime)
|
|
132
|
-
- [Get the current Bun version - Bun](https://bun.com/docs/guides/util/version)
|
|
133
|
-
|
|
134
|
-
### Issue 3: Incorrect macOS Version Format
|
|
135
|
-
|
|
136
|
-
**Location:** `src/bin/cli.js:75`
|
|
137
|
-
|
|
138
|
-
**Root Cause:**
|
|
139
|
-
|
|
140
|
-
- Code uses `os.release()` which returns kernel version (24.6.0)
|
|
141
|
-
- Should use `sw_vers -productVersion` for user-facing macOS version (15.7.2)
|
|
142
|
-
|
|
143
|
-
**Code Analysis:**
|
|
144
|
-
|
|
145
|
-
```javascript
|
|
146
|
-
console.log(`OS Release: ${os.release()}`);
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
**Kernel vs Product Version:**
|
|
150
|
-
|
|
151
|
-
- `os.release()` → 24.6.0 (Darwin kernel version)
|
|
152
|
-
- `sw_vers -productVersion` → 15.7.2 (macOS product version)
|
|
153
|
-
|
|
154
|
-
**Research Findings:**
|
|
155
|
-
The macOS `sw_vers` command provides user-facing version information:
|
|
156
|
-
|
|
157
|
-
- `sw_vers -productVersion` returns the macOS version (e.g., "15.7.2", "26.0")
|
|
158
|
-
- This is what users recognize as their macOS version
|
|
159
|
-
|
|
160
|
-
**Sources:**
|
|
161
|
-
|
|
162
|
-
- [sw_vers Man Page - macOS - SS64.com](https://ss64.com/mac/sw_vers.html)
|
|
163
|
-
- [Check macOS Latest Version · For Tahoe · 2025](https://mac.install.guide/macos/check-version)
|
|
164
|
-
|
|
165
|
-
### Issue 4: Argument Parsing for `--version --`
|
|
166
|
-
|
|
167
|
-
**Location:** `src/bin/cli.js:52-55`
|
|
168
|
-
|
|
169
|
-
**Root Cause:**
|
|
170
|
-
|
|
171
|
-
- Version check happens before argument parsing
|
|
172
|
-
- Only checks for exact match: `args.length === 1 && (args[0] === '--version' || args[0] === '-v')`
|
|
173
|
-
- When `--version --` is passed, args = `['--version', '--']`, length is 2, fails the check
|
|
174
|
-
- Falls through to argument parser which treats `--` as separator
|
|
175
|
-
|
|
176
|
-
**Code Analysis:**
|
|
177
|
-
|
|
178
|
-
```javascript
|
|
179
|
-
if (args.length === 1 && (args[0] === '--version' || args[0] === '-v')) {
|
|
180
|
-
printVersion();
|
|
181
|
-
process.exit(0);
|
|
182
|
-
}
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
**Expected Behavior:**
|
|
186
|
-
|
|
187
|
-
- `$ --version` → Show version ✓
|
|
188
|
-
- `$ --version --` → Show version (should ignore trailing `--`)
|
|
189
|
-
- `$ --` → "No command provided" error ✓
|
|
190
|
-
- `$` → Show usage ✓
|
|
191
|
-
|
|
192
|
-
## Proposed Solutions
|
|
193
|
-
|
|
194
|
-
### Solution 1: Fix Screen Detection
|
|
195
|
-
|
|
196
|
-
Capture both stdout and stderr when detecting tool versions:
|
|
197
|
-
|
|
198
|
-
```javascript
|
|
199
|
-
function getToolVersion(toolName, versionFlag) {
|
|
200
|
-
try {
|
|
201
|
-
const result = execSync(`${toolName} ${versionFlag} 2>&1`, {
|
|
202
|
-
encoding: 'utf8',
|
|
203
|
-
timeout: 5000,
|
|
204
|
-
}).trim();
|
|
205
|
-
const firstLine = result.split('\n')[0];
|
|
206
|
-
return firstLine;
|
|
207
|
-
} catch {
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
### Solution 2: Use Bun Version
|
|
214
|
-
|
|
215
|
-
Detect runtime and show appropriate version:
|
|
216
|
-
|
|
217
|
-
```javascript
|
|
218
|
-
// Detect if running in Bun
|
|
219
|
-
const runtime = typeof Bun !== 'undefined' ? 'Bun' : 'Node.js';
|
|
220
|
-
const runtimeVersion =
|
|
221
|
-
typeof Bun !== 'undefined' ? Bun.version : process.version;
|
|
222
|
-
|
|
223
|
-
console.log(`${runtime} Version: ${runtimeVersion}`);
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
### Solution 3: Fix macOS Version Detection
|
|
227
|
-
|
|
228
|
-
Use `sw_vers -productVersion` on macOS:
|
|
229
|
-
|
|
230
|
-
```javascript
|
|
231
|
-
function getOSVersion() {
|
|
232
|
-
if (process.platform === 'darwin') {
|
|
233
|
-
try {
|
|
234
|
-
return execSync('sw_vers -productVersion', { encoding: 'utf8' }).trim();
|
|
235
|
-
} catch {
|
|
236
|
-
return os.release();
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
return os.release();
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
console.log(`OS: ${process.platform}`);
|
|
243
|
-
console.log(`OS Version: ${getOSVersion()}`);
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
### Solution 4: Fix Argument Parsing
|
|
247
|
-
|
|
248
|
-
Check for `--version` flag regardless of other arguments:
|
|
249
|
-
|
|
250
|
-
```javascript
|
|
251
|
-
// Check if --version is present (ignore trailing --)
|
|
252
|
-
const hasVersionFlag = args.includes('--version') || args.includes('-v');
|
|
253
|
-
const isOnlyVersionWithSeparator =
|
|
254
|
-
args.length === 2 &&
|
|
255
|
-
(args[0] === '--version' || args[0] === '-v') &&
|
|
256
|
-
args[1] === '--';
|
|
257
|
-
|
|
258
|
-
if ((args.length === 1 && hasVersionFlag) || isOnlyVersionWithSeparator) {
|
|
259
|
-
printVersion();
|
|
260
|
-
process.exit(0);
|
|
261
|
-
}
|
|
262
|
-
```
|
|
263
|
-
|
|
264
|
-
## Implementation Plan
|
|
265
|
-
|
|
266
|
-
1. **Fix argument parsing** - Handle `--version --` case
|
|
267
|
-
2. **Fix screen detection** - Capture stderr in version detection
|
|
268
|
-
3. **Replace Node with Bun** - Detect runtime and show correct version
|
|
269
|
-
4. **Fix OS version** - Use `sw_vers` on macOS
|
|
270
|
-
5. **Update REQUIREMENTS.md** - Remove npm references, emphasize Bun-first
|
|
271
|
-
6. **Add comprehensive tests** - Cover all version scenarios
|
|
272
|
-
7. **Ensure CI runs tests** - Validate quality
|
|
273
|
-
|
|
274
|
-
## Testing Strategy
|
|
275
|
-
|
|
276
|
-
### Test Cases Required
|
|
277
|
-
|
|
278
|
-
1. **Argument Parsing Tests:**
|
|
279
|
-
- `$ --version` → Shows version
|
|
280
|
-
- `$ -v` → Shows version
|
|
281
|
-
- `$ --version --` → Shows version
|
|
282
|
-
- `$ --` → Error: No command provided
|
|
283
|
-
- `$` → Shows usage
|
|
284
|
-
|
|
285
|
-
2. **Screen Detection Tests:**
|
|
286
|
-
- When screen installed → Shows version
|
|
287
|
-
- When screen not installed → Shows "not installed"
|
|
288
|
-
|
|
289
|
-
3. **Runtime Detection Tests:**
|
|
290
|
-
- Running with Bun → Shows "Bun Version: X.X.X"
|
|
291
|
-
- Running with Node → Shows "Node.js Version: vX.X.X"
|
|
292
|
-
|
|
293
|
-
4. **OS Version Tests:**
|
|
294
|
-
- On macOS → Shows ProductVersion (15.7.2 format)
|
|
295
|
-
- On Linux → Shows kernel version
|
|
296
|
-
- On Windows → Shows kernel version
|
|
297
|
-
|
|
298
|
-
## Documentation Updates
|
|
299
|
-
|
|
300
|
-
### REQUIREMENTS.md Changes Needed
|
|
301
|
-
|
|
302
|
-
1. Replace all "npm install" references with "bun install"
|
|
303
|
-
2. Update "Node.js >= 14.0.0" to "Bun >= 1.0.0"
|
|
304
|
-
3. Update system information to show "Bun Version" instead of "Node Version"
|
|
305
|
-
4. Emphasize Bun-first approach
|
|
306
|
-
|
|
307
|
-
## Additional Notes
|
|
308
|
-
|
|
309
|
-
- The project uses `#!/usr/bin/env bun` shebang correctly
|
|
310
|
-
- Package scripts still use `node --test` which should be changed to `bun test`
|
|
311
|
-
- All references to npm in documentation should be updated to bun
|
|
312
|
-
- Consider removing npm-specific features if they don't work with bun
|
|
313
|
-
|
|
314
|
-
## Files to Modify
|
|
315
|
-
|
|
316
|
-
1. `src/bin/cli.js` - Fix all version detection issues
|
|
317
|
-
2. `src/lib/args-parser.js` - No changes needed (issue is in cli.js)
|
|
318
|
-
3. `REQUIREMENTS.md` - Update to Bun-first approach
|
|
319
|
-
4. `package.json` - Update test script to use bun
|
|
320
|
-
5. `test/cli.test.js` - Add version detection tests
|
|
321
|
-
6. New: `test/version.test.js` - Comprehensive version tests
|
|
322
|
-
|
|
323
|
-
## Success Criteria
|
|
324
|
-
|
|
325
|
-
- ✅ `$ --version --` works same as `$ --version`
|
|
326
|
-
- ✅ Screen version detected correctly when installed
|
|
327
|
-
- ✅ Shows "Bun Version" instead of "Node Version"
|
|
328
|
-
- ✅ macOS shows ProductVersion not kernel version
|
|
329
|
-
- ✅ All tests pass locally
|
|
330
|
-
- ✅ CI tests pass
|
|
331
|
-
- ✅ REQUIREMENTS.md updated
|
|
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
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"author": {
|
|
3
|
-
"id": "MDQ6VXNlcjE0MzE5MDQ=",
|
|
4
|
-
"is_bot": false,
|
|
5
|
-
"login": "konard",
|
|
6
|
-
"name": "Konstantin Diachenko"
|
|
7
|
-
},
|
|
8
|
-
"body": "```\nkonard@MacBook-Pro-Konstantin ~ % bun install -g start-command \nbun add v1.2.20 (6ad208bc)\n\ninstalled start-command@0.7.0 with binaries:\n - $\n\n1 package installed [2.40s]\nkonard@MacBook-Pro-Konstantin ~ % $ --version -- \nError: No command provided\nUsage: $ [options] [--] <command> [args...]\n $ <command> [args...]\n\nOptions:\n --isolated, -i <environment> Run in isolated environment (screen, tmux, docker)\n --attached, -a Run in attached mode (foreground)\n --detached, -d Run in detached mode (background)\n --session, -s <name> Session name for isolation\n --image <image> Docker image (required for docker isolation)\n --version, -v Show version information\n\nExamples:\n $ echo \"Hello World\"\n $ npm test\n $ --isolated tmux -- npm start\n $ -i screen -d npm start\n $ --isolated docker --image node:20 -- npm install\n\nFeatures:\n - Logs all output to temporary directory\n - Displays timestamps and exit codes\n - Auto-reports failures for NPM packages (when gh is available)\n - Natural language command aliases (via substitutions.lino)\n - Process isolation via screen, tmux, or docker\n\nAlias examples:\n $ install lodash npm package -> npm install lodash\n $ install 4.17.21 version of lodash npm package -> npm install lodash@4.17.21\n $ clone https://github.com/user/repo repository -> git clone https://github.com/user/repo\nkonard@MacBook-Pro-Konstantin ~ % $ --version \nstart-command version: 0.7.0\n\nOS: darwin\nOS Release: 24.6.0\nNode Version: v24.3.0\nArchitecture: arm64\n\nIsolation tools:\n screen: not installed\n tmux: not installed\n docker: Docker version 28.5.1, build e180ab8\nkonard@MacBook-Pro-Konstantin ~ % screen -v\nScreen version 4.00.03 (FAU) 23-Oct-06\nkonard@MacBook-Pro-Konstantin ~ % docker -v\nDocker version 28.5.1, build e180ab8\nkonard@MacBook-Pro-Konstantin ~ % sw_vers\nProductName:\t\tmacOS\nProductVersion:\t\t15.7.2\nBuildVersion:\t\t24G325\nkonard@MacBook-Pro-Konstantin ~ % \n```\n\nThe problems are:\n\n- `screen` tool version was not detected.\n- We use Bun, not Node.js (double check that, and also remove suggestions to install it using npm in the docs. Our tool should be Bun first and Bun only. For all scripts and shebangs we should use bun, not node. So in `--version` there should be bun version, not `node.js` version.\n- OS version detection was wrong.\n- `$ --version --` should work the same as `$ --version`, only `$ --` or `$` should result in `No command provided`.\n\nMake sure we have tests for all these (and these tests should be executed in CI, so we guarantee the quality). Also [REQUIREMENTS.md](https://github.com/link-foundation/start/blob/main/REQUIREMENTS.md) should be updated as needed.\n\nPlease download all logs and data related about the issue to this repository, make sure we compile that data to `./docs/case-studies/issue-{id}` folder, and use it to do deep case study analysis (also make sure to search online for additional facts and data), in which we will reconstruct timeline/sequence of events, find root causes of the problem, and propose possible solutions.",
|
|
9
|
-
"comments": [],
|
|
10
|
-
"createdAt": "2025-12-23T17:55:53Z",
|
|
11
|
-
"title": "--version issues"
|
|
12
|
-
}
|