@jsenv/file-size-impact 10.0.4 → 11.0.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 +14 -12
- package/readme.md +13 -23
- package/src/getFileSizeReport.js +1 -1
- package/src/internal/applyTrackingConfig.js +1 -1
- package/src/internal/compareTwoFileSizeReports.js +1 -1
- package/src/internal/formatComment.js +105 -224
- package/src/internal/jsenvCommentParameters.js +73 -69
- package/src/internal/orderBySizeImpact.js +3 -14
- package/src/internal/renderImpactTable.js +158 -155
- package/src/internal/size_map.js +49 -0
- package/src/internal/worker_generating_file_size_report.js +17 -0
- package/src/logFileSizeReport.js +1 -1
- package/src/reportFileSizeImpact.js +30 -25
- package/src/internal/getSizeMaps.js +0 -43
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/file-size-impact",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Add files size impact into pull requests",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"/index.js"
|
|
27
27
|
],
|
|
28
28
|
"scripts": {
|
|
29
|
-
"eslint-check": "node ./node_modules/eslint/bin/eslint.js .",
|
|
29
|
+
"eslint-check": "node ./node_modules/eslint/bin/eslint.js . --ext=.js,.mjs",
|
|
30
30
|
"generate-importmap": "node ./script/importmap/generate_importmap.mjs",
|
|
31
|
-
"
|
|
31
|
+
"measure-file-sizes": "node ./script/file_size/generate_file_size_report.mjs --local",
|
|
32
32
|
"generate-comment-snapshot-file": "node ./test/comment/generate_comment_snapshot_file.mjs",
|
|
33
33
|
"test": "node ./script/test/test.mjs",
|
|
34
34
|
"test-with-coverage": "npm run test -- --coverage",
|
|
@@ -41,23 +41,25 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@jsenv/github-pull-request-impact": "1.6.4",
|
|
43
43
|
"@jsenv/logger": "4.0.1",
|
|
44
|
-
"@jsenv/
|
|
44
|
+
"@jsenv/filesystem": "2.2.0",
|
|
45
45
|
"pretty-bytes": "5.6.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@
|
|
48
|
+
"@babel/core": "7.15.8",
|
|
49
|
+
"@babel/eslint-parser": "7.15.8",
|
|
50
|
+
"@jsenv/assert": "2.3.2",
|
|
49
51
|
"@jsenv/cancellation": "3.0.0",
|
|
50
52
|
"@jsenv/codecov-upload": "3.5.0",
|
|
51
|
-
"@jsenv/core": "
|
|
52
|
-
"@jsenv/eslint-config": "
|
|
53
|
-
"@jsenv/filesystem": "2.
|
|
53
|
+
"@jsenv/core": "23.0.2",
|
|
54
|
+
"@jsenv/eslint-config": "16.0.8",
|
|
55
|
+
"@jsenv/filesystem": "2.2.0",
|
|
54
56
|
"@jsenv/github-release-package": "1.2.3",
|
|
55
|
-
"@jsenv/importmap-eslint-resolver": "5.1.
|
|
56
|
-
"@jsenv/importmap-node-module": "
|
|
57
|
+
"@jsenv/importmap-eslint-resolver": "5.1.2",
|
|
58
|
+
"@jsenv/importmap-node-module": "2.4.1",
|
|
57
59
|
"@jsenv/package-publish": "1.6.2",
|
|
58
60
|
"@jsenv/prettier-check-project": "5.6.1",
|
|
59
61
|
"eslint": "7.32.0",
|
|
60
|
-
"eslint-plugin-import": "2.
|
|
61
|
-
"prettier": "2.
|
|
62
|
+
"eslint-plugin-import": "2.25.2",
|
|
63
|
+
"prettier": "2.4.1"
|
|
62
64
|
}
|
|
63
65
|
}
|
package/readme.md
CHANGED
|
@@ -11,16 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
This section shows pull request comment and how to read _group summary_ and _size impact_ sections.
|
|
13
13
|
|
|
14
|
-
_Screenshot of a pull request comment_
|
|
15
|
-
|
|
16
|
-

|
|
17
|
-
|
|
18
|
-
_Screenshot when comment is expanded_
|
|
19
|
-
|
|
20
|
-

|
|
21
|
-
|
|
22
|
-
## Pull request comment legend
|
|
23
|
-
|
|
24
14
|

|
|
25
15
|
|
|
26
16
|
"_critical files (1/2)_" is a group summary, it translates into the following sentence:
|
|
@@ -110,10 +100,10 @@ _report_file_size_impact.mjs_
|
|
|
110
100
|
|
|
111
101
|
import { reportFileSizeImpact, readGitHubWorkflowEnv } from "@jsenv/file-size-impact"
|
|
112
102
|
|
|
113
|
-
reportFileSizeImpact({
|
|
103
|
+
await reportFileSizeImpact({
|
|
114
104
|
...readGitHubWorkflowEnv(),
|
|
115
105
|
buildCommand: "npm run dist",
|
|
116
|
-
|
|
106
|
+
fileSizeModulePath: "./generate_file_size_report.mjs",
|
|
117
107
|
})
|
|
118
108
|
```
|
|
119
109
|
|
|
@@ -204,7 +194,7 @@ For example you can create two groups named _"critical files"_ and _"remaining f
|
|
|
204
194
|
```js
|
|
205
195
|
import { getFileSizeReport } from "@jsenv/file-size-impact"
|
|
206
196
|
|
|
207
|
-
getFileSizeReport({
|
|
197
|
+
await getFileSizeReport({
|
|
208
198
|
trackingConfig: {
|
|
209
199
|
"critical files": {
|
|
210
200
|
"./dist/main.js": true,
|
|
@@ -231,7 +221,7 @@ You can use this parameter to track file size after gzip compression.
|
|
|
231
221
|
```js
|
|
232
222
|
import { getFileSizeReport, raw, gzip, brotli } from "@jsenv/file-size-impact"
|
|
233
223
|
|
|
234
|
-
getFileSizeReport({
|
|
224
|
+
await getFileSizeReport({
|
|
235
225
|
transformations: { raw, gzip, brotli },
|
|
236
226
|
})
|
|
237
227
|
```
|
|
@@ -245,7 +235,7 @@ It's also possible to control compression level.
|
|
|
245
235
|
```js
|
|
246
236
|
import { getFileSizeReport, raw, gzip } from "@jsenv/file-size-impact"
|
|
247
237
|
|
|
248
|
-
getFileSizeReport({
|
|
238
|
+
await getFileSizeReport({
|
|
249
239
|
transformations: {
|
|
250
240
|
raw,
|
|
251
241
|
gzip7: (buffer) => gzip(buffer, { level: 7 }),
|
|
@@ -259,7 +249,7 @@ Finally _transformations_ can be used to add custom _transformations_.
|
|
|
259
249
|
```js
|
|
260
250
|
import { getFileSizeReport, raw, gzip, brotli } from "@jsenv/file-size-impact"
|
|
261
251
|
|
|
262
|
-
getFileSizeReport({
|
|
252
|
+
await getFileSizeReport({
|
|
263
253
|
transformations: {
|
|
264
254
|
raw,
|
|
265
255
|
trim: (buffer) => String(buffer).trim(),
|
|
@@ -276,7 +266,7 @@ This parameter reuses the shape of [trackingConfig](#trackingConfig) (associatin
|
|
|
276
266
|
```js
|
|
277
267
|
import { reportFileSizeImpact } from "@jsenv/file-size-impact"
|
|
278
268
|
|
|
279
|
-
reportFileSizeImpact({
|
|
269
|
+
await reportFileSizeImpact({
|
|
280
270
|
manifestConfig: {
|
|
281
271
|
"./dist/**/manifest.json": true,
|
|
282
272
|
},
|
|
@@ -288,7 +278,7 @@ You can disable manifest files handling by passing `null`.
|
|
|
288
278
|
```js
|
|
289
279
|
import { reportFileSizeImpact } from "@jsenv/file-size-impact"
|
|
290
280
|
|
|
291
|
-
reportFileSizeImpact({
|
|
281
|
+
await reportFileSizeImpact({
|
|
292
282
|
manifestConfig: {
|
|
293
283
|
"./dist/**/manifest.json": null,
|
|
294
284
|
},
|
|
@@ -315,7 +305,7 @@ await reportFileSizeImpact({
|
|
|
315
305
|
|
|
316
306
|
installCommand: "npm install",
|
|
317
307
|
buildCommand: "npm run build",
|
|
318
|
-
|
|
308
|
+
fileSizeModulePath: "./generate_file_size_report.mjs",
|
|
319
309
|
|
|
320
310
|
filesOrdering: "size_impact",
|
|
321
311
|
})
|
|
@@ -339,9 +329,9 @@ _installCommand_ parameter is a string representing the command to run in order
|
|
|
339
329
|
|
|
340
330
|
_buildCommand_ parameter is a string representing the command to run in order to generate files. This parameter is optional with a default value of `"npm run-script build"`. You can pass `null` if you don't need to run a build command before computing file sizes.
|
|
341
331
|
|
|
342
|
-
##
|
|
332
|
+
## fileSizeModulePath
|
|
343
333
|
|
|
344
|
-
|
|
334
|
+
_fileSizeModulePath_ is a string parameter representing an url relative to [projectDirectoryUrl](#projectDirectoryUrl) leading a module file. This file must contain a _generateFileSizeReport_ export.
|
|
345
335
|
|
|
346
336
|
## filesOrdering
|
|
347
337
|
|
|
@@ -365,7 +355,7 @@ Inside an other workflow, you can pass your own _runLink_. As in the example bel
|
|
|
365
355
|
```js
|
|
366
356
|
import { reportFileSizeImpact } from "@jsenv/file-size-impact"
|
|
367
357
|
|
|
368
|
-
reportFileSizeImpact({
|
|
358
|
+
await reportFileSizeImpact({
|
|
369
359
|
runLink: {
|
|
370
360
|
url: process.env.BUILD_URL,
|
|
371
361
|
text: `${process.env.JOB_NAME}#${process.env.BUILD_ID}`,
|
|
@@ -382,7 +372,7 @@ import { reportFileSizeImpact, readGitHubWorkflowEnv } from "@jsenv/file-size-im
|
|
|
382
372
|
|
|
383
373
|
const gitHubWorkflowEnv = readGitHubWorkflowEnv()
|
|
384
374
|
|
|
385
|
-
reportFileSizeImpact({
|
|
375
|
+
await reportFileSizeImpact({
|
|
386
376
|
...gitHubWorkflowEnv,
|
|
387
377
|
})
|
|
388
378
|
```
|
package/src/getFileSizeReport.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { urlToFileSystemPath, collectDirectoryMatchReport } from "@jsenv/
|
|
1
|
+
import { urlToFileSystemPath, collectDirectoryMatchReport } from "@jsenv/filesystem"
|
|
2
2
|
import { createCancellationToken } from "@jsenv/cancellation"
|
|
3
3
|
|
|
4
4
|
export const applyTrackingConfig = async (
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { compareTwoFileSizeReports } from "./compareTwoFileSizeReports.js"
|
|
2
|
-
import { getSizeMaps } from "./getSizeMaps.js"
|
|
3
2
|
import { isAdded, isModified, isDeleted } from "./helper.js"
|
|
4
3
|
import { renderImpactTable } from "./renderImpactTable.js"
|
|
5
4
|
import { orderBySizeImpact } from "./orderBySizeImpact.js"
|
|
5
|
+
import { getSizeMapsOneFile, getSizeMapsForManyFiles } from "./size_map.js"
|
|
6
6
|
|
|
7
7
|
export const formatComment = ({
|
|
8
8
|
pullRequestBase,
|
|
@@ -11,14 +11,13 @@ export const formatComment = ({
|
|
|
11
11
|
afterMergeFileSizeReport,
|
|
12
12
|
|
|
13
13
|
filesOrdering,
|
|
14
|
-
|
|
14
|
+
maxFilesPerGroup,
|
|
15
15
|
fileRelativeUrlMaxLength,
|
|
16
16
|
formatGroupSummary,
|
|
17
|
-
formatHiddenImpactSummary,
|
|
18
17
|
formatFileRelativeUrl,
|
|
19
18
|
formatFileCell,
|
|
20
19
|
formatFileSizeImpactCell,
|
|
21
|
-
|
|
20
|
+
formatEmojiCell,
|
|
22
21
|
shouldOpenGroupByDefault,
|
|
23
22
|
}) => {
|
|
24
23
|
const warnings = []
|
|
@@ -40,14 +39,13 @@ export const formatComment = ({
|
|
|
40
39
|
reportComparison,
|
|
41
40
|
|
|
42
41
|
filesOrdering,
|
|
43
|
-
|
|
42
|
+
maxFilesPerGroup,
|
|
44
43
|
fileRelativeUrlMaxLength,
|
|
45
44
|
formatGroupSummary,
|
|
46
|
-
formatHiddenImpactSummary,
|
|
47
45
|
formatFileRelativeUrl,
|
|
48
46
|
formatFileCell,
|
|
49
47
|
formatFileSizeImpactCell,
|
|
50
|
-
|
|
48
|
+
formatEmojiCell,
|
|
51
49
|
shouldOpenGroupByDefault,
|
|
52
50
|
})
|
|
53
51
|
|
|
@@ -64,199 +62,110 @@ const renderCommentBody = ({
|
|
|
64
62
|
reportComparison,
|
|
65
63
|
|
|
66
64
|
filesOrdering,
|
|
65
|
+
maxFilesPerGroup,
|
|
67
66
|
fileRelativeUrlMaxLength,
|
|
68
|
-
maxRowsPerTable,
|
|
69
67
|
formatGroupSummary,
|
|
70
|
-
formatHiddenImpactSummary,
|
|
71
68
|
formatFileRelativeUrl,
|
|
72
69
|
formatFileCell,
|
|
73
70
|
formatFileSizeImpactCell,
|
|
74
|
-
|
|
71
|
+
formatEmojiCell,
|
|
75
72
|
shouldOpenGroupByDefault,
|
|
76
73
|
}) => {
|
|
77
|
-
const
|
|
74
|
+
const { groups, transformationKeys } = reportComparison
|
|
78
75
|
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
{
|
|
82
|
-
groupName,
|
|
83
|
-
groupComparison,
|
|
84
|
-
groupFileCount,
|
|
85
|
-
groupImpactCount,
|
|
86
|
-
fileByFileImpact,
|
|
87
|
-
groupHiddenImpactCount,
|
|
88
|
-
fileByFileImpactHidden,
|
|
89
|
-
},
|
|
90
|
-
) => {
|
|
91
|
-
const groupSummary = formatGroupSummary({
|
|
92
|
-
groupName,
|
|
93
|
-
groupImpactCount,
|
|
94
|
-
groupFileCount,
|
|
95
|
-
})
|
|
96
|
-
const groupShouldBeOpenByDefault = shouldOpenGroupByDefault({
|
|
97
|
-
groupName,
|
|
98
|
-
groupComparison,
|
|
99
|
-
groupFileCount,
|
|
100
|
-
groupImpactCount,
|
|
101
|
-
fileByFileImpact,
|
|
102
|
-
groupHiddenImpactCount,
|
|
103
|
-
fileByFileImpactHidden,
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
return renderDetails({
|
|
107
|
-
open: groupShouldBeOpenByDefault,
|
|
108
|
-
summary: groupSummary,
|
|
109
|
-
content: groupMessage,
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const { transformationKeys } = reportComparison
|
|
114
|
-
const groupMessages = Object.keys(reportComparison.groups).map((groupName) => {
|
|
115
|
-
const groupComparison = reportComparison.groups[groupName]
|
|
76
|
+
const groupMessages = Object.keys(groups).map((groupName) => {
|
|
77
|
+
const groupComparison = groups[groupName]
|
|
116
78
|
const groupFileImpactMap = groupComparison.fileImpactMap
|
|
117
|
-
const groupFileCount = Object.keys(groupFileImpactMap).length
|
|
118
79
|
let fileByFileImpact = {}
|
|
119
|
-
|
|
120
|
-
if (groupFileCount === 0) {
|
|
121
|
-
return renderGroup(
|
|
122
|
-
formulateEmptyGroupContent({
|
|
123
|
-
groupName,
|
|
124
|
-
groupConfig: groupComparison.tracking,
|
|
125
|
-
}),
|
|
126
|
-
{
|
|
127
|
-
groupName,
|
|
128
|
-
groupComparison,
|
|
129
|
-
groupFileCount,
|
|
130
|
-
groupImpactCount: 0,
|
|
131
|
-
fileByFileImpact,
|
|
132
|
-
groupHiddenImpactCount: 0,
|
|
133
|
-
fileByFileImpactHidden,
|
|
134
|
-
},
|
|
135
|
-
)
|
|
136
|
-
}
|
|
80
|
+
const files = Object.keys(groupFileImpactMap)
|
|
137
81
|
|
|
138
|
-
|
|
82
|
+
files.forEach((fileRelativeUrl) => {
|
|
83
|
+
const { beforeMerge, afterMerge } = groupFileImpactMap[fileRelativeUrl]
|
|
84
|
+
const event = isAdded({ beforeMerge, afterMerge })
|
|
85
|
+
? "added"
|
|
86
|
+
: isDeleted({ beforeMerge, afterMerge })
|
|
87
|
+
? "deleted"
|
|
88
|
+
: isModified({ beforeMerge, afterMerge })
|
|
89
|
+
? "modified"
|
|
90
|
+
: "none"
|
|
139
91
|
const meta = event === "deleted" ? beforeMerge.meta : afterMerge.meta
|
|
140
|
-
|
|
141
|
-
|
|
92
|
+
|
|
93
|
+
const { sizeMapBeforeMerge, sizeMapAfterMerge, sizeImpactMap } = getSizeMapsOneFile({
|
|
94
|
+
sizeNames: transformationKeys,
|
|
142
95
|
beforeMerge,
|
|
143
96
|
afterMerge,
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
addImpact(fileRelativeUrl, {
|
|
163
|
-
event: "added",
|
|
164
|
-
beforeMerge,
|
|
165
|
-
afterMerge,
|
|
166
|
-
})
|
|
167
|
-
return
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (isDeleted({ beforeMerge, afterMerge })) {
|
|
171
|
-
addImpact(fileRelativeUrl, {
|
|
172
|
-
event: "deleted",
|
|
173
|
-
beforeMerge,
|
|
174
|
-
afterMerge,
|
|
175
|
-
})
|
|
176
|
-
return
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (isModified({ beforeMerge, afterMerge })) {
|
|
180
|
-
addImpact(fileRelativeUrl, {
|
|
181
|
-
event: "modified",
|
|
182
|
-
beforeMerge,
|
|
183
|
-
afterMerge,
|
|
184
|
-
})
|
|
97
|
+
})
|
|
98
|
+
const { showSizeImpact, formatFileRelativeUrl } = metaToData(meta, {
|
|
99
|
+
fileRelativeUrl,
|
|
100
|
+
sizeBeforeMerge: sizeMapBeforeMerge[0],
|
|
101
|
+
sizeAfterMerge: sizeMapAfterMerge[0],
|
|
102
|
+
sizeImpactMap,
|
|
103
|
+
})
|
|
104
|
+
fileByFileImpact[fileRelativeUrl] = {
|
|
105
|
+
event,
|
|
106
|
+
manifestKeyBeforeMerge: beforeMerge ? beforeMerge.manifestKey : undefined,
|
|
107
|
+
manifestKeyAfterMerge: afterMerge ? afterMerge.manifestKey : undefined,
|
|
108
|
+
relativeUrlBeforeMerge: beforeMerge ? beforeMerge.relativeUrl : undefined,
|
|
109
|
+
relativeUrlAfterMerge: afterMerge ? afterMerge.relativeUrl : undefined,
|
|
110
|
+
sizeMapBeforeMerge,
|
|
111
|
+
sizeMapAfterMerge,
|
|
112
|
+
sizeImpactMap,
|
|
113
|
+
showSizeImpact,
|
|
114
|
+
formatFileRelativeUrl,
|
|
185
115
|
}
|
|
186
116
|
})
|
|
187
|
-
|
|
188
117
|
if (filesOrdering === "size_impact") {
|
|
189
|
-
fileByFileImpact = orderBySizeImpact(fileByFileImpact,
|
|
190
|
-
fileByFileImpactHidden = orderBySizeImpact(
|
|
191
|
-
fileByFileImpactHidden,
|
|
192
|
-
reportComparison.transformationKeys,
|
|
193
|
-
)
|
|
118
|
+
fileByFileImpact = orderBySizeImpact(fileByFileImpact, transformationKeys)
|
|
194
119
|
}
|
|
195
120
|
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
fileByFileImpact,
|
|
205
|
-
groupHiddenImpactCount,
|
|
206
|
-
fileByFileImpactHidden,
|
|
207
|
-
})
|
|
208
|
-
}
|
|
121
|
+
const groupSizeMaps = getSizeMapsForManyFiles({
|
|
122
|
+
sizeNames: transformationKeys,
|
|
123
|
+
fileByFileImpact,
|
|
124
|
+
files,
|
|
125
|
+
})
|
|
126
|
+
const groupSizeMapBeforeMerge = groupSizeMaps.sizeMapBeforeMerge
|
|
127
|
+
const groupSizeMapAfterMerge = groupSizeMaps.sizeMapAfterMerge
|
|
128
|
+
const groupIsEmpty = Object.keys(fileByFileImpact).length === 0
|
|
209
129
|
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
: []),
|
|
225
|
-
...(groupHiddenImpactCount > 0
|
|
226
|
-
? [
|
|
227
|
-
renderDetails({
|
|
228
|
-
summary: formatHiddenImpactSummary({ groupName, groupHiddenImpactCount }),
|
|
229
|
-
content: renderImpactTable(fileByFileImpactHidden, {
|
|
230
|
-
groupFileImpactMap,
|
|
231
|
-
transformationKeys,
|
|
232
|
-
fileRelativeUrlMaxLength,
|
|
233
|
-
maxRowsPerTable,
|
|
234
|
-
formatFileRelativeUrl,
|
|
235
|
-
formatFileCell,
|
|
236
|
-
formatFileSizeImpactCell,
|
|
237
|
-
formatGroupSizeImpactCell,
|
|
238
|
-
}),
|
|
239
|
-
}),
|
|
240
|
-
]
|
|
241
|
-
: []),
|
|
242
|
-
]
|
|
130
|
+
const groupSummary = formatGroupSummary({
|
|
131
|
+
groupName,
|
|
132
|
+
groupSizeMapBeforeMerge,
|
|
133
|
+
groupSizeMapAfterMerge,
|
|
134
|
+
sizeNames: transformationKeys,
|
|
135
|
+
fileByFileImpact,
|
|
136
|
+
})
|
|
137
|
+
const groupShouldBeOpenByDefault = shouldOpenGroupByDefault({
|
|
138
|
+
groupName,
|
|
139
|
+
groupSizeMapBeforeMerge,
|
|
140
|
+
groupSizeMapAfterMerge,
|
|
141
|
+
sizeNames: transformationKeys,
|
|
142
|
+
fileByFileImpact,
|
|
143
|
+
})
|
|
243
144
|
|
|
244
|
-
return
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
145
|
+
return renderDetails({
|
|
146
|
+
open: groupShouldBeOpenByDefault,
|
|
147
|
+
summary: groupSummary,
|
|
148
|
+
content: groupIsEmpty
|
|
149
|
+
? renderEmptyGroupContent({
|
|
150
|
+
groupName,
|
|
151
|
+
groupConfig: groupComparison.tracking,
|
|
152
|
+
})
|
|
153
|
+
: renderImpactTable({
|
|
154
|
+
fileByFileImpact,
|
|
155
|
+
transformationKeys,
|
|
156
|
+
fileRelativeUrlMaxLength,
|
|
157
|
+
maxFilesPerGroup,
|
|
158
|
+
formatFileRelativeUrl,
|
|
159
|
+
formatFileCell,
|
|
160
|
+
formatFileSizeImpactCell,
|
|
161
|
+
formatEmojiCell,
|
|
162
|
+
groupSizeMapBeforeMerge,
|
|
163
|
+
groupSizeMapAfterMerge,
|
|
164
|
+
}),
|
|
165
|
+
})
|
|
257
166
|
})
|
|
258
167
|
|
|
259
|
-
const mergeImpact = formulateMergeImpact({ pullRequestHead, pullRequestBase
|
|
168
|
+
const mergeImpact = formulateMergeImpact({ pullRequestHead, pullRequestBase })
|
|
260
169
|
if (groupMessages.length === 0) {
|
|
261
170
|
return mergeImpact
|
|
262
171
|
}
|
|
@@ -267,43 +176,20 @@ ${groupMessages.join(`
|
|
|
267
176
|
`)}`
|
|
268
177
|
}
|
|
269
178
|
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
return `<p>Merging <em>${pullRequestHead}</em> into <em>${pullRequestBase}</em> will ${overallImpact}.</p>`
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
const formulateOverallImpact = (overallImpactInfo) => {
|
|
276
|
-
let impactedFileCount = 0
|
|
277
|
-
let impactedGroupCount = 0
|
|
278
|
-
const impactedGroups = []
|
|
279
|
-
Object.keys(overallImpactInfo).forEach((relativeUrl) => {
|
|
280
|
-
const groupName = overallImpactInfo[relativeUrl]
|
|
281
|
-
if (groupName) {
|
|
282
|
-
impactedFileCount++
|
|
283
|
-
if (!impactedGroups.includes(groupName)) {
|
|
284
|
-
impactedGroups.push(groupName)
|
|
285
|
-
impactedGroupCount++
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
})
|
|
289
|
-
|
|
290
|
-
if (impactedFileCount === 0) {
|
|
291
|
-
return `not impact files in any group`
|
|
292
|
-
}
|
|
293
|
-
return `impact ${formulateFileQuantity(impactedFileCount)} in ${formulateGroupQuantity(
|
|
294
|
-
impactedGroupCount,
|
|
295
|
-
)}`
|
|
296
|
-
}
|
|
179
|
+
const renderEmptyGroupContent = ({ groupName, groupConfig }) => {
|
|
180
|
+
return `<p>No file in ${groupName} group (see config below).</p>
|
|
297
181
|
|
|
298
|
-
|
|
299
|
-
|
|
182
|
+
\`\`\`json
|
|
183
|
+
${JSON.stringify(groupConfig, null, " ")}
|
|
184
|
+
\`\`\`
|
|
185
|
+
`
|
|
300
186
|
}
|
|
301
187
|
|
|
302
|
-
const
|
|
303
|
-
return
|
|
188
|
+
const formulateMergeImpact = ({ pullRequestBase, pullRequestHead }) => {
|
|
189
|
+
return `<p>Merging <em>${pullRequestHead}</em> into <em>${pullRequestBase}</em> impact files as follow:</p>`
|
|
304
190
|
}
|
|
305
191
|
|
|
306
|
-
const metaToData = (meta, { fileRelativeUrl,
|
|
192
|
+
const metaToData = (meta, { fileRelativeUrl, sizeBeforeMerge, sizeAfterMerge, sizeImpactMap }) => {
|
|
307
193
|
if (typeof meta === "boolean") {
|
|
308
194
|
return {
|
|
309
195
|
showSizeImpact: true,
|
|
@@ -313,9 +199,9 @@ const metaToData = (meta, { fileRelativeUrl, event, beforeMerge, afterMerge }) =
|
|
|
313
199
|
if (typeof meta === "object") {
|
|
314
200
|
const showSizeImpact = showSizeImpactGetter(meta, {
|
|
315
201
|
fileRelativeUrl,
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
202
|
+
sizeBeforeMerge,
|
|
203
|
+
sizeAfterMerge,
|
|
204
|
+
sizeImpactMap,
|
|
319
205
|
})
|
|
320
206
|
const { formatFileRelativeUrl } = meta
|
|
321
207
|
return {
|
|
@@ -330,7 +216,10 @@ const metaToData = (meta, { fileRelativeUrl, event, beforeMerge, afterMerge }) =
|
|
|
330
216
|
}
|
|
331
217
|
}
|
|
332
218
|
|
|
333
|
-
const showSizeImpactGetter = (
|
|
219
|
+
const showSizeImpactGetter = (
|
|
220
|
+
meta,
|
|
221
|
+
{ fileRelativeUrl, sizeBeforeMerge, sizeAfterMerge, sizeImpactMap },
|
|
222
|
+
) => {
|
|
334
223
|
const { showSizeImpact } = meta
|
|
335
224
|
|
|
336
225
|
if (typeof showSizeImpact === "undefined") {
|
|
@@ -344,8 +233,9 @@ const showSizeImpactGetter = (meta, { fileRelativeUrl, event, beforeMerge, after
|
|
|
344
233
|
if (typeof showSizeImpact === "function") {
|
|
345
234
|
return showSizeImpact({
|
|
346
235
|
fileRelativeUrl,
|
|
347
|
-
|
|
348
|
-
|
|
236
|
+
sizeBeforeMerge,
|
|
237
|
+
sizeAfterMerge,
|
|
238
|
+
sizeImpactMap,
|
|
349
239
|
})
|
|
350
240
|
}
|
|
351
241
|
|
|
@@ -355,15 +245,6 @@ const showSizeImpactGetter = (meta, { fileRelativeUrl, event, beforeMerge, after
|
|
|
355
245
|
return true
|
|
356
246
|
}
|
|
357
247
|
|
|
358
|
-
const formulateEmptyGroupContent = ({ groupName, groupConfig }) => {
|
|
359
|
-
return `<p>No file in ${groupName} group (see config below).</p>
|
|
360
|
-
|
|
361
|
-
\`\`\`json
|
|
362
|
-
${JSON.stringify(groupConfig, null, " ")}
|
|
363
|
-
\`\`\`
|
|
364
|
-
`
|
|
365
|
-
}
|
|
366
|
-
|
|
367
248
|
const renderDetails = ({ summary, content, open = false, indent = 0 }) => {
|
|
368
249
|
return `${" ".repeat(indent)}<details${open ? " open" : ""}>
|
|
369
250
|
${" ".repeat(indent + 2)}<summary>${summary}</summary>
|