From 26e226e0a3badf74927d220462c68f67b4bcad92 Mon Sep 17 00:00:00 2001 From: noelma Date: Tue, 30 Aug 2022 20:34:34 +0200 Subject: [PATCH] feat: add make commands --- .gitattributes | 1 + Makefile | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 Makefile diff --git a/.gitattributes b/.gitattributes index 259973a..72896a9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,6 +6,7 @@ .github export-ignore .gitignore export-ignore .php-cs-fixer.dist.php export-ignore +Makefile export-ignore phpdoc.dist.xml export-ignore phpunit.xml export-ignore phpstan.neon.dist export-ignore diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..471148d --- /dev/null +++ b/Makefile @@ -0,0 +1,91 @@ +SHELL=bash +SOURCE_DIR = $(shell pwd) +BIN_DIR = ${SOURCE_DIR}/bin +COMPOSER = composer + +_CYAN=\033[36m +_GREEN=\033[32m +_END=\033[0m + +define printSection + @printf "${_CYAN}\n══════════════════════════════════════════════════\n${_END}" + @printf "${_CYAN} $1 ${_END}" + @printf "${_CYAN}\n══════════════════════════════════════════════════\n${_END}" +endef + +# _ _ _ +# | | | | | | +# | |_| | ___| |_ __ +# | _ |/ _ \ | '_ \ +# | | | | __/ | |_) | +# \_| |_/\___|_| .__/ +# | | +# |_| + +.PHONY: help +help: ## Displays the list of commands + $(call printSection,HELP) + @grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) \ + | sort \ + | awk 'BEGIN {FS = ":.*?## "}; {printf "${_GREEN}%-20s${_END} %s\n", $$1, $$2}' \ + | sed -e 's/##//' + +# _____ +# / __ \ +# | / \/ ___ _ __ ___ _ __ ___ ___ ___ _ __ +# | | / _ \| '_ ` _ \| '_ \ / _ \/ __|/ _ \ '__| +# | \__/\ (_) | | | | | | |_) | (_) \__ \ __/ | +# \____/\___/|_| |_| |_| .__/ \___/|___/\___|_| +# | | +# |_| + +.PHONY: install +install: clean-vendor install-vendor ## Install the project + +.PHONY: clean-vendor +clean-vendor: ## Remove composer dependencies + $(call printSection,CLEAN VENDOR) + rm -rf ${SOURCE_DIR}/vendor + +.PHONY: install-vendor +install-vendor: ${SOURCE_DIR}/vendor/composer/installed.json ## Install composer dependencies + +${SOURCE_DIR}/vendor/composer/installed.json: + $(call printSection,INSTALL VENDOR) + $(COMPOSER) --no-interaction install --ansi --no-progress --prefer-dist + +# _____ _ _ _ +# | _ | | (_) | +# | | | |_ _ __ _| |_| |_ _ _ +# | | | | | | |/ _` | | | __| | | | +# \ \/' / |_| | (_| | | | |_| |_| | +# \_/\_\\__,_|\__,_|_|_|\__|\__, | +# __/ | +# |___/ + +.PHONY: cs-fix +cs-fix: ## Checks if code style is compliant + $(call printSection,PHP-CS-FIXER) + ${BIN_DIR}/php-cs-fixer fix + +.PHONY: rector +rector: ## Checks if the quality of the code is compliant + $(call printSection,RECTOR) + ${BIN_DIR}/rector process --dry-run + +.PHONY: phpstan +phpstan: ## Check if the data types are compliant + $(call printSection,PHPSTAN) + ${BIN_DIR}/phpstan --memory-limit=1G analyse + +# _____ _ +# |_ _| | | +# | | ___ ___| |_ +# | |/ _ \/ __| __| +# | | __/\__ \ |_ +# \_/\___||___/\__| + +.PHONY: test +test: ## Run unit tests + $(call printSection,TEST phpunit) + ${BIN_DIR}/phpunit