From 80d71731878a24faf5845e72e134e793847bd194 Mon Sep 17 00:00:00 2001 From: sahitya-chandra Date: Sun, 13 Oct 2024 01:48:00 +0530 Subject: [PATCH 01/11] pre-requisite dependency version check added in dev.sh file --- dev.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/dev.sh b/dev.sh index fe11a0c15..7efbdad10 100755 --- a/dev.sh +++ b/dev.sh @@ -1,5 +1,46 @@ #!/bin/bash +REQUIRED_NODE_VERSION=22.9.0 +REQUIRED_YARN_VERSION=1.22.22 + +version_ge() { + [ "$(printf '%s\n' "$@" | sort -V | head -n 1)" == "$1" ] +} + +# Check Node.js version +check_node_version() { + if ! command -v node &> /dev/null; then + echo "Node.js is not installed. Please install Node.js v$REQUIRED_NODE_VERSION or higher." + exit 1 + fi + + NODE_VERSION=$(node -v | sed 's/v//') + if ! version_ge "$NODE_VERSION" "$REQUIRED_NODE_VERSION"; then + echo "Current Node.js version ($NODE_VERSION) is incompatible. Please install v$REQUIRED_NODE_VERSION or higher." + exit 1 + fi +} + +# Check Yarn version +check_yarn_version() { + if ! command -v yarn &> /dev/null; then + echo "Yarn is not installed. Please install Yarn v$REQUIRED_YARN_VERSION or higher." + exit 1 + fi + + YARN_VERSION=$(yarn -v) + if ! version_ge "$YARN_VERSION" "$REQUIRED_YARN_VERSION"; then + echo "Current Yarn version ($YARN_VERSION) is incompatible. Please install v$REQUIRED_YARN_VERSION or higher." + exit 1 + fi +} + +check_node_version +check_yarn_version + +echo "Node.js and Yarn versions are compatible. Proceeding..." + + [ ! -f .env ] && cp env.example .env check_internet_connection() { From fd52d84995253185e869cb6c24c66706ba1e11e1 Mon Sep 17 00:00:00 2001 From: sahitya-chandra Date: Tue, 15 Oct 2024 14:10:56 +0530 Subject: [PATCH 02/11] docker version check added and minimum node version updated --- dev.sh | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/dev.sh b/dev.sh index 7efbdad10..580c397a8 100755 --- a/dev.sh +++ b/dev.sh @@ -1,9 +1,10 @@ #!/bin/bash -REQUIRED_NODE_VERSION=22.9.0 +REQUIRED_NODE_VERSION=22.0.0 REQUIRED_YARN_VERSION=1.22.22 +REQUIRED_DOCKER_VERSION=22.3.1 -version_ge() { +version_at_least() { [ "$(printf '%s\n' "$@" | sort -V | head -n 1)" == "$1" ] } @@ -15,7 +16,7 @@ check_node_version() { fi NODE_VERSION=$(node -v | sed 's/v//') - if ! version_ge "$NODE_VERSION" "$REQUIRED_NODE_VERSION"; then + if ! version_at_least "$NODE_VERSION" "$REQUIRED_NODE_VERSION"; then echo "Current Node.js version ($NODE_VERSION) is incompatible. Please install v$REQUIRED_NODE_VERSION or higher." exit 1 fi @@ -29,17 +30,31 @@ check_yarn_version() { fi YARN_VERSION=$(yarn -v) - if ! version_ge "$YARN_VERSION" "$REQUIRED_YARN_VERSION"; then + if ! version_at_least "$YARN_VERSION" "$REQUIRED_YARN_VERSION"; then echo "Current Yarn version ($YARN_VERSION) is incompatible. Please install v$REQUIRED_YARN_VERSION or higher." exit 1 fi } +# Check Docker version +check_docker_version() { + if ! command -v docker &> /dev/null; then + echo "Docker is not installed. Please install Docker v$REQUIRED_DOCKER_VERSION or higher." + exit 1 + fi + + DOCKER_VERSION=$(docker --version | awk '{print $3}' | sed 's/,//') + if ! version_at_least "$DOCKER_VERSION" "$REQUIRED_DOCKER_VERSION"; then + echo "Current Docker version ($DOCKER_VERSION) is incompatible. Please install v$REQUIRED_DOCKER_VERSION or higher." + exit 1 + fi +} + check_node_version check_yarn_version +check_docker_version -echo "Node.js and Yarn versions are compatible. Proceeding..." - +echo "Node.js, Yarn and Docker versions are compatible. Proceeding..." [ ! -f .env ] && cp env.example .env From a9b5758d73fcfc046ecd763b1db69c0248a997f0 Mon Sep 17 00:00:00 2001 From: sahitya-chandra Date: Tue, 15 Oct 2024 14:16:18 +0530 Subject: [PATCH 03/11] linting done --- dev.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dev.sh b/dev.sh index 580c397a8..e9cb97b38 100755 --- a/dev.sh +++ b/dev.sh @@ -58,6 +58,7 @@ echo "Node.js, Yarn and Docker versions are compatible. Proceeding..." [ ! -f .env ] && cp env.example .env +# Create .env file if it doesn't exist check_internet_connection() { curl -s https://www.google.com > /dev/null 2>&1 if [[ $? -ne 0 ]]; then From 13e9c36d90a97122b0be3b4c98f505a10421b7bf Mon Sep 17 00:00:00 2001 From: sahitya-chandra Date: Tue, 15 Oct 2024 15:30:00 +0530 Subject: [PATCH 04/11] docker version updated --- dev.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev.sh b/dev.sh index e9cb97b38..dc57d216d 100755 --- a/dev.sh +++ b/dev.sh @@ -2,7 +2,7 @@ REQUIRED_NODE_VERSION=22.0.0 REQUIRED_YARN_VERSION=1.22.22 -REQUIRED_DOCKER_VERSION=22.3.1 +REQUIRED_DOCKER_VERSION=24.0.0 version_at_least() { [ "$(printf '%s\n' "$@" | sort -V | head -n 1)" == "$1" ] From be18b219c936190392d380b40b89ea650b95ad27 Mon Sep 17 00:00:00 2001 From: sahitya-chandra Date: Tue, 15 Oct 2024 15:43:52 +0530 Subject: [PATCH 05/11] linting done --- dev.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dev.sh b/dev.sh index dc57d216d..56274e0cd 100755 --- a/dev.sh +++ b/dev.sh @@ -58,6 +58,7 @@ echo "Node.js, Yarn and Docker versions are compatible. Proceeding..." [ ! -f .env ] && cp env.example .env + # Create .env file if it doesn't exist check_internet_connection() { curl -s https://www.google.com > /dev/null 2>&1 From b1e474cb0199d884b5c6e1479f735969c49d0def Mon Sep 17 00:00:00 2001 From: sahitya-chandra Date: Tue, 15 Oct 2024 16:19:53 +0530 Subject: [PATCH 06/11] pre-commit error fix --- dev.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/dev.sh b/dev.sh index 56274e0cd..dc57d216d 100755 --- a/dev.sh +++ b/dev.sh @@ -58,7 +58,6 @@ echo "Node.js, Yarn and Docker versions are compatible. Proceeding..." [ ! -f .env ] && cp env.example .env - # Create .env file if it doesn't exist check_internet_connection() { curl -s https://www.google.com > /dev/null 2>&1 From 62654bfbcb7ea419485aa963d74e61da305ada5f Mon Sep 17 00:00:00 2001 From: sahitya-chandra Date: Tue, 15 Oct 2024 16:36:02 +0530 Subject: [PATCH 07/11] pre-req version check updated --- dev.sh | 68 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/dev.sh b/dev.sh index dc57d216d..f37f7c881 100755 --- a/dev.sh +++ b/dev.sh @@ -8,57 +8,55 @@ version_at_least() { [ "$(printf '%s\n' "$@" | sort -V | head -n 1)" == "$1" ] } -# Check Node.js version -check_node_version() { - if ! command -v node &> /dev/null; then - echo "Node.js is not installed. Please install Node.js v$REQUIRED_NODE_VERSION or higher." - exit 1 - fi +check_versions() { + local node_version yarn_version docker_version + local errors=() - NODE_VERSION=$(node -v | sed 's/v//') - if ! version_at_least "$NODE_VERSION" "$REQUIRED_NODE_VERSION"; then - echo "Current Node.js version ($NODE_VERSION) is incompatible. Please install v$REQUIRED_NODE_VERSION or higher." - exit 1 + # Check Node.js version + if ! command -v node &> /dev/null; then + errors+=("Node.js is not installed. Please install Node.js v$REQUIRED_NODE_VERSION or higher.") + else + node_version=$(node -v | sed 's/v//') + if ! version_at_least "$node_version" "$REQUIRED_NODE_VERSION"; then + errors+=("Current Node.js version ($node_version) is incompatible. Please install v$REQUIRED_NODE_VERSION or higher.") + fi fi -} -# Check Yarn version -check_yarn_version() { + # Check Yarn version if ! command -v yarn &> /dev/null; then - echo "Yarn is not installed. Please install Yarn v$REQUIRED_YARN_VERSION or higher." - exit 1 - fi - - YARN_VERSION=$(yarn -v) - if ! version_at_least "$YARN_VERSION" "$REQUIRED_YARN_VERSION"; then - echo "Current Yarn version ($YARN_VERSION) is incompatible. Please install v$REQUIRED_YARN_VERSION or higher." - exit 1 + errors+=("Yarn is not installed. Please install Yarn v$REQUIRED_YARN_VERSION or higher.") + else + yarn_version=$(yarn -v) + if ! version_at_least "$yarn_version" "$REQUIRED_YARN_VERSION"; then + errors+=("Current Yarn version ($yarn_version) is incompatible. Please install v$REQUIRED_YARN_VERSION or higher.") + fi fi -} -# Check Docker version -check_docker_version() { + # Check Docker version if ! command -v docker &> /dev/null; then - echo "Docker is not installed. Please install Docker v$REQUIRED_DOCKER_VERSION or higher." - exit 1 + errors+=("Docker is not installed. Please install Docker v$REQUIRED_DOCKER_VERSION or higher.") + else + docker_version=$(docker --version | awk '{print $3}' | sed 's/,//') + if ! version_at_least "$docker_version" "$REQUIRED_DOCKER_VERSION"; then + errors+=("Current Docker version ($docker_version) is incompatible. Please install v$REQUIRED_DOCKER_VERSION or higher.") + fi fi - DOCKER_VERSION=$(docker --version | awk '{print $3}' | sed 's/,//') - if ! version_at_least "$DOCKER_VERSION" "$REQUIRED_DOCKER_VERSION"; then - echo "Current Docker version ($DOCKER_VERSION) is incompatible. Please install v$REQUIRED_DOCKER_VERSION or higher." + # Display errors, if any + if [ ${#errors[@]} -ne 0 ]; then + for error in "${errors[@]}"; do + echo "$error" + done exit 1 fi -} -check_node_version -check_yarn_version -check_docker_version + echo "Node.js, Yarn, and Docker versions are compatible. Proceeding..." +} -echo "Node.js, Yarn and Docker versions are compatible. Proceeding..." +check_versions [ ! -f .env ] && cp env.example .env -# Create .env file if it doesn't exist check_internet_connection() { curl -s https://www.google.com > /dev/null 2>&1 if [[ $? -ne 0 ]]; then From 47c56d49e266eafb1f70d4ab4c198f476a1b5d2a Mon Sep 17 00:00:00 2001 From: sahitya-chandra Date: Tue, 15 Oct 2024 21:29:17 +0530 Subject: [PATCH 08/11] rebase done --- dev.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dev.sh b/dev.sh index f37f7c881..cd276c988 100755 --- a/dev.sh +++ b/dev.sh @@ -55,6 +55,7 @@ check_versions() { check_versions + [ ! -f .env ] && cp env.example .env check_internet_connection() { From 90602fc06e118fa0be436c1541e014cd0965c4e5 Mon Sep 17 00:00:00 2001 From: sahitya-chandra Date: Tue, 15 Oct 2024 22:11:27 +0530 Subject: [PATCH 09/11] error --- dev.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/dev.sh b/dev.sh index cd276c988..f37f7c881 100755 --- a/dev.sh +++ b/dev.sh @@ -55,7 +55,6 @@ check_versions() { check_versions - [ ! -f .env ] && cp env.example .env check_internet_connection() { From e54b5e9b110b323f731b5fac72c12b01c97fe473 Mon Sep 17 00:00:00 2001 From: sahitya-chandra Date: Tue, 15 Oct 2024 22:34:24 +0530 Subject: [PATCH 10/11] pr reopened --- dev.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/dev.sh b/dev.sh index f37f7c881..cd276c988 100755 --- a/dev.sh +++ b/dev.sh @@ -55,6 +55,7 @@ check_versions() { check_versions + [ ! -f .env ] && cp env.example .env check_internet_connection() { From bd47e453b2a9f35463c75bccc4d05d1ae1a3b5fe Mon Sep 17 00:00:00 2001 From: sahitya-chandra Date: Tue, 15 Oct 2024 22:56:30 +0530 Subject: [PATCH 11/11] env set --- dev.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/dev.sh b/dev.sh index cd276c988..f37f7c881 100755 --- a/dev.sh +++ b/dev.sh @@ -55,7 +55,6 @@ check_versions() { check_versions - [ ! -f .env ] && cp env.example .env check_internet_connection() {