lighthouse 9.5.0-dev.20230103 → 9.5.0-dev.20230104
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/core/config/config.js +4 -4
- package/core/config/filters.js +23 -23
- package/core/config/validation.js +5 -5
- package/core/gather/base-artifacts.js +1 -1
- package/core/gather/navigation-runner.js +4 -4
- package/core/index.js +2 -2
- package/core/legacy/config/config.js +29 -27
- package/core/runner.js +3 -3
- package/package.json +1 -1
- package/types/config.d.ts +4 -4
- package/types/gatherer.d.ts +1 -1
package/core/config/config.js
CHANGED
|
@@ -238,7 +238,7 @@ function resolveFakeNavigations(artifactDefns, settings) {
|
|
|
238
238
|
* @param {LH.Gatherer.GatherMode} gatherMode
|
|
239
239
|
* @param {LH.Config.Json=} configJSON
|
|
240
240
|
* @param {LH.Flags=} flags
|
|
241
|
-
* @return {Promise<{resolvedConfig: LH.Config.
|
|
241
|
+
* @return {Promise<{resolvedConfig: LH.Config.ResolvedConfig, warnings: string[]}>}
|
|
242
242
|
*/
|
|
243
243
|
async function initializeConfig(gatherMode, configJSON, flags = {}) {
|
|
244
244
|
const status = {msg: 'Initialize config', id: 'lh:config'};
|
|
@@ -256,7 +256,7 @@ async function initializeConfig(gatherMode, configJSON, flags = {}) {
|
|
|
256
256
|
|
|
257
257
|
const navigations = resolveFakeNavigations(artifacts, settings);
|
|
258
258
|
|
|
259
|
-
/** @type {LH.Config.
|
|
259
|
+
/** @type {LH.Config.ResolvedConfig} */
|
|
260
260
|
let resolvedConfig = {
|
|
261
261
|
artifacts,
|
|
262
262
|
navigations,
|
|
@@ -276,11 +276,11 @@ async function initializeConfig(gatherMode, configJSON, flags = {}) {
|
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
/**
|
|
279
|
-
* @param {LH.Config.
|
|
279
|
+
* @param {LH.Config.ResolvedConfig} resolvedConfig
|
|
280
280
|
* @return {string}
|
|
281
281
|
*/
|
|
282
282
|
function getConfigDisplayString(resolvedConfig) {
|
|
283
|
-
/** @type {LH.Config.
|
|
283
|
+
/** @type {LH.Config.ResolvedConfig} */
|
|
284
284
|
const resolvedConfigCopy = JSON.parse(JSON.stringify(resolvedConfig));
|
|
285
285
|
|
|
286
286
|
if (resolvedConfigCopy.navigations) {
|
package/core/config/filters.js
CHANGED
|
@@ -39,7 +39,7 @@ const filterResistantArtifactIds = ['Stacks', 'NetworkUserAgent'];
|
|
|
39
39
|
* If `onlyCategories` is not set, this function returns the list of all audit IDs across all
|
|
40
40
|
* categories.
|
|
41
41
|
*
|
|
42
|
-
* @param {LH.Config.
|
|
42
|
+
* @param {LH.Config.ResolvedConfig['categories']} allCategories
|
|
43
43
|
* @param {string[] | undefined} onlyCategories
|
|
44
44
|
* @return {Set<string>}
|
|
45
45
|
*/
|
|
@@ -55,9 +55,9 @@ function getAuditIdsInCategories(allCategories, onlyCategories) {
|
|
|
55
55
|
/**
|
|
56
56
|
* Filters an array of artifacts down to the set that's required by the specified audits.
|
|
57
57
|
*
|
|
58
|
-
* @param {LH.Config.
|
|
59
|
-
* @param {LH.Config.
|
|
60
|
-
* @return {LH.Config.
|
|
58
|
+
* @param {LH.Config.ResolvedConfig['artifacts']} artifacts
|
|
59
|
+
* @param {LH.Config.ResolvedConfig['audits']} audits
|
|
60
|
+
* @return {LH.Config.ResolvedConfig['artifacts']}
|
|
61
61
|
*/
|
|
62
62
|
function filterArtifactsByAvailableAudits(artifacts, audits) {
|
|
63
63
|
if (!artifacts) return null;
|
|
@@ -95,9 +95,9 @@ function filterArtifactsByAvailableAudits(artifacts, audits) {
|
|
|
95
95
|
/**
|
|
96
96
|
* Filters an array of artifacts down to the set that supports the specified gather mode.
|
|
97
97
|
*
|
|
98
|
-
* @param {LH.Config.
|
|
98
|
+
* @param {LH.Config.ResolvedConfig['artifacts']} artifacts
|
|
99
99
|
* @param {LH.Gatherer.GatherMode} mode
|
|
100
|
-
* @return {LH.Config.
|
|
100
|
+
* @return {LH.Config.ResolvedConfig['artifacts']}
|
|
101
101
|
*/
|
|
102
102
|
function filterArtifactsByGatherMode(artifacts, mode) {
|
|
103
103
|
if (!artifacts) return null;
|
|
@@ -109,9 +109,9 @@ function filterArtifactsByGatherMode(artifacts, mode) {
|
|
|
109
109
|
/**
|
|
110
110
|
* Filters an array of navigations down to the set supported by the available artifacts.
|
|
111
111
|
*
|
|
112
|
-
* @param {LH.Config.
|
|
112
|
+
* @param {LH.Config.ResolvedConfig['navigations']} navigations
|
|
113
113
|
* @param {Array<LH.Config.AnyArtifactDefn>} availableArtifacts
|
|
114
|
-
* @return {LH.Config.
|
|
114
|
+
* @return {LH.Config.ResolvedConfig['navigations']}
|
|
115
115
|
*/
|
|
116
116
|
function filterNavigationsByAvailableArtifacts(navigations, availableArtifacts) {
|
|
117
117
|
if (!navigations) return navigations;
|
|
@@ -133,9 +133,9 @@ function filterNavigationsByAvailableArtifacts(navigations, availableArtifacts)
|
|
|
133
133
|
/**
|
|
134
134
|
* Filters an array of audits down to the set that can be computed using only the specified artifacts.
|
|
135
135
|
*
|
|
136
|
-
* @param {LH.Config.
|
|
136
|
+
* @param {LH.Config.ResolvedConfig['audits']} audits
|
|
137
137
|
* @param {Array<LH.Config.AnyArtifactDefn>} availableArtifacts
|
|
138
|
-
* @return {LH.Config.
|
|
138
|
+
* @return {LH.Config.ResolvedConfig['audits']}
|
|
139
139
|
*/
|
|
140
140
|
function filterAuditsByAvailableArtifacts(audits, availableArtifacts) {
|
|
141
141
|
if (!audits) return null;
|
|
@@ -152,9 +152,9 @@ function filterAuditsByAvailableArtifacts(audits, availableArtifacts) {
|
|
|
152
152
|
/**
|
|
153
153
|
* Optional `supportedModes` property can explicitly exclude an audit even if all required artifacts are available.
|
|
154
154
|
*
|
|
155
|
-
* @param {LH.Config.
|
|
155
|
+
* @param {LH.Config.ResolvedConfig['audits']} audits
|
|
156
156
|
* @param {LH.Gatherer.GatherMode} mode
|
|
157
|
-
* @return {LH.Config.
|
|
157
|
+
* @return {LH.Config.ResolvedConfig['audits']}
|
|
158
158
|
*/
|
|
159
159
|
function filterAuditsByGatherMode(audits, mode) {
|
|
160
160
|
if (!audits) return null;
|
|
@@ -168,9 +168,9 @@ function filterAuditsByGatherMode(audits, mode) {
|
|
|
168
168
|
/**
|
|
169
169
|
* Optional `supportedModes` property can explicitly exclude a category even if some audits are available.
|
|
170
170
|
*
|
|
171
|
-
* @param {LH.Config.
|
|
171
|
+
* @param {LH.Config.LegacyResolvedConfig['categories']} categories
|
|
172
172
|
* @param {LH.Gatherer.GatherMode} mode
|
|
173
|
-
* @return {LH.Config.
|
|
173
|
+
* @return {LH.Config.LegacyResolvedConfig['categories']}
|
|
174
174
|
*/
|
|
175
175
|
function filterCategoriesByGatherMode(categories, mode) {
|
|
176
176
|
if (!categories) return null;
|
|
@@ -185,9 +185,9 @@ function filterCategoriesByGatherMode(categories, mode) {
|
|
|
185
185
|
/**
|
|
186
186
|
* Filters a categories object and their auditRefs down to the specified category ids.
|
|
187
187
|
*
|
|
188
|
-
* @param {LH.Config.
|
|
188
|
+
* @param {LH.Config.LegacyResolvedConfig['categories']} categories
|
|
189
189
|
* @param {string[] | null | undefined} onlyCategories
|
|
190
|
-
* @return {LH.Config.
|
|
190
|
+
* @return {LH.Config.LegacyResolvedConfig['categories']}
|
|
191
191
|
*/
|
|
192
192
|
function filterCategoriesByExplicitFilters(categories, onlyCategories) {
|
|
193
193
|
if (!categories || !onlyCategories) return categories;
|
|
@@ -201,7 +201,7 @@ function filterCategoriesByExplicitFilters(categories, onlyCategories) {
|
|
|
201
201
|
* Logs a warning if any specified onlyCategory is not a known category that can
|
|
202
202
|
* be included.
|
|
203
203
|
*
|
|
204
|
-
* @param {LH.Config.
|
|
204
|
+
* @param {LH.Config.LegacyResolvedConfig['categories']} allCategories
|
|
205
205
|
* @param {string[] | null} onlyCategories
|
|
206
206
|
* @return {void}
|
|
207
207
|
*/
|
|
@@ -219,9 +219,9 @@ function warnOnUnknownOnlyCategories(allCategories, onlyCategories) {
|
|
|
219
219
|
* Filters a categories object and their auditRefs down to the set that can be computed using
|
|
220
220
|
* only the specified audits.
|
|
221
221
|
*
|
|
222
|
-
* @param {LH.Config.
|
|
222
|
+
* @param {LH.Config.LegacyResolvedConfig['categories']} categories
|
|
223
223
|
* @param {Array<LH.Config.AuditDefn>} availableAudits
|
|
224
|
-
* @return {LH.Config.
|
|
224
|
+
* @return {LH.Config.LegacyResolvedConfig['categories']}
|
|
225
225
|
*/
|
|
226
226
|
function filterCategoriesByAvailableAudits(categories, availableAudits) {
|
|
227
227
|
if (!categories) return categories;
|
|
@@ -257,9 +257,9 @@ function filterCategoriesByAvailableAudits(categories, availableAudits) {
|
|
|
257
257
|
/**
|
|
258
258
|
* Filters a config's artifacts, audits, and categories down to the set that supports the specified gather mode.
|
|
259
259
|
*
|
|
260
|
-
* @param {LH.Config.
|
|
260
|
+
* @param {LH.Config.ResolvedConfig} resolvedConfig
|
|
261
261
|
* @param {LH.Gatherer.GatherMode} mode
|
|
262
|
-
* @return {LH.Config.
|
|
262
|
+
* @return {LH.Config.ResolvedConfig}
|
|
263
263
|
*/
|
|
264
264
|
function filterConfigByGatherMode(resolvedConfig, mode) {
|
|
265
265
|
const artifacts = filterArtifactsByGatherMode(resolvedConfig.artifacts, mode);
|
|
@@ -280,9 +280,9 @@ function filterConfigByGatherMode(resolvedConfig, mode) {
|
|
|
280
280
|
* Filters a config's artifacts, audits, and categories down to the requested set.
|
|
281
281
|
* Skip audits overrides inclusion via `onlyAudits`/`onlyCategories`.
|
|
282
282
|
*
|
|
283
|
-
* @param {LH.Config.
|
|
283
|
+
* @param {LH.Config.ResolvedConfig} resolvedConfig
|
|
284
284
|
* @param {Pick<LH.Config.Settings, 'onlyAudits'|'onlyCategories'|'skipAudits'>} filters
|
|
285
|
-
* @return {LH.Config.
|
|
285
|
+
* @return {LH.Config.ResolvedConfig}
|
|
286
286
|
*/
|
|
287
287
|
function filterConfigByExplicitFilters(resolvedConfig, filters) {
|
|
288
288
|
const {onlyAudits, onlyCategories, skipAudits} = filters;
|
|
@@ -79,7 +79,7 @@ function assertValidFRGatherer(gathererDefn) {
|
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* Throws an error if the provided object does not implement the required navigations interface.
|
|
82
|
-
* @param {LH.Config.
|
|
82
|
+
* @param {LH.Config.ResolvedConfig['navigations']} navigationsDefn
|
|
83
83
|
* @return {{warnings: string[]}}
|
|
84
84
|
*/
|
|
85
85
|
function assertValidFRNavigations(navigationsDefn) {
|
|
@@ -164,9 +164,9 @@ function assertValidAudit(auditDefinition) {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
/**
|
|
167
|
-
* @param {LH.Config.
|
|
168
|
-
* @param {LH.Config.
|
|
169
|
-
* @param {LH.Config.
|
|
167
|
+
* @param {LH.Config.ResolvedConfig['categories']} categories
|
|
168
|
+
* @param {LH.Config.ResolvedConfig['audits']} audits
|
|
169
|
+
* @param {LH.Config.ResolvedConfig['groups']} groups
|
|
170
170
|
*/
|
|
171
171
|
function assertValidCategories(categories, audits, groups) {
|
|
172
172
|
if (!categories) {
|
|
@@ -247,7 +247,7 @@ function assertArtifactTopologicalOrder(navigations) {
|
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
/**
|
|
250
|
-
* @param {LH.Config.
|
|
250
|
+
* @param {LH.Config.ResolvedConfig} resolvedConfig
|
|
251
251
|
* @return {{warnings: string[]}}
|
|
252
252
|
*/
|
|
253
253
|
function assertValidConfig(resolvedConfig) {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from './driver/environment.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @param {LH.Config.
|
|
15
|
+
* @param {LH.Config.ResolvedConfig} resolvedConfig
|
|
16
16
|
* @param {LH.Gatherer.FRTransitionalDriver} driver
|
|
17
17
|
* @param {{gatherMode: LH.Gatherer.GatherMode}} context
|
|
18
18
|
* @return {Promise<LH.BaseArtifacts>}
|
|
@@ -29,7 +29,7 @@ import {NetworkRecords} from '../computed/network-records.js';
|
|
|
29
29
|
* @typedef NavigationContext
|
|
30
30
|
* @property {Driver} driver
|
|
31
31
|
* @property {LH.Puppeteer.Page} page
|
|
32
|
-
* @property {LH.Config.
|
|
32
|
+
* @property {LH.Config.ResolvedConfig} resolvedConfig
|
|
33
33
|
* @property {LH.Config.NavigationDefn} navigation
|
|
34
34
|
* @property {LH.NavigationRequestor} requestor
|
|
35
35
|
* @property {LH.FRBaseArtifacts} baseArtifacts
|
|
@@ -42,7 +42,7 @@ const DEFAULT_HOSTNAME = '127.0.0.1';
|
|
|
42
42
|
const DEFAULT_PORT = 9222;
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* @param {{driver: Driver, resolvedConfig: LH.Config.
|
|
45
|
+
* @param {{driver: Driver, resolvedConfig: LH.Config.ResolvedConfig, requestor: LH.NavigationRequestor}} args
|
|
46
46
|
* @return {Promise<{baseArtifacts: LH.FRBaseArtifacts}>}
|
|
47
47
|
*/
|
|
48
48
|
async function _setup({driver, resolvedConfig, requestor}) {
|
|
@@ -250,7 +250,7 @@ async function _navigation(navigationContext) {
|
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
/**
|
|
253
|
-
* @param {{driver: Driver, page: LH.Puppeteer.Page, resolvedConfig: LH.Config.
|
|
253
|
+
* @param {{driver: Driver, page: LH.Puppeteer.Page, resolvedConfig: LH.Config.ResolvedConfig, requestor: LH.NavigationRequestor; baseArtifacts: LH.FRBaseArtifacts, computedCache: NavigationContext['computedCache']}} args
|
|
254
254
|
* @return {Promise<{artifacts: Partial<LH.FRArtifacts & LH.FRBaseArtifacts>}>}
|
|
255
255
|
*/
|
|
256
256
|
async function _navigations(args) {
|
|
@@ -299,7 +299,7 @@ async function _navigations(args) {
|
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
/**
|
|
302
|
-
* @param {{requestedUrl?: string, driver: Driver, resolvedConfig: LH.Config.
|
|
302
|
+
* @param {{requestedUrl?: string, driver: Driver, resolvedConfig: LH.Config.ResolvedConfig}} args
|
|
303
303
|
*/
|
|
304
304
|
async function _cleanup({requestedUrl, driver, resolvedConfig}) {
|
|
305
305
|
const didResetStorage = !resolvedConfig.settings.disableStorageReset && requestedUrl;
|
package/core/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import log from 'lighthouse-logger';
|
|
|
8
8
|
|
|
9
9
|
import {Runner} from './runner.js';
|
|
10
10
|
import {CriConnection} from './legacy/gather/connections/cri.js';
|
|
11
|
-
import {
|
|
11
|
+
import {LegacyResolvedConfig} from './legacy/config/config.js';
|
|
12
12
|
import UrlUtils from './lib/url-utils.js';
|
|
13
13
|
import {Driver} from './legacy/gather/driver.js';
|
|
14
14
|
import {UserFlow, auditGatherSteps} from './user-flow.js';
|
|
@@ -63,7 +63,7 @@ async function legacyNavigation(url, flags = {}, configJSON, userConnection) {
|
|
|
63
63
|
flags.logLevel = flags.logLevel || 'error';
|
|
64
64
|
log.setLevel(flags.logLevel);
|
|
65
65
|
|
|
66
|
-
const resolvedConfig = await
|
|
66
|
+
const resolvedConfig = await LegacyResolvedConfig.fromJson(configJSON, flags);
|
|
67
67
|
const computedCache = new Map();
|
|
68
68
|
const options = {resolvedConfig, computedCache};
|
|
69
69
|
const connection = userConnection || new CriConnection(flags.port, flags.hostname);
|
|
@@ -55,15 +55,15 @@ const BASE_ARTIFACT_BLANKS = {
|
|
|
55
55
|
const BASE_ARTIFACT_NAMES = Object.keys(BASE_ARTIFACT_BLANKS);
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* @param {
|
|
59
|
-
* @param {
|
|
58
|
+
* @param {LegacyResolvedConfig['passes']} passes
|
|
59
|
+
* @param {LegacyResolvedConfig['audits']} audits
|
|
60
60
|
*/
|
|
61
61
|
function assertValidPasses(passes, audits) {
|
|
62
62
|
if (!Array.isArray(passes)) {
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
const requestedGatherers =
|
|
66
|
+
const requestedGatherers = LegacyResolvedConfig.getGatherersRequestedByAudits(audits);
|
|
67
67
|
// Base artifacts are provided by GatherRunner, so start foundGatherers with them.
|
|
68
68
|
const foundGatherers = new Set(BASE_ARTIFACT_NAMES);
|
|
69
69
|
|
|
@@ -129,15 +129,15 @@ function assertValidGatherer(gathererInstance, gathererName) {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
|
-
* @implements {LH.Config.
|
|
132
|
+
* @implements {LH.Config.LegacyResolvedConfig}
|
|
133
133
|
*/
|
|
134
|
-
class
|
|
134
|
+
class LegacyResolvedConfig {
|
|
135
135
|
/**
|
|
136
136
|
* Resolves the provided config (inherits from extended config, if set), resolves
|
|
137
137
|
* all referenced modules, and validates.
|
|
138
138
|
* @param {LH.Config.Json=} configJSON If not provided, uses the default config.
|
|
139
139
|
* @param {LH.Flags=} flags
|
|
140
|
-
* @return {Promise<
|
|
140
|
+
* @return {Promise<LegacyResolvedConfig>}
|
|
141
141
|
*/
|
|
142
142
|
static async fromJson(configJSON, flags) {
|
|
143
143
|
const status = {msg: 'Create config', id: 'lh:init:config'};
|
|
@@ -161,7 +161,8 @@ class Config {
|
|
|
161
161
|
if (configJSON.extends !== 'lighthouse:default') {
|
|
162
162
|
throw new Error('`lighthouse:default` is the only valid extension method.');
|
|
163
163
|
}
|
|
164
|
-
configJSON =
|
|
164
|
+
configJSON = LegacyResolvedConfig.extendConfigJSON(
|
|
165
|
+
deepCloneConfigJson(legacyDefaultConfig), configJSON);
|
|
165
166
|
}
|
|
166
167
|
|
|
167
168
|
// The directory of the config path, if one was provided.
|
|
@@ -173,13 +174,13 @@ class Config {
|
|
|
173
174
|
const settings = resolveSettings(configJSON.settings || {}, flags);
|
|
174
175
|
|
|
175
176
|
// Augment passes with necessary defaults and require gatherers.
|
|
176
|
-
const passesWithDefaults =
|
|
177
|
-
|
|
178
|
-
const passes = await
|
|
177
|
+
const passesWithDefaults = LegacyResolvedConfig.augmentPassesWithDefaults(configJSON.passes);
|
|
178
|
+
LegacyResolvedConfig.adjustDefaultPassForThrottling(settings, passesWithDefaults);
|
|
179
|
+
const passes = await LegacyResolvedConfig.requireGatherers(passesWithDefaults, configDir);
|
|
179
180
|
|
|
180
|
-
const audits = await
|
|
181
|
+
const audits = await LegacyResolvedConfig.requireAudits(configJSON.audits, configDir);
|
|
181
182
|
|
|
182
|
-
const resolvedConfig = new
|
|
183
|
+
const resolvedConfig = new LegacyResolvedConfig(configJSON, {settings, passes, audits});
|
|
183
184
|
log.timeEnd(status);
|
|
184
185
|
return resolvedConfig;
|
|
185
186
|
}
|
|
@@ -202,7 +203,7 @@ class Config {
|
|
|
202
203
|
/** @type {?Record<string, LH.Config.Group>} */
|
|
203
204
|
this.groups = configJSON.groups || null;
|
|
204
205
|
|
|
205
|
-
|
|
206
|
+
LegacyResolvedConfig.filterConfigIfNeeded(this);
|
|
206
207
|
|
|
207
208
|
assertValidPasses(this.passes, this.audits);
|
|
208
209
|
validation.assertValidCategories(this.categories, this.audits, this.groups);
|
|
@@ -308,7 +309,7 @@ class Config {
|
|
|
308
309
|
|
|
309
310
|
/**
|
|
310
311
|
* Filter out any unrequested items from the config, based on requested categories or audits.
|
|
311
|
-
* @param {
|
|
312
|
+
* @param {LegacyResolvedConfig} config
|
|
312
313
|
*/
|
|
313
314
|
static filterConfigIfNeeded(config) {
|
|
314
315
|
const settings = config.settings;
|
|
@@ -317,18 +318,19 @@ class Config {
|
|
|
317
318
|
}
|
|
318
319
|
|
|
319
320
|
// 1. Filter to just the chosen categories/audits
|
|
320
|
-
const {categories, requestedAuditNames} =
|
|
321
|
-
settings);
|
|
321
|
+
const {categories, requestedAuditNames} =
|
|
322
|
+
LegacyResolvedConfig.filterCategoriesAndAudits(config.categories, settings);
|
|
322
323
|
|
|
323
324
|
// 2. Resolve which audits will need to run
|
|
324
325
|
const audits = config.audits && config.audits.filter(auditDefn =>
|
|
325
326
|
requestedAuditNames.has(auditDefn.implementation.meta.id));
|
|
326
327
|
|
|
327
328
|
// 3. Resolve which gatherers will need to run
|
|
328
|
-
const requestedGathererIds =
|
|
329
|
+
const requestedGathererIds = LegacyResolvedConfig.getGatherersRequestedByAudits(audits);
|
|
329
330
|
|
|
330
331
|
// 4. Filter to only the neccessary passes
|
|
331
|
-
const passes =
|
|
332
|
+
const passes =
|
|
333
|
+
LegacyResolvedConfig.generatePassesNeededByGatherers(config.passes, requestedGathererIds);
|
|
332
334
|
|
|
333
335
|
config.categories = categories;
|
|
334
336
|
config.audits = audits;
|
|
@@ -337,9 +339,9 @@ class Config {
|
|
|
337
339
|
|
|
338
340
|
/**
|
|
339
341
|
* Filter out any unrequested categories or audits from the categories object.
|
|
340
|
-
* @param {
|
|
342
|
+
* @param {LegacyResolvedConfig['categories']} oldCategories
|
|
341
343
|
* @param {LH.Config.Settings} settings
|
|
342
|
-
* @return {{categories:
|
|
344
|
+
* @return {{categories: LegacyResolvedConfig['categories'], requestedAuditNames: Set<string>}}
|
|
343
345
|
*/
|
|
344
346
|
static filterCategoriesAndAudits(oldCategories, settings) {
|
|
345
347
|
if (!oldCategories) {
|
|
@@ -350,7 +352,7 @@ class Config {
|
|
|
350
352
|
throw new Error('Cannot set both skipAudits and onlyAudits');
|
|
351
353
|
}
|
|
352
354
|
|
|
353
|
-
/** @type {NonNullable<
|
|
355
|
+
/** @type {NonNullable<LegacyResolvedConfig['categories']>} */
|
|
354
356
|
const categories = {};
|
|
355
357
|
const filterByIncludedCategory = !!settings.onlyCategories;
|
|
356
358
|
const filterByIncludedAudit = !!settings.onlyAudits;
|
|
@@ -424,7 +426,7 @@ class Config {
|
|
|
424
426
|
|
|
425
427
|
/**
|
|
426
428
|
* From some requested audits, return names of all required and optional artifacts
|
|
427
|
-
* @param {
|
|
429
|
+
* @param {LegacyResolvedConfig['audits']} audits
|
|
428
430
|
* @return {Set<string>}
|
|
429
431
|
*/
|
|
430
432
|
static getGatherersRequestedByAudits(audits) {
|
|
@@ -447,9 +449,9 @@ class Config {
|
|
|
447
449
|
|
|
448
450
|
/**
|
|
449
451
|
* Filters to only requested passes and gatherers, returning a new passes array.
|
|
450
|
-
* @param {
|
|
452
|
+
* @param {LegacyResolvedConfig['passes']} passes
|
|
451
453
|
* @param {Set<string>} requestedGatherers
|
|
452
|
-
* @return {
|
|
454
|
+
* @return {LegacyResolvedConfig['passes']}
|
|
453
455
|
*/
|
|
454
456
|
static generatePassesNeededByGatherers(passes, requestedGatherers) {
|
|
455
457
|
if (!passes) {
|
|
@@ -488,7 +490,7 @@ class Config {
|
|
|
488
490
|
* leaving only an array of AuditDefns.
|
|
489
491
|
* @param {LH.Config.Json['audits']} audits
|
|
490
492
|
* @param {string=} configDir
|
|
491
|
-
* @return {Promise<
|
|
493
|
+
* @return {Promise<LegacyResolvedConfig['audits']>}
|
|
492
494
|
*/
|
|
493
495
|
static async requireAudits(audits, configDir) {
|
|
494
496
|
const status = {msg: 'Requiring audits', id: 'lh:config:requireAudits'};
|
|
@@ -504,7 +506,7 @@ class Config {
|
|
|
504
506
|
* provided) using `resolveModulePath`, returning an array of full Passes.
|
|
505
507
|
* @param {?Array<Required<LH.Config.PassJson>>} passes
|
|
506
508
|
* @param {string=} configDir
|
|
507
|
-
* @return {Promise<
|
|
509
|
+
* @return {Promise<LegacyResolvedConfig['passes']>}
|
|
508
510
|
*/
|
|
509
511
|
static async requireGatherers(passes, configDir) {
|
|
510
512
|
if (!passes) {
|
|
@@ -535,4 +537,4 @@ class Config {
|
|
|
535
537
|
}
|
|
536
538
|
}
|
|
537
539
|
|
|
538
|
-
export {
|
|
540
|
+
export {LegacyResolvedConfig};
|
package/core/runner.js
CHANGED
|
@@ -28,11 +28,11 @@ const moduleDir = getModuleDirectory(import.meta);
|
|
|
28
28
|
|
|
29
29
|
/** @typedef {import('./legacy/gather/connections/connection.js').Connection} Connection */
|
|
30
30
|
/** @typedef {import('./lib/arbitrary-equality-map.js').ArbitraryEqualityMap} ArbitraryEqualityMap */
|
|
31
|
-
/** @typedef {LH.Config.
|
|
31
|
+
/** @typedef {LH.Config.LegacyResolvedConfig} Config */
|
|
32
32
|
|
|
33
33
|
class Runner {
|
|
34
34
|
/**
|
|
35
|
-
* @template {LH.Config.
|
|
35
|
+
* @template {LH.Config.LegacyResolvedConfig | LH.Config.ResolvedConfig} TConfig
|
|
36
36
|
* @param {LH.Artifacts} artifacts
|
|
37
37
|
* @param {{resolvedConfig: TConfig, driverMock?: Driver, computedCache: Map<string, ArbitraryEqualityMap>}} options
|
|
38
38
|
* @return {Promise<LH.RunnerResult|undefined>}
|
|
@@ -142,7 +142,7 @@ class Runner {
|
|
|
142
142
|
* -G and -A will run partial lighthouse pipelines,
|
|
143
143
|
* and -GA will run everything plus save artifacts and lhr to disk.
|
|
144
144
|
*
|
|
145
|
-
* @template {LH.Config.
|
|
145
|
+
* @template {LH.Config.LegacyResolvedConfig | LH.Config.ResolvedConfig} TConfig
|
|
146
146
|
* @param {(runnerData: {resolvedConfig: TConfig, driverMock?: Driver}) => Promise<LH.Artifacts>} gatherFn
|
|
147
147
|
* @param {{resolvedConfig: TConfig, driverMock?: Driver, computedCache: Map<string, ArbitraryEqualityMap>}} options
|
|
148
148
|
* @return {Promise<LH.Artifacts>}
|
package/package.json
CHANGED
package/types/config.d.ts
CHANGED
|
@@ -34,9 +34,9 @@ declare module Config {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* The normalized and fully resolved config.
|
|
37
|
+
* The normalized and fully resolved legacy config.
|
|
38
38
|
*/
|
|
39
|
-
interface
|
|
39
|
+
interface LegacyResolvedConfig {
|
|
40
40
|
settings: Settings;
|
|
41
41
|
passes: Pass[] | null;
|
|
42
42
|
audits: AuditDefn[] | null;
|
|
@@ -45,9 +45,9 @@ declare module Config {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* The normalized and fully resolved
|
|
48
|
+
* The normalized and fully resolved config.
|
|
49
49
|
*/
|
|
50
|
-
interface
|
|
50
|
+
interface ResolvedConfig {
|
|
51
51
|
settings: Settings;
|
|
52
52
|
artifacts: AnyArtifactDefn[] | null;
|
|
53
53
|
navigations: NavigationDefn[] | null;
|
package/types/gatherer.d.ts
CHANGED