aem-ext-daemon 0.3.5 → 0.3.7

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.
@@ -5,7 +5,7 @@
5
5
  * shell:exec runs a command and returns the full output.
6
6
  */
7
7
  import type { DaemonConnection } from "../connection.js";
8
- /** Run a shell command synchronously and return stdout. */
8
+ /** Run a shell command synchronously and return stdout + stderr. */
9
9
  export declare function exec(command: string, cwd: string): string;
10
10
  /** Check if AIO CLI is installed and return its version. */
11
11
  export declare function checkAio(): string;
@@ -5,6 +5,7 @@
5
5
  * shell:exec runs a command and returns the full output.
6
6
  */
7
7
  import { execSync, spawn } from "node:child_process";
8
+ import fs from "node:fs";
8
9
  import os from "node:os";
9
10
  const EXEC_TIMEOUT = 120_000; // 2 minutes
10
11
  const MAX_BUFFER = 5 * 1024 * 1024; // 5MB
@@ -35,19 +36,31 @@ function getEnhancedEnv() {
35
36
  PATH: `${extraPaths.join(":")}:${currentPath}`,
36
37
  };
37
38
  }
38
- /** Run a shell command synchronously and return stdout. */
39
+ /** Run a shell command synchronously and return stdout + stderr. */
39
40
  export function exec(command, cwd) {
40
41
  if (!command)
41
42
  throw new Error("command is required");
42
- const result = execSync(command, {
43
+ // Ensure the working directory exists locally — the server may have
44
+ // computed the path but only created it on its own filesystem.
45
+ if (!fs.existsSync(cwd)) {
46
+ fs.mkdirSync(cwd, { recursive: true });
47
+ }
48
+ // Redirect stderr to stdout so we capture everything, and ensure
49
+ // no interactive prompts leak to the daemon terminal.
50
+ // Also set CI=true and TERM=dumb so CLIs skip interactive prompts.
51
+ const wrappedCommand = `${command} 2>&1`;
52
+ const result = execSync(wrappedCommand, {
43
53
  cwd,
44
54
  timeout: EXEC_TIMEOUT,
45
55
  maxBuffer: MAX_BUFFER,
46
56
  encoding: "utf-8",
47
57
  shell: getUserShell(),
48
- env: getEnhancedEnv(),
49
- // Pipe all stdio so interactive prompts don't bleed into the daemon terminal.
50
- // stdin is /dev/null so commands that prompt for input fail fast instead of hanging.
58
+ env: {
59
+ ...getEnhancedEnv(),
60
+ CI: "true",
61
+ TERM: "dumb",
62
+ NO_COLOR: "1",
63
+ },
51
64
  stdio: ["pipe", "pipe", "pipe"],
52
65
  });
53
66
  return result;
@@ -77,6 +90,9 @@ export function checkAio() {
77
90
  */
78
91
  export function runAio(args, cwd, requestId, connection) {
79
92
  return new Promise((resolve, reject) => {
93
+ if (!fs.existsSync(cwd)) {
94
+ fs.mkdirSync(cwd, { recursive: true });
95
+ }
80
96
  const child = spawn("aio", args, {
81
97
  cwd,
82
98
  shell: getUserShell(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aem-ext-daemon",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Local daemon for AEM Extension Builder — connects your machine to the cloud UI",
5
5
  "type": "module",
6
6
  "bin": {