Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ golang 1.23.4
# The most common case is nodejs.
## <<Stencil::Block(toolver)>>
# The below tools are used by all repositories when using devbase
shellcheck 0.9.0
shfmt 3.7.0
goreleaser 1.20.0
terraform 1.4.4
## <</Stencil::Block>>
8 changes: 8 additions & 0 deletions shell/lib/mise.sh
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ mise_exec_tool_with_bin() {
shift
local binName="$1"
shift

# asdf shims take precedence in the PATH,
# so remove it in CI before execution.
local asdfShim="${ASDF_DIR:-$HOME/.asdf}/shims/$binName"
if in_ci_environment && [[ -f $asdfShim ]]; then
rm "$asdfShim"
fi

local version
version="$(get_tool_version "$binName")"
MISE_GITHUB_TOKEN=$(github_token) run_mise exec "$toolName@$version" -- "$binName" "$@"
Expand Down
10 changes: 7 additions & 3 deletions shell/linters/bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ find_shell_files() {
}

shellcheck_linter() {
find_shell_files | xargs -n40 "$SHELLCHECKPATH" -x -P SCRIPTDIR
# Wrapper script already sets external sources & script directory
# source path.
find_shell_files | xargs -n40 "$SHELLCHECKPATH"
}

shellfmt_linter() {
find_shell_files | xargs -n40 "$SHELLFMTPATH" -s -d
# Wrapper script already sets --simplify
find_shell_files | xargs -n40 "$SHELLFMTPATH" --diff
}

shellfmt_formatter() {
find_shell_files | xargs -n40 "$SHELLFMTPATH" -w -l
# Wrapper script already sets --simplify
find_shell_files | xargs -n40 "$SHELLFMTPATH" --write --list
}

linter() {
Expand Down
11 changes: 6 additions & 5 deletions shell/shellcheck.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env bash
# This is a wrapper around asdf to run shellcheck.
# This is a wrapper around mise to run shellcheck.
# Useful for using the correct version of shellcheck
# with your editor.
set -e

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"

# shellcheck source=./lib/asdf.sh
source "$DIR/lib/asdf.sh"
# shellcheck source=./lib/mise/stub.sh
source "$DIR/lib/mise/stub.sh"

# Always set the correct script directory.
args=("-P" "SCRIPTDIR" "-x" "$@")
asdf_devbase_exec shellcheck "${args[@]}"
args=(--external-sources --source-path=SCRIPTDIR "$@")

mise_exec_tool shellcheck "${args[@]}"
10 changes: 5 additions & 5 deletions shell/shfmt.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env bash
# This is a wrapper around asdf to run shfmt.
# This is a wrapper around mise to run shfmt.
# Useful for using the correct version of shfmt
# with your editor.
set -e

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"

# shellcheck source=./lib/asdf.sh
source "$DIR/lib/asdf.sh"
# shellcheck source=./lib/mise/stub.sh
source "$DIR/lib/mise/stub.sh"

# Always set simplify mode.
args=("-s" "$@")
args=("--simplify" "$@")

asdf_devbase_exec shfmt "${args[@]}"
mise_exec_tool shfmt "${args[@]}"
3 changes: 3 additions & 0 deletions versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ mage: 1.14.0
## Sync with templates/scripts/devbase.sh.tpl
gojq: v0.12.18

shellcheck: 0.9.0
shfmt: 3.7.0

# protobuf formatters/plugins/tools/etc
buf: 1.60.0
protoc-gen-validate: 0.6.7
Expand Down