browser4-cli 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/browser4-cli-darwin-arm64 +0 -0
- package/bin/browser4-cli-darwin-x64 +0 -0
- package/bin/browser4-cli-linux-arm64 +0 -0
- package/bin/browser4-cli-linux-musl-arm64 +0 -0
- package/bin/browser4-cli-linux-musl-x64 +0 -0
- package/bin/browser4-cli-linux-x64 +0 -0
- package/bin/browser4-cli-win32-x64.exe +0 -0
- package/package.json +1 -1
- package/scripts/install-browser4-cli.sh +81 -12
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -140,14 +140,34 @@ detect_libc() {
|
|
|
140
140
|
return
|
|
141
141
|
fi
|
|
142
142
|
|
|
143
|
-
# Check for musl
|
|
144
|
-
if ldd
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
echo ""
|
|
143
|
+
# Check for musl via ldd --version (guarded against missing ldd)
|
|
144
|
+
if command -v ldd >/dev/null 2>&1; then
|
|
145
|
+
if ldd --version 2>&1 | grep -qi musl; then
|
|
146
|
+
echo "musl"
|
|
147
|
+
return
|
|
148
|
+
fi
|
|
150
149
|
fi
|
|
150
|
+
|
|
151
|
+
# Check for musl loader — covers common architectures
|
|
152
|
+
# x86_64, aarch64, armhf (32-bit ARM), i386, riscv64, s390x, ppc64le, mips64
|
|
153
|
+
local musl_loader
|
|
154
|
+
for musl_loader in \
|
|
155
|
+
/lib/ld-musl-x86_64.so.1 \
|
|
156
|
+
/lib/ld-musl-aarch64.so.1 \
|
|
157
|
+
/lib/ld-musl-armhf.so.1 \
|
|
158
|
+
/lib/ld-musl-i386.so.1 \
|
|
159
|
+
/lib/ld-musl-riscv64.so.1 \
|
|
160
|
+
/lib/ld-musl-s390x.so.1 \
|
|
161
|
+
/lib/ld-musl-ppc64le.so.1 \
|
|
162
|
+
/lib/ld-musl-mips64.so.1 \
|
|
163
|
+
/lib/ld-musl-mipsel.so.1; do
|
|
164
|
+
if [[ -f "$musl_loader" ]]; then
|
|
165
|
+
echo "musl"
|
|
166
|
+
return
|
|
167
|
+
fi
|
|
168
|
+
done
|
|
169
|
+
|
|
170
|
+
echo ""
|
|
151
171
|
}
|
|
152
172
|
|
|
153
173
|
get_platform_key() {
|
|
@@ -196,8 +216,14 @@ get_default_install_dir() {
|
|
|
196
216
|
# ──────────────────────────────────────────────
|
|
197
217
|
|
|
198
218
|
check_commands() {
|
|
199
|
-
|
|
200
|
-
|
|
219
|
+
local missing=()
|
|
220
|
+
for cmd in curl mktemp stat awk grep ln mkdir chmod; do
|
|
221
|
+
if ! command -v "$cmd" >/dev/null 2>&1; then
|
|
222
|
+
missing+=("$cmd")
|
|
223
|
+
fi
|
|
224
|
+
done
|
|
225
|
+
if [[ ${#missing[@]} -gt 0 ]]; then
|
|
226
|
+
die "Required command(s) not found: ${missing[*]}. Install them and retry."
|
|
201
227
|
fi
|
|
202
228
|
}
|
|
203
229
|
|
|
@@ -240,10 +266,27 @@ download_file() {
|
|
|
240
266
|
return 0
|
|
241
267
|
fi
|
|
242
268
|
|
|
243
|
-
local
|
|
269
|
+
local curl_stderr
|
|
270
|
+
curl_stderr=$(mktemp)
|
|
271
|
+
local http_code curl_exit
|
|
272
|
+
|
|
244
273
|
http_code=$(curl -sSfL -w "%{http_code}" -o "$dest" \
|
|
245
274
|
${GITHUB_TOKEN:+-H "Authorization: Bearer $GITHUB_TOKEN"} \
|
|
246
|
-
"$url" 2
|
|
275
|
+
"$url" 2>"$curl_stderr")
|
|
276
|
+
curl_exit=$?
|
|
277
|
+
|
|
278
|
+
if [[ $curl_exit -ne 0 ]]; then
|
|
279
|
+
local stderr_msg
|
|
280
|
+
stderr_msg=$(<"$curl_stderr")
|
|
281
|
+
rm -f "$curl_stderr" "$dest"
|
|
282
|
+
if [[ -n "$stderr_msg" ]]; then
|
|
283
|
+
warn "curl error (exit ${curl_exit}): ${stderr_msg}"
|
|
284
|
+
else
|
|
285
|
+
warn "curl failed with exit code ${curl_exit} (no stderr output)"
|
|
286
|
+
fi
|
|
287
|
+
return 1
|
|
288
|
+
fi
|
|
289
|
+
rm -f "$curl_stderr"
|
|
247
290
|
|
|
248
291
|
if [[ "$http_code" == "200" ]] || [[ "$http_code" == "302" ]]; then
|
|
249
292
|
local size
|
|
@@ -297,12 +340,38 @@ add_to_shell_rc() {
|
|
|
297
340
|
return
|
|
298
341
|
fi
|
|
299
342
|
|
|
343
|
+
# Ensure the file ends with a newline before appending, so the new
|
|
344
|
+
# content isn't glued to the last existing line.
|
|
345
|
+
if [[ -s "$rc_file" ]]; then
|
|
346
|
+
local last_byte
|
|
347
|
+
last_byte=$(tail -c1 "$rc_file" 2>/dev/null || true)
|
|
348
|
+
if [[ -n "$last_byte" ]]; then
|
|
349
|
+
echo "" >> "$rc_file"
|
|
350
|
+
fi
|
|
351
|
+
fi
|
|
352
|
+
|
|
353
|
+
# Use a lock file to prevent concurrent append races (best-effort).
|
|
354
|
+
local lock_file="${rc_file}.browser4-install.lock"
|
|
355
|
+
local lock_fd=9
|
|
356
|
+
# Wait up to 10 seconds for another install process to release the lock.
|
|
357
|
+
local waited=0
|
|
358
|
+
while ! (umask 0002 && command -v flock >/dev/null 2>&1 && flock -n 9 2>/dev/null); do
|
|
359
|
+
if [[ $waited -ge 10 ]]; then
|
|
360
|
+
warn "Could not acquire lock on ${rc_file} after 10s; appending anyway"
|
|
361
|
+
break
|
|
362
|
+
fi
|
|
363
|
+
sleep 0.5
|
|
364
|
+
waited=$((waited + 1))
|
|
365
|
+
done 9>"$lock_file"
|
|
366
|
+
|
|
300
367
|
{
|
|
301
|
-
echo ""
|
|
302
368
|
echo "# browser4-cli"
|
|
303
369
|
echo "export PATH=\"$dir:\$PATH\""
|
|
304
370
|
} >> "$rc_file"
|
|
305
371
|
|
|
372
|
+
# Clean up (flock auto-releases when fd 9 is closed)
|
|
373
|
+
rm -f "$lock_file" 2>/dev/null || true
|
|
374
|
+
|
|
306
375
|
ok "Added to PATH in $rc_file"
|
|
307
376
|
say " Reload with: source $rc_file"
|
|
308
377
|
}
|