@@ -28,6 +28,20 @@ mkdir -p deploy/_just/static/$BUILD_ID/
2828
2929echo " $( cat $GITHUB_ACTION_PATH /src/buildManifest_start.js) " > deploy/_just/static/$BUILD_ID /buildManifest.js
3030
31+ # Convert bytes to human-readable format
32+ function human_readable_size {
33+ local size=$1
34+ if [ " $size " -ge 1073741824 ]; then
35+ echo " $( bc <<< " scale=2; $size/1073741824" ) GB"
36+ elif [ " $size " -ge 1048576 ]; then
37+ echo " $( bc <<< " scale=2; $size/1048576" ) MB"
38+ elif [ " $size " -ge 1024 ]; then
39+ echo " $( bc <<< " scale=2; $size/1024" ) KB"
40+ else
41+ echo " $size B"
42+ fi
43+ }
44+
3145echo -e " \n----------------\n\nBuild Map:\n"
3246FILE_ID=1
3347TOTAL_FILES=$( find deploy -mindepth 1 -print | wc -l)
@@ -37,7 +51,7 @@ find deploy -mindepth 1 -print | while read -r path; do
3751
3852 if [ -f " $path " ]; then
3953 case " ${path##* .} " in
40-
54+
4155 # Website files (idk how to name them)
4256 html) type=" HTML" ;;
4357 php) type=" PHP" ;;
@@ -80,20 +94,24 @@ find deploy -mindepth 1 -print | while read -r path; do
8094
8195 # Todo: more files support
8296 * ) type=" Other" ;;
97+
8398 esac
8499 file_size=$( stat -c%s " $path " )
85- TOTAL_SIZE=$(( TOTAL_SIZE + $file_size ))
86- if [ " $FILE_ID " -eq 1 ]; then
87- printf " ┌ %3d B | %s\n" " $file_size " " $relative_path "
88- elif [ " $FILE_ID " -eq " $TOTAL_FILES " ]; then
89- printf " └ %3d B | %s\n" " $file_size " " $relative_path "
90- else
91- printf " ├ %3d B | %s\n" " $file_size " " $relative_path "
92- fi
93- first_line=$( head -n 1 " $js_file " )
94- if [! [ " $first_line " == " // _just hide" ||
95- " $first_line " == " // _just doNotModify+hide" ]]; then
96- echo " _just_buildManifest.push({\" type\" : \" $type \" , \" path\" : \" $relative_path \" , \" size\" : $file_size });" >> deploy/_just/static/$BUILD_ID /buildManifest.js
100+ TOTAL_SIZE=$(( TOTAL_SIZE + file_size))
101+
102+ # Output formatting
103+ if [ " $FILE_ID " -eq 1 ]; then
104+ printf " ┌ %3d B | %s\n" " $( human_readable_size $file_size ) " " $relative_path "
105+ elif [ " $FILE_ID " -eq " $TOTAL_FILES " ]; then
106+ printf " └ %3d B | %s\n" " $( human_readable_size $file_size ) " " $relative_path "
107+ else
108+ printf " ├ %3d B | %s\n" " $( human_readable_size $file_size ) " " $relative_path "
109+ fi
110+
111+ # Build manifest entry
112+ if [[ " $first_line " != " // _just hide" ||
113+ " $first_line " != " // _just doNotModify+hide" ]]; then
114+ echo " _just_buildManifest.push({\" type\" : \" $type \" , \" path\" : \" $relative_path \" , \" size\" : {\" bytes\" : $file_size , \" string\" : $( human_readable_size $file_size ) }});" >> deploy/_just/static/$BUILD_ID /buildManifest.js
97115 fi
98116 fi
99117
102120
103121manifest_size=$( stat -c%s " deploy/_just/static/$BUILD_ID /buildManifest.js" )
104122echo -e " End Build Map\n\n"
105- echo -e " _just/static/$BUILD_ID /buildManifest.js size: $manifest_size bytes \n"
106- echo -e " Total build size: $TOTAL_SIZE bytes \n\n"
123+ echo -e " _just/static/$BUILD_ID /buildManifest.js size: $( human_readable_size $manifest_size ) \n"
124+ echo -e " Total build size: $( human_readable_size $TOTAL_SIZE ) \n\n"
107125echo -e " ----------------\n"
108126echo " $( cat $GITHUB_ACTION_PATH /src/buildManifest_end.js) " >> deploy/_just/static/$BUILD_ID /buildManifest.js
109127
0 commit comments