@jsenv/github-pull-request-impact 1.6.11 → 1.7.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/github-pull-request-impact",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Report pull request impact on something",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -23,24 +23,20 @@
|
|
|
23
23
|
"type": "module",
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
26
|
-
"import": "./main.js"
|
|
26
|
+
"import": "./src/main.js"
|
|
27
27
|
},
|
|
28
28
|
"./*": "./*"
|
|
29
29
|
},
|
|
30
|
-
"main": "./main.js",
|
|
30
|
+
"main": "./src/main.js",
|
|
31
31
|
"files": [
|
|
32
|
-
"/src/"
|
|
33
|
-
"/main.js"
|
|
32
|
+
"/src/"
|
|
34
33
|
],
|
|
35
34
|
"scripts": {
|
|
36
|
-
"
|
|
37
|
-
"test": "node ./script/test/test.mjs",
|
|
38
|
-
"test-with-coverage": "npm run test -- --coverage",
|
|
39
|
-
"prettier": "prettier --write ."
|
|
35
|
+
"test": "node ./scripts/test.mjs"
|
|
40
36
|
},
|
|
41
37
|
"dependencies": {
|
|
42
|
-
"@jsenv/
|
|
43
|
-
"@jsenv/
|
|
44
|
-
"
|
|
38
|
+
"@jsenv/fetch": "1.1.2",
|
|
39
|
+
"@jsenv/filesystem": "4.1.0",
|
|
40
|
+
"@jsenv/log": "2.1.0"
|
|
45
41
|
}
|
|
46
42
|
}
|
|
@@ -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
|
-
|
|
9
|
-
|
|
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:
|
|
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 = ({
|
|
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(
|
|
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
|
|
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
|
|
75
|
+
response = await fetchUrl(url, {
|
|
76
76
|
method,
|
|
77
77
|
headers: {
|
|
78
78
|
...(typeof body === "undefined"
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export const renderGeneratedByText = ({
|
|
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
|
|
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"
|