@lumeo_hq/openbooks-doctor 0.1.1 → 0.2.1
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/README.md +18 -0
- package/dist/index.js +15 -4
- package/package.json +2 -2
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -3,3 +3,21 @@
|
|
|
3
3
|
`runDoctor()` checks Node, finds a Python with the Open Books engine, and runs the engine's own diagnostics (providers, model
|
|
4
4
|
integrity, a built-in proven-or-refused self-test). A missing Python or engine comes back as a failed check in the report,
|
|
5
5
|
not as an exception.
|
|
6
|
+
|
|
7
|
+
~~~ts
|
|
8
|
+
import { runDoctor } from "@lumeo_hq/openbooks-doctor";
|
|
9
|
+
|
|
10
|
+
const report = await runDoctor({
|
|
11
|
+
python: process.env.OPENBOOKS_PYTHON,
|
|
12
|
+
deep: false,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
for (const check of report.checks) {
|
|
16
|
+
console.log(check.id, check.status, check.detail, check.fix ?? "");
|
|
17
|
+
}
|
|
18
|
+
if (!report.ok) process.exitCode = 1;
|
|
19
|
+
~~~
|
|
20
|
+
|
|
21
|
+
Use `deep: true` when your runner needs to load the typed heads with the `scan` extra. Use `strict: true` to treat warnings as readiness failures. Keep the Python executable explicit in CI when multiple interpreters are available.
|
|
22
|
+
|
|
23
|
+
[Installation and diagnostics](https://openbooks.lumeo.co.in/docs/installation)
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { EngineError, engineCommand, findEngine, runProcess } from "@lumeo_hq/openbooks-core";
|
|
2
2
|
const MIN_NODE = 20;
|
|
3
|
+
const DOCTOR_STATUSES = new Set(["pass", "warn", "fail", "skip"]);
|
|
4
|
+
function isCheck(value) {
|
|
5
|
+
if (!value || typeof value !== "object")
|
|
6
|
+
return false;
|
|
7
|
+
const item = value;
|
|
8
|
+
return typeof item.id === "string" && typeof item.detail === "string"
|
|
9
|
+
&& typeof item.status === "string" && DOCTOR_STATUSES.has(item.status)
|
|
10
|
+
&& (item.fix === undefined || typeof item.fix === "string");
|
|
11
|
+
}
|
|
3
12
|
function report(checks, strict) {
|
|
4
13
|
const summary = { pass: 0, warn: 0, fail: 0, skip: 0 };
|
|
5
14
|
for (const c of checks)
|
|
@@ -38,14 +47,16 @@ export async function runDoctor(opts = {}) {
|
|
|
38
47
|
if (r.code !== 0 && r.code !== 1) {
|
|
39
48
|
throw new EngineError("engine_fault", `doctor failed (exit ${r.code ?? r.signal}): ${r.stderr.trim().slice(-500)}`);
|
|
40
49
|
}
|
|
41
|
-
let
|
|
50
|
+
let parsed;
|
|
42
51
|
try {
|
|
43
|
-
|
|
52
|
+
parsed = JSON.parse(r.stdout);
|
|
44
53
|
}
|
|
45
54
|
catch {
|
|
46
55
|
throw new EngineError("bad_output", "doctor printed something that is not JSON");
|
|
47
56
|
}
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
const py = parsed;
|
|
58
|
+
if (py?.schema !== "openbooks.doctor.v1" || !Array.isArray(py.checks) || !py.checks.every(isCheck)) {
|
|
59
|
+
throw new EngineError("bad_output", "the Python engine returned an invalid doctor report");
|
|
60
|
+
}
|
|
50
61
|
return report([...checks, ...py.checks], opts.strict ?? false);
|
|
51
62
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumeo_hq/openbooks-doctor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Open Books doctor wrapper: typed access to the Python engine, restricted to the doctor layouts",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -20,6 +20,6 @@
|
|
|
20
20
|
"node": ">=20"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@lumeo_hq/openbooks-core": "0.
|
|
23
|
+
"@lumeo_hq/openbooks-core": "0.2.1"
|
|
24
24
|
}
|
|
25
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