From 63148d7ca1901f88239c931cfcbc47a564bc0be3 Mon Sep 17 00:00:00 2001 From: mkelvers Date: Mon, 20 Apr 2026 01:06:15 +0200 Subject: [PATCH] chore: add justfile and lefthook for local pre-push checks --- bun.lock | 23 +++++++++++++++++++++++ justfile | 40 ++++++++++++++++++++++++++++++++++++++++ lefthook.yml | 25 +++++++++++++++++++++++++ package.json | 1 + 4 files changed, 89 insertions(+) create mode 100644 justfile create mode 100644 lefthook.yml diff --git a/bun.lock b/bun.lock index d1199eb..f3e12ba 100644 --- a/bun.lock +++ b/bun.lock @@ -6,6 +6,7 @@ "name": "myanimelist-ui", "devDependencies": { "@tailwindcss/cli": "^4.2.2", + "lefthook": "^2.1.6", "tailwindcss": "^4.2.2", "typescript": "^6.0.3", }, @@ -92,6 +93,28 @@ "jiti": ["jiti@2.6.1", "", { "bin": { "jiti": "lib/jiti-cli.mjs" } }, "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ=="], + "lefthook": ["lefthook@2.1.6", "", { "optionalDependencies": { "lefthook-darwin-arm64": "2.1.6", "lefthook-darwin-x64": "2.1.6", "lefthook-freebsd-arm64": "2.1.6", "lefthook-freebsd-x64": "2.1.6", "lefthook-linux-arm64": "2.1.6", "lefthook-linux-x64": "2.1.6", "lefthook-openbsd-arm64": "2.1.6", "lefthook-openbsd-x64": "2.1.6", "lefthook-windows-arm64": "2.1.6", "lefthook-windows-x64": "2.1.6" }, "bin": { "lefthook": "bin/index.js" } }, "sha512-w9sBoR0mdN+kJc3SB85VzpiAAl451/rxdCRcZlwW71QLjkeH3EBQFgc4VMj5apePychYDHAlqEWTB8J8JK/j1Q=="], + + "lefthook-darwin-arm64": ["lefthook-darwin-arm64@2.1.6", "", { "os": "darwin", "cpu": "arm64" }, "sha512-hyB7eeiX78BS66f70byTJacDLC/xV1vgMv9n+idFUsrM7J3Udd/ag9Ag5NP3t0eN0EqQqAtrNnt35EH01lxnRQ=="], + + "lefthook-darwin-x64": ["lefthook-darwin-x64@2.1.6", "", { "os": "darwin", "cpu": "x64" }, "sha512-5Ka6cFxiH83krt+OMRQtmS6zqoZR5SLXSudLjTbZA1c3ZqF0+dqkeb4XcB6plx6WR0GFizabuc6Bi3iXPIe1eQ=="], + + "lefthook-freebsd-arm64": ["lefthook-freebsd-arm64@2.1.6", "", { "os": "freebsd", "cpu": "arm64" }, "sha512-VswyOg5CVN3rMaOJ2HtnkltiMKgFHW/wouWxXsV8RxSa4tgWOKxM0EmSXi8qc2jX+LRga6B0uOY6toXS01zWxA=="], + + "lefthook-freebsd-x64": ["lefthook-freebsd-x64@2.1.6", "", { "os": "freebsd", "cpu": "x64" }, "sha512-vXsCUFYuVwrVWwcypB7Zt2Hf+5pl1V1la7ZfvGYZaTRURu0zF/XUnMF/nOz/PebGv0f4x/iOWXWwP7E42xRWsg=="], + + "lefthook-linux-arm64": ["lefthook-linux-arm64@2.1.6", "", { "os": "linux", "cpu": "arm64" }, "sha512-WDJiQhJdZOvKORZd+kF/ms2l6NSsXzdA9ahflyr65V90AC4jES223W8VtEMbGPUtHuGWMEZ/v/XvwlWv0Ioz9g=="], + + "lefthook-linux-x64": ["lefthook-linux-x64@2.1.6", "", { "os": "linux", "cpu": "x64" }, "sha512-C18nCd7nTX1AVL4TcvwMmLAO1VI1OuGluIOTjiPkBQ746Ls1HhL5rl//jMPACmT28YmxIQJ2ZcLPNmhvEVBZvw=="], + + "lefthook-openbsd-arm64": ["lefthook-openbsd-arm64@2.1.6", "", { "os": "openbsd", "cpu": "arm64" }, "sha512-mZOMxM8HiPxVFXDO3PtCUbH4GB8rkveXhsgXF27oAZTYVzQ3gO9vT6r/pxit6msqRXz3fvcwimLVJgb8eRsa8A=="], + + "lefthook-openbsd-x64": ["lefthook-openbsd-x64@2.1.6", "", { "os": "openbsd", "cpu": "x64" }, "sha512-sG9ALLZSnnMOfXu+B7SmxFhJhuoAh4bqi5En5aaHJET48TqrLOcWWZuH+7ArFM6gr/U5KfSUvdmHFmY8WqCcIg=="], + + "lefthook-windows-arm64": ["lefthook-windows-arm64@2.1.6", "", { "os": "win32", "cpu": "arm64" }, "sha512-lD8yFWY4Csuljd0Rqs7EQaySC0VvDf7V3rN1FhRMUISTRDHutebIom1Loc8ckQPvKYGC6mftT9k0GvipsS+Brw=="], + + "lefthook-windows-x64": ["lefthook-windows-x64@2.1.6", "", { "os": "win32", "cpu": "x64" }, "sha512-q4z2n3xucLscoWiyMwFViEj3N8MDSkPulMwcJYuCYFHoPhP1h+icqNu7QRLGYj6AnVrCQweiUJY3Tb2X+GbD/A=="], + "lightningcss": ["lightningcss@1.32.0", "", { "dependencies": { "detect-libc": "^2.0.3" }, "optionalDependencies": { "lightningcss-android-arm64": "1.32.0", "lightningcss-darwin-arm64": "1.32.0", "lightningcss-darwin-x64": "1.32.0", "lightningcss-freebsd-x64": "1.32.0", "lightningcss-linux-arm-gnueabihf": "1.32.0", "lightningcss-linux-arm64-gnu": "1.32.0", "lightningcss-linux-arm64-musl": "1.32.0", "lightningcss-linux-x64-gnu": "1.32.0", "lightningcss-linux-x64-musl": "1.32.0", "lightningcss-win32-arm64-msvc": "1.32.0", "lightningcss-win32-x64-msvc": "1.32.0" } }, "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ=="], "lightningcss-android-arm64": ["lightningcss-android-arm64@1.32.0", "", { "os": "android", "cpu": "arm64" }, "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg=="], diff --git a/justfile b/justfile new file mode 100644 index 0000000..168cf23 --- /dev/null +++ b/justfile @@ -0,0 +1,40 @@ +set shell := ["bash", "-c"] +set dotenv-load := true + +fmt: + go fmt ./... + +lint: + go fmt ./... && go vet ./... + +test: + go test ./... + +build-go: + go build -o server ./cmd/server + +build-css: + bunx @tailwindcss/cli -i ./static/style.css -o ./dist/tailwind.css + +build-ts: + bun build ./static/*.ts --outdir ./dist --target browser + +build: build-go build-css build-ts + +typecheck: + bunx tsc -p tsconfig.json --noEmit + +check: lint test typecheck build + +install-hooks: + bunx lefthook install + +dev: build + ./server + +db_migrate: + go run ./cmd/server migrate + +clean: + rm -rf dist/* + rm -f server diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 0000000..c62c09d --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,25 @@ +{ + "$schema": "https://json.schemastore.org/lefthook.json", + "pre-push": { + "commands": { + "go-fmt": { + cmd: "go fmt ./..." + }, + "go-vet": { + cmd: "go vet ./..." + }, + "go-test": { + cmd: "go test ./..." + }, + "ts-typecheck": { + cmd: "bunx tsc -p tsconfig.json --noEmit" + }, + "build-assets": { + cmd: "bun run build:assets" + }, + "go-build": { + cmd: "go build -o server ./cmd/server" + } + } + } +} diff --git a/package.json b/package.json index 4c11024..d1e9b9e 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ }, "devDependencies": { "@tailwindcss/cli": "^4.2.2", + "lefthook": "^2.1.6", "tailwindcss": "^4.2.2", "typescript": "^6.0.3" }