From 0eb26a341e88e1921898b8f55c60329ff800183d Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Wed, 18 Mar 2026 04:03:15 +0200 Subject: [PATCH] refactor(dfm): replace per-language install commands with mise --- local/bin/dfm | 22 ++++++-- scripts/install-cargo-packages.md | 21 ------- scripts/install-cargo-packages.sh | 88 ------------------------------ scripts/install-go-packages.md | 18 ------ scripts/install-go-packages.sh | 69 ----------------------- scripts/install-npm-packages.md | 18 ------ scripts/install-npm-packages.sh | 71 ------------------------ scripts/install-python-packages.md | 8 +-- scripts/install-python-packages.sh | 55 ++----------------- 9 files changed, 26 insertions(+), 344 deletions(-) delete mode 100644 scripts/install-cargo-packages.md delete mode 100755 scripts/install-cargo-packages.sh delete mode 100644 scripts/install-go-packages.md delete mode 100755 scripts/install-go-packages.sh delete mode 100644 scripts/install-npm-packages.md delete mode 100755 scripts/install-npm-packages.sh diff --git a/local/bin/dfm b/local/bin/dfm index 1d08246..982da6a 100644 --- a/local/bin/dfm +++ b/local/bin/dfm @@ -168,11 +168,20 @@ section_install() msgr run "Installing tools via mise..." if ! command -v mise &> /dev/null; then msgr nested "Installing mise..." - curl -fsSL https://mise.run | sh || { msgr err "Failed to install mise"; exit 1; } + curl -fsSL https://mise.run | sh || { + msgr err "Failed to install mise" + exit 1 + } export PATH="${XDG_BIN_HOME:-$HOME/.local/bin}:$PATH" fi - mise install --yes || { msgr err "mise install failed"; exit 1; } - mise reshim || { msgr err "mise reshim failed"; exit 1; } + mise install --yes || { + msgr err "mise install failed" + exit 1 + } + mise reshim || { + msgr err "mise reshim failed" + exit 1 + } msgr yay "mise tools installed!" ;; @@ -542,7 +551,10 @@ section_dotfiles() && msgr ok "Deleted old nvim files (share, state and cache + config)" ln -s "$DOTFILES/config/nvim" ~/.config/nvim \ && msgr ok "Linked nvim and astronvim" - $0 install mise || { msgr err "Failed to install mise tools"; exit 1; } + $0 install mise || { + msgr err "Failed to install mise tools" + exit 1 + } msgr ok "Installed packages" msgr run_done "nvim reset!" ;; @@ -713,4 +725,4 @@ main() esac } -main "$@" \ No newline at end of file +main "$@" diff --git a/scripts/install-cargo-packages.md b/scripts/install-cargo-packages.md deleted file mode 100644 index 9c76a20..0000000 --- a/scripts/install-cargo-packages.md +++ /dev/null @@ -1,21 +0,0 @@ -# install-cargo-packages - -Install Rust packages defined in the script. - -## Usage - -```bash -scripts/install-cargo-packages.sh -``` - -## What it does - -1. If `cargo-install-update` is available, updates all existing packages first - and tracks which packages are already installed. -2. Installs each package from the inline list using `cargo install`, - skipping any already handled by the update step. - Builds run in parallel using available CPU cores (minus two). -3. Runs package-specific post-install steps. -4. Cleans the cargo cache with `cargo cache --autoclean`. - -To add or remove packages, edit the `packages` array in `scripts/install-cargo-packages.sh`. diff --git a/scripts/install-cargo-packages.sh b/scripts/install-cargo-packages.sh deleted file mode 100755 index 4f0e084..0000000 --- a/scripts/install-cargo-packages.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env bash -set -uo pipefail -# @description Install cargo/rust packages. -# -# shellcheck source=shared.sh -source "$DOTFILES/config/shared.sh" - -msgr run "Starting to install rust/cargo packages" - -# Track packages already managed by cargo install-update -declare -A installed_packages - -# If we have cargo install-update, use it first -if command -v cargo-install-update &> /dev/null; then - msgr run "Updating cargo packages with cargo install-update" - # Show output in real-time (via stderr) while capturing it for parsing - update_output=$(cargo install-update -a 2>&1 | tee /dev/stderr) - msgr run_done "Done with cargo install-update" - - # Parse installed package names from the update output - while IFS= read -r pkg_name; do - [[ -n "$pkg_name" ]] && installed_packages["$pkg_name"]=1 - done < <(echo "$update_output" | awk '/v[0-9]+\.[0-9]+/ { print $1 }') -fi - -# Cargo packages to install -packages=( - cargo-update # A cargo subcommand for checking and applying updates to installed executables - cargo-cache # Cargo cache management utility - tree-sitter-cli # An incremental parsing system for programming tools - bkt # A subprocess caching utility - difftastic # A structural diff that understands syntax - fd-find # A simple, fast and user-friendly alternative to 'find' - ripgrep # Recursively searches directories for a regex pattern while respecting your gitignore - bob-nvim # A version manager for neovim - bottom # A cross-platform graphical process/system monitor - eza # A modern alternative to ls - tmux-sessionizer # A tool for opening git repositories as tmux sessions - zoxide # A smarter cd command -) - -# Number of jobs to run in parallel, this helps to keep the system responsive -BUILD_JOBS=$(nproc --ignore=2 2> /dev/null || sysctl -n hw.ncpu 2> /dev/null || echo 1) - -# Function to install cargo packages -install_packages() -{ - for pkg in "${packages[@]}"; do - # Skip packages already handled by cargo install-update - if [[ -n "${installed_packages[$pkg]+x}" ]]; then - msgr ok "Skipping $pkg (already installed)" - continue - fi - - msgr run "Installing cargo package $pkg" - cargo install --jobs "$BUILD_JOBS" "$pkg" - msgr run_done "Done installing $pkg" - echo "" - done - return 0 -} - -# Function to perform additional steps for installed cargo packages -post_install_steps() -{ - msgr run "Now doing the next steps for cargo packages" - - # use bob to install latest stable nvim - if command -v bob &> /dev/null; then - bob use stable && x-path-append "$XDG_DATA_HOME/bob/nvim-bin" - fi - - msgr run "Removing cargo cache" - cargo cache --autoclean - msgr "done" "Done removing cargo cache" - return 0 -} - -# Install cargo packages and run post-install steps -main() -{ - install_packages - msgr "done" "Installed cargo packages!" - post_install_steps - return 0 -} - -main "$@" diff --git a/scripts/install-go-packages.md b/scripts/install-go-packages.md deleted file mode 100644 index bc938bb..0000000 --- a/scripts/install-go-packages.md +++ /dev/null @@ -1,18 +0,0 @@ -# install-go-packages - -Install Go packages defined in the script. - -## Usage - -```bash -scripts/install-go-packages.sh -``` - -## What it does - -1. Checks that `go` is available. -2. Installs each package from the inline list using `go install`. -3. Runs post-install steps (e.g. generating shell completions). -4. Clears the Go module and build caches. - -To add or remove packages, edit the `packages` array in `scripts/install-go-packages.sh`. diff --git a/scripts/install-go-packages.sh b/scripts/install-go-packages.sh deleted file mode 100755 index 3f27136..0000000 --- a/scripts/install-go-packages.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -# @description Install Go packages -# -# shellcheck source=shared.sh -source "$DOTFILES/config/shared.sh" - -msgr run "Installing go packages" - -! x-have "go" && msgr err "go hasn't been installed yet." && exit 0 - -# Go packages to install -packages=( - github.com/dotzero/git-profile@latest # Switch between git user profiles - github.com/google/yamlfmt/cmd/yamlfmt@latest # Format yaml files - github.com/cheat/cheat/cmd/cheat@latest # Interactive cheatsheets on the CLI - github.com/charmbracelet/glow@latest # Render markdown on the CLI - github.com/junegunn/fzf@latest # General-purpose fuzzy finder - github.com/charmbracelet/gum@latest # Glamorous shell scripts - github.com/joshmedeski/sesh/v2@latest # Terminal session manager -) - -# Function to install go packages -install_packages() -{ - for pkg in "${packages[@]}"; do - # Strip inline comments and trim whitespace - pkg="${pkg%%#*}" - pkg="${pkg// /}" - [[ -z "$pkg" ]] && continue - - msgr nested "Installing go package: $pkg" - go install "$pkg" - echo "" - done - return 0 -} - -# Function to install completions and run actions for selected packages -post_install() -{ - msgr run "Installing completions for selected packages" - - if command -v git-profile &> /dev/null; then - git-profile completion zsh > "$ZSH_CUSTOM_COMPLETION_PATH/_git-profile" \ - && msgr run_done "Installed completions for git-profile" - fi - return 0 -} - -# Function to clear go cache -clear_go_cache() -{ - msgr run "Clearing go cache" - go clean -cache -modcache - return 0 -} - -# Install go packages, completions, and clear cache -main() -{ - install_packages - post_install - clear_go_cache - msgr run_done "Done" - return 0 -} - -main "$@" diff --git a/scripts/install-npm-packages.md b/scripts/install-npm-packages.md deleted file mode 100644 index 16da78a..0000000 --- a/scripts/install-npm-packages.md +++ /dev/null @@ -1,18 +0,0 @@ -# install-npm-packages - -Install npm packages defined in the script. - -## Usage - -```bash -scripts/install-npm-packages.sh -``` - -## What it does - -1. Checks that `npm` is available. -2. Installs each package from the inline list using `npm install -g`. -3. Upgrades all global packages. -4. Cleans the npm cache. - -To add or remove packages, edit the `packages` array in `scripts/install-npm-packages.sh`. diff --git a/scripts/install-npm-packages.sh b/scripts/install-npm-packages.sh deleted file mode 100755 index 4b0d154..0000000 --- a/scripts/install-npm-packages.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -# @description Install npm packages globally. -# -# shellcheck source=shared.sh -source "$DOTFILES/config/shared.sh" - -msgr msg "Starting to install npm packages" - -if ! command -v npm &> /dev/null; then - msgr err "npm could not be found." - exit 0 -fi - -packages=( - editorconfig-checker # Check files against .editorconfig rules - github-release-notes # Create release notes from tags and issues - neovim # Neovim node client - corepack # Node.js package manager version management -) - -# Function to install npm packages -install_packages() -{ - for pkg in "${packages[@]}"; do - # Strip inline comments and trim whitespace - pkg="${pkg%%#*}" - pkg="${pkg// /}" - [[ -z "$pkg" ]] && continue - - if npm ls -g -p "$pkg" &> /dev/null; then - msgr run_done "$pkg" "already installed" - else - msgr run "Installing npm package:" "$pkg" - npm install -g --no-fund --no-progress --no-timing "$pkg" - fi - echo "" - done - return 0 -} - -# Function to upgrade all global npm packages -upgrade_global_packages() -{ - msgr run "Upgrading all global packages" - npm -g --no-progress --no-timing --no-fund outdated || true - npm -g --no-timing --no-fund upgrade - return 0 -} - -# Function to clean npm cache -clean_npm_cache() -{ - msgr run "Cleaning up npm cache" - npm cache verify - npm cache clean --force - npm cache verify - return 0 -} - -# Install, upgrade, and clean npm packages -main() -{ - install_packages - upgrade_global_packages - clean_npm_cache - msgr yay "npm package installations complete" - return 0 -} - -main "$@" diff --git a/scripts/install-python-packages.md b/scripts/install-python-packages.md index 379bdb6..d27e6c4 100644 --- a/scripts/install-python-packages.md +++ b/scripts/install-python-packages.md @@ -1,6 +1,6 @@ # install-python-packages -Install Python packages defined in the script using `uv`. +Install Python **libraries** (not tools — those are managed by mise). ## Usage @@ -11,8 +11,6 @@ scripts/install-python-packages.sh ## What it does 1. Checks that `uv` is available; if missing, installs it via the official installer. -2. Installs each CLI tool from the inline `tools` array using `uv tool install --upgrade`. -3. Installs each library from the inline `libraries` array using `uv pip install --system --upgrade`. -4. Upgrades all uv-managed tools with `uv tool upgrade --all`. +2. Installs each library from the inline `libraries` array using `uv pip install --system --upgrade`. -To add or remove packages, edit the `tools` or `libraries` arrays in `scripts/install-python-packages.sh`. +To add or remove packages, edit the `libraries` array in `scripts/install-python-packages.sh`. diff --git a/scripts/install-python-packages.sh b/scripts/install-python-packages.sh index d19689e..993ee87 100755 --- a/scripts/install-python-packages.sh +++ b/scripts/install-python-packages.sh @@ -1,53 +1,27 @@ #!/usr/bin/env bash set -euo pipefail -# @description Install Python packages using uv. +# @description Install Python libraries via uv pip (tools are managed by mise). # # shellcheck source=shared.sh source "$DOTFILES/config/shared.sh" -msgr run "Starting to install Python packages" +msgr run "Starting to install Python libraries" # Ensure uv is available if ! command -v uv &> /dev/null; then - msgr nested "uv not found, installing via official installer" - curl -LsSf https://astral.sh/uv/install.sh | sh - export PATH="$HOME/.local/bin:$PATH" + msgr err "uv not found — install it via mise first" + exit 1 fi -# CLI tools — installed isolated with `uv tool install` -tools=( - ansible # IT automation and configuration management - openapi-python-client # Generate Python API clients from OpenAPI specs - ruff # Fast Python linter and formatter -) - # Library packages — installed into system Python with `uv pip install --system` libraries=( libtmux # Python API for tmux pynvim # Neovim Python client ) -# Function to install CLI tools via uv tool install -install_tools() -{ - msgr run "Installing Python CLI tools" - for pkg in "${tools[@]}"; do - # Strip inline comments and trim whitespace - pkg="${pkg%%#*}" - pkg="${pkg// /}" - [[ -z "$pkg" ]] && continue - - msgr nested "Installing tool: $pkg" - uv tool install --upgrade "$pkg" - echo "" - done - return 0 -} - # Function to install library packages via uv pip install install_libraries() { - msgr run "Installing Python libraries" for pkg in "${libraries[@]}"; do # Strip inline comments and trim whitespace pkg="${pkg%%#*}" @@ -61,22 +35,5 @@ install_libraries() return 0 } -# Function to upgrade all uv-managed tools -upgrade_tools() -{ - msgr run "Upgrading all uv-managed tools" - uv tool upgrade --all - return 0 -} - -# Install Python tools, libraries, and upgrade all -main() -{ - install_tools - install_libraries - upgrade_tools - msgr yay "Python package installations complete" - return 0 -} - -main "$@" +install_libraries +msgr yay "Python library installations complete"