aem-ext-daemon 0.3.0 → 0.3.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/bin/cli.js +8 -2
- package/dist/capabilities/fs.d.ts +2 -0
- package/dist/capabilities/fs.js +5 -0
- package/dist/daemon.js +7 -1
- package/dist/dispatcher.js +6 -0
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -10,9 +10,15 @@
|
|
|
10
10
|
* npx aem-ext-daemon --reset # clear identity and re-pair
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import fs from "node:fs";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
13
16
|
import { Daemon } from "../dist/daemon.js";
|
|
14
17
|
import { resetIdentity, getConfigPath, getRailwayUrl } from "../dist/identity.js";
|
|
15
18
|
|
|
19
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
20
|
+
const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, "..", "package.json"), "utf-8"));
|
|
21
|
+
|
|
16
22
|
const DEFAULT_SERVER = "https://adobe-extension-builder-production.up.railway.app";
|
|
17
23
|
|
|
18
24
|
function parseArgs(argv) {
|
|
@@ -61,13 +67,13 @@ if (args.help) {
|
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
if (args.version) {
|
|
64
|
-
console.log(
|
|
70
|
+
console.log(pkg.version);
|
|
65
71
|
process.exit(0);
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
if (args.reset) {
|
|
69
75
|
resetIdentity();
|
|
70
|
-
console.log("
|
|
76
|
+
console.log(" \u2713 Identity reset. Will re-pair on next connection.");
|
|
71
77
|
console.log("");
|
|
72
78
|
}
|
|
73
79
|
|
|
@@ -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. */
|
package/dist/capabilities/fs.js
CHANGED
|
@@ -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);
|
package/dist/daemon.js
CHANGED
|
@@ -10,11 +10,17 @@
|
|
|
10
10
|
* 6. Dispatch incoming tool_exec messages to capabilities
|
|
11
11
|
*/
|
|
12
12
|
import os from "node:os";
|
|
13
|
+
import fs from "node:fs";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
13
16
|
import { DaemonConnection } from "./connection.js";
|
|
14
17
|
import { ensureIdentity, getWorkspaceRoot, setWorkspaceRoot } from "./identity.js";
|
|
15
18
|
import { generatePairCode, displayPairCode } from "./pairing.js";
|
|
16
19
|
import { dispatch } from "./dispatcher.js";
|
|
17
|
-
|
|
20
|
+
// Read version from package.json so it stays in sync automatically
|
|
21
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
22
|
+
const pkgPath = path.resolve(__dirname, "..", "package.json");
|
|
23
|
+
const VERSION = JSON.parse(fs.readFileSync(pkgPath, "utf-8")).version || "0.0.0";
|
|
18
24
|
export class Daemon {
|
|
19
25
|
connection;
|
|
20
26
|
identity;
|
package/dist/dispatcher.js
CHANGED
|
@@ -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);
|