@jsenv/file-size-impact 12.1.3 → 12.1.7
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 +2 -2
- package/readme.md +40 -35
- package/src/reportFileSizeImpact.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/file-size-impact",
|
|
3
|
-
"version": "12.1.
|
|
3
|
+
"version": "12.1.7",
|
|
4
4
|
"description": "Add files size impact into pull requests",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@jsenv/dynamic-import-worker": "1.0.1",
|
|
41
41
|
"@jsenv/filesystem": "2.7.1",
|
|
42
|
-
"@jsenv/github-pull-request-impact": "1.6.
|
|
42
|
+
"@jsenv/github-pull-request-impact": "1.6.9",
|
|
43
43
|
"@jsenv/logger": "4.0.1",
|
|
44
44
|
"pretty-bytes": "5.6.0"
|
|
45
45
|
},
|
package/readme.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# File size impact [](https://www.npmjs.com/package/@jsenv/file-size-impact)
|
|
1
|
+
# File size impact [](https://www.npmjs.com/package/@jsenv/file-size-impact)
|
|
2
2
|
|
|
3
3
|
`@jsenv/file-size-impact` analyses a pull request impact on specific files size. This analysis is posted in a comment of the pull request on GitHub.
|
|
4
4
|
|
|
@@ -9,29 +9,16 @@
|
|
|
9
9
|
|
|
10
10
|
# Pull request comment
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Screenshot + explanation on pull request comment.
|
|
13
13
|
|
|
14
14
|

|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## size impact
|
|
23
|
-
|
|
24
|
-
"_21.6 kB (+4.11 kB / +23.55%)_" is a size impact, it translates into the following sentence:
|
|
25
|
-
|
|
26
|
-
> "The size after merge is **21.6 kB**. Pull request adds **4.11 kB** representing an increase of **23.55%** of the size before merge."
|
|
27
|
-
|
|
28
|
-
## Unmodified row
|
|
29
|
-
|
|
30
|
-
Unmodified row is the sum of all files in a group that are not impacted by changes in the pull request.
|
|
31
|
-
|
|
32
|
-
## Total row
|
|
33
|
-
|
|
34
|
-
Total row is the sum of all files in a group.
|
|
16
|
+
| Text | How to read it |
|
|
17
|
+
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
18
|
+
| "remaining files (+4.71%)" | There is a group of files named "remaining files" and pull request has an overall impact of _+4.71%_ on these files. |
|
|
19
|
+
| "21.6 kB (+4.11 kB / +23.55%)" | The size after merge is _21.6 kB_. Pull request adds _4.11 kB_ representing an increase of _23.55%_ of the size before merge. |
|
|
20
|
+
| "_Unmodified (4)_" | Sum files in "remaining files" group not impacted by the pull request. |
|
|
21
|
+
| _Total (5)_ | Sum files in "remaining files" group. |
|
|
35
22
|
|
|
36
23
|
# Installation
|
|
37
24
|
|
|
@@ -46,7 +33,7 @@ _generate_file_size_report.mjs_
|
|
|
46
33
|
```js
|
|
47
34
|
import { generateFileSizeReport } from "@jsenv/file-size-impact"
|
|
48
35
|
|
|
49
|
-
export const
|
|
36
|
+
export const fileSizeReport = await generateFileSizeReport({
|
|
50
37
|
log: process.argv.includes("--log"),
|
|
51
38
|
projectDirectoryUrl: new URL("./", import.meta.url),
|
|
52
39
|
trackingConfig: {
|
|
@@ -110,18 +97,23 @@ _report_file_size_impact.mjs_
|
|
|
110
97
|
* This file is executed by file_size_impact.yml GitHub workflow.
|
|
111
98
|
* - it generates file size report before and after merging a pull request
|
|
112
99
|
* - Then, it creates or updates a comment in the pull request
|
|
113
|
-
* See https://github.com/jsenv/file-size-impact#how-it-works
|
|
100
|
+
* See https://github.com/jsenv/workflow/tree/main/packages/jsenv-file-size-impact#how-it-works
|
|
114
101
|
*/
|
|
115
102
|
|
|
116
|
-
import {
|
|
103
|
+
import {
|
|
104
|
+
reportFileSizeImpact,
|
|
105
|
+
readGitHubWorkflowEnv,
|
|
106
|
+
} from "@jsenv/file-size-impact"
|
|
117
107
|
|
|
118
108
|
await reportFileSizeImpact({
|
|
119
109
|
...readGitHubWorkflowEnv(),
|
|
120
110
|
buildCommand: "npm run dist",
|
|
121
|
-
|
|
111
|
+
fileSizeReportModulePath: "./generate_file_size_report.mjs#fileSizeReport",
|
|
122
112
|
})
|
|
123
113
|
```
|
|
124
114
|
|
|
115
|
+
where `fileSizeReport` is the name of the export from _generate_file_size_report.mjs_.
|
|
116
|
+
|
|
125
117
|
## Other tools
|
|
126
118
|
|
|
127
119
|
If you want to use an other tool than GitHub worflow to run the pull request comparison, like Jenkins, there is a few things to do:
|
|
@@ -202,7 +194,7 @@ const fileSizeReport = await generateFileSizeReport({
|
|
|
202
194
|
_trackingConfig_ parameter is an object used to configure group of files you want to track. This parameter is optional with a default value exported in [src/jsenvTrackingConfig.js](./src/jsenvTrackingConfig.js)
|
|
203
195
|
|
|
204
196
|
_trackingConfig_ keys are group names that will appear in the generated comment.
|
|
205
|
-
_trackingConfig_ values are objects associating a pattern to a value. This object is refered as _metaValueMap_ in [@jsenv/url-meta#structuredMetaMap](https://github.com/jsenv/
|
|
197
|
+
_trackingConfig_ values are objects associating a pattern to a value. This object is refered as _metaValueMap_ in [@jsenv/url-meta#structuredMetaMap](https://github.com/jsenv/url-meta#structuredmetamap).
|
|
206
198
|
|
|
207
199
|
For example you can create two groups named _"critical files"_ and _"remaining files"_ like this:
|
|
208
200
|
|
|
@@ -234,7 +226,12 @@ _transformations_ parameter is an object used to transform files content before
|
|
|
234
226
|
You can use this parameter to track file size after gzip compression.
|
|
235
227
|
|
|
236
228
|
```js
|
|
237
|
-
import {
|
|
229
|
+
import {
|
|
230
|
+
generateFileSizeReport,
|
|
231
|
+
raw,
|
|
232
|
+
gzip,
|
|
233
|
+
brotli,
|
|
234
|
+
} from "@jsenv/file-size-impact"
|
|
238
235
|
|
|
239
236
|
await generateFileSizeReport({
|
|
240
237
|
transformations: { raw, gzip, brotli },
|
|
@@ -262,7 +259,12 @@ await generateFileSizeReport({
|
|
|
262
259
|
Finally _transformations_ can be used to add custom _transformations_.
|
|
263
260
|
|
|
264
261
|
```js
|
|
265
|
-
import {
|
|
262
|
+
import {
|
|
263
|
+
generateFileSizeReport,
|
|
264
|
+
raw,
|
|
265
|
+
gzip,
|
|
266
|
+
brotli,
|
|
267
|
+
} from "@jsenv/file-size-impact"
|
|
266
268
|
|
|
267
269
|
await generateFileSizeReport({
|
|
268
270
|
transformations: {
|
|
@@ -320,7 +322,7 @@ await reportFileSizeImpact({
|
|
|
320
322
|
|
|
321
323
|
installCommand: "npm install",
|
|
322
324
|
buildCommand: "npm run build",
|
|
323
|
-
|
|
325
|
+
fileSizeReportModulePath: "./generate_file_size_report.mjs#fileSizeReport",
|
|
324
326
|
|
|
325
327
|
filesOrdering: "size_impact",
|
|
326
328
|
})
|
|
@@ -389,7 +391,10 @@ _commitInGeneratedByInfo_ parameter is a boolean controlling if a link to the co
|
|
|
389
391
|
_readGitHubWorkflowEnv_ is a function meant to be runned inside a GitHub workflow. It returns an object meant to be forwarded to [reportFileSizeImpact](#reportFileSizeImpact).
|
|
390
392
|
|
|
391
393
|
```js
|
|
392
|
-
import {
|
|
394
|
+
import {
|
|
395
|
+
reportFileSizeImpact,
|
|
396
|
+
readGitHubWorkflowEnv,
|
|
397
|
+
} from "@jsenv/file-size-impact"
|
|
393
398
|
|
|
394
399
|
const gitHubWorkflowEnv = readGitHubWorkflowEnv()
|
|
395
400
|
|
|
@@ -402,13 +407,13 @@ _gitHubWorkflowEnv_ object looks like this:
|
|
|
402
407
|
|
|
403
408
|
```js
|
|
404
409
|
const gitHubWorkflowEnv = {
|
|
405
|
-
projectDirectoryUrl: "/home/runner/work/
|
|
410
|
+
projectDirectoryUrl: "/home/runner/work/repository-name",
|
|
406
411
|
githubToken: "xxx",
|
|
407
412
|
repositoryOwner: "jsenv",
|
|
408
|
-
repositoryName: "
|
|
413
|
+
repositoryName: "repository-name",
|
|
409
414
|
pullRequestNumber: 10,
|
|
410
415
|
runLink: {
|
|
411
|
-
url: "https://github.com/jsenv/
|
|
416
|
+
url: "https://github.com/jsenv/repository-name/actions/runs/34",
|
|
412
417
|
text: "workflow-name#34",
|
|
413
418
|
},
|
|
414
419
|
}
|
|
@@ -430,8 +435,8 @@ Read more in [manifestConfig](#manifestConfig) parameter
|
|
|
430
435
|
|
|
431
436
|
# See also
|
|
432
437
|
|
|
433
|
-
- [@jsenv/performance-impact](
|
|
434
|
-
- [@jsenv/lighthouse-impact](
|
|
438
|
+
- [@jsenv/performance-impact](../jsenv-performance-impact): Monitor pull requests impacts but on performance metrics
|
|
439
|
+
- [@jsenv/lighthouse-impact](../jsenv-lighthouse-impact): Monitor pull requests impacts but on lighthouse score
|
|
435
440
|
|
|
436
441
|
# Note about GitHub workflow paths
|
|
437
442
|
|
|
@@ -109,7 +109,7 @@ export const reportFileSizeImpact = async ({
|
|
|
109
109
|
})
|
|
110
110
|
},
|
|
111
111
|
generatedByLink: {
|
|
112
|
-
url: "https://github.com/jsenv/file-size-impact",
|
|
112
|
+
url: "https://github.com/jsenv/workflow/tree/main/packages/jsenv-file-size-impact",
|
|
113
113
|
text: "@jsenv/file-size-impact",
|
|
114
114
|
},
|
|
115
115
|
runLink,
|