@jsenv/lighthouse-impact 2.0.0 → 2.1.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
@@ -1,12 +1,4 @@
1
- # Lighthouse impact
2
-
3
- Report pull request impacts on lighthouse score.
4
-
5
- [![npm package](https://img.shields.io/npm/v/@jsenv/lighthouse-impact.svg?logo=npm&label=package)](https://www.npmjs.com/package/@jsenv/lighthouse-impact)
6
- [![github main](https://github.com/jsenv/lighthouse-impact/workflows/main/badge.svg)](https://github.com/jsenv/lighthouse-impact/actions?workflow=main)
7
- [![codecov coverage](https://codecov.io/gh/jsenv/lighthouse-impact/branch/main/graph/badge.svg)](https://codecov.io/gh/jsenv/lighthouse-impact)
8
-
9
- # Presentation
1
+ # Lighthouse impact [![npm package](https://img.shields.io/npm/v/@jsenv/lighthouse-impact.svg?logo=npm&label=package)](https://www.npmjs.com/package/@jsenv/lighthouse-impact) [![github main](https://github.com/jsenv/lighthouse-impact/workflows/main/badge.svg)](https://github.com/jsenv/lighthouse-impact/actions?workflow=main) [![codecov coverage](https://codecov.io/gh/jsenv/lighthouse-impact/branch/main/graph/badge.svg)](https://codecov.io/gh/jsenv/lighthouse-impact)
10
2
 
11
3
  `@jsenv/lighthouse-impact` analyses a pull request impact on lighthouse score. This analysis is posted in a comment of the pull request on GitHub.
12
4
 
package/main.js CHANGED
@@ -1,5 +1,4 @@
1
1
  export { generateLighthouseReport } from "./src/generateLighthouseReport.js"
2
- export { logLighthouseReport } from "./src/logLighthouseReport.js"
3
2
 
4
3
  export { readGitHubWorkflowEnv } from "@jsenv/github-pull-request-impact"
5
4
  export { reportLighthouseImpact } from "./src/reportLighthouseImpact.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/lighthouse-impact",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Package description",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -16,8 +16,7 @@
16
16
  "node": ">=14.17.0"
17
17
  },
18
18
  "publishConfig": {
19
- "access": "public",
20
- "registry": "https://registry.npmjs.org"
19
+ "access": "public"
21
20
  },
22
21
  "type": "module",
23
22
  "exports": {
@@ -16,6 +16,8 @@ import {
16
16
  assertAndNormalizeDirectoryUrl,
17
17
  } from "@jsenv/filesystem"
18
18
 
19
+ import { formatLighthouseReportForLog } from "./internal/formatLighthouseReportForLog.js"
20
+
19
21
  const require = createRequire(import.meta.url)
20
22
 
21
23
  export const generateLighthouseReport = async (
@@ -36,6 +38,7 @@ export const generateLighthouseReport = async (
36
38
  delayBetweenEachRunInSeconds = 1,
37
39
 
38
40
  projectDirectoryUrl, // required only when jsonFile or htmlFile is passed
41
+ log = false,
39
42
  jsonFile = false,
40
43
  jsonFileRelativeUrl = "./lighthouse/lighthouse_report.json",
41
44
  jsonFileLog = true,
@@ -111,6 +114,11 @@ export const generateLighthouseReport = async (
111
114
  }, Promise.resolve())
112
115
 
113
116
  const lighthouseReport = computeMedianRun(reports)
117
+
118
+ if (log) {
119
+ logger.info(formatLighthouseReportForLog(lighthouseReport))
120
+ }
121
+
114
122
  await chrome.kill()
115
123
 
116
124
  if (jsonFile || htmlFile) {
@@ -1,7 +1,7 @@
1
- export const logLighthouseReport = (lighthouseReport) => {
1
+ export const formatLighthouseReportForLog = (lighthouseReport) => {
2
2
  const scores = {}
3
3
  Object.keys(lighthouseReport.categories).forEach((name) => {
4
4
  scores[name] = lighthouseReport.categories[name].score
5
5
  })
6
- console.log(JSON.stringify(scores, null, " "))
6
+ return JSON.stringify(scores, null, " ")
7
7
  }