From f1d312bfce4783332b74c651293e746d0ff22065 Mon Sep 17 00:00:00 2001 From: "Gustavo L de Mello (Guz)" Date: Mon, 7 Oct 2024 19:12:06 -0300 Subject: [PATCH] chore: configure makefile for development --- .gitignore | 6 ++++++ makefile | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 makefile diff --git a/.gitignore b/.gitignore index 03bd412..4cf3c21 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,7 @@ *.env +*_templ.go +node_modules/ +bin/ +tmp/ +dist/ +assets/css/uno.css diff --git a/makefile b/makefile new file mode 100644 index 0000000..02aa2cb --- /dev/null +++ b/makefile @@ -0,0 +1,57 @@ + +PORT?=8080 + +lint: + go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1 run + +fmt: + go fmt ./. + go run github.com/a-h/templ/cmd/templ@v0.2.707 fmt . + go run mvdan.cc/gofumpt@v0.7.0 -l -w . + go run github.com/segmentio/golines@v0.12.2 -w . + go run golang.org/x/tools/cmd/goimports@v0.26.0 -w -l . + +dev/templ: + go run github.com/a-h/templ/cmd/templ@v0.2.707 generate --watch \ + --proxy=http://localhost:$(PORT) \ + --open-browser=false + +dev/server: + go run github.com/air-verse/air@v1.52.2 \ + --build.cmd "go build ./cmd/serve -o tmp/bin/main" \ + --build.bin "tmp/bin/main" \ + --build.exclude_dir "node_modules" \ + --build.include_ext "go" \ + --build.stop_on_error "false" \ + --misc.clean_on_exit true \ + -- -p $(PORT) -d + +dev/sync_assets: + go run github.com/air-verse/air@v1.52.2 \ + --build.cmd "go run github.com/a-h/templ/cmd/templ@v0.2.707 generate --notify-proxy" \ + --build.bin "true" \ + --build.delay "100" \ + --build.exclude_dir "" \ + --build.include_dir "static" \ + --build.include_ext "js,css" + +dev/assets/css: + npx unocss --watch + +dev: + go run github.com/joho/godotenv/cmd/godotenv@v1.5.1 \ + make -j4 dev/templ dev/server dev/sync_assets dev/assets/css + +build/templ: + go run github.com/a-h/templ/cmd/templ@v0.2.707 generate + +build/server: + go build ./cmd/server -o dist/server + +build/assets: + npx unocss + +clean: + if [[ -d "dist" ]]; then rm -r ./dist; fi + if [[ -d "tmp" ]]; then rm -r ./tmp; fi + if [[ -d "bin" ]]; then rm -r ./bin; fi