-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (55 loc) · 1.52 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Simple Makefile for a Go project
# Build the application
all: build
build:
@echo "Building..."
@templ generate
@go build -o ./bin/main cmd/api/main.go
build_dev:
@echo "Building..."
@go build -tags local -o ./bin/main cmd/api/main.go
# Tailwind generation watch
tailwind:
@echo "Generating Tailwind CSS..."
@pnpm tailwindcss -i ./input.css -o ./cmd/web/assets/tailwind.css --watch
sqlc:
@echo "Generating SQLC..."
@sqlc generate
templ:
@echo "Generating templates..."
@templ generate -watch -proxy=http://localhost:8080 -open-browser=false
templ_fmt:
@echo "Formatting templates..."
@templ fmt ./internal/views
templ_clean:
@echo "Cleaning templates..."
@find ./internal/views -type f -name "*_templ.go" -delete
@find ./internal/views -type f -name "*_templ.txt" -delete
# Run the application
run:
@go run cmd/api/main.go
# Test the application
test:
@echo "Testing..."
@go test ./tests -v
# Clean the binary
clean:
@echo "Cleaning..."
@rm -f ./bin/main
# Live Reload
watch:
@if command -v air > /dev/null; then \
air; \
echo "Watching...";\
else \
read -p "Go's 'air' is not installed on your machine. Do you want to install it? [Y/n] " choice; \
if [ "$$choice" != "n" ] && [ "$$choice" != "N" ]; then \
go install github.com/cosmtrek/air@latest; \
air; \
echo "Watching...";\
else \
echo "You chose not to install air. Exiting..."; \
exit 1; \
fi; \
fi
.PHONY: all build run test clean tailwind templ watch sqlc templ_fmt templ_clean build_dev