-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
74 lines (63 loc) · 1.99 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
69
70
71
72
73
74
# Simple Makefile for a Go project
# Build the application
all: build test
templ-install:
@if ! command -v templ > /dev/null; then \
read -p "Go's 'templ' 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/a-h/templ/cmd/templ@latest; \
if [ ! -x "$$(command -v templ)" ]; then \
echo "templ installation failed. Exiting..."; \
exit 1; \
fi; \
else \
echo "You chose not to install templ. Exiting..."; \
exit 1; \
fi; \
fi
tailwind-install:
@if [ ! -f tailwindcss ]; then curl -sL https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 -o tailwindcss; fi
@chmod +x tailwindcss
build: tailwind-install templ-install
@echo "Building..."
@templ generate
@./tailwindcss -i cmd/web/assets/css/input.css -o cmd/web/assets/css/output.css
@go build -o main cmd/api/main.go
# Run the application
run:
@go run cmd/api/main.go
# Test the application
test:
@echo "Testing..."
@go test ./... -v
# Clean the binary
clean:
@echo "Cleaning..."
@rm -f 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/air-verse/air@latest; \
air; \
echo "Watching...";\
else \
echo "You chose not to install air. Exiting..."; \
exit 1; \
fi; \
fi
.PHONY: all build run test clean watch tailwind-install templ-install
# Migrations
# apply migrations
# migrate-up:
# goose -dir ./internal/database/migrations sqlite3 ./test.db up
# rollback
# migrate-rollback:
# goose -dir ./internal/database/migrations sqlite3 ./test.db down
# SQLC
sqlc-generate:
sqlc generate