@beeos-ai/cli 1.1.1 → 1.1.2
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/dist/index.js +940 -215
- package/package.json +1 -1
- package/scripts/install.sh +138 -9
package/package.json
CHANGED
package/scripts/install.sh
CHANGED
|
@@ -419,8 +419,8 @@ try_install_node() {
|
|
|
419
419
|
fi
|
|
420
420
|
fi
|
|
421
421
|
|
|
422
|
-
# 4. macOS Homebrew (
|
|
423
|
-
#
|
|
422
|
+
# 4. macOS Homebrew (already-installed brew only — we don't install
|
|
423
|
+
# brew itself).
|
|
424
424
|
if [[ "$OS_KIND" == "darwin" ]] && command -v brew &>/dev/null; then
|
|
425
425
|
info "Trying Homebrew..."
|
|
426
426
|
if brew install node >> "$BEEOS_INSTALL_LOG" 2>&1; then
|
|
@@ -429,6 +429,91 @@ try_install_node() {
|
|
|
429
429
|
fi
|
|
430
430
|
fi
|
|
431
431
|
|
|
432
|
+
# 5. Linux distro package manager (last resort).
|
|
433
|
+
#
|
|
434
|
+
# nvm + fnm both depend on `curl` to fetch the Node tarball from
|
|
435
|
+
# nodejs.org. Locked-down corporate networks frequently block
|
|
436
|
+
# `nodejs.org` while still allowing the distro mirror, so a system
|
|
437
|
+
# package install is the only way through. We deliberately put this
|
|
438
|
+
# AFTER nvm/fnm because:
|
|
439
|
+
#
|
|
440
|
+
# 1. distro Node LTS versions lag — Debian stable was on Node 18
|
|
441
|
+
# well into the Node 20 era, breaking device-agent's engines
|
|
442
|
+
# requirement. nvm/fnm pull current LTS regardless.
|
|
443
|
+
# 2. apt/dnf/pacman normally need root, which is a different
|
|
444
|
+
# security posture than user-scope nvm. We require sudo -n
|
|
445
|
+
# (non-interactive) to detect "user is already root or has
|
|
446
|
+
# passwordless sudo" — anything else falls through to the
|
|
447
|
+
# hint block.
|
|
448
|
+
#
|
|
449
|
+
# Operators on hardened systems can disable this branch entirely
|
|
450
|
+
# with BEEOS_NO_PKG_MANAGER_NODE=1 and rely on their own provisioning.
|
|
451
|
+
if [[ "$OS_KIND" == "linux" ]] \
|
|
452
|
+
&& [[ "${BEEOS_NO_PKG_MANAGER_NODE:-}" != "1" ]]; then
|
|
453
|
+
# `sudo -n true` returns 0 only when sudo is configured to skip the
|
|
454
|
+
# password prompt for the current user, OR when we're already root.
|
|
455
|
+
# No prompt = no surprise password dialog mid-install.
|
|
456
|
+
local sudo_cmd=""
|
|
457
|
+
if [[ $EUID -eq 0 ]]; then
|
|
458
|
+
sudo_cmd=""
|
|
459
|
+
elif command -v sudo &>/dev/null && sudo -n true 2>/dev/null; then
|
|
460
|
+
sudo_cmd="sudo -n"
|
|
461
|
+
else
|
|
462
|
+
info "Linux package managers require root and sudo is not passwordless — skipping."
|
|
463
|
+
fi
|
|
464
|
+
|
|
465
|
+
if [[ -n "$sudo_cmd" || $EUID -eq 0 ]]; then
|
|
466
|
+
# Probe in order of decreasing prevalence. Each branch is
|
|
467
|
+
# idempotent and short-circuits the chain on success.
|
|
468
|
+
if command -v apt-get &>/dev/null; then
|
|
469
|
+
info "Trying apt-get (Debian / Ubuntu)..."
|
|
470
|
+
# NodeSource setup script is the canonical way to get a
|
|
471
|
+
# current Node LTS on Debian-family distros. Same retry/log
|
|
472
|
+
# discipline as nvm above.
|
|
473
|
+
if curl -fsSL https://deb.nodesource.com/setup_lts.x \
|
|
474
|
+
| $sudo_cmd bash >> "$BEEOS_INSTALL_LOG" 2>&1 \
|
|
475
|
+
&& $sudo_cmd apt-get install -y nodejs >> "$BEEOS_INSTALL_LOG" 2>&1; then
|
|
476
|
+
success "Node.js installed via apt-get"
|
|
477
|
+
return 0
|
|
478
|
+
fi
|
|
479
|
+
elif command -v dnf &>/dev/null; then
|
|
480
|
+
info "Trying dnf (Fedora / RHEL)..."
|
|
481
|
+
if curl -fsSL https://rpm.nodesource.com/setup_lts.x \
|
|
482
|
+
| $sudo_cmd bash >> "$BEEOS_INSTALL_LOG" 2>&1 \
|
|
483
|
+
&& $sudo_cmd dnf install -y nodejs >> "$BEEOS_INSTALL_LOG" 2>&1; then
|
|
484
|
+
success "Node.js installed via dnf"
|
|
485
|
+
return 0
|
|
486
|
+
fi
|
|
487
|
+
elif command -v yum &>/dev/null; then
|
|
488
|
+
info "Trying yum (CentOS / Amazon Linux)..."
|
|
489
|
+
if curl -fsSL https://rpm.nodesource.com/setup_lts.x \
|
|
490
|
+
| $sudo_cmd bash >> "$BEEOS_INSTALL_LOG" 2>&1 \
|
|
491
|
+
&& $sudo_cmd yum install -y nodejs >> "$BEEOS_INSTALL_LOG" 2>&1; then
|
|
492
|
+
success "Node.js installed via yum"
|
|
493
|
+
return 0
|
|
494
|
+
fi
|
|
495
|
+
elif command -v pacman &>/dev/null; then
|
|
496
|
+
info "Trying pacman (Arch)..."
|
|
497
|
+
if $sudo_cmd pacman -Sy --noconfirm nodejs npm >> "$BEEOS_INSTALL_LOG" 2>&1; then
|
|
498
|
+
success "Node.js installed via pacman"
|
|
499
|
+
return 0
|
|
500
|
+
fi
|
|
501
|
+
elif command -v zypper &>/dev/null; then
|
|
502
|
+
info "Trying zypper (openSUSE)..."
|
|
503
|
+
if $sudo_cmd zypper --non-interactive install nodejs npm >> "$BEEOS_INSTALL_LOG" 2>&1; then
|
|
504
|
+
success "Node.js installed via zypper"
|
|
505
|
+
return 0
|
|
506
|
+
fi
|
|
507
|
+
elif command -v apk &>/dev/null; then
|
|
508
|
+
info "Trying apk (Alpine)..."
|
|
509
|
+
if $sudo_cmd apk add --no-cache nodejs npm >> "$BEEOS_INSTALL_LOG" 2>&1; then
|
|
510
|
+
success "Node.js installed via apk"
|
|
511
|
+
return 0
|
|
512
|
+
fi
|
|
513
|
+
fi
|
|
514
|
+
fi
|
|
515
|
+
fi
|
|
516
|
+
|
|
432
517
|
return 1
|
|
433
518
|
}
|
|
434
519
|
|
|
@@ -541,12 +626,16 @@ test_vnc_server() {
|
|
|
541
626
|
# automate from a curl|bash one-liner.
|
|
542
627
|
|
|
543
628
|
# Detect the user's preferred shell init file so that an `export
|
|
544
|
-
# PATH=...` write survives a new terminal. We support zsh
|
|
545
|
-
# (~
|
|
546
|
-
# printed hint instead of a silent edit to a file we
|
|
547
|
-
# understand. `$SHELL` is the login shell as recorded in
|
|
548
|
-
# NOT the currently-running interpreter — that's exactly
|
|
549
|
-
# for "what does the user's NEXT terminal source?".
|
|
629
|
+
# PATH=...` write survives a new terminal. We support zsh, bash, fish,
|
|
630
|
+
# and pwsh-on-Unix (~99% of macOS / Linux users); tcsh / nushell users
|
|
631
|
+
# still get the printed hint instead of a silent edit to a file we
|
|
632
|
+
# don't fully understand. `$SHELL` is the login shell as recorded in
|
|
633
|
+
# /etc/passwd, NOT the currently-running interpreter — that's exactly
|
|
634
|
+
# what we want for "what does the user's NEXT terminal source?".
|
|
635
|
+
#
|
|
636
|
+
# fish + pwsh emit different PATH syntaxes. The persisted block in
|
|
637
|
+
# `recover_eacces_prefix` below picks the right form by checking the
|
|
638
|
+
# rc path's basename, keeping shell detection isolated to this helper.
|
|
550
639
|
detect_shell_rc() {
|
|
551
640
|
local shell_name
|
|
552
641
|
shell_name="$(basename "${SHELL:-}")"
|
|
@@ -568,6 +657,22 @@ detect_shell_rc() {
|
|
|
568
657
|
printf '%s' "$HOME/.bashrc"
|
|
569
658
|
fi
|
|
570
659
|
;;
|
|
660
|
+
fish)
|
|
661
|
+
# fish auto-sources every *.fish under ~/.config/fish/conf.d/,
|
|
662
|
+
# so a single dropped-in file is the idiomatic way to add PATH
|
|
663
|
+
# without touching the user's main config.fish. mkdir is
|
|
664
|
+
# idempotent and ignored on permission errors.
|
|
665
|
+
mkdir -p "$HOME/.config/fish/conf.d" 2>/dev/null || true
|
|
666
|
+
printf '%s' "$HOME/.config/fish/conf.d/beeos.fish"
|
|
667
|
+
;;
|
|
668
|
+
pwsh)
|
|
669
|
+
# PowerShell on Linux / macOS reads
|
|
670
|
+
# ~/.config/powershell/Microsoft.PowerShell_profile.ps1 by
|
|
671
|
+
# default for the current user, all hosts. The exact filename
|
|
672
|
+
# is case-sensitive on Linux — preserve it.
|
|
673
|
+
mkdir -p "$HOME/.config/powershell" 2>/dev/null || true
|
|
674
|
+
printf '%s' "$HOME/.config/powershell/Microsoft.PowerShell_profile.ps1"
|
|
675
|
+
;;
|
|
571
676
|
*)
|
|
572
677
|
# Empty string ⇒ caller falls back to a manual-paste hint.
|
|
573
678
|
printf '%s' ""
|
|
@@ -643,6 +748,30 @@ recover_eacces_prefix() {
|
|
|
643
748
|
return 0
|
|
644
749
|
fi
|
|
645
750
|
|
|
751
|
+
# Pick PATH-export syntax based on the rc file's basename. fish and
|
|
752
|
+
# pwsh need different forms; sh-family rcs all share `export PATH=...`.
|
|
753
|
+
local rc_base
|
|
754
|
+
rc_base="$(basename "$rc")"
|
|
755
|
+
local export_line
|
|
756
|
+
case "$rc_base" in
|
|
757
|
+
*.fish)
|
|
758
|
+
# `fish_add_path -g` prepends to the global PATH list and is the
|
|
759
|
+
# idiomatic way fish persists PATH (universal fish_user_paths).
|
|
760
|
+
export_line="fish_add_path -g \"${prefix}/bin\""
|
|
761
|
+
;;
|
|
762
|
+
Microsoft.PowerShell_profile.ps1)
|
|
763
|
+
# PowerShell uses semicolon-delimited PATH on Windows but ':' on
|
|
764
|
+
# Unix where pwsh runs. `$env:PATH` mutation in the profile is
|
|
765
|
+
# the canonical way; we use the Unix separator literal because
|
|
766
|
+
# pwsh-on-Unix is the only host that reads this rc.
|
|
767
|
+
export_line="\$env:PATH = \"${prefix}/bin:\" + \$env:PATH"
|
|
768
|
+
;;
|
|
769
|
+
*)
|
|
770
|
+
# zsh / bash / dash-family — the historical contract.
|
|
771
|
+
export_line="export PATH=\"${prefix}/bin:\$PATH\""
|
|
772
|
+
;;
|
|
773
|
+
esac
|
|
774
|
+
|
|
646
775
|
# `>>` never clobbers existing content. If the rc doesn't exist yet
|
|
647
776
|
# (fresh user account), the redirect creates it with 0644 perms.
|
|
648
777
|
{
|
|
@@ -650,7 +779,7 @@ recover_eacces_prefix() {
|
|
|
650
779
|
printf '# Added by https://beeos.ai/install on %s\n' "$(date -u +%FT%TZ)"
|
|
651
780
|
printf '# Reason: system npm prefix was not writable (EACCES).\n'
|
|
652
781
|
printf '# To revert: delete this block AND run `npm config delete prefix`.\n'
|
|
653
|
-
printf '
|
|
782
|
+
printf '%s\n' "$export_line"
|
|
654
783
|
printf '%s\n' "$marker_end"
|
|
655
784
|
} >> "$rc"
|
|
656
785
|
info "Persisted PATH to ${rc}. Set BEEOS_NO_NPM_PREFIX_FIX=1 to skip on re-runs."
|