-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (110 loc) Β· 4.48 KB
/
Copy pathMakefile
File metadata and controls
129 lines (110 loc) Β· 4.48 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# ---------------------------------------
# π΄ββ οΈ Project: Blip
# ---------------------------------------
PROJECT_NAME := blip
PORT ?= 3000
BUN_VERSION ?= 1.2
IMAGE := $(PROJECT_NAME)
# --------------------------------------------------------------------
# π οΈ Shell Configuration
# --------------------------------------------------------------------
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
# Colors for flair
CLR_TEAL = \033[0;36m
CLR_YELLOW = \033[0;33m
CLR_GREEN = \033[0;32m
CLR_RESET = \033[0m
# --------------------------------------------------------------------
# β‘ Phony Targets
# --------------------------------------------------------------------
.PHONY: help dev test \
build run stop logs clean \
commit \
c-feat c-fix c-chore c-refactor c-test \
c-docs c-style c-perf c-ci c-build
# --------------------------------------------------------------------
# π Help
# --------------------------------------------------------------------
## help: π Display this help message
help:
@printf "$(CLR_TEAL)π΄ββ οΈ Blip β Pirate Deduction Game$(CLR_RESET)\n"
@printf "Usage: make <target>\n\n"
@printf "Available targets:\n"
@sed -n 's/^##//p' $(MAKEFILE_LIST) | while IFS=':' read -r target help; do \
printf " $(CLR_GREEN)%-18s$(CLR_RESET) %s\n" "$$target" "$$help"; \
done
@printf "\n"
# --------------------------------------------------------------------
# π Development
# --------------------------------------------------------------------
## dev: π Start the dev server on http://localhost:$(PORT)
dev:
@printf "$(CLR_TEAL)β π Starting dev server at http://localhost:$(PORT)...$(CLR_RESET)\n"
@bun run dev
## test: π§ͺ Run unit tests
test:
@printf "$(CLR_TEAL)β π§ͺ Running tests...$(CLR_RESET)\n"
@bun test
@printf "$(CLR_GREEN)β
All tests passed!$(CLR_RESET)\n"
# --------------------------------------------------------------------
# π³ Docker
# --------------------------------------------------------------------
## build: π³ Build the Docker image
build:
@printf "$(CLR_TEAL)β π³ Building $(IMAGE):latest (Bun $(BUN_VERSION))...$(CLR_RESET)\n"
@docker build \
--build-arg BUN_VERSION=$(BUN_VERSION) \
--build-arg PORT=$(PORT) \
-t $(IMAGE):latest .
@printf "$(CLR_GREEN)β
Image ready: $(IMAGE):latest$(CLR_RESET)\n"
## run: β Build and run the container (detached)
run: build
@printf "$(CLR_TEAL)β β Launching $(IMAGE) at http://localhost:$(PORT)...$(CLR_RESET)\n"
@docker run -d -p $(PORT):$(PORT) --name $(PROJECT_NAME) $(IMAGE):latest
@printf "$(CLR_GREEN)β
Container running β open http://localhost:$(PORT)$(CLR_RESET)\n"
## stop: π Stop and remove the container
stop:
@printf "$(CLR_TEAL)β π Stopping $(PROJECT_NAME)...$(CLR_RESET)\n"
@docker stop $(PROJECT_NAME) && docker rm $(PROJECT_NAME) 2>/dev/null || \
printf "$(CLR_YELLOW)β οΈ No running container named $(PROJECT_NAME).$(CLR_RESET)\n"
@printf "$(CLR_GREEN)β
Stopped.$(CLR_RESET)\n"
## logs: π Tail container logs
logs:
@printf "$(CLR_TEAL)β π Tailing logs for $(PROJECT_NAME)...$(CLR_RESET)\n"
@docker logs -f $(PROJECT_NAME)
## clean: π§Ή Remove the Docker image
clean:
@printf "$(CLR_TEAL)β π§Ή Removing image $(IMAGE):latest...$(CLR_RESET)\n"
@docker rmi $(IMAGE):latest 2>/dev/null || \
printf "$(CLR_YELLOW)β οΈ Image not found.$(CLR_RESET)\n"
@printf "$(CLR_GREEN)β¨ Clean complete!$(CLR_RESET)\n"
# --------------------------------------------------------------------
# πΏ Git / Conventional Commits
# --------------------------------------------------------------------
## commit: πΎ Commit all changes (usage: make commit MSG="your message")
commit:
@if [ -z "$(MSG)" ]; then \
printf "$(CLR_YELLOW)β Error: MSG is required.$(CLR_RESET)\n"; \
printf "Usage: make commit MSG=\"your message\"\n"; \
exit 1; \
fi
@git add .
@git commit -m "$(MSG)"
@printf "$(CLR_GREEN)β
Committed: $(MSG)$(CLR_RESET)\n"
# Conventional commit shortcuts β usage: make c-feat MSG="add something"
define commit_template
c-$1:
@$(MAKE) --no-print-directory commit MSG="$(1): $$(MSG)"
endef
$(eval $(call commit_template,feat))
$(eval $(call commit_template,fix))
$(eval $(call commit_template,chore))
$(eval $(call commit_template,refactor))
$(eval $(call commit_template,test))
$(eval $(call commit_template,docs))
$(eval $(call commit_template,style))
$(eval $(call commit_template,perf))
$(eval $(call commit_template,ci))
$(eval $(call commit_template,build))