-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
misc(build): generate report variants in deployment #9280
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,14 @@ | |
/* eslint-disable no-console */ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const mkdirp = require('mkdirp').sync; | ||
const swapLocale = require('../lib/i18n/swap-locale.js'); | ||
|
||
const ReportGenerator = require('../../lighthouse-core/report/report-generator.js'); | ||
const lhr = /** @type {LH.Result} */ (require('../../lighthouse-core/test/results/sample_v2.json')); | ||
|
||
const DIST = path.join(__dirname, `../../dist`); | ||
|
||
// Add a plugin to demo plugin rendering. | ||
lhr.categories['lighthouse-plugin-someplugin'] = { | ||
id: 'lighthouse-plugin-someplugin', | ||
|
@@ -22,8 +26,26 @@ lhr.categories['lighthouse-plugin-someplugin'] = { | |
auditRefs: [], | ||
}; | ||
|
||
console.log('🕒 Generating report for sample_v2.json...'); | ||
const html = ReportGenerator.generateReport(lhr, 'html'); | ||
const filename = path.join(__dirname, '../../dist/index.html'); | ||
fs.writeFileSync(filename, html, {encoding: 'utf-8'}); | ||
console.log('✅', filename, 'written.'); | ||
(async function() { | ||
const filenameToLhr = { | ||
'english': lhr, | ||
'espanol': swapLocale(lhr, 'es').lhr, | ||
'arabic': swapLocale(lhr, 'ar').lhr, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup. definitely will. |
||
}; | ||
|
||
mkdirp(DIST); | ||
|
||
// Generate and write reports | ||
Object.entries(filenameToLhr).forEach(([filename, lhr]) => { | ||
let html = ReportGenerator.generateReportHtml(lhr); | ||
for (const variant of ['', '-devtools']) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the future, PSI will be another report variant. |
||
if (variant === '-devtools') { | ||
html = html.replace(`"lh-root lh-vars"`, `"lh-root lh-vars lh-devtools"`); | ||
} | ||
const filepath = `${DIST}/${filename}${variant}/index.html`; | ||
mkdirp(path.dirname(filepath)); | ||
fs.writeFileSync(filepath, html, {encoding: 'utf-8'}); | ||
console.log('✅', filepath, 'written.'); | ||
} | ||
}); | ||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,7 @@ | |
"chrome": "node lighthouse-core/scripts/manual-chrome-launcher.js", | ||
"fast": "yarn start --emulated-form-factor=none --throttlingMethod=provided", | ||
"deploy-viewer": "yarn build-viewer --deploy", | ||
"now-build": "node lighthouse-core/scripts/build-report-for-autodeployment.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. neat! |
||
"bundlesize": "bundlesize", | ||
"timing-trace": "node lighthouse-core/scripts/generate-timing-trace.js", | ||
"changelog": "conventional-changelog --config ./build/changelog-generator/index.js --infile changelog.md --same-file", | ||
|
@@ -122,7 +123,6 @@ | |
"isomorphic-fetch": "^2.2.1", | ||
"jest": "^24.3.0", | ||
"jsdom": "^12.2.0", | ||
"lodash.set": "^4.3.2", | ||
"make-dir": "^1.3.0", | ||
"npm-run-posix-or-windows": "^2.0.2", | ||
"nyc": "^13.3.0", | ||
|
@@ -152,6 +152,7 @@ | |
"jsonlint-mod": "^1.7.4", | ||
"lighthouse-logger": "^1.2.0", | ||
"lodash.isequal": "^4.5.0", | ||
"lodash.set": "^4.3.2", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bundlephobia says this is 2KB minified+gzipped, so basically a nonfactor for folks already invoking |
||
"lookup-closest-locale": "6.0.4", | ||
"metaviewport-parser": "0.2.0", | ||
"mkdirp": "0.5.1", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mostly unrelated. just a driveby.