octo-dev 0.4.1 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "octo-dev",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "CLI for monorepo build orchestration, semantic versioning, and local infrastructure management",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -44,6 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "commander": "^13.1.0",
47
+ "execa": "^9.6.1",
47
48
  "ollama": "^0.5.16",
48
49
  "semver": "^7.7.2",
49
50
  "tsx": "^4.19.4",
@@ -55,7 +56,7 @@
55
56
  "@types/semver": "^7.7.0",
56
57
  "fast-check": "^4.1.1",
57
58
  "typescript": "^5.8.3",
58
- "vitest": "^3.2.4"
59
+ "vitest": "^4.1.8"
59
60
  },
60
61
  "engines": {
61
62
  "node": ">=25.0.0"
package/src/cli/index.ts CHANGED
@@ -11,7 +11,7 @@ const program = new Command();
11
11
  program
12
12
  .name('octo')
13
13
  .description('Monorepo build orchestration, versioning, and infrastructure CLI')
14
- .version('0.4.1');
14
+ .version('0.4.2');
15
15
 
16
16
  program
17
17
  .command('init')
@@ -1,4 +1,4 @@
1
- import { spawn } from 'node:child_process';
1
+ import { execaCommand, execa } from 'execa';
2
2
 
3
3
  export interface RunOptions {
4
4
  cwd?: string;
@@ -6,7 +6,7 @@ export interface RunOptions {
6
6
  env?: Record<string, string>;
7
7
  /** When true, inherits stdio so the user can interact (e.g. git password prompts) */
8
8
  interactive?: boolean;
9
- /** When true, runs command through the system shell. Use only for piped commands. */
9
+ /** When true, runs command through the system shell. Use only for piped/complex commands. */
10
10
  shell?: boolean;
11
11
  }
12
12
 
@@ -16,39 +16,31 @@ export interface RunResult {
16
16
  exitCode: number;
17
17
  }
18
18
 
19
- /** Wrapper for child_process.spawn with Promise, timeout, and stdout/stderr capture */
20
- export function run(command: string, args: string[] = [], options: RunOptions = {}): Promise<RunResult> {
19
+ /**
20
+ * Executes a command with args. Powered by execa.
21
+ * Returns stdout, stderr, and exitCode without throwing on non-zero exit.
22
+ */
23
+ export async function run(command: string, args: string[] = [], options: RunOptions = {}): Promise<RunResult> {
21
24
  const { cwd, timeout = 60_000, env, interactive = false, shell = false } = options;
22
25
 
23
- return new Promise((resolve, reject) => {
24
- const child = spawn(command, args, {
25
- cwd,
26
- env: env ? { ...process.env, ...env } : process.env,
27
- shell,
28
- stdio: interactive ? 'inherit' : 'pipe',
29
- });
30
-
31
- let stdout = '';
32
- let stderr = '';
33
-
34
- if (!interactive) {
35
- child.stdout!.on('data', (data: Buffer) => { stdout += data.toString(); });
36
- child.stderr!.on('data', (data: Buffer) => { stderr += data.toString(); });
37
- }
38
-
39
- const timer = setTimeout(() => {
40
- child.kill('SIGTERM');
41
- reject(new Error(`Command timed out after ${timeout}ms: ${command} ${args.join(' ')}`));
42
- }, timeout);
43
-
44
- child.on('close', (code) => {
45
- clearTimeout(timer);
46
- resolve({ stdout, stderr, exitCode: code ?? 1 });
47
- });
48
-
49
- child.on('error', (err) => {
50
- clearTimeout(timer);
51
- reject(err);
52
- });
53
- });
26
+ const execOptions = {
27
+ cwd,
28
+ env: env ? { ...process.env, ...env } : undefined,
29
+ timeout,
30
+ shell,
31
+ reject: false,
32
+ stdin: interactive ? 'inherit' as const : undefined,
33
+ stdout: interactive ? 'inherit' as const : 'pipe' as const,
34
+ stderr: interactive ? 'inherit' as const : 'pipe' as const,
35
+ };
36
+
37
+ const result = shell && args.length === 0
38
+ ? await execaCommand(command, execOptions)
39
+ : await execa(command, args, execOptions);
40
+
41
+ return {
42
+ stdout: result.stdout ?? '',
43
+ stderr: result.stderr ?? '',
44
+ exitCode: result.exitCode ?? 1,
45
+ };
54
46
  }