@appchy/jarvis 0.1.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.
package/bin/jarvis.mjs ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Jarvis CLI Launcher
5
+ *
6
+ * Dev mode: src/bin.ts exists → run via tsx (TypeScript, hot reload)
7
+ * Prod mode: dist/bin.js exists → run directly with node (bundled, no tsx)
8
+ */
9
+
10
+ import { fileURLToPath } from "url";
11
+ import { dirname, join } from "path";
12
+ import { existsSync } from "fs";
13
+
14
+ const __dirname = dirname(fileURLToPath(import.meta.url));
15
+ const root = join(__dirname, "..");
16
+ const srcEntry = join(root, "src", "bin.ts");
17
+ const distEntry = join(root, "dist", "bin.js");
18
+
19
+ if (existsSync(srcEntry)) {
20
+ // Dev: use tsx to run TypeScript source directly
21
+ const { execFileSync } = await import("child_process");
22
+ const tsxBin = join(root, "node_modules", ".bin", "tsx");
23
+ try {
24
+ execFileSync(tsxBin, [srcEntry, ...process.argv.slice(2)], {
25
+ stdio: "inherit",
26
+ cwd: process.cwd(),
27
+ env: { ...process.env, NODE_NO_WARNINGS: "1" },
28
+ });
29
+ } catch (err) {
30
+ process.exit(err.status ?? 1);
31
+ }
32
+ } else if (existsSync(distEntry)) {
33
+ // Prod: import bundled JS (no tsx needed)
34
+ await import(distEntry);
35
+ } else {
36
+ console.error("Error: No entry point found. Run `pnpm build` first.");
37
+ process.exit(1);
38
+ }