diff --git a/Install-Linux.sh b/Install-Linux.sh new file mode 100644 index 0000000..6ae2ed7 --- /dev/null +++ b/Install-Linux.sh @@ -0,0 +1,306 @@ +#!/bin/bash + +echo "" +echo " ███╗ ██╗ ██████╗ ███╗ ███╗ █████╗ ██████╗ █████╗ ██████╗ ██████╗██╗ ██╗" +echo " ████╗ ██║██╔═══██╗████╗ ████║██╔══██╗██╔══██╗██╔══██╗██╔════╝██║ ██║" +echo " ██╔██╗ ██║██║ ██║██╔████╔██║███████║██║ ██║███████║██████╔╝██║ ███████║" +echo " ██║╚██╗██║██║ ██║██║╚██╔╝██║██╔══██║██║ ██║██╔══██║██╔══██╗██║ ██╔══██║" +echo " ██║ ╚████║╚██████╔╝██║ ╚═╝ ██║██║ ██║██████╔╝██║ ██║██║ ██║╚██████╗██║ ██║" +echo " ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝" +echo "" +echo " INSTALLER - Enhanced with Auto-Dependency Resolution" +echo " ═════════════════════════════════════════════════════════════════════════════" +echo "" + +ERRORS=0 +WARNINGS=0 + +cd "$(dirname "$0")" + +echo "[STEP 1/7] Detecting Linux Distribution..." +echo "" + +if [ -f /etc/os-release ]; then + . /etc/os-release + DISTRO=$ID + DISTRO_VERSION=$VERSION_ID + echo "[OK] Detected: $PRETTY_NAME" +else + echo "[WARN] Could not detect specific distribution" + DISTRO="unknown" + WARNINGS=$((WARNINGS + 1)) +fi + +echo "" +echo "[STEP 2/7] Checking System Requirements..." +echo "" + +if ! command -v node &> /dev/null; then + echo "[ERROR] Node.js not found!" + echo "" + echo "NomadArch requires Node.js to run." + echo "" + echo "Install using your package manager:" + if [ "$DISTRO" = "ubuntu" ] || [ "$DISTRO" = "debian" ]; then + echo " sudo apt update && sudo apt install -y nodejs npm" + elif [ "$DISTRO" = "fedora" ]; then + echo " sudo dnf install -y nodejs npm" + elif [ "$DISTRO" = "arch" ] || [ "$DISTRO" = "manjaro" ]; then + echo " sudo pacman -S nodejs npm" + elif [ "$DISTRO" = "opensuse-leap" ] || [ "$DISTRO" = "opensuse-tumbleweed" ]; then + echo " sudo zypper install -y nodejs npm" + else + echo " Visit https://nodejs.org/ for installation instructions" + fi + echo "" + echo "Or install Node.js using NVM (Node Version Manager):" + echo " curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash" + echo " source ~/.bashrc" + echo " nvm install 20" + echo "" + exit 1 +fi + +NODE_VERSION=$(node --version) +echo "[OK] Node.js detected: $NODE_VERSION" + +NODE_MAJOR=$(echo $NODE_VERSION | cut -d. -f1 | sed 's/v//') +if [ "$NODE_MAJOR" -lt 18 ]; then + echo "[WARN] Node.js version is too old (found v$NODE_VERSION, required 18+)" + echo "[INFO] Please update Node.js" + WARNINGS=$((WARNINGS + 1)) +fi + +if ! command -v npm &> /dev/null; then + echo "[ERROR] npm not found! This should come with Node.js." + echo "Please reinstall Node.js" + ERRORS=$((ERRORS + 1)) +fi + +NPM_VERSION=$(npm --version) +echo "[OK] npm detected: $NPM_VERSION" + +echo "" +echo "[STEP 3/7] Checking OpenCode CLI..." +echo "" + +if command -v opencode &> /dev/null; then + echo "[OK] OpenCode is already installed globally" + OPENCODE_DONE=true +elif [ -f "bin/opencode" ]; then + echo "[OK] OpenCode binary found in bin/ folder" + OPENCODE_DONE=true +else + OPENCODE_DONE=false +fi + +if [ "$OPENCODE_DONE" = false ]; then + echo "[SETUP] OpenCode CLI not found. Installing..." + echo "" + echo "[INFO] Attempting to install OpenCode via npm..." + npm install -g opencode-ai@latest + if [ $? -eq 0 ]; then + echo "[SUCCESS] OpenCode installed successfully via npm" + if command -v opencode &> /dev/null; then + echo "[OK] OpenCode is now available in system PATH" + OPENCODE_DONE=true + fi + else + echo "[WARN] npm install failed, trying fallback method..." + echo "" + + if [ ! -d "bin" ]; then + mkdir bin + fi + + ARCH=$(uname -m) + if [ "$ARCH" = "x86_64" ]; then + FILENAME="opencode-linux-x64.zip" + elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then + FILENAME="opencode-linux-arm64.zip" + else + echo "[WARN] Unsupported architecture: $ARCH" + WARNINGS=$((WARNINGS + 1)) + FILENAME="" + fi + + if [ -n "$FILENAME" ]; then + echo "[SETUP] Downloading OpenCode from GitHub releases..." + curl -L -o "opencode.zip" "https://github.com/sst/opencode/releases/latest/download/$FILENAME" + if [ $? -ne 0 ]; then + echo "[ERROR] Failed to download OpenCode from GitHub!" + echo "[INFO] You can install OpenCode CLI manually from: https://opencode.ai/" + WARNINGS=$((WARNINGS + 1)) + else + echo "[OK] Downloaded OpenCode ZIP" + echo "[SETUP] Extracting OpenCode binary..." + + unzip -q "opencode.zip" -d "opencode-temp" + if [ -f "opencode-temp/opencode" ]; then + mv "opencode-temp/opencode" "bin/opencode" + chmod +x "bin/opencode" + echo "[OK] OpenCode binary placed in bin/ folder" + else + echo "[ERROR] opencode binary not found in extracted files!" + WARNINGS=$((WARNINGS + 1)) + fi + + rm -f "opencode.zip" + rm -rf "opencode-temp" + fi + fi + fi +fi + +echo "" +echo "[STEP 4/7] Installing NomadArch Dependencies..." +echo "" + +if [ -d "node_modules" ]; then + echo "[INFO] node_modules found. Skipping dependency installation." + echo "[INFO] To force reinstall, delete node_modules and run again." + goto :BUILD_CHECK +fi + +echo "[INFO] Installing root dependencies..." +npm install +if [ $? -ne 0 ]; then + echo "[ERROR] Failed to install root dependencies!" + ERRORS=$((ERRORS + 1)) +fi + +echo "[INFO] Installing package dependencies..." + +if [ -d "packages/server" ]; then + echo "[INFO] Installing server dependencies..." + cd packages/server + npm install + if [ $? -ne 0 ]; then + echo "[WARN] Failed to install server dependencies!" + WARNINGS=$((WARNINGS + 1)) + else + echo "[OK] Server dependencies installed" + fi + cd ../.. +fi + +if [ -d "packages/ui" ]; then + echo "[INFO] Installing UI dependencies..." + cd packages/ui + npm install + if [ $? -ne 0 ]; then + echo "[WARN] Failed to install UI dependencies!" + WARNINGS=$((WARNINGS + 1)) + else + echo "[OK] UI dependencies installed" + fi + cd ../.. +fi + +if [ -d "packages/electron-app" ]; then + echo "[INFO] Installing Electron app dependencies..." + cd packages/electron-app + npm install + if [ $? -ne 0 ]; then + echo "[WARN] Failed to install Electron app dependencies!" + WARNINGS=$((WARNINGS + 1)) + else + echo "[OK] Electron app dependencies installed" + fi + cd ../.. +fi + +echo "" +echo "[STEP 5/7] Setting Permissions..." +echo "" + +chmod +x Launch-Unix.sh 2>/dev/null +chmod +x Install-Linux.sh 2>/dev/null +chmod +x Install-Mac.sh 2>/dev/null + +echo "[OK] Scripts permissions set" + +echo "" +echo "[STEP 6/7] Checking for Existing Build..." +echo "" + +if [ -d "packages/ui/dist" ]; then + echo "[OK] UI build found. Skipping build step." + echo "[INFO] To rebuild, delete packages/ui/dist and run installer again." + goto :INSTALL_REPORT +fi + +echo "[INFO] No UI build found. Building UI..." +echo "" + +cd packages/ui +npm run build +if [ $? -ne 0 ]; then + echo "[WARN] Failed to build UI!" + WARNINGS=$((WARNINGS + 1)) + echo "[INFO] You can build manually later by running: cd packages/ui && npm run build" +fi +cd ../.. + +echo "" +echo "[STEP 7/7] Testing Installation..." +echo "" + +node --version >nul 2>&1 +if [ $? -eq 0 ]; then + echo "[OK] Node.js is working" +else + echo "[FAIL] Node.js is not working correctly" + ERRORS=$((ERRORS + 1)) +fi + +npm --version >nul 2>&1 +if [ $? -eq 0 ]; then + echo "[OK] npm is working" +else + echo "[FAIL] npm is not working correctly" + ERRORS=$((ERRORS + 1)) +fi + +if command -v opencode &> /dev/null; then + echo "[OK] OpenCode CLI is available" +elif [ -f "bin/opencode" ]; then + echo "[OK] OpenCode binary found in bin/ folder" +else + echo "[FAIL] OpenCode CLI not available" + WARNINGS=$((WARNINGS + 1)) +fi + +echo "" +echo "Installation Summary" +echo "" + +if [ $ERRORS -gt 0 ]; then + echo "" + echo "════════════════════════════════════════════════════════════════════════════" + echo "[FAILED] Installation encountered $ERRORS error(s)!" + echo "" + echo "Please review error messages above and try again." + echo "For help, see: https://github.com/roman-ryzenadvanced/NomadArch-v1.0/issues" + echo "════════════════════════════════════════════════════════════════════════════" + echo "" + exit 1 +fi + +echo "" +echo "════════════════════════════════════════════════════════════════════════════" +echo "[SUCCESS] Installation Complete!" +echo "" + +if [ $WARNINGS -gt 0 ]; then + echo "[WARN] There were $WARNINGS warning(s) during installation." + echo "Review warnings above. Most warnings are non-critical." + echo "" +fi + +echo "You can now run NomadArch using:" +echo " ./Launch-Unix.sh" +echo "" +echo "For help and documentation, see: README.md" +echo "════════════════════════════════════════════════════════════════════════════" +echo "" diff --git a/Install-Mac.sh b/Install-Mac.sh new file mode 100644 index 0000000..57fea9e --- /dev/null +++ b/Install-Mac.sh @@ -0,0 +1,331 @@ +#!/bin/bash + +echo "" +echo " ███╗ ██╗ ██████╗ ███╗ ███╗ █████╗ ██████╗ █████╗ ██████╗ ██████╗██╗ ██╗" +echo " ████╗ ██║██╔═══██╗████╗ ████║██╔══██╗██╔══██╗██╔══██╗██╔════╝██║ ██║" +echo " ██╔██╗ ██║██║ ██║██╔████╔██║███████║██║ ██║███████║██████╔╝██║ ███████║" +echo " ██║╚██╗██║██║ ██║██║╚██╔╝██║██╔══██║██║ ██║██╔══██║██╔══██╗██║ ██╔══██║" +echo " ██║ ╚████║╚██████╔╝██║ ╚═╝ ██║██║ ██║██████╔╝██║ ██║██║ ██║╚██████╗██║ ██║" +echo " ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝" +echo "" +echo " INSTALLER - macOS Enhanced with Auto-Dependency Resolution" +echo " ═══════════════════════════════════════════════════════════════════════════" +echo "" + +ERRORS=0 +WARNINGS=0 + +cd "$(dirname "$0")" + +echo "[STEP 1/7] Checking macOS Version..." +echo "" + +if [ -f /System/Library/CoreServices/SystemVersion.plist ]; then + MAC_VERSION=$(defaults read /System/Library/CoreServices/SystemVersion.plist ProductVersion) + MAC_MAJOR=$(echo $MAC_VERSION | cut -d. -f1) + echo "[OK] macOS detected: $MAC_VERSION" + + if [ "$MAC_MAJOR" -lt 11 ]; then + echo "[WARN] NomadArch requires macOS 11+ (Big Sur or later)" + echo "[INFO] Your version is $MAC_VERSION" + echo "[INFO] Please upgrade macOS to continue" + exit 1 + fi +else + echo "[WARN] Could not detect macOS version" + WARNINGS=$((WARNINGS + 1)) +fi + +ARCH=$(uname -m) +if [ "$ARCH" = "arm64" ]; then + echo "[OK] Apple Silicon detected (M1/M2/M3 chip)" +elif [ "$ARCH" = "x86_64" ]; then + echo "[OK] Intel Mac detected" +else + echo "[WARN] Unknown architecture: $ARCH" + WARNINGS=$((WARNINGS + 1)) +fi + +echo "" +echo "[STEP 2/7] Checking System Requirements..." +echo "" + +if ! command -v node &> /dev/null; then + echo "[ERROR] Node.js not found!" + echo "" + echo "NomadArch requires Node.js to run." + echo "" + echo "Install Node.js using one of these methods:" + echo "" + echo " 1. Homebrew (recommended):" + echo " brew install node" + echo "" + echo " 2. Download from official site:" + echo " Visit https://nodejs.org/" + echo " Download and install macOS installer" + echo "" + echo " 3. Using NVM (Node Version Manager):" + echo " curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash" + echo " source ~/.zshrc (or ~/.bash_profile)" + echo " nvm install 20" + echo "" + exit 1 +fi + +NODE_VERSION=$(node --version) +echo "[OK] Node.js detected: $NODE_VERSION" + +NODE_MAJOR=$(echo $NODE_VERSION | cut -d. -f1 | sed 's/v//') +if [ "$NODE_MAJOR" -lt 18 ]; then + echo "[WARN] Node.js version is too old (found v$NODE_VERSION, required 18+)" + echo "[INFO] Please update Node.js: brew upgrade node" + WARNINGS=$((WARNINGS + 1)) +fi + +if ! command -v npm &> /dev/null; then + echo "[ERROR] npm not found! This should come with Node.js." + echo "Please reinstall Node.js" + ERRORS=$((ERRORS + 1)) +fi + +NPM_VERSION=$(npm --version) +echo "[OK] npm detected: $NPM_VERSION" + +echo "[INFO] Checking Xcode Command Line Tools..." +if ! command -v xcode-select &> /dev/null; then + echo "[WARN] Xcode Command Line Tools not installed" + echo "[INFO] Required for building native Node.js modules" + echo "" + echo "Install by running:" + echo " xcode-select --install" + echo "" + echo "This will open a dialog to install the tools." + WARNINGS=$((WARNINGS + 1)) +else + XCODE_PATH=$(xcode-select -p) + echo "[OK] Xcode Command Line Tools detected: $XCODE_PATH" +fi + +echo "" +echo "[STEP 3/7] Checking OpenCode CLI..." +echo "" + +if command -v opencode &> /dev/null; then + echo "[OK] OpenCode is already installed globally" + OPENCODE_DONE=true +elif [ -f "bin/opencode" ]; then + echo "[OK] OpenCode binary found in bin/ folder" + OPENCODE_DONE=true +else + OPENCODE_DONE=false +fi + +if [ "$OPENCODE_DONE" = false ]; then + echo "[SETUP] OpenCode CLI not found. Installing..." + echo "" + echo "[INFO] Attempting to install OpenCode via npm..." + npm install -g opencode-ai@latest + if [ $? -eq 0 ]; then + echo "[SUCCESS] OpenCode installed successfully via npm" + if command -v opencode &> /dev/null; then + echo "[OK] OpenCode is now available in system PATH" + OPENCODE_DONE=true + fi + else + echo "[WARN] npm install failed, trying fallback method..." + echo "" + + if [ ! -d "bin" ]; then + mkdir bin + fi + + if [ "$ARCH" = "arm64" ]; then + FILENAME="opencode-darwin-arm64.zip" + elif [ "$ARCH" = "x86_64" ]; then + FILENAME="opencode-darwin-x64.zip" + else + echo "[WARN] Unsupported architecture: $ARCH" + WARNINGS=$((WARNINGS + 1)) + FILENAME="" + fi + + if [ -n "$FILENAME" ]; then + echo "[SETUP] Downloading OpenCode from GitHub releases..." + curl -L -o "opencode.zip" "https://github.com/sst/opencode/releases/latest/download/$FILENAME" + if [ $? -ne 0 ]; then + echo "[ERROR] Failed to download OpenCode from GitHub!" + echo "[INFO] You can install OpenCode CLI manually from: https://opencode.ai/" + WARNINGS=$((WARNINGS + 1)) + else + echo "[OK] Downloaded OpenCode ZIP" + echo "[SETUP] Extracting OpenCode binary..." + + unzip -q "opencode.zip" -d "opencode-temp" + if [ -f "opencode-temp/opencode" ]; then + mv "opencode-temp/opencode" "bin/opencode" + chmod +x "bin/opencode" + echo "[OK] OpenCode binary placed in bin/ folder" + else + echo "[ERROR] opencode binary not found in extracted files!" + WARNINGS=$((WARNINGS + 1)) + fi + + rm -f "opencode.zip" + rm -rf "opencode-temp" + fi + fi + fi +fi + +echo "" +echo "[STEP 4/7] Installing NomadArch Dependencies..." +echo "" + +if [ -d "node_modules" ]; then + echo "[INFO] node_modules found. Skipping dependency installation." + echo "[INFO] To force reinstall, delete node_modules and run again." + goto :BUILD_CHECK +fi + +echo "[INFO] Installing root dependencies..." +npm install +if [ $? -ne 0 ]; then + echo "[ERROR] Failed to install root dependencies!" + ERRORS=$((ERRORS + 1)) +fi + +echo "[INFO] Installing package dependencies..." + +if [ -d "packages/server" ]; then + echo "[INFO] Installing server dependencies..." + cd packages/server + npm install + if [ $? -ne 0 ]; then + echo "[WARN] Failed to install server dependencies!" + WARNINGS=$((WARNINGS + 1)) + else + echo "[OK] Server dependencies installed" + fi + cd ../.. +fi + +if [ -d "packages/ui" ]; then + echo "[INFO] Installing UI dependencies..." + cd packages/ui + npm install + if [ $? -ne 0 ]; then + echo "[WARN] Failed to install UI dependencies!" + WARNINGS=$((WARNINGS + 1)) + else + echo "[OK] UI dependencies installed" + fi + cd ../.. +fi + +if [ -d "packages/electron-app" ]; then + echo "[INFO] Installing Electron app dependencies..." + cd packages/electron-app + npm install + if [ $? -ne 0 ]; then + echo "[WARN] Failed to install Electron app dependencies!" + WARNINGS=$((WARNINGS + 1)) + else + echo "[OK] Electron app dependencies installed" + fi + cd ../.. +fi + +echo "" +echo "[STEP 5/7] Setting Permissions..." +echo "" + +chmod +x Launch-Unix.sh 2>/dev/null +chmod +x Install-Linux.sh 2>/dev/null +chmod +x Install-Mac.sh 2>/dev/null + +echo "[OK] Scripts permissions set" + +echo "" +echo "[STEP 6/7] Checking for Existing Build..." +echo "" + +if [ -d "packages/ui/dist" ]; then + echo "[OK] UI build found. Skipping build step." + echo "[INFO] To rebuild, delete packages/ui/dist and run installer again." + goto :INSTALL_REPORT +fi + +echo "[INFO] No UI build found. Building UI..." +echo "" + +cd packages/ui +npm run build +if [ $? -ne 0 ]; then + echo "[WARN] Failed to build UI!" + WARNINGS=$((WARNINGS + 1)) + echo "[INFO] You can build manually later by running: cd packages/ui && npm run build" +fi +cd ../.. + +echo "" +echo "[STEP 7/7] Testing Installation..." +echo "" + +node --version >nul 2>&1 +if [ $? -eq 0 ]; then + echo "[OK] Node.js is working" +else + echo "[FAIL] Node.js is not working correctly" + ERRORS=$((ERRORS + 1)) +fi + +npm --version >nul 2>&1 +if [ $? -eq 0 ]; then + echo "[OK] npm is working" +else + echo "[FAIL] npm is not working correctly" + ERRORS=$((ERRORS + 1)) +fi + +if command -v opencode &> /dev/null; then + echo "[OK] OpenCode CLI is available" +elif [ -f "bin/opencode" ]; then + echo "[OK] OpenCode binary found in bin/ folder" +else + echo "[FAIL] OpenCode CLI not available" + WARNINGS=$((WARNINGS + 1)) +fi + +echo "" +echo "Installation Summary" +echo "" + +if [ $ERRORS -gt 0 ]; then + echo "" + echo "════════════════════════════════════════════════════════════════════════════" + echo "[FAILED] Installation encountered $ERRORS error(s)!" + echo "" + echo "Please review error messages above and try again." + echo "For help, see: https://github.com/roman-ryzenadvanced/NomadArch-v1.0/issues" + echo "════════════════════════════════════════════════════════════════════════════" + echo "" + exit 1 +fi + +echo "" +echo "════════════════════════════════════════════════════════════════════════════" +echo "[SUCCESS] Installation Complete!" +echo "" + +if [ $WARNINGS -gt 0 ]; then + echo "[WARN] There were $WARNINGS warning(s) during installation." + echo "Review warnings above. Most warnings are non-critical." + echo "" +fi + +echo "You can now run NomadArch using:" +echo " ./Launch-Unix.sh" +echo "" +echo "For help and documentation, see: README.md" +echo "════════════════════════════════════════════════════════════════════════════" +echo "" diff --git a/Install-Windows.bat b/Install-Windows.bat new file mode 100644 index 0000000..60ef2f9 --- /dev/null +++ b/Install-Windows.bat @@ -0,0 +1,318 @@ +@echo off +title NomadArch Installer +color 0A +setlocal enabledelayedexpansion + +echo. +echo ███╗ ██╗ ██████╗ ███╗ ███╗ █████╗ ██████╗ █████╗ ██████╗ ██████╗██╗ ██╗ +echo ████╗ ██║██╔═══██╗████╗ ████║██╔══██╗██╔══██╗██╔══██╗██╔════╝██║ ██║ +echo ██╔██╗ ██║██║ ██║██╔████╔██║███████║██║ ██║███████║██████╔╝██║ ███████║ +echo ██║╚██╗██║██║ ██║██║╚██╔╝██║██╔══██║██║ ██║██╔══██║██╔══██╗██║ ██╔══██║ +echo ██║ ╚████║╚██████╔╝██║ ╚═╝ ██║██║ ██║██████╔╝██║ ██║██║ ██║╚██████╗██║ ██║ +echo ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ +echo. +echo INSTALLER - Enhanced with Auto-Dependency Resolution +echo ═══════════════════════════════════════════════════════════════════════════════ +echo. + +set ERRORS=0 +set WARNINGS=0 + +cd /d "%~dp0" + +echo [STEP 1/6] Checking System Requirements... +echo. + +:: Check for Administrator privileges +net session >nul 2>&1 +if %ERRORLEVEL% neq 0 ( + echo [WARN] Not running as Administrator. Some operations may fail. + set /a WARNINGS+=1 + echo. +) + +:: Check for Node.js +echo [INFO] Checking Node.js... +where node >nul 2>&1 +if %ERRORLEVEL% neq 0 ( + echo [ERROR] Node.js not found! + echo. + echo NomadArch requires Node.js to run. + echo. + echo Download from: https://nodejs.org/ + echo Recommended: Node.js 18.x LTS or 20.x LTS + echo. + echo Opening download page... + start "" "https://nodejs.org/" + echo. + echo Please install Node.js and run this installer again. + echo. + pause + exit /b 1 +) + +:: Display Node.js version +for /f "tokens=*" %%i in ('node --version') do set NODE_VERSION=%%i +echo [OK] Node.js found: %NODE_VERSION% + +:: Check for npm +echo [INFO] Checking npm... +where npm >nul 2>&1 +if %ERRORLEVEL% neq 0 ( + echo [ERROR] npm not found! + echo. + echo npm is required for dependency management. + echo. + pause + exit /b 1 +) + +for /f "tokens=*" %%i in ('npm --version') do set NPM_VERSION=%%i +echo [OK] npm found: %NPM_VERSION% + +echo. +echo [STEP 2/6] Checking OpenCode CLI... +echo. + +:: Check if opencode is already installed globally +where opencode >nul 2>&1 +if %ERRORLEVEL% equ 0 ( + echo [OK] OpenCode is already installed globally + goto :OPENCODE_DONE +) + +:: Check if opencode exists in bin/ folder +if exist "bin\opencode.exe" ( + echo [OK] OpenCode binary found in bin/ folder + goto :OPENCODE_DONE +) + +:: Install OpenCode CLI +echo [SETUP] OpenCode CLI not found. Installing... +echo. +echo [INFO] Attempting to install OpenCode via npm... +call npm install -g opencode-ai@latest +if %ERRORLEVEL% equ 0 ( + echo [SUCCESS] OpenCode installed successfully via npm + where opencode >nul 2>&1 + if %ERRORLEVEL% equ 0 ( + echo [OK] OpenCode is now available in system PATH + goto :OPENCODE_DONE + ) +) + +echo [WARN] npm install failed or not in PATH, trying fallback method... +echo. + +:: Fallback: Download from GitHub releases +echo [SETUP] Downloading OpenCode from GitHub releases... +echo. + +:: Download Windows x64 ZIP +curl -L -o "opencode-windows-x64.zip" "https://github.com/sst/opencode/releases/latest/download/opencode-windows-x64.zip" +if %ERRORLEVEL% neq 0 ( + echo [ERROR] Failed to download OpenCode from GitHub! + set /a ERRORS+=1 + goto :INSTALL_DEPS +) + +echo [OK] Downloaded OpenCode ZIP +echo [SETUP] Extracting OpenCode binary... + +:: Create bin directory if not exists +if not exist "bin" mkdir bin + +:: Extract using PowerShell +powershell -Command "Expand-Archive -Path 'opencode-windows-x64.zip' -DestinationPath 'opencode-temp' -Force" +if %ERRORLEVEL% neq 0 ( + echo [ERROR] Failed to extract OpenCode! + set /a ERRORS+=1 + goto :CLEANUP +) + +:: Move opencode.exe to bin/ folder +if exist "opencode-temp\opencode.exe" ( + move /Y "opencode-temp\opencode.exe" "bin\opencode.exe" >nul + echo [OK] OpenCode binary placed in bin/ folder +) else ( + echo [ERROR] opencode.exe not found in extracted files! + set /a ERRORS+=1 +) + +:CLEANUP +if exist "opencode-windows-x64.zip" del "opencode-windows-x64.zip" +if exist "opencode-temp" rmdir /s /q "opencode-temp" + +:OPENCODE_DONE +echo. + +echo [STEP 3/6] Installing NomadArch Dependencies... +echo. + +:: Check if node_modules exists +if exist "node_modules" ( + echo [INFO] node_modules found. Skipping dependency installation. + echo [INFO] To force reinstall, delete node_modules and run again. + goto :BUILD_CHECK +) + +echo [INFO] Installing root dependencies... +call npm install +if %ERRORLEVEL% neq 0 ( + echo [ERROR] Failed to install root dependencies! + set /a ERRORS+=1 + goto :INSTALL_REPORT +) + +echo [OK] Root dependencies installed +echo. + +echo [INFO] Installing package dependencies... + +:: Install server dependencies +if exist "packages\server" ( + echo [INFO] Installing server dependencies... + cd packages\server + call npm install + if %ERRORLEVEL% neq 0 ( + echo [WARN] Failed to install server dependencies! + set /a WARNINGS+=1 + ) else ( + echo [OK] Server dependencies installed + ) + cd ..\.. +) + +:: Install UI dependencies +if exist "packages\ui" ( + echo [INFO] Installing UI dependencies... + cd packages\ui + call npm install + if %ERRORLEVEL% neq 0 ( + echo [WARN] Failed to install UI dependencies! + set /a WARNINGS+=1 + ) else ( + echo [OK] UI dependencies installed + ) + cd ..\.. +) + +:: Install Electron app dependencies +if exist "packages\electron-app" ( + echo [INFO] Installing Electron app dependencies... + cd packages\electron-app + call npm install + if %ERRORLEVEL% neq 0 ( + echo [WARN] Failed to install Electron app dependencies! + set /a WARNINGS+=1 + ) else ( + echo [OK] Electron app dependencies installed + ) + cd ..\.. +) + +:BUILD_CHECK +echo. + +echo [STEP 4/6] Checking for Existing Build... +echo. + +if exist "packages\ui\dist" ( + echo [OK] UI build found. Skipping build step. + echo [INFO] To rebuild, delete packages\ui\dist and run installer again. + goto :INSTALL_REPORT +) + +echo [INFO] No UI build found. Building UI... +echo. + +:: Build UI +cd packages\ui +call npm run build +if %ERRORLEVEL% neq 0 ( + echo [WARN] Failed to build UI! + set /a WARNINGS+=1 + echo [INFO] You can build manually later by running: cd packages\ui ^&^& npm run build +) +cd ..\.. + +:INSTALL_REPORT +echo. +echo ═══════════════════════════════════════════════════════════════════════════════ +echo INSTALLATION COMPLETE +echo ═══════════════════════════════════════════════════════════════════════════════ +echo. +echo Summary: +echo. +if %ERRORS% equ 0 ( + echo ✓ No errors encountered +) else ( + echo ✗ %ERRORS% error(s) encountered +) +echo. +if %WARNINGS% equ 0 ( + echo ✓ No warnings +) else ( + echo ⚠ %WARNINGS% warning(s) encountered +) +echo. + +echo [STEP 5/6] Testing Installation... +echo. + +:: Test node command +node --version >nul 2>&1 +if %ERRORLEVEL% equ 0 ( + echo [OK] Node.js is working +) else ( + echo [FAIL] Node.js is not working correctly + set /a ERRORS+=1 +) + +:: Test npm command +npm --version >nul 2>&1 +if %ERRORLEVEL% equ 0 ( + echo [OK] npm is working +) else ( + echo [FAIL] npm is not working correctly + set /a ERRORS+=1 +) + +:: Test opencode command +where opencode >nul 2>&1 +if %ERRORLEVEL% equ 0 ( + echo [OK] OpenCode CLI is available +) else ( + if exist "bin\opencode.exe" ( + echo [OK] OpenCode binary found in bin/ folder + ) else ( + echo [FAIL] OpenCode CLI not available + set /a WARNINGS+=1 + ) +) + +echo. +echo [STEP 6/6] Next Steps... +echo. +echo To start NomadArch: +echo 1. Double-click and run: Launch-Windows.bat +echo OR +echo 2. Run from command line: npm run dev:electron +echo. +echo For development mode: +echo Run: Launch-Dev-Windows.bat +echo. + +if %ERRORS% gtr 0 ( + echo ⚠ INSTALLATION HAD ERRORS! + echo Please review the messages above and fix any issues. + echo. + pause + exit /b 1 +) else ( + echo ✓ Installation completed successfully! + echo. + echo Press any key to exit... + pause >nul + exit /b 0 +) diff --git a/Launch-Dev-Windows.bat b/Launch-Dev-Windows.bat new file mode 100644 index 0000000..56ca2b5 --- /dev/null +++ b/Launch-Dev-Windows.bat @@ -0,0 +1,125 @@ +@echo off +title NomadArch Development Launcher +color 0B +setlocal enabledelayedexpansion + +echo. +echo ███╗ ██╗ ██████╗ ███╗ ███╗ █████╗ ██████╗ █████╗ ██████╗ ██████╗██╗ ██╗ +echo ████╗ ██║██╔═══██╗████╗ ████║██╔══██╗██╔══██╗██╔══██╗██╔════╝██║ ██║ +echo ██╔██╗ ██║██║ ██║██╔████╔██║███████║██║ ██║███████║██████╔╝██║ ███████║ +echo ██║╚██╗██║██║ ██║██║╚██╔╝██║██╔══██║██║ ██║██╔══██║██╔══██╗██║ ██╔══██║ +echo ██║ ╚████║╚██████╔╝██║ ╚═╝ ██║██║ ██║██████╔╝██║ ██║██║ ██║╚██████╗██║ ██║ +echo ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ +echo. +echo DEVELOPMENT MODE - Separate Server & UI Terminals +echo ═════════════════════════════════════════════════════════════════════════════ +echo. + +cd /d "%~dp0" + +echo [STEP 1/4] Checking Dependencies... +echo. + +where node >nul 2>&1 +if %ERRORLEVEL% neq 0 ( + echo [ERROR] Node.js not found! + echo. + echo Please install Node.js first: https://nodejs.org/ + echo. + pause + exit /b 1 +) + +for /f "tokens=*" %%i in ('node --version') do set NODE_VERSION=%%i +echo [OK] Node.js: %NODE_VERSION% + +where npm >nul 2>&1 +if %ERRORLEVEL% neq 0 ( + echo [ERROR] npm not found! + echo. + pause + exit /b 1 +) + +for /f "tokens=*" %%i in ('npm --version') do set NPM_VERSION=%%i +echo [OK] npm: %NPM_VERSION% + +echo. +echo [STEP 2/4] Checking for OpenCode CLI... +echo. + +where opencode >nul 2>&1 +if %ERRORLEVEL% equ 0 ( + echo [OK] OpenCode is available in PATH +) else ( + if exist "bin\opencode.exe" ( + echo [OK] OpenCode binary found in bin/ folder + ) else ( + echo [WARN] OpenCode CLI not found + echo [INFO] Run Install-Windows.bat to install OpenCode + ) +) + +echo. +echo [STEP 3/4] Checking Port Availability... +echo. + +set SERVER_PORT=3001 +set UI_PORT=3000 + +netstat -ano | findstr ":%SERVER_PORT%" | findstr "LISTENING" >nul 2>&1 +if %ERRORLEVEL% equ 0 ( + echo [WARN] Port %SERVER_PORT% is already in use + echo [INFO] Another NomadArch instance may be running + echo [INFO] To find process: netstat -ano | findstr ":%SERVER_PORT%" + echo [INFO] To kill it: taskkill /F /PID ^ +) else ( + echo [OK] Port %SERVER_PORT% is available +) + +netstat -ano | findstr ":%UI_PORT%" | findstr "LISTENING" >nul 2>&1 +if %ERRORLEVEL% equ 0 ( + echo [WARN] Port %UI_PORT% is already in use + echo [INFO] To find process: netstat -ano | findstr ":%UI_PORT%" + echo [INFO] To kill it: taskkill /F /PID ^ +) else ( + echo [OK] Port %UI_PORT% is available +) + +echo. +echo [STEP 4/4] Starting NomadArch in Development Mode... +echo. +echo [INFO] This will open 3 separate terminal windows: +echo 1. Backend Server (port 3001) +echo 2. Frontend UI (port 3000) +echo 3. Electron App +echo. +echo [INFO] Press any key to start... +pause >nul + +echo. +echo [INFO] Starting Backend Server... +start "NomadArch Server" cmd /k "cd /d \"%~dp0packages\server\" && npm run dev" + +echo [INFO] Starting Frontend UI... +start "NomadArch UI" cmd /k "cd /d \"%~dp0packages\ui\" && npm run dev" + +echo [INFO] Starting Electron App... +start "NomadArch Electron" cmd /k "cd /d \"%~dp0packages\electron-app\" && npm run dev" + +echo. +echo [OK] All services started! +echo. +echo Press any key to stop all services (Ctrl+C in each window also works)... +pause >nul + +echo. +echo [INFO] Stopping all services... +taskkill /F /FI "WINDOWTITLE eq NomadArch*" >nul 2>&1 +taskkill /F /FI "WINDOWTITLE eq NomadArch Server*" >nul 2>&1 +taskkill /F /FI "WINDOWTITLE eq NomadArch UI*" >nul 2>&1 +taskkill /F /FI "WINDOWTITLE eq NomadArch Electron*" >nul 2>&1 + +echo [OK] All services stopped. +echo. +pause diff --git a/Launch-Unix.sh b/Launch-Unix.sh new file mode 100644 index 0000000..eb5aa7b --- /dev/null +++ b/Launch-Unix.sh @@ -0,0 +1,133 @@ +#!/bin/bash + +echo "" +echo " ███╗ ██╗ ██████╗ ███╗ ███╗ █████╗ ██████╗ █████╗ ██████╗ ██████╗██╗ ██╗" +echo " ████╗ ██║██╔═══██╗████╗ ████║██╔══██╗██╔══██╗██╔══██╗██╔════╝██║ ██║" +echo " ██╔██╗ ██║██║ ██║██╔████╔██║███████║██║ ██║███████║██████╔╝██║ ███████║" +echo " ██║╚██╗██║██║ ██║██║╚██╔╝██║██╔══██║██║ ██║██╔══██║██╔══██╗██║ ██╔══██║" +echo " ██║ ╚████║╚██████╔╝██║ ╚═╝ ██║██║ ██║██████╔╝██║ ██║██║ ██║╚██████╗██║ ██║" +echo " ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝" +echo "" +echo " LAUNCHER - Linux/macOS" +echo " ═════════════════════════════════════════════════════════════════════════════" +echo "" + +ERRORS=0 +WARNINGS=0 + +cd "$(dirname "$0")" + +echo "[STEP 1/5] Checking Dependencies..." +echo "" + +if ! command -v node &> /dev/null; then + echo "[ERROR] Node.js not found!" + echo "" + echo "Please install Node.js first: https://nodejs.org/" + echo "Then run: ./Install-Linux.sh (or ./Install-Mac.sh on macOS)" + echo "" + exit 1 +fi + +NODE_VERSION=$(node --version) +echo "[OK] Node.js: $NODE_VERSION" + +if ! command -v npm &> /dev/null; then + echo "[ERROR] npm not found!" + echo "" + exit 1 +fi + +NPM_VERSION=$(npm --version) +echo "[OK] npm: $NPM_VERSION" + +echo "" +echo "[STEP 2/5] Checking for OpenCode CLI..." +echo "" + +if command -v opencode &> /dev/null; then + echo "[OK] OpenCode is available in PATH" +elif [ -f "bin/opencode" ]; then + echo "[OK] OpenCode binary found in bin/ folder" +else + echo "[WARN] OpenCode CLI not found" + echo "[INFO] Run ./Install-Linux.sh (or ./Install-Mac.sh on macOS) to install OpenCode" + WARNINGS=$((WARNINGS + 1)) +fi + +echo "" +echo "[STEP 3/5] Checking for Existing Build..." +echo "" + +if [ -d "packages/ui/dist" ]; then + echo "[OK] UI build found" +else + echo "[WARN] No UI build found. Building now..." + echo "" + cd packages/ui + npm run build + if [ $? -ne 0 ]; then + echo "[ERROR] UI build failed!" + ERRORS=$((ERRORS + 1)) + else + echo "[OK] UI build completed" + fi + cd ../.. +fi + +echo "" +echo "[STEP 4/5] Checking Port Availability..." +echo "" + +SERVER_PORT=3001 +UI_PORT=3000 + +if lsof -Pi :$SERVER_PORT -sTCP:LISTEN -t >/dev/null 2>&1; then + echo "[WARN] Port $SERVER_PORT is already in use" + echo "[INFO] Another NomadArch instance or app may be running" + echo "[INFO] To find the process: lsof -i :$SERVER_PORT" + echo "[INFO] To kill it: kill -9 \$(lsof -t -i:$SERVER_PORT)" + WARNINGS=$((WARNINGS + 1)) +else + echo "[OK] Port $SERVER_PORT is available" +fi + +if lsof -Pi :$UI_PORT -sTCP:LISTEN -t >/dev/null 2>&1; then + echo "[WARN] Port $UI_PORT is already in use" + echo "[INFO] To find the process: lsof -i :$UI_PORT" + echo "[INFO] To kill it: kill -9 \$(lsof -t -i:$UI_PORT)" + WARNINGS=$((WARNINGS + 1)) +else + echo "[OK] Port $UI_PORT is available" +fi + +echo "" +echo "[STEP 5/5] Starting NomadArch..." +echo "" + +if [ $ERRORS -gt 0 ]; then + echo "[ERROR] Cannot start due to errors!" + echo "" + exit 1 +fi + +echo "[INFO] Starting NomadArch..." +echo "[INFO] Server will run on http://localhost:$SERVER_PORT" +echo "[INFO] Press Ctrl+C to stop" +echo "" + +npm run dev:electron + +if [ $? -ne 0 ]; then + echo "" + echo "[ERROR] NomadArch exited with an error!" + echo "" + echo "Common solutions:" + echo " 1. Check that all dependencies are installed: npm install" + echo " 2. Check that the UI is built: cd packages/ui && npm run build" + echo " 3. Check for port conflicts (see warnings above)" + echo " 4. Check the error message above for details" + echo "" + echo "To reinstall everything: ./Install-Linux.sh (or ./Install-Mac.sh on macOS)" + echo "" +fi diff --git a/Launch-Windows.bat b/Launch-Windows.bat new file mode 100644 index 0000000..400aeaf --- /dev/null +++ b/Launch-Windows.bat @@ -0,0 +1,148 @@ +@echo off +title NomadArch Launcher +color 0A +setlocal enabledelayedexpansion + +echo. +echo ███╗ ██╗ ██████╗ ███╗ ███╗ █████╗ ██████╗ █████╗ ██████╗ ██████╗██╗ ██╗ +echo ████╗ ██║██╔═══██╗████╗ ████║██╔══██╗██╔══██╗██╔══██╗██╔════╝██║ ██║ +echo ██╔██╗ ██║██║ ██║██╔████╔██║███████║██║ ██║███████║██████╔╝██║ ███████║ +echo ██║╚██╗██║██║ ██║██║╚██╔╝██║██╔══██║██║ ██║██╔══██║██╔══██╗██║ ██╔══██║ +echo ██║ ╚████║╚██████╔╝██║ ╚═╝ ██║██║ ██║██████╔╝██║ ██║██║ ██║╚██████╗██║ ██║ +echo ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ +echo. +echo LAUNCHER - Enhanced with Auto-Fix Capabilities +echo ═════════════════════════════════════════════════════════════════════════════ +echo. + +cd /d "%~dp0" + +set ERRORS=0 +set WARNINGS=0 + +echo [STEP 1/5] Checking Dependencies... +echo. + +where node >nul 2>&1 +if %ERRORLEVEL% neq 0 ( + echo [ERROR] Node.js not found! + echo. + echo Please install Node.js first: https://nodejs.org/ + echo Then run: Install-Windows.bat + echo. + pause + exit /b 1 +) + +for /f "tokens=*" %%i in ('node --version') do set NODE_VERSION=%%i +echo [OK] Node.js: %NODE_VERSION% + +where npm >nul 2>&1 +if %ERRORLEVEL% neq 0 ( + echo [ERROR] npm not found! + echo. + pause + exit /b 1 +) + +for /f "tokens=*" %%i in ('npm --version') do set NPM_VERSION=%%i +echo [OK] npm: %NPM_VERSION% + +echo. +echo [STEP 2/5] Checking for OpenCode CLI... +echo. + +where opencode >nul 2>&1 +if %ERRORLEVEL% equ 0 ( + echo [OK] OpenCode is available in PATH +) else ( + if exist "bin\opencode.exe" ( + echo [OK] OpenCode binary found in bin/ folder + ) else ( + echo [WARN] OpenCode CLI not found + echo [INFO] Run Install-Windows.bat to install OpenCode + set /a WARNINGS+=1 + ) +) + +echo. +echo [STEP 3/5] Checking for Existing Build... +echo. + +if exist "packages\ui\dist" ( + echo [OK] UI build found +) else ( + echo [WARN] No UI build found. Building now... + echo. + cd packages\ui + call npm run build + if %ERRORLEVEL% neq 0 ( + echo [ERROR] UI build failed! + set /a ERRORS+=1 + ) else ( + echo [OK] UI build completed + ) + cd ..\.. +) + +echo. +echo [STEP 4/5] Checking Port Availability... +echo. + +set SERVER_PORT=3001 +set UI_PORT=3000 + +netstat -ano | findstr ":%SERVER_PORT%" | findstr "LISTENING" >nul 2>&1 +if %ERRORLEVEL% equ 0 ( + echo [WARN] Port %SERVER_PORT% is already in use + echo [INFO] Another NomadArch instance or app may be running + echo [INFO] To find the process: netstat -ano | findstr ":%SERVER_PORT%" + echo [INFO] To kill it: taskkill /F /PID + set /a WARNINGS+=1 +) else ( + echo [OK] Port %SERVER_PORT% is available +) + +netstat -ano | findstr ":%UI_PORT%" | findstr "LISTENING" >nul 2>&1 +if %ERRORLEVEL% equ 0 ( + echo [WARN] Port %UI_PORT% is already in use + echo [INFO] To find the process: netstat -ano | findstr ":%UI_PORT%" + echo [INFO] To kill it: taskkill /F /PID + set /a WARNINGS+=1 +) else ( + echo [OK] Port %UI_PORT% is available +) + +echo. +echo [STEP 5/5] Starting NomadArch... +echo. + +if %ERRORS% gtr 0 ( + echo [ERROR] Cannot start due to errors! + echo. + pause + exit /b 1 +) + +echo [INFO] Starting NomadArch... +echo [INFO] Server will run on http://localhost:%SERVER_PORT% +echo [INFO] Press Ctrl+C to stop +echo. + +call npm run dev:electron + +if %ERRORLEVEL% neq 0 ( + echo. + echo [ERROR] NomadArch exited with an error! + echo. + echo Common solutions: + echo 1. Check that all dependencies are installed: npm install + echo 2. Check that the UI is built: cd packages\ui ^&^& npm run build + echo 3. Check for port conflicts (see warnings above) + echo 4. Check the error message above for details + echo. + echo To reinstall everything: Install-Windows.bat + echo. +) + +pause