Răsfoiți Sursa

feat add prerequisites validation (#943)

* feat add prerequisites validation

* fix error

* Update Makefile

Co-authored-by: Robert Brennan <accounts@rbren.io>

* change awk with sek

* fix typo

* fix error

* fix linux error

---------

Co-authored-by: Robert Brennan <accounts@rbren.io>
Co-authored-by: Jim Su <jimsu@protonmail.com>
Beichen Ma 1 an în urmă
părinte
comite
2242702cf9
1 a modificat fișierele cu 41 adăugiri și 1 ștergeri
  1. 41 1
      Makefile

+ 41 - 1
Makefile

@@ -31,12 +31,27 @@ build:
 
 check-dependencies:
 	@echo "$(YELLOW)Checking dependencies...$(RESET)"
+	@$(MAKE) -s check-system
 	@$(MAKE) -s check-python
 	@$(MAKE) -s check-npm
+	@$(MAKE) -s check-nodejs
 	@$(MAKE) -s check-docker
 	@$(MAKE) -s check-poetry
 	@echo "$(GREEN)Dependencies checked successfully.$(RESET)"
 
+check-system:
+	@echo "$(YELLOW)Checking system...$(RESET)"
+	@if [ "$(shell uname)" = "Darwin" ]; then \
+		echo "$(BLUE)macOS detected.$(RESET)"; \
+	elif [ "$(shell uname)" = "Linux" ]; then \
+		echo "$(BLUE)Linux detected.$(RESET)"; \
+	elif [ "$$(uname -r | grep -i microsoft)" ]; then \
+		echo "$(BLUE)Windows Subsystem for Linux detected.$(RESET)"; \
+	else \
+		echo "$(RED)Unsupported system detected. Please use macOS, Linux, or Windows Subsystem for Linux (WSL).$(RESET)"; \
+		exit 1; \
+	fi
+		
 check-python:
 	@echo "$(YELLOW)Checking Python installation...$(RESET)"
 	@if command -v python3.11 > /dev/null; then \
@@ -55,6 +70,22 @@ check-npm:
 		exit 1; \
 	fi
 
+check-nodejs:
+	@echo "$(YELLOW)Checking Node.js installation...$(RESET)"
+	@if command -v node > /dev/null; then \
+		NODE_VERSION=$(shell node --version | sed -E 's/v//g'); \
+		IFS='.' read -r -a NODE_VERSION_ARRAY <<< "$$NODE_VERSION"; \
+		if [ "$${NODE_VERSION_ARRAY[0]}" -gt 18 ] || ([ "$${NODE_VERSION_ARRAY[0]}" -eq 18 ] && [ "$${NODE_VERSION_ARRAY[1]}" -gt 17 ]) || ([ "$${NODE_VERSION_ARRAY[0]}" -eq 18 ] && [ "$${NODE_VERSION_ARRAY[1]}" -eq 17 ] && [ "$${NODE_VERSION_ARRAY[2]}" -ge 1 ]); then \
+			echo "$(BLUE)Node.js $$NODE_VERSION is already installed.$(RESET)"; \
+		else \
+			echo "$(RED)Node.js 18.17.1 or later is required. Please install Node.js 18.17.1 or later to continue.$(RESET)"; \
+			exit 1; \
+		fi; \
+	else \
+		echo "$(RED)Node.js is not installed. Please install Node.js to continue.$(RESET)"; \
+		exit 1; \
+	fi
+
 check-docker:
 	@echo "$(YELLOW)Checking Docker installation...$(RESET)"
 	@if command -v docker > /dev/null; then \
@@ -67,7 +98,16 @@ check-docker:
 check-poetry:
 	@echo "$(YELLOW)Checking Poetry installation...$(RESET)"
 	@if command -v poetry > /dev/null; then \
-		echo "$(BLUE)$(shell poetry --version) is already installed.$(RESET)"; \
+		POETRY_VERSION=$(shell poetry --version 2>&1 | sed -E 's/Poetry \(version ([0-9]+\.[0-9]+\.[0-9]+)\)/\1/'); \
+		IFS='.' read -r -a POETRY_VERSION_ARRAY <<< "$$POETRY_VERSION"; \
+		if [ $${POETRY_VERSION_ARRAY[0]} -ge 1 ] && [ $${POETRY_VERSION_ARRAY[1]} -ge 8 ]; then \
+			echo "$(BLUE)$(shell poetry --version) is already installed.$(RESET)"; \
+		else \
+			echo "$(RED)Poetry 1.8 or later is required. You can install poetry by running the following command, then adding Poetry to your PATH:"; \
+			echo "$(RED) curl -sSL https://install.python-poetry.org | python3 -$(RESET)"; \
+			echo "$(RED)More detail here: https://python-poetry.org/docs/#installing-with-the-official-installer$(RESET)"; \
+			exit 1; \
+		fi; \
 	else \
 		echo "$(RED)Poetry is not installed. You can install poetry by running the following command, then adding Poetry to your PATH:"; \
 		echo "$(RED) curl -sSL https://install.python-poetry.org | python3.11 -$(RESET)"; \