@kahitsan/plugin-sdk 0.2.0 → 0.3.0-staging.41
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.mjs +52 -0
- package/dist/index.js +1 -1
- package/package.json +7 -2
- package/src/dev/dev-assets.ts +156 -0
- package/src/dev/dev-host.ts +194 -0
- package/src/dev/dev-kernel.ts +499 -0
- package/src/dev/preload.ts +61 -0
- package/src/dev/sqlite-pool.ts +358 -0
package/bin/cli.mjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// @kahitsan/plugin-sdk CLI — the dev toolkit launcher (Vision §5.1, K3/K4).
|
|
3
|
+
//
|
|
4
|
+
// npx @kahitsan/plugin-sdk <pluginDir> [<pluginDir> …] ← headline form
|
|
5
|
+
// npx @kahitsan/plugin-sdk toolkit <pluginDir> … ← alias (back-compat)
|
|
6
|
+
//
|
|
7
|
+
// Boots the dev-kernel mediator + each plugin on Bun (local SQLite + a synthetic
|
|
8
|
+
// logged-in admin) entirely from the INSTALLED package — no kernel source required.
|
|
9
|
+
// Pass several plugin dirs to exercise the CONTRACT between plugins (does B expose
|
|
10
|
+
// the method A consumes?) locally — no kernel, no Postgres. The harness is Bun-only,
|
|
11
|
+
// so the launcher re-execs under Bun; install it from https://bun.sh.
|
|
12
|
+
import { spawn } from "node:child_process";
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
14
|
+
import { dirname, join } from "node:path";
|
|
15
|
+
|
|
16
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
17
|
+
let args = process.argv.slice(2);
|
|
18
|
+
// `toolkit` is an optional leading verb (kept for back-compat); the headline form
|
|
19
|
+
// takes plugin dirs directly, so a global `npx @kahitsan/plugin-sdk ./a ./b` works.
|
|
20
|
+
if (args[0] === "toolkit") args = args.slice(1);
|
|
21
|
+
const wantsHelp = args.includes("-h") || args.includes("--help");
|
|
22
|
+
const dirs = args.filter((a) => !a.startsWith("-"));
|
|
23
|
+
|
|
24
|
+
if (dirs.length === 0 || wantsHelp) {
|
|
25
|
+
const out = wantsHelp ? console.log : console.error;
|
|
26
|
+
out("usage: npx @kahitsan/plugin-sdk <pluginDir> [<pluginDir> …]");
|
|
27
|
+
out("");
|
|
28
|
+
out(" Boots the local dev toolkit — a dev-kernel mediator + each plugin on SQLite");
|
|
29
|
+
out(" + a synthetic logged-in admin, all from this installed package (no kernel");
|
|
30
|
+
out(" source). Load several plugins at once to exercise their cross-plugin calls:");
|
|
31
|
+
out("");
|
|
32
|
+
out(" npx @kahitsan/plugin-sdk ./kplugin_transactions ./kplugin_payees");
|
|
33
|
+
out("");
|
|
34
|
+
out(" Requires Bun (https://bun.sh). Ctrl-C stops every plugin.");
|
|
35
|
+
process.exit(wantsHelp ? 0 : 2);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// The harness ships as Bun source next to the package root (src/dev/), reachable from
|
|
39
|
+
// the published package without any kernel checkout. dev-host.ts takes N plugin dirs.
|
|
40
|
+
const devHost = join(here, "..", "src", "dev", "dev-host.ts");
|
|
41
|
+
const child = spawn("bun", [devHost, ...dirs], { stdio: "inherit" });
|
|
42
|
+
child.on("error", (err) => {
|
|
43
|
+
if (err && err.code === "ENOENT") {
|
|
44
|
+
console.error(
|
|
45
|
+
"The Hilinga plugin toolkit requires Bun (https://bun.sh) — install it and retry.",
|
|
46
|
+
);
|
|
47
|
+
process.exit(127);
|
|
48
|
+
}
|
|
49
|
+
console.error(err);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
});
|
|
52
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|