diff --git a/Makefile b/Makefile index eb460d4..53b851d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,3 @@ - MODULE := $(shell go list -m) MODULE_NAME := $(lastword $(subst /, ,$(MODULE))) BUILD := $(shell git rev-parse --short HEAD)@$(shell date +%s) @@ -13,7 +12,7 @@ GO_BUILD := CGO_ENABLED=0 go build -trimpath -ldflags $(LD_FLAGS) -tags=jsoniter .PHONY: init -init: +init: ## Init all dependencies go mod download go get entgo.io/ent/cmd/ent@latest go get github.com/google/wire/cmd/wire@latest @@ -26,102 +25,82 @@ init: buf dep update .PHONY: install -install: +install: ## Install all dependencies cd contrib/protoc-gen-sphere && go mod download && go install . cd contrib/protoc-gen-bot && go mod download && go install . cd contrib/ent-gen-proto && go mod download && go install . .PHONY: gen-proto -gen-proto: +gen-proto: ## Generate proto files and run protoc plugins ent-gen-proto buf generate protoc-go-inject-tag -input="./api/*/*/*.pb.go" -remove_tag_comment .PHONY: gen-docs -gen-docs: gen-proto +gen-docs: gen-proto ## Generate swagger docs swag init --output ./swagger/api --tags api.v1,shared.v1 --instanceName API -g docs.go --parseDependency swag init --output ./swagger/dash --tags dash.v1,shared.v1 --instanceName Dash -g docs.go --parseDependency .PHONY: gen-ts -gen-ts: gen-docs +gen-ts: gen-docs ## Generate typescript client npx swagger-typescript-api -p ./swagger/api/API_swagger.json -o ./swagger/api/typescript --modular --responses --extract-response-body --extract-response-error npx swagger-typescript-api -p ./swagger/dash/Dash_swagger.json -o ./swagger/dash/typescript --modular --responses --extract-response-body --extract-response-error .PHONY: gen-ent -gen-ent: +gen-ent: ## Generate ent code go generate ./internal/pkg/database/ent .PHONY: gen-wire -gen-wire: +gen-wire: ## Generate wire code go generate ./cmd/... .PHONY: gen-conf -gen-conf: +gen-conf: ## Generate example config go run ./cmd/cli/config gen .PHONY: generate -generate: +generate: ## Run all generate command go generate ./... $(MAKE) gen-docs .PHONY: dash -dash: +dash: ## Build dash sh ./assets/dash/build.sh .PHONY: build -build: +build: ## Build binary $(GO_BUILD) -o ./build/$(CURRENT_OS)_$(CURRENT_ARCH)/ ./... .PHONY: build-linux-amd -build-linux-amd: +build-linux-amd: ## Build linux amd64 binary GOOS=linux GOARCH=amd64 $(GO_BUILD) -o ./build/linux_x86/ ./... .PHONY: build-linux-arm -build-linux-arm: +build-linux-arm: ## Build linux arm64 binary GOOS=linux GOARCH=arm64 $(GO_BUILD) -o ./build/linux_arm64/ ./... .PHONY: build-all -build-all: build-linux-amd build-linux-arm +build-all: build-linux-amd build-linux-arm ## Build all arch binary .PHONY: build-docker -build-docker: +build-docker: ## Build docker image docker buildx build --platform=linux/amd64,linux/arm64 -t $(DOCKER_IMAGE) . -f $(DOCKER_FILE) --push --provenance=false .PHONY: delpoy -deploy: +deploy: ## Deploy binary ansible-playbook -i devops/hosts/inventory.ini devops/delpoy-binary.yaml .PHONY: lint -lint: +lint: ## Run linter golangci-lint run buf lint .PHONY: fmt -fmt: +fmt: ## Run formatter go fmt ./... buf format .PHONY: help -help: - @echo "Usage: make " - @echo "" - @echo "Targets:" - @echo " init Install all dependencies" - @echo " gen-proto Generate proto files" - @echo " gen-docs Generate swagger docs" - @echo " gen-ts Generate typescript client" - @echo " gen-ent Generate ent code" - @echo " gen-wire Generate wire code" - @echo " gen-conf Generate config" - @echo " generate Generate code" - @echo " dash Build dash" - @echo " build Build binary" - @echo " build-linux-amd Build linux amd64 binary" - @echo " build-linux-arm Build linux arm64 binary" - @echo " build-all Build all binary" - @echo " build-docker Build docker image" - @echo " deploy Deploy binary" - @echo " lint Run linter" - @echo " fmt Run formatter" - @echo " help Show this help message" - @echo "" \ No newline at end of file +help: ## Show this help message + @echo "\nSphere build tool:\n" + @grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -e 's/\(.*\):.*##\(.*\)/\1:\2/' | column -t -s ':' \ No newline at end of file diff --git a/doc/USAGE.md b/doc/USAGE.md index f876c3f..ff1a61b 100644 --- a/doc/USAGE.md +++ b/doc/USAGE.md @@ -12,27 +12,27 @@ Alternatively, you can import this project in go mod and implement your own busi ## Usage ``` -Usage: make - -Targets: - init Install all dependencies - gen-proto Generate proto files - gen-docs Generate swagger docs - gen-ts Generate typescript client - gen-ent Generate ent code - gen-wire Generate wire code - gen-conf Generate config - generate Generate code - dash Build dash - build Build binary - build-linux-amd Build linux amd64 binary - build-linux-arm Build linux arm64 binary - build-all Build all binary - build-docker Build docker image - deploy Deploy binary - lint Run linter - fmt Run formatter - help Show this help message +Sphere build tool: + +init Init all dependencies +install Install all dependencies +gen-proto Generate proto files and run protoc plugins +gen-docs Generate swagger docs +gen-ts Generate typescript client +gen-ent Generate ent code +gen-wire Generate wire code +gen-conf Generate example config +generate Run all generate command +dash Build dash +build Build binary +build-linux-amd Build linux amd64 binary +build-linux-arm Build linux arm64 binary +build-all Build all arch binary +build-docker Build docker image +deploy Deploy binary +lint Run linter +fmt Run formatter +help Show this help message ``` ## Project Structure