Skip to content

Commit 70cf59e

Browse files
committed
Add script to predownload offline build dependencies
1 parent a1cf7a0 commit 70cf59e

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
cd "$(dirname "$0")/.."
5+
6+
cache_dir="target/sqlpage_artefacts"
7+
mkdir -p "$cache_dir"
8+
9+
echo "[1/3] Prefetching Cargo dependencies"
10+
cargo fetch --locked
11+
12+
echo "[2/3] Prefetching npm dependencies"
13+
npm ci --ignore-scripts --no-audit
14+
if [ -f tests/end-to-end/package-lock.json ]; then
15+
(
16+
cd tests/end-to-end
17+
npm ci --ignore-scripts --no-audit
18+
)
19+
fi
20+
21+
echo "[3/3] Prefetching raw HTTP assets used by build.rs"
22+
mapfile -t urls < <(
23+
{
24+
rg -o --no-filename 'https://[[:alnum:]][[:alnum:].-]*/[^" )]+' build.rs
25+
rg -o --no-filename '^/\* !include https://[^ ]+' sqlpage/*.css sqlpage/*.js sqlpage/*.svg \
26+
| sed 's#^/\* !include ##'
27+
} | sort -u
28+
)
29+
30+
for url in "${urls[@]}"; do
31+
file_name=$(printf '%s' "$url" | sed -E 's/[^[:alnum:].-]/_/g')
32+
cache_file="$cache_dir/$file_name"
33+
34+
if [ -s "$cache_file" ]; then
35+
echo " - Cached: $url"
36+
continue
37+
fi
38+
39+
echo " - Downloading: $url"
40+
curl -fsSL "$url" -o "$cache_file"
41+
done
42+
43+
echo "Done. Offline caches are ready."

0 commit comments

Comments
 (0)