aem-ext-daemon 0.1.0 → 0.2.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Filesystem capabilities — browse, read, write, list.
2
+ * Filesystem capabilities — browse, read, write, list, roots.
3
3
  */
4
4
  export interface BrowseEntry {
5
5
  name: string;
@@ -9,6 +9,8 @@ export interface BrowseEntry {
9
9
  }
10
10
  /** Browse a directory — returns immediate children with metadata. */
11
11
  export declare function browse(dirPath: string, showHidden?: boolean): string;
12
+ /** Return useful root paths for folder browsing (home dir, system root, etc). */
13
+ export declare function roots(): string;
12
14
  /** Read a file and return its content. */
13
15
  export declare function readFile(filePath: string): string;
14
16
  /** Write content to a file. Creates parent directories if needed. */
@@ -1,8 +1,9 @@
1
1
  /**
2
- * Filesystem capabilities — browse, read, write, list.
2
+ * Filesystem capabilities — browse, read, write, list, roots.
3
3
  */
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
6
+ import os from "node:os";
6
7
  /** Browse a directory — returns immediate children with metadata. */
7
8
  export function browse(dirPath, showHidden = false) {
8
9
  const entries = fs.readdirSync(dirPath, { withFileTypes: true });
@@ -24,6 +25,23 @@ export function browse(dirPath, showHidden = false) {
24
25
  });
25
26
  return JSON.stringify(result);
26
27
  }
28
+ /** Return useful root paths for folder browsing (home dir, system root, etc). */
29
+ export function roots() {
30
+ const home = os.homedir();
31
+ const entries = [
32
+ { name: "Home", path: home },
33
+ { name: "Desktop", path: path.join(home, "Desktop") },
34
+ { name: "Documents", path: path.join(home, "Documents") },
35
+ ];
36
+ if (process.platform === "darwin") {
37
+ entries.push({ name: "Volumes", path: "/Volumes" });
38
+ }
39
+ else {
40
+ entries.push({ name: "/", path: "/" });
41
+ }
42
+ // Filter to only existing paths
43
+ return JSON.stringify(entries.filter((e) => fs.existsSync(e.path)));
44
+ }
27
45
  /** Read a file and return its content. */
28
46
  export function readFile(filePath) {
29
47
  if (!fs.existsSync(filePath)) {
@@ -30,9 +30,13 @@ function validatePath(targetPath) {
30
30
  export async function dispatch(command, payload, connection) {
31
31
  switch (command) {
32
32
  // ─── Filesystem ─────────────────────────────────────
33
+ case "fs:roots": {
34
+ return fsCap.roots();
35
+ }
33
36
  case "fs:browse": {
37
+ // fs:browse allows absolute paths for folder picking (not sandboxed to workspace)
34
38
  const target = payload.path
35
- ? validatePath(payload.path)
39
+ ? path.resolve(payload.path)
36
40
  : getWorkspaceRoot();
37
41
  return fsCap.browse(target, payload.showHidden);
38
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aem-ext-daemon",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Local daemon for AEM Extension Builder — connects your machine to the cloud UI",
5
5
  "type": "module",
6
6
  "bin": {