-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathconfig.ts
65 lines (62 loc) · 1.81 KB
/
config.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
55
56
57
58
59
60
61
62
63
64
65
import { z } from 'zod';
export const coverageTypeSchema = z.enum(['function', 'branch', 'line']);
export type CoverageType = z.infer<typeof coverageTypeSchema>;
export const coverageResultSchema = z.union([
z.object({
resultsPath: z
.string({
description: 'Path to coverage results for Nx setup.',
})
.includes('lcov'),
pathToProject: z
.string({
description:
'Path from workspace root to project root. Necessary for LCOV reports which provide a relative path.',
})
.optional(),
}),
z
.string({
description: 'Path to coverage results for a single project setup.',
})
.includes('lcov'),
]);
export type CoverageResult = z.infer<typeof coverageResultSchema>;
export const coveragePluginConfigSchema = z.object({
coverageToolCommand: z
.object({
command: z
.string({ description: 'Command to run coverage tool.' })
.min(1),
args: z
.array(z.string(), {
description: 'Arguments to be passed to the coverage tool.',
})
.optional(),
})
.optional(),
coverageTypes: z
.array(coverageTypeSchema, {
description: 'Coverage types measured. Defaults to all available types.',
})
.min(1)
.default(['function', 'branch', 'line']),
reports: z
.array(coverageResultSchema, {
description:
'Path to all code coverage report files. Only LCOV format is supported for now.',
})
.min(1),
perfectScoreThreshold: z
.number({
description:
'Score will be 1 (perfect) for this coverage and above. Score range is 0 - 1.',
})
.gt(0)
.max(1)
.optional(),
});
export type CoveragePluginConfig = z.input<typeof coveragePluginConfigSchema>;
export type FinalCoveragePluginConfig = z.infer<
typeof coveragePluginConfigSchema
>;