-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
87 lines (53 loc) · 1.71 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
75
76
77
78
79
80
81
82
83
84
85
86
87
GO_BIN = go
BIN_DIR = bin
TMP_DIR = tmp
PROJECT_PACKAGE = github.com/kevinmarquesp/go-postr
PROJECT_MAIN = cmd/application
PROJECT_BIN = gopostr-application
MIGRATIONS_TARGET = ./db/sqlite/migrations
DATABASE_URL = ./tmp/application.db
DATABASE_PROVIDER = sqlite3
PORT = 8000
NPM = pnpm
# Project build related recipes.
run: build
./$(BIN_DIR)/$(PROJECT_BIN)
build: bin tailwind templ
build-bin:
$(GO_BIN) build -o $(BIN_DIR)/$(PROJECT_BIN) $(PROJECT_PACKAGE)/$(PROJECT_MAIN)
clean:
rm -rf $(BIN_DIR) $(TMP_DIR)
rm -rf */**/*_templ.{go,txt}
.PHONY: run build build-bin clean
# Goose recipes to handle the migration files.
dep-goose:
$(GO_BIN) install github.com/pressly/goose/v3/cmd/goose@latest
goose-add:
@mkdir -vp $(MIGRATIONS_TARGET)
@read -rp "(read) File name: " file; \
GOOSE_DBSTRING=$(DATABASE_URL) goose -dir=$(MIGRATIONS_TARGET) $(DATABASE_PROVIDER) create "$$file" sql
goose-up:
GOOSE_DBSTRING=$(DATABASE_URL) goose -dir=$(MIGRATIONS_TARGET) $(DATABASE_PROVIDER) up
goose-reset:
GOOSE_DBSTRING=$(DATABASE_URL) goose -dir=$(MIGRATIONS_TARGET) $(DATABASE_PROVIDER) reset
.PHONY: migration-add migration-up migration-reset
# Using Air to recompile the project when something changes.
dep-air:
go install github.com/air-verse/air@latest
air:
air -build.bin $(BIN_DIR)/$(PROJECT_BIN)
.PHONY: dep-air
# Generate the views files with Templ
dep-templ:
go install github.com/a-h/templ/cmd/templ@latest
templ:
templ generate
templ-watch:
templ generate -watch -proxy=http://localhost:$(PORT) -open-browser=false
.PHONY: dep-templ templ templ-watch
# Tailwindcss generation scripts with node.
tailwind:
$(NPM) run tailwind
tailwind-watch:
$(NPM) run tailwind:watch
.PHONY: tailwind tailwind-watch