Website/app/Makefile

126 lines
4.7 KiB
Makefile
Raw Normal View History

2024-02-04 02:46:53 +00:00
include .env.make
##|--[ General ]---------------------------------------------------|
help: ## Shops available Commands
@grep -E '(^[a-zA-Z0-9_-]+:.*##.*$$)|(^##)' Makefile| \
awk 'BEGIN {FS = ":.*?## "}{printf "${COLOR_BASE}${COLOR_HELP_COMMAND}%-20s${CLEAR} %s\n", $$1, $$2}' | \
sed -e "s/\${COLOR_HELP_COMMAND}##/${COLOR_HELP_GROUP}/"
check: ## Checks whether Requirements are met
@printf "${BLUE}▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄\n"
@printf "█ Checking Requirements █\n"
@printf "▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀${CLEAR}\n"
@# Check Symfony CLI
@command -v symfony >/dev/null 2>&1 || \
{ \
printf >&2 "${RED}✘ Symfony CLI${YELLOW} is ${RED}not installed${YELLOW}! please install it from:\nhttps://symfony.com/download\n"; \
exit 1; \
}
@printf >&2 "${GREEN}✔ Symfony CLI${BLUE} is ${GREEN}installed${BLUE}!\n"
@# Check PHP
@command -v php >/dev/null 2>&1 || \
{ printf >&2 "${RED}✘ PHP${YELLOW} is ${RED}not installed${YELLOW}!\n"; exit 1;}
@# Check PHP Version
@required_php_version=$$(cat .php-version) && \
current_php_version=$$(symfony php -r "echo PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;") && \
[ "$${current_php_version}" = "$${required_php_version}" ] || \
{ \
printf >&2 "${RED}✘ Wrong PHP Version${YELLOW} is installed!\n Version ${RED}$${required_php_version}${YELLOW} is ${RED}required${YELLOW}.\n"; \
symfony local:php:list; \
exit 1; \
} && \
printf >&2 "${GREEN}✔ PHP${BLUE} Version ${GREEN}$${current_php_version}${BLUE} is ${GREEN}installed${BLUE}.\n"
@# Check Composer
@command -v composer >/dev/null 2>&1 || \
{ printf >&2 "${RED}✘ Composer${YELLOW} is ${RED}not installed${YELLOW}!\n"; exit 1;}
@# Check Composer Version
@current_composer_version=$$(composer --version | awk '{print $$3}' | cut -d '.' -f 1) && \
[ "$${current_composer_version}" = "2" ] || \
{ \
printf >&2 "${RED}✘ Wrong Composer Version${YELLOW} is installed!\n Version ${RED}2${YELLOW} is ${RED}required${YELLOW}.\n"; \
exit 1; \
} && \
printf >&2 "${GREEN}✔ Composer${BLUE} Version ${GREEN}$${current_composer_version}${BLUE} is ${GREEN}installed${BLUE}.\n"
@# Check Volta
@command -v volta >/dev/null 2>&1 || \
{ \
printf >&2 "${RED}✘ Volta${YELLOW} is ${RED}not installed${YELLOW}! \n"; \
exit 1; \
}
@printf >&2 "${GREEN}✔ Volta${BLUE} is ${GREEN}installed${BLUE}.\n"
@# Check Node
@command -v node >/dev/null 2>&1 || \
{ printf >&2 "${RED}✘ Node${YELLOW} is ${RED}not installed${YELLOW}!\n"; exit 1;}
@# Check Node Version
@required_node_version=$$(cat package.json | grep -oP '(?<="node": ")([0-9]*)(?=\.[0-9]*\.[0-9]")') && \
current_major_node_version=$$(node -v | cut -c 2- | cut -d '.' -f 1) && \
current_node_version=$$(node -v | cut -c 2-) && \
[ "$${current_major_node_version}" = "$${required_node_version}" ] || \
{ \
printf >&2 "${RED}✘ Wrong Node Version${YELLOW} is installed!\n Version ${RED}$${required_node_version}${YELLOW} is ${RED}required${YELLOW}.\n"; \
exit 1; \
} && \
printf >&2 "${GREEN}✔ Node${BLUE} Version ${GREEN}$${current_node_version}${BLUE} is ${GREEN}installed${BLUE}.\n"
@# Check NPM
@command -v npm >/dev/null 2>&1 || \
{ \
printf >&2 "${RED}✘ NPM${YELLOW} is ${RED}not installed${YELLOW}!\n Install it via Volta.\n"; \
exit 1; \
}
@printf >&2 "${GREEN}✔ NPM${BLUE} is ${GREEN}installed${BLUE}.\n"
##|--[ Local Server ]----------------------------------------------|
start: ## Starts the Local Instance
@make stop
make check
docker compose up -d
symfony local:server:start -d --no-tls
bash -c '$(npm run watch)& echo $! > ./npm-watch.pid'
stop: ## Stops the Local Instance
ifneq (,$(wildcard ./npm-watch.pid))
@printf "${RED}Killing ${YELLOW}Encore${CLEAR}!\n"
kill $$(cat ./npm-watch.pid)
@rm -rf ./npm-watch.pid
endif
symfony local:server:stop
docker compose down
fresh: ## Starts a Fresh Local Instance
make stop
symfony composer install
npm i
make start
make db-demo
##|--[ Code Quality ]----------------------------------------------|
lint: ## Runs the Linters
vendor/bin/php-cs-fixer fix
npm run lint:fix
php bin/console lint:fix
analyze: ## Runs Static Code Analysis
vendor/bin/phpstan analyze
test: ## Runs all Unittests
vendor/bin/phpunit
##|--[ Data ]------------------------------------------------------|
db-demo: ## Writes the Demo Data to the Local Instance
symofny console doctrine:database:drop --if-exists --force
symofny console doctrine:database:create
symofny console doctrine:schema:update --force
symfony console doctrine:fixtures:load -n
symfony console cache:clear
db-migration-gen: ## Generates a Migration
symfony console doctrine:migration:diff
db-migration-do: ## Does the Migration
symfony console doctrine:migration:migrate