From 7c835e84278ff928094298baaeac4dddf4e32445 Mon Sep 17 00:00:00 2001 From: sahitya-chandra Date: Wed, 16 Oct 2024 20:11:33 +0530 Subject: [PATCH 1/4] pre-requisite dependency version check added in dev.sh file --- dev.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/dev.sh b/dev.sh index fe11a0c1..f37f7c88 100755 --- a/dev.sh +++ b/dev.sh @@ -1,5 +1,60 @@ #!/bin/bash +REQUIRED_NODE_VERSION=22.0.0 +REQUIRED_YARN_VERSION=1.22.22 +REQUIRED_DOCKER_VERSION=24.0.0 + +version_at_least() { + [ "$(printf '%s\n' "$@" | sort -V | head -n 1)" == "$1" ] +} + +check_versions() { + local node_version yarn_version docker_version + local errors=() + + # 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 + if ! command -v yarn &> /dev/null; then + 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 + if ! command -v docker &> /dev/null; then + 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 + + # Display errors, if any + if [ ${#errors[@]} -ne 0 ]; then + for error in "${errors[@]}"; do + echo "$error" + done + exit 1 + fi + + echo "Node.js, Yarn, and Docker versions are compatible. Proceeding..." +} + +check_versions + [ ! -f .env ] && cp env.example .env check_internet_connection() { From d06e940dd4f990a79959807037fdbea9f22a8da3 Mon Sep 17 00:00:00 2001 From: sahitya-chandra Date: Wed, 16 Oct 2024 20:42:52 +0530 Subject: [PATCH 2/4] happy path msg removed --- dev.sh | 1 - web-server/src/assets/dora-icon.svg | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dev.sh b/dev.sh index f37f7c88..9e3fd2d8 100755 --- a/dev.sh +++ b/dev.sh @@ -50,7 +50,6 @@ check_versions() { exit 1 fi - echo "Node.js, Yarn, and Docker versions are compatible. Proceeding..." } check_versions diff --git a/web-server/src/assets/dora-icon.svg b/web-server/src/assets/dora-icon.svg index 611e37dd..6bf6baba 100644 --- a/web-server/src/assets/dora-icon.svg +++ b/web-server/src/assets/dora-icon.svg @@ -1 +1 @@ - \ No newline at end of file + From d8bff65bb5daac87305fdae72787709e7ea88e90 Mon Sep 17 00:00:00 2001 From: sahitya-chandra Date: Thu, 17 Oct 2024 19:40:47 +0530 Subject: [PATCH 3/4] final touch done --- dev.sh | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/dev.sh b/dev.sh index 9e3fd2d8..1373e37c 100755 --- a/dev.sh +++ b/dev.sh @@ -1,11 +1,14 @@ #!/bin/bash -REQUIRED_NODE_VERSION=22.0.0 -REQUIRED_YARN_VERSION=1.22.22 -REQUIRED_DOCKER_VERSION=24.0.0 +#!/bin/bash + +MINIMUM_NODE_VERSION=22.0.0 +MINIMUM_YARN_VERSION=1.22.22 +MINIMUM_DOCKER_VERSION=24.0.0 +# Function to compare versions correctly version_at_least() { - [ "$(printf '%s\n' "$@" | sort -V | head -n 1)" == "$1" ] + printf '%s\n%s\n' "$1" "$2" | sort -V | head -n 1 | grep -qx "$1" } check_versions() { @@ -14,31 +17,31 @@ check_versions() { # 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.") + errors+=("Node.js is not installed. Please install Node.js v$MINIMUM_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.") + node_version=$(node -v | sed 's/^v//') + if ! version_at_least "$MINIMUM_NODE_VERSION" "$node_version"; then + errors+=("Current Node.js version ($node_version) is incompatible. Please install v$MINIMUM_NODE_VERSION or higher.") fi fi # Check Yarn version if ! command -v yarn &> /dev/null; then - errors+=("Yarn is not installed. Please install Yarn v$REQUIRED_YARN_VERSION or higher.") + errors+=("Yarn is not installed. Please install Yarn v$MINIMUM_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.") + if ! version_at_least "$MINIMUM_YARN_VERSION" "$yarn_version"; then + errors+=("Current Yarn version ($yarn_version) is incompatible. Please install v$MINIMUM_YARN_VERSION or higher.") fi fi # Check Docker version if ! command -v docker &> /dev/null; then - errors+=("Docker is not installed. Please install Docker v$REQUIRED_DOCKER_VERSION or higher.") + errors+=("Docker is not installed. Please install Docker v$MINIMUM_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.") + if ! version_at_least "$MINIMUM_DOCKER_VERSION" "$docker_version"; then + errors+=("Current Docker version ($docker_version) is incompatible. Please install v$MINIMUM_DOCKER_VERSION or higher.") fi fi @@ -50,10 +53,12 @@ check_versions() { exit 1 fi + echo "All required versions are met." } check_versions + [ ! -f .env ] && cp env.example .env check_internet_connection() { From 0411e33b75aaf9468fe7fb7eb9b0f228ba902e91 Mon Sep 17 00:00:00 2001 From: sahitya-chandra Date: Thu, 17 Oct 2024 20:19:43 +0530 Subject: [PATCH 4/4] happy msg removed --- dev.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/dev.sh b/dev.sh index 1373e37c..d8e86f51 100755 --- a/dev.sh +++ b/dev.sh @@ -53,7 +53,6 @@ check_versions() { exit 1 fi - echo "All required versions are met." } check_versions