@@ -110,23 +110,26 @@ async function run() {
110
110
const md = [ "" , `#### ${ name } ` , "" ] ;
111
111
const data = [ name , bytesToSize ( totalDiffSize ) ] ;
112
112
113
+ if ( totalDiffSize - totalSize === 0 ) return ;
114
+
113
115
if ( hasDiff ) {
114
116
// If a diff path was provided and the component folder doesn't exist,
115
117
// report that the compiled assets were removed
116
118
if (
117
119
! existsSync ( join ( diffPath , "components" , name ) ) ||
118
120
( totalSize === 0 && totalDiffSize > 0 )
119
121
) {
120
- data . push ( "🚨 package deleted/moved/renamed" ) ;
122
+ data . push ( "🚨 deleted, moved, or renamed" ) ;
123
+ summaryTable . push ( data ) ;
121
124
} else if ( totalSize > 0 && totalDiffSize === 0 ) {
122
- data . push ( "🎉 new package" ) ;
123
- } else {
125
+ data . push ( "🎉 new" ) ;
126
+ summaryTable . push ( data ) ;
127
+ } else if ( bytesToSize ( Math . abs ( totalDiffSize - totalSize ) ) !== "< 0.01 KB" ) {
124
128
data . push ( printChange ( totalDiffSize - totalSize ) ) ;
129
+ summaryTable . push ( data ) ;
125
130
}
126
131
}
127
132
128
- summaryTable . push ( data ) ;
129
-
130
133
md . push (
131
134
...[
132
135
[ "File" , "Size" , ...( hasDiff ? [ "Base" , "Δ" ] : [ ] ) ] ,
@@ -137,7 +140,7 @@ async function run() {
137
140
...( hasDiff
138
141
? [
139
142
bytesToSize ( totalDiffSize ) ,
140
- `${ printChange ( totalDiffSize - totalSize ) } (${ printPercentChange ( ( totalDiffSize - totalSize ) / totalSize ) } )` ,
143
+ `${ printChange ( totalDiffSize - totalSize ) } ${ totalDiffSize - totalSize !== 0 ? ` (${ printPercentChange ( ( totalDiffSize - totalSize ) / totalSize ) } )` : "" } ` ,
141
144
]
142
145
: [ ] ) ,
143
146
] ,
@@ -157,7 +160,7 @@ async function run() {
157
160
byteSize === 0 && diffByteSize > 0 ? "**removed**" : bytesToSize ( byteSize ) ,
158
161
...( hasDiff ? [
159
162
bytesToSize ( diffByteSize ) ,
160
- `${ printChange ( diffByteSize - byteSize ) } (${ printPercentChange ( ( diffByteSize - byteSize ) / byteSize ) } )` ,
163
+ `${ printChange ( diffByteSize - byteSize ) } ${ diffByteSize - byteSize !== 0 ? ` (${ printPercentChange ( ( diffByteSize - byteSize ) / byteSize ) } )` : "" } ` ,
161
164
] : [ ] ) ,
162
165
]
163
166
] ;
@@ -177,7 +180,14 @@ async function run() {
177
180
summary . push ( ...summaryTable . map ( ( row ) => `| ${ row . join ( " | " ) } |` ) ) ;
178
181
}
179
182
180
- markdown . push ( "" , `<small><sup>*</sup> <em>An ASCII character in UTF-8 is 8 bits or 1 byte.</em></small>` ) ;
183
+ markdown . push (
184
+ "" ,
185
+ "<small>" ,
186
+ "* <em>Size determined by adding together the size of the main file (index.css) for all packages in the library.</em><br/>" ,
187
+ "* <em>Results are not gzipped or minified.</em><br/>" ,
188
+ "* <em>An ASCII character in UTF-8 is 8 bits or 1 byte.</em>" ,
189
+ "</small>"
190
+ ) ;
181
191
182
192
// --------------- Start Comment ---------------
183
193
if ( shouldAddComment ) {
@@ -255,30 +265,38 @@ const printPercentChange = function (delta) {
255
265
256
266
/**
257
267
*
258
- * @param {Map<string, number> } pathMap
259
- * @param {Map<string, number> } diffMap
260
- * @returns {string }
268
+ * @param {Map<string, Map<string, { byteSize: number, diffByteSize: number }>> } COMPONENTS
269
+ * @returns {Array<{ name: string, totalSize: number, totalDiffSize: number, hasChange: boolean, fileMap: Map<string, { byteSize: number, diffByteSize: number }>}> }
261
270
*/
262
271
const makeTable = function ( COMPONENTS ) {
263
272
const sections = [ ] ;
264
273
265
274
/** Next convert that component data into a comment */
266
275
COMPONENTS . forEach ( ( fileMap , componentName ) => {
267
- const totalSize = [ ...fileMap . values ( ) ] . reduce (
268
- ( acc , { byteSize } ) => acc + byteSize ,
276
+ const mainFileOnly = [ ...fileMap . keys ( ) ] . filter ( ( file ) => file . endsWith ( "index.css" ) ) ;
277
+ const totalSize = mainFileOnly . reduce (
278
+ ( acc , filename ) => {
279
+ const { byteSize = 0 } = fileMap . get ( filename ) ;
280
+ return acc + byteSize ;
281
+ } ,
269
282
0
270
283
) ;
271
- const totalDiffSize = [ ...fileMap . values ( ) ] . reduce (
272
- ( acc , { diffByteSize = 0 } ) => acc + diffByteSize ,
284
+ const totalDiffSize = mainFileOnly . reduce (
285
+ ( acc , filename ) => {
286
+ const { diffByteSize = 0 } = fileMap . get ( filename ) ;
287
+ return acc + diffByteSize ;
288
+ } ,
273
289
0
274
290
) ;
275
291
292
+ const hasChange = fileMap . size > 0 && [ ...fileMap . values ( ) ] . some ( ( { byteSize, diffByteSize } ) => byteSize !== diffByteSize ) ;
293
+
276
294
/**
277
295
* We don't need to report on components that haven't changed unless they're new or removed
278
296
*/
279
297
if ( totalSize === totalDiffSize ) return ;
280
298
281
- sections . push ( { name : componentName , totalSize, totalDiffSize, fileMap } ) ;
299
+ sections . push ( { name : componentName , totalSize, totalDiffSize, hasChange , fileMap } ) ;
282
300
} ) ;
283
301
284
302
return sections ;
0 commit comments