From 8e0b0b15e7ce757d441d68d1a0817ab06896c3b3 Mon Sep 17 00:00:00 2001 From: thibauult Date: Wed, 19 Jun 2024 09:47:44 +0200 Subject: [PATCH] Check prerequisites in Makefile --- Makefile | 18 +++++++++++++++--- README.md | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a7d030f..0c61dca 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ help: @grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "make \033[36m%-10s\033[0m %s\n", $$1, $$2}' .PHONY: generate -generate: ## Generates the openhue/gen/openhue.gen.go client. Usage: make generate [spec=/path/to/openhue.yaml] +generate: _check-oapi-codegen-installation ## Generates the openhue/gen/openhue.gen.go client. Usage: make generate [spec=/path/to/openhue.yaml] ifdef spec @echo "Code generation from $(spec)" @oapi-codegen --package=gen -generate=client,types -o ./openhue/gen/openhue.gen.go "$(spec)" @@ -26,7 +26,7 @@ endif @echo "\n${GREEN}${BOLD}./openhue/openhue.gen.go successfully generated ๐Ÿš€${RESET}" .PHONY: build -build: ## Generates the openhue-cli executables in the ./dist folder +build: _check-goreleaser-installation ## Generates the openhue-cli executables in the ./dist folder @$(GORELEASER) check @$(GORELEASER) build --clean --snapshot --single-target @echo "\n${GREEN}${BOLD}openhue binaries successfully generated in the ./dist folder ๐Ÿ“ฆ${RESET}" @@ -57,4 +57,16 @@ clean: ## @rm -f c.out @rm -f coverage.html @$(GO) clean - @echo "\n${GREEN}${BOLD}Project successfully cleaned ๐Ÿงน${RESET} (removed ./dist folder + go clean)" \ No newline at end of file + @echo "\n${GREEN}${BOLD}Project successfully cleaned ๐Ÿงน${RESET} (removed ./dist folder + go clean)" + +# +# Private targets +# + +.PHONY: _check-goreleaser-installation +_check-goreleaser-installation: + @command -v goreleaser >/dev/null 2>&1 || { echo >&2 "GoReleaser is not installed (https://goreleaser.com/install)"; exit 1; } + +.PHONY: _check-oapi-codegen-installation +_check-oapi-codegen-installation: + @command -v oapi-codegen >/dev/null 2>&1 || { echo >&2 "oapi-codegen is not installed (https://github.com/oapi-codegen/oapi-codegen)"; exit 1; } \ No newline at end of file diff --git a/README.md b/README.md index 33ae3d2..00a99d9 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ To begin developing with Open-Hue's OpenAPI specification, follow these steps: Before you start, ensure that you have the following prerequisites installed: - [Golang](https://go.dev/doc/install) that is used to build and run the project - [GoReleaser](https://goreleaser.com) that is used to build and release the binaries. Used behind the scene when running the `make build` command +- [oapi-codegen](https://github.com/oapi-codegen/oapi-codegen) (_optional_) that is used to generate the client code from the openhue-api specification. Used behind the scene when running the `make generate` command - [Docker](https://docs.docker.com/engine/install/) (_optional_) that is used to build the CLI Docker Image and run it as a container ### Fork the Repository