Skip to content

Commit 24cdc4a

Browse files
Updates
1 parent fe930b7 commit 24cdc4a

File tree

7 files changed

+54
-23
lines changed

7 files changed

+54
-23
lines changed

src/build_map.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,23 @@ generate_strings() {
4343
random_strings=($(generate_strings 1 16))
4444
clearCache_name=${random_strings[0]}c
4545

46+
echo "[" > deploy/api/build-manifest
47+
echo "" > deploy/api/build-manifest.txt
48+
echo "[" > deploy/api/_just_build-manifest
49+
echo "" > deploy/api/_just_build-manifest.txt
50+
4651
echo "$(cat $GITHUB_ACTION_PATH/src/buildManifest_start.js)" > deploy/_just/static/$BUILD_ID/buildManifest.js
4752
echo "$(cat $GITHUB_ACTION_PATH/src/_justManifest_start.js)" > deploy/_just/static/$BUILD_ID/_justManifest.js
48-
echo "$(cat $GITHUB_ACTION_PATH/src/clearCache.js)" > deploy/_just/static/chunks/$clearCache_name.js
53+
echo "$(cat $GITHUB_ACTION_PATH/src/insert/clearCache.js)" > deploy/_just/static/chunks/$clearCache_name.js
4954
find _just_data -mindepth 1 -print | while read -r path; do
5055
relative_path=${path#_just_data/}
5156
first_line=$(head -n 1 "$path")
5257
if [ -f "$path" ]; then
5358
if [[ "$first_line" != "// _just hide" ||
5459
"$first_line" != "// _just doNotModify+hide" ]]; then
5560
echo " _just_Manifest0.push(\"$relative_path\");" >> deploy/_just/static/$BUILD_ID/_justManifest.js
61+
echo "\"$relative_path\"," >> deploy/api/_just_build-manifest
62+
echo "$relative_path\n" >> deploy/api/_just_build-manifest.txt
5663
fi
5764
fi
5865
done
@@ -140,7 +147,10 @@ find deploy -mindepth 1 -print | while read -r path; do
140147
# Build manifest entry
141148
if [[ "$first_line" != "// _just hide" ||
142149
"$first_line" != "// _just doNotModify+hide" ]]; then
143-
echo " _just_buildManifest0.push({\"type\": \"$type\", \"path\": \"$relative_path\", \"size\": {\"bytes\": $file_size, \"string\": \"$(human_readable_size $file_size)\"}});" >> deploy/_just/static/$BUILD_ID/buildManifest.js
150+
buildManifestJSONString="{\"type\": \"$type\", \"path\": \"$relative_path\", \"size\": {\"bytes\": $file_size, \"string\": \"$(human_readable_size $file_size)\"}}"
151+
echo " _just_buildManifest0.push($buildManifestJSONString);" >> deploy/_just/static/$BUILD_ID/buildManifest.js
152+
echo "$buildManifestJSONString" >> deploy/api/build-manifest
153+
echo "($type) $relative_path - $(human_readable_size $file_size)\n" >> deploy/api/build-manifest.txt
144154
fi
145155
fi
146156

@@ -167,3 +177,7 @@ for html_file in deploy/*.html; do
167177
echo "</body>" >> "$html_file"
168178
echo "</html>" >> "$html_file"
169179
done
180+
181+
# Add API Endpoints
182+
cp deploy/api/_just_build-manifest deploy/api/_just_build-manifest.json
183+
cp deploy/api/build-manifest deploy/api/build-manifest.json

src/clearCache.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/create_api_endpoints.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ BUILD_ID=$(cat .next/BUILD_ID)
3535
echo "$BUILD_ID" > deploy/api/build-id
3636
echo "$BUILD_ID" > deploy/api/build-id.txt
3737
echo "{\"BUILD_ID\": \"$BUILD_ID\"}" > deploy/api/build-id.json
38-
cp .next/build-manifest.json deploy/api/build-manifest
39-
cp .next/build-manifest.json deploy/api/build-manifest.json
40-
cp .next/build-manifest.json deploy/api/build-manifest.txt
38+
cp .next/build-manifest.json deploy/api/next_build-manifest
39+
cp .next/build-manifest.json deploy/api/next_build-manifest.json
40+
cp .next/build-manifest.json deploy/api/next_build-manifest.txt

src/insert/clearCache.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
try {
2+
window._just_Manifest.forEach(item => {
3+
const url = `${window.location.protocol}//${window.location.hostname}/${item}`;
4+
if (caches) {
5+
caches.keys().then(cacheNames => {
6+
cacheNames.forEach(cacheName => {
7+
caches.open(cacheName).then(cache => {
8+
cache.match(url).then(response => {
9+
if (response) {
10+
cache.delete(url);
11+
}
12+
});
13+
});
14+
});
15+
});
16+
}
17+
});
18+
} catch {
19+
document.body.innerHTML = `<iframe src="/_just/e"></iframe>`;
20+
console.error('_just error: it looks like your website\'s scripts override window._just_Manifest.')
21+
}

src/insert/error.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
iframe[src="/_just/e"] {
2+
position: fixed;
3+
z-index: 10000;
4+
top: 0px;
5+
left: 0px;
6+
width: 100%;
7+
height: 100%;
8+
}
9+
body:has(iframe[src="/_just/e"]), html:has(iframe[src="/_just/e"]) {
10+
overflow: hidden !important;
11+
}
File renamed without changes.

src/override_deployment.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ for html_file in deploy/*.html; do # Get all HTML files
3636
for css_file in deploy/_just/*.css; do
3737
echo "<link href=\"_just/$(basename "$css_file")\" rel=\"stylesheet\">" >> "$html_file" # Insert css files as <link href="PATH TO FILE" rel="stylesheet" />
3838
done
39+
echo "<link href=\"_just/e.css\" rel=\"stylesheet\">" >> "$html_file"
3940
echo "$(cat $GITHUB_ACTION_PATH/src/comment.html)" >> "$html_file"
4041
sed -i '/<\/head>/i\ '"$(cat "$html_file")" "$html_file"
4142
done
@@ -48,5 +49,5 @@ if [ ! -f "deploy/404.html" ]; then
4849
cp _just/404.html deploy/404.html
4950
fi
5051

51-
mkdir -p deploy/_just/e/
52-
echo "$(cat $GITHUB_ACTION_PATH/src/error.html)" > deploy/_just/e/1.html
52+
echo "$(cat $GITHUB_ACTION_PATH/src/insert/error.html)" > deploy/_just/e.html
53+
echo "$(cat $GITHUB_ACTION_PATH/src/insert/error.css)" > deploy/_just/e.css

0 commit comments

Comments
 (0)