diff --git a/local/bin/dfm b/local/bin/dfm index 9b39ff9..866c8bc 100755 --- a/local/bin/dfm +++ b/local/bin/dfm @@ -88,6 +88,7 @@ section_install() "nvm-latest:Install latest lts node using nvm" "nvm:Install Node Version Manager (nvm)" "python-packages:Install Python packages via uv" + "shellspec:Install shellspec testing framework" "xcode-cli-tools:Install Xcode CLI tools (macOS)" "z:Install z" ) @@ -121,6 +122,7 @@ section_install() $0 install ntfy # Tier 4: Independent utilities + $0 install shellspec $0 install z msgr msg "Reloading configurations again..." @@ -245,6 +247,12 @@ section_install() && msgr yay "Xcode CLI tools installed!" ;; + shellspec) + msgr run "Installing shellspec..." + bash "$DOTFILES/scripts/install-shellspec.sh" \ + && msgr yay "shellspec has been installed!" + ;; + z) msgr run "Installing z..." bash "$DOTFILES/scripts/install-z.sh" \ diff --git a/scripts/install-shellspec.md b/scripts/install-shellspec.md new file mode 100644 index 0000000..7f9a322 --- /dev/null +++ b/scripts/install-shellspec.md @@ -0,0 +1,16 @@ +# install-shellspec + +Installs [shellspec](https://github.com/shellspec/shellspec), a BDD-style +testing framework for shell scripts. + +## Usage + +```bash +scripts/install-shellspec.sh +``` + +The script resolves the latest release tag via `x-gh-get-latest-version`, +clones shellspec to `~/.cache/shellspec` pinned to that tag, and runs +`make install PREFIX=$HOME/.local`, placing the binary in `~/.local/bin/`. +Re-running the script fetches and checks out the newest release tag +before reinstalling. diff --git a/scripts/install-shellspec.sh b/scripts/install-shellspec.sh new file mode 100755 index 0000000..7f3501e --- /dev/null +++ b/scripts/install-shellspec.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +set -euo pipefail +# @description Install shellspec testing framework +# +# shellcheck source=shared.sh +source "${DOTFILES}/config/shared.sh" + +SHELLSPEC_REPO="https://github.com/shellspec/shellspec.git" +SHELLSPEC_CACHE="$HOME/.cache/shellspec" + +install_shellspec() +{ + local version + version=$(x-gh-get-latest-version shellspec/shellspec) + msgr ok "Latest shellspec version: $version" + + if [[ -d "$SHELLSPEC_CACHE" ]]; then + msgr ok "shellspec repo already cloned, fetching $version..." + git -C "$SHELLSPEC_CACHE" fetch --depth=1 origin "refs/tags/$version" + git -C "$SHELLSPEC_CACHE" checkout "$version" + else + git clone --branch "$version" --depth=1 "$SHELLSPEC_REPO" "$SHELLSPEC_CACHE" + fi + + msgr run "Running make install..." + make -C "$SHELLSPEC_CACHE" install PREFIX="$HOME/.local" + msgr run_done "shellspec $version installed to $HOME/.local/bin/shellspec" + return 0 +} + +main() +{ + install_shellspec + return 0 +} + +main "$@"