-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathconfig.ts
More file actions
69 lines (66 loc) · 2.14 KB
/
config.ts
File metadata and controls
69 lines (66 loc) · 2.14 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
import { z } from 'zod';
import { pluginScoreTargetsSchema } from '@code-pushup/models';
import { ALL_COVERAGE_TYPES } from './constants.js';
export const coverageTypeSchema = z
.enum(ALL_COVERAGE_TYPES)
.meta({ title: 'CoverageType' });
export type CoverageType = z.infer<typeof coverageTypeSchema>;
export const coverageResultSchema = z
.union([
z.object({
resultsPath: z
.string()
.includes('lcov')
.meta({ description: 'Path to coverage results for Nx setup.' }),
pathToProject: z
.string()
.meta({
description:
'Path from workspace root to project root. Necessary for LCOV reports which provide a relative path.',
})
.optional(),
}),
z.string().includes('lcov').meta({
description: 'Path to coverage results for a single project setup.',
}),
])
.meta({ title: 'CoverageResult' });
export type CoverageResult = z.infer<typeof coverageResultSchema>;
export const coveragePluginConfigSchema = z
.object({
coverageToolCommand: z
.object({
command: z
.string()
.min(1)
.meta({ description: 'Command to run coverage tool.' }),
args: z.array(z.string()).optional().meta({
description: 'Arguments to be passed to the coverage tool.',
}),
})
.optional(),
continueOnCommandFail: z.boolean().default(true).meta({
description:
'Continue on coverage tool command failure or error. Defaults to true.',
}),
coverageTypes: z
.array(coverageTypeSchema)
.min(1)
.default([...ALL_COVERAGE_TYPES])
.meta({
description:
'Coverage types measured. Defaults to all available types.',
}),
reports: z
.array(coverageResultSchema)
.min(1)
.describe(
'Path to all code coverage report files. Only LCOV format is supported for now.',
),
scoreTargets: pluginScoreTargetsSchema,
})
.meta({ title: 'CoveragePluginConfig' });
export type CoveragePluginConfig = z.input<typeof coveragePluginConfigSchema>;
export type FinalCoveragePluginConfig = z.infer<
typeof coveragePluginConfigSchema
>;