diff --git a/.cspell.json b/.cspell.json index 0b130d14..7a3271c7 100644 --- a/.cspell.json +++ b/.cspell.json @@ -19,7 +19,8 @@ "reqwest", "safify", "supabase", - "swiper" + "swiper", + "lefthook" ], "dictionaries": [ "softwareTerms", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 106a74bc..969ca1dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: bun-version: latest - run: make setup-ci - - run: make spell-check + - run: bunx cspell --quiet . test: name: Bun Test diff --git a/.gitignore b/.gitignore index 7894de25..9754c10c 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ dist-ssr .env /.direnv +.husky diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100755 index c82ad188..00000000 --- a/.husky/pre-commit +++ /dev/null @@ -1 +0,0 @@ -make precommit diff --git a/Makefile b/Makefile index 3892e689..52564e1b 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,6 @@ LOCAL_DB := postgres://user:password@localhost:5432/database setup: if [ ! `command -v bun` ]; then echo 'ERR: Bun is required!'; exit 1; fi make sync - bunx husky @echo "auto setup is done. now do:" @echo "- edit server/.env.dev" @echo "- edit web/.env" @@ -17,6 +16,7 @@ setup-ci: make generate-sql sync: sync-server sync-web sync-root copy-common + lefthook install || true @echo '----------------------------------------------------------------------------------------------------------' @echo '| Most work is done. now running prisma-generate-sql (which might fail if .env.dev is not set configured)|' @echo '----------------------------------------------------------------------------------------------------------' @@ -80,16 +80,6 @@ dev-db: @make seed; @echo "Seeding completed." - -precommit: check-branch lint-staged spell-check - -lint-staged: - bunx lint-staged -check-branch: - @ if [ "$(git branch --show-current)" == "main" ]; then echo "Cannot make commit on main! aborting..."; exit 1; fi -spell-check: - bunx cspell --quiet . - # Sync (install/update packages, generate prisma, etc) sync-web: diff --git a/README.md b/README.md index f9d8a2e7..b8081128 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,6 @@ GNU Make が導入されています。以下は、ユーザーが使うこと - make setup (セットアップします。) - make start (build -> serve します。) - make watch (ホットリロードします。) -- make precommit (type-check, format-check, lint を実行します。husky で自動実行されます。) ### 環境構築 @@ -27,6 +26,7 @@ GNU Make が導入されています。以下は、ユーザーが使うこと - Bun (js) - GNU Make - nvm (optional) + - lefthook - `make setup` を実行します。 diff --git a/bun.lockb b/bun.lockb index 176fd1dd..b7524f52 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/flake.nix b/flake.nix index 25c451e5..e9eae472 100644 --- a/flake.nix +++ b/flake.nix @@ -27,11 +27,13 @@ biome pkg-config openssl + lefthook ] ++ [ rust-pkgs ]; shellHook = '' export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${pkgs.stdenv.cc.cc.lib}/lib + lefthook install '' + prisma.shellHook; }; }); diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 00000000..a40679ed --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,16 @@ +# Lefthook: Precommit Hook +# docs: https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md +# 必須: Lefthook +# 必須: `lefthook install` +pre-commit: + parallel: true + commands: + biome: + glob: "*" + run: biome check --write --no-errors-on-unmatched --files-ignore-unknown=true -- {staged_files} + stage_fixed: true + prevent-commit-on-main: + run: if [ "$(git branch --show-current)" == "main" ]; then echo "Cannot make commit on main! aborting..."; exit 1; fi + cspell: + glob: "*" + run: bunx cspell --quiet -- {staged_files} diff --git a/package.json b/package.json index d8731d54..a648064a 100644 --- a/package.json +++ b/package.json @@ -4,16 +4,13 @@ "description": "", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "prepare": "husky" + "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { "@biomejs/biome": "^1.9.1", - "husky": "^9.1.4", - "lint-staged": "^15.2.10", "typescript": "^5.6.2" }, "dependencies": { @@ -21,8 +18,5 @@ "cspell": "^8.14.4", "zod": "^3.23.8" }, - "lint-staged": { - "*.{js,jsx,ts,tsx,json}": ["biome check --write"] - }, "trustedDependencies": ["@biomejs/biome"] }