@jsenv/lighthouse-impact 2.1.11 → 2.2.0
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 +6 -3
- package/package.json +1 -1
- package/src/reportLighthouseImpact.js +8 -5
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ _index.html_
|
|
|
69
69
|
</html>
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
At this stage, you could generate a lighthouse report on your machine.
|
|
72
|
+
At this stage, you could generate a lighthouse report on your machine.
|
|
73
73
|
|
|
74
74
|
Now it's time to configure a workflow to compare lighthouse reports before and after merging a pull request.
|
|
75
75
|
|
|
@@ -125,7 +125,10 @@ import {
|
|
|
125
125
|
|
|
126
126
|
await reportLighthouseImpact({
|
|
127
127
|
...readGitHubWorkflowEnv(),
|
|
128
|
-
lighthouseReportPath:
|
|
128
|
+
lighthouseReportPath: new URL(
|
|
129
|
+
"./lighthouse.mjs#lighthouseReport",
|
|
130
|
+
import.meta.url,
|
|
131
|
+
),
|
|
129
132
|
})
|
|
130
133
|
```
|
|
131
134
|
|
|
@@ -186,7 +189,7 @@ The pull request comment can contain links to see lighthouse reports in [Lightho
|
|
|
186
189
|
To unlock this you need a GitHub token with the right to create gists.
|
|
187
190
|
Every github workflow has access to a magic token `secrets.GITHUB_TOKEN`.
|
|
188
191
|
But this token is not allowed to create gists.
|
|
189
|
-
We need to update the worflow file
|
|
192
|
+
We need to update the worflow file to use an other token that will have the rights to create gists.
|
|
190
193
|
|
|
191
194
|
```diff
|
|
192
195
|
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assertAndNormalizeDirectoryUrl
|
|
1
|
+
import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem"
|
|
2
2
|
import { commentGitHubPullRequestImpact } from "@jsenv/github-pull-request-impact"
|
|
3
3
|
import { importOneExportFromFile } from "@jsenv/dynamic-import-worker"
|
|
4
4
|
|
|
@@ -24,13 +24,16 @@ export const reportLighthouseImpact = async ({
|
|
|
24
24
|
skipGistWarning = false,
|
|
25
25
|
}) => {
|
|
26
26
|
rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl)
|
|
27
|
-
|
|
27
|
+
let lighthouseReportUrl
|
|
28
|
+
if (lighthouseReportPath === "string") {
|
|
29
|
+
lighthouseReportUrl = new URL(lighthouseReportPath, rootDirectoryUrl).href
|
|
30
|
+
} else if (lighthouseReportPath instanceof URL) {
|
|
31
|
+
lighthouseReportUrl = lighthouseReportPath.href
|
|
32
|
+
} else {
|
|
28
33
|
throw new TypeError(
|
|
29
|
-
`lighthouseReportPath must be a string but received ${lighthouseReportPath}`,
|
|
34
|
+
`lighthouseReportPath must be a string or an url but received ${lighthouseReportPath}`,
|
|
30
35
|
)
|
|
31
36
|
}
|
|
32
|
-
rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl)
|
|
33
|
-
const lighthouseReportUrl = resolveUrl(lighthouseReportPath, rootDirectoryUrl)
|
|
34
37
|
|
|
35
38
|
return commentGitHubPullRequestImpact({
|
|
36
39
|
logLevel,
|