@jsenv/lighthouse-impact 2.2.0 → 3.0.1
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 +2 -2
- package/package.json +15 -20
- package/src/generateLighthouseReport.js +8 -20
- package/src/internal/patchOrPostGists.js +1 -1
- package/src/main.js +4 -0
- package/src/reportLighthouseImpact.js +5 -7
- package/main.js +0 -4
package/README.md
CHANGED
|
@@ -125,7 +125,7 @@ import {
|
|
|
125
125
|
|
|
126
126
|
await reportLighthouseImpact({
|
|
127
127
|
...readGitHubWorkflowEnv(),
|
|
128
|
-
|
|
128
|
+
lighthouseReportUrl: new URL(
|
|
129
129
|
"./lighthouse.mjs#lighthouseReport",
|
|
130
130
|
import.meta.url,
|
|
131
131
|
),
|
|
@@ -170,7 +170,7 @@ reportLighthouseImpact({
|
|
|
170
170
|
+ repositoryName: process.env.TRAVIS_REPO_SLUG.split("/")[1],
|
|
171
171
|
+ pullRequestNumber: process.env.TRAVIS_PULL_REQUEST,
|
|
172
172
|
+ githubToken: process.env.GITHUB_TOKEN, // see next step
|
|
173
|
-
|
|
173
|
+
lighthouseReportUrl: "./lighthouse.mjs#lighthouseReport",
|
|
174
174
|
})
|
|
175
175
|
```
|
|
176
176
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/lighthouse-impact",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Package description",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -17,35 +17,30 @@
|
|
|
17
17
|
"node": ">=16.13.0"
|
|
18
18
|
},
|
|
19
19
|
"publishConfig": {
|
|
20
|
-
"access": "public"
|
|
21
|
-
"registry": "https://registry.npmjs.org"
|
|
20
|
+
"access": "public"
|
|
22
21
|
},
|
|
23
22
|
"type": "module",
|
|
24
23
|
"exports": {
|
|
25
24
|
".": {
|
|
26
|
-
"import": "./main.js"
|
|
25
|
+
"import": "./src/main.js"
|
|
27
26
|
},
|
|
28
27
|
"./*": "./*"
|
|
29
28
|
},
|
|
30
|
-
"main": "./main.js",
|
|
29
|
+
"main": "./src/main.js",
|
|
31
30
|
"files": [
|
|
32
|
-
"/src/"
|
|
33
|
-
"/main.js"
|
|
31
|
+
"/src/"
|
|
34
32
|
],
|
|
35
33
|
"scripts": {
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"test": "node ./script/test/test.mjs",
|
|
39
|
-
"test-with-coverage": "npm run test -- --coverage",
|
|
40
|
-
"prettier": "prettier --write ."
|
|
34
|
+
"snapshot": "node ./tests/comment/generate_comment_snapshot_file.mjs",
|
|
35
|
+
"test": "node ./scripts/test.mjs"
|
|
41
36
|
},
|
|
42
37
|
"dependencies": {
|
|
43
|
-
"@jsenv/abort": "4.
|
|
44
|
-
"@jsenv/dynamic-import-worker": "1.0
|
|
45
|
-
"@jsenv/filesystem": "
|
|
46
|
-
"@jsenv/github-pull-request-impact": "1.
|
|
47
|
-
"@jsenv/
|
|
48
|
-
"chrome-launcher": "0.15.
|
|
49
|
-
"lighthouse": "9.
|
|
38
|
+
"@jsenv/abort": "4.2.4",
|
|
39
|
+
"@jsenv/dynamic-import-worker": "1.1.0",
|
|
40
|
+
"@jsenv/filesystem": "4.1.5",
|
|
41
|
+
"@jsenv/github-pull-request-impact": "1.7.0",
|
|
42
|
+
"@jsenv/log": "3.3.1",
|
|
43
|
+
"chrome-launcher": "0.15.1",
|
|
44
|
+
"lighthouse": "9.6.7"
|
|
50
45
|
}
|
|
51
|
-
}
|
|
46
|
+
}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
// https://github.com/GoogleChrome/lighthouse/blob/5a14deb5c4e0ec4e8e58f50ff72b53851b021bcf/docs/readme.md#using-programmatically
|
|
2
2
|
|
|
3
3
|
import { createRequire } from "node:module"
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
writeFile,
|
|
7
|
-
resolveUrl,
|
|
8
|
-
assertAndNormalizeDirectoryUrl,
|
|
9
|
-
} from "@jsenv/filesystem"
|
|
10
|
-
import { createLogger } from "@jsenv/logger"
|
|
4
|
+
import { writeFile, assertAndNormalizeFileUrl } from "@jsenv/filesystem"
|
|
5
|
+
import { createLogger } from "@jsenv/log"
|
|
11
6
|
import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
|
|
12
7
|
|
|
13
8
|
import { formatLighthouseReportForLog } from "./internal/formatLighthouseReportForLog.js"
|
|
@@ -31,13 +26,10 @@ export const generateLighthouseReport = async (
|
|
|
31
26
|
runCount = 1,
|
|
32
27
|
delayBetweenEachRunInSeconds = 1,
|
|
33
28
|
|
|
34
|
-
rootDirectoryUrl, // required only when jsonFile or htmlFile is passed
|
|
35
29
|
log = false,
|
|
36
|
-
|
|
37
|
-
jsonFileRelativeUrl = "./lighthouse/lighthouse_report.json",
|
|
30
|
+
jsonFileUrl,
|
|
38
31
|
jsonFileLog = true,
|
|
39
|
-
|
|
40
|
-
htmlFileRelativeUrl = "./lighthouse/lighthouse_report.html",
|
|
32
|
+
htmlFileUrl,
|
|
41
33
|
htmlFileLog = true,
|
|
42
34
|
} = {},
|
|
43
35
|
) => {
|
|
@@ -117,15 +109,11 @@ export const generateLighthouseReport = async (
|
|
|
117
109
|
|
|
118
110
|
await chrome.kill()
|
|
119
111
|
|
|
120
|
-
if (jsonFile || htmlFile) {
|
|
121
|
-
rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
112
|
const promises = []
|
|
125
|
-
if (
|
|
113
|
+
if (jsonFileUrl) {
|
|
114
|
+
assertAndNormalizeFileUrl(jsonFileUrl)
|
|
126
115
|
promises.push(
|
|
127
116
|
(async () => {
|
|
128
|
-
const jsonFileUrl = resolveUrl(jsonFileRelativeUrl, rootDirectoryUrl)
|
|
129
117
|
const json = JSON.stringify(lighthouseReport, null, " ")
|
|
130
118
|
await writeFile(jsonFileUrl, json)
|
|
131
119
|
if (jsonFileLog) {
|
|
@@ -134,10 +122,10 @@ export const generateLighthouseReport = async (
|
|
|
134
122
|
})(),
|
|
135
123
|
)
|
|
136
124
|
}
|
|
137
|
-
if (
|
|
125
|
+
if (htmlFileUrl) {
|
|
126
|
+
assertAndNormalizeFileUrl(htmlFileUrl)
|
|
138
127
|
promises.push(
|
|
139
128
|
(async () => {
|
|
140
|
-
const htmlFileUrl = resolveUrl(htmlFileRelativeUrl, rootDirectoryUrl)
|
|
141
129
|
const html = ReportGenerator.generateReportHtml(lighthouseReport)
|
|
142
130
|
await writeFile(htmlFileUrl, html)
|
|
143
131
|
if (htmlFileLog) {
|
package/src/main.js
ADDED
|
@@ -16,7 +16,7 @@ export const reportLighthouseImpact = async ({
|
|
|
16
16
|
repositoryName,
|
|
17
17
|
pullRequestNumber,
|
|
18
18
|
installCommand = "npm install",
|
|
19
|
-
|
|
19
|
+
lighthouseReportUrl,
|
|
20
20
|
|
|
21
21
|
runLink,
|
|
22
22
|
commitInGeneratedByInfo,
|
|
@@ -24,14 +24,12 @@ export const reportLighthouseImpact = async ({
|
|
|
24
24
|
skipGistWarning = false,
|
|
25
25
|
}) => {
|
|
26
26
|
rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} else if (lighthouseReportPath instanceof URL) {
|
|
31
|
-
lighthouseReportUrl = lighthouseReportPath.href
|
|
27
|
+
if (lighthouseReportUrl === "string") {
|
|
28
|
+
lighthouseReportUrl = new URL(lighthouseReportUrl, rootDirectoryUrl).href
|
|
29
|
+
} else if (lighthouseReportUrl instanceof URL) {
|
|
32
30
|
} else {
|
|
33
31
|
throw new TypeError(
|
|
34
|
-
`
|
|
32
|
+
`lighthouseReportUrl must be a string or an url but received ${lighthouseReportUrl}`,
|
|
35
33
|
)
|
|
36
34
|
}
|
|
37
35
|
|
package/main.js
DELETED