Skip to content

Commit 0b3a000

Browse files
Updates
1 parent fb863e1 commit 0b3a000

File tree

7 files changed

+100
-43
lines changed

7 files changed

+100
-43
lines changed

src/buildManifest_start.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1 @@
1-
/*
2-
3-
MIT License
4-
5-
Copyright (c) 2025 JustDeveloper <https://justdeveloper.is-a.dev/>
6-
7-
Permission is hereby granted, free of charge, to any person obtaining a copy
8-
of this software and associated documentation files (the "Software"), to deal
9-
in the Software without restriction, including without limitation the rights
10-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11-
copies of the Software, and to permit persons to whom the Software is
12-
furnished to do so, subject to the following conditions:
13-
14-
The above copyright notice and this permission notice shall be included in all
15-
copies or substantial portions of the Software.
16-
17-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23-
SOFTWARE.
24-
25-
*/
26-
271
const _just_buildManifest = [];

src/build_map.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ find deploy -mindepth 1 -print | while read -r path; do
3737

3838
if [ -f "$path" ]; then
3939
case "${path##*.}" in
40+
41+
# Website files (idk how to name them)
4042
html) type="HTML" ;;
4143
php) type="PHP" ;;
4244
css) type="CSS" ;;
@@ -46,6 +48,7 @@ find deploy -mindepth 1 -print | while read -r path; do
4648
xml) type="XML" ;;
4749
webmanifest) type="Webmanifest" ;;
4850

51+
# Media
4952
png) type="Image/Png" ;;
5053
svg) type="Image/SVG" ;;
5154
jpeg|jpg) type="Image/Jpeg" ;;
@@ -54,27 +57,28 @@ find deploy -mindepth 1 -print | while read -r path; do
5457
gif) type="Image/GIF" ;;
5558
heic) type="Image/HEIC" ;;
5659
ico) type="Favicon" ;;
57-
5860
mp4) type="Video/MP4" ;;
5961
mov) type="Video/Mov" ;;
6062
webm) type="Video/Webm" ;;
61-
62-
otf) type="Font/OTF" ;;
63-
woff) type="Font/WOFF" ;;
64-
woff2) type="Font/WOFF2" ;;
65-
6663
m4a) type="Audio/M4A" ;;
6764
mp2) type="Audio/MP2" ;;
6865
mp3) type="Audio/MP3" ;;
6966
ogg) type="Audio/OGG" ;;
7067
wav) type="Audio/WAV" ;;
7168
wma) type="Audio/WMA" ;;
7269

70+
# Fonts
71+
otf) type="Font/OTF" ;;
72+
woff) type="Font/WOFF" ;;
73+
woff2) type="Font/WOFF2" ;;
74+
75+
# Archive
7376
7z) type="Archive/7z" ;;
7477
tar) type="Archive/TAR" ;;
7578
rar) type="Archive/RAR" ;;
7679
zip) type="Archive/ZIP" ;;
7780

81+
# Todo: more files support
7882
*) type="Other" ;;
7983
esac
8084
file_size=$(stat -c%s "$path")
@@ -86,7 +90,11 @@ find deploy -mindepth 1 -print | while read -r path; do
8690
else
8791
printf "├ %3d B | %s\n" "$file_size" "$relative_path"
8892
fi
89-
echo " _just_buildManifest.push({\"type\": \"$type\", \"path\": \"$relative_path\", \"size\": $file_size});" >> deploy/_just/static/$BUILD_ID/buildManifest.js
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
97+
fi
9098
fi
9199

92100
FILE_ID=$((FILE_ID + 1))

src/checks.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# SOFTWARE.
2222

2323
# Directory & File Checks
24+
2425
for dir in "_just" "_just/js" "_just/style"; do
2526
if [ ! -d "$dir" ]; then
2627
echo -e "\n----------------\n\n_just Checks:\n"

src/create_api_endpoints.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@
2121
# SOFTWARE.
2222

2323
# (fake) API Endpoints
24+
25+
# Check
26+
if [ -d "deploy/api" ]; then
27+
echo "Error: Your website have api directory in the root. Please remove it to proceed." >&2
28+
exit 1
29+
fi
30+
2431
mkdir -p deploy/api/
32+
33+
# Get Next.js data and copy it to API Endpoints
2534
BUILD_ID=$(cat .next/BUILD_ID)
2635
echo "$BUILD_ID" > deploy/api/build-id
2736
echo "$BUILD_ID" > deploy/api/build-id.txt

src/modify_deployment.sh

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,79 @@
2121
# SOFTWARE.
2222

2323
# Modify Deployment
24+
2425
if [ -d "deploy/_just" ]; then
25-
echo "Error: Your website have _just directory in the root. Please remove it to proceed." >&2
26+
echo "Error: Your website has a _just directory in the root. Please remove it to proceed." >&2
2627
exit 1
2728
fi
29+
2830
mkdir -p deploy/_just/
29-
FILE_ID=1
3031
echo -e "\n----------------\n\n_just Chunks:\n"
32+
33+
# Merging logic
34+
merged_file="deploy/_just/merged.js"
35+
> "$merged_file"
36+
for file in _just/js/*; do
37+
file_size=$(stat -c%s "$file")
38+
if [[ $file_size -gt 51200 ]]; then # Check if file is greater than 50KB
39+
cat "$file" >> "$merged_file"
40+
echo -e "\n" >> "$merged_file" # Add new line after each file
41+
fi
42+
done
43+
44+
# Check if merged file is less than 128KB
45+
while [[ $(stat -c%s "$merged_file") -lt 131072 ]]; do
46+
largest_file=$(ls -S "$merged_file" | head -n 1) # Get the largest file
47+
sed -i "/$(basename "$largest_file")/d" "$merged_file" # Remove the largest file from merged file
48+
done
49+
50+
# Move unmerged files to _just/js/
3151
for file in _just/js/*; do
52+
first_line=$(head -n 1 "$file")
53+
if [[ $first_line == "// _just ignore"* ]]; then
54+
continue
55+
fi
56+
if [[ ! -f "$merged_file" || $(stat -c%s "$merged_file") -lt 131072 ]]; then
57+
cp "$file" "_just/js/$(basename "$file")" # Keep unmerged files
58+
fi
59+
done
60+
61+
# Move js files to deploy/_just/
62+
FILE_ID=1
63+
for file in _just/js/*; do
64+
first_line=$(head -n 1 "$file")
65+
if [[ $first_line == "// _just ignore"* ]]; then
66+
continue
67+
fi
3268
cp "$file" "deploy/_just/${FILE_ID}.js"
3369
echo "_just/${FILE_ID}.js"
3470
FILE_ID=$((FILE_ID + 1))
3571
done
72+
73+
# Move css files to deploy/_just/
3674
FILE_ID=1
3775
for file in _just/style/*; do
3876
cp "$file" "deploy/_just/${FILE_ID}.css"
3977
echo "_just/${FILE_ID}.css"
4078
FILE_ID=$((FILE_ID + 1))
4179
done
80+
4281
echo -e "\nEnd _just Chunks\n"
4382
echo -e "----------------\n"
4483
echo -e "\n----------------\n\nDangerously Inserted Files:\n"
45-
for file in _just/dangerously-insert-files/*; do
46-
cp "$file" "deploy/$(basename "$file")"
47-
echo "$(basename "$file")"
84+
85+
# Dangerously insert files
86+
find _just/dangerously-insert-files/ -type f | while read -r file; do
87+
target_dir="deploy/$(dirname "$file" | sed 's|_just/dangerously-insert-files/||')"
88+
mkdir -p "$target_dir"
89+
if [ -f "$target_dir/$(basename "$file")" ]; then
90+
echo "Warning: Failed to insert file \"$target_dir/$(basename "$file")\"."
91+
fi
92+
if [ ! -f "deploy/404.html" ]; then
93+
cp "$file" "$target_dir/$(basename "$file")"
94+
echo "$target_dir/$(basename "$file")"
95+
fi
4896
done
97+
4998
echo -e "\nEnd Dangerously Inserted Files\n"
50-
echo -e "----------------\n"
99+
echo -e "----------------\n"

src/override_deployment.sh

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,29 @@
2121
# SOFTWARE.
2222

2323
# Override Deployment
24-
for html_file in deploy/*.html; do
24+
25+
for html_file in deploy/*.html; do # Get all HTML files
2526
for js_file in deploy/_just/*.js; do
26-
echo "<script src=\"_just/$(basename "$js_file")\"></script>" >> "$html_file"
27+
first_line=$(head -n 1 "$js_file")
28+
if [[ "$first_line" == "// _just doNotInsert" ||
29+
"$first_line" == "// _just hide" ||
30+
"$first_line" == "// _just doNotModify+doNotInsert" ||
31+
"$first_line" == "// _just doNotModify+hide" ]]; then
32+
continue # Do not insert file
33+
fi
34+
echo "<script src=\"_just/$(basename "$js_file")\"></script>" >> "$html_file" # Insert js files as <script src="PATH TO FILE" />
2735
done
2836
for css_file in deploy/_just/*.css; do
29-
echo "<link href=\"_just/$(basename "$css_file")\" rel=\"stylesheet\">" >> "$html_file"
37+
echo "<link href=\"_just/$(basename "$css_file")\" rel=\"stylesheet\">" >> "$html_file" # Insert css files as <link href="PATH TO FILE" rel="stylesheet" />
3038
done
3139
echo "$(cat $GITHUB_ACTION_PATH/src/comment.html)" >> "$html_file"
3240
sed -i '/<\/head>/i\ '"$(cat "$html_file")" "$html_file"
3341
done
34-
cp _just/404.html deploy/404.html
42+
43+
# Insert custom 404.html file
44+
if [ -f "deploy/404.html" ]; then
45+
echo "Warning: Your website already has a 404.html file, _just/404.html won't be inserted."
46+
fi
47+
if [ ! -f "deploy/404.html" ]; then
48+
cp _just/404.html deploy/404.html
49+
fi

src/prepare_deployment.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
# SOFTWARE.
2222

2323
# Prepare Deployment
24+
2425
mkdir -p deploy
2526
cp -r .next/server/pages/* deploy/
2627
mkdir -p deploy/_next/static/

0 commit comments

Comments
 (0)