browser4-cli 4.12.0-rc.3 → 4.12.1
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/README.md +21 -15
- 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/build-all-platforms.ps1 +104 -104
- package/scripts/enumerate-help.ps1 +382 -382
- package/scripts/install-browser4-cli.ps1 +812 -750
- package/scripts/install-browser4-cli.sh +31 -8
- package/scripts/tests/install-browser4-cli.tests.ps1 +476 -311
- package/scripts/tests/install-browser4-cli.tests.sh +135 -0
|
@@ -303,6 +303,141 @@ test "empty --version with dry-run doesn't download" bash -c "
|
|
|
303
303
|
|
|
304
304
|
echo ""
|
|
305
305
|
|
|
306
|
+
# ── create_symlinks (b4 link logic) ─────────────────────
|
|
307
|
+
|
|
308
|
+
echo "--- create_symlinks ---" | cyan
|
|
309
|
+
|
|
310
|
+
# Run symlink tests using the already-sourced FUNC_TEST_SCRIPT.
|
|
311
|
+
SYMLINK_TEST_SCRIPT="$(mktemp)"
|
|
312
|
+
SYMLINK_RESULT="$(mktemp)"
|
|
313
|
+
trap "rm -f '$FUNC_TEST_SCRIPT' '$SYMLINK_TEST_SCRIPT' '$SYMLINK_RESULT'" EXIT
|
|
314
|
+
|
|
315
|
+
cat > "$SYMLINK_TEST_SCRIPT" << 'SYMLINKEOF'
|
|
316
|
+
src="$1"
|
|
317
|
+
result_file="$2"
|
|
318
|
+
set -- # clear positional params so the sourced install script doesn't parse our args
|
|
319
|
+
source "$src" >/dev/null 2>&1
|
|
320
|
+
|
|
321
|
+
# Detect platform for test names
|
|
322
|
+
case "$(uname -s)" in
|
|
323
|
+
MINGW*|MSYS*|CYGWIN*) test_platform="win32-x64"; test_ext=".exe" ;;
|
|
324
|
+
*) test_platform="linux-x64"; test_ext="" ;;
|
|
325
|
+
esac
|
|
326
|
+
test_binary="browser4-cli-${test_platform}${test_ext}"
|
|
327
|
+
test_short="b4${test_ext}"
|
|
328
|
+
|
|
329
|
+
temp_dir="${TMPDIR:-/tmp}/b4-install-test-$$"
|
|
330
|
+
mkdir -p "$temp_dir"
|
|
331
|
+
cd "$temp_dir" || exit 1
|
|
332
|
+
|
|
333
|
+
pass=0
|
|
334
|
+
fail=0
|
|
335
|
+
|
|
336
|
+
do_test() {
|
|
337
|
+
local name="$1" fn="$2"
|
|
338
|
+
if bash -c "$fn" 2>/dev/null; then
|
|
339
|
+
pass=$((pass + 1))
|
|
340
|
+
printf '\033[0;32m PASS %s\033[0m\n' "$name"
|
|
341
|
+
else
|
|
342
|
+
fail=$((fail + 1))
|
|
343
|
+
printf '\033[0;31m FAIL %s\033[0m\n' "$name"
|
|
344
|
+
fi
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
# Create dummy platform binary (required by create_symlinks)
|
|
348
|
+
echo "dummy" > "$test_binary"
|
|
349
|
+
|
|
350
|
+
# ── Scenario 1: b4 does not exist → should create ──
|
|
351
|
+
rm -f "$test_short" "b4.cmd" 2>/dev/null || true
|
|
352
|
+
create_symlinks "$test_binary" "$temp_dir" >/dev/null 2>&1
|
|
353
|
+
|
|
354
|
+
do_test "create_symlinks creates b4 when it does not exist" \
|
|
355
|
+
"[[ -e '$test_short' || -L '$test_short' || -e '$temp_dir/b4.cmd' ]]"
|
|
356
|
+
|
|
357
|
+
# ── Scenario 2: b4 exists in install dir → should update ──
|
|
358
|
+
rm -f "$test_short" "$temp_dir/b4.cmd" 2>/dev/null || true
|
|
359
|
+
create_symlinks "$test_binary" "$temp_dir" >/dev/null 2>&1
|
|
360
|
+
|
|
361
|
+
existing=""
|
|
362
|
+
if [[ -e "$test_short" ]] || [[ -L "$test_short" ]]; then
|
|
363
|
+
existing="$test_short"
|
|
364
|
+
elif [[ -e "$temp_dir/b4.cmd" ]]; then
|
|
365
|
+
existing="$temp_dir/b4.cmd"
|
|
366
|
+
fi
|
|
367
|
+
|
|
368
|
+
if [[ -n "$existing" ]]; then
|
|
369
|
+
# Remove the link and verify create_symlinks recreates it
|
|
370
|
+
rm -f "$existing"
|
|
371
|
+
[[ ! -e "$test_short" ]] && [[ ! -L "$test_short" ]] && [[ ! -e "$temp_dir/b4.cmd" ]] || true
|
|
372
|
+
|
|
373
|
+
create_symlinks "$test_binary" "$temp_dir" >/dev/null 2>&1
|
|
374
|
+
|
|
375
|
+
after_path=""
|
|
376
|
+
if [[ -e "$test_short" ]] || [[ -L "$test_short" ]]; then
|
|
377
|
+
after_path="$test_short"
|
|
378
|
+
elif [[ -e "$temp_dir/b4.cmd" ]]; then
|
|
379
|
+
after_path="$temp_dir/b4.cmd"
|
|
380
|
+
fi
|
|
381
|
+
|
|
382
|
+
do_test "create_symlinks updates b4 when it already exists in install dir" \
|
|
383
|
+
"[[ -n '$after_path' ]]"
|
|
384
|
+
else
|
|
385
|
+
printf ' SKIP create_symlinks updates b4 (precondition: initial link creation failed)\n'
|
|
386
|
+
fi
|
|
387
|
+
|
|
388
|
+
# ── Scenario 3: foreign b4 on PATH → should NOT create b4 ──
|
|
389
|
+
rm -f "$test_short" "$temp_dir/b4.cmd" 2>/dev/null || true
|
|
390
|
+
|
|
391
|
+
foreign_dir="${TMPDIR:-/tmp}/b4-foreign-$$"
|
|
392
|
+
mkdir -p "$foreign_dir"
|
|
393
|
+
foreign_b4="${foreign_dir}/${test_short}"
|
|
394
|
+
printf '#!/bin/sh\necho NotBrowser4\n' > "$foreign_b4"
|
|
395
|
+
chmod +x "$foreign_b4" 2>/dev/null || true
|
|
396
|
+
|
|
397
|
+
OLD_PATH="$PATH"
|
|
398
|
+
PATH="${foreign_dir}:${PATH}"
|
|
399
|
+
create_symlinks "$test_binary" "$temp_dir" >/dev/null 2>&1
|
|
400
|
+
PATH="$OLD_PATH"
|
|
401
|
+
|
|
402
|
+
do_test "create_symlinks skips b4 when foreign b4 is on PATH" \
|
|
403
|
+
"! [[ -e '$test_short' || -L '$test_short' || -e '$temp_dir/b4.cmd' ]]"
|
|
404
|
+
|
|
405
|
+
rm -rf "$foreign_dir"
|
|
406
|
+
|
|
407
|
+
# ── Scenario 4: b4 on PATH is browser4-cli → should create b4 ──
|
|
408
|
+
rm -f "$test_short" "$temp_dir/b4.cmd" 2>/dev/null || true
|
|
409
|
+
|
|
410
|
+
ours_dir="${TMPDIR:-/tmp}/b4-ours-$$"
|
|
411
|
+
mkdir -p "$ours_dir"
|
|
412
|
+
ours_b4="${ours_dir}/${test_short}"
|
|
413
|
+
printf '#!/bin/sh\necho browser4-cli v4.12.0\n' > "$ours_b4"
|
|
414
|
+
chmod +x "$ours_b4" 2>/dev/null || true
|
|
415
|
+
|
|
416
|
+
OLD_PATH="$PATH"
|
|
417
|
+
PATH="${ours_dir}:${PATH}"
|
|
418
|
+
create_symlinks "$test_binary" "$temp_dir" >/dev/null 2>&1
|
|
419
|
+
PATH="$OLD_PATH"
|
|
420
|
+
|
|
421
|
+
do_test "create_symlinks creates b4 when b4 on PATH is browser4-cli" \
|
|
422
|
+
"[[ -e '$test_short' || -L '$test_short' || -e '$temp_dir/b4.cmd' ]]"
|
|
423
|
+
|
|
424
|
+
rm -rf "$ours_dir"
|
|
425
|
+
|
|
426
|
+
# Cleanup temp dir
|
|
427
|
+
rm -rf "$temp_dir"
|
|
428
|
+
|
|
429
|
+
# Write results to the result file for the parent to parse
|
|
430
|
+
printf '%d\n%d\n' "$pass" "$fail" > "$result_file"
|
|
431
|
+
SYMLINKEOF
|
|
432
|
+
|
|
433
|
+
bash "$SYMLINK_TEST_SCRIPT" "$FUNC_TEST_SCRIPT" "$SYMLINK_RESULT"
|
|
434
|
+
symlink_pass=$(head -1 "$SYMLINK_RESULT")
|
|
435
|
+
symlink_fail=$(tail -1 "$SYMLINK_RESULT")
|
|
436
|
+
PASS=$((PASS + ${symlink_pass:-0}))
|
|
437
|
+
FAIL=$((FAIL + ${symlink_fail:-0}))
|
|
438
|
+
|
|
439
|
+
echo ""
|
|
440
|
+
|
|
306
441
|
# ── Summary ────────────────────────────────────────────
|
|
307
442
|
|
|
308
443
|
cyan "============================================"
|