Skip to content

Commit 040b212

Browse files
Refactor the code and add comments
1 parent a9d4e4f commit 040b212

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

compose/bin/check-dependencies

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#!/usr/bin/env bash
22

3+
# Define colors for formatting
34
RED='\033[0;31m'
45
GREEN='\033[0;32m'
56
NC='\033[0m' # No Color
67

8+
# Declare arrays for storing common dependencies and Magento versions
79
declare -a common_dependencies
810
declare -a magento_versions=("2.4.7-beta3" "2.4.7-beta2" "2.4.6-p4" "2.4.6-p3" "2.4.6-p2" "2.4.6-p1" "2.4.6" "2.4.5-p5" "2.4.5-p4" "2.4.5-p3" "2.4.5-p2" "2.4.5-p1" "2.4.5" "2.4.4-p6" "2.4.4-p5" "2.4.4-p4" "2.4.4-p3" "2.4.4-p2" "2.4.4-p1" "2.4.4" "2.4.3-p3" "2.4.2-p2")
911

12+
# Assign common dependencies to corresponding Magento versions
1013
common_dependencies[0]="Composer:2.6 Elasticsearch:8.11 OpenSearch:2.11 MariaDB:10.6 MySQL:8.0 PHP:8.3,8.2 RabbitMQ:3.12 Redis:7.2 Varnish:7.4 Apache:2.4 nginx:1.24 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.11.20 'AWS-ElastiCache':Redis7.0 'AWS-Elasticsearch':-- 'AWS-OpenSearch':2.11"
1114
common_dependencies[1]="Composer:2.5 Elasticsearch:8.7 OpenSearch:2.5 MariaDB:10.6 MySQL:8.0 PHP:8.2,8.1 RabbitMQ:3.11 Redis:7.0 Varnish:7.3 Apache:2.4 nginx:1.24 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.10.20 'AWS-ElastiCache':Redis7.0 'AWS-Elasticsearch':-- 'AWS-OpenSearch':2.5"
1215
common_dependencies[2]="Composer:2.2 Elasticsearch:8.5,7.17 OpenSearch:2.5 MariaDB:10.6 MySQL:8.0 PHP:8.2,8.1 RabbitMQ:3.11,3.9 Redis:7.0 Varnish:7.3 Apache:2.4 nginx:1.24 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.16 'AWS-ElastiCache':Redis6.2 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2"
@@ -30,16 +33,19 @@ common_dependencies[19]="Composer:2.1 Elasticsearch:7.16 OpenSearch:1.2 MariaDB:
3033
common_dependencies[20]="Composer:1 Elasticsearch:7.16 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:7.4 RabbitMQ:3.8 Redis:6.0 Varnish:6.5 Apache:2.4 nginx:1.18 'AWS-Aurora-(MySQL)':5.7 'AWS-S3':✔️ 'AWS-MQ':3.8.11 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':7.9 'AWS-OpenSearch':--"
3134
common_dependencies[21]="Composer:1 Elasticsearch:7.9 OpenSearch:-- MariaDB:10.4 MySQL:8.0 PHP:7.4 RabbitMQ:3.8 Redis:6.0 Varnish:6.4 Apache:2.4 nginx:1.18 'AWS-Aurora-(MySQL)':-- 'AWS-S3':✔️ 'AWS-MQ':-- 'AWS-ElastiCache':-- 'AWS-Elasticsearch':-- 'AWS-OpenSearch':--"
3235

36+
# Function to print available Magento versions
3337
print_magento_versions() {
3438
echo "Available Magento 2 versions:"
3539
for version in "${magento_versions[@]}"; do
3640
echo "$version"
3741
done
3842
}
3943

44+
# Function to print dependencies for a given Magento version
4045
print_dependencies() {
4146
local version=$1
4247
local index
48+
echo -e "${GREEN}Recommended software dependencies:${NC}"
4349
for (( index=0; index<${#magento_versions[@]}; index++ )); do
4450
if [[ "${magento_versions[$index]}" == "$version" ]]; then
4551
local dependencies=${common_dependencies[$index]}
@@ -50,12 +56,13 @@ print_dependencies() {
5056
return
5157
fi
5258
done
59+
# If the provided Magento version is not recognized, prompt the user to choose a valid version
5360
echo -e "${RED}Magento version not recognized. Please choose a valid version from the list below:${NC}"
5461
print_magento_versions
5562
}
5663

64+
# Prompt the user to enter a Magento version and print its dependencies
5765
read -r -p "Enter the Magento 2 version you'd like to check dependencies on: " magento_version
5866

59-
print_dependencies "$magento_version"
60-
6167

68+
print_dependencies "$magento_version"

0 commit comments

Comments
 (0)