-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathinstall-deps.sh
executable file
·122 lines (105 loc) · 3.16 KB
/
install-deps.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
set -euo pipefail
SHOULD_SKIP_NPM=false
CI_MODE=false
SHOULD_COMPILE_WASM=false
SHOULD_COMPILE_NODE=false
SHOULD_COMPILE_WARP=false
for arg in "$@"; do
case "$arg" in
"--skip-npm")
SHOULD_SKIP_NPM=true
;;
"--ci")
CI_MODE=true
;;
"--wasm")
SHOULD_COMPILE_WASM=true
;;
"--node")
SHOULD_COMPILE_NODE=true
;;
"--warp")
SHOULD_COMPILE_WARP=true
;;
"--all")
SHOULD_COMPILE_WASM=true
SHOULD_COMPILE_NODE=true
SHOULD_COMPILE_WARP=true
;;
esac
done
install() {
echo "Installing: $1"
local max_retries=3
local retry_count=0
set +euo pipefail
while [ $retry_count -lt $max_retries ]; do
if [ $retry_count -gt 0 ]; then
attempt_msg=" (attempt $((retry_count + 1)))"
else
attempt_msg=""
fi
if command -v bun &> /dev/null; then
if [ "$CI_MODE" = true ]; then
echo "Using bun for installation in CI mode${attempt_msg}"
bun install --cwd "$1" --no-cache && break || {
echo "Failed to install packages for $1 in CI mode using bun"
((retry_count++))
}
else
echo "Using bun for installation${attempt_msg}"
bun install --cwd "$1" && break || {
echo "Failed to install packages for $1 using bun"
((retry_count++))
}
fi
else
echo "Using npm for installation${attempt_msg}"
if [ "$CI_MODE" = true ]; then
npm --prefix "$1" --force ci --cache .npm --prefer-offline --no-audit --verbose && break || {
echo "Failed to install packages in CI mode for $1 using npm"
((retry_count++))
}
else
npm --prefix "$1" --force install --cache .npm && break || {
echo "Failed to install packages for $1 using npm"
((retry_count++))
}
fi
fi
if [ $retry_count -eq $max_retries ]; then
echo "Installation failed after $max_retries attempts for $1"
exit 1
else
echo "Retrying installation for $1..."
sleep 2
fi
done
set -euo pipefail
}
fetch_gh_ratelimit() {
curl -s https://api.github.com/rate_limit | grep -A 2 '"core":' | grep '"remaining":' | awk '{print $2}' | tr -d ','
}
if ! "$SHOULD_SKIP_NPM"; then
install "."
if [ -f "services/package.json" ]; then
install "services"
fi
fi
echo "Github API rate limit: $(fetch_gh_ratelimit)"
if $SHOULD_COMPILE_WASM; then
mkdir -p apps/browser/wasm/dist
npm --prefix apps/browser run build:wasm
fi
if $SHOULD_COMPILE_NODE; then
npm --prefix apps/next/crates/next-gramax-git run build
fi
if $SHOULD_COMPILE_WARP; then
cargo install --path rbins/warp-spa
fi
echo "Compiling schemes"
npm run build:schemes 2>&1 || {
echo "Failed to compile schemes"
exit 1
}