@appchy/jarvis 0.1.31 → 0.1.32
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-dev.mjs +40 -0
- package/dist/bin.js +16 -3
- package/dist/bin.js.map +1 -1
- package/package.json +7 -6
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Jarvis CLI — Dev Launcher
|
|
5
|
+
*
|
|
6
|
+
* Always runs `tsx src/bin.ts` against the source tree so the dev binary
|
|
7
|
+
* can coexist on PATH with the prod `jarvis` (which runs `dist/bin.js`).
|
|
8
|
+
*
|
|
9
|
+
* Errors out cleanly if the source tree isn't present (e.g. someone
|
|
10
|
+
* installed the published prod package and got `jarvis-dev` along for
|
|
11
|
+
* the ride — there's nothing for it to run).
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { fileURLToPath } from "url";
|
|
15
|
+
import { dirname, join } from "path";
|
|
16
|
+
import { existsSync } from "fs";
|
|
17
|
+
import { execFileSync } from "child_process";
|
|
18
|
+
|
|
19
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
20
|
+
const root = join(__dirname, "..");
|
|
21
|
+
const srcEntry = join(root, "src", "bin.ts");
|
|
22
|
+
const tsxBin = join(root, "node_modules", ".bin", "tsx");
|
|
23
|
+
|
|
24
|
+
if (!existsSync(srcEntry)) {
|
|
25
|
+
console.error(
|
|
26
|
+
"jarvis-dev requires the source tree (apps/cli/src/bin.ts).\n" +
|
|
27
|
+
"Run it from a checkout of the repo, or use `jarvis` (prod) instead.",
|
|
28
|
+
);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
execFileSync(tsxBin, [srcEntry, ...process.argv.slice(2)], {
|
|
34
|
+
stdio: "inherit",
|
|
35
|
+
cwd: process.cwd(),
|
|
36
|
+
env: { ...process.env, NODE_NO_WARNINGS: "1" },
|
|
37
|
+
});
|
|
38
|
+
} catch (err) {
|
|
39
|
+
process.exit(err.status ?? 1);
|
|
40
|
+
}
|
package/dist/bin.js
CHANGED
|
@@ -29586,9 +29586,22 @@ async function runInit(options = {}) {
|
|
|
29586
29586
|
try {
|
|
29587
29587
|
console.log("\n Jarvis local agent setup");
|
|
29588
29588
|
console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n");
|
|
29589
|
-
|
|
29590
|
-
|
|
29591
|
-
|
|
29589
|
+
const mode = isDev() ? "dev" : "prod";
|
|
29590
|
+
console.log(` \u25B8 Pairing this machine [${mode} \u2192 ${appUrl}]`);
|
|
29591
|
+
const pairUrl = `${appUrl}/api/v1/envs/pair`;
|
|
29592
|
+
let create;
|
|
29593
|
+
try {
|
|
29594
|
+
create = await fetch(pairUrl, { method: "POST" });
|
|
29595
|
+
} catch (err) {
|
|
29596
|
+
const cause = err instanceof Error ? err.cause : void 0;
|
|
29597
|
+
const errCode = cause?.code ? ` (${cause.code})` : "";
|
|
29598
|
+
const hint = mode === "dev" ? " Is the local web running on :3000? Try `pnpm dev` from the repo root." : " Check connectivity to https://jarvis.appchy.com.";
|
|
29599
|
+
throw new Error(
|
|
29600
|
+
`Pair request failed${errCode}: ${pairUrl}
|
|
29601
|
+
${hint}`
|
|
29602
|
+
);
|
|
29603
|
+
}
|
|
29604
|
+
if (!create.ok) throw new Error(`Failed to start pairing at ${pairUrl} (${create.status})`);
|
|
29592
29605
|
const body = await create.json();
|
|
29593
29606
|
const code = body.code;
|
|
29594
29607
|
const url2 = absolutizeUrl(body.url, code, appUrl);
|