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

core(runner): split lhr, artifacts return, respect output type #4999

Merged
merged 7 commits into from
Apr 23, 2018

Conversation

patrickhulce
Copy link
Collaborator

jumped on @brendankenny's suggestion to make {lhr, artifacts} and a breaking feature in the process (#4333), having node module respect the output=html setting

also I had a bug in config with default settings when undefined (mostly happens in tests, but could be user explicitly passing undefined) so fixing that was good 👍

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

probably easier to still have the report generated outside of runner so that the devtools bundle doesn't need it (arguably cleaner that way than pruning via browserify, otoh doing it the other way moves us closer to the various background scripts just using the node interface)

also the lighthouse-background side will currently be broken

@brendankenny
Copy link
Member

also, FWIW, "core(runner): respect output setting" is definitely not the most important change happening here :P

@patrickhulce
Copy link
Collaborator Author

also, FWIW, "core(runner): respect output setting" is definitely not the most important change happening here :P

what's the most important change?

probably easier to still have the report generated outside of runner so that the devtools bundle doesn't need it

I see, so against the feature existing or just proposing index.js?

@patrickhulce patrickhulce changed the title core(runner): respect output setting [WIP] core(runner): respect output setting Apr 19, 2018
@patrickhulce
Copy link
Collaborator Author

patrickhulce commented Apr 19, 2018

also the lighthouse-background side will currently be broken

yes this was meant to be proposal, added [PROPOSAL]

@patrickhulce patrickhulce changed the title [WIP] core(runner): respect output setting [PROPOSAL] core(runner): respect output setting Apr 19, 2018
@paulirish
Copy link
Member

One option: add browserify ignore for lib/format-output.. and always check if it's truth before using it. But I should look closer before jumping to a solution

@brendankenny
Copy link
Member

what's the most important change?

splitting up the return value from the module :)

I see, so against the feature existing or just proposing index.js?

oh, I think 👍 👍, just index.js or have to do something about the bundling

@patrickhulce patrickhulce changed the title [PROPOSAL] core(runner): respect output setting [PROPOSAL] core(runner): split lhr, artifacts return, respect output type Apr 19, 2018
Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

seems like you can add '../report/v2/report-generator' to browserify ignore, and we should be good.

and update the lh-bg files to request their intended output

@@ -46,10 +46,12 @@ function lighthouse(url, flags = {}, configJSON) {
// kick off a lighthouse run
return Runner.run(connection, {url, config})
.then((lighthouseResults = {}) => {
lighthouseResults.lhr = lighthouseResults.lhr || {};
Copy link
Member

Choose a reason for hiding this comment

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

rename to runnerResult

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

const artifacts = results.artifacts;
delete results.artifacts;
return saveResults(results, artifacts, flags).then(_ => results);
return saveResults(results, flags).then(_ => results);
Copy link
Member

Choose a reason for hiding this comment

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

rename results to runnerResult

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

* @param {!LH.Flags} flags
* @return {Promise<void>}
*/
function saveResults(results, artifacts, flags) {
function saveResults(results, flags) {
const {lhr, artifacts} = results;
Copy link
Member

Choose a reason for hiding this comment

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

rename results to runnerResult

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@@ -17,16 +17,15 @@ const fs = require('fs');
const path = require('path');
const URL = require('./lib/url-shim');
const Sentry = require('./lib/sentry');
const getFormattedReport = require('./lib/format-output').createOutput;
Copy link
Member

Choose a reason for hiding this comment

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

nearly all our source files are defined as nouns, so we should do lhr-formatter.js or something.

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

I'm +1 on the proposal.

@brendankenny
Copy link
Member

seems like you can add '../report/v2/report-generator' to browserify ignore, and we should be good.

extension needs it, though, it just (currently) uses it in lighthouse-ext-background.js, so would need to split on builds

@@ -0,0 +1,72 @@
/**
Copy link
Member

Choose a reason for hiding this comment

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

live under report/?

@patrickhulce patrickhulce changed the title [PROPOSAL] core(runner): split lhr, artifacts return, respect output type core(runner): split lhr, artifacts return, respect output type Apr 20, 2018
@patrickhulce
Copy link
Collaborator Author

aight folks ready for re-review!

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

implementation looks great! But bikeshedding...

  • do we want to refer to the final report string as the formattedReport instead of the generatedReport? That makes a certain amount of sense, but I'd like to get rid of the one we don't use because they sound very similar (e.g. if we use formattedReport, there shouldn't be a report-generator.js :)

  • one way of doing this would be to merge report-formatter.js and report-generator.js in this PR, a single file that makes reports, but kick out the fs.readFileSync() calls and reportJs/reportCss/reportTemplates getters to a different file that's just like html-report-assets.js or whatever and we can browserify.ignore() that file

/**
* Creates the results output in a format based on the `mode`.
* @param {LH.Result} lhr
* @param {string} outputMode
Copy link
Member

Choose a reason for hiding this comment

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

'html'|'csv'|'json'?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@patrickhulce
Copy link
Collaborator Author

do we want to refer to the final report string as the formattedReport instead of the generatedReport? That makes a certain amount of sense, but I'd like to get rid of the one we don't use because they sound very similar (e.g. if we use formattedReport, there shouldn't be a report-generator.js

resolved on .report 🎉

one way of doing this would be to merge report-formatter.js and report-generator.js in this PR, a single file that makes reports, but kick out the fs.readFileSync() calls and reportJs/reportCss/reportTemplates getters to a different file that's just like html-report-assets.js or whatever and we can browserify.ignore() that file

great idea, done! 👍

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

I love this

@patrickhulce patrickhulce merged commit 711ca6e into master Apr 23, 2018
@patrickhulce patrickhulce deleted the move_output_to_core branch April 23, 2018 23:55
@ebidel
Copy link
Contributor

ebidel commented Apr 24, 2018

It's a party.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants