206 lines
6.9 KiB
Makefile
206 lines
6.9 KiB
Makefile
|
_default:
|
||
|
@bin/just/choose.sh {{ source_file() }} choose
|
||
|
|
||
|
alias i := install
|
||
|
alias start := up
|
||
|
alias stop := halt
|
||
|
alias clean := fresh
|
||
|
|
||
|
screen_frontend_session_name := "euph-website_frontend"
|
||
|
linter_options := "All\nPHP\nTS\nSCSS\nTwig"
|
||
|
migration_options := "Generate\nExecute\n"
|
||
|
suite_options := "All\nUnit\nIntegration\nWeb"
|
||
|
|
||
|
# Checks whether the requriements are met
|
||
|
[group('main')]
|
||
|
check:
|
||
|
#!/bin/bash
|
||
|
source bin/just/colors.sh
|
||
|
source bin/just/check.sh
|
||
|
|
||
|
printf "${BLUE_BG}${BLACK_FG} Checking Justfile Requirements ${CLEAR}\n"
|
||
|
check_cmd "jq" "jq"
|
||
|
check_cmd "fzf" "fzf"
|
||
|
check_cmd "screen" "screen"
|
||
|
check_cmd "grep" "grep"
|
||
|
check_cmd "printf" "Printf"
|
||
|
check_cmd "sed" "sed"
|
||
|
check_cmd "awk" "awk"
|
||
|
check_cmd "cut" "cut"
|
||
|
check_cmd "highlight" "highlight"
|
||
|
if ((error > 0 )); then
|
||
|
exit 1
|
||
|
fi
|
||
|
echo ""
|
||
|
|
||
|
printf "${BLUE_BG}${BLACK_FG} Checking Backend Requirements ${CLEAR}\n"
|
||
|
check_cmd "php" "Php"
|
||
|
check_cmd "composer" "Composer"
|
||
|
check_cmd "symfony" "Symfony cli"
|
||
|
current_composer_version=$(composer --version 2>/dev/null | awk '{print $3}' | cut -d '.' -f 1)
|
||
|
if [ "${current_composer_version}" = "2" ]; then
|
||
|
printf >&2 "${GREEN_FG}✔ Composer${BLUE_FG} Version ${GREEN_FG}${current_composer_version}${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"
|
||
|
else
|
||
|
printf >&2 "${RED_FG}✘ Wrong Composer Version${YELLOW_FG} is installed!\n Version ${RED_FG}2${YELLOW_FG} is ${RED_FG}required${YELLOW_FG}.\n"
|
||
|
error = 1
|
||
|
fi
|
||
|
required_php_version=$(cat .php-version)
|
||
|
current_php_version=$(symfony php -r "echo PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;")
|
||
|
if [ "${current_php_version}" = "${required_php_version}" ]; then
|
||
|
printf >&2 "${GREEN_FG}✔ PHP${BLUE_FG} Version ${GREEN_FG}${current_php_version}${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"
|
||
|
else
|
||
|
printf >&2 "${RED_FG}✘ Wrong PHP Version${YELLOW_FG} is installed!\n Version ${RED_FG}${required_php_version}${YELLOW_FG} is ${RED_FG}required${YELLOW_FG}.\n"
|
||
|
symfony local:php:list
|
||
|
error = 1
|
||
|
fi
|
||
|
check "[ $(php -m | grep -c PDO) -eq 1 ]" "Php PDO"
|
||
|
check "[ $(php -m | grep -c pdo_mysql) -eq 1 ]" "Php Mysql PDO"
|
||
|
check_cmd "docker" "Docker"
|
||
|
if echo "$(docker compose version 2>&1)" | grep -q '[0-9]\+\.[0-9]\+\.[0-9]\+'; then
|
||
|
printf >&2 "${GREEN_FG}✔ Docker Compose${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"
|
||
|
else
|
||
|
printf >&2 "${RED_FG}✘ Docker Compose${YELLOW_FG} is ${RED_FG}not installed${YELLOW_FG}! \n"
|
||
|
error=1
|
||
|
fi
|
||
|
if ((error > 0 )); then
|
||
|
exit 1
|
||
|
fi
|
||
|
echo ""
|
||
|
|
||
|
printf "${BLUE_BG}${BLACK_FG} Checking Frontend Requirements ${CLEAR}\n"
|
||
|
check_cmd "volta" "Volta"
|
||
|
check_cmd "node" "Node"
|
||
|
check_cmd "npm" "NPM"
|
||
|
required_node_version=$( \
|
||
|
cat package.json \
|
||
|
| jq .volta.node \
|
||
|
| cut -c 2- \
|
||
|
| cut -d '.' -f 1 \
|
||
|
)
|
||
|
current_major_node_version=$(node -v | cut -c 2- | cut -d '.' -f 1)
|
||
|
current_node_version=$(node -v | cut -c 2-)
|
||
|
if [ "${current_major_node_version}" = "${required_node_version}" ]; then
|
||
|
printf >&2 "${GREEN_FG}✔ Node${BLUE_FG} Version ${GREEN_FG}${current_node_version}${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"
|
||
|
else
|
||
|
printf >&2 "${RED_FG}✘ Wrong Node Version${YELLOW_FG} is installed!\n Version ${RED_FG}${required_node_version}${YELLOW_FG} is ${RED_FG}required${YELLOW_FG}.\n"
|
||
|
error = 1
|
||
|
fi
|
||
|
if ((error > 0 )); then
|
||
|
exit 1
|
||
|
fi
|
||
|
echo ""
|
||
|
|
||
|
# Installs the dependencies
|
||
|
[group('main')]
|
||
|
install:
|
||
|
parallel ::: "composer install" "npm i --no-fund"
|
||
|
|
||
|
# Starts the local Development Setup
|
||
|
[group('main')]
|
||
|
up: halt check
|
||
|
#!/bin/bash
|
||
|
source bin/just/colors.sh
|
||
|
docker compose up -d
|
||
|
symfony local:server:start -d --no-tls
|
||
|
screen -dmS {{ screen_frontend_session_name }} npm run watch >> /dev/null
|
||
|
if [ $? -eq 0 ]; then
|
||
|
printf "${GREEN_FG}Frontend was started${CLEAR}\n"
|
||
|
else
|
||
|
printf "${RED_FG}Frontend didn't start${CLEAR}\n"
|
||
|
fi
|
||
|
|
||
|
# Stops the local Development Setup
|
||
|
[group('main')]
|
||
|
halt:
|
||
|
#!/bin/bash
|
||
|
source bin/just/colors.sh
|
||
|
symfony local:server:stop
|
||
|
docker compose down
|
||
|
screen -XS {{ screen_frontend_session_name }} quit >> /dev/null
|
||
|
if [ $? -eq 0 ]; then
|
||
|
printf "${GREEN_FG}Frontend was stopped${CLEAR}\n"
|
||
|
fi
|
||
|
|
||
|
[group('main')]
|
||
|
attach:
|
||
|
#!/bin/bash
|
||
|
source bin/just/colors.sh
|
||
|
if screen -ls | grep -q {{ screen_frontend_session_name }}; then
|
||
|
screen -r {{ screen_frontend_session_name }}
|
||
|
else
|
||
|
printf "${RED_FG}Frontend is down${CLEAR}\n"
|
||
|
fi
|
||
|
|
||
|
# Starts the local Development Setup Fresh, with no Cache and the reseted test Data
|
||
|
[group('main')]
|
||
|
fresh: halt install up
|
||
|
@just backend::demo-data
|
||
|
|
||
|
# Lints all Files, or if specified only a specifc Set
|
||
|
[group('utility')]
|
||
|
lint linter="":
|
||
|
#!/bin/bash
|
||
|
chosen_linter=$(
|
||
|
printf "{{ linter_options }}" |\
|
||
|
fzf --header="Which linters should be run?" --height 8 -i -q "{{ linter }}" -1
|
||
|
)
|
||
|
case "$chosen_linter" in
|
||
|
*All*) \
|
||
|
parallel ::: \
|
||
|
"vendor/bin/php-cs-fixer fix --allow-risky=yes" \
|
||
|
"npm run lint:ts:fix" \
|
||
|
"npm run lint:scss:fix" \
|
||
|
"vendor/bin/twig-cs-fixer lint --fix && php bin/console lint:twig" \
|
||
|
;;
|
||
|
*PHP*) vendor/bin/php-cs-fixer fix --allow-risky=yes ;;
|
||
|
*TS*) npm run lint:ts:fix ;;
|
||
|
*SCSS*) npm run lint:scss:fix ;;
|
||
|
*Twig*) vendor/bin/twig-cs-fixer lint --fix && php bin/console lint:twig ;;
|
||
|
esac
|
||
|
|
||
|
# Runs the Static Code Analysis
|
||
|
[group('utility')]
|
||
|
stan:
|
||
|
@vendor/bin/phpstan analyze --memory-limit=2G
|
||
|
|
||
|
# Runs all Tests, or if specified only a specific Suite
|
||
|
[group('utility')]
|
||
|
test suite="":
|
||
|
#!/bin/bash
|
||
|
chosen_suite=$(
|
||
|
printf "{{ suite_options }}" |\
|
||
|
fzf --header="which tests should be run?" --height 7 -i -q "{{ suite }}" -1
|
||
|
)
|
||
|
if [ "$chosen_suite" != "All" ]; then
|
||
|
suite_arg="--testsuite $chosen_suite"
|
||
|
fi
|
||
|
symfony console doctrine:database:drop --if-exists --force --env=test
|
||
|
symfony console doctrine:database:create --env=test
|
||
|
symfony console doctrine:schema:update --force --complete --env=test
|
||
|
symfony console doctrine:fixtures:load -n --env=test
|
||
|
symfony console cache:clear --env=test
|
||
|
vendor/bin/phpunit $suite_arg
|
||
|
|
||
|
# Create and Execute Migrations
|
||
|
[group('utility')]
|
||
|
migration migration="":
|
||
|
#!/bin/bash
|
||
|
chosen_migration=$(
|
||
|
printf "{{ migration_options }}" |\
|
||
|
fzf --header="Which migration action to perform?" --height 7 -i -q "{{ migration }}" -1
|
||
|
)
|
||
|
case "$chosen_migration" in
|
||
|
*Generate*) symfony console doctrine:migrations:diff ;;
|
||
|
*Execute*) symfony console doctrine:migrations:migrate ;;
|
||
|
esac
|
||
|
|
||
|
# Sets up a Fresh Data Set
|
||
|
[group('utility')]
|
||
|
demo-data:
|
||
|
#!/bin/bash
|
||
|
symfony console doctrine:database:drop --if-exists --force
|
||
|
symfony console doctrine:database:create
|
||
|
symfony console doctrine:migrations:migrate -n
|
||
|
symfony console doctrine:fixtures:load -n
|
||
|
symfony console cache:clear
|