Website/app/bin/make/check.sh

106 lines
3.9 KiB
Bash
Raw Normal View History

2024-02-19 21:23:38 +00:00
#!/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 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 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"
2024-02-29 21:49:41 +00:00
# Check PHP PDO_MYSQL
php -m | grep -i pdo_mysql >/dev/null 2>&1 || \
{ \
printf >&2 "${RED_FG}✘ PHP PDO_MSQL${YELLOW_FG} is ${RED_FG}not installed${YELLOW_FG}!\n"; \
exit 1; \
}
2024-02-19 21:23:38 +00:00
# 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 | 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 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 | 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_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"