@code-pushup/lighthouse-plugin 0.42.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/CONTRIBUTING.md +117 -0
- package/README.md +203 -0
- package/index.js +1530 -0
- package/package.json +51 -0
- package/src/index.d.ts +7 -0
- package/src/lib/constants.d.ts +2 -0
- package/src/lib/lighthouse-plugin.d.ts +3 -0
- package/src/lib/normalize-flags.d.ts +20 -0
- package/src/lib/runner/constants.d.ts +21 -0
- package/src/lib/runner/index.d.ts +3 -0
- package/src/lib/runner/runner.d.ts +3 -0
- package/src/lib/runner/types.d.ts +10 -0
- package/src/lib/runner/utils.d.ts +20 -0
- package/src/lib/types.d.ts +7 -0
- package/src/lib/utils.d.ts +18 -0
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@code-pushup/lighthouse-plugin",
|
|
3
|
+
"version": "0.42.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@code-pushup/models": "0.42.0",
|
|
7
|
+
"lighthouse": "^11.0.0",
|
|
8
|
+
"@code-pushup/utils": "0.42.0",
|
|
9
|
+
"lighthouse-logger": "2.0.1",
|
|
10
|
+
"chalk": "^5.3.0"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/code-pushup/cli#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/code-pushup/cli/issues"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/code-pushup/cli.git",
|
|
19
|
+
"directory": "packages/plugin-lighthouse"
|
|
20
|
+
},
|
|
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
|
+
"type": "module",
|
|
49
|
+
"main": "./index.js",
|
|
50
|
+
"types": "./src/index.d.ts"
|
|
51
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { lighthousePlugin } from './lib/lighthouse-plugin';
|
|
2
|
+
export { LIGHTHOUSE_REPORT_NAME } from './lib/runner';
|
|
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';
|
|
6
|
+
export { lighthousePlugin } from './lib/lighthouse-plugin';
|
|
7
|
+
export default lighthousePlugin;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LighthouseCliFlags } from './runner';
|
|
2
|
+
import type { LighthouseOptions } from './types';
|
|
3
|
+
export declare const DEFAULT_LIGHTHOUSE_OPTIONS: {
|
|
4
|
+
onlyGroups: never[];
|
|
5
|
+
verbose: false;
|
|
6
|
+
quiet: false;
|
|
7
|
+
saveAssets: false;
|
|
8
|
+
chromeFlags: string[];
|
|
9
|
+
port: number;
|
|
10
|
+
hostname: string;
|
|
11
|
+
view: false;
|
|
12
|
+
channel: string;
|
|
13
|
+
onlyAudits: never[];
|
|
14
|
+
skipAudits: never[];
|
|
15
|
+
budgets: never[];
|
|
16
|
+
output: "json"[];
|
|
17
|
+
outputPath: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function normalizeFlags(flags?: LighthouseOptions): LighthouseCliFlags;
|
|
20
|
+
export declare function logUnsupportedFlagsInUse(flags: LighthouseOptions, displayCount?: number): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Audit, Group } from '@code-pushup/models';
|
|
2
|
+
export declare const PLUGIN_SLUG = "lighthouse";
|
|
3
|
+
export declare const LIGHTHOUSE_NAVIGATION_AUDITS: Audit[];
|
|
4
|
+
export declare const LIGHTHOUSE_GROUPS: Group[];
|
|
5
|
+
export declare const LIGHTHOUSE_REPORT_NAME = "lighthouse-report.json";
|
|
6
|
+
export declare const DEFAULT_CLI_FLAGS: {
|
|
7
|
+
verbose: false;
|
|
8
|
+
quiet: false;
|
|
9
|
+
saveAssets: false;
|
|
10
|
+
chromeFlags: string[];
|
|
11
|
+
port: number;
|
|
12
|
+
hostname: string;
|
|
13
|
+
view: false;
|
|
14
|
+
channel: string;
|
|
15
|
+
onlyAudits: never[];
|
|
16
|
+
skipAudits: never[];
|
|
17
|
+
onlyCategories: never[];
|
|
18
|
+
budgets: never[];
|
|
19
|
+
output: "json"[];
|
|
20
|
+
outputPath: string;
|
|
21
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Budget } from 'lighthouse';
|
|
2
|
+
import type { LighthouseOptions } from '../types';
|
|
3
|
+
export type NormalizedFlags = {
|
|
4
|
+
chromeFlags: string[];
|
|
5
|
+
onlyAudits: string[];
|
|
6
|
+
onlyCategories: string[];
|
|
7
|
+
skipAudits: string[];
|
|
8
|
+
budgets: Budget[];
|
|
9
|
+
};
|
|
10
|
+
export type LighthouseCliFlags = Omit<LighthouseOptions, keyof NormalizedFlags> & NormalizedFlags;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Budget, Config } from 'lighthouse';
|
|
2
|
+
import { Result } from 'lighthouse/types/lhr/audit-result';
|
|
3
|
+
import { AuditOutputs } from '@code-pushup/models';
|
|
4
|
+
import type { LighthouseOptions } from '../types';
|
|
5
|
+
import { LighthouseCliFlags } from './types';
|
|
6
|
+
export declare function normalizeAuditOutputs(auditOutputs: AuditOutputs, flags?: LighthouseOptions): AuditOutputs;
|
|
7
|
+
export declare function toAuditOutputs(lhrAudits: Result[], { verbose }?: {
|
|
8
|
+
verbose?: boolean;
|
|
9
|
+
}): AuditOutputs;
|
|
10
|
+
export declare const unsupportedDetailTypes: Set<string>;
|
|
11
|
+
export declare function logUnsupportedDetails(lhrAudits: Result[], { displayCount }?: {
|
|
12
|
+
displayCount?: number;
|
|
13
|
+
}): void;
|
|
14
|
+
export declare function setLogLevel({ verbose, quiet, }?: {
|
|
15
|
+
verbose?: boolean;
|
|
16
|
+
quiet?: boolean;
|
|
17
|
+
}): void;
|
|
18
|
+
export type ConfigOptions = Partial<Pick<LighthouseCliFlags, 'configPath' | 'preset'>>;
|
|
19
|
+
export declare function getConfig(options?: ConfigOptions): Promise<Config | undefined>;
|
|
20
|
+
export declare function getBudgets(budgetPath?: string): Promise<Budget[]>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CliFlags } from 'lighthouse';
|
|
2
|
+
import { ExcludeNullFromPropertyTypes } from '@code-pushup/utils';
|
|
3
|
+
export type LighthouseOptions = ExcludeNullFromPropertyTypes<Partial<Omit<CliFlags, '_' | 'precomputedLanternDataPath' | 'enableErrorReporting' | 'list-all-audits' | 'list-locales' | 'list-trace-categories' | 'chromeIgnoreDefaultFlags' | 'onlyCategories' | 'onlyAudits' | 'skipAudits'>>> & {
|
|
4
|
+
onlyGroups?: string | string[];
|
|
5
|
+
onlyAudits?: string | string[];
|
|
6
|
+
skipAudits?: string | string[];
|
|
7
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Audit, CategoryRef, Group } from '@code-pushup/models';
|
|
2
|
+
import { LighthouseCliFlags } from './runner';
|
|
3
|
+
export type LighthouseGroupSlugs = 'performance' | 'accessibility' | 'best-practices' | 'seo' | 'pwa';
|
|
4
|
+
export declare function lighthouseGroupRef(groupSlug: LighthouseGroupSlugs, weight?: number): CategoryRef;
|
|
5
|
+
export declare function lighthouseAuditRef(auditSlug: string, weight?: number): CategoryRef;
|
|
6
|
+
export declare class AuditsNotImplementedError extends Error {
|
|
7
|
+
constructor(auditSlugs: string[]);
|
|
8
|
+
}
|
|
9
|
+
export declare function validateAudits(audits: Audit[], onlyAudits: string[]): boolean;
|
|
10
|
+
export declare class CategoriesNotImplementedError extends Error {
|
|
11
|
+
constructor(categorySlugs: string[]);
|
|
12
|
+
}
|
|
13
|
+
export declare function validateOnlyCategories(groups: Group[], onlyCategories: string | string[]): boolean;
|
|
14
|
+
export type FilterOptions = Partial<Pick<LighthouseCliFlags, 'onlyAudits' | 'onlyCategories' | 'skipAudits'>>;
|
|
15
|
+
export declare function filterAuditsAndGroupsByOnlyOptions(audits: Audit[], groups: Group[], options?: FilterOptions): {
|
|
16
|
+
audits: Audit[];
|
|
17
|
+
groups: Group[];
|
|
18
|
+
};
|