(options: PluginOptions)
| 48 | * |
| 49 | */ |
| 50 | export 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 | |
| 86 | export function runnerConfig(options: LighthouseCliOptions): RunnerConfig { |
| 87 | const { |
nothing calls this directly
no test coverage detected