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

README: Reorganization and new "Using programmatically" section #1721

Merged
merged 4 commits into from
Feb 15, 2017
Merged

Conversation

ebidel
Copy link
Contributor

@ebidel ebidel commented Feb 14, 2017

R: all

Also fixes #1719.

The example is extracted and simplified from lighthouse hue lights thing I made. Happy to rework it a little, but it's pretty chill and is known to be everything you need to call LH programmatically.

@ebidel ebidel changed the title README: reorganize and add programmatic section README: Reorganization and new "Using programmatically" section Feb 14, 2017
readme.md Outdated

The traceviewer-based trace processor from [node-big-rig](https://github.com/GoogleChrome/node-big-rig/tree/master/lib) was forked into Lighthouse. Additionally, the [DevTools' Timeline Model](https://github.com/paulirish/devtools-timeline-model) is available as well. There may be advantages for using one model over another.

### Trace processing

**To update traceviewer source:**
Copy link
Member

Choose a reason for hiding this comment

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

this is dev instructions for us, and belongs in the contributing.md

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

readme.md Outdated
DevTools](https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27#.59rma3ukm)
for more info.

## Coding Style
Copy link
Member

Choose a reason for hiding this comment

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

move to contributing.md

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

readme.md Outdated

# The CLI is authored in TypeScript and requires compilation.
# If you need to make changes to the CLI, run the TS compiler in watch mode:
# cd lighthouse-cli && npm run dev
Copy link
Member

Choose a reason for hiding this comment

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

link to contributing and architecture somewhere around here?

Copy link
Member

Choose a reason for hiding this comment

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

and can you link to architecture doc from contributing.md?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

readme.md Outdated

### Are results sent to a remote server?

Hope. Lighthouse runs locally, auditing a page using a local version of the Chrome browser installed the
Copy link
Member

Choose a reason for hiding this comment

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

Hope 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ha

readme.md Outdated
<p align="center">
<img src="https://cloud.githubusercontent.com/assets/39191/22478294/23f662f6-e79e-11e6-8de3-ffd7be7bf628.png" alt="Lighthouse logo" height="300">
<img src="https://cloud.githubusercontent.com/assets/39191/22478294/23f662f6-e79e-11e6-8de3-ffd7be7bf628.png" alt="Lighthouse logo" height="150">
<br>
<b>Lighthouse</b>, ˈlītˌhous (n): a <s>tower or other structure</s> tool containing a beacon light to warn or guide <s>ships</s> developers at "sea".
Copy link
Member

Choose a reason for hiding this comment

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

ships at sea developers.

IMO slightly better. if you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,60 @@
# Architecture
Copy link
Member

Choose a reason for hiding this comment

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

IMO this file can get merged with API-and-internals.md

and since readme and contributing are in root, i kinda prefer keeping this md file there rather than docs/. wdyt?

Copy link
Contributor Author

@ebidel ebidel Feb 14, 2017

Choose a reason for hiding this comment

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

Up to you. I figured we'd have more in the future and wanted to declutter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved and renamed that file to "headless-chrome.md". It didn't contain anything but headless Chrome stuff :)

Copy link
Member

Choose a reason for hiding this comment

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

sg

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

nice it was due for some cleanup!

## Components

* **Driver** - Interfaces with [Chrome Debugging Protocol](https://developer.chrome.com/devtools/docs/debugger-protocol) ([API viewer](https://chromedevtools.github.io/debugger-protocol-viewer/))
* **Gathers** - Requesting data from the browser (and maybe post-processing)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Gatherers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

* **Artifacts** - The output of gatherers
* **Audits** - Non-performance evaluations of capabilities and issues. Includes a raw value and score of that value.
* **Metrics** - Performance metrics summarizing the UX
* **Diagnoses** - The perf problems that affect those metrics
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this still a thing that we call Diagnoses?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

readme.md Outdated

Some basic unit tests forked are in `/test` and run via mocha. ESLint also checks for style violations.
The example below shows how to setup and run Lighthouse programmatically as a Node module.
Copy link
Collaborator

Choose a reason for hiding this comment

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

How important is supporting use as a node module to us? If we think it's important, any issues to make basic usage easier than 80 lines? If not, maybe let's move this to separate file and link to it from README.

Personally, I'd love to see chrome launcher published to NPM separately with a slightly friendlier interface (happy to take this up if there's agreement), and a more organized programmatic API that doesn't involve so much digging into our directory tree (more resilient to doing our rename of lighthouse-cli -> cli etc

Copy link
Contributor Author

@ebidel ebidel Feb 14, 2017

Choose a reason for hiding this comment

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

Open sourcing a more convenient launcher would be great. That's really the bulk of the example, and something I struggled to get working for my demo.

When looking into a lib, I do really like seeing install + different usages in the main readme. Since a lot of people ask for docs on this, I'd love to keep it front and center. Ironically, an email thread from Addy prompted me to add this to our radme...which then led to a full reorg :)

Happy to move it out though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

When looking into a lib, I do really like seeing install + different usages in the main readme.

Totally agree, I just also would find it off-putting if the usage example was so complicated :) I say let's leave it here, and I'll file issue to improve the API.

@ebidel
Copy link
Contributor Author

ebidel commented Feb 14, 2017

PTAL

readme.md Outdated
const PERF_CONFIG = require('lighthouse/lighthouse-core/config/perf.json');
// const DEFAULT_CONFIG = require('lighthouse/lighthouse-core/config/default.json');

const _SIGINT = 'SIGINT';
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this seem like overkill? Handling command line args and SIGINT seems out of scope for a readme example

readme.md Outdated
}

// Example of extracting the overall score from the results.
getOverallScore(results) {
Copy link
Member

Choose a reason for hiding this comment

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

Ha, seems like we should already be including this in the lighthouse results

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, but I don't think it hurts to show an "Example of extracting" things from our crazy config object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

kept, but moved it as a separate function example

Copy link
Member

Choose a reason for hiding this comment

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

ha, sorry, I meant it's ridiculous that the results object don't currently include the overall score and that it has to be extracted :) Somehow I hadn't noticed that in all this time. We should add it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha. I was surprised too. But I guess we've also never come across it. We have the notion of scores for each aggregation, but only have 1 that's scored atm.

readme.md Outdated
}
}

const flags = yargs
Copy link
Member

Choose a reason for hiding this comment

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

yargs especially seems like it could be cut. 9 times out of 10 it seems like people will be calling lighthouse within an existing script or with hardcoded values

Copy link
Member

Choose a reason for hiding this comment

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

+1 to this.

you can see https://github.com/paulirish/pwmetrics/blob/27ee73fd1c9c8ed5457eebafb245b1592ac26a38/lib/index.js#L64-L90 which is how we adopt LH in pwmetrics. it's pretty small.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@ebidel
Copy link
Contributor Author

ebidel commented Feb 15, 2017

Removed the extras from the example

@paulirish
Copy link
Member

Yeah this small example is clutch. Nice!

@ebidel
Copy link
Contributor Author

ebidel commented Feb 15, 2017

@patrickhulce how does this look?

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

great improvements!

@ebidel ebidel merged commit c0d7ebf into master Feb 15, 2017
@ebidel ebidel deleted the readme branch February 15, 2017 18:21
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.

README: add note that testing and results are done locally (no remote servers)
4 participants