@msareen/knowledge-hub-builder 0.2.2 → 0.2.3
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/AGENTS.md +4 -3
- package/README.md +41 -1
- package/SPEC.md +21 -5
- package/package.json +1 -1
- package/scripts/cli.ts +45 -25
- package/scripts/config.ts +229 -0
- package/scripts/doctor.ts +37 -8
- package/scripts/export.ts +8 -4
- package/scripts/hubs.ts +184 -92
- package/scripts/ingest/folder.ts +2 -1
- package/scripts/ingest/index.ts +21 -13
- package/scripts/init.ts +21 -12
- package/scripts/lib/color.ts +75 -0
- package/scripts/lib/config-check.ts +364 -0
- package/scripts/lib/log.ts +4 -2
- package/scripts/lib/registry.ts +20 -1
- package/scripts/lint.ts +9 -4
- package/scripts/new-bundle.ts +9 -4
- package/scripts/visualize.ts +7 -6
package/scripts/visualize.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { buildGraphData, readConceptFile } from "./lib/graph";
|
|
9
9
|
import { renderGraphPage } from "./lib/graph-page";
|
|
10
10
|
import { takeFlag, takeOpt, rejectUnknownFlags } from "./lib/args";
|
|
11
|
+
import { paint, paintErr } from "./lib/color";
|
|
11
12
|
|
|
12
13
|
const USAGE = "khb visualize [--port N] [--no-open]";
|
|
13
14
|
const argv = process.argv.slice(2);
|
|
@@ -21,8 +22,8 @@ rejectUnknownFlags(argv, USAGE);
|
|
|
21
22
|
// looks like the flag working right up until nothing is listening where you expected.
|
|
22
23
|
const requestedPort = portArg === undefined ? 0 : Number(portArg);
|
|
23
24
|
if (!Number.isInteger(requestedPort) || requestedPort < 0 || requestedPort > 65535) {
|
|
24
|
-
console.error(
|
|
25
|
-
console.error(`Usage: ${USAGE}`);
|
|
25
|
+
console.error(`${paintErr.bad("--port must be a number between 0 and 65535, not:")} ${portArg}`);
|
|
26
|
+
console.error(`Usage: ${paintErr.cmd(USAGE)}`);
|
|
26
27
|
process.exit(1);
|
|
27
28
|
}
|
|
28
29
|
|
|
@@ -76,7 +77,7 @@ try {
|
|
|
76
77
|
server = Bun.serve({ port: requestedPort, fetch: fetchHandler });
|
|
77
78
|
} catch (e) {
|
|
78
79
|
if (requestedPort && (e as { code?: string }).code === "EADDRINUSE") {
|
|
79
|
-
console.warn(`Port ${requestedPort} is busy — picking a free one instead.`);
|
|
80
|
+
console.warn(paintErr.warn(`Port ${requestedPort} is busy — picking a free one instead.`));
|
|
80
81
|
server = Bun.serve({ port: 0, fetch: fetchHandler });
|
|
81
82
|
} else throw e;
|
|
82
83
|
}
|
|
@@ -89,7 +90,7 @@ setInterval(() => {
|
|
|
89
90
|
}, HEARTBEAT_INTERVAL_MS).unref();
|
|
90
91
|
|
|
91
92
|
const url = `http://localhost:${server.port}`;
|
|
92
|
-
console.log(
|
|
93
|
+
console.log(`${paint.head("khb visualize")} → ${paint.cmd(url)} ${paint.dim(`(${summarize(data)})`)}`);
|
|
93
94
|
|
|
94
95
|
// Open the default browser. If that fails the URL is already printed above, so a headless
|
|
95
96
|
// or locked-down box just falls back to copy-paste rather than erroring out.
|
|
@@ -103,7 +104,7 @@ if (!noOpen) {
|
|
|
103
104
|
try {
|
|
104
105
|
Bun.spawn(cmd, { stdout: "ignore", stderr: "ignore" }).unref();
|
|
105
106
|
} catch {
|
|
106
|
-
console.warn("Could not launch a browser — open the URL above yourself.");
|
|
107
|
+
console.warn(paintErr.warn("Could not launch a browser — open the URL above yourself."));
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
|
-
console.log(`The server exits on its own once you close the tab. Ctrl+C also works.`);
|
|
110
|
+
console.log(paint.dim(`The server exits on its own once you close the tab. Ctrl+C also works.`));
|