From 36c7be07b3bd30e728ec5de38e13f2ec7d96c144 Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Fri, 26 Jun 2026 21:35:34 +0530 Subject: [PATCH] refactor: Migrate all installers to use installation strategies --- installers/install_agy.sh | 2 ++ installers/install_asciicinema.sh | 2 ++ installers/install_bat.sh | 1 + installers/install_docker.sh | 2 ++ installers/install_lazygit.sh | 2 ++ installers/install_node.sh | 2 ++ installers/install_nvim.sh | 2 ++ installers/install_pnpm.sh | 2 ++ installers/install_rust.sh | 2 ++ installers/install_starship.sh | 2 ++ installers/install_uv.sh | 2 ++ installers/install_yay.sh | 2 ++ installers/install_yazi.sh | 1 + installers/install_zoxide.sh | 2 ++ lib/registry.sh | 17 +++++++++++++++++ scripts/generate_registry.sh | 10 ++++++++++ 16 files changed, 53 insertions(+) diff --git a/installers/install_agy.sh b/installers/install_agy.sh index 8eef314..4a8150d 100644 --- a/installers/install_agy.sh +++ b/installers/install_agy.sh @@ -2,6 +2,7 @@ # Tool: agy # DisplayName: Antigravity # Description: Install Antigravity CLI +# Strategy: binary # # Antigravity CLI Installer Script (Linux Only) # @@ -127,6 +128,7 @@ install_agy() { track_file "$BINARY_PATH" log_success "Antigravity CLI successfully installed to $BINARY_PATH." + register_tool "agy" "binary" "" "github:sortedcord/agy" } configure_shell() { diff --git a/installers/install_asciicinema.sh b/installers/install_asciicinema.sh index fccc014..d8fbe2a 100644 --- a/installers/install_asciicinema.sh +++ b/installers/install_asciicinema.sh @@ -2,6 +2,7 @@ # Tool: asciicinema # DisplayName: asciicinema # Description: Install asciinema terminal recorder +# Strategy: binary # # asciinema Installer Script # @@ -84,6 +85,7 @@ install_asciicinema() { track_file "/usr/local/bin/asciicinema" log_success "asciinema ${latest_tag} installed." + register_tool "asciicinema" "binary" "$latest_tag" "github:asciinema/asciinema" } main() { diff --git a/installers/install_bat.sh b/installers/install_bat.sh index 8a10b7e..557482f 100644 --- a/installers/install_bat.sh +++ b/installers/install_bat.sh @@ -2,6 +2,7 @@ # Tool: bat # DisplayName: Bat # Description: Install Bat (alternative to cat) and configure alias +# Strategy: binary # # Bat Installer Script # diff --git a/installers/install_docker.sh b/installers/install_docker.sh index af0e477..ac66dd0 100644 --- a/installers/install_docker.sh +++ b/installers/install_docker.sh @@ -2,6 +2,7 @@ # Tool: docker # DisplayName: Docker # Description: Container runtime and orchestration platform +# Strategy: system # # Docker Installer Script # @@ -58,6 +59,7 @@ install_docker() { sudo systemctl enable --now docker.service || true sudo systemctl enable --now containerd.service || true fi + register_tool "docker" "system" "" "os-package-manager" } # ─── Main ───────────────────────────────────────────────────────────── diff --git a/installers/install_lazygit.sh b/installers/install_lazygit.sh index 0963c15..9697b65 100755 --- a/installers/install_lazygit.sh +++ b/installers/install_lazygit.sh @@ -2,6 +2,7 @@ # Tool: lazygit # DisplayName: lazygit # Description: Simple terminal UI for git commands +# Strategy: binary # # lazygit Installer Script # @@ -61,6 +62,7 @@ install_lazygit() { cp "$TMP_DIR/lazygit" "$HOME/.local/bin/lazygit" chmod +x "$HOME/.local/bin/lazygit" track_file "$HOME/.local/bin/lazygit" + register_tool "lazygit" "binary" "$latest_tag" "github:jesseduffield/lazygit" } # ─── Main ───────────────────────────────────────────────────────────── diff --git a/installers/install_node.sh b/installers/install_node.sh index a3198cf..6ce4377 100644 --- a/installers/install_node.sh +++ b/installers/install_node.sh @@ -2,6 +2,7 @@ # Tool: node # DisplayName: Node # Description: Install Node.js (LTS) and NVM +# Strategy: managed # # Node.js and NVM Installer Script # @@ -95,6 +96,7 @@ install_node() { nvm alias default 'lts/*' log_success "Node.js installed successfully!" set -u + register_tool "node" "managed" "$latest_tag" "github:nvm-sh/nvm" } main() { diff --git a/installers/install_nvim.sh b/installers/install_nvim.sh index 773d5c4..943e393 100644 --- a/installers/install_nvim.sh +++ b/installers/install_nvim.sh @@ -2,6 +2,7 @@ # Tool: nvim # DisplayName: Neovim # Description: Install Neovim 0.12.0 and configuration +# Strategy: binary # # Neovim Installer Script # @@ -91,6 +92,7 @@ install_nvim() { log_success "Installed:" nvim --version | head -n1 + register_tool "nvim" "binary" "$NVIM_VERSION" "github:neovim/neovim" } install_config() { diff --git a/installers/install_pnpm.sh b/installers/install_pnpm.sh index 5053305..0db0559 100644 --- a/installers/install_pnpm.sh +++ b/installers/install_pnpm.sh @@ -2,6 +2,7 @@ # Tool: pnpm # DisplayName: Pnpm # Description: Install pnpm package manager +# Strategy: binary # # pnpm Installer Script # @@ -182,6 +183,7 @@ install_pnpm() { track_dir "$HOME/.local/share/pnpm" log_success "pnpm v${version} installed successfully!" + register_tool "pnpm" "binary" "$version" "github:pnpm/pnpm" } # ─── Shell Configuration ───────────────────────────────────────────── diff --git a/installers/install_rust.sh b/installers/install_rust.sh index e6db38f..09c81c6 100644 --- a/installers/install_rust.sh +++ b/installers/install_rust.sh @@ -2,6 +2,7 @@ # Tool: rust # DisplayName: Rust # Description: Install Rustup and Rust compiler/toolchain +# Strategy: managed # # Rust Installer Script (Simplified Local Rustup Init) # @@ -87,6 +88,7 @@ install_rust() { "$dest" -y --no-modify-path add_rollback_cmd "rustup self uninstall -y" + register_tool "rust" "managed" "" "rustup" } configure_shell() { diff --git a/installers/install_starship.sh b/installers/install_starship.sh index 29553dc..4ef2d70 100644 --- a/installers/install_starship.sh +++ b/installers/install_starship.sh @@ -2,6 +2,7 @@ # Tool: starship # DisplayName: Starship # Description: Install Starship shell prompt +# Strategy: binary # # Starship Installer Script # @@ -66,6 +67,7 @@ install_starship() { cp "$TMP_DIR/starship" "$target_dir/starship" chmod +x "$target_dir/starship" track_file "$target_dir/starship" + register_tool "starship" "binary" "$latest_tag" "github:starship/starship" } configure_shell() { diff --git a/installers/install_uv.sh b/installers/install_uv.sh index f538a09..0c89324 100644 --- a/installers/install_uv.sh +++ b/installers/install_uv.sh @@ -2,6 +2,7 @@ # Tool: uv # DisplayName: uv # Description: Fast Python package installer and resolver +# Strategy: binary # # uv Installer Script # @@ -77,6 +78,7 @@ install_uv() { chmod +x "$target_dir/uv" "$target_dir/uvx" track_file "$target_dir/uv" track_file "$target_dir/uvx" + register_tool "uv" "binary" "$latest_tag" "github:astral-sh/uv" } configure_shell() { diff --git a/installers/install_yay.sh b/installers/install_yay.sh index aaa5a8d..34bb8a7 100755 --- a/installers/install_yay.sh +++ b/installers/install_yay.sh @@ -2,6 +2,7 @@ # Tool: yay # DisplayName: Yay # Description: Install Yay AUR helper +# Strategy: system # # Yay Installer Script # @@ -66,6 +67,7 @@ install_yay() { cd "$orig_dir" log_info "Cleaning up installer directory..." rm -rf "$clone_dir" + register_tool "yay" "system" "" "aur:yay-bin" } # ─── Main ───────────────────────────────────────────────────────────── diff --git a/installers/install_yazi.sh b/installers/install_yazi.sh index 4cb4295..cd193e3 100755 --- a/installers/install_yazi.sh +++ b/installers/install_yazi.sh @@ -2,6 +2,7 @@ # Tool: yazi # DisplayName: Yazi # Description: Install Yazi terminal file manager and dependencies +# Strategy: binary # # Yazi Installer Script # diff --git a/installers/install_zoxide.sh b/installers/install_zoxide.sh index 110baa3..957cc66 100755 --- a/installers/install_zoxide.sh +++ b/installers/install_zoxide.sh @@ -2,6 +2,7 @@ # Tool: zoxide # DisplayName: Zoxide # Description: Install Zoxide directory jumper +# Strategy: managed # # Zoxide Installer Script # @@ -41,6 +42,7 @@ install_zoxide() { log_info "Downloading and running the official zoxide installer..." curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh track_file "$HOME/.local/bin/zoxide" + register_tool "zoxide" "managed" "" "github:ajeetdsouza/zoxide" } configure_shell() { diff --git a/lib/registry.sh b/lib/registry.sh index abbb9b4..d465f00 100644 --- a/lib/registry.sh +++ b/lib/registry.sh @@ -34,4 +34,21 @@ declare -A INSTALLER_DISPLAYS=( [zoxide]="Zoxide" ) +declare -A INSTALLER_STRATEGIES=( + [agy]="binary" + [asciicinema]="binary" + [bat]="binary" + [docker]="system" + [lazygit]="binary" + [node]="managed" + [nvim]="binary" + [pnpm]="binary" + [rust]="managed" + [starship]="binary" + [uv]="binary" + [yay]="system" + [yazi]="binary" + [zoxide]="managed" +) + INSTALLER_KEYS=(agy asciicinema bat docker lazygit node nvim pnpm rust starship uv yay yazi zoxide) diff --git a/scripts/generate_registry.sh b/scripts/generate_registry.sh index e95a916..e3cbf99 100755 --- a/scripts/generate_registry.sh +++ b/scripts/generate_registry.sh @@ -13,6 +13,7 @@ echo "==> Generating registry.sh..." # Temporary arrays declare -A tools_desc declare -A tools_disp +declare -A tools_strat keys=() for f in "$INSTALLERS_DIR"/install_*.sh; do @@ -20,10 +21,12 @@ for f in "$INSTALLERS_DIR"/install_*.sh; do tool=$(grep -E "^# Tool:" "$f" | head -n1 | sed -E 's/^# Tool:\s*//I') disp_name=$(grep -E "^# DisplayName:" "$f" | head -n1 | sed -E 's/^# DisplayName:\s*//I') desc=$(grep -E "^# Description:" "$f" | head -n1 | sed -E 's/^# Description:\s*//I' | sed -E 's/^Install\s+//I') + strat=$(grep -E "^# Strategy:" "$f" | head -n1 | sed -E 's/^# Strategy:\s*//I') if [ -n "$tool" ]; then tools_desc["$tool"]="$desc" tools_disp["$tool"]="${disp_name:-$tool}" + tools_strat["$tool"]="${strat:-unknown}" keys+=("$tool") fi done @@ -49,6 +52,13 @@ sorted_keys=($(printf '%s\n' "${keys[@]}" | sort)) done echo ")" echo "" + echo "declare -A INSTALLER_STRATEGIES=(" + for k in "${sorted_keys[@]}"; do + escaped_strat=$(echo "${tools_strat[$k]}" | sed 's/"/\\"/g') + echo " [$k]=\"$escaped_strat\"" + done + echo ")" + echo "" # Format keys output as space-separated list in array declaration format echo "INSTALLER_KEYS=(${sorted_keys[*]})" } > "$REGISTRY_FILE"