@jsenv/file-size-impact 12.0.0 → 12.1.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": "12.
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "Add files size impact into pull requests",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
"node": ">=14.17.0"
|
|
12
12
|
},
|
|
13
13
|
"publishConfig": {
|
|
14
|
-
"access": "public"
|
|
15
|
-
"registry": "https://registry.npmjs.org"
|
|
14
|
+
"access": "public"
|
|
16
15
|
},
|
|
17
16
|
"type": "module",
|
|
18
17
|
"exports": {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { comparePathnames } from "@jsenv/filesystem"
|
|
2
|
+
|
|
3
|
+
import { manifestToMappings } from "./manifest.js"
|
|
2
4
|
|
|
3
5
|
export const compareTwoFileSizeReports = ({
|
|
4
6
|
afterMergeFileSizeReport,
|
|
@@ -146,31 +148,6 @@ const compareTwoGroups = (beforeMergeGroup, afterMergeGroup) => {
|
|
|
146
148
|
}
|
|
147
149
|
}
|
|
148
150
|
|
|
149
|
-
const ABSTRACT_DIRECTORY_URL = "file:///directory/"
|
|
150
|
-
|
|
151
|
-
const manifestToMappings = (manifestMap) => {
|
|
152
|
-
const mappings = {}
|
|
153
|
-
Object.keys(manifestMap).forEach((manifestRelativeUrl) => {
|
|
154
|
-
const manifest = manifestMap[manifestRelativeUrl]
|
|
155
|
-
const manifestAbstractUrl = resolveUrl(manifestRelativeUrl, ABSTRACT_DIRECTORY_URL)
|
|
156
|
-
Object.keys(manifest).forEach((manifestKey) => {
|
|
157
|
-
const manifestValue = manifest[manifestKey]
|
|
158
|
-
const manifestKeyAsAbstractUrl = resolveUrl(manifestKey, manifestAbstractUrl)
|
|
159
|
-
const manifestValueAsAbstractUrl = resolveUrl(manifestValue, manifestAbstractUrl)
|
|
160
|
-
const manifestKeyAsRelativeUrl = urlToRelativeUrl(
|
|
161
|
-
manifestKeyAsAbstractUrl,
|
|
162
|
-
ABSTRACT_DIRECTORY_URL,
|
|
163
|
-
)
|
|
164
|
-
const manifestValueAsRelativeUrl = urlToRelativeUrl(
|
|
165
|
-
manifestValueAsAbstractUrl,
|
|
166
|
-
ABSTRACT_DIRECTORY_URL,
|
|
167
|
-
)
|
|
168
|
-
mappings[manifestKeyAsRelativeUrl] = manifestValueAsRelativeUrl
|
|
169
|
-
})
|
|
170
|
-
})
|
|
171
|
-
return mappings
|
|
172
|
-
}
|
|
173
|
-
|
|
174
151
|
const manifestKeyFromRelativeUrl = (relativeUrl, mappings) => {
|
|
175
152
|
return Object.keys(mappings).find((keyCandidate) => {
|
|
176
153
|
return mappings[keyCandidate] === relativeUrl
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import { formatSize } from "./formatSize.js"
|
|
2
|
+
import { manifestToMappings } from "./manifest.js"
|
|
2
3
|
|
|
3
4
|
export const formatFileSizeReportForLog = (fileSizeReport) => {
|
|
4
5
|
const { groups } = fileSizeReport
|
|
5
6
|
|
|
6
7
|
const groupMessages = Object.keys(groups).map((groupName) => {
|
|
7
|
-
const { fileMap } = groups[groupName]
|
|
8
|
+
const { fileMap, manifestMap } = groups[groupName]
|
|
8
9
|
|
|
10
|
+
const mappings = manifestToMappings(manifestMap)
|
|
9
11
|
const fileMessages = Object.keys(fileMap).map((fileRelativeUrl) => {
|
|
12
|
+
const fileDisplayed = mappings[fileRelativeUrl] || fileRelativeUrl
|
|
10
13
|
const file = fileMap[fileRelativeUrl]
|
|
11
14
|
const { sizeMap } = file
|
|
12
15
|
const sizeNames = Object.keys(sizeMap)
|
|
13
16
|
if (sizeNames.length === 1) {
|
|
14
|
-
return `${
|
|
17
|
+
return `${fileDisplayed}: ${formatSize(sizeMap[sizeNames[0]])}`
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
const sizesFormatted = sizeNames.map((sizeName) => {
|
|
18
21
|
return `${sizeName}: ${formatSize(sizeMap[sizeName])}`
|
|
19
22
|
})
|
|
20
|
-
return `${
|
|
23
|
+
return `${fileDisplayed}: { ${sizesFormatted.join(`, `)} }`
|
|
21
24
|
})
|
|
22
25
|
|
|
23
26
|
return `${groupName}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { resolveUrl, urlToRelativeUrl } from "@jsenv/filesystem"
|
|
2
|
+
|
|
3
|
+
export const manifestToMappings = (manifestMap) => {
|
|
4
|
+
const mappings = {}
|
|
5
|
+
Object.keys(manifestMap).forEach((manifestRelativeUrl) => {
|
|
6
|
+
const manifest = manifestMap[manifestRelativeUrl]
|
|
7
|
+
const manifestAbstractUrl = resolveUrl(manifestRelativeUrl, ABSTRACT_DIRECTORY_URL)
|
|
8
|
+
Object.keys(manifest).forEach((manifestKey) => {
|
|
9
|
+
const manifestValue = manifest[manifestKey]
|
|
10
|
+
const manifestKeyAsAbstractUrl = resolveUrl(manifestKey, manifestAbstractUrl)
|
|
11
|
+
const manifestValueAsAbstractUrl = resolveUrl(manifestValue, manifestAbstractUrl)
|
|
12
|
+
const manifestKeyAsRelativeUrl = urlToRelativeUrl(
|
|
13
|
+
manifestKeyAsAbstractUrl,
|
|
14
|
+
ABSTRACT_DIRECTORY_URL,
|
|
15
|
+
)
|
|
16
|
+
const manifestValueAsRelativeUrl = urlToRelativeUrl(
|
|
17
|
+
manifestValueAsAbstractUrl,
|
|
18
|
+
ABSTRACT_DIRECTORY_URL,
|
|
19
|
+
)
|
|
20
|
+
mappings[manifestKeyAsRelativeUrl] = manifestValueAsRelativeUrl
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
return mappings
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const ABSTRACT_DIRECTORY_URL = "file:///directory/"
|