Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Rework Makefile structure #15

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 45 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@

# -------------------------------------------------------------------------------------------------
# main
# -------------------------------------------------------------------------------------------------

## help: Display help
.PHONY: help
help: Makefile
@echo "Usage: make COMMAND"
@echo
@echo "Commands:"
@sed -n 's/^##//p' $< | column -ts ':' | sed -e 's/^/ /'

## tools: Install github.com/a-h/templ/cmd/templ@latest
.PHONY: tools
tools:
go install github.com/a-h/templ/cmd/templ@latest

## get-deps: Download go dependencies
.PHONY: get-deps
get-deps:
go mod download

## generate: Compile templ files
.PHONY: generate
generate:
~/go/bin/templ generate
all: help

## build: Compile templ files and build application
.PHONY: build
Expand All @@ -33,16 +15,6 @@ build: get-deps generate
start: get-deps generate
go run ./cmd/app

## get-air: Install live reload server github.com/cosmtrek/air@latest
.PHONY: get-air
get-air:
go install github.com/cosmtrek/air@latest

## air: Build and start application in live reload mode via air
.PHONY: air
air: get-deps generate
air

## build-docker: Build Docker container image with this app
.PHONY: build-docker
build-docker:
Expand All @@ -53,7 +25,48 @@ build-docker:
run-docker:
docker run --rm -it -p 8080:8080 $(shell basename $(PWD)):latest

# -------------------------------------------------------------------------------------------------
# testing
# -------------------------------------------------------------------------------------------------

## test: Run unit tests
.PHONY: test
test:
@go test ./...

# -------------------------------------------------------------------------------------------------
# tools && shared
# -------------------------------------------------------------------------------------------------

## get-deps: Download go dependencies
.PHONY: get-deps
get-deps:
go mod download

## tools: Install github.com/a-h/templ/cmd/templ@latest
.PHONY: tools
tools:
go install github.com/a-h/templ/cmd/templ@latest

## get-air: Install live reload server github.com/cosmtrek/air@latest
.PHONY: get-air
get-air:
go install github.com/cosmtrek/air@latest

## generate: Compile templ files
.PHONY: generate
generate:
~/go/bin/templ generate

## air: Build and start application in live reload mode via air
.PHONY: air
air: get-deps generate
air

## help: Display help
.PHONY: help
help: Makefile
@echo "Usage: make COMMAND"
@echo
@echo "Commands:"
@sed -n 's/^##//p' $< | column -ts ':' | sed -e 's/^/ /'