@code-pushup/lighthouse-plugin 0.49.0 → 0.50.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 +49 -52
- package/package.json +5 -31
- package/src/index.d.ts +2 -2
- package/src/lib/normalize-flags.d.ts +1 -1
- package/src/lib/runner/details/details.d.ts +2 -2
- package/src/lib/runner/details/opportunity.type.d.ts +1 -1
- package/src/lib/runner/details/table.type.d.ts +1 -1
- package/src/lib/runner/details/utils.d.ts +1 -1
- package/src/lib/runner/index.d.ts +1 -1
- package/src/lib/runner/runner.d.ts +2 -2
- package/src/lib/runner/utils.d.ts +3 -3
- package/src/lib/types.d.ts +1 -1
- package/src/lib/utils.d.ts +2 -2
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.
|
|
3
|
+
var version = "0.50.0";
|
|
4
4
|
|
|
5
5
|
// packages/plugin-lighthouse/src/lib/constants.ts
|
|
6
6
|
import { join } from "node:path";
|
|
@@ -676,6 +676,8 @@ var auditResultSchema = scorableWithPluginMetaSchema.merge(
|
|
|
676
676
|
);
|
|
677
677
|
var reportsDiffSchema = z15.object({
|
|
678
678
|
commits: makeComparisonSchema(commitSchema).nullable().describe("Commits identifying compared reports"),
|
|
679
|
+
portalUrl: urlSchema.optional().describe("Link to comparison page in Code PushUp portal"),
|
|
680
|
+
label: z15.string().optional().describe("Label (e.g. project name)"),
|
|
679
681
|
categories: makeArraysComparisonSchema(
|
|
680
682
|
categoryDiffSchema,
|
|
681
683
|
categoryResultSchema,
|
|
@@ -720,6 +722,13 @@ import { md } from "build-md";
|
|
|
720
722
|
// packages/utils/src/lib/reports/constants.ts
|
|
721
723
|
var TERMINAL_WIDTH = 80;
|
|
722
724
|
|
|
725
|
+
// packages/utils/src/lib/reports/utils.ts
|
|
726
|
+
function formatReportScore(score) {
|
|
727
|
+
const scaledScore = score * 100;
|
|
728
|
+
const roundedScore = Math.round(scaledScore);
|
|
729
|
+
return roundedScore === 100 && score !== 1 ? Math.floor(scaledScore).toString() : roundedScore.toString();
|
|
730
|
+
}
|
|
731
|
+
|
|
723
732
|
// packages/utils/src/lib/file-system.ts
|
|
724
733
|
import { bold, gray } from "ansis";
|
|
725
734
|
import { bundleRequire } from "bundle-require";
|
|
@@ -960,17 +969,23 @@ var html = {
|
|
|
960
969
|
};
|
|
961
970
|
|
|
962
971
|
// packages/utils/src/lib/reports/formatting.ts
|
|
963
|
-
import {
|
|
972
|
+
import {
|
|
973
|
+
MarkdownDocument,
|
|
974
|
+
md as md2
|
|
975
|
+
} from "build-md";
|
|
964
976
|
|
|
965
977
|
// packages/utils/src/lib/reports/generate-md-report-categoy-section.ts
|
|
966
978
|
import { MarkdownDocument as MarkdownDocument2, md as md3 } from "build-md";
|
|
967
979
|
|
|
968
980
|
// packages/utils/src/lib/reports/generate-md-reports-diff.ts
|
|
969
981
|
import {
|
|
970
|
-
MarkdownDocument as
|
|
971
|
-
md as
|
|
982
|
+
MarkdownDocument as MarkdownDocument5,
|
|
983
|
+
md as md6
|
|
972
984
|
} from "build-md";
|
|
973
985
|
|
|
986
|
+
// packages/utils/src/lib/reports/generate-md-reports-diff-utils.ts
|
|
987
|
+
import { MarkdownDocument as MarkdownDocument4, md as md5 } from "build-md";
|
|
988
|
+
|
|
974
989
|
// packages/utils/src/lib/reports/log-stdout-summary.ts
|
|
975
990
|
import { bold as bold4, cyan, cyanBright, green as green2, red } from "ansis";
|
|
976
991
|
|
|
@@ -1188,7 +1203,6 @@ function parseTableToAuditDetailsTable(details2) {
|
|
|
1188
1203
|
}
|
|
1189
1204
|
try {
|
|
1190
1205
|
return tableSchema().parse({
|
|
1191
|
-
title: "Table",
|
|
1192
1206
|
columns: parseTableColumns(rawHeadings),
|
|
1193
1207
|
rows: items.map((row) => parseTableRow(row, rawHeadings))
|
|
1194
1208
|
});
|
|
@@ -1322,19 +1336,7 @@ function logUnsupportedDetails(lhrAudits, { displayCount = 3 } = {}) {
|
|
|
1322
1336
|
// packages/plugin-lighthouse/src/lib/runner/utils.ts
|
|
1323
1337
|
function normalizeAuditOutputs(auditOutputs, flags = { skipAudits: [] }) {
|
|
1324
1338
|
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
|
-
});
|
|
1339
|
+
return auditOutputs.filter(({ slug }) => !toSkip.has(slug));
|
|
1338
1340
|
}
|
|
1339
1341
|
var LighthouseAuditParsingError = class extends Error {
|
|
1340
1342
|
constructor(slug, error) {
|
|
@@ -1343,37 +1345,37 @@ Audit ${bold8(slug)} failed parsing details:
|
|
|
1343
1345
|
${error.message}`);
|
|
1344
1346
|
}
|
|
1345
1347
|
};
|
|
1348
|
+
function formatBaseAuditOutput(lhrAudit) {
|
|
1349
|
+
const {
|
|
1350
|
+
id: slug,
|
|
1351
|
+
score,
|
|
1352
|
+
numericValue,
|
|
1353
|
+
displayValue,
|
|
1354
|
+
scoreDisplayMode
|
|
1355
|
+
} = lhrAudit;
|
|
1356
|
+
return {
|
|
1357
|
+
slug,
|
|
1358
|
+
score: score ?? 1,
|
|
1359
|
+
value: numericValue ?? score ?? 0,
|
|
1360
|
+
displayValue: displayValue ?? (scoreDisplayMode === "binary" ? score === 1 ? "passed" : "failed" : score ? `${formatReportScore(score)}%` : void 0)
|
|
1361
|
+
};
|
|
1362
|
+
}
|
|
1363
|
+
function processAuditDetails(auditOutput, details2) {
|
|
1364
|
+
try {
|
|
1365
|
+
const parsedDetails = toAuditDetails(details2);
|
|
1366
|
+
return Object.keys(parsedDetails).length > 0 ? { ...auditOutput, details: parsedDetails } : auditOutput;
|
|
1367
|
+
} catch (error) {
|
|
1368
|
+
throw new LighthouseAuditParsingError(auditOutput.slug, error);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1346
1371
|
function toAuditOutputs(lhrAudits, { verbose = false } = {}) {
|
|
1347
1372
|
if (verbose) {
|
|
1348
1373
|
logUnsupportedDetails(lhrAudits);
|
|
1349
1374
|
}
|
|
1350
|
-
return lhrAudits.map(
|
|
1351
|
-
(
|
|
1352
|
-
|
|
1353
|
-
|
|
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
|
-
);
|
|
1375
|
+
return lhrAudits.map((audit) => {
|
|
1376
|
+
const auditOutput = formatBaseAuditOutput(audit);
|
|
1377
|
+
return audit.details == null ? auditOutput : processAuditDetails(auditOutput, audit.details);
|
|
1378
|
+
});
|
|
1377
1379
|
}
|
|
1378
1380
|
function determineAndSetLogLevel({
|
|
1379
1381
|
verbose,
|
|
@@ -1485,7 +1487,7 @@ function normalizeFlags(flags) {
|
|
|
1485
1487
|
([flagName]) => !LIGHTHOUSE_UNSUPPORTED_CLI_FLAGS.has(
|
|
1486
1488
|
flagName
|
|
1487
1489
|
)
|
|
1488
|
-
).map(([key, v]) => [key === "onlyGroups" ? "onlyCategories" : key, v]).map(([key, v]) => {
|
|
1490
|
+
).map(([key, v]) => [key === "onlyGroups" ? "onlyCategories" : key, v]).filter(([_, v]) => !(Array.isArray(v) && v.length === 0)).map(([key, v]) => {
|
|
1489
1491
|
if (!REFINED_STRING_OR_STRING_ARRAY.has(key)) {
|
|
1490
1492
|
return [key, v];
|
|
1491
1493
|
}
|
|
@@ -1596,12 +1598,7 @@ function filterAuditsAndGroupsByOnlyOptions(audits2, groups, options) {
|
|
|
1596
1598
|
|
|
1597
1599
|
// packages/plugin-lighthouse/src/lib/lighthouse-plugin.ts
|
|
1598
1600
|
function lighthousePlugin(url, flags) {
|
|
1599
|
-
const {
|
|
1600
|
-
skipAudits = [],
|
|
1601
|
-
onlyAudits = [],
|
|
1602
|
-
onlyCategories: onlyCategories2 = [],
|
|
1603
|
-
...unparsedFlags
|
|
1604
|
-
} = normalizeFlags(flags ?? {});
|
|
1601
|
+
const { skipAudits, onlyAudits, onlyCategories: onlyCategories2, ...unparsedFlags } = normalizeFlags(flags ?? {});
|
|
1605
1602
|
const { audits: audits2, groups } = filterAuditsAndGroupsByOnlyOptions(
|
|
1606
1603
|
LIGHTHOUSE_NAVIGATION_AUDITS,
|
|
1607
1604
|
LIGHTHOUSE_GROUPS,
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-pushup/lighthouse-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.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.
|
|
7
|
-
"@code-pushup/utils": "0.
|
|
7
|
+
"@code-pushup/models": "0.50.0",
|
|
8
|
+
"@code-pushup/utils": "0.50.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,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);
|
package/src/lib/types.d.ts
CHANGED
|
@@ -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[];
|
package/src/lib/utils.d.ts
CHANGED
|
@@ -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;
|