build(aio): upgrade lighthouse to v2.5.0

This commit is contained in:
George Kalpakas 2017-10-10 12:22:06 +03:00 committed by Victor Berchet
parent 9975486954
commit 22946cfd40
3 changed files with 12 additions and 15 deletions

View File

@ -121,7 +121,7 @@
"karma-coverage-istanbul-reporter": "^1.3.0", "karma-coverage-istanbul-reporter": "^1.3.0",
"karma-jasmine": "^1.1.0", "karma-jasmine": "^1.1.0",
"karma-jasmine-html-reporter": "^0.2.2", "karma-jasmine-html-reporter": "^0.2.2",
"lighthouse": "^2.1.0", "lighthouse": "^2.5.0",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"lunr": "^2.1.0", "lunr": "^2.1.0",
"protractor": "~5.1.0", "protractor": "~5.1.0",

View File

@ -7,12 +7,12 @@
* Fails if the score is below `<min-score>`. * Fails if the score is below `<min-score>`.
* If `<log-file>` is defined, the full results will be logged there. * If `<log-file>` is defined, the full results will be logged there.
* *
* (Ignores HTTPS-related audits, when run for HTTP URL.) * (Skips HTTPS-related audits, when run for HTTP URL.)
*/ */
// Imports // Imports
const lighthouse = require('lighthouse'); const lighthouse = require('lighthouse');
const chromeLauncher = require('lighthouse/chrome-launcher/chrome-launcher'); const chromeLauncher = require('lighthouse/chrome-launcher');
const printer = require('lighthouse/lighthouse-cli/printer'); const printer = require('lighthouse/lighthouse-cli/printer');
const config = require('lighthouse/lighthouse-core/config/default.js'); const config = require('lighthouse/lighthouse-core/config/default.js');
@ -35,7 +35,7 @@ function _main(args) {
console.log(`Running PWA audit for '${url}'...`); console.log(`Running PWA audit for '${url}'...`);
if (isOnHttp) { if (isOnHttp) {
ignoreHttpsAudits(config); skipHttpsAudits(config);
} }
launchChromeAndRunLighthouse(url, {}, config). launchChromeAndRunLighthouse(url, {}, config).
@ -54,20 +54,14 @@ function evaluateScore(expectedScore, actualScore) {
} }
} }
function ignoreHttpsAudits(config) { function skipHttpsAudits(config) {
const httpsAudits = [ const httpsAudits = [
'redirects-http' 'redirects-http'
]; ];
console.info(`Ignoring HTTPS-related audits (${httpsAudits.join(', ')})...`); console.info(`Skipping HTTPS-related audits (${httpsAudits.join(', ')})...`);
config.categories.pwa.audits.forEach(audit => { config.settings.skipAudits = httpsAudits;
if (httpsAudits.indexOf(audit.id) !== -1) {
// Ugly hack to ignore HTTPS-related audits.
// Only meant for use during development.
audit.weight = 0;
}
});
} }
function launchChromeAndRunLighthouse(url, flags, config) { function launchChromeAndRunLighthouse(url, flags, config) {
@ -105,7 +99,10 @@ function processResults(results, logFile) {
console.log(`Saving results in '${logFile}'...`); console.log(`Saving results in '${logFile}'...`);
console.log(`(LightHouse viewer: ${VIEWER_URL})`); console.log(`(LightHouse viewer: ${VIEWER_URL})`);
results.artifacts = undefined; // Too large for the logs. // Remove the artifacts, which are not necessary for the report.
// (Saves ~1,500,000 lines of formatted JSON output \o/)
results.artifacts = undefined;
promise = printer.write(results, 'json', logFile); promise = printer.write(results, 'json', logFile);
} }

View File

@ -4998,7 +4998,7 @@ lighthouse-logger@^1.0.0:
dependencies: dependencies:
debug "^2.6.8" debug "^2.6.8"
lighthouse@^2.1.0: lighthouse@^2.5.0:
version "2.5.0" version "2.5.0"
resolved "https://registry.yarnpkg.com/lighthouse/-/lighthouse-2.5.0.tgz#c38c3bb0cfc5645bd59ed2550531bdc59a6c8fdd" resolved "https://registry.yarnpkg.com/lighthouse/-/lighthouse-2.5.0.tgz#c38c3bb0cfc5645bd59ed2550531bdc59a6c8fdd"
dependencies: dependencies: