MCPcopy Create free account
hub / github.com/code-pushup/cli / create

Function create

examples/plugins/src/lighthouse/src/lighthouse.plugin.ts:50–84  ·  view source on GitHub ↗
(options: PluginOptions)

Source from the content-addressed store, hash-verified

48 *
49 */
50export async function create(options: PluginOptions) {
51 const {
52 // @NOTICE
53 // Not all audits are implemented, so we always rely on the `onlyAudits` argument
54 onlyAudits: onlyAuditsOption = audits.map(({ slug }) => slug),
55 headless: headlessOption = true,
56 outputPath,
57 } = options;
58 const onlyAudits = toArray(onlyAuditsOption);
59 const headless = headlessOption ? ('new' as const) : false;
60
61 // ensure output dir
62 if (outputPath !== undefined) {
63 await ensureDirectoryExists(path.dirname(outputPath));
64 }
65
66 return {
67 slug: PLUGIN_SLUG,
68 title: 'Lighthouse',
69 icon: 'lighthouse',
70 description: 'Chrome lighthouse CLI as code-pushup plugin',
71 runner: runnerConfig({
72 ...options,
73 onlyAudits,
74 // @NOTICE
75 // Examples have a reduced scope, so we only execute the performance category here
76 onlyCategories: ['performance'],
77 headless,
78 }),
79 audits: audits.filter(({ slug }) => onlyAudits.includes(slug)),
80 groups: filterItemRefsBy([categoryCorePerfGroup], ({ slug }) =>
81 onlyAudits.includes(slug),
82 ),
83 } satisfies PluginConfig;
84}
85
86export function runnerConfig(options: LighthouseCliOptions): RunnerConfig {
87 const {

Callers

nothing calls this directly

Calls 4

toArrayFunction · 0.90
ensureDirectoryExistsFunction · 0.90
filterItemRefsByFunction · 0.90
runnerConfigFunction · 0.85

Tested by

no test coverage detected