11FILENAME =presidium
22DOCSDIR =docs
33.DEFAULT_GOAL =help
4- .PHONY : build test dist clean fmt vet tidy coverage_report help
4+ .PHONY : build test dist clean fmt vet tidy coverage_report help update-themes prepare-themes restore-themes lint checks serve-docs
55
66help : # # Display available targets
77 @grep -E ' ^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | awk ' BEGIN {FS = ":.*?## "}; {printf " %-18s %s\n", $$1, $$2}'
88
9- build : # # Build the presidium binary
10- go build -tags extended -o $(FILENAME ) .
9+ update-themes : # # Update theme submodules to their latest versions
10+ @echo " Updating theme submodules to latest..."
11+ @git submodule update --remote themes/presidium-styling-base themes/presidium-layouts-base themes/presidium-layouts-blog
12+ @echo " Theme submodules updated."
1113
12- test : # # Run tests with coverage
14+ prepare-themes : # # Prepare themes for embedding (rename go.mod to make embeddable)
15+ @echo " Preparing themes for embedding..."
16+ @for theme in themes/presidium-* ; do \
17+ if [ -f " $$ theme/go.mod" ]; then \
18+ echo " Renaming $$ theme/go.mod -> go.mod.tmpl" ; \
19+ mv " $$ theme/go.mod" " $$ theme/go.mod.tmpl" ; \
20+ fi ; \
21+ if [ -f " $$ theme/go.sum" ]; then \
22+ echo " Renaming $$ theme/go.sum -> go.sum.tmpl" ; \
23+ mv " $$ theme/go.sum" " $$ theme/go.sum.tmpl" ; \
24+ fi ; \
25+ done
26+
27+ restore-themes : # # Restore theme go.mod files to original names
28+ @echo " Restoring theme go.mod files..."
29+ @for theme in themes/presidium-* ; do \
30+ if [ -f " $$ theme/go.mod.tmpl" ]; then \
31+ echo " Renaming $$ theme/go.mod.tmpl -> go.mod" ; \
32+ mv " $$ theme/go.mod.tmpl" " $$ theme/go.mod" ; \
33+ fi ; \
34+ if [ -f " $$ theme/go.sum.tmpl" ]; then \
35+ echo " Renaming $$ theme/go.sum.tmpl -> go.sum" ; \
36+ mv " $$ theme/go.sum.tmpl" " $$ theme/go.sum" ; \
37+ fi ; \
38+ done
39+
40+ build : prepare-themes # # Build the presidium binary
41+ go build -tags extended -o $(FILENAME ) . ; status=$$? ; $(MAKE ) restore-themes ; rstatus=$$? ; if [ $$ status -eq 0 ]; then status=$$ rstatus; fi ; exit $$ status
42+
43+ test : prepare-themes # # Run tests with coverage
1344 @mkdir -p reports
14- go test -race -timeout 120s ./... -coverprofile=reports/tests-cov.out
45+ go test -race -timeout 120s ./... -coverprofile=reports/tests-cov.out ; status= $$? ; $( MAKE ) restore-themes ; rstatus= $$? ; if [ $$ status -eq 0 ] ; then status= $$ rstatus ; fi ; exit $$ status
1546
1647fmt : # # Format Go source files
1748 go fmt ./...
1849
19- vet : # # Run go vet
20- go vet ./...
50+ vet : prepare-themes # # Run go vet
51+ go vet ./... ; status= $$? ; $( MAKE ) restore-themes ; rstatus= $$? ; if [ $$ status -eq 0 ] ; then status= $$ rstatus ; fi ; exit $$ status
2152
2253tidy : # # Tidy and verify module dependencies
2354 go mod tidy && go mod verify
2455
25- clean : # # Remove build artifacts
26- rm -fr " dist"
56+ clean : restore-themes # # Remove build artifacts and restore themes
57+ rm -fr " dist" " $( FILENAME ) " " presidium-test "
2758
2859coverage_report : # # Open coverage report in browser
2960 @go tool cover -html=reports/tests-cov.out
3061
31- dist : # # Build distribution binary
32- mkdir -p " dist"
33- go build -trimpath -o " dist/presidium" --tags extended
34-
35- checks : tidy fmt vet lint test build
62+ dist : prepare-themes # # Build distribution binary
63+ mkdir -p " dist" && go build -trimpath -o " dist/presidium" --tags extended ; status=$$? ; $(MAKE ) restore-themes ; rstatus=$$? ; if [ $$ status -eq 0 ]; then status=$$ rstatus; fi ; exit $$ status
3664
3765serve-docs :
3866 cd $(DOCSDIR ) && make serve
3967
40- lint :
41- golangci-lint run --timeout 10m
68+ lint : prepare-themes # # Run golangci-lint
69+ golangci-lint run --timeout 10m ; status= $$? ; $( MAKE ) restore-themes ; rstatus= $$? ; if [ $$ status -eq 0 ] ; then status= $$ rstatus ; fi ; exit $$ status
0 commit comments