-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathlighthouse-plugin.ts
More file actions
44 lines (39 loc) · 1.27 KB
/
lighthouse-plugin.ts
File metadata and controls
44 lines (39 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { createRequire } from 'node:module';
import type { PluginConfig } from '@code-pushup/models';
import { LIGHTHOUSE_PLUGIN_SLUG } from './constants.js';
import { normalizeFlags } from './normalize-flags.js';
import { normalizeUrlInput, processAuditsAndGroups } from './processing.js';
import { createRunnerFunction } from './runner/runner.js';
import type { LighthouseOptions, LighthouseUrls } from './types.js';
export function lighthousePlugin(
urls: LighthouseUrls,
flags?: LighthouseOptions,
): PluginConfig {
const { skipAudits, onlyAudits, onlyCategories, ...unparsedFlags } =
normalizeFlags(flags ?? {});
const { urls: normalizedUrls, context } = normalizeUrlInput(urls);
const { audits, groups } = processAuditsAndGroups(normalizedUrls, {
skipAudits,
onlyAudits,
onlyCategories,
});
const packageJson = createRequire(import.meta.url)(
'../../package.json',
) as typeof import('../../package.json');
return {
slug: LIGHTHOUSE_PLUGIN_SLUG,
packageName: packageJson.name,
version: packageJson.version,
title: 'Lighthouse',
icon: 'lighthouse',
audits,
groups,
runner: createRunnerFunction(normalizedUrls, {
skipAudits,
onlyAudits,
onlyCategories,
...unparsedFlags,
}),
context,
};
}