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

devtools: import html generator code #7421

Merged
merged 13 commits into from
Mar 15, 2019
19 changes: 19 additions & 0 deletions build/dt-report-generator-bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @license Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';

const browserify = require('browserify');
brendankenny marked this conversation as resolved.
Show resolved Hide resolved
const fs = require('fs');

const distDir = __dirname + '/../dist';
const outFile = `${distDir}/report-generator.js`;
const generatorFilename = `./lighthouse-core/report/report-generator.js`;
browserify(generatorFilename, {standalone: 'ReportGenerator'})
.transform('brfs')
.bundle((err, src) => {
if (err) throw err;
fs.writeFileSync(outFile, src.toString());
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sweet, I think this might help @exterkamp as well. At least I think he was looking for a standalone report generator?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! He can just remove the dt- bit then, that'd be a great PR @exterkamp :)

4 changes: 4 additions & 0 deletions lighthouse-core/report/report-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
const htmlReportAssets = require('./html/html-report-assets');

class ReportGenerator {
static getAssets() {
return htmlReportAssets;
}

/**
* Replaces all the specified strings in source without serial replacements.
* @param {string} source
Expand Down
5 changes: 4 additions & 1 deletion lighthouse-core/scripts/roll-to-devtools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ lh_bg_js="dist/lighthouse-dt-bundle.js"
lh_worker_dir="$frontend_dir/audits2_worker/lighthouse"

# copy report files
cp -pPR $report_dir/{report-styles.css,templates.html,renderer} "$fe_lh_dir"
cp -pPR $report_dir/renderer "$fe_lh_dir"
echo -e "\033[32m ✓\033[39m Report renderer files copied."

# copy lighthouse-dt-bundle (potentially stale)
cp -pPR "$lh_bg_js" "$lh_worker_dir/lighthouse-dt-bundle.js"
echo -e "\033[96m ✓\033[39m (Potentially stale) lighthouse-dt-bundle copied."

# copy report generator
cp dist/report-generator.js $fe_lh_dir
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"build-all:task": "yarn build-extension & yarn build-devtools & yarn build-lr & yarn build-viewer & wait",
"build-all:task:windows": "yarn build-extension && yarn build-devtools && yarn build-lr && yarn build-viewer",
"build-extension": "node ./build/build-extension.js",
"build-devtools": "node ./build/build-bundle.js clients/devtools-entry.js dist/lighthouse-dt-bundle.js",
"build-devtools": "node ./build/build-bundle.js clients/devtools-entry.js dist/lighthouse-dt-bundle.js && node ./build/dt-report-generator-bundle.js",
"build-lr": "node ./build/build-bundle.js clients/lightrider-entry.js dist/lighthouse-lr-bundle.js",
"build-viewer": "node ./build/build-viewer.js",
"clean": "rimraf dist proto/scripts/*.json proto/scripts/*_pb2.* proto/scripts/*_pb.* proto/scripts/__pycache__ proto/scripts/*.pyc *.report.html *.report.dom.html *.report.json *.devtoolslog.json *.trace.json || true",
Expand Down