@jsenv/lighthouse-impact 4.0.2 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -112,7 +112,7 @@ _.github/workflows/lighthouse_impact.yml_
|
|
|
112
112
|
|
|
113
113
|
name: lighthouse impact
|
|
114
114
|
|
|
115
|
-
on:
|
|
115
|
+
on: pull_request
|
|
116
116
|
|
|
117
117
|
jobs:
|
|
118
118
|
lighthouse_impact:
|
|
@@ -120,11 +120,11 @@ jobs:
|
|
|
120
120
|
name: lighthouse impact
|
|
121
121
|
steps:
|
|
122
122
|
- name: Setup git
|
|
123
|
-
uses: actions/checkout@
|
|
123
|
+
uses: actions/checkout@v3
|
|
124
124
|
- name: Setup node
|
|
125
|
-
uses: actions/setup-node@
|
|
125
|
+
uses: actions/setup-node@v3
|
|
126
126
|
with:
|
|
127
|
-
node-version: "
|
|
127
|
+
node-version: "18.3.0"
|
|
128
128
|
- name: Install node modules
|
|
129
129
|
run: npm install
|
|
130
130
|
- name: Report lighthouse impact
|
|
@@ -138,7 +138,7 @@ _report_lighthouse_impact.mjs_
|
|
|
138
138
|
* This file is executed by lighthouse_impact.yml GitHub workflow.
|
|
139
139
|
* - it generates lighthouse report before and after merging a pull request
|
|
140
140
|
* - Then, it creates or updates a comment in the pull request
|
|
141
|
-
* See https://github.com/jsenv/workflow/tree/main/packages/
|
|
141
|
+
* See https://github.com/jsenv/workflow/tree/main/packages/performance-impact
|
|
142
142
|
*/
|
|
143
143
|
|
|
144
144
|
import {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/lighthouse-impact",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Package description",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
13
|
"url": "https://github.com/jsenv/workflow",
|
|
14
|
-
"directory": "packages/
|
|
14
|
+
"directory": "packages/lighthouse-impact"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
17
|
"node": ">=16.13.0"
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@jsenv/abort": "4.2.4",
|
|
39
39
|
"@jsenv/dynamic-import-worker": "1.1.0",
|
|
40
|
-
"@jsenv/filesystem": "4.
|
|
41
|
-
"@jsenv/github-pull-request-impact": "1.7.
|
|
42
|
-
"@jsenv/log": "3.3.
|
|
43
|
-
"lighthouse": "
|
|
40
|
+
"@jsenv/filesystem": "4.2.3",
|
|
41
|
+
"@jsenv/github-pull-request-impact": "1.7.2",
|
|
42
|
+
"@jsenv/log": "3.3.4",
|
|
43
|
+
"lighthouse": "10.2.0"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -110,7 +110,7 @@ export const generateLighthouseReport = async (
|
|
|
110
110
|
throw e
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
const lighthouseReport = reduceToMedianReport(reports)
|
|
113
|
+
const lighthouseReport = await reduceToMedianReport(reports)
|
|
114
114
|
if (log) {
|
|
115
115
|
logger.info(formatReportAsSummaryText(lighthouseReport))
|
|
116
116
|
}
|
|
@@ -124,7 +124,7 @@ export const generateLighthouseReport = async (
|
|
|
124
124
|
}
|
|
125
125
|
if (htmlFileUrl) {
|
|
126
126
|
assertAndNormalizeFileUrl(htmlFileUrl)
|
|
127
|
-
const html = formatReportAsHtml(lighthouseReport)
|
|
127
|
+
const html = await formatReportAsHtml(lighthouseReport)
|
|
128
128
|
writeFileSync(htmlFileUrl, html)
|
|
129
129
|
if (htmlFileLog) {
|
|
130
130
|
logger.info(`-> ${htmlFileUrl}`)
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { createRequire } from "node:module"
|
|
2
|
-
|
|
3
|
-
const require = createRequire(import.meta.url)
|
|
4
|
-
|
|
5
1
|
export const runLighthouse = async (url, lighthouseOptions) => {
|
|
6
|
-
const lighthouse =
|
|
2
|
+
const { default: lighthouse } = await import("lighthouse")
|
|
7
3
|
const results = await lighthouse(url, undefined, lighthouseOptions)
|
|
8
4
|
// use results.lhr for the JS-consumeable output
|
|
9
5
|
// https://github.com/GoogleChrome/lighthouse/blob/master/types/lhr.d.ts
|
|
@@ -19,10 +15,8 @@ export const runLighthouse = async (url, lighthouseOptions) => {
|
|
|
19
15
|
return lhr
|
|
20
16
|
}
|
|
21
17
|
|
|
22
|
-
export const reduceToMedianReport = (lighthouseReports) => {
|
|
23
|
-
const {
|
|
24
|
-
computeMedianRun,
|
|
25
|
-
} = require("lighthouse/lighthouse-core/lib/median-run.js")
|
|
18
|
+
export const reduceToMedianReport = async (lighthouseReports) => {
|
|
19
|
+
const { computeMedianRun } = await import("lighthouse/core/lib/median-run.js")
|
|
26
20
|
return computeMedianRun(lighthouseReports)
|
|
27
21
|
}
|
|
28
22
|
|
|
@@ -39,8 +33,10 @@ export const formatReportAsJson = (lighthouseReport) => {
|
|
|
39
33
|
return json
|
|
40
34
|
}
|
|
41
35
|
|
|
42
|
-
export const formatReportAsHtml = (lighthouseReport) => {
|
|
43
|
-
const ReportGenerator =
|
|
36
|
+
export const formatReportAsHtml = async (lighthouseReport) => {
|
|
37
|
+
const { ReportGenerator } = await import(
|
|
38
|
+
"lighthouse/report/generator/report-generator.js"
|
|
39
|
+
)
|
|
44
40
|
const html = ReportGenerator.generateReportHtml(lighthouseReport)
|
|
45
41
|
return html
|
|
46
42
|
}
|
|
@@ -109,7 +109,7 @@ export const reportLighthouseImpactInGithubPullRequest = async ({
|
|
|
109
109
|
}
|
|
110
110
|
},
|
|
111
111
|
generatedByLink: {
|
|
112
|
-
url: "https://github.com/jsenv/workflow/tree/main/packages/
|
|
112
|
+
url: "https://github.com/jsenv/workflow/tree/main/packages/lighthouse-impact",
|
|
113
113
|
text: "@jsenv/lighthouse-impact",
|
|
114
114
|
},
|
|
115
115
|
runLink,
|