From e93bac9a0b70f47b7d27b1f85e163f3229b3078d Mon Sep 17 00:00:00 2001 From: Brendan Kenny Date: Tue, 24 Apr 2018 18:37:48 -0700 Subject: [PATCH] report: move html report from v2/ dir to html/ (#5034) --- docs/hacking-tips.md | 10 +++---- lighthouse-core/audits/audit.js | 2 +- lighthouse-core/audits/bootup-time.js | 2 +- .../byte-efficiency/total-byte-weight.js | 2 +- .../audits/consistently-interactive.js | 2 +- .../audits/critical-request-chains.js | 2 +- lighthouse-core/audits/deprecations.js | 2 +- .../audits/dobetterweb/dom-size.js | 2 +- .../dobetterweb/link-blocking-first-paint.js | 2 +- .../audits/dobetterweb/uses-http2.js | 2 +- .../audits/estimated-input-latency.js | 2 +- .../audits/first-contentful-paint.js | 2 +- lighthouse-core/audits/first-cpu-idle.js | 2 +- .../audits/first-meaningful-paint.js | 2 +- lighthouse-core/audits/is-on-https.js | 2 +- .../audits/load-fast-enough-for-pwa.js | 2 +- .../audits/mainthread-work-breakdown.js | 2 +- lighthouse-core/audits/mixed-content.js | 2 +- lighthouse-core/audits/predictive-perf.js | 2 +- lighthouse-core/audits/redirects.js | 2 +- lighthouse-core/audits/speed-index.js | 2 +- lighthouse-core/audits/time-to-first-byte.js | 2 +- lighthouse-core/audits/uses-rel-preload.js | 2 +- .../closure/closure-type-checking.js | 2 +- lighthouse-core/lib/url-shim.js | 2 +- .../report/{v2 => html}/html-report-assets.js | 0 .../renderer/category-renderer.js | 0 .../renderer/crc-details-renderer.js | 0 .../{v2 => html}/renderer/details-renderer.js | 0 .../report/{v2 => html}/renderer/dom.js | 0 .../report/{v2 => html}/renderer/logger.js | 0 .../renderer/performance-category-renderer.js | 0 .../{v2 => html}/renderer/report-renderer.js | 0 .../renderer/report-ui-features.js | 0 .../report/{v2 => html}/renderer/util.js | 0 .../report/{v2 => html}/report-styles.css | 0 .../report/{v2 => html}/report-template.html | 0 .../report/{v2 => html}/templates.html | 0 .../report/{v2 => }/report-generator.js | 14 ++++----- lighthouse-core/runner.js | 2 +- lighthouse-core/scripts/roll-to-devtools.sh | 4 +-- .../renderer/category-renderer-test.js | 15 +++++----- .../renderer/crc-details-renderer-test.js | 9 +++--- .../renderer/details-renderer-test.js | 9 +++--- .../report/{v2 => html}/renderer/dom-test.js | 5 ++-- .../performance-category-renderer-test.js | 17 ++++++----- .../renderer/report-renderer-test.js | 21 ++++++------- .../report/{v2 => html}/renderer/util-test.js | 2 +- .../report/{v2 => }/report-generator-test.js | 30 +++++++++---------- lighthouse-extension/gulpfile.js | 2 +- lighthouse-viewer/gulpfile.js | 10 +++---- 51 files changed, 102 insertions(+), 96 deletions(-) rename lighthouse-core/report/{v2 => html}/html-report-assets.js (100%) rename lighthouse-core/report/{v2 => html}/renderer/category-renderer.js (100%) rename lighthouse-core/report/{v2 => html}/renderer/crc-details-renderer.js (100%) rename lighthouse-core/report/{v2 => html}/renderer/details-renderer.js (100%) rename lighthouse-core/report/{v2 => html}/renderer/dom.js (100%) rename lighthouse-core/report/{v2 => html}/renderer/logger.js (100%) rename lighthouse-core/report/{v2 => html}/renderer/performance-category-renderer.js (100%) rename lighthouse-core/report/{v2 => html}/renderer/report-renderer.js (100%) rename lighthouse-core/report/{v2 => html}/renderer/report-ui-features.js (100%) rename lighthouse-core/report/{v2 => html}/renderer/util.js (100%) rename lighthouse-core/report/{v2 => html}/report-styles.css (100%) rename lighthouse-core/report/{v2 => html}/report-template.html (100%) rename lighthouse-core/report/{v2 => html}/templates.html (100%) rename lighthouse-core/report/{v2 => }/report-generator.js (90%) rename lighthouse-core/test/report/{v2 => html}/renderer/category-renderer-test.js (95%) rename lighthouse-core/test/report/{v2 => html}/renderer/crc-details-renderer-test.js (91%) rename lighthouse-core/test/report/{v2 => html}/renderer/details-renderer-test.js (94%) rename lighthouse-core/test/report/{v2 => html}/renderer/dom-test.js (96%) rename lighthouse-core/test/report/{v2 => html}/renderer/performance-category-renderer-test.js (91%) rename lighthouse-core/test/report/{v2 => html}/renderer/report-renderer-test.js (90%) rename lighthouse-core/test/report/{v2 => html}/renderer/util-test.js (97%) rename lighthouse-core/test/report/{v2 => }/report-generator-test.js (77%) diff --git a/docs/hacking-tips.md b/docs/hacking-tips.md index f20101e3a744..7546b74758bf 100644 --- a/docs/hacking-tips.md +++ b/docs/hacking-tips.md @@ -24,7 +24,7 @@ npm run start -- --output=json --output-path=lighthouse-core/test/results/sample After updating, consider deleting any irrelevant changes from the diff (exact timings, timestamps, etc). Be sure to run the tests. -## Iterating on the v2 report +## Iterating on the report This will generate new reports from the same results json. @@ -33,15 +33,15 @@ This will generate new reports from the same results json. lighthouse --output=json http://example.com > temp.report.json # quickly generate reports: -node generate_report_v2.js > temp.report.html; open temp.report.html +node generate_report.js > temp.report.html; open temp.report.html ``` ```js -// generate_report_v2.js +// generate_report.js 'use strict'; -const ReportGeneratorV2 = require('./lighthouse-core/report/v2/report-generator'); +const ReportGenerator = require('./lighthouse-core/report/report-generator'); const results = require('./temp.report.json'); -const html = ReportGeneratorV2.generateReportHtml(results); +const html = ReportGenerator.generateReportHtml(results); console.log(html); ``` diff --git a/lighthouse-core/audits/audit.js b/lighthouse-core/audits/audit.js index 4d66bf726217..a531a644cbf0 100644 --- a/lighthouse-core/audits/audit.js +++ b/lighthouse-core/audits/audit.js @@ -6,7 +6,7 @@ 'use strict'; const statistics = require('../lib/statistics'); -const Util = require('../report/v2/renderer/util'); +const Util = require('../report/html/renderer/util'); const DEFAULT_PASS = 'defaultPass'; diff --git a/lighthouse-core/audits/bootup-time.js b/lighthouse-core/audits/bootup-time.js index 5b20254f7345..b77daaa92578 100644 --- a/lighthouse-core/audits/bootup-time.js +++ b/lighthouse-core/audits/bootup-time.js @@ -7,7 +7,7 @@ const Audit = require('./audit'); const WebInspector = require('../lib/web-inspector'); -const Util = require('../report/v2/renderer/util'); +const Util = require('../report/html/renderer/util'); const {groupIdToName, taskToGroup} = require('../lib/task-groups'); const THRESHOLD_IN_MS = 10; diff --git a/lighthouse-core/audits/byte-efficiency/total-byte-weight.js b/lighthouse-core/audits/byte-efficiency/total-byte-weight.js index b962a70a6cb6..816108aced68 100644 --- a/lighthouse-core/audits/byte-efficiency/total-byte-weight.js +++ b/lighthouse-core/audits/byte-efficiency/total-byte-weight.js @@ -6,7 +6,7 @@ 'use strict'; const ByteEfficiencyAudit = require('./byte-efficiency-audit'); -const Util = require('../../report/v2/renderer/util'); +const Util = require('../../report/html/renderer/util'); class TotalByteWeight extends ByteEfficiencyAudit { /** diff --git a/lighthouse-core/audits/consistently-interactive.js b/lighthouse-core/audits/consistently-interactive.js index aa56477a4c90..e351eac364ad 100644 --- a/lighthouse-core/audits/consistently-interactive.js +++ b/lighthouse-core/audits/consistently-interactive.js @@ -6,7 +6,7 @@ 'use strict'; const Audit = require('./audit'); -const Util = require('../report/v2/renderer/util'); +const Util = require('../report/html/renderer/util'); /** * @fileoverview This audit identifies the time the page is "consistently interactive". diff --git a/lighthouse-core/audits/critical-request-chains.js b/lighthouse-core/audits/critical-request-chains.js index fbb187e369f5..dc17b8cafb6a 100644 --- a/lighthouse-core/audits/critical-request-chains.js +++ b/lighthouse-core/audits/critical-request-chains.js @@ -6,7 +6,7 @@ 'use strict'; const Audit = require('./audit'); -const Util = require('../report/v2/renderer/util'); +const Util = require('../report/html/renderer/util'); class CriticalRequestChains extends Audit { /** diff --git a/lighthouse-core/audits/deprecations.js b/lighthouse-core/audits/deprecations.js index 99df0d6d190e..ff5ac95c0bad 100644 --- a/lighthouse-core/audits/deprecations.js +++ b/lighthouse-core/audits/deprecations.js @@ -12,7 +12,7 @@ */ const Audit = require('./audit'); -const Util = require('../report/v2/renderer/util'); +const Util = require('../report/html/renderer/util'); class Deprecations extends Audit { /** diff --git a/lighthouse-core/audits/dobetterweb/dom-size.js b/lighthouse-core/audits/dobetterweb/dom-size.js index f5d99790491a..70db56c4e7f3 100644 --- a/lighthouse-core/audits/dobetterweb/dom-size.js +++ b/lighthouse-core/audits/dobetterweb/dom-size.js @@ -13,7 +13,7 @@ 'use strict'; const Audit = require('../audit'); -const Util = require('../../report/v2/renderer/util.js'); +const Util = require('../../report/html/renderer/util.js'); const MAX_DOM_NODES = 1500; const MAX_DOM_TREE_WIDTH = 60; diff --git a/lighthouse-core/audits/dobetterweb/link-blocking-first-paint.js b/lighthouse-core/audits/dobetterweb/link-blocking-first-paint.js index 6deecbd6dd66..8b8a3f21822b 100644 --- a/lighthouse-core/audits/dobetterweb/link-blocking-first-paint.js +++ b/lighthouse-core/audits/dobetterweb/link-blocking-first-paint.js @@ -11,7 +11,7 @@ 'use strict'; const Audit = require('../audit'); -const Util = require('../../report/v2/renderer/util.js'); +const Util = require('../../report/html/renderer/util.js'); const ByteEfficiencyAudit = require('../byte-efficiency/byte-efficiency-audit'); // Because of the way we detect blocking stylesheets, asynchronously loaded diff --git a/lighthouse-core/audits/dobetterweb/uses-http2.js b/lighthouse-core/audits/dobetterweb/uses-http2.js index 53ceb31548f0..169b5466a000 100644 --- a/lighthouse-core/audits/dobetterweb/uses-http2.js +++ b/lighthouse-core/audits/dobetterweb/uses-http2.js @@ -13,7 +13,7 @@ const URL = require('../../lib/url-shim'); const Audit = require('../audit'); -const Util = require('../../report/v2/renderer/util.js'); +const Util = require('../../report/html/renderer/util.js'); class UsesHTTP2Audit extends Audit { /** diff --git a/lighthouse-core/audits/estimated-input-latency.js b/lighthouse-core/audits/estimated-input-latency.js index d70857300d20..52d02f14d05f 100644 --- a/lighthouse-core/audits/estimated-input-latency.js +++ b/lighthouse-core/audits/estimated-input-latency.js @@ -6,7 +6,7 @@ 'use strict'; const Audit = require('./audit'); -const Util = require('../report/v2/renderer/util'); +const Util = require('../report/html/renderer/util'); const TracingProcessor = require('../lib/traces/tracing-processor'); const LHError = require('../lib/errors'); diff --git a/lighthouse-core/audits/first-contentful-paint.js b/lighthouse-core/audits/first-contentful-paint.js index 8baa1b2696d0..f45d9df8449c 100644 --- a/lighthouse-core/audits/first-contentful-paint.js +++ b/lighthouse-core/audits/first-contentful-paint.js @@ -6,7 +6,7 @@ 'use strict'; const Audit = require('./audit'); -const Util = require('../report/v2/renderer/util.js'); +const Util = require('../report/html/renderer/util.js'); class FirstContentfulPaint extends Audit { /** diff --git a/lighthouse-core/audits/first-cpu-idle.js b/lighthouse-core/audits/first-cpu-idle.js index a32016e088e0..ede70fbf2b69 100644 --- a/lighthouse-core/audits/first-cpu-idle.js +++ b/lighthouse-core/audits/first-cpu-idle.js @@ -6,7 +6,7 @@ 'use strict'; const Audit = require('./audit'); -const Util = require('../report/v2/renderer/util.js'); +const Util = require('../report/html/renderer/util.js'); class FirstCPUIdle extends Audit { /** diff --git a/lighthouse-core/audits/first-meaningful-paint.js b/lighthouse-core/audits/first-meaningful-paint.js index 03a24f66be10..0949d0d472e2 100644 --- a/lighthouse-core/audits/first-meaningful-paint.js +++ b/lighthouse-core/audits/first-meaningful-paint.js @@ -6,7 +6,7 @@ 'use strict'; const Audit = require('./audit'); -const Util = require('../report/v2/renderer/util'); +const Util = require('../report/html/renderer/util'); class FirstMeaningfulPaint extends Audit { /** diff --git a/lighthouse-core/audits/is-on-https.js b/lighthouse-core/audits/is-on-https.js index 709d8d5e7572..2bd47c7ec269 100644 --- a/lighthouse-core/audits/is-on-https.js +++ b/lighthouse-core/audits/is-on-https.js @@ -7,7 +7,7 @@ const Audit = require('./audit'); const URL = require('../lib/url-shim'); -const Util = require('../report/v2/renderer/util'); +const Util = require('../report/html/renderer/util'); const SECURE_SCHEMES = ['data', 'https', 'wss', 'blob', 'chrome', 'chrome-extension', 'about']; const SECURE_DOMAINS = ['localhost', '127.0.0.1']; diff --git a/lighthouse-core/audits/load-fast-enough-for-pwa.js b/lighthouse-core/audits/load-fast-enough-for-pwa.js index 17b1d7943757..8abaf3e86b2f 100644 --- a/lighthouse-core/audits/load-fast-enough-for-pwa.js +++ b/lighthouse-core/audits/load-fast-enough-for-pwa.js @@ -14,7 +14,7 @@ const isDeepEqual = require('lodash.isequal'); const Audit = require('./audit'); const mobile3GThrottling = require('../config/constants').throttling.mobile3G; -const Util = require('../report/v2/renderer/util.js'); +const Util = require('../report/html/renderer/util.js'); // Maximum TTI to be considered "fast" for PWA baseline checklist // https://developers.google.com/web/progressive-web-apps/checklist diff --git a/lighthouse-core/audits/mainthread-work-breakdown.js b/lighthouse-core/audits/mainthread-work-breakdown.js index 74062a3528ea..7bb8da2d5bab 100644 --- a/lighthouse-core/audits/mainthread-work-breakdown.js +++ b/lighthouse-core/audits/mainthread-work-breakdown.js @@ -11,7 +11,7 @@ 'use strict'; const Audit = require('./audit'); -const Util = require('../report/v2/renderer/util'); +const Util = require('../report/html/renderer/util'); // We group all trace events into groups to show a highlevel breakdown of the page const {taskToGroup} = require('../lib/task-groups'); diff --git a/lighthouse-core/audits/mixed-content.js b/lighthouse-core/audits/mixed-content.js index afc8b32ad512..fe0f1ed2ce05 100644 --- a/lighthouse-core/audits/mixed-content.js +++ b/lighthouse-core/audits/mixed-content.js @@ -7,7 +7,7 @@ const Audit = require('./audit'); const URL = require('../lib/url-shim'); -const Util = require('../report/v2/renderer/util'); +const Util = require('../report/html/renderer/util'); /** * This audit checks which resources a page currently loads over HTTP which it diff --git a/lighthouse-core/audits/predictive-perf.js b/lighthouse-core/audits/predictive-perf.js index d18d31708a7b..9bf72f66d143 100644 --- a/lighthouse-core/audits/predictive-perf.js +++ b/lighthouse-core/audits/predictive-perf.js @@ -6,7 +6,7 @@ 'use strict'; const Audit = require('./audit'); -const Util = require('../report/v2/renderer/util'); +const Util = require('../report/html/renderer/util'); // Parameters (in ms) for log-normal CDF scoring. To see the curve: // https://www.desmos.com/calculator/rjp0lbit8y diff --git a/lighthouse-core/audits/redirects.js b/lighthouse-core/audits/redirects.js index c3468ce8e5dc..3a1097f5dc33 100644 --- a/lighthouse-core/audits/redirects.js +++ b/lighthouse-core/audits/redirects.js @@ -6,7 +6,7 @@ 'use strict'; const Audit = require('./audit'); -const Util = require('../report/v2/renderer/util'); +const Util = require('../report/html/renderer/util'); const UnusedBytes = require('./byte-efficiency/byte-efficiency-audit'); class Redirects extends Audit { diff --git a/lighthouse-core/audits/speed-index.js b/lighthouse-core/audits/speed-index.js index 991261b2935f..77f91ae53314 100644 --- a/lighthouse-core/audits/speed-index.js +++ b/lighthouse-core/audits/speed-index.js @@ -6,7 +6,7 @@ 'use strict'; const Audit = require('./audit'); -const Util = require('../report/v2/renderer/util'); +const Util = require('../report/html/renderer/util'); class SpeedIndex extends Audit { /** diff --git a/lighthouse-core/audits/time-to-first-byte.js b/lighthouse-core/audits/time-to-first-byte.js index 93313d4b0576..cbf9f3e76567 100644 --- a/lighthouse-core/audits/time-to-first-byte.js +++ b/lighthouse-core/audits/time-to-first-byte.js @@ -6,7 +6,7 @@ 'use strict'; const Audit = require('./audit'); -const Util = require('../report/v2/renderer/util'); +const Util = require('../report/html/renderer/util'); const TTFB_THRESHOLD = 600; diff --git a/lighthouse-core/audits/uses-rel-preload.js b/lighthouse-core/audits/uses-rel-preload.js index 1f8af46e0301..963c9a8248d4 100644 --- a/lighthouse-core/audits/uses-rel-preload.js +++ b/lighthouse-core/audits/uses-rel-preload.js @@ -7,7 +7,7 @@ 'use strict'; const Audit = require('./audit'); -const Util = require('../report/v2/renderer/util'); +const Util = require('../report/html/renderer/util'); const UnusedBytes = require('./byte-efficiency/byte-efficiency-audit'); const THRESHOLD_IN_MS = 100; diff --git a/lighthouse-core/closure/closure-type-checking.js b/lighthouse-core/closure/closure-type-checking.js index d596f6646a25..4dc3bbebeefc 100755 --- a/lighthouse-core/closure/closure-type-checking.js +++ b/lighthouse-core/closure/closure-type-checking.js @@ -24,7 +24,7 @@ gulp.task('compile-report', () => { 'closure/typedefs/viewer-externs.js', 'lib/file-namer.js', - 'report/v2/renderer/*.js', + 'report/html/renderer/*.js', '../lighthouse-viewer/app/src/viewer-ui-features.js', ]) diff --git a/lighthouse-core/lib/url-shim.js b/lighthouse-core/lib/url-shim.js index fd6be7b7ccc2..b2aeca30c5e8 100644 --- a/lighthouse-core/lib/url-shim.js +++ b/lighthouse-core/lib/url-shim.js @@ -11,7 +11,7 @@ /* global self */ -const Util = require('../report/v2/renderer/util.js'); +const Util = require('../report/html/renderer/util.js'); // Type cast so tsc sees window.URL and require('url').URL as sufficiently equivalent. const URL = /** @type {!Window["URL"]} */ (typeof self !== 'undefined' && self.URL) || diff --git a/lighthouse-core/report/v2/html-report-assets.js b/lighthouse-core/report/html/html-report-assets.js similarity index 100% rename from lighthouse-core/report/v2/html-report-assets.js rename to lighthouse-core/report/html/html-report-assets.js diff --git a/lighthouse-core/report/v2/renderer/category-renderer.js b/lighthouse-core/report/html/renderer/category-renderer.js similarity index 100% rename from lighthouse-core/report/v2/renderer/category-renderer.js rename to lighthouse-core/report/html/renderer/category-renderer.js diff --git a/lighthouse-core/report/v2/renderer/crc-details-renderer.js b/lighthouse-core/report/html/renderer/crc-details-renderer.js similarity index 100% rename from lighthouse-core/report/v2/renderer/crc-details-renderer.js rename to lighthouse-core/report/html/renderer/crc-details-renderer.js diff --git a/lighthouse-core/report/v2/renderer/details-renderer.js b/lighthouse-core/report/html/renderer/details-renderer.js similarity index 100% rename from lighthouse-core/report/v2/renderer/details-renderer.js rename to lighthouse-core/report/html/renderer/details-renderer.js diff --git a/lighthouse-core/report/v2/renderer/dom.js b/lighthouse-core/report/html/renderer/dom.js similarity index 100% rename from lighthouse-core/report/v2/renderer/dom.js rename to lighthouse-core/report/html/renderer/dom.js diff --git a/lighthouse-core/report/v2/renderer/logger.js b/lighthouse-core/report/html/renderer/logger.js similarity index 100% rename from lighthouse-core/report/v2/renderer/logger.js rename to lighthouse-core/report/html/renderer/logger.js diff --git a/lighthouse-core/report/v2/renderer/performance-category-renderer.js b/lighthouse-core/report/html/renderer/performance-category-renderer.js similarity index 100% rename from lighthouse-core/report/v2/renderer/performance-category-renderer.js rename to lighthouse-core/report/html/renderer/performance-category-renderer.js diff --git a/lighthouse-core/report/v2/renderer/report-renderer.js b/lighthouse-core/report/html/renderer/report-renderer.js similarity index 100% rename from lighthouse-core/report/v2/renderer/report-renderer.js rename to lighthouse-core/report/html/renderer/report-renderer.js diff --git a/lighthouse-core/report/v2/renderer/report-ui-features.js b/lighthouse-core/report/html/renderer/report-ui-features.js similarity index 100% rename from lighthouse-core/report/v2/renderer/report-ui-features.js rename to lighthouse-core/report/html/renderer/report-ui-features.js diff --git a/lighthouse-core/report/v2/renderer/util.js b/lighthouse-core/report/html/renderer/util.js similarity index 100% rename from lighthouse-core/report/v2/renderer/util.js rename to lighthouse-core/report/html/renderer/util.js diff --git a/lighthouse-core/report/v2/report-styles.css b/lighthouse-core/report/html/report-styles.css similarity index 100% rename from lighthouse-core/report/v2/report-styles.css rename to lighthouse-core/report/html/report-styles.css diff --git a/lighthouse-core/report/v2/report-template.html b/lighthouse-core/report/html/report-template.html similarity index 100% rename from lighthouse-core/report/v2/report-template.html rename to lighthouse-core/report/html/report-template.html diff --git a/lighthouse-core/report/v2/templates.html b/lighthouse-core/report/html/templates.html similarity index 100% rename from lighthouse-core/report/v2/templates.html rename to lighthouse-core/report/html/templates.html diff --git a/lighthouse-core/report/v2/report-generator.js b/lighthouse-core/report/report-generator.js similarity index 90% rename from lighthouse-core/report/v2/report-generator.js rename to lighthouse-core/report/report-generator.js index bb8debf74f3c..d010ce4ce5d4 100644 --- a/lighthouse-core/report/v2/report-generator.js +++ b/lighthouse-core/report/report-generator.js @@ -5,9 +5,9 @@ */ 'use strict'; -const htmlReportAssets = require('./html-report-assets'); +const htmlReportAssets = require('./html/html-report-assets'); -class ReportGeneratorV2 { +class ReportGenerator { /** * Replaces all the specified strings in source without serial replacements. * @param {string} source @@ -23,7 +23,7 @@ class ReportGeneratorV2 { const nextReplacements = replacements.slice(1); return source .split(firstReplacement.search) - .map(part => ReportGeneratorV2.replaceStrings(part, nextReplacements)) + .map(part => ReportGenerator.replaceStrings(part, nextReplacements)) .join(firstReplacement.replacement); } @@ -39,7 +39,7 @@ class ReportGeneratorV2 { .replace(/\u2029/g, '\\u2029'); // replaces paragraph separators const sanitizedJavascript = htmlReportAssets.REPORT_JAVASCRIPT.replace(/<\//g, '\\u003c/'); - return ReportGeneratorV2.replaceStrings(htmlReportAssets.REPORT_TEMPLATE, [ + return ReportGenerator.replaceStrings(htmlReportAssets.REPORT_TEMPLATE, [ {search: '%%LIGHTHOUSE_JSON%%', replacement: sanitizedJson}, {search: '%%LIGHTHOUSE_JAVASCRIPT%%', replacement: sanitizedJavascript}, {search: '/*%%LIGHTHOUSE_CSS%%*/', replacement: htmlReportAssets.REPORT_CSS}, @@ -92,11 +92,11 @@ class ReportGeneratorV2 { static generateReport(lhr, outputMode) { // HTML report. if (outputMode === 'html') { - return ReportGeneratorV2.generateReportHtml(lhr); + return ReportGenerator.generateReportHtml(lhr); } // CSV report. if (outputMode === 'csv') { - return ReportGeneratorV2.generateReportCSV(lhr); + return ReportGenerator.generateReportCSV(lhr); } // JSON report. if (outputMode === 'json') { @@ -107,4 +107,4 @@ class ReportGeneratorV2 { } } -module.exports = ReportGeneratorV2; +module.exports = ReportGenerator; diff --git a/lighthouse-core/runner.js b/lighthouse-core/runner.js index 6daeb5b1031d..c617654d8f57 100644 --- a/lighthouse-core/runner.js +++ b/lighthouse-core/runner.js @@ -17,7 +17,7 @@ const fs = require('fs'); const path = require('path'); const URL = require('./lib/url-shim'); const Sentry = require('./lib/sentry'); -const generateReport = require('./report/v2/report-generator').generateReport; +const generateReport = require('./report/report-generator').generateReport; const Connection = require('./gather/connections/connection.js'); // eslint-disable-line no-unused-vars diff --git a/lighthouse-core/scripts/roll-to-devtools.sh b/lighthouse-core/scripts/roll-to-devtools.sh index d52970a66dc2..0736397e14df 100755 --- a/lighthouse-core/scripts/roll-to-devtools.sh +++ b/lighthouse-core/scripts/roll-to-devtools.sh @@ -30,14 +30,14 @@ else echo -e "\033[96m ✓\033[39m Chromium folder in place." fi -v2dir="lighthouse-core/report/v2" +report_dir="lighthouse-core/report/html" fe_lh_dir="$frontend_dir/audits2/lighthouse" lh_bg_js="lighthouse-extension/dist/scripts/lighthouse-background.js" lh_worker_dir="$frontend_dir/audits2_worker/lighthouse" # copy report files -cp -pPR $v2dir/{report-styles.css,templates.html,renderer} "$fe_lh_dir" +cp -pPR $report_dir/{report-styles.css,templates.html,renderer} "$fe_lh_dir" echo -e "\033[32m ✓\033[39m Report renderer files copied." # copy lighthouse-background (potentially stale) diff --git a/lighthouse-core/test/report/v2/renderer/category-renderer-test.js b/lighthouse-core/test/report/html/renderer/category-renderer-test.js similarity index 95% rename from lighthouse-core/test/report/v2/renderer/category-renderer-test.js rename to lighthouse-core/test/report/html/renderer/category-renderer-test.js index deeaaca4180c..7476db32f63a 100644 --- a/lighthouse-core/test/report/v2/renderer/category-renderer-test.js +++ b/lighthouse-core/test/report/html/renderer/category-renderer-test.js @@ -10,17 +10,18 @@ const assert = require('assert'); const fs = require('fs'); const jsdom = require('jsdom'); -const Util = require('../../../../report/v2/renderer/util.js'); +const Util = require('../../../../report/html/renderer/util.js'); const URL = require('../../../../lib/url-shim'); -const DOM = require('../../../../report/v2/renderer/dom.js'); -const DetailsRenderer = require('../../../../report/v2/renderer/details-renderer.js'); +const DOM = require('../../../../report/html/renderer/dom.js'); +const DetailsRenderer = require('../../../../report/html/renderer/details-renderer.js'); const CriticalRequestChainRenderer = require( - '../../../../report/v2/renderer/crc-details-renderer.js'); -const CategoryRenderer = require('../../../../report/v2/renderer/category-renderer.js'); -const ReportRenderer = require('../../../../report/v2/renderer/report-renderer.js'); + '../../../../report/html/renderer/crc-details-renderer.js'); +const CategoryRenderer = require('../../../../report/html/renderer/category-renderer.js'); +const ReportRenderer = require('../../../../report/html/renderer/report-renderer.js'); const sampleResults = require('../../../results/sample_v2.json'); -const TEMPLATE_FILE = fs.readFileSync(__dirname + '/../../../../report/v2/templates.html', 'utf8'); +const TEMPLATE_FILE = fs.readFileSync(__dirname + + '/../../../../report/html/templates.html', 'utf8'); describe('CategoryRenderer', () => { let renderer; diff --git a/lighthouse-core/test/report/v2/renderer/crc-details-renderer-test.js b/lighthouse-core/test/report/html/renderer/crc-details-renderer-test.js similarity index 91% rename from lighthouse-core/test/report/v2/renderer/crc-details-renderer-test.js rename to lighthouse-core/test/report/html/renderer/crc-details-renderer-test.js index a63bc0f186fb..c2cdc8edcf3b 100644 --- a/lighthouse-core/test/report/v2/renderer/crc-details-renderer-test.js +++ b/lighthouse-core/test/report/html/renderer/crc-details-renderer-test.js @@ -11,12 +11,13 @@ const assert = require('assert'); const fs = require('fs'); const jsdom = require('jsdom'); const URL = require('../../../../lib/url-shim'); -const Util = require('../../../../report/v2/renderer/util.js'); -const DOM = require('../../../../report/v2/renderer/dom.js'); +const Util = require('../../../../report/html/renderer/util.js'); +const DOM = require('../../../../report/html/renderer/dom.js'); const CriticalRequestChainRenderer = - require('../../../../report/v2/renderer/crc-details-renderer.js'); + require('../../../../report/html/renderer/crc-details-renderer.js'); -const TEMPLATE_FILE = fs.readFileSync(__dirname + '/../../../../report/v2/templates.html', 'utf8'); +const TEMPLATE_FILE = fs.readFileSync(__dirname + + '/../../../../report/html/templates.html', 'utf8'); const superLongURL = 'https://example.com/thisIsASuperLongURLThatWillTriggerFilenameTruncationWhichWeWantToTest.js'; diff --git a/lighthouse-core/test/report/v2/renderer/details-renderer-test.js b/lighthouse-core/test/report/html/renderer/details-renderer-test.js similarity index 94% rename from lighthouse-core/test/report/v2/renderer/details-renderer-test.js rename to lighthouse-core/test/report/html/renderer/details-renderer-test.js index 167b266cc2de..2d303a6f30cb 100644 --- a/lighthouse-core/test/report/v2/renderer/details-renderer-test.js +++ b/lighthouse-core/test/report/html/renderer/details-renderer-test.js @@ -9,11 +9,12 @@ const assert = require('assert'); const fs = require('fs'); const jsdom = require('jsdom'); const URL = require('../../../../lib/url-shim'); -const DOM = require('../../../../report/v2/renderer/dom.js'); -const Util = require('../../../../report/v2/renderer/util.js'); -const DetailsRenderer = require('../../../../report/v2/renderer/details-renderer.js'); +const DOM = require('../../../../report/html/renderer/dom.js'); +const Util = require('../../../../report/html/renderer/util.js'); +const DetailsRenderer = require('../../../../report/html/renderer/details-renderer.js'); -const TEMPLATE_FILE = fs.readFileSync(__dirname + '/../../../../report/v2/templates.html', 'utf8'); +const TEMPLATE_FILE = fs.readFileSync(__dirname + + '/../../../../report/html/templates.html', 'utf8'); /* eslint-env mocha */ diff --git a/lighthouse-core/test/report/v2/renderer/dom-test.js b/lighthouse-core/test/report/html/renderer/dom-test.js similarity index 96% rename from lighthouse-core/test/report/v2/renderer/dom-test.js rename to lighthouse-core/test/report/html/renderer/dom-test.js index 37549b39ffc2..11d0382c2b89 100644 --- a/lighthouse-core/test/report/v2/renderer/dom-test.js +++ b/lighthouse-core/test/report/html/renderer/dom-test.js @@ -9,9 +9,10 @@ const assert = require('assert'); const fs = require('fs'); const jsdom = require('jsdom'); const URL = require('../../../../lib/url-shim'); -const DOM = require('../../../../report/v2/renderer/dom.js'); +const DOM = require('../../../../report/html/renderer/dom.js'); -const TEMPLATE_FILE = fs.readFileSync(__dirname + '/../../../../report/v2/templates.html', 'utf8'); +const TEMPLATE_FILE = fs.readFileSync(__dirname + + '/../../../../report/html/templates.html', 'utf8'); /* eslint-env mocha */ diff --git a/lighthouse-core/test/report/v2/renderer/performance-category-renderer-test.js b/lighthouse-core/test/report/html/renderer/performance-category-renderer-test.js similarity index 91% rename from lighthouse-core/test/report/v2/renderer/performance-category-renderer-test.js rename to lighthouse-core/test/report/html/renderer/performance-category-renderer-test.js index 07b3866176d2..8b0b479265ae 100644 --- a/lighthouse-core/test/report/v2/renderer/performance-category-renderer-test.js +++ b/lighthouse-core/test/report/html/renderer/performance-category-renderer-test.js @@ -10,17 +10,18 @@ const assert = require('assert'); const fs = require('fs'); const jsdom = require('jsdom'); -const Util = require('../../../../report/v2/renderer/util.js'); +const Util = require('../../../../report/html/renderer/util.js'); const URL = require('../../../../lib/url-shim'); -const DOM = require('../../../../report/v2/renderer/dom.js'); -const DetailsRenderer = require('../../../../report/v2/renderer/details-renderer.js'); +const DOM = require('../../../../report/html/renderer/dom.js'); +const DetailsRenderer = require('../../../../report/html/renderer/details-renderer.js'); const CriticalRequestChainRenderer = require( - '../../../../report/v2/renderer/crc-details-renderer.js'); -const CategoryRenderer = require('../../../../report/v2/renderer/category-renderer.js'); -const ReportRenderer = require('../../../../report/v2/renderer/report-renderer.js'); + '../../../../report/html/renderer/crc-details-renderer.js'); +const CategoryRenderer = require('../../../../report/html/renderer/category-renderer.js'); +const ReportRenderer = require('../../../../report/html/renderer/report-renderer.js'); const sampleResults = require('../../../results/sample_v2.json'); -const TEMPLATE_FILE = fs.readFileSync(__dirname + '/../../../../report/v2/templates.html', 'utf8'); +const TEMPLATE_FILE = fs.readFileSync(__dirname + + '/../../../../report/html/templates.html', 'utf8'); describe('PerfCategoryRenderer', () => { let renderer; @@ -32,7 +33,7 @@ describe('PerfCategoryRenderer', () => { global.CategoryRenderer = CategoryRenderer; const PerformanceCategoryRenderer = - require('../../../../report/v2/renderer/performance-category-renderer.js'); + require('../../../../report/html/renderer/performance-category-renderer.js'); const document = jsdom.jsdom(TEMPLATE_FILE); const dom = new DOM(document); diff --git a/lighthouse-core/test/report/v2/renderer/report-renderer-test.js b/lighthouse-core/test/report/html/renderer/report-renderer-test.js similarity index 90% rename from lighthouse-core/test/report/v2/renderer/report-renderer-test.js rename to lighthouse-core/test/report/html/renderer/report-renderer-test.js index e4332696292d..6e77a29635aa 100644 --- a/lighthouse-core/test/report/v2/renderer/report-renderer-test.js +++ b/lighthouse-core/test/report/html/renderer/report-renderer-test.js @@ -10,23 +10,24 @@ const assert = require('assert'); const fs = require('fs'); const jsdom = require('jsdom'); -const Util = require('../../../../report/v2/renderer/util.js'); +const Util = require('../../../../report/html/renderer/util.js'); const URL = require('../../../../lib/url-shim'); -const DOM = require('../../../../report/v2/renderer/dom.js'); -const DetailsRenderer = require('../../../../report/v2/renderer/details-renderer.js'); -const ReportUIFeatures = require('../../../../report/v2/renderer/report-ui-features.js'); -const CategoryRenderer = require('../../../../report/v2/renderer/category-renderer.js'); +const DOM = require('../../../../report/html/renderer/dom.js'); +const DetailsRenderer = require('../../../../report/html/renderer/details-renderer.js'); +const ReportUIFeatures = require('../../../../report/html/renderer/report-ui-features.js'); +const CategoryRenderer = require('../../../../report/html/renderer/category-renderer.js'); // lazy loaded because it depends on CategoryRenderer to be available globally let PerformanceCategoryRenderer = null; const CriticalRequestChainRenderer = require( - '../../../../report/v2/renderer/crc-details-renderer.js'); -const ReportRenderer = require('../../../../report/v2/renderer/report-renderer.js'); + '../../../../report/html/renderer/crc-details-renderer.js'); +const ReportRenderer = require('../../../../report/html/renderer/report-renderer.js'); const sampleResults = require('../../../results/sample_v2.json'); const TIMESTAMP_REGEX = /\d+, \d{4}.*\d+:\d+/; -const TEMPLATE_FILE = fs.readFileSync(__dirname + '/../../../../report/v2/templates.html', 'utf8'); +const TEMPLATE_FILE = fs.readFileSync(__dirname + + '/../../../../report/html/templates.html', 'utf8'); -describe('ReportRenderer V2', () => { +describe('ReportRenderer', () => { let renderer; before(() => { @@ -38,7 +39,7 @@ describe('ReportRenderer V2', () => { global.CategoryRenderer = CategoryRenderer; if (!PerformanceCategoryRenderer) { PerformanceCategoryRenderer = - require('../../../../report/v2/renderer/performance-category-renderer.js'); + require('../../../../report/html/renderer/performance-category-renderer.js'); } global.PerformanceCategoryRenderer = PerformanceCategoryRenderer; diff --git a/lighthouse-core/test/report/v2/renderer/util-test.js b/lighthouse-core/test/report/html/renderer/util-test.js similarity index 97% rename from lighthouse-core/test/report/v2/renderer/util-test.js rename to lighthouse-core/test/report/html/renderer/util-test.js index 7cfaf2d630c6..dba2979fab3e 100644 --- a/lighthouse-core/test/report/v2/renderer/util-test.js +++ b/lighthouse-core/test/report/html/renderer/util-test.js @@ -6,7 +6,7 @@ 'use strict'; const assert = require('assert'); -const Util = require('../../../../report/v2/renderer/util.js'); +const Util = require('../../../../report/html/renderer/util.js'); const NBSP = '\xa0'; /* eslint-env mocha */ diff --git a/lighthouse-core/test/report/v2/report-generator-test.js b/lighthouse-core/test/report/report-generator-test.js similarity index 77% rename from lighthouse-core/test/report/v2/report-generator-test.js rename to lighthouse-core/test/report/report-generator-test.js index 0eea432682bc..00557ea86797 100644 --- a/lighthouse-core/test/report/v2/report-generator-test.js +++ b/lighthouse-core/test/report/report-generator-test.js @@ -8,18 +8,18 @@ const assert = require('assert'); const fs = require('fs'); const jsdom = require('jsdom'); -const ReportGeneratorV2 = require('../../../report/v2/report-generator.js'); -const TEMPLATES_FILE = fs.readFileSync(__dirname + '/../../../report/v2/templates.html', 'utf8'); -const sampleResults = require('../../../../lighthouse-core/test/results/sample_v2.json'); +const ReportGenerator = require('../../report/report-generator.js'); +const TEMPLATES_FILE = fs.readFileSync(__dirname + '/../../report/html/templates.html', 'utf8'); +const sampleResults = require('../../../lighthouse-core/test/results/sample_v2.json'); const csvValidator = require('csv-validator'); /* eslint-env mocha */ -describe('ReportGeneratorV2', () => { +describe('ReportGenerator', () => { describe('#replaceStrings', () => { it('should replace all occurrences', () => { const source = '%foo! %foo %bar!'; - const result = ReportGeneratorV2.replaceStrings(source, [ + const result = ReportGenerator.replaceStrings(source, [ {search: '%foo', replacement: 'hey'}, {search: '%bar', replacement: 'you'}, ]); @@ -28,7 +28,7 @@ describe('ReportGeneratorV2', () => { }); it('should not replace serial occurences', () => { - const result = ReportGeneratorV2.replaceStrings('%1', [ + const result = ReportGenerator.replaceStrings('%1', [ {search: '%1', replacement: '%2'}, {search: '%2', replacement: 'pwnd'}, ]); @@ -39,34 +39,34 @@ describe('ReportGeneratorV2', () => { describe('#generateHtmlReport', () => { it('should return html', () => { - const result = ReportGeneratorV2.generateReportHtml({}); + const result = ReportGenerator.generateReportHtml({}); assert.ok(result.includes('doctype html'), 'includes doctype'); assert.ok(result.trim().match(/<\/html>$/), 'ends with HTML tag'); }); it('should inject the report JSON', () => { const code = 'hax\u2028hax