@code-pushup/coverage-plugin 0.50.0 → 0.52.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 +111 -108
- package/index.js +126 -123
- package/package.json +6 -3
package/bin.js
CHANGED
|
@@ -160,9 +160,27 @@ function hasNonZeroWeightedRef(refs) {
|
|
|
160
160
|
return refs.reduce((acc, { weight }) => weight + acc, 0) !== 0;
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
// packages/models/src/lib/
|
|
163
|
+
// packages/models/src/lib/source.ts
|
|
164
164
|
import { z as z2 } from "zod";
|
|
165
|
-
var
|
|
165
|
+
var sourceFileLocationSchema = z2.object(
|
|
166
|
+
{
|
|
167
|
+
file: filePathSchema.describe("Relative path to source file in Git repo"),
|
|
168
|
+
position: z2.object(
|
|
169
|
+
{
|
|
170
|
+
startLine: positiveIntSchema.describe("Start line"),
|
|
171
|
+
startColumn: positiveIntSchema.describe("Start column").optional(),
|
|
172
|
+
endLine: positiveIntSchema.describe("End line").optional(),
|
|
173
|
+
endColumn: positiveIntSchema.describe("End column").optional()
|
|
174
|
+
},
|
|
175
|
+
{ description: "Location in file" }
|
|
176
|
+
).optional()
|
|
177
|
+
},
|
|
178
|
+
{ description: "Source file location" }
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
// packages/models/src/lib/audit.ts
|
|
182
|
+
import { z as z3 } from "zod";
|
|
183
|
+
var auditSchema = z3.object({
|
|
166
184
|
slug: slugSchema.describe("ID (unique within plugin)")
|
|
167
185
|
}).merge(
|
|
168
186
|
metaSchema({
|
|
@@ -172,7 +190,7 @@ var auditSchema = z2.object({
|
|
|
172
190
|
description: "List of scorable metrics for the given plugin"
|
|
173
191
|
})
|
|
174
192
|
);
|
|
175
|
-
var pluginAuditsSchema =
|
|
193
|
+
var pluginAuditsSchema = z3.array(auditSchema, {
|
|
176
194
|
description: "List of audits maintained in a plugin"
|
|
177
195
|
}).min(1).refine(
|
|
178
196
|
(auditMetadata) => !getDuplicateSlugsInAudits(auditMetadata),
|
|
@@ -191,31 +209,16 @@ function getDuplicateSlugsInAudits(audits) {
|
|
|
191
209
|
}
|
|
192
210
|
|
|
193
211
|
// packages/models/src/lib/audit-output.ts
|
|
194
|
-
import { z as
|
|
212
|
+
import { z as z6 } from "zod";
|
|
195
213
|
|
|
196
214
|
// packages/models/src/lib/issue.ts
|
|
197
|
-
import { z as
|
|
198
|
-
var
|
|
199
|
-
{
|
|
200
|
-
file: filePathSchema.describe("Relative path to source file in Git repo"),
|
|
201
|
-
position: z3.object(
|
|
202
|
-
{
|
|
203
|
-
startLine: positiveIntSchema.describe("Start line"),
|
|
204
|
-
startColumn: positiveIntSchema.describe("Start column").optional(),
|
|
205
|
-
endLine: positiveIntSchema.describe("End line").optional(),
|
|
206
|
-
endColumn: positiveIntSchema.describe("End column").optional()
|
|
207
|
-
},
|
|
208
|
-
{ description: "Location in file" }
|
|
209
|
-
).optional()
|
|
210
|
-
},
|
|
211
|
-
{ description: "Source file location" }
|
|
212
|
-
);
|
|
213
|
-
var issueSeveritySchema = z3.enum(["info", "warning", "error"], {
|
|
215
|
+
import { z as z4 } from "zod";
|
|
216
|
+
var issueSeveritySchema = z4.enum(["info", "warning", "error"], {
|
|
214
217
|
description: "Severity level"
|
|
215
218
|
});
|
|
216
|
-
var issueSchema =
|
|
219
|
+
var issueSchema = z4.object(
|
|
217
220
|
{
|
|
218
|
-
message:
|
|
221
|
+
message: z4.string({ description: "Descriptive error message" }).max(MAX_ISSUE_MESSAGE_LENGTH),
|
|
219
222
|
severity: issueSeveritySchema,
|
|
220
223
|
source: sourceFileLocationSchema.optional()
|
|
221
224
|
},
|
|
@@ -223,60 +226,60 @@ var issueSchema = z3.object(
|
|
|
223
226
|
);
|
|
224
227
|
|
|
225
228
|
// packages/models/src/lib/table.ts
|
|
226
|
-
import { z as
|
|
227
|
-
var tableAlignmentSchema =
|
|
229
|
+
import { z as z5 } from "zod";
|
|
230
|
+
var tableAlignmentSchema = z5.enum(["left", "center", "right"], {
|
|
228
231
|
description: "Cell alignment"
|
|
229
232
|
});
|
|
230
|
-
var tableColumnObjectSchema =
|
|
231
|
-
key:
|
|
232
|
-
label:
|
|
233
|
+
var tableColumnObjectSchema = z5.object({
|
|
234
|
+
key: z5.string(),
|
|
235
|
+
label: z5.string().optional(),
|
|
233
236
|
align: tableAlignmentSchema.optional()
|
|
234
237
|
});
|
|
235
|
-
var tableRowObjectSchema =
|
|
238
|
+
var tableRowObjectSchema = z5.record(tableCellValueSchema, {
|
|
236
239
|
description: "Object row"
|
|
237
240
|
});
|
|
238
|
-
var tableRowPrimitiveSchema =
|
|
241
|
+
var tableRowPrimitiveSchema = z5.array(tableCellValueSchema, {
|
|
239
242
|
description: "Primitive row"
|
|
240
243
|
});
|
|
241
|
-
var tableSharedSchema =
|
|
242
|
-
title:
|
|
244
|
+
var tableSharedSchema = z5.object({
|
|
245
|
+
title: z5.string().optional().describe("Display title for table")
|
|
243
246
|
});
|
|
244
247
|
var tablePrimitiveSchema = tableSharedSchema.merge(
|
|
245
|
-
|
|
248
|
+
z5.object(
|
|
246
249
|
{
|
|
247
|
-
columns:
|
|
248
|
-
rows:
|
|
250
|
+
columns: z5.array(tableAlignmentSchema).optional(),
|
|
251
|
+
rows: z5.array(tableRowPrimitiveSchema)
|
|
249
252
|
},
|
|
250
253
|
{ description: "Table with primitive rows and optional alignment columns" }
|
|
251
254
|
)
|
|
252
255
|
);
|
|
253
256
|
var tableObjectSchema = tableSharedSchema.merge(
|
|
254
|
-
|
|
257
|
+
z5.object(
|
|
255
258
|
{
|
|
256
|
-
columns:
|
|
257
|
-
|
|
258
|
-
|
|
259
|
+
columns: z5.union([
|
|
260
|
+
z5.array(tableAlignmentSchema),
|
|
261
|
+
z5.array(tableColumnObjectSchema)
|
|
259
262
|
]).optional(),
|
|
260
|
-
rows:
|
|
263
|
+
rows: z5.array(tableRowObjectSchema)
|
|
261
264
|
},
|
|
262
265
|
{
|
|
263
266
|
description: "Table with object rows and optional alignment or object columns"
|
|
264
267
|
}
|
|
265
268
|
)
|
|
266
269
|
);
|
|
267
|
-
var tableSchema = (description = "Table information") =>
|
|
270
|
+
var tableSchema = (description = "Table information") => z5.union([tablePrimitiveSchema, tableObjectSchema], { description });
|
|
268
271
|
|
|
269
272
|
// packages/models/src/lib/audit-output.ts
|
|
270
273
|
var auditValueSchema = nonnegativeNumberSchema.describe("Raw numeric value");
|
|
271
|
-
var auditDisplayValueSchema =
|
|
272
|
-
var auditDetailsSchema =
|
|
274
|
+
var auditDisplayValueSchema = z6.string({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" }).optional();
|
|
275
|
+
var auditDetailsSchema = z6.object(
|
|
273
276
|
{
|
|
274
|
-
issues:
|
|
277
|
+
issues: z6.array(issueSchema, { description: "List of findings" }).optional(),
|
|
275
278
|
table: tableSchema("Table of related findings").optional()
|
|
276
279
|
},
|
|
277
280
|
{ description: "Detailed information" }
|
|
278
281
|
);
|
|
279
|
-
var auditOutputSchema =
|
|
282
|
+
var auditOutputSchema = z6.object(
|
|
280
283
|
{
|
|
281
284
|
slug: slugSchema.describe("Reference to audit"),
|
|
282
285
|
displayValue: auditDisplayValueSchema,
|
|
@@ -286,7 +289,7 @@ var auditOutputSchema = z5.object(
|
|
|
286
289
|
},
|
|
287
290
|
{ description: "Audit information" }
|
|
288
291
|
);
|
|
289
|
-
var auditOutputsSchema =
|
|
292
|
+
var auditOutputsSchema = z6.array(auditOutputSchema, {
|
|
290
293
|
description: "List of JSON formatted audit output emitted by the runner process of a plugin"
|
|
291
294
|
}).refine(
|
|
292
295
|
(audits) => !getDuplicateSlugsInAudits2(audits),
|
|
@@ -303,13 +306,13 @@ function getDuplicateSlugsInAudits2(audits) {
|
|
|
303
306
|
}
|
|
304
307
|
|
|
305
308
|
// packages/models/src/lib/category-config.ts
|
|
306
|
-
import { z as
|
|
309
|
+
import { z as z7 } from "zod";
|
|
307
310
|
var categoryRefSchema = weightedRefSchema(
|
|
308
311
|
"Weighted references to audits and/or groups for the category",
|
|
309
312
|
"Slug of an audit or group (depending on `type`)"
|
|
310
313
|
).merge(
|
|
311
|
-
|
|
312
|
-
type:
|
|
314
|
+
z7.object({
|
|
315
|
+
type: z7.enum(["audit", "group"], {
|
|
313
316
|
description: "Discriminant for reference kind, affects where `slug` is looked up"
|
|
314
317
|
}),
|
|
315
318
|
plugin: slugSchema.describe(
|
|
@@ -330,8 +333,8 @@ var categoryConfigSchema = scorableSchema(
|
|
|
330
333
|
description: "Meta info for category"
|
|
331
334
|
})
|
|
332
335
|
).merge(
|
|
333
|
-
|
|
334
|
-
isBinary:
|
|
336
|
+
z7.object({
|
|
337
|
+
isBinary: z7.boolean({
|
|
335
338
|
description: 'Is this a binary category (i.e. only a perfect score considered a "pass")?'
|
|
336
339
|
}).optional()
|
|
337
340
|
})
|
|
@@ -347,7 +350,7 @@ function getDuplicateRefsInCategoryMetrics(metrics) {
|
|
|
347
350
|
metrics.map(({ slug, type, plugin }) => `${type} :: ${plugin} / ${slug}`)
|
|
348
351
|
);
|
|
349
352
|
}
|
|
350
|
-
var categoriesSchema =
|
|
353
|
+
var categoriesSchema = z7.array(categoryConfigSchema, {
|
|
351
354
|
description: "Categorization of individual audits"
|
|
352
355
|
}).refine(
|
|
353
356
|
(categoryCfg) => !getDuplicateSlugCategories(categoryCfg),
|
|
@@ -366,18 +369,18 @@ function getDuplicateSlugCategories(categories) {
|
|
|
366
369
|
}
|
|
367
370
|
|
|
368
371
|
// packages/models/src/lib/commit.ts
|
|
369
|
-
import { z as
|
|
370
|
-
var commitSchema =
|
|
372
|
+
import { z as z8 } from "zod";
|
|
373
|
+
var commitSchema = z8.object(
|
|
371
374
|
{
|
|
372
|
-
hash:
|
|
375
|
+
hash: z8.string({ description: "Commit SHA (full)" }).regex(
|
|
373
376
|
/^[\da-f]{40}$/,
|
|
374
377
|
"Commit SHA should be a 40-character hexadecimal string"
|
|
375
378
|
),
|
|
376
|
-
message:
|
|
377
|
-
date:
|
|
379
|
+
message: z8.string({ description: "Commit message" }),
|
|
380
|
+
date: z8.coerce.date({
|
|
378
381
|
description: "Date and time when commit was authored"
|
|
379
382
|
}),
|
|
380
|
-
author:
|
|
383
|
+
author: z8.string({
|
|
381
384
|
description: "Commit author name"
|
|
382
385
|
}).trim()
|
|
383
386
|
},
|
|
@@ -385,22 +388,22 @@ var commitSchema = z7.object(
|
|
|
385
388
|
);
|
|
386
389
|
|
|
387
390
|
// packages/models/src/lib/core-config.ts
|
|
388
|
-
import { z as
|
|
391
|
+
import { z as z14 } from "zod";
|
|
389
392
|
|
|
390
393
|
// packages/models/src/lib/persist-config.ts
|
|
391
|
-
import { z as
|
|
392
|
-
var formatSchema =
|
|
393
|
-
var persistConfigSchema =
|
|
394
|
+
import { z as z9 } from "zod";
|
|
395
|
+
var formatSchema = z9.enum(["json", "md"]);
|
|
396
|
+
var persistConfigSchema = z9.object({
|
|
394
397
|
outputDir: filePathSchema.describe("Artifacts folder").optional(),
|
|
395
398
|
filename: fileNameSchema.describe("Artifacts file name (without extension)").optional(),
|
|
396
|
-
format:
|
|
399
|
+
format: z9.array(formatSchema).optional()
|
|
397
400
|
});
|
|
398
401
|
|
|
399
402
|
// packages/models/src/lib/plugin-config.ts
|
|
400
|
-
import { z as
|
|
403
|
+
import { z as z12 } from "zod";
|
|
401
404
|
|
|
402
405
|
// packages/models/src/lib/group.ts
|
|
403
|
-
import { z as
|
|
406
|
+
import { z as z10 } from "zod";
|
|
404
407
|
var groupRefSchema = weightedRefSchema(
|
|
405
408
|
"Weighted reference to a group",
|
|
406
409
|
"Reference slug to a group within this plugin (e.g. 'max-lines')"
|
|
@@ -417,7 +420,7 @@ var groupSchema = scorableSchema(
|
|
|
417
420
|
getDuplicateRefsInGroups,
|
|
418
421
|
duplicateRefsInGroupsErrorMsg
|
|
419
422
|
).merge(groupMetaSchema);
|
|
420
|
-
var groupsSchema =
|
|
423
|
+
var groupsSchema = z10.array(groupSchema, {
|
|
421
424
|
description: "List of groups"
|
|
422
425
|
}).optional().refine(
|
|
423
426
|
(groups) => !getDuplicateSlugsInGroups(groups),
|
|
@@ -445,14 +448,14 @@ function getDuplicateSlugsInGroups(groups) {
|
|
|
445
448
|
}
|
|
446
449
|
|
|
447
450
|
// packages/models/src/lib/runner-config.ts
|
|
448
|
-
import { z as
|
|
449
|
-
var outputTransformSchema =
|
|
450
|
-
var runnerConfigSchema =
|
|
451
|
+
import { z as z11 } from "zod";
|
|
452
|
+
var outputTransformSchema = z11.function().args(z11.unknown()).returns(z11.union([auditOutputsSchema, z11.promise(auditOutputsSchema)]));
|
|
453
|
+
var runnerConfigSchema = z11.object(
|
|
451
454
|
{
|
|
452
|
-
command:
|
|
455
|
+
command: z11.string({
|
|
453
456
|
description: "Shell command to execute"
|
|
454
457
|
}),
|
|
455
|
-
args:
|
|
458
|
+
args: z11.array(z11.string({ description: "Command arguments" })).optional(),
|
|
456
459
|
outputFile: filePathSchema.describe("Output path"),
|
|
457
460
|
outputTransform: outputTransformSchema.optional()
|
|
458
461
|
},
|
|
@@ -460,8 +463,8 @@ var runnerConfigSchema = z10.object(
|
|
|
460
463
|
description: "How to execute runner"
|
|
461
464
|
}
|
|
462
465
|
);
|
|
463
|
-
var onProgressSchema =
|
|
464
|
-
var runnerFunctionSchema =
|
|
466
|
+
var onProgressSchema = z11.function().args(z11.unknown()).returns(z11.void());
|
|
467
|
+
var runnerFunctionSchema = z11.function().args(onProgressSchema.optional()).returns(z11.union([auditOutputsSchema, z11.promise(auditOutputsSchema)]));
|
|
465
468
|
|
|
466
469
|
// packages/models/src/lib/plugin-config.ts
|
|
467
470
|
var pluginMetaSchema = packageVersionSchema().merge(
|
|
@@ -472,13 +475,13 @@ var pluginMetaSchema = packageVersionSchema().merge(
|
|
|
472
475
|
description: "Plugin metadata"
|
|
473
476
|
})
|
|
474
477
|
).merge(
|
|
475
|
-
|
|
478
|
+
z12.object({
|
|
476
479
|
slug: slugSchema.describe("Unique plugin slug within core config"),
|
|
477
480
|
icon: materialIconSchema
|
|
478
481
|
})
|
|
479
482
|
);
|
|
480
|
-
var pluginDataSchema =
|
|
481
|
-
runner:
|
|
483
|
+
var pluginDataSchema = z12.object({
|
|
484
|
+
runner: z12.union([runnerConfigSchema, runnerFunctionSchema]),
|
|
482
485
|
audits: pluginAuditsSchema,
|
|
483
486
|
groups: groupsSchema
|
|
484
487
|
});
|
|
@@ -504,22 +507,22 @@ function getMissingRefsFromGroups(pluginCfg) {
|
|
|
504
507
|
}
|
|
505
508
|
|
|
506
509
|
// packages/models/src/lib/upload-config.ts
|
|
507
|
-
import { z as
|
|
508
|
-
var uploadConfigSchema =
|
|
510
|
+
import { z as z13 } from "zod";
|
|
511
|
+
var uploadConfigSchema = z13.object({
|
|
509
512
|
server: urlSchema.describe("URL of deployed portal API"),
|
|
510
|
-
apiKey:
|
|
513
|
+
apiKey: z13.string({
|
|
511
514
|
description: "API key with write access to portal (use `process.env` for security)"
|
|
512
515
|
}),
|
|
513
516
|
organization: slugSchema.describe(
|
|
514
517
|
"Organization slug from Code PushUp portal"
|
|
515
518
|
),
|
|
516
519
|
project: slugSchema.describe("Project slug from Code PushUp portal"),
|
|
517
|
-
timeout:
|
|
520
|
+
timeout: z13.number({ description: "Request timeout in minutes (default is 5)" }).positive().int().optional()
|
|
518
521
|
});
|
|
519
522
|
|
|
520
523
|
// packages/models/src/lib/core-config.ts
|
|
521
|
-
var unrefinedCoreConfigSchema =
|
|
522
|
-
plugins:
|
|
524
|
+
var unrefinedCoreConfigSchema = z14.object({
|
|
525
|
+
plugins: z14.array(pluginConfigSchema, {
|
|
523
526
|
description: "List of plugins to be used (official, community-provided, or custom)"
|
|
524
527
|
}).min(1),
|
|
525
528
|
/** portal configuration for persisting results */
|
|
@@ -542,7 +545,7 @@ function refineCoreConfig(schema) {
|
|
|
542
545
|
}
|
|
543
546
|
|
|
544
547
|
// packages/models/src/lib/report.ts
|
|
545
|
-
import { z as
|
|
548
|
+
import { z as z15 } from "zod";
|
|
546
549
|
var auditReportSchema = auditSchema.merge(auditOutputSchema);
|
|
547
550
|
var pluginReportSchema = pluginMetaSchema.merge(
|
|
548
551
|
executionMetaSchema({
|
|
@@ -550,9 +553,9 @@ var pluginReportSchema = pluginMetaSchema.merge(
|
|
|
550
553
|
descriptionDuration: "Duration of the plugin run in ms"
|
|
551
554
|
})
|
|
552
555
|
).merge(
|
|
553
|
-
|
|
554
|
-
audits:
|
|
555
|
-
groups:
|
|
556
|
+
z15.object({
|
|
557
|
+
audits: z15.array(auditReportSchema).min(1),
|
|
558
|
+
groups: z15.array(groupSchema).optional()
|
|
556
559
|
})
|
|
557
560
|
).refine(
|
|
558
561
|
(pluginReport) => !getMissingRefsFromGroups2(pluginReport.audits, pluginReport.groups ?? []),
|
|
@@ -586,10 +589,10 @@ var reportSchema = packageVersionSchema({
|
|
|
586
589
|
descriptionDuration: "Duration of the collect run in ms"
|
|
587
590
|
})
|
|
588
591
|
).merge(
|
|
589
|
-
|
|
592
|
+
z15.object(
|
|
590
593
|
{
|
|
591
|
-
categories:
|
|
592
|
-
plugins:
|
|
594
|
+
categories: z15.array(categoryConfigSchema),
|
|
595
|
+
plugins: z15.array(pluginReportSchema).min(1),
|
|
593
596
|
commit: commitSchema.describe("Git commit for which report was collected").nullable()
|
|
594
597
|
},
|
|
595
598
|
{ description: "Collect output data" }
|
|
@@ -605,40 +608,40 @@ var reportSchema = packageVersionSchema({
|
|
|
605
608
|
);
|
|
606
609
|
|
|
607
610
|
// packages/models/src/lib/reports-diff.ts
|
|
608
|
-
import { z as
|
|
611
|
+
import { z as z16 } from "zod";
|
|
609
612
|
function makeComparisonSchema(schema) {
|
|
610
613
|
const sharedDescription = schema.description || "Result";
|
|
611
|
-
return
|
|
614
|
+
return z16.object({
|
|
612
615
|
before: schema.describe(`${sharedDescription} (source commit)`),
|
|
613
616
|
after: schema.describe(`${sharedDescription} (target commit)`)
|
|
614
617
|
});
|
|
615
618
|
}
|
|
616
619
|
function makeArraysComparisonSchema(diffSchema, resultSchema, description) {
|
|
617
|
-
return
|
|
620
|
+
return z16.object(
|
|
618
621
|
{
|
|
619
|
-
changed:
|
|
620
|
-
unchanged:
|
|
621
|
-
added:
|
|
622
|
-
removed:
|
|
622
|
+
changed: z16.array(diffSchema),
|
|
623
|
+
unchanged: z16.array(resultSchema),
|
|
624
|
+
added: z16.array(resultSchema),
|
|
625
|
+
removed: z16.array(resultSchema)
|
|
623
626
|
},
|
|
624
627
|
{ description }
|
|
625
628
|
);
|
|
626
629
|
}
|
|
627
|
-
var scorableMetaSchema =
|
|
630
|
+
var scorableMetaSchema = z16.object({
|
|
628
631
|
slug: slugSchema,
|
|
629
632
|
title: titleSchema,
|
|
630
633
|
docsUrl: docsUrlSchema
|
|
631
634
|
});
|
|
632
635
|
var scorableWithPluginMetaSchema = scorableMetaSchema.merge(
|
|
633
|
-
|
|
636
|
+
z16.object({
|
|
634
637
|
plugin: pluginMetaSchema.pick({ slug: true, title: true, docsUrl: true }).describe("Plugin which defines it")
|
|
635
638
|
})
|
|
636
639
|
);
|
|
637
640
|
var scorableDiffSchema = scorableMetaSchema.merge(
|
|
638
|
-
|
|
641
|
+
z16.object({
|
|
639
642
|
scores: makeComparisonSchema(scoreSchema).merge(
|
|
640
|
-
|
|
641
|
-
diff:
|
|
643
|
+
z16.object({
|
|
644
|
+
diff: z16.number().min(-1).max(1).describe("Score change (`scores.after - scores.before`)")
|
|
642
645
|
})
|
|
643
646
|
).describe("Score comparison")
|
|
644
647
|
})
|
|
@@ -649,10 +652,10 @@ var scorableWithPluginDiffSchema = scorableDiffSchema.merge(
|
|
|
649
652
|
var categoryDiffSchema = scorableDiffSchema;
|
|
650
653
|
var groupDiffSchema = scorableWithPluginDiffSchema;
|
|
651
654
|
var auditDiffSchema = scorableWithPluginDiffSchema.merge(
|
|
652
|
-
|
|
655
|
+
z16.object({
|
|
653
656
|
values: makeComparisonSchema(auditValueSchema).merge(
|
|
654
|
-
|
|
655
|
-
diff:
|
|
657
|
+
z16.object({
|
|
658
|
+
diff: z16.number().int().describe("Value change (`values.after - values.before`)")
|
|
656
659
|
})
|
|
657
660
|
).describe("Audit `value` comparison"),
|
|
658
661
|
displayValues: makeComparisonSchema(auditDisplayValueSchema).describe(
|
|
@@ -661,18 +664,18 @@ var auditDiffSchema = scorableWithPluginDiffSchema.merge(
|
|
|
661
664
|
})
|
|
662
665
|
);
|
|
663
666
|
var categoryResultSchema = scorableMetaSchema.merge(
|
|
664
|
-
|
|
667
|
+
z16.object({ score: scoreSchema })
|
|
665
668
|
);
|
|
666
669
|
var groupResultSchema = scorableWithPluginMetaSchema.merge(
|
|
667
|
-
|
|
670
|
+
z16.object({ score: scoreSchema })
|
|
668
671
|
);
|
|
669
672
|
var auditResultSchema = scorableWithPluginMetaSchema.merge(
|
|
670
673
|
auditOutputSchema.pick({ score: true, value: true, displayValue: true })
|
|
671
674
|
);
|
|
672
|
-
var reportsDiffSchema =
|
|
675
|
+
var reportsDiffSchema = z16.object({
|
|
673
676
|
commits: makeComparisonSchema(commitSchema).nullable().describe("Commits identifying compared reports"),
|
|
674
677
|
portalUrl: urlSchema.optional().describe("Link to comparison page in Code PushUp portal"),
|
|
675
|
-
label:
|
|
678
|
+
label: z16.string().optional().describe("Label (e.g. project name)"),
|
|
676
679
|
categories: makeArraysComparisonSchema(
|
|
677
680
|
categoryDiffSchema,
|
|
678
681
|
categoryResultSchema,
|
package/index.js
CHANGED
|
@@ -159,9 +159,27 @@ function hasNonZeroWeightedRef(refs) {
|
|
|
159
159
|
return refs.reduce((acc, { weight }) => weight + acc, 0) !== 0;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
// packages/models/src/lib/
|
|
162
|
+
// packages/models/src/lib/source.ts
|
|
163
163
|
import { z as z2 } from "zod";
|
|
164
|
-
var
|
|
164
|
+
var sourceFileLocationSchema = z2.object(
|
|
165
|
+
{
|
|
166
|
+
file: filePathSchema.describe("Relative path to source file in Git repo"),
|
|
167
|
+
position: z2.object(
|
|
168
|
+
{
|
|
169
|
+
startLine: positiveIntSchema.describe("Start line"),
|
|
170
|
+
startColumn: positiveIntSchema.describe("Start column").optional(),
|
|
171
|
+
endLine: positiveIntSchema.describe("End line").optional(),
|
|
172
|
+
endColumn: positiveIntSchema.describe("End column").optional()
|
|
173
|
+
},
|
|
174
|
+
{ description: "Location in file" }
|
|
175
|
+
).optional()
|
|
176
|
+
},
|
|
177
|
+
{ description: "Source file location" }
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
// packages/models/src/lib/audit.ts
|
|
181
|
+
import { z as z3 } from "zod";
|
|
182
|
+
var auditSchema = z3.object({
|
|
165
183
|
slug: slugSchema.describe("ID (unique within plugin)")
|
|
166
184
|
}).merge(
|
|
167
185
|
metaSchema({
|
|
@@ -171,7 +189,7 @@ var auditSchema = z2.object({
|
|
|
171
189
|
description: "List of scorable metrics for the given plugin"
|
|
172
190
|
})
|
|
173
191
|
);
|
|
174
|
-
var pluginAuditsSchema =
|
|
192
|
+
var pluginAuditsSchema = z3.array(auditSchema, {
|
|
175
193
|
description: "List of audits maintained in a plugin"
|
|
176
194
|
}).min(1).refine(
|
|
177
195
|
(auditMetadata) => !getDuplicateSlugsInAudits(auditMetadata),
|
|
@@ -190,31 +208,16 @@ function getDuplicateSlugsInAudits(audits) {
|
|
|
190
208
|
}
|
|
191
209
|
|
|
192
210
|
// packages/models/src/lib/audit-output.ts
|
|
193
|
-
import { z as
|
|
211
|
+
import { z as z6 } from "zod";
|
|
194
212
|
|
|
195
213
|
// packages/models/src/lib/issue.ts
|
|
196
|
-
import { z as
|
|
197
|
-
var
|
|
198
|
-
{
|
|
199
|
-
file: filePathSchema.describe("Relative path to source file in Git repo"),
|
|
200
|
-
position: z3.object(
|
|
201
|
-
{
|
|
202
|
-
startLine: positiveIntSchema.describe("Start line"),
|
|
203
|
-
startColumn: positiveIntSchema.describe("Start column").optional(),
|
|
204
|
-
endLine: positiveIntSchema.describe("End line").optional(),
|
|
205
|
-
endColumn: positiveIntSchema.describe("End column").optional()
|
|
206
|
-
},
|
|
207
|
-
{ description: "Location in file" }
|
|
208
|
-
).optional()
|
|
209
|
-
},
|
|
210
|
-
{ description: "Source file location" }
|
|
211
|
-
);
|
|
212
|
-
var issueSeveritySchema = z3.enum(["info", "warning", "error"], {
|
|
214
|
+
import { z as z4 } from "zod";
|
|
215
|
+
var issueSeveritySchema = z4.enum(["info", "warning", "error"], {
|
|
213
216
|
description: "Severity level"
|
|
214
217
|
});
|
|
215
|
-
var issueSchema =
|
|
218
|
+
var issueSchema = z4.object(
|
|
216
219
|
{
|
|
217
|
-
message:
|
|
220
|
+
message: z4.string({ description: "Descriptive error message" }).max(MAX_ISSUE_MESSAGE_LENGTH),
|
|
218
221
|
severity: issueSeveritySchema,
|
|
219
222
|
source: sourceFileLocationSchema.optional()
|
|
220
223
|
},
|
|
@@ -222,60 +225,60 @@ var issueSchema = z3.object(
|
|
|
222
225
|
);
|
|
223
226
|
|
|
224
227
|
// packages/models/src/lib/table.ts
|
|
225
|
-
import { z as
|
|
226
|
-
var tableAlignmentSchema =
|
|
228
|
+
import { z as z5 } from "zod";
|
|
229
|
+
var tableAlignmentSchema = z5.enum(["left", "center", "right"], {
|
|
227
230
|
description: "Cell alignment"
|
|
228
231
|
});
|
|
229
|
-
var tableColumnObjectSchema =
|
|
230
|
-
key:
|
|
231
|
-
label:
|
|
232
|
+
var tableColumnObjectSchema = z5.object({
|
|
233
|
+
key: z5.string(),
|
|
234
|
+
label: z5.string().optional(),
|
|
232
235
|
align: tableAlignmentSchema.optional()
|
|
233
236
|
});
|
|
234
|
-
var tableRowObjectSchema =
|
|
237
|
+
var tableRowObjectSchema = z5.record(tableCellValueSchema, {
|
|
235
238
|
description: "Object row"
|
|
236
239
|
});
|
|
237
|
-
var tableRowPrimitiveSchema =
|
|
240
|
+
var tableRowPrimitiveSchema = z5.array(tableCellValueSchema, {
|
|
238
241
|
description: "Primitive row"
|
|
239
242
|
});
|
|
240
|
-
var tableSharedSchema =
|
|
241
|
-
title:
|
|
243
|
+
var tableSharedSchema = z5.object({
|
|
244
|
+
title: z5.string().optional().describe("Display title for table")
|
|
242
245
|
});
|
|
243
246
|
var tablePrimitiveSchema = tableSharedSchema.merge(
|
|
244
|
-
|
|
247
|
+
z5.object(
|
|
245
248
|
{
|
|
246
|
-
columns:
|
|
247
|
-
rows:
|
|
249
|
+
columns: z5.array(tableAlignmentSchema).optional(),
|
|
250
|
+
rows: z5.array(tableRowPrimitiveSchema)
|
|
248
251
|
},
|
|
249
252
|
{ description: "Table with primitive rows and optional alignment columns" }
|
|
250
253
|
)
|
|
251
254
|
);
|
|
252
255
|
var tableObjectSchema = tableSharedSchema.merge(
|
|
253
|
-
|
|
256
|
+
z5.object(
|
|
254
257
|
{
|
|
255
|
-
columns:
|
|
256
|
-
|
|
257
|
-
|
|
258
|
+
columns: z5.union([
|
|
259
|
+
z5.array(tableAlignmentSchema),
|
|
260
|
+
z5.array(tableColumnObjectSchema)
|
|
258
261
|
]).optional(),
|
|
259
|
-
rows:
|
|
262
|
+
rows: z5.array(tableRowObjectSchema)
|
|
260
263
|
},
|
|
261
264
|
{
|
|
262
265
|
description: "Table with object rows and optional alignment or object columns"
|
|
263
266
|
}
|
|
264
267
|
)
|
|
265
268
|
);
|
|
266
|
-
var tableSchema = (description = "Table information") =>
|
|
269
|
+
var tableSchema = (description = "Table information") => z5.union([tablePrimitiveSchema, tableObjectSchema], { description });
|
|
267
270
|
|
|
268
271
|
// packages/models/src/lib/audit-output.ts
|
|
269
272
|
var auditValueSchema = nonnegativeNumberSchema.describe("Raw numeric value");
|
|
270
|
-
var auditDisplayValueSchema =
|
|
271
|
-
var auditDetailsSchema =
|
|
273
|
+
var auditDisplayValueSchema = z6.string({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" }).optional();
|
|
274
|
+
var auditDetailsSchema = z6.object(
|
|
272
275
|
{
|
|
273
|
-
issues:
|
|
276
|
+
issues: z6.array(issueSchema, { description: "List of findings" }).optional(),
|
|
274
277
|
table: tableSchema("Table of related findings").optional()
|
|
275
278
|
},
|
|
276
279
|
{ description: "Detailed information" }
|
|
277
280
|
);
|
|
278
|
-
var auditOutputSchema =
|
|
281
|
+
var auditOutputSchema = z6.object(
|
|
279
282
|
{
|
|
280
283
|
slug: slugSchema.describe("Reference to audit"),
|
|
281
284
|
displayValue: auditDisplayValueSchema,
|
|
@@ -285,7 +288,7 @@ var auditOutputSchema = z5.object(
|
|
|
285
288
|
},
|
|
286
289
|
{ description: "Audit information" }
|
|
287
290
|
);
|
|
288
|
-
var auditOutputsSchema =
|
|
291
|
+
var auditOutputsSchema = z6.array(auditOutputSchema, {
|
|
289
292
|
description: "List of JSON formatted audit output emitted by the runner process of a plugin"
|
|
290
293
|
}).refine(
|
|
291
294
|
(audits) => !getDuplicateSlugsInAudits2(audits),
|
|
@@ -302,13 +305,13 @@ function getDuplicateSlugsInAudits2(audits) {
|
|
|
302
305
|
}
|
|
303
306
|
|
|
304
307
|
// packages/models/src/lib/category-config.ts
|
|
305
|
-
import { z as
|
|
308
|
+
import { z as z7 } from "zod";
|
|
306
309
|
var categoryRefSchema = weightedRefSchema(
|
|
307
310
|
"Weighted references to audits and/or groups for the category",
|
|
308
311
|
"Slug of an audit or group (depending on `type`)"
|
|
309
312
|
).merge(
|
|
310
|
-
|
|
311
|
-
type:
|
|
313
|
+
z7.object({
|
|
314
|
+
type: z7.enum(["audit", "group"], {
|
|
312
315
|
description: "Discriminant for reference kind, affects where `slug` is looked up"
|
|
313
316
|
}),
|
|
314
317
|
plugin: slugSchema.describe(
|
|
@@ -329,8 +332,8 @@ var categoryConfigSchema = scorableSchema(
|
|
|
329
332
|
description: "Meta info for category"
|
|
330
333
|
})
|
|
331
334
|
).merge(
|
|
332
|
-
|
|
333
|
-
isBinary:
|
|
335
|
+
z7.object({
|
|
336
|
+
isBinary: z7.boolean({
|
|
334
337
|
description: 'Is this a binary category (i.e. only a perfect score considered a "pass")?'
|
|
335
338
|
}).optional()
|
|
336
339
|
})
|
|
@@ -346,7 +349,7 @@ function getDuplicateRefsInCategoryMetrics(metrics) {
|
|
|
346
349
|
metrics.map(({ slug, type, plugin }) => `${type} :: ${plugin} / ${slug}`)
|
|
347
350
|
);
|
|
348
351
|
}
|
|
349
|
-
var categoriesSchema =
|
|
352
|
+
var categoriesSchema = z7.array(categoryConfigSchema, {
|
|
350
353
|
description: "Categorization of individual audits"
|
|
351
354
|
}).refine(
|
|
352
355
|
(categoryCfg) => !getDuplicateSlugCategories(categoryCfg),
|
|
@@ -365,18 +368,18 @@ function getDuplicateSlugCategories(categories) {
|
|
|
365
368
|
}
|
|
366
369
|
|
|
367
370
|
// packages/models/src/lib/commit.ts
|
|
368
|
-
import { z as
|
|
369
|
-
var commitSchema =
|
|
371
|
+
import { z as z8 } from "zod";
|
|
372
|
+
var commitSchema = z8.object(
|
|
370
373
|
{
|
|
371
|
-
hash:
|
|
374
|
+
hash: z8.string({ description: "Commit SHA (full)" }).regex(
|
|
372
375
|
/^[\da-f]{40}$/,
|
|
373
376
|
"Commit SHA should be a 40-character hexadecimal string"
|
|
374
377
|
),
|
|
375
|
-
message:
|
|
376
|
-
date:
|
|
378
|
+
message: z8.string({ description: "Commit message" }),
|
|
379
|
+
date: z8.coerce.date({
|
|
377
380
|
description: "Date and time when commit was authored"
|
|
378
381
|
}),
|
|
379
|
-
author:
|
|
382
|
+
author: z8.string({
|
|
380
383
|
description: "Commit author name"
|
|
381
384
|
}).trim()
|
|
382
385
|
},
|
|
@@ -384,22 +387,22 @@ var commitSchema = z7.object(
|
|
|
384
387
|
);
|
|
385
388
|
|
|
386
389
|
// packages/models/src/lib/core-config.ts
|
|
387
|
-
import { z as
|
|
390
|
+
import { z as z14 } from "zod";
|
|
388
391
|
|
|
389
392
|
// packages/models/src/lib/persist-config.ts
|
|
390
|
-
import { z as
|
|
391
|
-
var formatSchema =
|
|
392
|
-
var persistConfigSchema =
|
|
393
|
+
import { z as z9 } from "zod";
|
|
394
|
+
var formatSchema = z9.enum(["json", "md"]);
|
|
395
|
+
var persistConfigSchema = z9.object({
|
|
393
396
|
outputDir: filePathSchema.describe("Artifacts folder").optional(),
|
|
394
397
|
filename: fileNameSchema.describe("Artifacts file name (without extension)").optional(),
|
|
395
|
-
format:
|
|
398
|
+
format: z9.array(formatSchema).optional()
|
|
396
399
|
});
|
|
397
400
|
|
|
398
401
|
// packages/models/src/lib/plugin-config.ts
|
|
399
|
-
import { z as
|
|
402
|
+
import { z as z12 } from "zod";
|
|
400
403
|
|
|
401
404
|
// packages/models/src/lib/group.ts
|
|
402
|
-
import { z as
|
|
405
|
+
import { z as z10 } from "zod";
|
|
403
406
|
var groupRefSchema = weightedRefSchema(
|
|
404
407
|
"Weighted reference to a group",
|
|
405
408
|
"Reference slug to a group within this plugin (e.g. 'max-lines')"
|
|
@@ -416,7 +419,7 @@ var groupSchema = scorableSchema(
|
|
|
416
419
|
getDuplicateRefsInGroups,
|
|
417
420
|
duplicateRefsInGroupsErrorMsg
|
|
418
421
|
).merge(groupMetaSchema);
|
|
419
|
-
var groupsSchema =
|
|
422
|
+
var groupsSchema = z10.array(groupSchema, {
|
|
420
423
|
description: "List of groups"
|
|
421
424
|
}).optional().refine(
|
|
422
425
|
(groups) => !getDuplicateSlugsInGroups(groups),
|
|
@@ -444,14 +447,14 @@ function getDuplicateSlugsInGroups(groups) {
|
|
|
444
447
|
}
|
|
445
448
|
|
|
446
449
|
// packages/models/src/lib/runner-config.ts
|
|
447
|
-
import { z as
|
|
448
|
-
var outputTransformSchema =
|
|
449
|
-
var runnerConfigSchema =
|
|
450
|
+
import { z as z11 } from "zod";
|
|
451
|
+
var outputTransformSchema = z11.function().args(z11.unknown()).returns(z11.union([auditOutputsSchema, z11.promise(auditOutputsSchema)]));
|
|
452
|
+
var runnerConfigSchema = z11.object(
|
|
450
453
|
{
|
|
451
|
-
command:
|
|
454
|
+
command: z11.string({
|
|
452
455
|
description: "Shell command to execute"
|
|
453
456
|
}),
|
|
454
|
-
args:
|
|
457
|
+
args: z11.array(z11.string({ description: "Command arguments" })).optional(),
|
|
455
458
|
outputFile: filePathSchema.describe("Output path"),
|
|
456
459
|
outputTransform: outputTransformSchema.optional()
|
|
457
460
|
},
|
|
@@ -459,8 +462,8 @@ var runnerConfigSchema = z10.object(
|
|
|
459
462
|
description: "How to execute runner"
|
|
460
463
|
}
|
|
461
464
|
);
|
|
462
|
-
var onProgressSchema =
|
|
463
|
-
var runnerFunctionSchema =
|
|
465
|
+
var onProgressSchema = z11.function().args(z11.unknown()).returns(z11.void());
|
|
466
|
+
var runnerFunctionSchema = z11.function().args(onProgressSchema.optional()).returns(z11.union([auditOutputsSchema, z11.promise(auditOutputsSchema)]));
|
|
464
467
|
|
|
465
468
|
// packages/models/src/lib/plugin-config.ts
|
|
466
469
|
var pluginMetaSchema = packageVersionSchema().merge(
|
|
@@ -471,13 +474,13 @@ var pluginMetaSchema = packageVersionSchema().merge(
|
|
|
471
474
|
description: "Plugin metadata"
|
|
472
475
|
})
|
|
473
476
|
).merge(
|
|
474
|
-
|
|
477
|
+
z12.object({
|
|
475
478
|
slug: slugSchema.describe("Unique plugin slug within core config"),
|
|
476
479
|
icon: materialIconSchema
|
|
477
480
|
})
|
|
478
481
|
);
|
|
479
|
-
var pluginDataSchema =
|
|
480
|
-
runner:
|
|
482
|
+
var pluginDataSchema = z12.object({
|
|
483
|
+
runner: z12.union([runnerConfigSchema, runnerFunctionSchema]),
|
|
481
484
|
audits: pluginAuditsSchema,
|
|
482
485
|
groups: groupsSchema
|
|
483
486
|
});
|
|
@@ -503,22 +506,22 @@ function getMissingRefsFromGroups(pluginCfg) {
|
|
|
503
506
|
}
|
|
504
507
|
|
|
505
508
|
// packages/models/src/lib/upload-config.ts
|
|
506
|
-
import { z as
|
|
507
|
-
var uploadConfigSchema =
|
|
509
|
+
import { z as z13 } from "zod";
|
|
510
|
+
var uploadConfigSchema = z13.object({
|
|
508
511
|
server: urlSchema.describe("URL of deployed portal API"),
|
|
509
|
-
apiKey:
|
|
512
|
+
apiKey: z13.string({
|
|
510
513
|
description: "API key with write access to portal (use `process.env` for security)"
|
|
511
514
|
}),
|
|
512
515
|
organization: slugSchema.describe(
|
|
513
516
|
"Organization slug from Code PushUp portal"
|
|
514
517
|
),
|
|
515
518
|
project: slugSchema.describe("Project slug from Code PushUp portal"),
|
|
516
|
-
timeout:
|
|
519
|
+
timeout: z13.number({ description: "Request timeout in minutes (default is 5)" }).positive().int().optional()
|
|
517
520
|
});
|
|
518
521
|
|
|
519
522
|
// packages/models/src/lib/core-config.ts
|
|
520
|
-
var unrefinedCoreConfigSchema =
|
|
521
|
-
plugins:
|
|
523
|
+
var unrefinedCoreConfigSchema = z14.object({
|
|
524
|
+
plugins: z14.array(pluginConfigSchema, {
|
|
522
525
|
description: "List of plugins to be used (official, community-provided, or custom)"
|
|
523
526
|
}).min(1),
|
|
524
527
|
/** portal configuration for persisting results */
|
|
@@ -541,7 +544,7 @@ function refineCoreConfig(schema) {
|
|
|
541
544
|
}
|
|
542
545
|
|
|
543
546
|
// packages/models/src/lib/report.ts
|
|
544
|
-
import { z as
|
|
547
|
+
import { z as z15 } from "zod";
|
|
545
548
|
var auditReportSchema = auditSchema.merge(auditOutputSchema);
|
|
546
549
|
var pluginReportSchema = pluginMetaSchema.merge(
|
|
547
550
|
executionMetaSchema({
|
|
@@ -549,9 +552,9 @@ var pluginReportSchema = pluginMetaSchema.merge(
|
|
|
549
552
|
descriptionDuration: "Duration of the plugin run in ms"
|
|
550
553
|
})
|
|
551
554
|
).merge(
|
|
552
|
-
|
|
553
|
-
audits:
|
|
554
|
-
groups:
|
|
555
|
+
z15.object({
|
|
556
|
+
audits: z15.array(auditReportSchema).min(1),
|
|
557
|
+
groups: z15.array(groupSchema).optional()
|
|
555
558
|
})
|
|
556
559
|
).refine(
|
|
557
560
|
(pluginReport) => !getMissingRefsFromGroups2(pluginReport.audits, pluginReport.groups ?? []),
|
|
@@ -585,10 +588,10 @@ var reportSchema = packageVersionSchema({
|
|
|
585
588
|
descriptionDuration: "Duration of the collect run in ms"
|
|
586
589
|
})
|
|
587
590
|
).merge(
|
|
588
|
-
|
|
591
|
+
z15.object(
|
|
589
592
|
{
|
|
590
|
-
categories:
|
|
591
|
-
plugins:
|
|
593
|
+
categories: z15.array(categoryConfigSchema),
|
|
594
|
+
plugins: z15.array(pluginReportSchema).min(1),
|
|
592
595
|
commit: commitSchema.describe("Git commit for which report was collected").nullable()
|
|
593
596
|
},
|
|
594
597
|
{ description: "Collect output data" }
|
|
@@ -604,40 +607,40 @@ var reportSchema = packageVersionSchema({
|
|
|
604
607
|
);
|
|
605
608
|
|
|
606
609
|
// packages/models/src/lib/reports-diff.ts
|
|
607
|
-
import { z as
|
|
610
|
+
import { z as z16 } from "zod";
|
|
608
611
|
function makeComparisonSchema(schema) {
|
|
609
612
|
const sharedDescription = schema.description || "Result";
|
|
610
|
-
return
|
|
613
|
+
return z16.object({
|
|
611
614
|
before: schema.describe(`${sharedDescription} (source commit)`),
|
|
612
615
|
after: schema.describe(`${sharedDescription} (target commit)`)
|
|
613
616
|
});
|
|
614
617
|
}
|
|
615
618
|
function makeArraysComparisonSchema(diffSchema, resultSchema, description) {
|
|
616
|
-
return
|
|
619
|
+
return z16.object(
|
|
617
620
|
{
|
|
618
|
-
changed:
|
|
619
|
-
unchanged:
|
|
620
|
-
added:
|
|
621
|
-
removed:
|
|
621
|
+
changed: z16.array(diffSchema),
|
|
622
|
+
unchanged: z16.array(resultSchema),
|
|
623
|
+
added: z16.array(resultSchema),
|
|
624
|
+
removed: z16.array(resultSchema)
|
|
622
625
|
},
|
|
623
626
|
{ description }
|
|
624
627
|
);
|
|
625
628
|
}
|
|
626
|
-
var scorableMetaSchema =
|
|
629
|
+
var scorableMetaSchema = z16.object({
|
|
627
630
|
slug: slugSchema,
|
|
628
631
|
title: titleSchema,
|
|
629
632
|
docsUrl: docsUrlSchema
|
|
630
633
|
});
|
|
631
634
|
var scorableWithPluginMetaSchema = scorableMetaSchema.merge(
|
|
632
|
-
|
|
635
|
+
z16.object({
|
|
633
636
|
plugin: pluginMetaSchema.pick({ slug: true, title: true, docsUrl: true }).describe("Plugin which defines it")
|
|
634
637
|
})
|
|
635
638
|
);
|
|
636
639
|
var scorableDiffSchema = scorableMetaSchema.merge(
|
|
637
|
-
|
|
640
|
+
z16.object({
|
|
638
641
|
scores: makeComparisonSchema(scoreSchema).merge(
|
|
639
|
-
|
|
640
|
-
diff:
|
|
642
|
+
z16.object({
|
|
643
|
+
diff: z16.number().min(-1).max(1).describe("Score change (`scores.after - scores.before`)")
|
|
641
644
|
})
|
|
642
645
|
).describe("Score comparison")
|
|
643
646
|
})
|
|
@@ -648,10 +651,10 @@ var scorableWithPluginDiffSchema = scorableDiffSchema.merge(
|
|
|
648
651
|
var categoryDiffSchema = scorableDiffSchema;
|
|
649
652
|
var groupDiffSchema = scorableWithPluginDiffSchema;
|
|
650
653
|
var auditDiffSchema = scorableWithPluginDiffSchema.merge(
|
|
651
|
-
|
|
654
|
+
z16.object({
|
|
652
655
|
values: makeComparisonSchema(auditValueSchema).merge(
|
|
653
|
-
|
|
654
|
-
diff:
|
|
656
|
+
z16.object({
|
|
657
|
+
diff: z16.number().int().describe("Value change (`values.after - values.before`)")
|
|
655
658
|
})
|
|
656
659
|
).describe("Audit `value` comparison"),
|
|
657
660
|
displayValues: makeComparisonSchema(auditDisplayValueSchema).describe(
|
|
@@ -660,18 +663,18 @@ var auditDiffSchema = scorableWithPluginDiffSchema.merge(
|
|
|
660
663
|
})
|
|
661
664
|
);
|
|
662
665
|
var categoryResultSchema = scorableMetaSchema.merge(
|
|
663
|
-
|
|
666
|
+
z16.object({ score: scoreSchema })
|
|
664
667
|
);
|
|
665
668
|
var groupResultSchema = scorableWithPluginMetaSchema.merge(
|
|
666
|
-
|
|
669
|
+
z16.object({ score: scoreSchema })
|
|
667
670
|
);
|
|
668
671
|
var auditResultSchema = scorableWithPluginMetaSchema.merge(
|
|
669
672
|
auditOutputSchema.pick({ score: true, value: true, displayValue: true })
|
|
670
673
|
);
|
|
671
|
-
var reportsDiffSchema =
|
|
674
|
+
var reportsDiffSchema = z16.object({
|
|
672
675
|
commits: makeComparisonSchema(commitSchema).nullable().describe("Commits identifying compared reports"),
|
|
673
676
|
portalUrl: urlSchema.optional().describe("Link to comparison page in Code PushUp portal"),
|
|
674
|
-
label:
|
|
677
|
+
label: z16.string().optional().describe("Label (e.g. project name)"),
|
|
675
678
|
categories: makeArraysComparisonSchema(
|
|
676
679
|
categoryDiffSchema,
|
|
677
680
|
categoryResultSchema,
|
|
@@ -811,38 +814,38 @@ import { bold as bold4, cyan, cyanBright, green as green2, red } from "ansis";
|
|
|
811
814
|
|
|
812
815
|
// packages/plugin-coverage/package.json
|
|
813
816
|
var name = "@code-pushup/coverage-plugin";
|
|
814
|
-
var version = "0.
|
|
817
|
+
var version = "0.52.0";
|
|
815
818
|
|
|
816
819
|
// packages/plugin-coverage/src/lib/config.ts
|
|
817
|
-
import { z as
|
|
818
|
-
var coverageTypeSchema =
|
|
819
|
-
var coverageResultSchema =
|
|
820
|
-
|
|
821
|
-
resultsPath:
|
|
820
|
+
import { z as z17 } from "zod";
|
|
821
|
+
var coverageTypeSchema = z17.enum(["function", "branch", "line"]);
|
|
822
|
+
var coverageResultSchema = z17.union([
|
|
823
|
+
z17.object({
|
|
824
|
+
resultsPath: z17.string({
|
|
822
825
|
description: "Path to coverage results for Nx setup."
|
|
823
826
|
}).includes("lcov"),
|
|
824
|
-
pathToProject:
|
|
827
|
+
pathToProject: z17.string({
|
|
825
828
|
description: "Path from workspace root to project root. Necessary for LCOV reports which provide a relative path."
|
|
826
829
|
}).optional()
|
|
827
830
|
}),
|
|
828
|
-
|
|
831
|
+
z17.string({
|
|
829
832
|
description: "Path to coverage results for a single project setup."
|
|
830
833
|
}).includes("lcov")
|
|
831
834
|
]);
|
|
832
|
-
var coveragePluginConfigSchema =
|
|
833
|
-
coverageToolCommand:
|
|
834
|
-
command:
|
|
835
|
-
args:
|
|
835
|
+
var coveragePluginConfigSchema = z17.object({
|
|
836
|
+
coverageToolCommand: z17.object({
|
|
837
|
+
command: z17.string({ description: "Command to run coverage tool." }).min(1),
|
|
838
|
+
args: z17.array(z17.string(), {
|
|
836
839
|
description: "Arguments to be passed to the coverage tool."
|
|
837
840
|
}).optional()
|
|
838
841
|
}).optional(),
|
|
839
|
-
coverageTypes:
|
|
842
|
+
coverageTypes: z17.array(coverageTypeSchema, {
|
|
840
843
|
description: "Coverage types measured. Defaults to all available types."
|
|
841
844
|
}).min(1).default(["function", "branch", "line"]),
|
|
842
|
-
reports:
|
|
845
|
+
reports: z17.array(coverageResultSchema, {
|
|
843
846
|
description: "Path to all code coverage report files. Only LCOV format is supported for now."
|
|
844
847
|
}).min(1),
|
|
845
|
-
perfectScoreThreshold:
|
|
848
|
+
perfectScoreThreshold: z17.number({
|
|
846
849
|
description: "Score will be 1 (perfect) for this coverage and above. Score range is 0 - 1."
|
|
847
850
|
}).gt(0).max(1).optional()
|
|
848
851
|
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/coverage-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.0",
|
|
4
4
|
"description": "Code PushUp plugin for tracking code coverage ☂",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@code-pushup/models": "0.
|
|
7
|
-
"@code-pushup/utils": "0.
|
|
6
|
+
"@code-pushup/models": "0.52.0",
|
|
7
|
+
"@code-pushup/utils": "0.52.0",
|
|
8
8
|
"ansis": "^3.3.0",
|
|
9
9
|
"parse-lcov": "^1.0.4",
|
|
10
10
|
"zod": "^3.22.4"
|
|
@@ -35,6 +35,9 @@
|
|
|
35
35
|
"url": "git+https://github.com/code-pushup/cli.git",
|
|
36
36
|
"directory": "packages/plugin-coverage"
|
|
37
37
|
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
38
41
|
"type": "module",
|
|
39
42
|
"main": "./index.js",
|
|
40
43
|
"types": "./src/index.d.ts"
|