@code-pushup/coverage-plugin 0.25.6 → 0.26.0
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/bin.js +51 -31
- package/index.js +66 -46
- package/package.json +1 -1
package/bin.js
CHANGED
|
@@ -317,23 +317,42 @@ function getDuplicateSlugCategories(categories) {
|
|
|
317
317
|
return hasDuplicateStrings(categories.map(({ slug }) => slug));
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
+
// packages/models/src/lib/commit.ts
|
|
321
|
+
import { z as z6 } from "zod";
|
|
322
|
+
var commitSchema = z6.object(
|
|
323
|
+
{
|
|
324
|
+
hash: z6.string({ description: "Commit SHA (full)" }).regex(
|
|
325
|
+
/^[\da-f]{40}$/,
|
|
326
|
+
"Commit SHA should be a 40-character hexadecimal string"
|
|
327
|
+
),
|
|
328
|
+
message: z6.string({ description: "Commit message" }),
|
|
329
|
+
date: z6.coerce.date({
|
|
330
|
+
description: "Date and time when commit was authored"
|
|
331
|
+
}),
|
|
332
|
+
author: z6.string({
|
|
333
|
+
description: "Commit author name"
|
|
334
|
+
}).trim()
|
|
335
|
+
},
|
|
336
|
+
{ description: "Git commit" }
|
|
337
|
+
);
|
|
338
|
+
|
|
320
339
|
// packages/models/src/lib/core-config.ts
|
|
321
|
-
import { z as
|
|
340
|
+
import { z as z12 } from "zod";
|
|
322
341
|
|
|
323
342
|
// packages/models/src/lib/persist-config.ts
|
|
324
|
-
import { z as
|
|
325
|
-
var formatSchema =
|
|
326
|
-
var persistConfigSchema =
|
|
343
|
+
import { z as z7 } from "zod";
|
|
344
|
+
var formatSchema = z7.enum(["json", "md"]);
|
|
345
|
+
var persistConfigSchema = z7.object({
|
|
327
346
|
outputDir: filePathSchema.describe("Artifacts folder").optional(),
|
|
328
347
|
filename: fileNameSchema.describe("Artifacts file name (without extension)").optional(),
|
|
329
|
-
format:
|
|
348
|
+
format: z7.array(formatSchema).optional()
|
|
330
349
|
});
|
|
331
350
|
|
|
332
351
|
// packages/models/src/lib/plugin-config.ts
|
|
333
|
-
import { z as
|
|
352
|
+
import { z as z10 } from "zod";
|
|
334
353
|
|
|
335
354
|
// packages/models/src/lib/group.ts
|
|
336
|
-
import { z as
|
|
355
|
+
import { z as z8 } from "zod";
|
|
337
356
|
var groupRefSchema = weightedRefSchema(
|
|
338
357
|
"Weighted reference to a group",
|
|
339
358
|
"Reference slug to a group within this plugin (e.g. 'max-lines')"
|
|
@@ -350,7 +369,7 @@ var groupSchema = scorableSchema(
|
|
|
350
369
|
getDuplicateRefsInGroups,
|
|
351
370
|
duplicateRefsInGroupsErrorMsg
|
|
352
371
|
).merge(groupMetaSchema);
|
|
353
|
-
var groupsSchema =
|
|
372
|
+
var groupsSchema = z8.array(groupSchema, {
|
|
354
373
|
description: "List of groups"
|
|
355
374
|
}).optional().refine(
|
|
356
375
|
(groups) => !getDuplicateSlugsInGroups(groups),
|
|
@@ -378,14 +397,14 @@ function getDuplicateSlugsInGroups(groups) {
|
|
|
378
397
|
}
|
|
379
398
|
|
|
380
399
|
// packages/models/src/lib/runner-config.ts
|
|
381
|
-
import { z as
|
|
382
|
-
var outputTransformSchema =
|
|
383
|
-
var runnerConfigSchema =
|
|
400
|
+
import { z as z9 } from "zod";
|
|
401
|
+
var outputTransformSchema = z9.function().args(z9.unknown()).returns(z9.union([auditOutputsSchema, z9.promise(auditOutputsSchema)]));
|
|
402
|
+
var runnerConfigSchema = z9.object(
|
|
384
403
|
{
|
|
385
|
-
command:
|
|
404
|
+
command: z9.string({
|
|
386
405
|
description: "Shell command to execute"
|
|
387
406
|
}),
|
|
388
|
-
args:
|
|
407
|
+
args: z9.array(z9.string({ description: "Command arguments" })).optional(),
|
|
389
408
|
outputFile: filePathSchema.describe("Output path"),
|
|
390
409
|
outputTransform: outputTransformSchema.optional()
|
|
391
410
|
},
|
|
@@ -393,8 +412,8 @@ var runnerConfigSchema = z8.object(
|
|
|
393
412
|
description: "How to execute runner"
|
|
394
413
|
}
|
|
395
414
|
);
|
|
396
|
-
var onProgressSchema =
|
|
397
|
-
var runnerFunctionSchema =
|
|
415
|
+
var onProgressSchema = z9.function().args(z9.unknown()).returns(z9.void());
|
|
416
|
+
var runnerFunctionSchema = z9.function().args(onProgressSchema.optional()).returns(z9.union([auditOutputsSchema, z9.promise(auditOutputsSchema)]));
|
|
398
417
|
|
|
399
418
|
// packages/models/src/lib/plugin-config.ts
|
|
400
419
|
var pluginMetaSchema = packageVersionSchema().merge(
|
|
@@ -405,13 +424,13 @@ var pluginMetaSchema = packageVersionSchema().merge(
|
|
|
405
424
|
description: "Plugin metadata"
|
|
406
425
|
})
|
|
407
426
|
).merge(
|
|
408
|
-
|
|
427
|
+
z10.object({
|
|
409
428
|
slug: slugSchema.describe("Unique plugin slug within core config"),
|
|
410
429
|
icon: materialIconSchema
|
|
411
430
|
})
|
|
412
431
|
);
|
|
413
|
-
var pluginDataSchema =
|
|
414
|
-
runner:
|
|
432
|
+
var pluginDataSchema = z10.object({
|
|
433
|
+
runner: z10.union([runnerConfigSchema, runnerFunctionSchema]),
|
|
415
434
|
audits: pluginAuditsSchema,
|
|
416
435
|
groups: groupsSchema
|
|
417
436
|
});
|
|
@@ -437,22 +456,22 @@ function getMissingRefsFromGroups(pluginCfg) {
|
|
|
437
456
|
}
|
|
438
457
|
|
|
439
458
|
// packages/models/src/lib/upload-config.ts
|
|
440
|
-
import { z as
|
|
441
|
-
var uploadConfigSchema =
|
|
459
|
+
import { z as z11 } from "zod";
|
|
460
|
+
var uploadConfigSchema = z11.object({
|
|
442
461
|
server: urlSchema.describe("URL of deployed portal API"),
|
|
443
|
-
apiKey:
|
|
462
|
+
apiKey: z11.string({
|
|
444
463
|
description: "API key with write access to portal (use `process.env` for security)"
|
|
445
464
|
}),
|
|
446
465
|
organization: slugSchema.describe(
|
|
447
466
|
"Organization slug from Code PushUp portal"
|
|
448
467
|
),
|
|
449
468
|
project: slugSchema.describe("Project slug from Code PushUp portal"),
|
|
450
|
-
timeout:
|
|
469
|
+
timeout: z11.number({ description: "Request timeout in minutes (default is 5)" }).positive().int().optional()
|
|
451
470
|
});
|
|
452
471
|
|
|
453
472
|
// packages/models/src/lib/core-config.ts
|
|
454
|
-
var unrefinedCoreConfigSchema =
|
|
455
|
-
plugins:
|
|
473
|
+
var unrefinedCoreConfigSchema = z12.object({
|
|
474
|
+
plugins: z12.array(pluginConfigSchema, {
|
|
456
475
|
description: "List of plugins to be used (official, community-provided, or custom)"
|
|
457
476
|
}).min(1),
|
|
458
477
|
/** portal configuration for persisting results */
|
|
@@ -475,7 +494,7 @@ function refineCoreConfig(schema) {
|
|
|
475
494
|
}
|
|
476
495
|
|
|
477
496
|
// packages/models/src/lib/report.ts
|
|
478
|
-
import { z as
|
|
497
|
+
import { z as z13 } from "zod";
|
|
479
498
|
var auditReportSchema = auditSchema.merge(auditOutputSchema);
|
|
480
499
|
var pluginReportSchema = pluginMetaSchema.merge(
|
|
481
500
|
executionMetaSchema({
|
|
@@ -483,9 +502,9 @@ var pluginReportSchema = pluginMetaSchema.merge(
|
|
|
483
502
|
descriptionDuration: "Duration of the plugin run in ms"
|
|
484
503
|
})
|
|
485
504
|
).merge(
|
|
486
|
-
|
|
487
|
-
audits:
|
|
488
|
-
groups:
|
|
505
|
+
z13.object({
|
|
506
|
+
audits: z13.array(auditReportSchema).min(1),
|
|
507
|
+
groups: z13.array(groupSchema).optional()
|
|
489
508
|
})
|
|
490
509
|
).refine(
|
|
491
510
|
(pluginReport) => !getMissingRefsFromGroups2(pluginReport.audits, pluginReport.groups ?? []),
|
|
@@ -519,10 +538,11 @@ var reportSchema = packageVersionSchema({
|
|
|
519
538
|
descriptionDuration: "Duration of the collect run in ms"
|
|
520
539
|
})
|
|
521
540
|
).merge(
|
|
522
|
-
|
|
541
|
+
z13.object(
|
|
523
542
|
{
|
|
524
|
-
categories:
|
|
525
|
-
plugins:
|
|
543
|
+
categories: z13.array(categoryConfigSchema),
|
|
544
|
+
plugins: z13.array(pluginReportSchema).min(1),
|
|
545
|
+
commit: commitSchema.describe("Git commit for which report was collected").nullable()
|
|
526
546
|
},
|
|
527
547
|
{ description: "Collect output data" }
|
|
528
548
|
)
|
package/index.js
CHANGED
|
@@ -316,23 +316,42 @@ function getDuplicateSlugCategories(categories) {
|
|
|
316
316
|
return hasDuplicateStrings(categories.map(({ slug }) => slug));
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
+
// packages/models/src/lib/commit.ts
|
|
320
|
+
import { z as z6 } from "zod";
|
|
321
|
+
var commitSchema = z6.object(
|
|
322
|
+
{
|
|
323
|
+
hash: z6.string({ description: "Commit SHA (full)" }).regex(
|
|
324
|
+
/^[\da-f]{40}$/,
|
|
325
|
+
"Commit SHA should be a 40-character hexadecimal string"
|
|
326
|
+
),
|
|
327
|
+
message: z6.string({ description: "Commit message" }),
|
|
328
|
+
date: z6.coerce.date({
|
|
329
|
+
description: "Date and time when commit was authored"
|
|
330
|
+
}),
|
|
331
|
+
author: z6.string({
|
|
332
|
+
description: "Commit author name"
|
|
333
|
+
}).trim()
|
|
334
|
+
},
|
|
335
|
+
{ description: "Git commit" }
|
|
336
|
+
);
|
|
337
|
+
|
|
319
338
|
// packages/models/src/lib/core-config.ts
|
|
320
|
-
import { z as
|
|
339
|
+
import { z as z12 } from "zod";
|
|
321
340
|
|
|
322
341
|
// packages/models/src/lib/persist-config.ts
|
|
323
|
-
import { z as
|
|
324
|
-
var formatSchema =
|
|
325
|
-
var persistConfigSchema =
|
|
342
|
+
import { z as z7 } from "zod";
|
|
343
|
+
var formatSchema = z7.enum(["json", "md"]);
|
|
344
|
+
var persistConfigSchema = z7.object({
|
|
326
345
|
outputDir: filePathSchema.describe("Artifacts folder").optional(),
|
|
327
346
|
filename: fileNameSchema.describe("Artifacts file name (without extension)").optional(),
|
|
328
|
-
format:
|
|
347
|
+
format: z7.array(formatSchema).optional()
|
|
329
348
|
});
|
|
330
349
|
|
|
331
350
|
// packages/models/src/lib/plugin-config.ts
|
|
332
|
-
import { z as
|
|
351
|
+
import { z as z10 } from "zod";
|
|
333
352
|
|
|
334
353
|
// packages/models/src/lib/group.ts
|
|
335
|
-
import { z as
|
|
354
|
+
import { z as z8 } from "zod";
|
|
336
355
|
var groupRefSchema = weightedRefSchema(
|
|
337
356
|
"Weighted reference to a group",
|
|
338
357
|
"Reference slug to a group within this plugin (e.g. 'max-lines')"
|
|
@@ -349,7 +368,7 @@ var groupSchema = scorableSchema(
|
|
|
349
368
|
getDuplicateRefsInGroups,
|
|
350
369
|
duplicateRefsInGroupsErrorMsg
|
|
351
370
|
).merge(groupMetaSchema);
|
|
352
|
-
var groupsSchema =
|
|
371
|
+
var groupsSchema = z8.array(groupSchema, {
|
|
353
372
|
description: "List of groups"
|
|
354
373
|
}).optional().refine(
|
|
355
374
|
(groups) => !getDuplicateSlugsInGroups(groups),
|
|
@@ -377,14 +396,14 @@ function getDuplicateSlugsInGroups(groups) {
|
|
|
377
396
|
}
|
|
378
397
|
|
|
379
398
|
// packages/models/src/lib/runner-config.ts
|
|
380
|
-
import { z as
|
|
381
|
-
var outputTransformSchema =
|
|
382
|
-
var runnerConfigSchema =
|
|
399
|
+
import { z as z9 } from "zod";
|
|
400
|
+
var outputTransformSchema = z9.function().args(z9.unknown()).returns(z9.union([auditOutputsSchema, z9.promise(auditOutputsSchema)]));
|
|
401
|
+
var runnerConfigSchema = z9.object(
|
|
383
402
|
{
|
|
384
|
-
command:
|
|
403
|
+
command: z9.string({
|
|
385
404
|
description: "Shell command to execute"
|
|
386
405
|
}),
|
|
387
|
-
args:
|
|
406
|
+
args: z9.array(z9.string({ description: "Command arguments" })).optional(),
|
|
388
407
|
outputFile: filePathSchema.describe("Output path"),
|
|
389
408
|
outputTransform: outputTransformSchema.optional()
|
|
390
409
|
},
|
|
@@ -392,8 +411,8 @@ var runnerConfigSchema = z8.object(
|
|
|
392
411
|
description: "How to execute runner"
|
|
393
412
|
}
|
|
394
413
|
);
|
|
395
|
-
var onProgressSchema =
|
|
396
|
-
var runnerFunctionSchema =
|
|
414
|
+
var onProgressSchema = z9.function().args(z9.unknown()).returns(z9.void());
|
|
415
|
+
var runnerFunctionSchema = z9.function().args(onProgressSchema.optional()).returns(z9.union([auditOutputsSchema, z9.promise(auditOutputsSchema)]));
|
|
397
416
|
|
|
398
417
|
// packages/models/src/lib/plugin-config.ts
|
|
399
418
|
var pluginMetaSchema = packageVersionSchema().merge(
|
|
@@ -404,13 +423,13 @@ var pluginMetaSchema = packageVersionSchema().merge(
|
|
|
404
423
|
description: "Plugin metadata"
|
|
405
424
|
})
|
|
406
425
|
).merge(
|
|
407
|
-
|
|
426
|
+
z10.object({
|
|
408
427
|
slug: slugSchema.describe("Unique plugin slug within core config"),
|
|
409
428
|
icon: materialIconSchema
|
|
410
429
|
})
|
|
411
430
|
);
|
|
412
|
-
var pluginDataSchema =
|
|
413
|
-
runner:
|
|
431
|
+
var pluginDataSchema = z10.object({
|
|
432
|
+
runner: z10.union([runnerConfigSchema, runnerFunctionSchema]),
|
|
414
433
|
audits: pluginAuditsSchema,
|
|
415
434
|
groups: groupsSchema
|
|
416
435
|
});
|
|
@@ -436,22 +455,22 @@ function getMissingRefsFromGroups(pluginCfg) {
|
|
|
436
455
|
}
|
|
437
456
|
|
|
438
457
|
// packages/models/src/lib/upload-config.ts
|
|
439
|
-
import { z as
|
|
440
|
-
var uploadConfigSchema =
|
|
458
|
+
import { z as z11 } from "zod";
|
|
459
|
+
var uploadConfigSchema = z11.object({
|
|
441
460
|
server: urlSchema.describe("URL of deployed portal API"),
|
|
442
|
-
apiKey:
|
|
461
|
+
apiKey: z11.string({
|
|
443
462
|
description: "API key with write access to portal (use `process.env` for security)"
|
|
444
463
|
}),
|
|
445
464
|
organization: slugSchema.describe(
|
|
446
465
|
"Organization slug from Code PushUp portal"
|
|
447
466
|
),
|
|
448
467
|
project: slugSchema.describe("Project slug from Code PushUp portal"),
|
|
449
|
-
timeout:
|
|
468
|
+
timeout: z11.number({ description: "Request timeout in minutes (default is 5)" }).positive().int().optional()
|
|
450
469
|
});
|
|
451
470
|
|
|
452
471
|
// packages/models/src/lib/core-config.ts
|
|
453
|
-
var unrefinedCoreConfigSchema =
|
|
454
|
-
plugins:
|
|
472
|
+
var unrefinedCoreConfigSchema = z12.object({
|
|
473
|
+
plugins: z12.array(pluginConfigSchema, {
|
|
455
474
|
description: "List of plugins to be used (official, community-provided, or custom)"
|
|
456
475
|
}).min(1),
|
|
457
476
|
/** portal configuration for persisting results */
|
|
@@ -474,7 +493,7 @@ function refineCoreConfig(schema) {
|
|
|
474
493
|
}
|
|
475
494
|
|
|
476
495
|
// packages/models/src/lib/report.ts
|
|
477
|
-
import { z as
|
|
496
|
+
import { z as z13 } from "zod";
|
|
478
497
|
var auditReportSchema = auditSchema.merge(auditOutputSchema);
|
|
479
498
|
var pluginReportSchema = pluginMetaSchema.merge(
|
|
480
499
|
executionMetaSchema({
|
|
@@ -482,9 +501,9 @@ var pluginReportSchema = pluginMetaSchema.merge(
|
|
|
482
501
|
descriptionDuration: "Duration of the plugin run in ms"
|
|
483
502
|
})
|
|
484
503
|
).merge(
|
|
485
|
-
|
|
486
|
-
audits:
|
|
487
|
-
groups:
|
|
504
|
+
z13.object({
|
|
505
|
+
audits: z13.array(auditReportSchema).min(1),
|
|
506
|
+
groups: z13.array(groupSchema).optional()
|
|
488
507
|
})
|
|
489
508
|
).refine(
|
|
490
509
|
(pluginReport) => !getMissingRefsFromGroups2(pluginReport.audits, pluginReport.groups ?? []),
|
|
@@ -518,10 +537,11 @@ var reportSchema = packageVersionSchema({
|
|
|
518
537
|
descriptionDuration: "Duration of the collect run in ms"
|
|
519
538
|
})
|
|
520
539
|
).merge(
|
|
521
|
-
|
|
540
|
+
z13.object(
|
|
522
541
|
{
|
|
523
|
-
categories:
|
|
524
|
-
plugins:
|
|
542
|
+
categories: z13.array(categoryConfigSchema),
|
|
543
|
+
plugins: z13.array(pluginReportSchema).min(1),
|
|
544
|
+
commit: commitSchema.describe("Git commit for which report was collected").nullable()
|
|
525
545
|
},
|
|
526
546
|
{ description: "Collect output data" }
|
|
527
547
|
)
|
|
@@ -579,38 +599,38 @@ import CliTable3 from "cli-table3";
|
|
|
579
599
|
|
|
580
600
|
// packages/plugin-coverage/package.json
|
|
581
601
|
var name = "@code-pushup/coverage-plugin";
|
|
582
|
-
var version = "0.
|
|
602
|
+
var version = "0.26.0";
|
|
583
603
|
|
|
584
604
|
// packages/plugin-coverage/src/lib/config.ts
|
|
585
|
-
import { z as
|
|
586
|
-
var coverageTypeSchema =
|
|
587
|
-
var coverageResultSchema =
|
|
588
|
-
|
|
589
|
-
resultsPath:
|
|
605
|
+
import { z as z14 } from "zod";
|
|
606
|
+
var coverageTypeSchema = z14.enum(["function", "branch", "line"]);
|
|
607
|
+
var coverageResultSchema = z14.union([
|
|
608
|
+
z14.object({
|
|
609
|
+
resultsPath: z14.string({
|
|
590
610
|
description: "Path to coverage results for Nx setup."
|
|
591
611
|
}).includes("lcov"),
|
|
592
|
-
pathToProject:
|
|
612
|
+
pathToProject: z14.string({
|
|
593
613
|
description: "Path from workspace root to project root. Necessary for LCOV reports which provide a relative path."
|
|
594
614
|
}).optional()
|
|
595
615
|
}),
|
|
596
|
-
|
|
616
|
+
z14.string({
|
|
597
617
|
description: "Path to coverage results for a single project setup."
|
|
598
618
|
}).includes("lcov")
|
|
599
619
|
]);
|
|
600
|
-
var coveragePluginConfigSchema =
|
|
601
|
-
coverageToolCommand:
|
|
602
|
-
command:
|
|
603
|
-
args:
|
|
620
|
+
var coveragePluginConfigSchema = z14.object({
|
|
621
|
+
coverageToolCommand: z14.object({
|
|
622
|
+
command: z14.string({ description: "Command to run coverage tool." }).min(1),
|
|
623
|
+
args: z14.array(z14.string(), {
|
|
604
624
|
description: "Arguments to be passed to the coverage tool."
|
|
605
625
|
}).optional()
|
|
606
626
|
}).optional(),
|
|
607
|
-
coverageTypes:
|
|
627
|
+
coverageTypes: z14.array(coverageTypeSchema, {
|
|
608
628
|
description: "Coverage types measured. Defaults to all available types."
|
|
609
629
|
}).min(1).default(["function", "branch", "line"]),
|
|
610
|
-
reports:
|
|
630
|
+
reports: z14.array(coverageResultSchema, {
|
|
611
631
|
description: "Path to all code coverage report files. Only LCOV format is supported for now."
|
|
612
632
|
}).min(1),
|
|
613
|
-
perfectScoreThreshold:
|
|
633
|
+
perfectScoreThreshold: z14.number({
|
|
614
634
|
description: "Score will be 1 (perfect) for this coverage and above. Score range is 0 - 1."
|
|
615
635
|
}).gt(0).max(1).optional()
|
|
616
636
|
});
|