-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreport.ts
54 lines (48 loc) · 1.15 KB
/
report.ts
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
import { green, yellow } from "@kitql/helpers";
import * as p from "@clack/prompts";
export interface CliReport {
typeCouldBeBetter: string[];
sAdded: string[];
}
export const logReport = (
reportKind: "no" | "numbers" | "full",
report: CliReport,
) => {
if (reportKind === "no") {
return;
}
if (reportKind === "full") {
if (report.typeCouldBeBetter.length > 0) {
p.log.info(
`${green(`Type need to be manually typed`)}:
${yellow(report.typeCouldBeBetter.join("\n "))}`,
);
}
if (report.sAdded.length > 0) {
p.log.info(
`${green(`We added an "s" to the key to avoid collision on`)}:
${report.sAdded.join("\n ")}`,
);
}
return;
}
if (reportKind === "numbers") {
if (report.typeCouldBeBetter.length > 0) {
p.log.info(
`${green(`Type need to be manually typed`)}: ${yellow(
report.typeCouldBeBetter.length.toString(),
)}`,
);
}
if (report.sAdded.length > 0) {
p.log.info(
`${green(`We added an "s" to the key to avoid collision on`)}: ${yellow(
report.sAdded.length.toString(),
)}`,
);
}
return;
}
// make sure all reportKinds was exhausted
reportKind satisfies never;
};