(flags?: LighthouseOptions)
| 36 | ]); |
| 37 | |
| 38 | export function normalizeFlags(flags?: LighthouseOptions): LighthouseCliFlags { |
| 39 | const prefilledFlags = { ...DEFAULT_LIGHTHOUSE_OPTIONS, ...flags }; |
| 40 | |
| 41 | logUnsupportedFlagsInUse(prefilledFlags); |
| 42 | |
| 43 | return Object.fromEntries( |
| 44 | Object.entries(prefilledFlags) |
| 45 | .filter( |
| 46 | ([flagName]) => |
| 47 | !LIGHTHOUSE_UNSUPPORTED_CLI_FLAGS.has( |
| 48 | flagName as UnsupportedCliFlags, |
| 49 | ), |
| 50 | ) |
| 51 | // in code-pushup lighthouse categories are mapped as groups, therefor we had to rename "onlyCategories" to "onlyGroups" for the user of the plugin as it was confusing |
| 52 | .map(([key, v]) => [key === 'onlyGroups' ? 'onlyCategories' : key, v]) |
| 53 | // onlyAudits and onlyCategories cannot be empty arrays, otherwise skipAudits is ignored by lighthouse |
| 54 | .filter(([_, v]) => !(Array.isArray(v) && v.length === 0)) |
| 55 | // undefined | string | string[] => string[] (empty for undefined) |
| 56 | .map(([key, v]) => { |
| 57 | if (!REFINED_STRING_OR_STRING_ARRAY.has(key as never)) { |
| 58 | return [key, v]; |
| 59 | } |
| 60 | return [key, Array.isArray(v) ? v : v == null ? [] : [v]]; |
| 61 | }), |
| 62 | ) as LighthouseCliFlags; |
| 63 | } |
| 64 | |
| 65 | export function logUnsupportedFlagsInUse( |
| 66 | flags: LighthouseOptions, |
no test coverage detected