@@ -18,6 +18,9 @@ if (!process.env.BASE_DIST_FILES) {
18
18
if ( ! process . env . PR_DIST_FILES ) {
19
19
throw new Error ( 'Missing or invalid "PR_DIST_FILES" env variable.' ) ;
20
20
}
21
+ if ( ! process . env . GITHUB_HEAD_REF ) {
22
+ throw new Error ( 'Missing or invalid "GITHUB_HEAD_REF" env variable.' ) ;
23
+ }
21
24
22
25
/**
23
26
* Adapted from https://gist.github.com/zentala/1e6f72438796d74531803cc3833c039c?permalink_comment_id=4455218#gistcomment-4455218
@@ -85,14 +88,25 @@ export function main() {
85
88
return output ;
86
89
}
87
90
91
+ const displayedPackageRow = new Set ( ) ;
88
92
output += 'Thanks for the PR! Here is the difference in size of the dist files between the base and the PR.\n' ;
89
93
output += 'Please review the changes and make sure they are expected.\n\n' ;
90
94
output += `<table>
91
95
<thead><tr><th>File</th><th>Diff (B)</th><th>Diff (%)</th></tr></thead>
92
96
<tbody>` ;
93
97
for ( const [ file , details ] of files . entries ( ) ) {
98
+ const isBridge = file . includes ( 'src/Bridge' ) ;
99
+ const packageName = file . split ( '/' ) [ 1 ] ;
100
+ const bridgeName = isBridge ? file . split ( '/' ) [ 4 ] : '' ;
101
+ const fileShort = file . replace ( isBridge ? `src/${ packageName } /src/Bridge/${ bridgeName } /assets/dist/` : `src/${ packageName } /assets/dist/` , '' ) ;
102
+ const row = isBridge ? `${ packageName } (Bridge ${ bridgeName } )` : packageName ;
103
+ if ( ! displayedPackageRow . has ( row ) ) {
104
+ displayedPackageRow . add ( row ) ;
105
+ output += `<tr><td colspan="3"><b>${ row } </b></td></tr>` ;
106
+ }
107
+
94
108
output += `<tr>
95
- <td><code>${ file } </code> ${ details . state === 'added' ? '(new)' : ( details . state === 'removed' ? '(deleted)' : '' ) } </td>
109
+ <td><code>${ fileShort } </code> ${ details . state === 'added' ? '(new)' : ( details . state === 'removed' ? '(deleted)' : '' ) } </td>
96
110
<td>
97
111
Size: <code>${ formatBytes ( base [ file ] ?. size || 0 ) } </code> → <code>${ formatBytes ( pr [ file ] ?. size || 0 ) } </code><br>
98
112
Gzip: <code>${ formatBytes ( base [ file ] ?. size_gz || 0 ) } </code> → <code>${ formatBytes ( pr [ file ] ?. size_gz || 0 ) } </code><br>
0 commit comments