@code-pushup/coverage-plugin 0.17.0 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/bin.js +3 -2
- package/index.js +14 -7
- package/package.json +3 -43
- package/src/lib/config.d.ts +8 -8
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ Measured coverage types are mapped to Code PushUp audits in the following way
|
|
|
36
36
|
plugins: [
|
|
37
37
|
// ...
|
|
38
38
|
await coveragePlugin({
|
|
39
|
-
reports: [
|
|
39
|
+
reports: ['coverage/lcov.info'],
|
|
40
40
|
coverageToolCommand: {
|
|
41
41
|
command: 'npx',
|
|
42
42
|
args: ['jest', '--coverage', '--coverageReporters=lcov'],
|
|
@@ -119,8 +119,9 @@ It recognises the following entities:
|
|
|
119
119
|
The plugin accepts the following parameters:
|
|
120
120
|
|
|
121
121
|
- `coverageTypes`: An array of types of coverage that you wish to track. Supported values: `function`, `branch`, `line`. Defaults to all available types.
|
|
122
|
-
- `reports`: Array of information about files with code coverage results
|
|
123
|
-
-
|
|
122
|
+
- `reports`: Array of information about files with code coverage results. LCOV format is supported for now.
|
|
123
|
+
- For a single project, providing paths to results as strings is enough.
|
|
124
|
+
- If you have a monorepo, both path to results (`resultsPath`) and path from the root to project the results belong to (`pathToProject`) need to be provided for the LCOV format. For Nx monorepos, you can use our helper function `getNxCoveragePaths` to get the path information automatically.
|
|
124
125
|
- (optional) `coverageToolCommand`: If you wish to run your coverage tool to generate the results first, you may define it here.
|
|
125
126
|
- (optional) `perfectScoreThreshold`: If your coverage goal is not 100%, you may define it here in range 0-1. Any score above the defined threshold will be given the perfect score. The value will stay unaffected.
|
|
126
127
|
|
package/bin.js
CHANGED
|
@@ -803,11 +803,12 @@ async function lcovResultsToAuditOutputs(results, coverageTypes) {
|
|
|
803
803
|
async function parseLcovFiles(results) {
|
|
804
804
|
const parsedResults = await Promise.all(
|
|
805
805
|
results.map(async (result) => {
|
|
806
|
-
const
|
|
806
|
+
const resultsPath = typeof result === "string" ? result : result.resultsPath;
|
|
807
|
+
const lcovFileContent = await readTextFile(resultsPath);
|
|
807
808
|
const parsedRecords = parseLcov(toUnixNewlines(lcovFileContent));
|
|
808
809
|
return parsedRecords.map((record) => ({
|
|
809
810
|
...record,
|
|
810
|
-
file: result.pathToProject == null ? record.file : join3(result.pathToProject, record.file)
|
|
811
|
+
file: typeof result === "string" || result.pathToProject == null ? record.file : join3(result.pathToProject, record.file)
|
|
811
812
|
}));
|
|
812
813
|
})
|
|
813
814
|
);
|
package/index.js
CHANGED
|
@@ -592,17 +592,24 @@ import chalk4 from "chalk";
|
|
|
592
592
|
|
|
593
593
|
// packages/plugin-coverage/package.json
|
|
594
594
|
var name = "@code-pushup/coverage-plugin";
|
|
595
|
-
var version = "0.
|
|
595
|
+
var version = "0.18.1";
|
|
596
596
|
|
|
597
597
|
// packages/plugin-coverage/src/lib/config.ts
|
|
598
598
|
import { z as z13 } from "zod";
|
|
599
599
|
var coverageTypeSchema = z13.enum(["function", "branch", "line"]);
|
|
600
|
-
var coverageResultSchema = z13.
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
600
|
+
var coverageResultSchema = z13.union([
|
|
601
|
+
z13.object({
|
|
602
|
+
resultsPath: z13.string({
|
|
603
|
+
description: "Path to coverage results for Nx setup."
|
|
604
|
+
}).includes("lcov"),
|
|
605
|
+
pathToProject: z13.string({
|
|
606
|
+
description: "Path from workspace root to project root. Necessary for LCOV reports which provide a relative path."
|
|
607
|
+
}).optional()
|
|
608
|
+
}),
|
|
609
|
+
z13.string({
|
|
610
|
+
description: "Path to coverage results for a single project setup."
|
|
611
|
+
}).includes("lcov")
|
|
612
|
+
]);
|
|
606
613
|
var coveragePluginConfigSchema = z13.object({
|
|
607
614
|
coverageToolCommand: z13.object({
|
|
608
615
|
command: z13.string({ description: "Command to run coverage tool." }).min(1),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/coverage-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@code-pushup/models": "*",
|
|
6
6
|
"@code-pushup/utils": "*",
|
|
@@ -15,45 +15,5 @@
|
|
|
15
15
|
"@nx/devkit": {
|
|
16
16
|
"optional": true
|
|
17
17
|
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
"homepage": "https://github.com/code-pushup/cli#readme",
|
|
21
|
-
"bugs": {
|
|
22
|
-
"url": "https://github.com/code-pushup/cli/issues"
|
|
23
|
-
},
|
|
24
|
-
"repository": {
|
|
25
|
-
"type": "git",
|
|
26
|
-
"url": "https://github.com/code-pushup/cli.git",
|
|
27
|
-
"directory": "packages/plugin-coverage"
|
|
28
|
-
},
|
|
29
|
-
"contributors": [
|
|
30
|
-
{
|
|
31
|
-
"name": "Igor Katsuba",
|
|
32
|
-
"email": "igor@katsuba.dev",
|
|
33
|
-
"url": "https://katsuba.dev"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"name": "Kateřina Pilátová",
|
|
37
|
-
"email": "katerina.pilatova@flowup.cz",
|
|
38
|
-
"url": "https://github.com/Tlacenka"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
"name": "Matěj Chalk",
|
|
42
|
-
"email": "matej.chalk@flowup.cz",
|
|
43
|
-
"url": "https://github.com/matejchalk"
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"name": "Michael Hladky",
|
|
47
|
-
"email": "michael.hladky@push-based.io",
|
|
48
|
-
"url": "https://push-based.io"
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
"name": "Michael Seredenko",
|
|
52
|
-
"email": "misha.seredenko@push-based.io",
|
|
53
|
-
"url": "https://github.com/MishaSeredenkoPushBased"
|
|
54
|
-
}
|
|
55
|
-
],
|
|
56
|
-
"type": "module",
|
|
57
|
-
"main": "./index.js",
|
|
58
|
-
"types": "./src/index.d.ts"
|
|
59
|
-
}
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/lib/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const coverageTypeSchema: z.ZodEnum<["function", "branch", "line"]>;
|
|
3
3
|
export type CoverageType = z.infer<typeof coverageTypeSchema>;
|
|
4
|
-
export declare const coverageResultSchema: z.ZodObject<{
|
|
4
|
+
export declare const coverageResultSchema: z.ZodUnion<[z.ZodObject<{
|
|
5
5
|
resultsPath: z.ZodString;
|
|
6
6
|
pathToProject: z.ZodOptional<z.ZodString>;
|
|
7
7
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -10,7 +10,7 @@ export declare const coverageResultSchema: z.ZodObject<{
|
|
|
10
10
|
}, {
|
|
11
11
|
resultsPath: string;
|
|
12
12
|
pathToProject?: string | undefined;
|
|
13
|
-
}>;
|
|
13
|
+
}>, z.ZodString]>;
|
|
14
14
|
export type CoverageResult = z.infer<typeof coverageResultSchema>;
|
|
15
15
|
export declare const coveragePluginConfigSchema: z.ZodObject<{
|
|
16
16
|
coverageToolCommand: z.ZodOptional<z.ZodObject<{
|
|
@@ -24,7 +24,7 @@ export declare const coveragePluginConfigSchema: z.ZodObject<{
|
|
|
24
24
|
args?: string[] | undefined;
|
|
25
25
|
}>>;
|
|
26
26
|
coverageTypes: z.ZodDefault<z.ZodArray<z.ZodEnum<["function", "branch", "line"]>, "many">>;
|
|
27
|
-
reports: z.ZodArray<z.ZodObject<{
|
|
27
|
+
reports: z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
28
28
|
resultsPath: z.ZodString;
|
|
29
29
|
pathToProject: z.ZodOptional<z.ZodString>;
|
|
30
30
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -33,24 +33,24 @@ export declare const coveragePluginConfigSchema: z.ZodObject<{
|
|
|
33
33
|
}, {
|
|
34
34
|
resultsPath: string;
|
|
35
35
|
pathToProject?: string | undefined;
|
|
36
|
-
}>, "many">;
|
|
36
|
+
}>, z.ZodString]>, "many">;
|
|
37
37
|
perfectScoreThreshold: z.ZodOptional<z.ZodNumber>;
|
|
38
38
|
}, "strip", z.ZodTypeAny, {
|
|
39
39
|
coverageTypes: ("function" | "branch" | "line")[];
|
|
40
|
-
reports: {
|
|
40
|
+
reports: (string | {
|
|
41
41
|
resultsPath: string;
|
|
42
42
|
pathToProject?: string | undefined;
|
|
43
|
-
}[];
|
|
43
|
+
})[];
|
|
44
44
|
coverageToolCommand?: {
|
|
45
45
|
command: string;
|
|
46
46
|
args?: string[] | undefined;
|
|
47
47
|
} | undefined;
|
|
48
48
|
perfectScoreThreshold?: number | undefined;
|
|
49
49
|
}, {
|
|
50
|
-
reports: {
|
|
50
|
+
reports: (string | {
|
|
51
51
|
resultsPath: string;
|
|
52
52
|
pathToProject?: string | undefined;
|
|
53
|
-
}[];
|
|
53
|
+
})[];
|
|
54
54
|
coverageToolCommand?: {
|
|
55
55
|
command: string;
|
|
56
56
|
args?: string[] | undefined;
|