From 51d0e88426de39f6ef424848b0a56222791d6546 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 30 Apr 2025 09:41:40 -0700 Subject: [PATCH 1/5] fix(linters): allow prettier to be installed via mise instead of package.json --- shell/languages/nodejs.sh | 5 +++++ shell/linters/prettier.sh | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/shell/languages/nodejs.sh b/shell/languages/nodejs.sh index f5a48c3a4..5ee713e8d 100644 --- a/shell/languages/nodejs.sh +++ b/shell/languages/nodejs.sh @@ -7,6 +7,11 @@ source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)/../lib/she yarn_install_if_needed() { local stateFile="node_modules/devbase.lock" + if [[ ! -e "package.json" ]]; then + echo "No package.json found, skipping yarn install" + return + fi + if ! yarn -v >/dev/null 2>&1; then npm install -g yarn fi diff --git a/shell/linters/prettier.sh b/shell/linters/prettier.sh index 0d8bf8ead..e64b617fc 100644 --- a/shell/linters/prettier.sh +++ b/shell/linters/prettier.sh @@ -10,6 +10,13 @@ source "$DIR/languages/nodejs.sh" extensions=(yaml yml json md ts) PRETTIER="node_modules/.bin/prettier" +if [[ ! -f "$PRETTIER" ]]; then + # Try to find prettier installed via mise + PRETTIER="$(mise which prettier)" + if [[ -z $PRETTIER ]]; then + fatal "prettier not found in repo" + fi +fi prettier_log_level_flag() { if [[ $("$PRETTIER" --version) =~ ^2 ]]; then From 642863d95bfcf5441ce55a5c25a363d885a8f19b Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Thu, 1 May 2025 10:10:36 -0700 Subject: [PATCH 2/5] Use warn instead of echo --- shell/languages/nodejs.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shell/languages/nodejs.sh b/shell/languages/nodejs.sh index 5ee713e8d..cb5d2721f 100644 --- a/shell/languages/nodejs.sh +++ b/shell/languages/nodejs.sh @@ -1,6 +1,9 @@ #!/usr/bin/env bash # Helpers for node.js +# shellcheck source=../lib/logging.sh +source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)/../lib/logging.sh" + # shellcheck source=../lib/shell.sh source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)/../lib/shell.sh" @@ -8,7 +11,7 @@ yarn_install_if_needed() { local stateFile="node_modules/devbase.lock" if [[ ! -e "package.json" ]]; then - echo "No package.json found, skipping yarn install" + warn "No package.json found, skipping yarn install" return fi From e51b9104e5fb592d199bd9c922b20291bcf637a6 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Thu, 1 May 2025 11:27:04 -0700 Subject: [PATCH 3/5] Only look for prettier via mise if there's no package.json --- shell/linters/prettier.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/linters/prettier.sh b/shell/linters/prettier.sh index e64b617fc..a25d14458 100644 --- a/shell/linters/prettier.sh +++ b/shell/linters/prettier.sh @@ -10,7 +10,7 @@ source "$DIR/languages/nodejs.sh" extensions=(yaml yml json md ts) PRETTIER="node_modules/.bin/prettier" -if [[ ! -f "$PRETTIER" ]]; then +if [[ ! -f "$PRETTIER" ]] && [[ ! -f package.json ]]; then # Try to find prettier installed via mise PRETTIER="$(mise which prettier)" if [[ -z $PRETTIER ]]; then From 51a70c5267843beef49f825178dc446d6f61e23d Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Thu, 1 May 2025 11:28:12 -0700 Subject: [PATCH 4/5] shfmt --- shell/linters/prettier.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/linters/prettier.sh b/shell/linters/prettier.sh index a25d14458..55ebc6f2d 100644 --- a/shell/linters/prettier.sh +++ b/shell/linters/prettier.sh @@ -10,7 +10,7 @@ source "$DIR/languages/nodejs.sh" extensions=(yaml yml json md ts) PRETTIER="node_modules/.bin/prettier" -if [[ ! -f "$PRETTIER" ]] && [[ ! -f package.json ]]; then +if [[ ! -f $PRETTIER ]] && [[ ! -f package.json ]]; then # Try to find prettier installed via mise PRETTIER="$(mise which prettier)" if [[ -z $PRETTIER ]]; then From 5e85ec1c76c6ab3dc9dc1cd268001ffa34d49cfc Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Mon, 5 May 2025 08:12:53 -0700 Subject: [PATCH 5/5] Better error message --- shell/linters/prettier.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/linters/prettier.sh b/shell/linters/prettier.sh index 55ebc6f2d..6f8ae2a19 100644 --- a/shell/linters/prettier.sh +++ b/shell/linters/prettier.sh @@ -14,7 +14,7 @@ if [[ ! -f $PRETTIER ]] && [[ ! -f package.json ]]; then # Try to find prettier installed via mise PRETTIER="$(mise which prettier)" if [[ -z $PRETTIER ]]; then - fatal "prettier not found in repo" + fatal "prettier not found in repo, make sure 'npx:prettier' is defined in 'mise.toml' and you have run 'mise install'" fi fi