@@ -18,6 +18,9 @@ if (!process.env.BASE_DIST_FILES) {
1818if ( ! process . env . PR_DIST_FILES ) {
1919 throw new Error ( 'Missing or invalid "PR_DIST_FILES" env variable.' ) ;
2020}
21+ if ( ! process . env . GITHUB_HEAD_REF ) {
22+ throw new Error ( 'Missing or invalid "GITHUB_HEAD_REF" env variable.' ) ;
23+ }
2124
2225/**
2326 * Adapted from https://gist.github.com/zentala/1e6f72438796d74531803cc3833c039c?permalink_comment_id=4455218#gistcomment-4455218
@@ -85,14 +88,25 @@ export function main() {
8588 return output ;
8689 }
8790
91+ const displayedPackageRow = new Set ( ) ;
8892 output += 'Thanks for the PR! Here is the difference in size of the dist files between the base and the PR.\n' ;
8993 output += 'Please review the changes and make sure they are expected.\n\n' ;
9094 output += `<table>
9195 <thead><tr><th>File</th><th>Diff (B)</th><th>Diff (%)</th></tr></thead>
9296 <tbody>` ;
9397 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+
94108 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>
96110 <td>
97111 Size: <code>${ formatBytes ( base [ file ] ?. size || 0 ) } </code> → <code>${ formatBytes ( pr [ file ] ?. size || 0 ) } </code><br>
98112 Gzip: <code>${ formatBytes ( base [ file ] ?. size_gz || 0 ) } </code> → <code>${ formatBytes ( pr [ file ] ?. size_gz || 0 ) } </code><br>
0 commit comments