@@ -1835,3 +1835,66 @@ devpi-delete: devpi-setup-user ## Delete mcpgateway==$(VER) from
1835
1835
devpi use $(DEVPI_INDEX ) && \
1836
1836
devpi remove -y mcpgateway==$(VER ) || true"
1837
1837
@echo " ✅ Delete complete (if it existed)"
1838
+
1839
+
1840
+ # =============================================================================
1841
+ # 🐚 LINT SHELL FILES
1842
+ # =============================================================================
1843
+ # help: 🐚 LINT SHELL FILES
1844
+ # help: shell-linters-install - Install ShellCheck, shfmt & bashate (best-effort per OS)
1845
+ # help: shell-lint - Run shfmt (check-only) + ShellCheck + bashate on every *.sh
1846
+ # help: shfmt-fix - AUTO-FORMAT all *.sh in-place with shfmt -w
1847
+ # -----------------------------------------------------------------------------
1848
+
1849
+ # ──────────────────────────
1850
+ # Which shell files to scan
1851
+ # ──────────────────────────
1852
+ SHELL_SCRIPTS := $(shell find . -type f -name '* .sh' -not -path './node_modules/* ')
1853
+
1854
+ .PHONY : shell-linters-install shell-lint shfmt-fix shellcheck bashate
1855
+
1856
+ shell-linters-install : # # 🔧 Install shellcheck, shfmt, bashate
1857
+ @echo " 🔧 Installing/ensuring shell linters are present…"
1858
+ @set -e ; \
1859
+ # -------- ShellCheck -------- \
1860
+ if ! command -v shellcheck > /dev/null 2>&1 ; then \
1861
+ echo " 🛠 Installing ShellCheck…" ; \
1862
+ case " $$ (uname -s)" in \
1863
+ Darwin) brew install shellcheck ;; \
1864
+ Linux) { command -v apt-get && sudo apt-get update -qq && sudo apt-get install -y shellcheck ; } || \
1865
+ { command -v dnf && sudo dnf install -y ShellCheck ; } || \
1866
+ { command -v pacman && sudo pacman -Sy --noconfirm shellcheck ; } || true ;; \
1867
+ * ) echo " ⚠️ Please install ShellCheck manually" ;; \
1868
+ esac ; \
1869
+ fi ; \
1870
+ # -------- shfmt (Go) -------- \
1871
+ if ! command -v shfmt > /dev/null 2>&1 ; then \
1872
+ echo " 🛠 Installing shfmt…" ; \
1873
+ GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@latest || \
1874
+ { echo " ⚠️ go not found – install Go or brew/apt shfmt package manually" ; } ; \
1875
+ export PATH=$$ PATH:$$ HOME/go/bin ; \
1876
+ fi ; \
1877
+ # -------- bashate (pip) ----- \
1878
+ if ! $( VENV_DIR) /bin/bashate -h > /dev/null 2>&1 ; then \
1879
+ echo " 🛠 Installing bashate (into venv)…" ; \
1880
+ test -d " $( VENV_DIR) " || $(MAKE ) venv ; \
1881
+ /bin/bash -c " source $( VENV_DIR) /bin/activate && python -m pip install --quiet bashate" ; \
1882
+ fi
1883
+ @echo " ✅ Shell linters ready."
1884
+
1885
+ # -----------------------------------------------------------------------------
1886
+
1887
+ shell-lint : shell-linters-install # # 🔍 Run shfmt, ShellCheck & bashate
1888
+ @echo " 🔍 Running shfmt (diff-only)…"
1889
+ @shfmt -d -i 4 -ci $(SHELL_SCRIPTS ) || true
1890
+ @echo " 🔍 Running ShellCheck…"
1891
+ @shellcheck $(SHELL_SCRIPTS ) || true
1892
+ @echo " 🔍 Running bashate…"
1893
+ @$(VENV_DIR ) /bin/bashate -C $(SHELL_SCRIPTS ) || true
1894
+ @echo " ✅ Shell lint complete."
1895
+
1896
+
1897
+ shfmt-fix : shell-linters-install # # 🎨 Auto-format *.sh in place
1898
+ @echo " 🎨 Formatting shell scripts with shfmt -w…"
1899
+ @shfmt -w -i 4 -ci $(SHELL_SCRIPTS )
1900
+ @echo " ✅ shfmt formatting done."
0 commit comments