@jsenv/github-pull-request-impact 1.6.11 → 1.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/github-pull-request-impact",
3
- "version": "1.6.11",
3
+ "version": "1.7.1",
4
4
  "description": "Report pull request impact on something",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -17,30 +17,25 @@
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
- "test": "node ./script/test/test.mjs",
38
- "test-with-coverage": "npm run test -- --coverage",
39
- "prettier": "prettier --write ."
34
+ "test": "node ./scripts/test.mjs"
40
35
  },
41
36
  "dependencies": {
42
- "@jsenv/filesystem": "3.1.0",
43
- "@jsenv/logger": "4.0.1",
44
- "node-fetch": "2.6.7"
37
+ "@jsenv/fetch": "1.1.22",
38
+ "@jsenv/filesystem": "4.1.6",
39
+ "@jsenv/log": "3.3.1"
45
40
  }
46
- }
41
+ }
@@ -4,11 +4,9 @@
4
4
  * @jsenv/file-size-impact, @jsenv/performance-impact and @jsenv/lighthouse-score-impact
5
5
  */
6
6
 
7
- import {
8
- assertAndNormalizeDirectoryUrl,
9
- urlToFileSystemPath,
10
- } from "@jsenv/filesystem"
11
- import { createLogger } from "@jsenv/logger"
7
+ import { fileURLToPath } from "node:url"
8
+ import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem"
9
+ import { createLogger } from "@jsenv/log"
12
10
 
13
11
  import * as githubRESTAPI from "./internal/github_rest_api.js"
14
12
  import { exec } from "./internal/exec.js"
@@ -133,7 +131,7 @@ const commentPrImpact = async ({
133
131
  const execCommandInRootDirectory = (command) => {
134
132
  logger.info(`> ${command}`)
135
133
  return exec(command, {
136
- cwd: urlToFileSystemPath(rootDirectoryUrl),
134
+ cwd: fileURLToPath(rootDirectoryUrl),
137
135
  onLog: (string) => {
138
136
  if (commandLogs) {
139
137
  logger.info(string)
@@ -370,9 +368,7 @@ const ensureGitConfig = async (
370
368
  await execCommandInRootDirectory(`git config ${name}`)
371
369
  return () => {}
372
370
  } catch (e) {
373
- await execCommandInRootDirectory(
374
- `git config ${name} "${valueIfMissing}"`,
375
- )
371
+ await execCommandInRootDirectory(`git config ${name} "${valueIfMissing}"`)
376
372
  return async () => {
377
373
  await execCommandInRootDirectory(`git config --unset ${name}`)
378
374
  }
@@ -36,7 +36,14 @@ export const createGitHubPullRequestCommentText = ({
36
36
  })
37
37
  }
38
38
 
39
- const truncateComment = ({ commentLength, maxLength, header, warnings, body, footer }) => {
39
+ const truncateComment = ({
40
+ commentLength,
41
+ maxLength,
42
+ header,
43
+ warnings,
44
+ body,
45
+ footer,
46
+ }) => {
40
47
  const warningsWithTruncateWarning = [
41
48
  ...warnings,
42
49
  `**Warning:** The comment body was truncated to fit GitHub limit on comment length.
@@ -69,7 +76,9 @@ For the record the full comment length was ${commentLength} bytes.`,
69
76
 
70
77
  const composeCommentText = ({ header, warnings, body, footer }) => {
71
78
  const warningsAsText = composeWarningsText(warnings)
72
- const parts = [header, warningsAsText, body, footer].filter((string) => string.length > 0)
79
+ const parts = [header, warningsAsText, body, footer].filter(
80
+ (string) => string.length > 0,
81
+ )
73
82
 
74
83
  return parts.join(`
75
84
 
@@ -1,4 +1,4 @@
1
- import nodeFetch from "node-fetch"
1
+ import { fetchUrl } from "@jsenv/fetch"
2
2
 
3
3
  export const GET = async ({ url, githubToken, headers }) => {
4
4
  return sendHttpRequest({
@@ -72,7 +72,7 @@ const sendHttpRequest = async ({
72
72
  }) => {
73
73
  let response
74
74
  try {
75
- response = await nodeFetch(url, {
75
+ response = await fetchUrl(url, {
76
76
  method,
77
77
  headers: {
78
78
  ...(typeof body === "undefined"
@@ -1,4 +1,8 @@
1
- export const renderGeneratedByText = ({ generatedByLink, runLink, commitLink }) => {
1
+ export const renderGeneratedByText = ({
2
+ generatedByLink,
3
+ runLink,
4
+ commitLink,
5
+ }) => {
2
6
  if (runLink && typeof runLink !== "object") {
3
7
  console.warn(
4
8
  `runLink ignored because it should be an object with {url, text}, received ${runLink}`,
@@ -9,7 +13,9 @@ export const renderGeneratedByText = ({ generatedByLink, runLink, commitLink })
9
13
  const parts = [
10
14
  `Generated by <a href="${generatedByLink.url}">${generatedByLink.text}</a>`,
11
15
  ...(runLink ? [`during <a href="${runLink.url}">${runLink.text}</a>`] : []),
12
- ...(commitLink ? [`on <a href="${commitLink.url}">${commitLink.text}</a>`] : []),
16
+ ...(commitLink
17
+ ? [`on <a href="${commitLink.url}">${commitLink.text}</a>`]
18
+ : []),
13
19
  ]
14
20
 
15
21
  return `<sub>
package/src/main.js ADDED
@@ -0,0 +1,6 @@
1
+ export { readGitHubWorkflowEnv } from "./readGitHubWorkflowEnv.js"
2
+ export { commentGitHubPullRequestImpact } from "./commentGitHubPullRequestImpact.js"
3
+
4
+ // not planned to be documented but can be useful
5
+ // to get a github comment from a { warnings, body } object
6
+ export { createGitHubPullRequestCommentText } from "./internal/createGitHubPullRequestCommentText.js"
package/main.js DELETED
@@ -1,6 +0,0 @@
1
- export { readGitHubWorkflowEnv } from "./src/readGitHubWorkflowEnv.js"
2
- export { commentGitHubPullRequestImpact } from "./src/commentGitHubPullRequestImpact.js"
3
-
4
- // not planned to be documented but can be useful
5
- // to get a github comment from a { warnings, body } object
6
- export { createGitHubPullRequestCommentText } from "./src/internal/createGitHubPullRequestCommentText.js"