@appchy/jarvis 0.1.31 → 0.1.33
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/bin/jarvis.mjs +21 -23
- package/dist/bin.js +28 -9
- package/dist/bin.js.map +1 -1
- package/package.json +6 -5
|
@@ -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/bin/jarvis.mjs
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Jarvis CLI Launcher
|
|
4
|
+
* Jarvis CLI — Prod Launcher
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Always runs the bundled `dist/bin.js` (production: hits jarvis.appchy.com).
|
|
7
|
+
* For source-tree development, use `jarvis-dev` instead — it skips the
|
|
8
|
+
* dist/ check and always runs `tsx src/bin.ts` against the live source.
|
|
9
|
+
*
|
|
10
|
+
* The previous version of this launcher auto-detected dev vs prod based on
|
|
11
|
+
* whether `src/bin.ts` existed. That meant invoking `jarvis` from a source
|
|
12
|
+
* checkout silently flipped to dev mode against localhost — not what users
|
|
13
|
+
* who installed `@appchy/jarvis` globally expect. The split bins
|
|
14
|
+
* (`jarvis` / `jarvis-dev`) make the choice explicit and irreversible.
|
|
8
15
|
*/
|
|
9
16
|
|
|
10
17
|
import { fileURLToPath } from "url";
|
|
@@ -12,27 +19,18 @@ import { dirname, join } from "path";
|
|
|
12
19
|
import { existsSync } from "fs";
|
|
13
20
|
|
|
14
21
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
15
|
-
const
|
|
16
|
-
const srcEntry = join(root, "src", "bin.ts");
|
|
17
|
-
const distEntry = join(root, "dist", "bin.js");
|
|
22
|
+
const distEntry = join(__dirname, "..", "dist", "bin.js");
|
|
18
23
|
|
|
19
|
-
if (existsSync(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
env: { ...process.env, NODE_NO_WARNINGS: "1" },
|
|
28
|
-
});
|
|
29
|
-
} catch (err) {
|
|
30
|
-
process.exit(err.status ?? 1);
|
|
24
|
+
if (!existsSync(distEntry)) {
|
|
25
|
+
const isSourceCheckout = existsSync(join(__dirname, "..", "src", "bin.ts"));
|
|
26
|
+
console.error("Error: dist/bin.js not found.");
|
|
27
|
+
if (isSourceCheckout) {
|
|
28
|
+
console.error(" This is a source checkout. Use `jarvis-dev` for dev work,");
|
|
29
|
+
console.error(" or run `pnpm -C apps/cli build` to produce a prod bundle.");
|
|
30
|
+
} else {
|
|
31
|
+
console.error(" The package may be corrupted. Reinstall with `pnpm i -g @appchy/jarvis`.");
|
|
31
32
|
}
|
|
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
33
|
process.exit(1);
|
|
38
34
|
}
|
|
35
|
+
|
|
36
|
+
await import(distEntry);
|
package/dist/bin.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRequire as __cr } from 'module'; const require = __cr(import.meta.url);
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -29029,13 +29030,18 @@ import { fileURLToPath } from "url";
|
|
|
29029
29030
|
var __filename = fileURLToPath(import.meta.url);
|
|
29030
29031
|
var __dirname = path.dirname(__filename);
|
|
29031
29032
|
function isDev() {
|
|
29032
|
-
|
|
29033
|
-
|
|
29034
|
-
|
|
29035
|
-
|
|
29036
|
-
|
|
29037
|
-
|
|
29033
|
+
const candidates = [
|
|
29034
|
+
path.join(__dirname, "env.json"),
|
|
29035
|
+
path.join(__dirname, "..", "env.json")
|
|
29036
|
+
];
|
|
29037
|
+
for (const envFile of candidates) {
|
|
29038
|
+
try {
|
|
29039
|
+
const data = JSON.parse(fs.readFileSync(envFile, "utf-8"));
|
|
29040
|
+
return data.env === "development";
|
|
29041
|
+
} catch {
|
|
29042
|
+
}
|
|
29038
29043
|
}
|
|
29044
|
+
return false;
|
|
29039
29045
|
}
|
|
29040
29046
|
var PROD_APP_URL = "https://jarvis.appchy.com";
|
|
29041
29047
|
var DEV_APP_URL = "http://localhost:3000";
|
|
@@ -29586,9 +29592,22 @@ async function runInit(options = {}) {
|
|
|
29586
29592
|
try {
|
|
29587
29593
|
console.log("\n Jarvis local agent setup");
|
|
29588
29594
|
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
|
-
|
|
29595
|
+
const mode = isDev() ? "dev" : "prod";
|
|
29596
|
+
console.log(` \u25B8 Pairing this machine [${mode} \u2192 ${appUrl}]`);
|
|
29597
|
+
const pairUrl = `${appUrl}/api/v1/envs/pair`;
|
|
29598
|
+
let create;
|
|
29599
|
+
try {
|
|
29600
|
+
create = await fetch(pairUrl, { method: "POST" });
|
|
29601
|
+
} catch (err) {
|
|
29602
|
+
const cause = err instanceof Error ? err.cause : void 0;
|
|
29603
|
+
const errCode = cause?.code ? ` (${cause.code})` : "";
|
|
29604
|
+
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.";
|
|
29605
|
+
throw new Error(
|
|
29606
|
+
`Pair request failed${errCode}: ${pairUrl}
|
|
29607
|
+
${hint}`
|
|
29608
|
+
);
|
|
29609
|
+
}
|
|
29610
|
+
if (!create.ok) throw new Error(`Failed to start pairing at ${pairUrl} (${create.status})`);
|
|
29592
29611
|
const body = await create.json();
|
|
29593
29612
|
const code = body.code;
|
|
29594
29613
|
const url2 = absolutizeUrl(body.url, code, appUrl);
|