@jsenv/lighthouse-impact 2.1.2 → 2.1.3

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,4 +1,4 @@
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)
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)
2
2
 
3
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.
4
4
 
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/lighthouse-impact",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "Package description",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -10,7 +10,8 @@
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "https://github.com/jsenv/lighthouse-impact"
13
+ "url": "https://github.com/jsenv/workflow",
14
+ "directory": "packages/jsenv-lighthouse-impact"
14
15
  },
15
16
  "engines": {
16
17
  "node": ">=16.13.0"
@@ -32,11 +33,9 @@
32
33
  "/main.js"
33
34
  ],
34
35
  "scripts": {
35
- "eslint": "node ./node_modules/eslint/bin/eslint.js . --ext=.js,.mjs",
36
+ "eslint": "npx eslint . --ext=.js,.mjs",
36
37
  "importmap": "node ./script/importmap/importmap.mjs",
37
- "performance": "node --expose-gc ./script/performance/performance.mjs --log",
38
- "lighthouse": "node ./script/lighthouse/lighthouse.mjs --local",
39
- "generate-comment-snapshot-file": "node ./test/comment/generate_comment_snapshot_file.mjs",
38
+ "snapshot": "node ./test/comment/generate_comment_snapshot_file.mjs",
40
39
  "test": "node ./script/test/test.mjs",
41
40
  "test-with-coverage": "npm run test -- --coverage",
42
41
  "prettier": "prettier --write ."
@@ -44,25 +43,20 @@
44
43
  "dependencies": {
45
44
  "@jsenv/abort": "4.1.2",
46
45
  "@jsenv/dynamic-import-worker": "1.0.0",
47
- "@jsenv/filesystem": "2.5.1",
48
- "@jsenv/github-pull-request-impact": "1.6.4",
46
+ "@jsenv/filesystem": "2.7.1",
47
+ "@jsenv/github-pull-request-impact": "1.6.6",
49
48
  "@jsenv/logger": "4.0.1",
50
49
  "chrome-launcher": "0.15.0",
51
- "lighthouse": "9.1.0"
50
+ "lighthouse": "9.2.0"
52
51
  },
53
52
  "devDependencies": {
54
- "@jsenv/assert": "2.4.0",
55
- "@jsenv/core": "24.5.8",
53
+ "@jsenv/assert": "2.4.1",
54
+ "@jsenv/core": "25.3.0",
56
55
  "@jsenv/eslint-config": "16.0.9",
57
- "@jsenv/github-release-package": "1.2.3",
58
- "@jsenv/importmap-eslint-resolver": "5.2.1",
59
- "@jsenv/importmap-node-module": "2.8.0",
60
- "@jsenv/package-publish": "1.6.2",
61
- "@jsenv/performance-impact": "2.2.1",
62
- "@jsenv/server": "12.2.0",
63
- "eslint": "8.4.1",
64
- "eslint-plugin-html": "6.2.0",
65
- "eslint-plugin-import": "2.25.3",
56
+ "@jsenv/importmap-eslint-resolver": "5.2.5",
57
+ "@jsenv/importmap-node-module": "5.1.3",
58
+ "eslint": "8.7.0",
59
+ "eslint-plugin-import": "2.25.4",
66
60
  "prettier": "2.5.1"
67
61
  }
68
62
  }
@@ -2,14 +2,13 @@
2
2
 
3
3
  import { createRequire } from "node:module"
4
4
 
5
- import { createLogger } from "@jsenv/logger"
6
- import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
7
-
8
5
  import {
9
6
  writeFile,
10
7
  resolveUrl,
11
8
  assertAndNormalizeDirectoryUrl,
12
9
  } from "@jsenv/filesystem"
10
+ import { createLogger } from "@jsenv/logger"
11
+ import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
13
12
 
14
13
  import { formatLighthouseReportForLog } from "./internal/formatLighthouseReportForLog.js"
15
14
 
@@ -1,15 +1,9 @@
1
- /* eslint-disable new-cap */
1
+ import * as githubRESTAPI from "@jsenv/github-pull-request-impact/src/internal/github_rest_api.js"
2
2
  import { createDetailedMessage } from "@jsenv/logger"
3
- import {
4
- GET,
5
- POST,
6
- PATCH,
7
- } from "@jsenv/github-pull-request-impact/src/internal/git_hub_api.js"
8
3
 
9
4
  // https://developer.github.com/v3/gists/#create-a-gist
10
5
 
11
6
  export const patchOrPostGists = async ({
12
- cancellationToken,
13
7
  logger,
14
8
 
15
9
  githubToken,
@@ -45,14 +39,14 @@ export const patchOrPostGists = async ({
45
39
  logger.debug(`update or create both gists.`)
46
40
  let [beforeMergeGist, afterMergeGist] = await Promise.all([
47
41
  beforeMergeGistId
48
- ? GET(`https://api.github.com/gists/${beforeMergeGistId}`, {
49
- cancellationToken,
42
+ ? githubRESTAPI.GET({
43
+ url: `https://api.github.com/gists/${beforeMergeGistId}`,
50
44
  githubToken,
51
45
  })
52
46
  : null,
53
47
  afterMergeGistId
54
- ? GET(`https://api.github.com/gists/${afterMergeGistId}`, {
55
- cancellationToken,
48
+ ? githubRESTAPI.GET({
49
+ url: `https://api.github.com/gists/${afterMergeGistId}`,
56
50
  githubToken,
57
51
  })
58
52
  : null,
@@ -66,25 +60,19 @@ export const patchOrPostGists = async ({
66
60
  })
67
61
  if (beforeMergeGist) {
68
62
  logger.info(`updating base gist at ${gistIdToUrl(beforeMergeGist.id)}`)
69
- beforeMergeGist = await PATCH(
70
- `https://api.github.com/gists/${beforeMergeGist.id}`,
71
- beforeMergeGistBody,
72
- {
73
- cancellationToken,
74
- githubToken,
75
- },
76
- )
63
+ beforeMergeGist = await githubRESTAPI.PATCH({
64
+ url: `https://api.github.com/gists/${beforeMergeGist.id}`,
65
+ githubToken,
66
+ body: beforeMergeGistBody,
67
+ })
77
68
  logger.info(`base gist updated`)
78
69
  } else {
79
70
  logger.info(`creating base gist`)
80
- beforeMergeGist = await POST(
81
- `https://api.github.com/gists`,
82
- beforeMergeGistBody,
83
- {
84
- cancellationToken,
85
- githubToken,
86
- },
87
- )
71
+ beforeMergeGist = await githubRESTAPI.POST({
72
+ url: `https://api.github.com/gists`,
73
+ githubToken,
74
+ body: beforeMergeGistBody,
75
+ })
88
76
  logger.info(`base gist created at ${gistIdToUrl(beforeMergeGist.id)}`)
89
77
  }
90
78
 
@@ -98,25 +86,19 @@ export const patchOrPostGists = async ({
98
86
  logger.info(
99
87
  `updating after merge gist at ${gistIdToUrl(afterMergeGist.id)}`,
100
88
  )
101
- afterMergeGist = await PATCH(
102
- `https://api.github.com/gists/${afterMergeGist.id}`,
103
- afterMergeGistBody,
104
- {
105
- cancellationToken,
106
- githubToken,
107
- },
108
- )
89
+ afterMergeGist = await githubRESTAPI.PATCH({
90
+ url: `https://api.github.com/gists/${afterMergeGist.id}`,
91
+ githubToken,
92
+ body: afterMergeGistBody,
93
+ })
109
94
  logger.info(`after merge gist updated`)
110
95
  } else {
111
96
  logger.info(`creating after merge gist`)
112
- afterMergeGist = await POST(
113
- `https://api.github.com/gists`,
114
- afterMergeGistBody,
115
- {
116
- cancellationToken,
117
- githubToken,
118
- },
119
- )
97
+ afterMergeGist = await githubRESTAPI.POST({
98
+ url: `https://api.github.com/gists`,
99
+ githubToken,
100
+ body: afterMergeGistBody,
101
+ })
120
102
  logger.info(`after merge gist created at ${gistIdToUrl(afterMergeGist.id)}`)
121
103
  }
122
104
 
@@ -1,5 +1,5 @@
1
- import { commentGitHubPullRequestImpact } from "@jsenv/github-pull-request-impact"
2
1
  import { assertAndNormalizeDirectoryUrl, resolveUrl } from "@jsenv/filesystem"
2
+ import { commentGitHubPullRequestImpact } from "@jsenv/github-pull-request-impact"
3
3
  import { importOneExportFromFile } from "@jsenv/dynamic-import-worker"
4
4
 
5
5
  import { patchOrPostGists } from "./internal/patchOrPostGists.js"
@@ -8,9 +8,6 @@ import { createLighthouseImpactComment } from "./internal/createLighthouseImpact
8
8
  export const reportLighthouseImpact = async ({
9
9
  logLevel,
10
10
  commandLogs = false,
11
- // TODO: update { cancellationToken, cancelOnSIGINT } in "@jsenv/github-pull-request-impact"
12
- // to use { signal, handleSIGINT } instead
13
- cancellationToken,
14
11
  cancelOnSIGINT,
15
12
  projectDirectoryUrl,
16
13
 
@@ -43,7 +40,6 @@ export const reportLighthouseImpact = async ({
43
40
  commandLogs,
44
41
  // lighthouse report are super verbose, do not log them
45
42
  infoLogs: false,
46
- cancellationToken,
47
43
  cancelOnSIGINT,
48
44
  projectDirectoryUrl,
49
45
 
@@ -61,7 +57,6 @@ export const reportLighthouseImpact = async ({
61
57
  },
62
58
  commentIdentifier: `<!-- Generated by @jsenv/lighthouse-impact -->`,
63
59
  createCommentForComparison: async ({
64
- cancellationToken,
65
60
  logger,
66
61
 
67
62
  pullRequestBase,
@@ -76,7 +71,6 @@ export const reportLighthouseImpact = async ({
76
71
  let afterMergeGist
77
72
  try {
78
73
  const gistResult = await patchOrPostGists({
79
- cancellationToken,
80
74
  logger,
81
75
 
82
76
  githubToken,