forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
43 lines (40 loc) · 1.26 KB
/
Copy pathutils.ts
File metadata and controls
43 lines (40 loc) · 1.26 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
import chalk from "chalk";
export function flattenObject(
obj: Record<string, any>,
parentKey = "",
res: Record<string, any> = {},
): Record<string, any> {
for (let key in obj) {
const propName = parentKey ? `${parentKey}.${key}` : key;
if (typeof obj[key] === "object" && obj[key] !== null) {
flattenObject(obj[key], propName, res);
} else {
res[propName] = obj[key];
}
}
return res;
}
export function printSecurityNotice(advisory: {
advisory: string | null;
message: string;
severity: "low" | "medium" | "high" | "none";
}) {
const severityColor =
{
low: chalk.blue,
medium: chalk.yellow,
high: chalk.red,
}[advisory.severity.toLowerCase()] || chalk.white;
console.log();
console.log(
`━━━━━━━━━━━━━━━━━━ ${chalk.bold(`CopilotKit`)} ━━━━━━━━━━━━━━━━━━`,
);
console.log();
console.log(
`${chalk.bold(`Severity: ${severityColor(advisory.severity.toUpperCase())}`)}`,
);
console.log();
console.log(`${chalk.bold(advisory.message)}`);
console.log();
console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`);
}