@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 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. For an example, see [package.json#L37](./package.json#L37) and [script/lighthouse/lighthouse.mjs#L19](./script/lighthouse/lighthouse.mjs#L19).
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: "./lighthouse.mjs#lighthouseReport",
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 like [lighthouse-score-impact.yml#L21](./.github/workflows/lighthouse_impact.yml#L21) to use an other token that will have the rights to create gists.
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/lighthouse-impact",
3
- "version": "2.1.11",
3
+ "version": "2.2.0",
4
4
  "description": "Package description",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -1,4 +1,4 @@
1
- import { assertAndNormalizeDirectoryUrl, resolveUrl } from "@jsenv/filesystem"
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
- if (typeof lighthouseReportPath !== "string") {
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,