Website/app/bin/make/check.sh
Snoweuph f96c46ff99
Some checks are pending
Quality Check / Check (push) Waiting to run
#1: Fix Check & Compose.yaml to be more Specific
2024-04-22 19:30:59 +02:00

117 lines
No EOL
4.2 KiB
Bash
Executable file

#!/bin/bash
source bin/make/colors.sh
printf "${BLUE_BG} ${CLEAR}\n"
printf "${BLUE_BG}${BLACK_FG} Checking Requirements ${CLEAR}\n"
printf "${BLUE_BG} ${CLEAR}\n"
# Check PHP
command -v php >/dev/null 2>&1 || \
{ \
printf >&2 "${RED_FG}✘ PHP${YELLOW_FG} is ${RED_FG}not installed${YELLOW_FG}!\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_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; \
exit 1; \
} && \
printf >&2 "${GREEN_FG}✔ PHP${BLUE_FG} Version ${GREEN_FG}${current_php_version}${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"
# Check PHP PDO_MYSQL
php -m | grep -i pdo_mysql >/dev/null 2>&1 || \
{ \
printf >&2 "${RED_FG}✘ PHP PDO_MYSQL${YELLOW_FG} is ${RED_FG}not installed${YELLOW_FG}!\n"; \
exit 1; \
}
printf >&2 "${GREEN_FG}✔ PHP MySQL PDO${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"
# Check Composer
command -v composer >/dev/null 2>&1 || \
{ \
printf >&2 "${RED_FG}✘ Composer${YELLOW_FG} is ${RED_FG}not installed${YELLOW_FG}!\n"; \
exit 1; \
}
# Check Composer Version
current_composer_version=$(composer --version 2> /dev/null | awk '{print $3}' | cut -d '.' -f 1) && \
[ "${current_composer_version}" = "2" ] || \
{ \
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"; \
exit 1; \
} && \
printf >&2 "${GREEN_FG}✔ Composer${BLUE_FG} Version ${GREEN_FG}${current_composer_version}${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"
# Check Symfony CLI
command -v symfony >/dev/null 2>&1 || \
{ \
printf >&2 "${RED_FG}✘ Symfony CLI${YELLOW_FG} is ${RED_FG}not installed${YELLOW_FG}! please install it from:\nhttps://symfony.com/download\n"; \
exit 1; \
}
printf >&2 "${GREEN_FG}✔ Symfony CLI${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}!\n"
# Check JQ
command -v jq >/dev/null 2>&1 || \
{ \
printf >&2 "${RED_FG}✘ JQ${YELLOW_FG} is ${RED_FG}not installed${YELLOW_FG}!"; \
exit 1; \
}
printf >&2 "${GREEN_FG}✔ JQ${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}!\n"
# Check Volta
command -v volta >/dev/null 2>&1 || \
{ \
printf >&2 "${RED_FG}✘ Volta${YELLOW_FG} is ${RED_FG}not installed${YELLOW_FG}! \n"; \
exit 1; \
}
printf >&2 "${GREEN_FG}✔ Volta${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"
# Check Node
command -v node >/dev/null 2>&1 || \
{ \
printf >&2 "${RED_FG}✘ Node${YELLOW_FG} is ${RED_FG}not installed${YELLOW_FG}!\n"; \
exit 1; \
}
# Check Node Version
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-) && \
[ "${current_major_node_version}" = "${required_node_version}" ] || \
{ \
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"; \
exit 1; \
} && \
printf >&2 "${GREEN_FG}✔ Node${BLUE_FG} Version ${GREEN_FG}${current_node_version}${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"
# Check NPM
command -v npm >/dev/null 2>&1 || \
{ \
printf >&2 "${RED_FG}✘ NPM${YELLOW_FG} is ${RED_FG}not installed${YELLOW_FG}!\n Install it via Volta.\n"; \
exit 1; \
}
printf >&2 "${GREEN_FG}✔ NPM${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"
# Check for Docker
command -v docker >/dev/null 2>&1 || \
{ \
printf >&2 "${RED_FG}✘ Docker${YELLOW_FG} is ${RED_FG}not installed${YELLOW_FG}!\n"; \
exit 1; \
}
printf >&2 "${GREEN_FG}✔ Docker${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"
# Check for Docker Compose
! docker compose version >/dev/null 2>&1 && \
{ \
printf >&2 "${RED_FG}✘ Docker Compose${YELLOW_FG} is ${RED_FG}not installed${YELLOW_FG}!\n"; \
exit 1; \
}
printf >&2 "${GREEN_FG}✔ Docker Compose${BLUE_FG} is ${GREEN_FG}installed${BLUE_FG}.\n"