-
Notifications
You must be signed in to change notification settings - Fork 73
/
Makefile
56 lines (46 loc) · 1.72 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
PROJECT_ROOT=${PWD}
OPENAPI_GENERATOR_VER=v5.4.0
OPENAPI_GENERATOR_IMAGE=openapitools/openapi-generator-cli:$(OPENAPI_GENERATOR_VER)
OPENAPI_GENERATOR_CLI=docker run --rm -u ${shell id -u} -v "$(PROJECT_ROOT):/local" -w "/local" ${OPENAPI_GENERATOR_IMAGE}
OPENAPI_TARGET_DIR=openapi/
help: Makefile ## show list of commands
@echo "Choose a command run:"
@echo ""
@awk 'BEGIN {FS = ":.*?## "} /[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-40s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
generate: generate-server generate-cli generate-web
generate-web: ## generates OpenAPI types for WebUI
cd web; npm run types:generate
generate-cli:
$(eval BASE := ./cli)
mkdir -p $(BASE)/tmp
rm -rf $(BASE)/$(OPENAPI_TARGET_DIR)
mkdir -p $(BASE)/$(OPENAPI_TARGET_DIR)
$(OPENAPI_GENERATOR_CLI) generate \
-i api/openapi.yaml \
-g go \
-o $(BASE)/tmp \
--generate-alias-as-model
cp $(BASE)/tmp/*.go $(BASE)/$(OPENAPI_TARGET_DIR)
chmod 644 $(BASE)/$(OPENAPI_TARGET_DIR)/*.go
rm -rf $(BASE)/tmp
cd $(BASE); go fmt ./...
generate-server: ## generates OpenAPI types for server
$(eval BASE := ./server)
mkdir -p $(BASE)/tmp
rm -rf $(BASE)/$(OPENAPI_TARGET_DIR)
mkdir -p $(BASE)/$(OPENAPI_TARGET_DIR)
$(OPENAPI_GENERATOR_CLI) generate \
-i api/openapi.yaml \
-g go-server \
-o $(BASE)/tmp \
--generate-alias-as-model
cp $(BASE)/tmp/go/*.go $(BASE)/$(OPENAPI_TARGET_DIR)
chmod 644 $(BASE)/$(OPENAPI_TARGET_DIR)/*.go
rm -f $(BASE)/$(OPENAPI_TARGET_DIR)/api_api_service.go
rm -rf $(BASE)/tmp
cd $(BASE); go fmt ./...
serve-docs: ## serve documentation for Tracetest
docker build -t tracetest-docs -f docs-Dockerfile .
docker run --network host tracetest-docs
sleep 1
open http://localhost:8000