aem-ext-daemon 0.3.1 → 0.3.3

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.
@@ -13,6 +13,8 @@ export declare function browse(dirPath: string, showHidden?: boolean): string;
13
13
  export declare function roots(): string;
14
14
  /** Read a file and return its content. */
15
15
  export declare function readFile(filePath: string): string;
16
+ /** Create a directory (and parents) if it doesn't exist. */
17
+ export declare function mkdir(dirPath: string): string;
16
18
  /** Write content to a file. Creates parent directories if needed. */
17
19
  export declare function writeFile(filePath: string, content: string): string;
18
20
  /** Recursive directory listing up to a max depth. */
@@ -53,6 +53,11 @@ export function readFile(filePath) {
53
53
  }
54
54
  return fs.readFileSync(filePath, "utf-8");
55
55
  }
56
+ /** Create a directory (and parents) if it doesn't exist. */
57
+ export function mkdir(dirPath) {
58
+ fs.mkdirSync(dirPath, { recursive: true });
59
+ return JSON.stringify({ created: true, path: dirPath });
60
+ }
56
61
  /** Write content to a file. Creates parent directories if needed. */
57
62
  export function writeFile(filePath, content) {
58
63
  const dir = path.dirname(filePath);
@@ -5,8 +5,35 @@
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 os from "node:os";
8
9
  const EXEC_TIMEOUT = 120_000; // 2 minutes
9
10
  const MAX_BUFFER = 5 * 1024 * 1024; // 5MB
11
+ /** Resolve the user's login shell (falls back to /bin/sh). */
12
+ function getUserShell() {
13
+ return process.env.SHELL || "/bin/sh";
14
+ }
15
+ /**
16
+ * Build a PATH that includes common tool locations.
17
+ * npx runs with a minimal env, so tools like git from Homebrew
18
+ * or nvm-managed node may not be on the default PATH.
19
+ */
20
+ function getEnhancedEnv() {
21
+ const home = os.homedir();
22
+ const extraPaths = [
23
+ "/usr/local/bin",
24
+ "/opt/homebrew/bin",
25
+ "/opt/homebrew/sbin",
26
+ `${home}/.nvm/current/bin`,
27
+ `${home}/.volta/bin`,
28
+ `${home}/.cargo/bin`,
29
+ "/usr/local/git/bin",
30
+ ];
31
+ const currentPath = process.env.PATH || "/usr/bin:/bin";
32
+ return {
33
+ ...process.env,
34
+ PATH: `${extraPaths.join(":")}:${currentPath}`,
35
+ };
36
+ }
10
37
  /** Run a shell command synchronously and return stdout. */
11
38
  export function exec(command, cwd) {
12
39
  if (!command)
@@ -16,7 +43,8 @@ export function exec(command, cwd) {
16
43
  timeout: EXEC_TIMEOUT,
17
44
  maxBuffer: MAX_BUFFER,
18
45
  encoding: "utf-8",
19
- shell: "/bin/sh",
46
+ shell: getUserShell(),
47
+ env: getEnhancedEnv(),
20
48
  });
21
49
  return result;
22
50
  }
@@ -26,7 +54,8 @@ export function checkAio() {
26
54
  const version = execSync("aio --version", {
27
55
  timeout: 10_000,
28
56
  encoding: "utf-8",
29
- shell: "/bin/sh",
57
+ shell: getUserShell(),
58
+ env: getEnhancedEnv(),
30
59
  }).trim();
31
60
  return JSON.stringify({ installed: true, version });
32
61
  }
@@ -46,8 +75,8 @@ export function runAio(args, cwd, requestId, connection) {
46
75
  return new Promise((resolve, reject) => {
47
76
  const child = spawn("aio", args, {
48
77
  cwd,
49
- shell: true,
50
- env: { ...process.env },
78
+ shell: getUserShell(),
79
+ env: getEnhancedEnv(),
51
80
  });
52
81
  let stdout = "";
53
82
  let stderr = "";
@@ -41,6 +41,12 @@ export async function dispatch(command, payload, connection) {
41
41
  : getWorkspaceRoot();
42
42
  return fsCap.browse(target, payload.showHidden);
43
43
  }
44
+ case "fs:mkdir": {
45
+ const dirPath = payload.path;
46
+ if (!dirPath || !path.isAbsolute(dirPath))
47
+ throw new Error("Absolute path is required");
48
+ return fsCap.mkdir(dirPath);
49
+ }
44
50
  case "fs:read": {
45
51
  const filePath = validatePath(payload.path);
46
52
  return fsCap.readFile(filePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aem-ext-daemon",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Local daemon for AEM Extension Builder — connects your machine to the cloud UI",
5
5
  "type": "module",
6
6
  "bin": {