-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
85 lines (67 loc) · 2.27 KB
/
Makefile
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
.DEFAULT_GOAL := help
VERSION := $(shell cat server.go | grep "const Version ="| cut -d"\"" -f2)
GOFLAGS=-mod=mod
#help: @ List available tasks
help:
@clear
@echo "Usage: make COMMAND"
@echo "Commands :"
@grep -E '[a-zA-Z\.\-]+:.*?@ .*$$' $(MAKEFILE_LIST)| tr -d '#' | awk 'BEGIN {FS = ":.*?@ "}; {printf "\033[32m%-16s\033[0m - %s\n", $$1, $$2}'
#clean: @ Cleanup
clean:
@rm -rf ./.bin/
@rm -rf vendor/
@mkdir ./.bin/
#generate: @ Generate GraphQL go source code
generate:
@rm -rf graph/model
@rm -rf graph/generated
@export GOFLAGS=$(GOFLAGS); go run github.com/99designs/gqlgen generate
#test: @ Run tests
test: generate
@export GOFLAGS=$(GOFLAGS); go test -v ./...
#build: @ Build GraphQL API
build: generate
@export GOFLAGS=$(GOFLAGS); go build -o ./.bin/server server.go
#run: @ Run GraphQL API
run: build
@export GOFLAGS=$(GOFLAGS); go run server.go
#image: @ Build Docker image
image: generate
@docker build -t gqlgen-graphql-subscriptions .
#build-frontend: @ Build JS client frontend
build-frontend:
@rm -Rf ./frontend/node_modules && rm -f ./frontend/yarn.lock && cd ./frontend && yarn install && yarn upgrade --latest && yarn build
#run-frontend: @ Run JS client frontend
run-frontend:
@cd ./frontend && yarn start
#image-frontend: @ Build JS client Docker image
image-frontend: build-frontend
@cd ./frontend && docker build -t gqlgen-graphql-frontend .
#get: @ Download and install packages
get: clean
@export GOFLAGS=$(GOFLAGS); go get . ; go mod tidy
#deps: @ Download and install dependencies
deps:
@export GOFLAGS=$(GOFLAGS); go install github.com/99designs/gqlgen@latest
@pnpm install -g yarn
#release: @ Create and push a new tag. Modify `Version` field in `server.go` as it's used as an actual tag name
release:
@echo -n "Are you sure to create and push ${VERSION} tag? [y/N] " && read ans && [ $${ans:-N} = y ]
@git commit -s -m "Cut ${VERSION} release"
@git tag ${VERSION}
@git push origin ${VERSION}
@git push
@echo "Done."
#update: @ Update dependencies to latest versions
update: clean
@export GOFLAGS=$(GOFLAGS); go get -u; go mod tidy
#version: @ Print current version(tag)
version:
@echo ${VERSION}
#redis-up: @ Start Redis
redis-up: redis-down
docker-compose up
#redis-down: @ Stop Redis
redis-down:
docker-compose down -v --remove-orphans