Skip to content

Commit

Permalink
report: move html report from v2/ dir to html/ (GoogleChrome#5034)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny authored and kdzwinel committed Aug 16, 2018
1 parent 6eda27b commit 75ecb57
Show file tree
Hide file tree
Showing 51 changed files with 102 additions and 96 deletions.
10 changes: 5 additions & 5 deletions docs/hacking-tips.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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);
```
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/bootup-time.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/consistently-interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/critical-request-chains.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/deprecations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/dobetterweb/dom-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/dobetterweb/uses-http2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/estimated-input-latency.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/first-contentful-paint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/first-cpu-idle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/first-meaningful-paint.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/is-on-https.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/load-fast-enough-for-pwa.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/mainthread-work-breakdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/mixed-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/predictive-perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/redirects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/speed-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/time-to-first-byte.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/audits/uses-rel-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/closure/closure-type-checking.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
])

Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/lib/url-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

Expand All @@ -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},
Expand Down Expand Up @@ -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') {
Expand All @@ -107,4 +107,4 @@ class ReportGeneratorV2 {
}
}

module.exports = ReportGeneratorV2;
module.exports = ReportGenerator;
2 changes: 1 addition & 1 deletion lighthouse-core/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions lighthouse-core/scripts/roll-to-devtools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
Loading

0 comments on commit 75ecb57

Please sign in to comment.