Skip to content

Commit 210aa0a

Browse files
fix
1 parent 634abb9 commit 210aa0a

File tree

2 files changed

+36
-17
lines changed

2 files changed

+36
-17
lines changed

src/build_map.sh

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ mkdir -p deploy/_just/static/$BUILD_ID/
2828

2929
echo "$(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+
3145
echo -e "\n----------------\n\nBuild Map:\n"
3246
FILE_ID=1
3347
TOTAL_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

@@ -102,8 +120,8 @@ done
102120

103121
manifest_size=$(stat -c%s "deploy/_just/static/$BUILD_ID/buildManifest.js")
104122
echo -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"
107125
echo -e "----------------\n"
108126
echo "$(cat $GITHUB_ACTION_PATH/src/buildManifest_end.js)" >> deploy/_just/static/$BUILD_ID/buildManifest.js
109127

src/modify_deployment.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,13 @@ echo -e "\n----------------\n\nDangerously Inserted Files:\n"
9797

9898
# Dangerously insert files
9999
find _just/dangerously-insert-files/ -type f | while read -r file; do
100-
target_dir="deploy/$(dirname "$file" | sed 's|_just/dangerously-insert-files/||')"
100+
relative_path="${file#_just/dangerously-insert-files/}"
101+
target_dir="deploy/$(dirname "$relative_path")"
101102
mkdir -p "$target_dir"
102103
if [ -f "$target_dir/$(basename "$file")" ]; then
103104
echo "Warning: Failed to insert file \"$target_dir/$(basename "$file")\"."
104105
fi
105-
if [ ! -f "deploy/404.html" ]; then
106+
if [ ! -f "$target_dir/$(basename "$file")" ]; then
106107
cp "$file" "$target_dir/$(basename "$file")"
107108
echo "$target_dir/$(basename "$file")"
108109
fi

0 commit comments

Comments
 (0)