@code-pushup/lighthouse-plugin 0.49.0 → 0.51.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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // packages/plugin-lighthouse/package.json
2
2
  var name = "@code-pushup/lighthouse-plugin";
3
- var version = "0.49.0";
3
+ var version = "0.51.0";
4
4
 
5
5
  // packages/plugin-lighthouse/src/lib/constants.ts
6
6
  import { join } from "node:path";
@@ -162,9 +162,27 @@ function hasNonZeroWeightedRef(refs) {
162
162
  return refs.reduce((acc, { weight }) => weight + acc, 0) !== 0;
163
163
  }
164
164
 
165
- // packages/models/src/lib/audit.ts
165
+ // packages/models/src/lib/source.ts
166
166
  import { z as z2 } from "zod";
167
- var auditSchema = z2.object({
167
+ var sourceFileLocationSchema = z2.object(
168
+ {
169
+ file: filePathSchema.describe("Relative path to source file in Git repo"),
170
+ position: z2.object(
171
+ {
172
+ startLine: positiveIntSchema.describe("Start line"),
173
+ startColumn: positiveIntSchema.describe("Start column").optional(),
174
+ endLine: positiveIntSchema.describe("End line").optional(),
175
+ endColumn: positiveIntSchema.describe("End column").optional()
176
+ },
177
+ { description: "Location in file" }
178
+ ).optional()
179
+ },
180
+ { description: "Source file location" }
181
+ );
182
+
183
+ // packages/models/src/lib/audit.ts
184
+ import { z as z3 } from "zod";
185
+ var auditSchema = z3.object({
168
186
  slug: slugSchema.describe("ID (unique within plugin)")
169
187
  }).merge(
170
188
  metaSchema({
@@ -174,7 +192,7 @@ var auditSchema = z2.object({
174
192
  description: "List of scorable metrics for the given plugin"
175
193
  })
176
194
  );
177
- var pluginAuditsSchema = z2.array(auditSchema, {
195
+ var pluginAuditsSchema = z3.array(auditSchema, {
178
196
  description: "List of audits maintained in a plugin"
179
197
  }).min(1).refine(
180
198
  (auditMetadata) => !getDuplicateSlugsInAudits(auditMetadata),
@@ -193,31 +211,16 @@ function getDuplicateSlugsInAudits(audits2) {
193
211
  }
194
212
 
195
213
  // packages/models/src/lib/audit-output.ts
196
- import { z as z5 } from "zod";
214
+ import { z as z6 } from "zod";
197
215
 
198
216
  // packages/models/src/lib/issue.ts
199
- import { z as z3 } from "zod";
200
- var sourceFileLocationSchema = z3.object(
201
- {
202
- file: filePathSchema.describe("Relative path to source file in Git repo"),
203
- position: z3.object(
204
- {
205
- startLine: positiveIntSchema.describe("Start line"),
206
- startColumn: positiveIntSchema.describe("Start column").optional(),
207
- endLine: positiveIntSchema.describe("End line").optional(),
208
- endColumn: positiveIntSchema.describe("End column").optional()
209
- },
210
- { description: "Location in file" }
211
- ).optional()
212
- },
213
- { description: "Source file location" }
214
- );
215
- var issueSeveritySchema = z3.enum(["info", "warning", "error"], {
217
+ import { z as z4 } from "zod";
218
+ var issueSeveritySchema = z4.enum(["info", "warning", "error"], {
216
219
  description: "Severity level"
217
220
  });
218
- var issueSchema = z3.object(
221
+ var issueSchema = z4.object(
219
222
  {
220
- message: z3.string({ description: "Descriptive error message" }).max(MAX_ISSUE_MESSAGE_LENGTH),
223
+ message: z4.string({ description: "Descriptive error message" }).max(MAX_ISSUE_MESSAGE_LENGTH),
221
224
  severity: issueSeveritySchema,
222
225
  source: sourceFileLocationSchema.optional()
223
226
  },
@@ -225,60 +228,60 @@ var issueSchema = z3.object(
225
228
  );
226
229
 
227
230
  // packages/models/src/lib/table.ts
228
- import { z as z4 } from "zod";
229
- var tableAlignmentSchema = z4.enum(["left", "center", "right"], {
231
+ import { z as z5 } from "zod";
232
+ var tableAlignmentSchema = z5.enum(["left", "center", "right"], {
230
233
  description: "Cell alignment"
231
234
  });
232
- var tableColumnObjectSchema = z4.object({
233
- key: z4.string(),
234
- label: z4.string().optional(),
235
+ var tableColumnObjectSchema = z5.object({
236
+ key: z5.string(),
237
+ label: z5.string().optional(),
235
238
  align: tableAlignmentSchema.optional()
236
239
  });
237
- var tableRowObjectSchema = z4.record(tableCellValueSchema, {
240
+ var tableRowObjectSchema = z5.record(tableCellValueSchema, {
238
241
  description: "Object row"
239
242
  });
240
- var tableRowPrimitiveSchema = z4.array(tableCellValueSchema, {
243
+ var tableRowPrimitiveSchema = z5.array(tableCellValueSchema, {
241
244
  description: "Primitive row"
242
245
  });
243
- var tableSharedSchema = z4.object({
244
- title: z4.string().optional().describe("Display title for table")
246
+ var tableSharedSchema = z5.object({
247
+ title: z5.string().optional().describe("Display title for table")
245
248
  });
246
249
  var tablePrimitiveSchema = tableSharedSchema.merge(
247
- z4.object(
250
+ z5.object(
248
251
  {
249
- columns: z4.array(tableAlignmentSchema).optional(),
250
- rows: z4.array(tableRowPrimitiveSchema)
252
+ columns: z5.array(tableAlignmentSchema).optional(),
253
+ rows: z5.array(tableRowPrimitiveSchema)
251
254
  },
252
255
  { description: "Table with primitive rows and optional alignment columns" }
253
256
  )
254
257
  );
255
258
  var tableObjectSchema = tableSharedSchema.merge(
256
- z4.object(
259
+ z5.object(
257
260
  {
258
- columns: z4.union([
259
- z4.array(tableAlignmentSchema),
260
- z4.array(tableColumnObjectSchema)
261
+ columns: z5.union([
262
+ z5.array(tableAlignmentSchema),
263
+ z5.array(tableColumnObjectSchema)
261
264
  ]).optional(),
262
- rows: z4.array(tableRowObjectSchema)
265
+ rows: z5.array(tableRowObjectSchema)
263
266
  },
264
267
  {
265
268
  description: "Table with object rows and optional alignment or object columns"
266
269
  }
267
270
  )
268
271
  );
269
- var tableSchema = (description = "Table information") => z4.union([tablePrimitiveSchema, tableObjectSchema], { description });
272
+ var tableSchema = (description = "Table information") => z5.union([tablePrimitiveSchema, tableObjectSchema], { description });
270
273
 
271
274
  // packages/models/src/lib/audit-output.ts
272
275
  var auditValueSchema = nonnegativeNumberSchema.describe("Raw numeric value");
273
- var auditDisplayValueSchema = z5.string({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" }).optional();
274
- var auditDetailsSchema = z5.object(
276
+ var auditDisplayValueSchema = z6.string({ description: "Formatted value (e.g. '0.9 s', '2.1 MB')" }).optional();
277
+ var auditDetailsSchema = z6.object(
275
278
  {
276
- issues: z5.array(issueSchema, { description: "List of findings" }).optional(),
279
+ issues: z6.array(issueSchema, { description: "List of findings" }).optional(),
277
280
  table: tableSchema("Table of related findings").optional()
278
281
  },
279
282
  { description: "Detailed information" }
280
283
  );
281
- var auditOutputSchema = z5.object(
284
+ var auditOutputSchema = z6.object(
282
285
  {
283
286
  slug: slugSchema.describe("Reference to audit"),
284
287
  displayValue: auditDisplayValueSchema,
@@ -288,7 +291,7 @@ var auditOutputSchema = z5.object(
288
291
  },
289
292
  { description: "Audit information" }
290
293
  );
291
- var auditOutputsSchema = z5.array(auditOutputSchema, {
294
+ var auditOutputsSchema = z6.array(auditOutputSchema, {
292
295
  description: "List of JSON formatted audit output emitted by the runner process of a plugin"
293
296
  }).refine(
294
297
  (audits2) => !getDuplicateSlugsInAudits2(audits2),
@@ -305,13 +308,13 @@ function getDuplicateSlugsInAudits2(audits2) {
305
308
  }
306
309
 
307
310
  // packages/models/src/lib/category-config.ts
308
- import { z as z6 } from "zod";
311
+ import { z as z7 } from "zod";
309
312
  var categoryRefSchema = weightedRefSchema(
310
313
  "Weighted references to audits and/or groups for the category",
311
314
  "Slug of an audit or group (depending on `type`)"
312
315
  ).merge(
313
- z6.object({
314
- type: z6.enum(["audit", "group"], {
316
+ z7.object({
317
+ type: z7.enum(["audit", "group"], {
315
318
  description: "Discriminant for reference kind, affects where `slug` is looked up"
316
319
  }),
317
320
  plugin: slugSchema.describe(
@@ -332,8 +335,8 @@ var categoryConfigSchema = scorableSchema(
332
335
  description: "Meta info for category"
333
336
  })
334
337
  ).merge(
335
- z6.object({
336
- isBinary: z6.boolean({
338
+ z7.object({
339
+ isBinary: z7.boolean({
337
340
  description: 'Is this a binary category (i.e. only a perfect score considered a "pass")?'
338
341
  }).optional()
339
342
  })
@@ -349,7 +352,7 @@ function getDuplicateRefsInCategoryMetrics(metrics) {
349
352
  metrics.map(({ slug, type, plugin }) => `${type} :: ${plugin} / ${slug}`)
350
353
  );
351
354
  }
352
- var categoriesSchema = z6.array(categoryConfigSchema, {
355
+ var categoriesSchema = z7.array(categoryConfigSchema, {
353
356
  description: "Categorization of individual audits"
354
357
  }).refine(
355
358
  (categoryCfg) => !getDuplicateSlugCategories(categoryCfg),
@@ -368,18 +371,18 @@ function getDuplicateSlugCategories(categories2) {
368
371
  }
369
372
 
370
373
  // packages/models/src/lib/commit.ts
371
- import { z as z7 } from "zod";
372
- var commitSchema = z7.object(
374
+ import { z as z8 } from "zod";
375
+ var commitSchema = z8.object(
373
376
  {
374
- hash: z7.string({ description: "Commit SHA (full)" }).regex(
377
+ hash: z8.string({ description: "Commit SHA (full)" }).regex(
375
378
  /^[\da-f]{40}$/,
376
379
  "Commit SHA should be a 40-character hexadecimal string"
377
380
  ),
378
- message: z7.string({ description: "Commit message" }),
379
- date: z7.coerce.date({
381
+ message: z8.string({ description: "Commit message" }),
382
+ date: z8.coerce.date({
380
383
  description: "Date and time when commit was authored"
381
384
  }),
382
- author: z7.string({
385
+ author: z8.string({
383
386
  description: "Commit author name"
384
387
  }).trim()
385
388
  },
@@ -387,22 +390,22 @@ var commitSchema = z7.object(
387
390
  );
388
391
 
389
392
  // packages/models/src/lib/core-config.ts
390
- import { z as z13 } from "zod";
393
+ import { z as z14 } from "zod";
391
394
 
392
395
  // packages/models/src/lib/persist-config.ts
393
- import { z as z8 } from "zod";
394
- var formatSchema = z8.enum(["json", "md"]);
395
- var persistConfigSchema = z8.object({
396
+ import { z as z9 } from "zod";
397
+ var formatSchema = z9.enum(["json", "md"]);
398
+ var persistConfigSchema = z9.object({
396
399
  outputDir: filePathSchema.describe("Artifacts folder").optional(),
397
400
  filename: fileNameSchema.describe("Artifacts file name (without extension)").optional(),
398
- format: z8.array(formatSchema).optional()
401
+ format: z9.array(formatSchema).optional()
399
402
  });
400
403
 
401
404
  // packages/models/src/lib/plugin-config.ts
402
- import { z as z11 } from "zod";
405
+ import { z as z12 } from "zod";
403
406
 
404
407
  // packages/models/src/lib/group.ts
405
- import { z as z9 } from "zod";
408
+ import { z as z10 } from "zod";
406
409
  var groupRefSchema = weightedRefSchema(
407
410
  "Weighted reference to a group",
408
411
  "Reference slug to a group within this plugin (e.g. 'max-lines')"
@@ -419,7 +422,7 @@ var groupSchema = scorableSchema(
419
422
  getDuplicateRefsInGroups,
420
423
  duplicateRefsInGroupsErrorMsg
421
424
  ).merge(groupMetaSchema);
422
- var groupsSchema = z9.array(groupSchema, {
425
+ var groupsSchema = z10.array(groupSchema, {
423
426
  description: "List of groups"
424
427
  }).optional().refine(
425
428
  (groups) => !getDuplicateSlugsInGroups(groups),
@@ -447,14 +450,14 @@ function getDuplicateSlugsInGroups(groups) {
447
450
  }
448
451
 
449
452
  // packages/models/src/lib/runner-config.ts
450
- import { z as z10 } from "zod";
451
- var outputTransformSchema = z10.function().args(z10.unknown()).returns(z10.union([auditOutputsSchema, z10.promise(auditOutputsSchema)]));
452
- var runnerConfigSchema = z10.object(
453
+ import { z as z11 } from "zod";
454
+ var outputTransformSchema = z11.function().args(z11.unknown()).returns(z11.union([auditOutputsSchema, z11.promise(auditOutputsSchema)]));
455
+ var runnerConfigSchema = z11.object(
453
456
  {
454
- command: z10.string({
457
+ command: z11.string({
455
458
  description: "Shell command to execute"
456
459
  }),
457
- args: z10.array(z10.string({ description: "Command arguments" })).optional(),
460
+ args: z11.array(z11.string({ description: "Command arguments" })).optional(),
458
461
  outputFile: filePathSchema.describe("Output path"),
459
462
  outputTransform: outputTransformSchema.optional()
460
463
  },
@@ -462,8 +465,8 @@ var runnerConfigSchema = z10.object(
462
465
  description: "How to execute runner"
463
466
  }
464
467
  );
465
- var onProgressSchema = z10.function().args(z10.unknown()).returns(z10.void());
466
- var runnerFunctionSchema = z10.function().args(onProgressSchema.optional()).returns(z10.union([auditOutputsSchema, z10.promise(auditOutputsSchema)]));
468
+ var onProgressSchema = z11.function().args(z11.unknown()).returns(z11.void());
469
+ var runnerFunctionSchema = z11.function().args(onProgressSchema.optional()).returns(z11.union([auditOutputsSchema, z11.promise(auditOutputsSchema)]));
467
470
 
468
471
  // packages/models/src/lib/plugin-config.ts
469
472
  var pluginMetaSchema = packageVersionSchema().merge(
@@ -474,13 +477,13 @@ var pluginMetaSchema = packageVersionSchema().merge(
474
477
  description: "Plugin metadata"
475
478
  })
476
479
  ).merge(
477
- z11.object({
480
+ z12.object({
478
481
  slug: slugSchema.describe("Unique plugin slug within core config"),
479
482
  icon: materialIconSchema
480
483
  })
481
484
  );
482
- var pluginDataSchema = z11.object({
483
- runner: z11.union([runnerConfigSchema, runnerFunctionSchema]),
485
+ var pluginDataSchema = z12.object({
486
+ runner: z12.union([runnerConfigSchema, runnerFunctionSchema]),
484
487
  audits: pluginAuditsSchema,
485
488
  groups: groupsSchema
486
489
  });
@@ -506,22 +509,22 @@ function getMissingRefsFromGroups(pluginCfg) {
506
509
  }
507
510
 
508
511
  // packages/models/src/lib/upload-config.ts
509
- import { z as z12 } from "zod";
510
- var uploadConfigSchema = z12.object({
512
+ import { z as z13 } from "zod";
513
+ var uploadConfigSchema = z13.object({
511
514
  server: urlSchema.describe("URL of deployed portal API"),
512
- apiKey: z12.string({
515
+ apiKey: z13.string({
513
516
  description: "API key with write access to portal (use `process.env` for security)"
514
517
  }),
515
518
  organization: slugSchema.describe(
516
519
  "Organization slug from Code PushUp portal"
517
520
  ),
518
521
  project: slugSchema.describe("Project slug from Code PushUp portal"),
519
- timeout: z12.number({ description: "Request timeout in minutes (default is 5)" }).positive().int().optional()
522
+ timeout: z13.number({ description: "Request timeout in minutes (default is 5)" }).positive().int().optional()
520
523
  });
521
524
 
522
525
  // packages/models/src/lib/core-config.ts
523
- var unrefinedCoreConfigSchema = z13.object({
524
- plugins: z13.array(pluginConfigSchema, {
526
+ var unrefinedCoreConfigSchema = z14.object({
527
+ plugins: z14.array(pluginConfigSchema, {
525
528
  description: "List of plugins to be used (official, community-provided, or custom)"
526
529
  }).min(1),
527
530
  /** portal configuration for persisting results */
@@ -547,7 +550,7 @@ function refineCoreConfig(schema) {
547
550
  var DEFAULT_PERSIST_OUTPUT_DIR = ".code-pushup";
548
551
 
549
552
  // packages/models/src/lib/report.ts
550
- import { z as z14 } from "zod";
553
+ import { z as z15 } from "zod";
551
554
  var auditReportSchema = auditSchema.merge(auditOutputSchema);
552
555
  var pluginReportSchema = pluginMetaSchema.merge(
553
556
  executionMetaSchema({
@@ -555,9 +558,9 @@ var pluginReportSchema = pluginMetaSchema.merge(
555
558
  descriptionDuration: "Duration of the plugin run in ms"
556
559
  })
557
560
  ).merge(
558
- z14.object({
559
- audits: z14.array(auditReportSchema).min(1),
560
- groups: z14.array(groupSchema).optional()
561
+ z15.object({
562
+ audits: z15.array(auditReportSchema).min(1),
563
+ groups: z15.array(groupSchema).optional()
561
564
  })
562
565
  ).refine(
563
566
  (pluginReport) => !getMissingRefsFromGroups2(pluginReport.audits, pluginReport.groups ?? []),
@@ -591,10 +594,10 @@ var reportSchema = packageVersionSchema({
591
594
  descriptionDuration: "Duration of the collect run in ms"
592
595
  })
593
596
  ).merge(
594
- z14.object(
597
+ z15.object(
595
598
  {
596
- categories: z14.array(categoryConfigSchema),
597
- plugins: z14.array(pluginReportSchema).min(1),
599
+ categories: z15.array(categoryConfigSchema),
600
+ plugins: z15.array(pluginReportSchema).min(1),
598
601
  commit: commitSchema.describe("Git commit for which report was collected").nullable()
599
602
  },
600
603
  { description: "Collect output data" }
@@ -610,40 +613,40 @@ var reportSchema = packageVersionSchema({
610
613
  );
611
614
 
612
615
  // packages/models/src/lib/reports-diff.ts
613
- import { z as z15 } from "zod";
616
+ import { z as z16 } from "zod";
614
617
  function makeComparisonSchema(schema) {
615
618
  const sharedDescription = schema.description || "Result";
616
- return z15.object({
619
+ return z16.object({
617
620
  before: schema.describe(`${sharedDescription} (source commit)`),
618
621
  after: schema.describe(`${sharedDescription} (target commit)`)
619
622
  });
620
623
  }
621
624
  function makeArraysComparisonSchema(diffSchema, resultSchema, description) {
622
- return z15.object(
625
+ return z16.object(
623
626
  {
624
- changed: z15.array(diffSchema),
625
- unchanged: z15.array(resultSchema),
626
- added: z15.array(resultSchema),
627
- removed: z15.array(resultSchema)
627
+ changed: z16.array(diffSchema),
628
+ unchanged: z16.array(resultSchema),
629
+ added: z16.array(resultSchema),
630
+ removed: z16.array(resultSchema)
628
631
  },
629
632
  { description }
630
633
  );
631
634
  }
632
- var scorableMetaSchema = z15.object({
635
+ var scorableMetaSchema = z16.object({
633
636
  slug: slugSchema,
634
637
  title: titleSchema,
635
638
  docsUrl: docsUrlSchema
636
639
  });
637
640
  var scorableWithPluginMetaSchema = scorableMetaSchema.merge(
638
- z15.object({
641
+ z16.object({
639
642
  plugin: pluginMetaSchema.pick({ slug: true, title: true, docsUrl: true }).describe("Plugin which defines it")
640
643
  })
641
644
  );
642
645
  var scorableDiffSchema = scorableMetaSchema.merge(
643
- z15.object({
646
+ z16.object({
644
647
  scores: makeComparisonSchema(scoreSchema).merge(
645
- z15.object({
646
- diff: z15.number().min(-1).max(1).describe("Score change (`scores.after - scores.before`)")
648
+ z16.object({
649
+ diff: z16.number().min(-1).max(1).describe("Score change (`scores.after - scores.before`)")
647
650
  })
648
651
  ).describe("Score comparison")
649
652
  })
@@ -654,10 +657,10 @@ var scorableWithPluginDiffSchema = scorableDiffSchema.merge(
654
657
  var categoryDiffSchema = scorableDiffSchema;
655
658
  var groupDiffSchema = scorableWithPluginDiffSchema;
656
659
  var auditDiffSchema = scorableWithPluginDiffSchema.merge(
657
- z15.object({
660
+ z16.object({
658
661
  values: makeComparisonSchema(auditValueSchema).merge(
659
- z15.object({
660
- diff: z15.number().int().describe("Value change (`values.after - values.before`)")
662
+ z16.object({
663
+ diff: z16.number().int().describe("Value change (`values.after - values.before`)")
661
664
  })
662
665
  ).describe("Audit `value` comparison"),
663
666
  displayValues: makeComparisonSchema(auditDisplayValueSchema).describe(
@@ -666,16 +669,18 @@ var auditDiffSchema = scorableWithPluginDiffSchema.merge(
666
669
  })
667
670
  );
668
671
  var categoryResultSchema = scorableMetaSchema.merge(
669
- z15.object({ score: scoreSchema })
672
+ z16.object({ score: scoreSchema })
670
673
  );
671
674
  var groupResultSchema = scorableWithPluginMetaSchema.merge(
672
- z15.object({ score: scoreSchema })
675
+ z16.object({ score: scoreSchema })
673
676
  );
674
677
  var auditResultSchema = scorableWithPluginMetaSchema.merge(
675
678
  auditOutputSchema.pick({ score: true, value: true, displayValue: true })
676
679
  );
677
- var reportsDiffSchema = z15.object({
680
+ var reportsDiffSchema = z16.object({
678
681
  commits: makeComparisonSchema(commitSchema).nullable().describe("Commits identifying compared reports"),
682
+ portalUrl: urlSchema.optional().describe("Link to comparison page in Code PushUp portal"),
683
+ label: z16.string().optional().describe("Label (e.g. project name)"),
679
684
  categories: makeArraysComparisonSchema(
680
685
  categoryDiffSchema,
681
686
  categoryResultSchema,
@@ -720,6 +725,13 @@ import { md } from "build-md";
720
725
  // packages/utils/src/lib/reports/constants.ts
721
726
  var TERMINAL_WIDTH = 80;
722
727
 
728
+ // packages/utils/src/lib/reports/utils.ts
729
+ function formatReportScore(score) {
730
+ const scaledScore = score * 100;
731
+ const roundedScore = Math.round(scaledScore);
732
+ return roundedScore === 100 && score !== 1 ? Math.floor(scaledScore).toString() : roundedScore.toString();
733
+ }
734
+
723
735
  // packages/utils/src/lib/file-system.ts
724
736
  import { bold, gray } from "ansis";
725
737
  import { bundleRequire } from "bundle-require";
@@ -960,17 +972,23 @@ var html = {
960
972
  };
961
973
 
962
974
  // packages/utils/src/lib/reports/formatting.ts
963
- import { MarkdownDocument, md as md2 } from "build-md";
975
+ import {
976
+ MarkdownDocument,
977
+ md as md2
978
+ } from "build-md";
964
979
 
965
980
  // packages/utils/src/lib/reports/generate-md-report-categoy-section.ts
966
981
  import { MarkdownDocument as MarkdownDocument2, md as md3 } from "build-md";
967
982
 
968
983
  // packages/utils/src/lib/reports/generate-md-reports-diff.ts
969
984
  import {
970
- MarkdownDocument as MarkdownDocument4,
971
- md as md5
985
+ MarkdownDocument as MarkdownDocument5,
986
+ md as md6
972
987
  } from "build-md";
973
988
 
989
+ // packages/utils/src/lib/reports/generate-md-reports-diff-utils.ts
990
+ import { MarkdownDocument as MarkdownDocument4, md as md5 } from "build-md";
991
+
974
992
  // packages/utils/src/lib/reports/log-stdout-summary.ts
975
993
  import { bold as bold4, cyan, cyanBright, green as green2, red } from "ansis";
976
994
 
@@ -1188,7 +1206,6 @@ function parseTableToAuditDetailsTable(details2) {
1188
1206
  }
1189
1207
  try {
1190
1208
  return tableSchema().parse({
1191
- title: "Table",
1192
1209
  columns: parseTableColumns(rawHeadings),
1193
1210
  rows: items.map((row) => parseTableRow(row, rawHeadings))
1194
1211
  });
@@ -1322,19 +1339,7 @@ function logUnsupportedDetails(lhrAudits, { displayCount = 3 } = {}) {
1322
1339
  // packages/plugin-lighthouse/src/lib/runner/utils.ts
1323
1340
  function normalizeAuditOutputs(auditOutputs, flags = { skipAudits: [] }) {
1324
1341
  const toSkip = new Set(flags.skipAudits ?? []);
1325
- return auditOutputs.filter(({ slug }) => {
1326
- const doSkip = toSkip.has(slug);
1327
- if (doSkip) {
1328
- ui().logger.info(
1329
- `Audit ${bold8(
1330
- slug
1331
- )} was included in audit outputs of lighthouse but listed under ${bold8(
1332
- "skipAudits"
1333
- )}.`
1334
- );
1335
- }
1336
- return !doSkip;
1337
- });
1342
+ return auditOutputs.filter(({ slug }) => !toSkip.has(slug));
1338
1343
  }
1339
1344
  var LighthouseAuditParsingError = class extends Error {
1340
1345
  constructor(slug, error) {
@@ -1343,37 +1348,37 @@ Audit ${bold8(slug)} failed parsing details:
1343
1348
  ${error.message}`);
1344
1349
  }
1345
1350
  };
1351
+ function formatBaseAuditOutput(lhrAudit) {
1352
+ const {
1353
+ id: slug,
1354
+ score,
1355
+ numericValue,
1356
+ displayValue,
1357
+ scoreDisplayMode
1358
+ } = lhrAudit;
1359
+ return {
1360
+ slug,
1361
+ score: score ?? 1,
1362
+ value: numericValue ?? score ?? 0,
1363
+ displayValue: displayValue ?? (scoreDisplayMode === "binary" ? score === 1 ? "passed" : "failed" : score ? `${formatReportScore(score)}%` : void 0)
1364
+ };
1365
+ }
1366
+ function processAuditDetails(auditOutput, details2) {
1367
+ try {
1368
+ const parsedDetails = toAuditDetails(details2);
1369
+ return Object.keys(parsedDetails).length > 0 ? { ...auditOutput, details: parsedDetails } : auditOutput;
1370
+ } catch (error) {
1371
+ throw new LighthouseAuditParsingError(auditOutput.slug, error);
1372
+ }
1373
+ }
1346
1374
  function toAuditOutputs(lhrAudits, { verbose = false } = {}) {
1347
1375
  if (verbose) {
1348
1376
  logUnsupportedDetails(lhrAudits);
1349
1377
  }
1350
- return lhrAudits.map(
1351
- ({
1352
- id: slug,
1353
- score,
1354
- numericValue: value = 0,
1355
- // not every audit has a numericValue
1356
- details: details2,
1357
- displayValue
1358
- }) => {
1359
- const auditOutput = {
1360
- slug,
1361
- score: score ?? 1,
1362
- // score can be null
1363
- value,
1364
- displayValue
1365
- };
1366
- if (details2 != null) {
1367
- try {
1368
- const parsedDetails = toAuditDetails(details2);
1369
- return Object.keys(parsedDetails).length > 0 ? { ...auditOutput, details: parsedDetails } : auditOutput;
1370
- } catch (error) {
1371
- throw new LighthouseAuditParsingError(slug, error);
1372
- }
1373
- }
1374
- return auditOutput;
1375
- }
1376
- );
1378
+ return lhrAudits.map((audit) => {
1379
+ const auditOutput = formatBaseAuditOutput(audit);
1380
+ return audit.details == null ? auditOutput : processAuditDetails(auditOutput, audit.details);
1381
+ });
1377
1382
  }
1378
1383
  function determineAndSetLogLevel({
1379
1384
  verbose,
@@ -1485,7 +1490,7 @@ function normalizeFlags(flags) {
1485
1490
  ([flagName]) => !LIGHTHOUSE_UNSUPPORTED_CLI_FLAGS.has(
1486
1491
  flagName
1487
1492
  )
1488
- ).map(([key, v]) => [key === "onlyGroups" ? "onlyCategories" : key, v]).map(([key, v]) => {
1493
+ ).map(([key, v]) => [key === "onlyGroups" ? "onlyCategories" : key, v]).filter(([_, v]) => !(Array.isArray(v) && v.length === 0)).map(([key, v]) => {
1489
1494
  if (!REFINED_STRING_OR_STRING_ARRAY.has(key)) {
1490
1495
  return [key, v];
1491
1496
  }
@@ -1596,12 +1601,7 @@ function filterAuditsAndGroupsByOnlyOptions(audits2, groups, options) {
1596
1601
 
1597
1602
  // packages/plugin-lighthouse/src/lib/lighthouse-plugin.ts
1598
1603
  function lighthousePlugin(url, flags) {
1599
- const {
1600
- skipAudits = [],
1601
- onlyAudits = [],
1602
- onlyCategories: onlyCategories2 = [],
1603
- ...unparsedFlags
1604
- } = normalizeFlags(flags ?? {});
1604
+ const { skipAudits, onlyAudits, onlyCategories: onlyCategories2, ...unparsedFlags } = normalizeFlags(flags ?? {});
1605
1605
  const { audits: audits2, groups } = filterAuditsAndGroupsByOnlyOptions(
1606
1606
  LIGHTHOUSE_NAVIGATION_AUDITS,
1607
1607
  LIGHTHOUSE_GROUPS,
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@code-pushup/lighthouse-plugin",
3
- "version": "0.49.0",
3
+ "version": "0.51.0",
4
4
  "license": "MIT",
5
+ "description": "Code PushUp plugin for measuring web performance and quality with Lighthouse 🔥",
5
6
  "dependencies": {
6
- "@code-pushup/models": "0.49.0",
7
- "@code-pushup/utils": "0.49.0",
7
+ "@code-pushup/models": "0.51.0",
8
+ "@code-pushup/utils": "0.51.0",
8
9
  "ansis": "^3.3.0",
9
10
  "lighthouse": "^12.0.0",
10
11
  "lighthouse-logger": "2.0.1"
11
12
  },
12
- "homepage": "https://github.com/code-pushup/cli#readme",
13
+ "homepage": "https://github.com/code-pushup/cli/tree/main/packages/plugin-lighthouse#readme",
13
14
  "bugs": {
14
15
  "url": "https://github.com/code-pushup/cli/issues"
15
16
  },
@@ -18,33 +19,6 @@
18
19
  "url": "git+https://github.com/code-pushup/cli.git",
19
20
  "directory": "packages/plugin-lighthouse"
20
21
  },
21
- "contributors": [
22
- {
23
- "name": "Igor Katsuba",
24
- "email": "igor@katsuba.dev",
25
- "url": "https://katsuba.dev"
26
- },
27
- {
28
- "name": "Kateřina Pilátová",
29
- "email": "katerina.pilatova@flowup.cz",
30
- "url": "https://github.com/Tlacenka"
31
- },
32
- {
33
- "name": "Matěj Chalk",
34
- "email": "matej.chalk@flowup.cz",
35
- "url": "https://github.com/matejchalk"
36
- },
37
- {
38
- "name": "Michael Hladky",
39
- "email": "michael.hladky@push-based.io",
40
- "url": "https://push-based.io"
41
- },
42
- {
43
- "name": "Michael Seredenko",
44
- "email": "misha.seredenko@push-based.io",
45
- "url": "https://github.com/MishaSeredenkoPushBased"
46
- }
47
- ],
48
22
  "type": "module",
49
23
  "main": "./index.js",
50
24
  "types": "./src/index.d.ts"
package/src/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { lighthousePlugin } from './lib/lighthouse-plugin';
2
2
  export { LIGHTHOUSE_REPORT_NAME } from './lib/runner';
3
3
  export { LIGHTHOUSE_PLUGIN_SLUG, LIGHTHOUSE_OUTPUT_PATH, } from './lib/constants';
4
- export { lighthouseAuditRef, lighthouseGroupRef, LighthouseGroupSlugs, } from './lib/utils';
5
- export { LighthouseOptions } from './lib/types';
4
+ export { lighthouseAuditRef, lighthouseGroupRef, type LighthouseGroupSlugs, } from './lib/utils';
5
+ export type { LighthouseOptions } from './lib/types';
6
6
  export { lighthousePlugin } from './lib/lighthouse-plugin';
7
7
  export default lighthousePlugin;
@@ -1,4 +1,4 @@
1
- import { LighthouseCliFlags } from './runner';
1
+ import { type LighthouseCliFlags } from './runner';
2
2
  import type { LighthouseOptions } from './types';
3
3
  export declare const DEFAULT_LIGHTHOUSE_OPTIONS: {
4
4
  onlyGroups: never[];
@@ -1,7 +1,7 @@
1
1
  import type { FormattedIcu } from 'lighthouse';
2
2
  import type Details from 'lighthouse/types/lhr/audit-details';
3
- import { Result } from 'lighthouse/types/lhr/audit-result';
4
- import { AuditDetails } from '@code-pushup/models';
3
+ import type { Result } from 'lighthouse/types/lhr/audit-result';
4
+ import type { AuditDetails } from '@code-pushup/models';
5
5
  export declare function toAuditDetails<T extends FormattedIcu<Details>>(details: T | undefined): AuditDetails;
6
6
  export declare const unsupportedDetailTypes: Set<string>;
7
7
  export declare function logUnsupportedDetails(lhrAudits: Result[], { displayCount }?: {
@@ -1,5 +1,5 @@
1
1
  import type Details from 'lighthouse/types/lhr/audit-details';
2
- import { Table, TableRowObject } from '@code-pushup/models';
2
+ import { type Table, type TableRowObject } from '@code-pushup/models';
3
3
  export declare function parseOpportunityToAuditDetailsTable(details: Details.Opportunity): Table | undefined;
4
4
  export declare function parseOpportunityItemToTableRow(opportunityItem: Details.OpportunityItem, headings: Details.TableColumnHeading[]): TableRowObject;
5
5
  export declare function parseOpportunityEntry([key, value]: [
@@ -1,5 +1,5 @@
1
1
  import type Details from 'lighthouse/types/lhr/audit-details';
2
- import { Table, TableColumnObject, TableRowObject } from '@code-pushup/models';
2
+ import { type Table, type TableColumnObject, type TableRowObject } from '@code-pushup/models';
3
3
  export declare function parseTableToAuditDetailsTable(details: Details.Table): Table | undefined;
4
4
  export declare function parseTableColumns(rawHeadings: Details.TableColumnHeading[]): TableColumnObject[];
5
5
  export declare function parseTableRow(tableItem: Details.TableItem, headings: Details.TableColumnHeading[]): TableRowObject;
@@ -1,4 +1,4 @@
1
- import Details from 'lighthouse/types/lhr/audit-details';
1
+ import type Details from 'lighthouse/types/lhr/audit-details';
2
2
  export declare class LighthouseAuditDetailsParsingError extends Error {
3
3
  constructor(type: Details['type'], rawTable: Record<string, unknown>, error: string);
4
4
  }
@@ -1,3 +1,3 @@
1
1
  export { createRunnerFunction } from './runner';
2
2
  export { LIGHTHOUSE_REPORT_NAME, LIGHTHOUSE_NAVIGATION_AUDITS, LIGHTHOUSE_GROUPS, DEFAULT_CLI_FLAGS, } from './constants';
3
- export { LighthouseCliFlags } from './types';
3
+ export type { LighthouseCliFlags } from './types';
@@ -1,3 +1,3 @@
1
- import { RunnerFunction } from '@code-pushup/models';
2
- import { LighthouseCliFlags } from './types';
1
+ import type { RunnerFunction } from '@code-pushup/models';
2
+ import type { LighthouseCliFlags } from './types';
3
3
  export declare function createRunnerFunction(urlUnderTest: string, flags?: LighthouseCliFlags): RunnerFunction;
@@ -1,8 +1,8 @@
1
1
  import type { Config } from 'lighthouse';
2
- import { Result } from 'lighthouse/types/lhr/audit-result';
3
- import { AuditOutputs } from '@code-pushup/models';
2
+ import type { Result } from 'lighthouse/types/lhr/audit-result';
3
+ import type { AuditOutputs } from '@code-pushup/models';
4
4
  import type { LighthouseOptions } from '../types';
5
- import { LighthouseCliFlags } from './types';
5
+ import type { LighthouseCliFlags } from './types';
6
6
  export declare function normalizeAuditOutputs(auditOutputs: AuditOutputs, flags?: LighthouseOptions): AuditOutputs;
7
7
  export declare class LighthouseAuditParsingError extends Error {
8
8
  constructor(slug: string, error: Error);
@@ -1,5 +1,5 @@
1
1
  import type { CliFlags } from 'lighthouse';
2
- import { ExcludeNullFromPropertyTypes } from '@code-pushup/utils';
2
+ import type { ExcludeNullFromPropertyTypes } from '@code-pushup/utils';
3
3
  export type LighthouseOptions = ExcludeNullFromPropertyTypes<Partial<Omit<CliFlags, '_' | 'precomputedLanternDataPath' | 'enableErrorReporting' | 'list-all-audits' | 'list-locales' | 'list-trace-categories' | 'chromeIgnoreDefaultFlags' | 'onlyCategories' | 'onlyAudits' | 'skipAudits'>>> & {
4
4
  onlyGroups?: string | string[];
5
5
  onlyAudits?: string | string[];
@@ -1,5 +1,5 @@
1
- import { Audit, CategoryRef, Group } from '@code-pushup/models';
2
- import { LighthouseCliFlags } from './runner';
1
+ import type { Audit, CategoryRef, Group } from '@code-pushup/models';
2
+ import type { LighthouseCliFlags } from './runner';
3
3
  export type LighthouseGroupSlugs = 'performance' | 'accessibility' | 'best-practices' | 'seo' | 'pwa';
4
4
  export declare function lighthouseGroupRef(groupSlug: LighthouseGroupSlugs, weight?: number): CategoryRef;
5
5
  export declare function lighthouseAuditRef(auditSlug: string, weight?: number): CategoryRef;