start-command 0.26.0 → 0.27.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 (42) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/README.md +1 -1
  3. package/bunfig.toml +2 -2
  4. package/eslint.config.mjs +1 -1
  5. package/package.json +2 -2
  6. package/src/bin/cli.js +30 -0
  7. package/src/lib/args-parser.js +72 -6
  8. package/src/lib/execution-control.js +317 -0
  9. package/src/lib/isolation.js +22 -4
  10. package/src/lib/status-formatter.js +46 -2
  11. package/src/lib/usage.js +5 -1
  12. package/test/args-parser-control.js +71 -0
  13. package/test/{args-parser.test.js → args-parser.js} +1 -1
  14. package/test/cli.js +260 -0
  15. package/test/docker-autoremove.js +175 -0
  16. package/test/execution-control.js +253 -0
  17. package/test/{isolation.test.js → isolation.js} +4 -2
  18. package/test/merge-changesets.mjs +154 -0
  19. package/test/release-name.mjs +117 -0
  20. package/test/{screen-integration.test.js → screen-integration.js} +1 -1
  21. package/test/{ssh-integration.test.js → ssh-integration.js} +1 -1
  22. package/test/{status-query.test.js → status-query.js} +2 -0
  23. package/test/{substitution.test.js → substitution.js} +1 -2
  24. package/test/{user-manager.test.js → user-manager.js} +17 -0
  25. package/test/cli.test.js +0 -218
  26. package/test/docker-autoremove.test.js +0 -164
  27. package/test/release-name.test.mjs +0 -34
  28. /package/test/{args-parser-shell.test.js → args-parser-shell.js} +0 -0
  29. /package/test/{echo-integration.test.js → echo-integration.js} +0 -0
  30. /package/test/{execution-store.test.js → execution-store.js} +0 -0
  31. /package/test/{failure-handler.test.js → failure-handler.js} +0 -0
  32. /package/test/{isolation-cleanup.test.js → isolation-cleanup.js} +0 -0
  33. /package/test/{isolation-log-utils.test.js → isolation-log-utils.js} +0 -0
  34. /package/test/{isolation-stacking.test.js → isolation-stacking.js} +0 -0
  35. /package/test/{output-blocks.test.js → output-blocks.js} +0 -0
  36. /package/test/{public-exports.test.js → public-exports.js} +0 -0
  37. /package/test/{regression-84.test.js → regression-84.js} +0 -0
  38. /package/test/{regression-89.test.js → regression-89.js} +0 -0
  39. /package/test/{regression-91.test.js → regression-91.js} +0 -0
  40. /package/test/{sequence-parser.test.js → sequence-parser.js} +0 -0
  41. /package/test/{session-name-status.test.js → session-name-status.js} +0 -0
  42. /package/test/{version.test.js → version.js} +0 -0
package/test/cli.test.js DELETED
@@ -1,218 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * Unit tests for the CLI
4
- * Tests version flag and basic CLI behavior
5
- */
6
-
7
- const { describe, it } = require('node:test');
8
- const assert = require('assert');
9
- const { spawnSync } = require('child_process');
10
- const path = require('path');
11
- const fs = require('fs');
12
-
13
- // Path to the CLI script
14
- const CLI_PATH = path.join(__dirname, '../src/bin/cli.js');
15
-
16
- // Timeout for CLI operations - longer on Windows due to cold-start latency
17
- const CLI_TIMEOUT = process.platform === 'win32' ? 30000 : 10000;
18
-
19
- // Helper to run CLI with timeout
20
- function runCLI(args = []) {
21
- return spawnSync('bun', [CLI_PATH, ...args], {
22
- encoding: 'utf8',
23
- timeout: CLI_TIMEOUT,
24
- env: {
25
- ...process.env,
26
- START_DISABLE_AUTO_ISSUE: '1',
27
- START_DISABLE_LOG_UPLOAD: '1',
28
- },
29
- });
30
- }
31
-
32
- describe('CLI version flag', () => {
33
- it('should display version with --version', () => {
34
- const result = runCLI(['--version']);
35
-
36
- // Check if process was killed (e.g., due to timeout)
37
- assert.notStrictEqual(
38
- result.status,
39
- null,
40
- `Process should complete (was killed with signal: ${result.signal})`
41
- );
42
- assert.strictEqual(result.status, 0, 'Exit code should be 0');
43
-
44
- // Check for key elements in version output
45
- assert.ok(
46
- result.stdout.includes('start-command version:'),
47
- 'Should display start-command version'
48
- );
49
- assert.ok(result.stdout.includes('OS:'), 'Should display OS');
50
- assert.ok(
51
- result.stdout.includes('OS Version:'),
52
- 'Should display OS Version'
53
- );
54
- // Check for either Bun or Node.js version depending on runtime
55
- const hasBunVersion = result.stdout.includes('Bun Version:');
56
- const hasNodeVersion = result.stdout.includes('Node.js Version:');
57
- assert.ok(
58
- hasBunVersion || hasNodeVersion,
59
- 'Should display Bun Version or Node.js Version'
60
- );
61
- assert.ok(
62
- result.stdout.includes('Architecture:'),
63
- 'Should display Architecture'
64
- );
65
- assert.ok(
66
- result.stdout.includes('Isolation tools:'),
67
- 'Should display Isolation tools section'
68
- );
69
- assert.ok(
70
- result.stdout.includes('screen:'),
71
- 'Should check for screen installation'
72
- );
73
- assert.ok(
74
- result.stdout.includes('tmux:'),
75
- 'Should check for tmux installation'
76
- );
77
- assert.ok(
78
- result.stdout.includes('docker:'),
79
- 'Should check for docker installation'
80
- );
81
- });
82
-
83
- it('should display version with -v', () => {
84
- const result = runCLI(['-v']);
85
-
86
- assert.strictEqual(result.status, 0, 'Exit code should be 0');
87
- assert.ok(
88
- result.stdout.includes('start-command version:'),
89
- 'Should display start-command version'
90
- );
91
- });
92
-
93
- it('should show correct package version', () => {
94
- const result = runCLI(['--version']);
95
- const packageJson = JSON.parse(
96
- fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8')
97
- );
98
-
99
- assert.ok(
100
- result.stdout.includes(`start-command version: ${packageJson.version}`),
101
- `Should display version ${packageJson.version}`
102
- );
103
- });
104
- });
105
-
106
- describe('CLI basic behavior', () => {
107
- it('should show usage when no arguments provided', () => {
108
- const result = runCLI([]);
109
-
110
- assert.strictEqual(result.status, 0, 'Exit code should be 0');
111
- assert.ok(result.stdout.includes('Usage:'), 'Should display usage');
112
- assert.ok(
113
- result.stdout.includes('--version'),
114
- 'Usage should mention --version flag'
115
- );
116
- });
117
-
118
- it('should show usage when no command provided after --', () => {
119
- const result = runCLI(['--']);
120
-
121
- assert.strictEqual(result.status, 0, 'Exit code should be 0');
122
- assert.ok(result.stdout.includes('Usage:'), 'Should display usage');
123
- });
124
- });
125
-
126
- describe('CLI isolation output (issue #67)', () => {
127
- const { isCommandAvailable } = require('../src/lib/isolation');
128
-
129
- it('should display screen session name when using screen isolation', async () => {
130
- if (!isCommandAvailable('screen')) {
131
- console.log(' Skipping: screen not installed');
132
- return;
133
- }
134
-
135
- const result = runCLI(['-i', 'screen', '--', 'echo', 'hello']);
136
-
137
- // The output should contain the screen session name (in format screen-timestamp-random)
138
- // Check that the session UUID is displayed
139
- assert.ok(
140
- result.stdout.includes('│ session'),
141
- 'Should display session UUID'
142
- );
143
- // Check that screen isolation info is displayed
144
- assert.ok(
145
- result.stdout.includes('│ isolation screen'),
146
- 'Should display screen isolation'
147
- );
148
- // Check that the actual screen session name is displayed (issue #67 fix)
149
- assert.ok(
150
- result.stdout.includes('│ screen screen-'),
151
- 'Should display actual screen session name for reconnection (issue #67)'
152
- );
153
- });
154
-
155
- it('should display tmux session name when using tmux isolation', async () => {
156
- if (!isCommandAvailable('tmux')) {
157
- console.log(' Skipping: tmux not installed');
158
- return;
159
- }
160
-
161
- const result = runCLI(['-i', 'tmux', '--', 'echo', 'hello']);
162
-
163
- // The output should contain the tmux session name
164
- assert.ok(
165
- result.stdout.includes('│ session'),
166
- 'Should display session UUID'
167
- );
168
- assert.ok(
169
- result.stdout.includes('│ isolation tmux'),
170
- 'Should display tmux isolation'
171
- );
172
- // Check that the actual tmux session name is displayed (issue #67 fix)
173
- assert.ok(
174
- result.stdout.includes('│ tmux tmux-'),
175
- 'Should display actual tmux session name for reconnection (issue #67)'
176
- );
177
- });
178
-
179
- it('should display docker container name when using docker isolation', async () => {
180
- const { canRunLinuxDockerImages } = require('../src/lib/isolation');
181
-
182
- if (!canRunLinuxDockerImages()) {
183
- console.log(
184
- ' Skipping: docker not available or cannot run Linux images'
185
- );
186
- return;
187
- }
188
-
189
- const result = runCLI([
190
- '-i',
191
- 'docker',
192
- '--image',
193
- 'alpine:latest',
194
- '--',
195
- 'echo',
196
- 'hello',
197
- ]);
198
-
199
- // The output should contain the docker container name
200
- assert.ok(
201
- result.stdout.includes('│ session'),
202
- 'Should display session UUID'
203
- );
204
- assert.ok(
205
- result.stdout.includes('│ isolation docker'),
206
- 'Should display docker isolation'
207
- );
208
- assert.ok(
209
- result.stdout.includes('│ image alpine:latest'),
210
- 'Should display docker image'
211
- );
212
- // Check that the actual container name is displayed (issue #67 fix)
213
- assert.ok(
214
- result.stdout.includes('│ container docker-'),
215
- 'Should display actual container name for reconnection (issue #67)'
216
- );
217
- });
218
- });
@@ -1,164 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * Tests for Docker auto-remove container feature
4
- */
5
-
6
- const { describe, it } = require('node:test');
7
- const assert = require('assert');
8
- const { isCommandAvailable } = require('../src/lib/isolation');
9
- const { runInDocker } = require('../src/lib/isolation');
10
- const { execSync } = require('child_process');
11
-
12
- // Helper to wait for a condition with timeout
13
- async function waitFor(conditionFn, timeout = 5000, interval = 100) {
14
- const startTime = Date.now();
15
- while (Date.now() - startTime < timeout) {
16
- if (conditionFn()) {
17
- return true;
18
- }
19
- await new Promise((resolve) => setTimeout(resolve, interval));
20
- }
21
- return false;
22
- }
23
-
24
- // Use the canRunLinuxDockerImages function from isolation module
25
- // to properly detect if Linux containers can run (handles Windows containers mode)
26
- const { canRunLinuxDockerImages } = require('../src/lib/isolation');
27
-
28
- describe('Docker Auto-Remove Container Feature', () => {
29
- // These tests verify the --auto-remove-docker-container option
30
- // which automatically removes the container after exit (disabled by default)
31
-
32
- describe('auto-remove enabled', () => {
33
- it('should automatically remove container when autoRemoveDockerContainer is true', async () => {
34
- if (!canRunLinuxDockerImages()) {
35
- console.log(
36
- ' Skipping: docker not available, daemon not running, or Linux containers not supported'
37
- );
38
- return;
39
- }
40
-
41
- const containerName = `test-autoremove-${Date.now()}`;
42
-
43
- // Run command with autoRemoveDockerContainer enabled
44
- const result = await runInDocker('echo "test" && sleep 0.5', {
45
- image: 'alpine:latest',
46
- session: containerName,
47
- detached: true,
48
- keepAlive: false,
49
- autoRemoveDockerContainer: true,
50
- });
51
-
52
- assert.strictEqual(result.success, true);
53
- assert.ok(
54
- result.message.includes('automatically removed'),
55
- 'Message should indicate auto-removal'
56
- );
57
-
58
- // Wait for container to finish and be removed
59
- const containerRemoved = await waitFor(() => {
60
- try {
61
- execSync(`docker inspect -f '{{.State.Status}}' ${containerName}`, {
62
- encoding: 'utf8',
63
- stdio: ['pipe', 'pipe', 'pipe'],
64
- });
65
- return false; // Container still exists
66
- } catch {
67
- return true; // Container does not exist (removed)
68
- }
69
- }, 10000);
70
-
71
- assert.ok(
72
- containerRemoved,
73
- 'Container should be automatically removed after exit with --auto-remove-docker-container'
74
- );
75
-
76
- // Double-check with docker ps -a that container is completely removed
77
- try {
78
- const allContainers = execSync('docker ps -a', {
79
- encoding: 'utf8',
80
- stdio: ['pipe', 'pipe', 'pipe'],
81
- });
82
- assert.ok(
83
- !allContainers.includes(containerName),
84
- 'Container should NOT appear in docker ps -a (completely removed)'
85
- );
86
- console.log(
87
- ' ✓ Docker container auto-removed after exit (filesystem not preserved)'
88
- );
89
- } catch (err) {
90
- assert.fail(`Failed to verify container removal: ${err.message}`);
91
- }
92
-
93
- // No cleanup needed - container should already be removed
94
- });
95
- });
96
-
97
- describe('auto-remove disabled (default)', () => {
98
- it('should preserve container filesystem by default (without autoRemoveDockerContainer)', async () => {
99
- if (!canRunLinuxDockerImages()) {
100
- console.log(
101
- ' Skipping: docker not available, daemon not running, or Linux containers not supported'
102
- );
103
- return;
104
- }
105
-
106
- const containerName = `test-preserve-${Date.now()}`;
107
-
108
- // Run command without autoRemoveDockerContainer
109
- const result = await runInDocker('echo "test" && sleep 0.1', {
110
- image: 'alpine:latest',
111
- session: containerName,
112
- detached: true,
113
- keepAlive: false,
114
- autoRemoveDockerContainer: false,
115
- });
116
-
117
- assert.strictEqual(result.success, true);
118
- assert.ok(
119
- result.message.includes('filesystem will be preserved'),
120
- 'Message should indicate filesystem preservation'
121
- );
122
-
123
- // Wait for container to exit
124
- await waitFor(() => {
125
- try {
126
- const status = execSync(
127
- `docker inspect -f '{{.State.Status}}' ${containerName}`,
128
- {
129
- encoding: 'utf8',
130
- stdio: ['pipe', 'pipe', 'pipe'],
131
- }
132
- ).trim();
133
- return status === 'exited';
134
- } catch {
135
- return false;
136
- }
137
- }, 10000);
138
-
139
- // Container should still exist (in exited state)
140
- try {
141
- const allContainers = execSync('docker ps -a', {
142
- encoding: 'utf8',
143
- stdio: ['pipe', 'pipe', 'pipe'],
144
- });
145
- assert.ok(
146
- allContainers.includes(containerName),
147
- 'Container should appear in docker ps -a (filesystem preserved)'
148
- );
149
- console.log(
150
- ' ✓ Docker container filesystem preserved by default (can be re-entered)'
151
- );
152
- } catch (err) {
153
- assert.fail(`Failed to verify container preservation: ${err.message}`);
154
- }
155
-
156
- // Clean up
157
- try {
158
- execSync(`docker rm -f ${containerName}`, { stdio: 'ignore' });
159
- } catch {
160
- // Ignore cleanup errors
161
- }
162
- });
163
- });
164
- });
@@ -1,34 +0,0 @@
1
- import { describe, expect, it } from 'bun:test';
2
- import { releaseName, releaseTag } from '../../scripts/release-name.mjs';
3
-
4
- describe('releaseTag', () => {
5
- it('uses plain "v${version}" when no prefix is given', () => {
6
- expect(releaseTag('0.25.4')).toBe('v0.25.4');
7
- expect(releaseTag('0.25.4', '')).toBe('v0.25.4');
8
- });
9
-
10
- it('prepends known language prefixes', () => {
11
- expect(releaseTag('0.25.4', 'js-')).toBe('js-v0.25.4');
12
- expect(releaseTag('0.14.0', 'rust-')).toBe('rust-v0.14.0');
13
- });
14
-
15
- it('passes arbitrary prefixes through', () => {
16
- expect(releaseTag('1.0.0', 'api-')).toBe('api-v1.0.0');
17
- });
18
- });
19
-
20
- describe('releaseName', () => {
21
- it('returns bare version when prefix is empty (preserves pre-issue-108 behaviour)', () => {
22
- expect(releaseName('0.25.4')).toBe('0.25.4');
23
- expect(releaseName('0.25.4', '')).toBe('0.25.4');
24
- });
25
-
26
- it('decorates known language prefixes with human titles', () => {
27
- expect(releaseName('0.25.4', 'js-')).toBe('[JavaScript] 0.25.4');
28
- expect(releaseName('0.14.0', 'rust-')).toBe('[Rust] 0.14.0');
29
- });
30
-
31
- it('falls back to "${prefix}${version}" for unknown prefixes', () => {
32
- expect(releaseName('1.0.0', 'api-')).toBe('api-1.0.0');
33
- });
34
- });
File without changes