Add some helpful documentation to the makefile while I'm here

This commit is contained in:
R Tyler Croy 2019-06-22 08:24:40 -07:00
parent 4e57668226
commit c459131c59
No known key found for this signature in database
GPG Key ID: E5C92681BEF6CEA2
1 changed files with 18 additions and 13 deletions

View File

@ -10,24 +10,29 @@ IMAGE_TAG:=$(shell git rev-parse HEAD)
JEST_ARGS=--runInBand --bail --forceExit --detectOpenHandles
# Cute hack thanks to:
# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help: ## Display this help text
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
all: build check container
container: Dockerfile depends
container: Dockerfile depends ## Build the Docker container
docker build -t $(IMAGE_NAME):$(IMAGE_TAG) .
docker tag $(IMAGE_NAME):$(IMAGE_TAG) $(IMAGE_NAME):latest
publish:
publish: ## Publish the Docker container to docker hub
docker push ${IMAGE_NAME}:$(IMAGE_TAG)
docker push $(IMAGE_NAME):latest
depends: package.json package-lock.json
depends: package.json package-lock.json ## Install node dependencies
if [ ! -d node_modules ]; then npm install; fi;
build: depends
build: depends ## Compile TypeScript
$(TSC)
check: build depends migrate
check: build depends migrate ## Run all tests
# Running with docker-compose since our tests require a database to be
# present
$(COMPOSE) run --rm \
@ -35,22 +40,22 @@ check: build depends migrate
node \
/usr/local/bin/node $(JEST) $(JEST_ARGS)
clean:
clean: ## Remove node_modules and clean up
$(COMPOSE) down || true
rm -rf node_modules
debug-jest:
debug-jest: ## Launch jest with debugger on port 9229
node --inspect-brk=0.0.0.0:9229 $(JEST)
debug-db:
$(COMPOSE) run --rm db psql -h db -U postgres uplink_development
generate-event:
generate-event: ## Send a sample event to a service running on localhost:3030
curl -d '{"type":"stapler", "correlator" : "86e3f00d-b12a-4391-bbf2-6f01c1606e17", "payload" : {"timestamp" : "$(shell date)", "hi" : "there"}}' \
-H "Content-Type: application/json" \
http://localhost:3030/events
migrate: depends
migrate: depends ## Run migrations against the local development database
$(COMPOSE) up -d db
@echo ">> waiting a moment to make sure the database comes online.."
@sleep 3
@ -59,7 +64,7 @@ migrate: depends
$(COMPOSE) run --rm node \
/usr/local/bin/node $(SEQUELIZE) db:seed:all
watch: migrate
watch: migrate ## Run the tests in "watch" mode
# Running with docker-compose since our tests require a database to be
# present
$(COMPOSE) run --rm \
@ -67,14 +72,14 @@ watch: migrate
node \
/usr/local/bin/node $(JEST) $(JEST_ARGS) --watch --coverage=false
watch-compile:
watch-compile: ## Run the TypeScript compiler in "watch' mode
$(TSC) -w
run: build
run: build ## Run the uplink service first
@echo ">> Make sure you run migrations first!"
@sleep 1
$(COMPOSE) up
.PHONY: all depends build clean check watch run
.PHONY: all depends build clean check help run watch
# vim: set et