115 lines
3.8 KiB
Text
115 lines
3.8 KiB
Text
__default:
|
|
@../bin/just/choose.sh {{ source_file() }} choose
|
|
|
|
# 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 Backend Requirements ${CLEAR}\n"
|
|
cd ..
|
|
|
|
check_cmd "php" "Php"
|
|
check_cmd "composer" "Composer"
|
|
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
|
|
|
|
check_cmd "symfony" "Symfony cli"
|
|
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"
|
|
check "$(docker compose version >/dev/null 2>&1)" "Docker Compose"
|
|
|
|
if ((error > 0 )); then
|
|
exit 1
|
|
fi
|
|
echo ""
|
|
|
|
# Installs the dependencies
|
|
[group('main')]
|
|
install:
|
|
cd .. && composer install
|
|
|
|
# Starts the local Development Setup
|
|
[group('main')]
|
|
up: halt
|
|
-@cd .. && docker compose up -d
|
|
-@cd .. && symfony local:server:start -d --no-tls
|
|
|
|
# Stops the local Development Setup
|
|
[group('main')]
|
|
halt:
|
|
-@cd .. && symfony local:server:stop
|
|
-@cd .. && docker compose down
|
|
|
|
suite_options := "All\nUnit\nIntegration\nWeb"
|
|
# 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
|
|
cd ..
|
|
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
|
|
|
|
# Lints the PHP Backend Code
|
|
[group('utility')]
|
|
lint:
|
|
@cd .. && vendor/bin/php-cs-fixer fix --allow-risky=yes
|
|
|
|
# Runs the Static Code Analysis
|
|
[group('utility')]
|
|
stan:
|
|
@cd .. && vendor/bin/phpstan analyze --memory-limit=2G
|
|
|
|
migration_options := "Generate\nExecute\n"
|
|
# 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
|
|
)
|
|
cd ..
|
|
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
|
|
cd ..
|
|
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
|