forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-prereqs.mjs
More file actions
83 lines (76 loc) · 2.2 KB
/
Copy pathcheck-prereqs.mjs
File metadata and controls
83 lines (76 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env node
import { spawnSync } from "node:child_process";
const PREREQS = {
install: [
{
command: "uv",
label: "uv",
url: "https://docs.astral.sh/uv/getting-started/installation/",
reason:
"Required to install the Python agent's dependencies via `uv sync`.",
},
],
dev: [
{
command: "uv",
label: "uv",
url: "https://docs.astral.sh/uv/getting-started/installation/",
reason: "Required to run the LangGraph Python agent.",
},
{
command: "docker",
label: "Docker",
url: "https://docs.docker.com/get-started/get-docker/",
reason:
"Required to start the Postgres, Redis, and Intelligence services.",
check: (cmd) => {
if (!hasCommand(cmd)) return "missing";
const probe = spawnSync(cmd, ["info"], { stdio: "ignore" });
return probe.status === 0 ? "ok" : "not-running";
},
},
],
};
function hasCommand(cmd) {
const probe = spawnSync(
process.platform === "win32" ? "where" : "which",
[cmd],
{ stdio: "ignore" },
);
return probe.status === 0;
}
const phase = process.argv[2];
const list = PREREQS[phase];
if (!list) {
console.error(`check-prereqs: unknown phase "${phase}"`);
process.exit(2);
}
const failures = [];
for (const prereq of list) {
const status = prereq.check
? prereq.check(prereq.command)
: hasCommand(prereq.command)
? "ok"
: "missing";
if (status !== "ok") failures.push({ ...prereq, status });
}
if (failures.length === 0) process.exit(0);
const red = (s) => `\x1b[31m${s}\x1b[0m`;
const bold = (s) => `\x1b[1m${s}\x1b[0m`;
const dim = (s) => `\x1b[2m${s}\x1b[0m`;
console.error("");
console.error(red(bold("✖ Missing prerequisites for this template")));
console.error("");
for (const f of failures) {
const headline =
f.status === "not-running"
? `${f.label} is installed but does not appear to be running.`
: `${f.label} is not installed.`;
console.error(` • ${bold(headline)}`);
console.error(` ${f.reason}`);
console.error(` Install / docs: ${f.url}`);
console.error("");
}
console.error(dim("After resolving the items above, re-run the command."));
console.error("");
process.exit(1);