-
Notifications
You must be signed in to change notification settings - Fork 73
/
Makefile
69 lines (56 loc) · 2.06 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
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
.PHONY: build-docker build-go build-web
build-docker: build-go build-web
VERSION=latest \
goreleaser release --clean --skip-announce --snapshot -f .goreleaser.dev.yaml
build-web:
cd web; npm install
cd web; npm run build
build-go:
goreleaser build --single-target --clean --snapshot
find ./dist -name 'tracetest*' -exec cp {} ./dist \;
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