@jsenv/file-size-impact 13.0.2 → 14.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/file-size-impact",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "14.0.0",
|
|
4
4
|
"description": "Add files size impact into pull requests",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@jsenv/dynamic-import-worker": "1.1.0",
|
|
35
|
-
"@jsenv/filesystem": "4.1.
|
|
35
|
+
"@jsenv/filesystem": "4.1.9",
|
|
36
36
|
"@jsenv/github-pull-request-impact": "1.7.1",
|
|
37
|
-
"@jsenv/log": "3.3.
|
|
37
|
+
"@jsenv/log": "3.3.3",
|
|
38
38
|
"@jsenv/urls": "1.2.8"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/readme.md
CHANGED
|
@@ -69,7 +69,7 @@ _.github/workflows/file_size_impact.yml_
|
|
|
69
69
|
|
|
70
70
|
name: file size impact
|
|
71
71
|
|
|
72
|
-
on:
|
|
72
|
+
on: pull_request
|
|
73
73
|
|
|
74
74
|
jobs:
|
|
75
75
|
file_size_impact:
|
|
@@ -77,11 +77,11 @@ jobs:
|
|
|
77
77
|
name: file size impact
|
|
78
78
|
steps:
|
|
79
79
|
- name: Setup git
|
|
80
|
-
uses: actions/checkout@
|
|
80
|
+
uses: actions/checkout@v3
|
|
81
81
|
- name: Setup node
|
|
82
|
-
uses: actions/setup-node@
|
|
82
|
+
uses: actions/setup-node@v3
|
|
83
83
|
with:
|
|
84
|
-
node-version: "
|
|
84
|
+
node-version: "18.3.0"
|
|
85
85
|
- name: Setup npm
|
|
86
86
|
run: npm install
|
|
87
87
|
- name: Report file size impact
|
|
@@ -101,11 +101,11 @@ _report_file_size_impact.mjs_
|
|
|
101
101
|
*/
|
|
102
102
|
|
|
103
103
|
import {
|
|
104
|
-
|
|
104
|
+
reportFileSizeImpactInGitHubPullRequest,
|
|
105
105
|
readGitHubWorkflowEnv,
|
|
106
106
|
} from "@jsenv/file-size-impact"
|
|
107
107
|
|
|
108
|
-
await
|
|
108
|
+
await reportFileSizeImpactInGitHubPullRequest({
|
|
109
109
|
...readGitHubWorkflowEnv(),
|
|
110
110
|
buildCommand: "npm run dist",
|
|
111
111
|
fileSizeReportUrl: new URL("./file_size.mjs#fileSizeReport", import.meta.url),
|
|
@@ -139,13 +139,13 @@ node ./report_file_size_impact.mjs
|
|
|
139
139
|
|
|
140
140
|
### 2. Adjust _report_file_size_impact.mjs_
|
|
141
141
|
|
|
142
|
-
When outside a GitHub workflow, you cannot use _readGitHubWorkflowEnv()_. It means you must pass several parameters to
|
|
142
|
+
When outside a GitHub workflow, you cannot use _readGitHubWorkflowEnv()_. It means you must pass several parameters to _reportFileSizeImpactInGitHubPullRequest_. The example below assume code is executed by Travis.
|
|
143
143
|
|
|
144
144
|
```diff
|
|
145
|
-
- import {
|
|
146
|
-
+ import {
|
|
145
|
+
- import { reportFileSizeImpactInGitHubPullRequest, readGitHubWorkflowEnv } from "@jsenv/file-size-impact"
|
|
146
|
+
+ import { reportFileSizeImpactInGitHubPullRequest } from "@jsenv/file-size-impact"
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
reportFileSizeImpactInGitHubPullRequest({
|
|
149
149
|
- ...readGitHubWorkflowEnv(),
|
|
150
150
|
+ rootDirectoryUrl: process.env.TRAVIS_BUILD_DIR,
|
|
151
151
|
+ repositoryOwner: process.env.TRAVIS_REPO_SLUG.split("/")[0],
|
|
@@ -284,9 +284,9 @@ _manifestConfig_ parameter is an object used to configure the location of an opt
|
|
|
284
284
|
This parameter reuses the shape of [trackingConfig](#trackingConfig) (associating pattern + value).
|
|
285
285
|
|
|
286
286
|
```js
|
|
287
|
-
import {
|
|
287
|
+
import { reportFileSizeImpactInGitHubPullRequest } from "@jsenv/file-size-impact"
|
|
288
288
|
|
|
289
|
-
await
|
|
289
|
+
await reportFileSizeImpactInGitHubPullRequest({
|
|
290
290
|
manifestConfig: {
|
|
291
291
|
"./dist/**/manifest.json": true,
|
|
292
292
|
},
|
|
@@ -296,9 +296,9 @@ await reportFileSizeImpact({
|
|
|
296
296
|
You can disable manifest files handling by passing `null`.
|
|
297
297
|
|
|
298
298
|
```js
|
|
299
|
-
import {
|
|
299
|
+
import { reportFileSizeImpactInGitHubPullRequest } from "@jsenv/file-size-impact"
|
|
300
300
|
|
|
301
|
-
await
|
|
301
|
+
await reportFileSizeImpactInGitHubPullRequest({
|
|
302
302
|
manifestConfig: {
|
|
303
303
|
"./dist/**/manifest.json": null,
|
|
304
304
|
},
|
|
@@ -307,14 +307,17 @@ await reportFileSizeImpact({
|
|
|
307
307
|
|
|
308
308
|
In that case _manifest.json_ will be handled as a regular file.
|
|
309
309
|
|
|
310
|
-
#
|
|
310
|
+
# reportFileSizeImpactInGitHubPullRequest
|
|
311
311
|
|
|
312
|
-
|
|
312
|
+
_reportFileSizeImpactInGitHubPullRequest_ is an async function that will analyse a pull request file size impact and post a comment with the result of this analysis.
|
|
313
313
|
|
|
314
314
|
```js
|
|
315
|
-
import {
|
|
315
|
+
import {
|
|
316
|
+
reportFileSizeImpactInGitHubPullRequest,
|
|
317
|
+
raw,
|
|
318
|
+
} from "@jsenv/file-size-impact"
|
|
316
319
|
|
|
317
|
-
await
|
|
320
|
+
await reportFileSizeImpactInGitHubPullRequest({
|
|
318
321
|
logLevel: "info",
|
|
319
322
|
|
|
320
323
|
rootDirectoryUrl: "file:///directory",
|
|
@@ -372,9 +375,9 @@ This parameter is returned by [readGitHubWorkflowEnv](#readGitHubWorkflowEnv) me
|
|
|
372
375
|
Inside an other workflow, you can pass your own _runLink_. As in the example below where it is assumed that script is runned by jenkins.
|
|
373
376
|
|
|
374
377
|
```js
|
|
375
|
-
import {
|
|
378
|
+
import { reportFileSizeImpactInGitHubPullRequest } from "@jsenv/file-size-impact"
|
|
376
379
|
|
|
377
|
-
await
|
|
380
|
+
await reportFileSizeImpactInGitHubPullRequest({
|
|
378
381
|
runLink: {
|
|
379
382
|
url: process.env.BUILD_URL,
|
|
380
383
|
text: `${process.env.JOB_NAME}#${process.env.BUILD_ID}`,
|
|
@@ -390,17 +393,17 @@ _commitInGeneratedByInfo_ parameter is a boolean controlling if a link to the co
|
|
|
390
393
|
|
|
391
394
|
# readGitHubWorkflowEnv
|
|
392
395
|
|
|
393
|
-
_readGitHubWorkflowEnv_ is a function meant to be runned inside a GitHub workflow. It returns an object meant to be forwarded to [
|
|
396
|
+
_readGitHubWorkflowEnv_ is a function meant to be runned inside a GitHub workflow. It returns an object meant to be forwarded to [reportFileSizeImpactInGitHubPullRequest](#reportFileSizeImpactInGitHubPullRequest).
|
|
394
397
|
|
|
395
398
|
```js
|
|
396
399
|
import {
|
|
397
|
-
|
|
400
|
+
reportFileSizeImpactInGitHubPullRequest,
|
|
398
401
|
readGitHubWorkflowEnv,
|
|
399
402
|
} from "@jsenv/file-size-impact"
|
|
400
403
|
|
|
401
404
|
const gitHubWorkflowEnv = readGitHubWorkflowEnv()
|
|
402
405
|
|
|
403
|
-
await
|
|
406
|
+
await reportFileSizeImpactInGitHubPullRequest({
|
|
404
407
|
...gitHubWorkflowEnv,
|
|
405
408
|
})
|
|
406
409
|
```
|
package/src/main.js
CHANGED
|
@@ -5,4 +5,4 @@ export { transform as raw } from "./rawTransformation.js"
|
|
|
5
5
|
export { transform as gzip } from "./gzipTransformation.js"
|
|
6
6
|
export { transform as brotli } from "./brotliTransformation.js"
|
|
7
7
|
export { generateFileSizeReport } from "./generateFileSizeReport.js"
|
|
8
|
-
export {
|
|
8
|
+
export { reportFileSizeImpactInGitHubPullRequest } from "./report_file_size_impact_in_github_pr.js"
|
|
@@ -5,7 +5,7 @@ import { importOneExportFromFile } from "@jsenv/dynamic-import-worker"
|
|
|
5
5
|
import { formatComment } from "./internal/formatComment.js"
|
|
6
6
|
import { jsenvCommentParameters } from "./internal/jsenvCommentParameters.js"
|
|
7
7
|
|
|
8
|
-
export const
|
|
8
|
+
export const reportFileSizeImpactInGitHubPullRequest = async ({
|
|
9
9
|
logLevel,
|
|
10
10
|
commandLogs,
|
|
11
11
|
cancellationToken,
|