From f4da5151208b125578f2d56006b9ee656464c9f5 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Thu, 20 Feb 2025 02:28:17 +0200 Subject: [PATCH] chore(scripts): refactor cargo and go pkg install --- scripts/install-cargo-packages.sh | 37 +++++++++++----------------- scripts/install-go-packages.sh | 40 +++++++++++++------------------ 2 files changed, 30 insertions(+), 47 deletions(-) diff --git a/scripts/install-cargo-packages.sh b/scripts/install-cargo-packages.sh index cb07026..13856b1 100755 --- a/scripts/install-cargo-packages.sh +++ b/scripts/install-cargo-packages.sh @@ -15,29 +15,20 @@ if command -v cargo-install-update &> /dev/null; then msgr run_done "Done with cargo install-update" fi -packages=( - # A cargo subcommand for checking and applying - # updates to installed executables - "cargo-update" - # Cargo cache management utility - "cargo-cache" - # An incremental parsing system for programming tools - "tree-sitter-cli" - # a subprocess caching utility - "bkt" - # a structural diff that understands syntax - "difftastic" - # a modern replacement for ls. - "eza" - # A simple, fast and user-friendly alternative to 'find' - "fd-find" - # recursively searches directories for a - # regex pattern while respecting your gitignore - "ripgrep" - # A version manager for neovim - "bob-nvim" - "bottom" -) +[[ -z "$ASDF_CRATE_DEFAULT_PACKAGES_FILE" ]] && \ + ASDF_CRATE_DEFAULT_PACKAGES_FILE="$DOTFILES/config/asdf/cargo-packages" + +# Packages are defined in $DOTFILES/config/asdf/cargo-packages, one per line +# Skip comments and empty lines +packages=() +while IFS= read -r line; do + # Skip comments + if [[ ${line:0:1} == "#" ]]; then continue; fi + if [[ ${line:0:1} == "/" ]]; then continue; fi + # Skip empty lines + if [[ -z "$line" ]]; then continue; fi + packages+=("$line") +done < "$ASDF_CRATE_DEFAULT_PACKAGES_FILE" # Number of jobs to run in parallel, this helps to keep the system responsive BUILD_JOBS=$(nproc --ignore=2) diff --git a/scripts/install-go-packages.sh b/scripts/install-go-packages.sh index a02a9db..3e7afba 100755 --- a/scripts/install-go-packages.sh +++ b/scripts/install-go-packages.sh @@ -11,30 +11,22 @@ msgr run "Installing go packages" ! x-have "go" && msgr err "go hasn't been installed yet." && exit 0 -packages=( - # A shell parser, formatter, and interpreter with bash support; includes shfmt - mvdan.cc/sh/v3/cmd/shfmt@latest - # sysadmin/scripting utilities, distributed as a single binary - github.com/skx/sysbox@latest - # Git Profile allows you to switch between user profiles in git repos - github.com/dotzero/git-profile@latest - # An extensible command line tool or library to format yaml files. - github.com/google/yamlfmt/cmd/yamlfmt@latest - # Parsing HTML at the command line - github.com/ericchiang/pup@latest - # HTML to Markdown converter - github.com/suntong/html2md@latest - # cheat allows you to create and view interactive cheatsheets on the cli. - github.com/cheat/cheat/cmd/cheat@latest - # Render markdown on the CLI, with pizzazz! 💅 - github.com/charmbracelet/glow@latest - # Static checker for GitHub Actions workflow files - github.com/rhysd/actionlint/cmd/actionlint@latest - # simple terminal UI for git commands - github.com/jesseduffield/lazygit@latest - # Cleans up your $HOME from those pesky dotfiles - github.com/doron-cohen/antidot@latest -) +[[ -z "$ASDF_GOLANG_DEFAULT_PACKAGES_FILE" ]] && \ + ASDF_GOLANG_DEFAULT_PACKAGES_FILE="$DOTFILES/config/asdf/golang-packages" + +# Packages are defined in $DOTFILES/config/asdf/golang-packages, one per line +# Skip comments and empty lines +packages=() +if [[ -f "$ASDF_GOLANG_DEFAULT_PACKAGES_FILE" ]]; then + while IFS= read -r line; do + # Skip comments + if [[ ${line:0:1} == "#" ]]; then continue; fi + if [[ ${line:0:1} == "/" ]]; then continue; fi + # Skip empty lines + if [[ -z "$line" ]]; then continue; fi + packages+=("$line") + done < "$ASDF_GOLANG_DEFAULT_PACKAGES_FILE" +fi # Function to install go packages install_packages()