create-metaclaw 3.3.1 → 3.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/create-metaclaw.mjs +26 -18
- package/package.json +1 -1
package/bin/create-metaclaw.mjs
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { execFileSync } from "child_process";
|
|
3
2
|
import { fileURLToPath } from "url";
|
|
4
3
|
import { dirname, join } from "path";
|
|
5
|
-
import { existsSync } from "fs";
|
|
6
4
|
|
|
7
5
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
const
|
|
9
|
-
const entry = join(root, "installer", "index.ts");
|
|
6
|
+
const entry = join(__dirname, "..", "installer", "index.ts");
|
|
10
7
|
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
8
|
+
// Use tsx's programmatic API — works regardless of where .bin lands
|
|
9
|
+
import("tsx/esm/api").then(({ register }) => {
|
|
10
|
+
register();
|
|
11
|
+
import(new URL(`file://${entry.replace(/\\/g, "/")}`).href);
|
|
12
|
+
}).catch(() => {
|
|
13
|
+
// Fallback: spawn tsx as a child process
|
|
14
|
+
import("child_process").then(({ execFileSync }) => {
|
|
15
|
+
import("fs").then(({ existsSync }) => {
|
|
16
|
+
const root = join(__dirname, "..");
|
|
17
|
+
const places = [
|
|
18
|
+
join(root, "node_modules", ".bin", "tsx.cmd"),
|
|
19
|
+
join(root, "node_modules", ".bin", "tsx"),
|
|
20
|
+
join(root, "..", ".bin", "tsx.cmd"),
|
|
21
|
+
join(root, "..", ".bin", "tsx"),
|
|
22
|
+
];
|
|
23
|
+
const tsx = places.find(p => existsSync(p)) || "tsx";
|
|
24
|
+
try {
|
|
25
|
+
execFileSync(tsx, [entry], { stdio: "inherit", cwd: root, shell: tsx.endsWith(".cmd") });
|
|
26
|
+
} catch (e) {
|
|
27
|
+
console.error("Failed to start MetaClaw. Make sure tsx is installed: npm install -g tsx");
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|