@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 CHANGED
@@ -125,7 +125,7 @@ import {
125
125
 
126
126
  await reportLighthouseImpact({
127
127
  ...readGitHubWorkflowEnv(),
128
- lighthouseReportPath: new URL(
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
- lighthouseReportPath: "./lighthouse.mjs#lighthouseReport",
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": "2.2.0",
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
- "eslint": "npx eslint . --ext=.js,.mjs",
37
- "snapshot": "node ./test/comment/generate_comment_snapshot_file.mjs",
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.1.2",
44
- "@jsenv/dynamic-import-worker": "1.0.1",
45
- "@jsenv/filesystem": "3.1.0",
46
- "@jsenv/github-pull-request-impact": "1.6.11",
47
- "@jsenv/logger": "4.0.1",
48
- "chrome-launcher": "0.15.0",
49
- "lighthouse": "9.2.0"
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
- jsonFile = false,
37
- jsonFileRelativeUrl = "./lighthouse/lighthouse_report.json",
30
+ jsonFileUrl,
38
31
  jsonFileLog = true,
39
- htmlFile = false,
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 (jsonFile) {
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 (htmlFile) {
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) {
@@ -1,5 +1,5 @@
1
1
  import * as githubRESTAPI from "@jsenv/github-pull-request-impact/src/internal/github_rest_api.js"
2
- import { createDetailedMessage } from "@jsenv/logger"
2
+ import { createDetailedMessage } from "@jsenv/log"
3
3
 
4
4
  // https://developer.github.com/v3/gists/#create-a-gist
5
5
 
package/src/main.js ADDED
@@ -0,0 +1,4 @@
1
+ export { readGitHubWorkflowEnv } from "@jsenv/github-pull-request-impact"
2
+
3
+ export { generateLighthouseReport } from "./generateLighthouseReport.js"
4
+ export { reportLighthouseImpact } from "./reportLighthouseImpact.js"
@@ -16,7 +16,7 @@ export const reportLighthouseImpact = async ({
16
16
  repositoryName,
17
17
  pullRequestNumber,
18
18
  installCommand = "npm install",
19
- lighthouseReportPath,
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
- let lighthouseReportUrl
28
- if (lighthouseReportPath === "string") {
29
- lighthouseReportUrl = new URL(lighthouseReportPath, rootDirectoryUrl).href
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
- `lighthouseReportPath must be a string or an url but received ${lighthouseReportPath}`,
32
+ `lighthouseReportUrl must be a string or an url but received ${lighthouseReportUrl}`,
35
33
  )
36
34
  }
37
35
 
package/main.js DELETED
@@ -1,4 +0,0 @@
1
- export { generateLighthouseReport } from "./src/generateLighthouseReport.js"
2
-
3
- export { readGitHubWorkflowEnv } from "@jsenv/github-pull-request-impact"
4
- export { reportLighthouseImpact } from "./src/reportLighthouseImpact.js"