-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
62 lines (44 loc) · 1.48 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
# Base command
NPM_CMD = pnpm
GO_CMD = go
# Templ
TEMPL_CMD = $(GOPATH)/bin/templ
# Goose DB Migration
ifneq ("$(wildcard .env)","")
include .env
endif
MIGRATION_DIR = database/migrations
MIGRATE_SOURCE = -database $(DB_URI)
MIGRATE_CMD = $(GOPATH)/bin/migrate
ENTRYPOINT = stashbin.go
BUILD_NAME = stashbin
help:
@egrep -h '\s##\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-15s\033[0m %s\n", $$1, $$2}'
install: ## Install all dependencies
@$(GO_CMD) mod download
@$(NPM_CMD) install
generate: ## Generate templ files
@echo "Generating templ files..."
@$(TEMPL_CMD) generate
@echo "Generating static files..."
@$(NPM_CMD) run build
build: generate ## build Production Executable
go build -o $(BUILD_NAME)
dev: ## Run dev server
@echo "Running dev server..."
@$(NPM_CMD) run watch & $(GO_CMD) run $(ENTRYPOINT) && kill $!
dev-go: generate ## Run dev server (Go only)
@$(GO_CMD) run $(ENTRYPOINT)
clean: ## Cleanup the project
@echo "Cleaning up files"
@rm -f $(BINARY_NAME)
@rm -rf ./assets
@rm -rf ./view/*templ.go
version: ## Print migration version
@$(MIGRATE_CMD) -path $(MIGRATION_DIR) $(MIGRATE_SOURCE) version
revision: ## Create new migration file
@$(MIGRATE_CMD) create -ext sql -dir $(MIGRATION_DIR) $(name)
upgrade: ## Migrate the DB to the most recent version available
@$(MIGRATE_CMD) -path $(MIGRATION_DIR) $(MIGRATE_SOURCE) up
downgrade: ## Roll back the DB version by 1
@$(MIGRATE_CMD) -path $(MIGRATION_DIR) $(MIGRATE_SOURCE) down