diff --git a/.husky/commit-msg b/.husky/commit-msg deleted file mode 100644 index 6a2e4c8..0000000 --- a/.husky/commit-msg +++ /dev/null @@ -1 +0,0 @@ -pnpm exec commitlint --edit $1 diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100644 index 6498af3..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1 +0,0 @@ -task format && task lint && git add -A . diff --git a/.husky/pre-push b/.husky/pre-push deleted file mode 100644 index 23e6b9b..0000000 --- a/.husky/pre-push +++ /dev/null @@ -1 +0,0 @@ -task test diff --git a/README.md b/README.md index 10c7a27..b1845a2 100644 --- a/README.md +++ b/README.md @@ -16,5 +16,5 @@ task install_tools - **[mvdan/gofumpt](https://github.com/mvdan/gofumpt)** - A stricter gofmt - **[golang.org/x/tools/cmd/goimports](https://pkg.go.dev/golang.org/x/tools/cmd/goimports)** - Updates Go import lines - **[go-task/task](https://github.com/go-task/task)** - A task runner / simpler Make alternative -- **[typicode/husky](https://github.com/typicode/husky)** - Git hooks made easy +- **[evilmartians/lefthook](https://github.com/evilmartians/lefthook)** - Fast and powerful Git hooks manager - **[conventional-changelog/commitlint](https://github.com/conventional-changelog/commitlint)** - Lint commit messages diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 0000000..e1b9c69 --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,18 @@ +pre-commit: + commands: + format: + run: task format + lint: + run: task lint + stage: + run: git add -A . + +pre-push: + commands: + test: + run: task test + +commit-msg: + commands: + commitlint: + run: pnpm exec commitlint --edit {1} diff --git a/package.json b/package.json index ace61da..88674c0 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,7 @@ "description": "", "packageManager": "pnpm@10.32.1", "scripts": { - "preinstall": "npx only-allow pnpm", - "prepare": "husky" + "preinstall": "npx only-allow pnpm" }, "repository": { "type": "git", @@ -20,7 +19,6 @@ "devDependencies": { "@commitlint/cli": "19.8.1", "@commitlint/config-conventional": "19.8.1", - "@commitlint/types": "^20.5.0", - "husky": "9.1.7" + "@commitlint/types": "^20.5.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5b0abd1..7f6ce25 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,9 +17,6 @@ importers: '@commitlint/types': specifier: ^20.5.0 version: 20.5.0 - husky: - specifier: 9.1.7 - version: 9.1.7 packages: @@ -238,11 +235,6 @@ packages: resolution: {integrity: sha512-wHTUcDUoZ1H5/0iVqEudYW4/kAlN5cZ3j/bXn0Dpbizl9iaUVeWSHqiOjsgk6OW2bkLclbBjzewBz6weQ1zA2Q==} engines: {node: '>=18'} - husky@9.1.7: - resolution: {integrity: sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==} - engines: {node: '>=18'} - hasBin: true - import-fresh@3.3.1: resolution: {integrity: sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==} engines: {node: '>=6'} @@ -686,8 +678,6 @@ snapshots: dependencies: ini: 4.1.1 - husky@9.1.7: {} - import-fresh@3.3.1: dependencies: parent-module: 1.0.1 diff --git a/scripts/install-tools.sh b/scripts/install-tools.sh index fe9deaa..392a045 100755 --- a/scripts/install-tools.sh +++ b/scripts/install-tools.sh @@ -39,12 +39,16 @@ fi # install node.js tools pnpm install -# add husky hooks -pnpm exec husky init -cat > .husky/pre-commit << 'HOOK' -task format && task lint && git add -A . -HOOK -cat > .husky/pre-push << 'HOOK' -task test -HOOK -echo "pnpm exec commitlint --edit \$1" > .husky/commit-msg +# install lefthook (git hooks manager) if missing — pinned via @vX.Y.Z +if ! command -v lefthook >/dev/null 2>&1; then + if command -v go >/dev/null 2>&1; then + go install github.com/evilmartians/lefthook/v2@v2.1.8 + else + echo "go not found on PATH; skipping lefthook install (git hooks will NOT be wired)" + fi +fi + +# wire git hooks via lefthook (config lives in lefthook.yml) +if command -v lefthook >/dev/null 2>&1; then + lefthook install +fi