Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: internalize resolved configs #14589

Merged
merged 1 commit into from Dec 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 1 addition & 32 deletions core/index.js
Expand Up @@ -11,7 +11,6 @@ import {CriConnection} from './legacy/gather/connections/cri.js';
import {Config} from './legacy/config/config.js';
import UrlUtils from './lib/url-utils.js';
import {Driver} from './legacy/gather/driver.js';
import {initializeConfig} from './config/config.js';
import {UserFlow, auditGatherSteps} from './user-flow.js';
import {ReportGenerator} from '../report/generator/report-generator.js';
import {startTimespanGather} from './gather/timespan-runner.js';
Expand Down Expand Up @@ -64,7 +63,7 @@ async function legacyNavigation(url, flags = {}, configJSON, userConnection) {
flags.logLevel = flags.logLevel || 'error';
log.setLevel(flags.logLevel);

const config = await generateLegacyConfig(configJSON, flags);
const config = await Config.fromJson(configJSON, flags);
const computedCache = new Map();
const options = {config, computedCache};
const connection = userConnection || new CriConnection(flags.port, flags.hostname);
Expand Down Expand Up @@ -146,34 +145,6 @@ async function auditFlowArtifacts(flowArtifacts, config) {
return await auditGatherSteps(gatherSteps, {name, config});
}

/**
* Generate a Lighthouse Config.
* @param {LH.Config.Json=} configJson Configuration for the Lighthouse run. If
* not present, the default config is used.
* @param {LH.Flags=} flags Optional settings for the Lighthouse run. If present,
* they will override any settings in the config.
* @param {LH.Gatherer.GatherMode=} gatherMode Gather mode used to collect artifacts. If present
* the config may override certain settings based on the mode.
* @return {Promise<LH.Config.FRConfig>}
*/
async function generateConfig(configJson, flags = {}, gatherMode = 'navigation') {
const {config} = await initializeConfig(gatherMode, configJson, flags);
return config;
}

/**
* Generate a legacy Lighthouse Config.
* @deprecated
* @param {LH.Config.Json=} configJson Configuration for the Lighthouse run. If
* not present, the default config is used.
* @param {LH.Flags=} flags Optional settings for the Lighthouse run. If present,
* they will override any settings in the config.
* @return {Promise<Config>}
*/
function generateLegacyConfig(configJson, flags) {
return Config.fromJson(configJson, flags);
}

function getAuditList() {
return Runner.getAuditList();
}
Expand All @@ -194,8 +165,6 @@ export {
snapshot,
generateReport,
auditFlowArtifacts,
generateConfig,
generateLegacyConfig,
getAuditList,
traceCategories,
};