Skip to content

Commit fadd305

Browse files
authored
Merge pull request #4 from netlify-labs/refactor/use_puppeteer_chrome
Refactor: use puppeteer chrome
2 parents f35367f + 9350ad6 commit fadd305

File tree

18 files changed

+3845
-2730
lines changed

18 files changed

+3845
-2730
lines changed

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Url to audit
2+
AUDIT_URL=https://www.example.com
3+
# Ignored when AUDIT_URL is configured
4+
PUBLISH_DIR=FULL_PATH_TO_LOCAL_BUILD_DIRECTORY
5+
# JSON string of thresholds to enforce
6+
THRESHOLDS={"performance":0.9,"accessibility":0.9,"best-practices":0.9,"seo":0.9,"pwa":0.9}

.eslintrc.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
env: {
3+
commonjs: true,
4+
es6: true,
5+
node: true,
6+
},
7+
extends: 'eslint:recommended',
8+
globals: {
9+
Atomics: 'readonly',
10+
SharedArrayBuffer: 'readonly',
11+
},
12+
parserOptions: {
13+
ecmaVersion: 11,
14+
},
15+
};

.github/workflows/test.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Node CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- '*'
9+
10+
pull_request:
11+
types: [opened, synchronize, reopened]
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
node-version: [12.x]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Use Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v1
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
- name: Get yarn cache directory path
27+
id: yarn-cache-dir-path
28+
run: echo "::set-output name=dir::$(yarn cache dir)"
29+
- uses: actions/cache@v2
30+
with:
31+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
32+
key: ${{ runner.os }}-yarn-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
33+
restore-keys: |
34+
${{ runner.os }}-yarn-
35+
- name: log versions
36+
run: node --version && npm --version && yarn --version
37+
- name: install dependencies
38+
run: yarn --frozen-lockfile
39+
- name: run linter
40+
run: yarn lint
41+
- name: check formatting
42+
run: yarn format:ci

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.env
3+
.vscode

.prettierrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"semi": true,
5+
"singleQuote": true,
6+
"trailingComma": "all",
7+
"useTabs": false,
8+
"overrides": [
9+
{
10+
"files": "*.json",
11+
"options": { "printWidth": 200 }
12+
}
13+
]
14+
}

CONTRIBUTING.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
## Contributing
1+
# Contributing
22

3-
First fork this project.
3+
First fork this project
44

5-
* git clone <your-forked-repo>
6-
* npm install
5+
```bash
6+
git clone <your-forked-repo>
7+
yarn install
8+
git checkout -b my-fix
9+
```
710

8-
* git checkout -b my-fix
11+
Then fix some code and
912

10-
#### fix some code...
13+
```bash
14+
git commit -m "added this feature"
15+
git push origin my-fix
16+
```
1117

12-
* git commit -m "added this feature"
13-
* git push origin my-fix
14-
15-
Lastly, open a pull request on Github.
18+
Lastly, open a pull request on Github.

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Copyright (c) 2019-2020 Netlify <[email protected]>
2+
3+
MIT License
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
"Software"), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
1-
## Netlify Plugin Lighthouse
1+
# Netlify Plugin Lighthouse
22

3-
this does a basic lighthouse run and reports and stores the results. if it there has been a previous run, it also diffs
4-
the results to report improvements.
5-
6-
This shows the diffs:
7-
8-
![image](https://user-images.githubusercontent.com/6764957/62481118-8749c880-b77f-11e9-91d9-44ae028c452b.png)
3+
A Netlify plugin to generate a lighthouse report for every deploy
94

105
## Usage
116

12-
Inside your `netlify.yml`:
7+
This plugin can be included via npm. Install it as a dependency with the following command:
138

14-
```yaml
15-
plugins:
16-
- type: '@netlify/plugin-lighthouse'
17-
config:
18-
currentVersion: '0.0.3'
19-
compareWithVersion: '0.0.1'
9+
```bash
10+
npm install --save "@netlify/plugin-lighthouse"
2011
```
2112

22-
you can pin lighthouse result versions:
23-
24-
```yaml
25-
plugins:
26-
- type: '@netlify/plugin-lighthouse'
27-
config:
28-
currentVersion: '0.0.3'
29-
compareWithVersion: '0.0.1'
13+
To use a build plugin, create a `plugins` in your `netlify.toml` like so:
14+
15+
```toml
16+
[[plugins]]
17+
package = "@netlify/plugin-lighthouse"
18+
[plugins.inputs]
19+
# optional, defaults to scanning the current built version of the site
20+
audit_url = 'https://www.my-custom-site.com'
21+
# optional, fails build when a category is below a threshold
22+
[plugins.inputs.thresholds]
23+
performance = 0.9
24+
accessibility = 0.9
25+
best-practices = 0.9
26+
seo = 0.9
27+
pwa = 0.9
3028
```
3129

32-
## TODO
33-
34-
https://github.com/netlify/build/issues/27
30+
Run `netlify build` locally to check that the plugin works

commitlint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { extends: ['@commitlint/config-conventional'] };

example/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Empty Site</title>
6+
</head>
7+
<body>
8+
Empty Site
9+
</body>
10+
</html>

0 commit comments

Comments
 (0)