1- color_red := $(shell printf "\e[1;31m")
2- color_green := $(shell printf "\e[1;32m")
3- color_yellow := $(shell printf "\e[1;33m")
4- color_blue := $(shell printf "\e[1;34m")
5- color_magenta := $(shell printf "\e[1;35m")
6- color_cyan := $(shell printf "\e[1;36m")
1+ # Colors
2+ color_green := $(shell printf "\e[32m") # Green color
73color_reset := $(shell printf "\e[0m")
84
9- EXAMPLES := \
10- _examples/a-h-templ-single-toast \
11- _examples/a-h-templ-multiple-toasts \
12- _examples/custom-animations \
13- _examples/custom-icons \
14- _examples/theming \
15- _examples/variants \
16- _examples/go-html-template-single-toast \
17- _examples/go-html-template-multiple-toasts
18-
195# ==================================================================================== #
206# HELPERS
217# ==================================================================================== #
@@ -26,61 +12,91 @@ help: ## Print this help message
2612 @echo " "
2713 @echo " Available Actions:"
2814 @echo " "
29- @awk -F ' :|##' ' /^[^\t].+?:.*?##/ {printf " \033[36m%-15s\033[0m %s\n", $$1, $$NF}' $(MAKEFILE_LIST ) | sort
15+ @awk -v green=" $( color_green) " -v reset=" $( color_reset) " -F ' :|##' \
16+ ' /^[^\t].+?:.*?##/ {printf "%s* %-15s%s %s\n", green, $$1, reset, $$NF}' $(MAKEFILE_LIST ) | sort
3017 @echo " "
3118
3219# ==================================================================================== #
33- # PRIVATE BUILDERS
20+ # PRIVATE TARGETS
3421# ==================================================================================== #
35- _process_templ_files :
36- @echo " $( color_magenta) Process TEMPL files$( color_reset) "
37-
38- @echo "$(color_cyan) * Formatting templ files...$(color_reset)"
39- @templ fmt .
40-
41- @echo "$(color_cyan) * Generating templ funcs...$(color_reset)"
42- @templ generate
43-
44- @echo "$(color_green)Done!$(color_reset)"
22+ .PHONY : modernize
23+ modernize :
24+ @modernize -test ./...
4525
46- _go_tools :
47- @echo " "
48- @echo " $( color_magenta) Run go tools...$( color_reset) "
49-
50- @echo "$(color_cyan) * Downloading modules...$(color_reset)"
51- @go mod download; go mod tidy
52- @go build -v ./...
53- @echo "$(color_cyan) * Running golangci-lint...$(color_reset)"
26+ .PHONY : lint
27+ lint :
5428 @golangci-lint run ./...
55- @echo "$(color_cyan) * Running tests...$(color_reset)"
56- @$(MAKE) _test
57-
58- @echo "$(color_green)Done!$(color_reset)"
5929
60- _test :
61- @go test -race -covermode=atomic ./...
30+ .PHONY : test/view-total-coverage
31+ test/view-total-coverage :
32+ @echo " "
33+ @echo " Total Coverage:"
34+ @go tool cover -func=profile.cov | grep total | awk -F ' [[:space:]]+' ' {print $$NF}'
35+
36+ .PHONY : test/view-coverage
37+ test/view-coverage :
38+ @go tool cover -html=profile.cov
39+ @echo " Coverage report displayed in your default browser."
40+
41+ .PHONY : live/templ
42+ live/templ :
43+ @templ generate --watch --proxy=" http://localhost:3300" --open-browser=true
44+
45+ .PHONY : live/server
46+ live/server :
47+ @go run github.com/air-verse/
[email protected] \ 48+ --build.cmd " go build -o tmp/bin/main ./examples" \
49+ --build.bin " tmp/bin/main" \
50+ --build.delay " 100" \
51+ --build.exclude_dir " assets,docs" \
52+ --build.include_ext " go" \
53+ --build.stop_on_error " false" \
54+ --misc.clean_on_exit true
55+
56+ .PHONY : live/sync
57+ live/sync :
58+ @go run github.com/air-verse/
[email protected] \ 59+ --build.cmd " tempo sync && templ generate -notify-proxy" \
60+ --build.bin " true" \
61+ --build.delay " 100" \
62+ --build.exclude_dir " " \
63+ --build.include_dir " assets" \
64+ --build.include_ext " js,css"
6265
6366# ==================================================================================== #
64- # BUILDERS
67+ # PUBLIC TARGETS
6568# ==================================================================================== #
66-
67- examples : # # Process templ files in the _examples folder
68- @for example in $(EXAMPLES ) ; do \
69- pushd $$ example && templ fmt . && templ generate && popd ; \
70- done
71-
72- test : # # Run go tests
73- @$(MAKE ) _test
74-
75- templ : # # Process TEMPL files
76- @$(MAKE ) _process_templ_files
77-
78- clean :
79- @echo " "
80- @echo " $( color_magenta) Clean up$( color_reset) "
81- @find . -type f -name ' *.grc.bk' -exec rm -f {} +
82- @find . -type f -name ' *_templ.txt' -exec rm -f {} +
83- @echo " $( color_green) Done!$( color_reset) "
84-
85- build : # # The main build target
86- @$(MAKE ) templ _go_tools
69+ .PHONY : test
70+ test : # # Run all tests and generate coverage report
71+ @go test -count=1 -timeout 30s $(shell go list ./... | grep -Ev 'examples|components') -covermode=atomic -coverprofile=profile.cov
72+ @$(MAKE ) test/view-total-coverage
73+
74+ .PHONY : test/coverage
75+ test/coverage : # # Run go tests and use go tool cover
76+ @$(MAKE ) test/force
77+ @$(MAKE ) test/view-coverage
78+
79+ .PHONY : test/force
80+ test/force : # # Clean go tests cache and run all tests
81+ @go clean -testcache
82+ @$(MAKE ) test
83+
84+ .PHONY : templ
85+ templ : # # Run all tests and generate coverage report
86+ @templ fmt . && templ generate
87+
88+ .PHONY : dev
89+ dev : # # Run the dev server with live reload
90+ make -j3 live/templ live/server live/sync
91+
92+ .PHONY : pre-build
93+ pre-build : # # Run pre-build tasks
94+ @$(MAKE ) modernize
95+ @$(MAKE ) lint
96+ @$(MAKE ) test/force
97+
98+ .PHONY : build
99+ build : # # Build for production with minified asset files
100+ @$(MAKE ) pre-build
101+ @tempo sync --prod
102+ @$(MAKE ) templ
0 commit comments