Compare commits
8 Commits
52720b2e84
...
main
457
Install-Linux.sh
457
Install-Linux.sh
@@ -1,9 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# NomadArch Installer for Linux
|
# NomadArch Installer for Linux
|
||||||
# Version: 0.6.0 - Robust Edition
|
# Version: 0.6.1 - Universal Edition
|
||||||
|
|
||||||
# Exit on error, but handle gracefully
|
# Exit on error but provide helpful messages
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
# Colors
|
# Colors
|
||||||
@@ -31,19 +31,19 @@ log() {
|
|||||||
|
|
||||||
print_header() {
|
print_header() {
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${CYAN}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
echo -e "${CYAN}==============================================================${NC}"
|
||||||
echo -e "${CYAN}║${NC} ${BOLD}NomadArch Installer for Linux${NC} ${CYAN}║${NC}"
|
echo -e "${CYAN}|${NC} ${BOLD}NomadArch Installer for Linux${NC} ${CYAN}|${NC}"
|
||||||
echo -e "${CYAN}║${NC} Version: 0.6.0 - Robust Edition ${CYAN}║${NC}"
|
echo -e "${CYAN}|${NC} Version: 0.6.1 - Universal Edition ${CYAN}|${NC}"
|
||||||
echo -e "${CYAN}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
echo -e "${CYAN}==============================================================${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
print_header
|
print_header
|
||||||
log "========== Installer started =========="
|
log "========== Installer started =========="
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
# STEP 1: OS and Architecture Detection
|
# STEP 1: OS and Architecture Detection
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
echo "[STEP 1/8] Detecting System..."
|
echo "[STEP 1/8] Detecting System..."
|
||||||
|
|
||||||
OS_TYPE=$(uname -s)
|
OS_TYPE=$(uname -s)
|
||||||
@@ -52,41 +52,15 @@ log "OS: $OS_TYPE, Arch: $ARCH_TYPE"
|
|||||||
|
|
||||||
if [[ "$OS_TYPE" != "Linux" ]]; then
|
if [[ "$OS_TYPE" != "Linux" ]]; then
|
||||||
echo -e "${RED}[ERROR]${NC} This installer is for Linux. Current OS: $OS_TYPE"
|
echo -e "${RED}[ERROR]${NC} This installer is for Linux. Current OS: $OS_TYPE"
|
||||||
echo " Use Install-Mac.sh for macOS or Install-Windows.bat for Windows."
|
|
||||||
log "ERROR: Not Linux ($OS_TYPE)"
|
log "ERROR: Not Linux ($OS_TYPE)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$ARCH_TYPE" in
|
echo -e "${GREEN}[OK]${NC} OS: Linux ($ARCH_TYPE)"
|
||||||
x86_64) ARCH="x64" ;;
|
|
||||||
aarch64) ARCH="arm64" ;;
|
|
||||||
armv7l) ARCH="arm" ;;
|
|
||||||
*)
|
|
||||||
echo -e "${YELLOW}[WARN]${NC} Unusual architecture: $ARCH_TYPE (proceeding anyway)"
|
|
||||||
ARCH="$ARCH_TYPE"
|
|
||||||
((WARNINGS++)) || true
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo -e "${GREEN}[OK]${NC} OS: Linux"
|
# ---------------------------------------------------------------
|
||||||
echo -e "${GREEN}[OK]${NC} Architecture: $ARCH_TYPE ($ARCH)"
|
|
||||||
|
|
||||||
# Detect distribution
|
|
||||||
if [[ -f /etc/os-release ]]; then
|
|
||||||
# shellcheck disable=SC1091
|
|
||||||
. /etc/os-release
|
|
||||||
DISTRO="${ID:-unknown}"
|
|
||||||
DISTRO_NAME="${PRETTY_NAME:-$DISTRO}"
|
|
||||||
echo -e "${GREEN}[INFO]${NC} Distribution: $DISTRO_NAME"
|
|
||||||
else
|
|
||||||
DISTRO="unknown"
|
|
||||||
DISTRO_NAME="Unknown Linux"
|
|
||||||
fi
|
|
||||||
log "Distribution: $DISTRO_NAME"
|
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
|
||||||
# STEP 2: Check Write Permissions
|
# STEP 2: Check Write Permissions
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 2/8] Checking Write Permissions..."
|
echo "[STEP 2/8] Checking Write Permissions..."
|
||||||
|
|
||||||
@@ -98,363 +72,170 @@ if ! touch "$SCRIPT_DIR/.install-write-test" 2>/dev/null; then
|
|||||||
BIN_DIR="$TARGET_DIR/bin"
|
BIN_DIR="$TARGET_DIR/bin"
|
||||||
LOG_FILE="$TARGET_DIR/install.log"
|
LOG_FILE="$TARGET_DIR/install.log"
|
||||||
mkdir -p "$BIN_DIR"
|
mkdir -p "$BIN_DIR"
|
||||||
if ! touch "$TARGET_DIR/.install-write-test" 2>/dev/null; then
|
cp -R "$SCRIPT_DIR/"* "$TARGET_DIR/" 2>/dev/null || true
|
||||||
echo -e "${RED}[ERROR]${NC} Cannot write to $TARGET_DIR"
|
echo -e "${GREEN}[INFO]${NC} Using fallback location: $TARGET_DIR"
|
||||||
log "ERROR: Write permission denied"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
rm -f "$TARGET_DIR/.install-write-test"
|
|
||||||
echo -e "${GREEN}[OK]${NC} Using fallback: $TARGET_DIR"
|
|
||||||
else
|
else
|
||||||
rm -f "$SCRIPT_DIR/.install-write-test"
|
rm "$SCRIPT_DIR/.install-write-test" 2>/dev/null
|
||||||
echo -e "${GREEN}[OK]${NC} Write access verified"
|
echo -e "${GREEN}[OK]${NC} Write permissions verified"
|
||||||
fi
|
fi
|
||||||
log "Install target: $TARGET_DIR"
|
log "Install target: $TARGET_DIR"
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
# STEP 3: Detect Package Manager and sudo
|
# STEP 3: Check and Install Node.js
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 3/8] Detecting Package Manager..."
|
echo "[STEP 3/8] Checking Node.js..."
|
||||||
|
|
||||||
SUDO=""
|
|
||||||
if [[ $EUID -ne 0 ]]; then
|
|
||||||
if command -v sudo >/dev/null 2>&1; then
|
|
||||||
SUDO="sudo"
|
|
||||||
echo -e "${GREEN}[OK]${NC} sudo available (may prompt for password)"
|
|
||||||
else
|
|
||||||
echo -e "${YELLOW}[WARN]${NC} Not root and sudo not found. Package installation may fail."
|
|
||||||
((WARNINGS++)) || true
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo -e "${GREEN}[OK]${NC} Running as root"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Detect package manager
|
|
||||||
PACKAGE_MANAGER=""
|
|
||||||
if command -v apt-get >/dev/null 2>&1; then
|
|
||||||
PACKAGE_MANAGER="apt"
|
|
||||||
echo -e "${GREEN}[OK]${NC} Package manager: apt (Debian/Ubuntu)"
|
|
||||||
elif command -v dnf >/dev/null 2>&1; then
|
|
||||||
PACKAGE_MANAGER="dnf"
|
|
||||||
echo -e "${GREEN}[OK]${NC} Package manager: dnf (Fedora/RHEL)"
|
|
||||||
elif command -v yum >/dev/null 2>&1; then
|
|
||||||
PACKAGE_MANAGER="yum"
|
|
||||||
echo -e "${GREEN}[OK]${NC} Package manager: yum (CentOS/RHEL)"
|
|
||||||
elif command -v pacman >/dev/null 2>&1; then
|
|
||||||
PACKAGE_MANAGER="pacman"
|
|
||||||
echo -e "${GREEN}[OK]${NC} Package manager: pacman (Arch)"
|
|
||||||
elif command -v zypper >/dev/null 2>&1; then
|
|
||||||
PACKAGE_MANAGER="zypper"
|
|
||||||
echo -e "${GREEN}[OK]${NC} Package manager: zypper (openSUSE)"
|
|
||||||
elif command -v apk >/dev/null 2>&1; then
|
|
||||||
PACKAGE_MANAGER="apk"
|
|
||||||
echo -e "${GREEN}[OK]${NC} Package manager: apk (Alpine)"
|
|
||||||
else
|
|
||||||
echo -e "${YELLOW}[WARN]${NC} No recognized package manager found"
|
|
||||||
echo -e "${YELLOW}[INFO]${NC} You may need to install dependencies manually"
|
|
||||||
((WARNINGS++)) || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Package installation helper
|
|
||||||
install_packages() {
|
|
||||||
local packages=("$@")
|
|
||||||
if [[ -z "$PACKAGE_MANAGER" ]]; then
|
|
||||||
echo -e "${YELLOW}[WARN]${NC} Cannot install packages: no package manager"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "${BLUE}[INFO]${NC} Installing: ${packages[*]}"
|
|
||||||
case "$PACKAGE_MANAGER" in
|
|
||||||
apt)
|
|
||||||
$SUDO apt-get update -y >/dev/null 2>&1 || true
|
|
||||||
$SUDO apt-get install -y "${packages[@]}"
|
|
||||||
;;
|
|
||||||
dnf)
|
|
||||||
$SUDO dnf install -y "${packages[@]}"
|
|
||||||
;;
|
|
||||||
yum)
|
|
||||||
$SUDO yum install -y "${packages[@]}"
|
|
||||||
;;
|
|
||||||
pacman)
|
|
||||||
$SUDO pacman -Sy --noconfirm "${packages[@]}"
|
|
||||||
;;
|
|
||||||
zypper)
|
|
||||||
$SUDO zypper -n install "${packages[@]}"
|
|
||||||
;;
|
|
||||||
apk)
|
|
||||||
$SUDO apk add --no-cache "${packages[@]}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
|
||||||
# STEP 4: Install Node.js
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
|
||||||
echo ""
|
|
||||||
echo "[STEP 4/8] Checking Node.js..."
|
|
||||||
|
|
||||||
NODE_OK=0
|
NODE_OK=0
|
||||||
NPM_OK=0
|
NPM_OK=0
|
||||||
|
|
||||||
if command -v node >/dev/null 2>&1; then
|
if command -v node >/dev/null 2>&1; then
|
||||||
NODE_VERSION=$(node --version 2>/dev/null || echo "unknown")
|
NODE_VERSION=$(node --version)
|
||||||
if [[ "$NODE_VERSION" != "unknown" ]]; then
|
echo -e "${GREEN}[OK]${NC} Node.js found: $NODE_VERSION"
|
||||||
NODE_MAJOR=$(echo "$NODE_VERSION" | sed 's/v//' | cut -d'.' -f1)
|
NODE_OK=1
|
||||||
echo -e "${GREEN}[OK]${NC} Node.js: $NODE_VERSION"
|
|
||||||
NODE_OK=1
|
|
||||||
|
|
||||||
if [[ $NODE_MAJOR -lt 18 ]]; then
|
|
||||||
echo -e "${YELLOW}[WARN]${NC} Node.js 18+ recommended (current: $NODE_VERSION)"
|
|
||||||
((WARNINGS++)) || true
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $NODE_OK -eq 0 ]]; then
|
if [[ $NODE_OK -eq 0 ]]; then
|
||||||
echo -e "${BLUE}[INFO]${NC} Node.js not found. Attempting installation..."
|
echo -e "${YELLOW}[INFO]${NC} Node.js not found. Attempting automatic installation..."
|
||||||
log "Node.js not found, installing"
|
|
||||||
|
|
||||||
INSTALL_SUCCESS=0
|
# Check for apt (Debian/Ubuntu)
|
||||||
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
# Try package manager first
|
echo -e "${GREEN}[INFO]${NC} Installing Node.js via apt-get..."
|
||||||
if [[ -n "$PACKAGE_MANAGER" ]]; then
|
sudo apt-get update && sudo apt-get install -y nodejs npm
|
||||||
case "$PACKAGE_MANAGER" in
|
[[ $? -eq 0 ]] && NODE_OK=1
|
||||||
apt)
|
|
||||||
# Try NodeSource for newer versions
|
# Check for dnf (Fedora)
|
||||||
if curl -fsSL https://deb.nodesource.com/setup_20.x 2>/dev/null | $SUDO -E bash - >/dev/null 2>&1; then
|
elif command -v dnf >/dev/null 2>&1; then
|
||||||
$SUDO apt-get install -y nodejs && INSTALL_SUCCESS=1
|
echo -e "${GREEN}[INFO]${NC} Installing Node.js via dnf..."
|
||||||
fi
|
sudo dnf install -y nodejs npm
|
||||||
# Fallback to distro package
|
[[ $? -eq 0 ]] && NODE_OK=1
|
||||||
if [[ $INSTALL_SUCCESS -eq 0 ]]; then
|
|
||||||
install_packages nodejs npm && INSTALL_SUCCESS=1
|
# Check for pacman (Arch)
|
||||||
fi
|
elif command -v pacman >/dev/null 2>&1; then
|
||||||
;;
|
echo -e "${GREEN}[INFO]${NC} Installing Node.js via pacman..."
|
||||||
dnf|yum)
|
sudo pacman -S --noconfirm nodejs npm
|
||||||
if curl -fsSL https://rpm.nodesource.com/setup_20.x 2>/dev/null | $SUDO bash - >/dev/null 2>&1; then
|
[[ $? -eq 0 ]] && NODE_OK=1
|
||||||
$SUDO "$PACKAGE_MANAGER" install -y nodejs && INSTALL_SUCCESS=1
|
|
||||||
fi
|
|
||||||
if [[ $INSTALL_SUCCESS -eq 0 ]]; then
|
|
||||||
install_packages nodejs npm && INSTALL_SUCCESS=1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
pacman)
|
|
||||||
install_packages nodejs npm && INSTALL_SUCCESS=1
|
|
||||||
;;
|
|
||||||
zypper)
|
|
||||||
install_packages nodejs18 npm18 && INSTALL_SUCCESS=1
|
|
||||||
if [[ $INSTALL_SUCCESS -eq 0 ]]; then
|
|
||||||
install_packages nodejs npm && INSTALL_SUCCESS=1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
apk)
|
|
||||||
install_packages nodejs npm && INSTALL_SUCCESS=1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Try nvm as fallback
|
|
||||||
if [[ $INSTALL_SUCCESS -eq 0 ]] && command -v curl >/dev/null 2>&1; then
|
|
||||||
echo -e "${BLUE}[INFO]${NC} Trying nvm installation..."
|
|
||||||
export NVM_DIR="$HOME/.nvm"
|
|
||||||
if curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh 2>/dev/null | bash >/dev/null 2>&1; then
|
|
||||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
||||||
nvm install 20 && INSTALL_SUCCESS=1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $INSTALL_SUCCESS -eq 1 ]]; then
|
|
||||||
# Re-check
|
|
||||||
if command -v node >/dev/null 2>&1; then
|
|
||||||
NODE_VERSION=$(node --version)
|
|
||||||
echo -e "${GREEN}[OK]${NC} Node.js installed: $NODE_VERSION"
|
|
||||||
NODE_OK=1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $NODE_OK -eq 0 ]]; then
|
if [[ $NODE_OK -eq 0 ]]; then
|
||||||
echo -e "${RED}[ERROR]${NC} Could not install Node.js automatically"
|
echo -e "${RED}[ERROR]${NC} Could not install Node.js automatically."
|
||||||
echo ""
|
echo "Please install Node.js manually using your package manager."
|
||||||
echo "Please install Node.js manually:"
|
((ERRORS++))
|
||||||
echo " Ubuntu/Debian: sudo apt install nodejs npm"
|
|
||||||
echo " Fedora: sudo dnf install nodejs npm"
|
|
||||||
echo " Arch: sudo pacman -S nodejs npm"
|
|
||||||
echo " Or visit: https://nodejs.org/"
|
|
||||||
echo ""
|
|
||||||
log "ERROR: Node.js installation failed"
|
|
||||||
ERRORS=$((ERRORS+1))
|
|
||||||
|
|
||||||
# Don't exit - let user see summary
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check npm
|
# ---------------------------------------------------------------
|
||||||
if command -v npm >/dev/null 2>&1; then
|
# STEP 4: Check Git (Optional)
|
||||||
NPM_VERSION=$(npm --version 2>/dev/null || echo "unknown")
|
# ---------------------------------------------------------------
|
||||||
if [[ "$NPM_VERSION" != "unknown" ]]; then
|
|
||||||
echo -e "${GREEN}[OK]${NC} npm: $NPM_VERSION"
|
|
||||||
NPM_OK=1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $NPM_OK -eq 0 && $NODE_OK -eq 1 ]]; then
|
|
||||||
echo -e "${YELLOW}[WARN]${NC} npm not found, trying to install..."
|
|
||||||
install_packages npm || true
|
|
||||||
if command -v npm >/dev/null 2>&1; then
|
|
||||||
NPM_VERSION=$(npm --version)
|
|
||||||
echo -e "${GREEN}[OK]${NC} npm installed: $NPM_VERSION"
|
|
||||||
NPM_OK=1
|
|
||||||
else
|
|
||||||
echo -e "${RED}[ERROR]${NC} npm not available"
|
|
||||||
ERRORS=$((ERRORS+1))
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
|
||||||
# STEP 5: Check Git and curl (optional)
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 5/8] Checking Optional Dependencies..."
|
echo "[STEP 4/8] Checking Git (optional)..."
|
||||||
|
|
||||||
if command -v git >/dev/null 2>&1; then
|
if command -v git >/dev/null 2>&1; then
|
||||||
echo -e "${GREEN}[OK]${NC} Git: $(git --version)"
|
GIT_VERSION=$(git --version)
|
||||||
|
echo -e "${GREEN}[OK]${NC} $GIT_VERSION"
|
||||||
else
|
else
|
||||||
echo -e "${YELLOW}[INFO]${NC} Git not found (optional)"
|
echo -e "${YELLOW}[INFO]${NC} Git not found (optional)"
|
||||||
|
((WARNINGS++))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if command -v curl >/dev/null 2>&1; then
|
# ---------------------------------------------------------------
|
||||||
echo -e "${GREEN}[OK]${NC} curl: available"
|
# STEP 5: Install Dependencies
|
||||||
else
|
# ---------------------------------------------------------------
|
||||||
echo -e "${YELLOW}[INFO]${NC} curl not found (optional, installing...)"
|
|
||||||
install_packages curl || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
|
||||||
# STEP 6: Install npm Dependencies
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 6/8] Installing Dependencies..."
|
echo "[STEP 5/8] Installing Dependencies..."
|
||||||
|
|
||||||
if [[ $NODE_OK -eq 0 || $NPM_OK -eq 0 ]]; then
|
cd "$TARGET_DIR" || exit 1
|
||||||
echo -e "${YELLOW}[SKIP]${NC} Skipping npm install (Node.js/npm not available)"
|
|
||||||
|
if [[ ! -f "package.json" ]]; then
|
||||||
|
echo -e "${RED}[ERROR]${NC} package.json not found"
|
||||||
|
((ERRORS++))
|
||||||
else
|
else
|
||||||
cd "$SCRIPT_DIR"
|
echo -e "${GREEN}[INFO]${NC} Running npm install..."
|
||||||
|
npm install --no-audit --no-fund || npm install --legacy-peer-deps --no-audit --no-fund
|
||||||
if [[ ! -f "package.json" ]]; then
|
if [[ $? -eq 0 ]]; then
|
||||||
echo -e "${RED}[ERROR]${NC} package.json not found in $SCRIPT_DIR"
|
echo -e "${GREEN}[OK]${NC} Dependencies installed"
|
||||||
echo "Make sure you extracted the full NomadArch package."
|
|
||||||
log "ERROR: package.json missing"
|
|
||||||
ERRORS=$((ERRORS+1))
|
|
||||||
else
|
else
|
||||||
echo -e "${BLUE}[INFO]${NC} Running npm install (this may take a few minutes)..."
|
echo -e "${RED}[ERROR]${NC} npm install failed"
|
||||||
log "Running npm install"
|
((ERRORS++))
|
||||||
|
|
||||||
if npm install --no-audit --no-fund 2>&1; then
|
|
||||||
echo -e "${GREEN}[OK]${NC} Dependencies installed"
|
|
||||||
else
|
|
||||||
echo -e "${YELLOW}[WARN]${NC} npm install had issues, trying with legacy peer deps..."
|
|
||||||
if npm install --legacy-peer-deps --no-audit --no-fund 2>&1; then
|
|
||||||
echo -e "${GREEN}[OK]${NC} Dependencies installed (with legacy peer deps)"
|
|
||||||
else
|
|
||||||
echo -e "${RED}[ERROR]${NC} npm install failed"
|
|
||||||
log "ERROR: npm install failed"
|
|
||||||
ERRORS=$((ERRORS+1))
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
# STEP 7: Build UI Assets
|
# STEP 6: OpenCode Setup
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "[STEP 6/8] OpenCode Setup..."
|
||||||
|
echo ""
|
||||||
|
echo -e "${CYAN}==============================================================${NC}"
|
||||||
|
echo -e "${CYAN}|${NC} NomadArch supports Binary-Free Mode! ${CYAN}|${NC}"
|
||||||
|
echo -e "${CYAN}|${NC} Using free cloud models: GPT-5 Nano, Grok Code, etc. ${CYAN}|${NC}"
|
||||||
|
echo -e "${CYAN}==============================================================${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 7/8] Building UI Assets..."
|
|
||||||
|
|
||||||
if [[ $NODE_OK -eq 0 || $NPM_OK -eq 0 ]]; then
|
echo -e "${GREEN}[OK]${NC} Using Binary-Free Mode (default)"
|
||||||
echo -e "${YELLOW}[SKIP]${NC} Skipping UI build (Node.js/npm not available)"
|
|
||||||
elif [[ -f "$SCRIPT_DIR/packages/ui/dist/index.html" ]]; then
|
# ---------------------------------------------------------------
|
||||||
echo -e "${GREEN}[OK]${NC} UI build already exists"
|
# STEP 7: Build Assets
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "[STEP 7/8] Building Assets..."
|
||||||
|
|
||||||
|
if [[ -f "$TARGET_DIR/packages/ui/dist/index.html" ]]; then
|
||||||
|
echo -e "${GREEN}[OK]${NC} UI build exists"
|
||||||
else
|
else
|
||||||
echo -e "${BLUE}[INFO]${NC} Building UI (this may take 1-2 minutes)..."
|
echo -e "${GREEN}[INFO]${NC} Building UI..."
|
||||||
cd "$SCRIPT_DIR/packages/ui"
|
cd "$TARGET_DIR/packages/ui" && npm run build
|
||||||
if npm run build 2>&1; then
|
if [[ $? -eq 0 ]]; then
|
||||||
echo -e "${GREEN}[OK]${NC} UI assets built successfully"
|
echo -e "${GREEN}[OK]${NC} UI assets built"
|
||||||
else
|
else
|
||||||
echo -e "${RED}[ERROR]${NC} UI build failed"
|
echo -e "${RED}[ERROR]${NC} UI build failed"
|
||||||
log "ERROR: UI build failed"
|
((ERRORS++))
|
||||||
ERRORS=$((ERRORS+1))
|
|
||||||
fi
|
fi
|
||||||
cd "$SCRIPT_DIR"
|
cd "$TARGET_DIR" || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
# STEP 8: Health Check and Summary
|
# STEP 8: Health Check
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 8/8] Running Health Check..."
|
echo "[STEP 8/8] Running Health Check..."
|
||||||
|
|
||||||
HEALTH_ERRORS=0
|
HEALTH_OK=1
|
||||||
|
[[ -f "$TARGET_DIR/package.json" ]] || HEALTH_OK=0
|
||||||
|
[[ -d "$TARGET_DIR/packages/ui" ]] || HEALTH_OK=0
|
||||||
|
[[ -d "$TARGET_DIR/packages/server" ]] || HEALTH_OK=0
|
||||||
|
[[ -d "$TARGET_DIR/node_modules" ]] || HEALTH_OK=0
|
||||||
|
|
||||||
[[ -f "$SCRIPT_DIR/package.json" ]] || { echo -e "${RED}[FAIL]${NC} package.json missing"; HEALTH_ERRORS=$((HEALTH_ERRORS+1)); }
|
if [[ $HEALTH_OK -eq 1 ]]; then
|
||||||
[[ -d "$SCRIPT_DIR/packages/ui" ]] || { echo -e "${RED}[FAIL]${NC} packages/ui missing"; HEALTH_ERRORS=$((HEALTH_ERRORS+1)); }
|
echo -e "${GREEN}[OK]${NC} All checks passed"
|
||||||
[[ -d "$SCRIPT_DIR/packages/server" ]] || { echo -e "${RED}[FAIL]${NC} packages/server missing"; HEALTH_ERRORS=$((HEALTH_ERRORS+1)); }
|
|
||||||
|
|
||||||
if [[ $NODE_OK -eq 1 && $NPM_OK -eq 1 ]]; then
|
|
||||||
[[ -d "$SCRIPT_DIR/node_modules" ]] || { echo -e "${RED}[FAIL]${NC} node_modules missing"; HEALTH_ERRORS=$((HEALTH_ERRORS+1)); }
|
|
||||||
[[ -f "$SCRIPT_DIR/packages/ui/dist/index.html" ]] || { echo -e "${YELLOW}[WARN]${NC} UI build missing"; ((WARNINGS++)) || true; }
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $HEALTH_ERRORS -eq 0 ]]; then
|
|
||||||
echo -e "${GREEN}[OK]${NC} Health checks passed"
|
|
||||||
else
|
else
|
||||||
ERRORS=$((ERRORS+HEALTH_ERRORS))
|
echo -e "${RED}[ERROR]${NC} Health checks failed"
|
||||||
|
((ERRORS++))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Summary
|
# ---------------------------------------------------------------
|
||||||
|
# SUMMARY
|
||||||
|
# ---------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${CYAN}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
echo -e "${CYAN}==============================================================${NC}"
|
||||||
echo -e "${CYAN}║${NC} ${BOLD}INSTALLATION SUMMARY${NC} ${CYAN}║${NC}"
|
echo -e "${CYAN}|${NC} INSTALLATION SUMMARY ${CYAN}|${NC}"
|
||||||
echo -e "${CYAN}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
echo -e "${CYAN}==============================================================${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
echo " Install Directory: $TARGET_DIR"
|
echo " Target: $TARGET_DIR"
|
||||||
echo " Architecture: $ARCH ($ARCH_TYPE)"
|
echo " Mode: Binary-Free Mode"
|
||||||
echo " Distribution: $DISTRO_NAME"
|
echo " Errors: $ERRORS"
|
||||||
[[ -n "${NODE_VERSION:-}" ]] && echo " Node.js: $NODE_VERSION"
|
echo " Warnings: $WARNINGS"
|
||||||
[[ -n "${NPM_VERSION:-}" ]] && echo " npm: $NPM_VERSION"
|
|
||||||
echo " Mode: Binary-Free Mode"
|
|
||||||
echo " Errors: $ERRORS"
|
|
||||||
echo " Warnings: $WARNINGS"
|
|
||||||
echo " Log File: $LOG_FILE"
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
if [[ $ERRORS -gt 0 ]]; then
|
if [[ $ERRORS -gt 0 ]]; then
|
||||||
echo -e "${RED}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
echo -e "${RED}INSTALLATION FAILED${NC}"
|
||||||
echo -e "${RED}║${NC} ${BOLD}INSTALLATION COMPLETED WITH ERRORS${NC} ${RED}║${NC}"
|
echo "Check the log file: $LOG_FILE"
|
||||||
echo -e "${RED}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
exit 1
|
||||||
echo ""
|
|
||||||
echo "Review the errors above and check: $LOG_FILE"
|
|
||||||
echo ""
|
|
||||||
echo "Common fixes:"
|
|
||||||
echo " 1. Install Node.js: sudo apt install nodejs npm"
|
|
||||||
echo " 2. Run with sudo if permission issues"
|
|
||||||
echo " 3. Check internet connection"
|
|
||||||
echo ""
|
|
||||||
log "Installation FAILED with $ERRORS errors"
|
|
||||||
else
|
else
|
||||||
echo -e "${GREEN}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
echo -e "${GREEN}INSTALLATION SUCCESSFUL!${NC}"
|
||||||
echo -e "${GREEN}║${NC} ${BOLD}INSTALLATION SUCCESSFUL!${NC} ${GREEN}║${NC}"
|
|
||||||
echo -e "${GREEN}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "To start NomadArch, run:"
|
echo "To start NomadArch, run:"
|
||||||
echo " ./Launch-Unix.sh"
|
echo -e " ${BOLD}./Launch-Linux.sh${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Available Free Models:"
|
exit 0
|
||||||
echo " - GPT-5 Nano (fast)"
|
|
||||||
echo " - Grok Code (coding)"
|
|
||||||
echo " - GLM-4.7 (general)"
|
|
||||||
echo " - Doubao (creative)"
|
|
||||||
echo ""
|
|
||||||
log "Installation SUCCESSFUL"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit $ERRORS
|
|
||||||
|
|||||||
421
Install-Mac.sh
421
Install-Mac.sh
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# NomadArch Installer for macOS
|
# NomadArch Installer for macOS
|
||||||
# Version: 0.6.0 - Robust Edition
|
# Version: 0.6.1 - Universal Edition
|
||||||
|
|
||||||
# Exit on undefined variables
|
# Exit on undefined variables
|
||||||
set -u
|
set -u
|
||||||
@@ -31,19 +31,19 @@ log() {
|
|||||||
|
|
||||||
print_header() {
|
print_header() {
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${CYAN}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
echo -e "${CYAN}==============================================================${NC}"
|
||||||
echo -e "${CYAN}║${NC} ${BOLD}NomadArch Installer for macOS${NC} ${CYAN}║${NC}"
|
echo -e "${CYAN}|${NC} ${BOLD}NomadArch Installer for macOS${NC} ${CYAN}|${NC}"
|
||||||
echo -e "${CYAN}║${NC} Version: 0.6.0 - Robust Edition ${CYAN}║${NC}"
|
echo -e "${CYAN}|${NC} Version: 0.6.1 - Universal Edition ${CYAN}|${NC}"
|
||||||
echo -e "${CYAN}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
echo -e "${CYAN}==============================================================${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
print_header
|
print_header
|
||||||
log "========== Installer started =========="
|
log "========== Installer started =========="
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
# STEP 1: OS and Architecture Detection
|
# STEP 1: OS and Architecture Detection
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
echo "[STEP 1/8] Detecting System..."
|
echo "[STEP 1/8] Detecting System..."
|
||||||
|
|
||||||
OS_TYPE=$(uname -s)
|
OS_TYPE=$(uname -s)
|
||||||
@@ -58,8 +58,8 @@ if [[ "$OS_TYPE" != "Darwin" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
case "$ARCH_TYPE" in
|
case "$ARCH_TYPE" in
|
||||||
arm64) ARCH="arm64" ;;
|
x86_64) ARCH="x64" ;;
|
||||||
x86_64) ARCH="x64" ;;
|
arm64) ARCH="arm64" ;;
|
||||||
*)
|
*)
|
||||||
echo -e "${YELLOW}[WARN]${NC} Unusual architecture: $ARCH_TYPE (proceeding anyway)"
|
echo -e "${YELLOW}[WARN]${NC} Unusual architecture: $ARCH_TYPE (proceeding anyway)"
|
||||||
ARCH="$ARCH_TYPE"
|
ARCH="$ARCH_TYPE"
|
||||||
@@ -67,16 +67,12 @@ case "$ARCH_TYPE" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Get macOS version
|
echo -e "${GREEN}[OK]${NC} OS: macOS ($OS_TYPE)"
|
||||||
MACOS_VERSION=$(sw_vers -productVersion 2>/dev/null || echo "unknown")
|
|
||||||
|
|
||||||
echo -e "${GREEN}[OK]${NC} OS: macOS $MACOS_VERSION"
|
|
||||||
echo -e "${GREEN}[OK]${NC} Architecture: $ARCH_TYPE ($ARCH)"
|
echo -e "${GREEN}[OK]${NC} Architecture: $ARCH_TYPE ($ARCH)"
|
||||||
log "macOS $MACOS_VERSION, Arch: $ARCH_TYPE"
|
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
# STEP 2: Check Write Permissions
|
# STEP 2: Check Write Permissions
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 2/8] Checking Write Permissions..."
|
echo "[STEP 2/8] Checking Write Permissions..."
|
||||||
|
|
||||||
@@ -88,326 +84,213 @@ if ! touch "$SCRIPT_DIR/.install-write-test" 2>/dev/null; then
|
|||||||
BIN_DIR="$TARGET_DIR/bin"
|
BIN_DIR="$TARGET_DIR/bin"
|
||||||
LOG_FILE="$TARGET_DIR/install.log"
|
LOG_FILE="$TARGET_DIR/install.log"
|
||||||
mkdir -p "$BIN_DIR"
|
mkdir -p "$BIN_DIR"
|
||||||
if ! touch "$TARGET_DIR/.install-write-test" 2>/dev/null; then
|
cp -R "$SCRIPT_DIR/"* "$TARGET_DIR/" 2>/dev/null || true
|
||||||
echo -e "${RED}[ERROR]${NC} Cannot write to $TARGET_DIR"
|
echo -e "${GREEN}[INFO]${NC} Using fallback location: $TARGET_DIR"
|
||||||
log "ERROR: Write permission denied"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
rm -f "$TARGET_DIR/.install-write-test"
|
|
||||||
echo -e "${GREEN}[OK]${NC} Using fallback: $TARGET_DIR"
|
|
||||||
else
|
else
|
||||||
rm -f "$SCRIPT_DIR/.install-write-test"
|
rm "$SCRIPT_DIR/.install-write-test" 2>/dev/null
|
||||||
echo -e "${GREEN}[OK]${NC} Write access verified"
|
echo -e "${GREEN}[OK]${NC} Write permissions verified"
|
||||||
fi
|
fi
|
||||||
log "Install target: $TARGET_DIR"
|
log "Install target: $TARGET_DIR"
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
# STEP 3: Check Xcode Command Line Tools
|
# STEP 3: Check and Install Node.js
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 3/8] Checking Xcode Command Line Tools..."
|
echo "[STEP 3/8] Checking Node.js..."
|
||||||
|
|
||||||
if xcode-select -p >/dev/null 2>&1; then
|
|
||||||
echo -e "${GREEN}[OK]${NC} Xcode Command Line Tools installed"
|
|
||||||
else
|
|
||||||
echo -e "${BLUE}[INFO]${NC} Installing Xcode Command Line Tools..."
|
|
||||||
echo -e "${YELLOW}[NOTE]${NC} A dialog may appear - click 'Install' to proceed"
|
|
||||||
xcode-select --install 2>/dev/null || true
|
|
||||||
|
|
||||||
# Wait for installation
|
|
||||||
echo -e "${BLUE}[INFO]${NC} Waiting for Xcode tools installation..."
|
|
||||||
while ! xcode-select -p >/dev/null 2>&1; do
|
|
||||||
sleep 5
|
|
||||||
done
|
|
||||||
echo -e "${GREEN}[OK]${NC} Xcode Command Line Tools installed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
|
||||||
# STEP 4: Check and Install Homebrew + Node.js
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
|
||||||
echo ""
|
|
||||||
echo "[STEP 4/8] Checking Homebrew and Node.js..."
|
|
||||||
|
|
||||||
BREW_OK=0
|
|
||||||
NODE_OK=0
|
NODE_OK=0
|
||||||
NPM_OK=0
|
NPM_OK=0
|
||||||
|
|
||||||
# Check Homebrew
|
if command -v node >/dev/null 2>&1; then
|
||||||
if command -v brew >/dev/null 2>&1; then
|
NODE_VERSION=$(node --version)
|
||||||
echo -e "${GREEN}[OK]${NC} Homebrew: $(brew --version | head -1)"
|
echo -e "${GREEN}[OK]${NC} Node.js found: $NODE_VERSION"
|
||||||
BREW_OK=1
|
NODE_OK=1
|
||||||
else
|
fi
|
||||||
echo -e "${BLUE}[INFO]${NC} Homebrew not found. Installing..."
|
|
||||||
log "Installing Homebrew"
|
if [[ $NODE_OK -eq 0 ]]; then
|
||||||
|
echo -e "${YELLOW}[INFO]${NC} Node.js not found. Attempting automatic installation..."
|
||||||
|
log "Node.js not found, attempting install"
|
||||||
|
|
||||||
if /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; then
|
# Check for Homebrew
|
||||||
# Add Homebrew to PATH for Apple Silicon
|
if command -v brew >/dev/null 2>&1; then
|
||||||
if [[ "$ARCH_TYPE" == "arm64" ]]; then
|
echo -e "${GREEN}[INFO]${NC} Installing Node.js via Homebrew..."
|
||||||
eval "$(/opt/homebrew/bin/brew shellenv)" 2>/dev/null || true
|
brew install node
|
||||||
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile 2>/dev/null || true
|
if [[ $? -eq 0 ]]; then
|
||||||
fi
|
echo -e "${GREEN}[OK]${NC} Node.js installed via Homebrew"
|
||||||
|
NODE_OK=1
|
||||||
# Verify
|
|
||||||
if command -v brew >/dev/null 2>&1; then
|
|
||||||
echo -e "${GREEN}[OK]${NC} Homebrew installed successfully"
|
|
||||||
BREW_OK=1
|
|
||||||
else
|
else
|
||||||
echo -e "${YELLOW}[WARN]${NC} Homebrew installed but not in PATH"
|
echo -e "${RED}[ERROR]${NC} Homebrew install failed"
|
||||||
echo -e "${YELLOW}[INFO]${NC} You may need to restart your terminal"
|
|
||||||
((WARNINGS++)) || true
|
|
||||||
|
|
||||||
# Try to find it
|
|
||||||
if [[ -f "/opt/homebrew/bin/brew" ]]; then
|
|
||||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
|
||||||
BREW_OK=1
|
|
||||||
elif [[ -f "/usr/local/bin/brew" ]]; then
|
|
||||||
eval "$(/usr/local/bin/brew shellenv)"
|
|
||||||
BREW_OK=1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo -e "${RED}[ERROR]${NC} Failed to install Homebrew"
|
echo -e "${YELLOW}[WARN]${NC} Homebrew not found. Trying direct download..."
|
||||||
log "ERROR: Homebrew installation failed"
|
|
||||||
((WARNINGS++)) || true
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check Node.js
|
|
||||||
if command -v node >/dev/null 2>&1; then
|
|
||||||
NODE_VERSION=$(node --version 2>/dev/null || echo "unknown")
|
|
||||||
if [[ "$NODE_VERSION" != "unknown" ]]; then
|
|
||||||
NODE_MAJOR=$(echo "$NODE_VERSION" | sed 's/v//' | cut -d'.' -f1)
|
|
||||||
echo -e "${GREEN}[OK]${NC} Node.js: $NODE_VERSION"
|
|
||||||
NODE_OK=1
|
|
||||||
|
|
||||||
if [[ $NODE_MAJOR -lt 18 ]]; then
|
# Download macOS installer
|
||||||
echo -e "${YELLOW}[WARN]${NC} Node.js 18+ recommended (current: $NODE_VERSION)"
|
DOWNLOAD_URL="https://nodejs.org/dist/v20.10.0/node-v20.10.0.pkg"
|
||||||
((WARNINGS++)) || true
|
PKG_FILE="$TARGET_DIR/node-installer.pkg"
|
||||||
fi
|
|
||||||
fi
|
echo -e "${GREEN}[INFO]${NC} Downloading Node.js installer..."
|
||||||
fi
|
curl -L "$DOWNLOAD_URL" -o "$PKG_FILE"
|
||||||
|
|
||||||
# Install Node.js if needed
|
if [[ -f "$PKG_FILE" ]]; then
|
||||||
if [[ $NODE_OK -eq 0 ]]; then
|
echo -e "${GREEN}[INFO]${NC} Running installer (requires password)..."
|
||||||
echo -e "${BLUE}[INFO]${NC} Node.js not found. Installing..."
|
if sudo installer -pkg "$PKG_FILE" -target /; then
|
||||||
log "Installing Node.js"
|
echo -e "${GREEN}[OK]${NC} Node.js installed successfully"
|
||||||
|
NODE_OK=1
|
||||||
INSTALL_SUCCESS=0
|
else
|
||||||
|
echo -e "${RED}[ERROR]${NC} Node.js installation failed"
|
||||||
# Try Homebrew first
|
|
||||||
if [[ $BREW_OK -eq 1 ]]; then
|
|
||||||
if brew install node 2>&1; then
|
|
||||||
INSTALL_SUCCESS=1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Try nvm as fallback
|
|
||||||
if [[ $INSTALL_SUCCESS -eq 0 ]]; then
|
|
||||||
echo -e "${BLUE}[INFO]${NC} Trying nvm installation..."
|
|
||||||
export NVM_DIR="$HOME/.nvm"
|
|
||||||
if curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh 2>/dev/null | bash >/dev/null 2>&1; then
|
|
||||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
||||||
if nvm install 20 2>&1; then
|
|
||||||
INSTALL_SUCCESS=1
|
|
||||||
fi
|
fi
|
||||||
fi
|
rm "$PKG_FILE"
|
||||||
fi
|
else
|
||||||
|
echo -e "${RED}[ERROR]${NC} Failed to download Node.js installer"
|
||||||
# Try official pkg installer as last resort
|
|
||||||
if [[ $INSTALL_SUCCESS -eq 0 ]]; then
|
|
||||||
echo -e "${BLUE}[INFO]${NC} Downloading Node.js installer..."
|
|
||||||
NODE_PKG="/tmp/node-installer.pkg"
|
|
||||||
if curl -fsSL "https://nodejs.org/dist/v20.10.0/node-v20.10.0.pkg" -o "$NODE_PKG" 2>/dev/null; then
|
|
||||||
echo -e "${BLUE}[INFO]${NC} Running Node.js installer (may require password)..."
|
|
||||||
sudo installer -pkg "$NODE_PKG" -target / && INSTALL_SUCCESS=1
|
|
||||||
rm -f "$NODE_PKG"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $INSTALL_SUCCESS -eq 1 ]]; then
|
|
||||||
# Verify installation
|
|
||||||
hash -r 2>/dev/null || true
|
|
||||||
if command -v node >/dev/null 2>&1; then
|
|
||||||
NODE_VERSION=$(node --version)
|
|
||||||
echo -e "${GREEN}[OK]${NC} Node.js installed: $NODE_VERSION"
|
|
||||||
NODE_OK=1
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $NODE_OK -eq 0 ]]; then
|
if [[ $NODE_OK -eq 0 ]]; then
|
||||||
echo -e "${RED}[ERROR]${NC} Could not install Node.js automatically"
|
echo -e "${RED}[ERROR]${NC} Could not install Node.js automatically."
|
||||||
echo ""
|
echo "Please install Node.js manually from https://nodejs.org/"
|
||||||
echo "Please install Node.js manually:"
|
echo "and run this installer again."
|
||||||
echo " 1. Install via Homebrew: brew install node"
|
|
||||||
echo " 2. Or download from: https://nodejs.org/"
|
|
||||||
echo ""
|
|
||||||
log "ERROR: Node.js installation failed"
|
log "ERROR: Node.js installation failed"
|
||||||
ERRORS=$((ERRORS+1))
|
((ERRORS++))
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check npm
|
# Check npm
|
||||||
if command -v npm >/dev/null 2>&1; then
|
if command -v npm >/dev/null 2>&1; then
|
||||||
NPM_VERSION=$(npm --version 2>/dev/null || echo "unknown")
|
NPM_VERSION=$(npm --version)
|
||||||
if [[ "$NPM_VERSION" != "unknown" ]]; then
|
echo -e "${GREEN}[OK]${NC} npm found: $NPM_VERSION"
|
||||||
echo -e "${GREEN}[OK]${NC} npm: $NPM_VERSION"
|
NPM_OK=1
|
||||||
NPM_OK=1
|
else
|
||||||
fi
|
echo -e "${RED}[ERROR]${NC} npm not found (check Node.js installation)"
|
||||||
|
((ERRORS++))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $NPM_OK -eq 0 && $NODE_OK -eq 1 ]]; then
|
# ---------------------------------------------------------------
|
||||||
echo -e "${RED}[ERROR]${NC} npm not found (should come with Node.js)"
|
# STEP 4: Check Git (Optional)
|
||||||
ERRORS=$((ERRORS+1))
|
# ---------------------------------------------------------------
|
||||||
fi
|
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
|
||||||
# STEP 5: Check Git (optional)
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 5/8] Checking Optional Dependencies..."
|
echo "[STEP 4/8] Checking Git (optional)..."
|
||||||
|
|
||||||
if command -v git >/dev/null 2>&1; then
|
if command -v git >/dev/null 2>&1; then
|
||||||
echo -e "${GREEN}[OK]${NC} Git: $(git --version)"
|
GIT_VERSION=$(git --version)
|
||||||
|
echo -e "${GREEN}[OK]${NC} $GIT_VERSION"
|
||||||
else
|
else
|
||||||
echo -e "${YELLOW}[INFO]${NC} Git not found (optional - installing via Homebrew)"
|
echo -e "${YELLOW}[INFO]${NC} Git not found (optional)"
|
||||||
if [[ $BREW_OK -eq 1 ]]; then
|
((WARNINGS++))
|
||||||
brew install git 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if command -v curl >/dev/null 2>&1; then
|
# ---------------------------------------------------------------
|
||||||
echo -e "${GREEN}[OK]${NC} curl: available"
|
# STEP 5: Install Dependencies
|
||||||
else
|
# ---------------------------------------------------------------
|
||||||
echo -e "${RED}[ERROR]${NC} curl not found (required)"
|
|
||||||
ERRORS=$((ERRORS+1))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
|
||||||
# STEP 6: Install npm Dependencies
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 6/8] Installing Dependencies..."
|
echo "[STEP 5/8] Installing Dependencies..."
|
||||||
|
|
||||||
if [[ $NODE_OK -eq 0 || $NPM_OK -eq 0 ]]; then
|
cd "$TARGET_DIR" || exit 1
|
||||||
echo -e "${YELLOW}[SKIP]${NC} Skipping npm install (Node.js/npm not available)"
|
|
||||||
|
if [[ ! -f "package.json" ]]; then
|
||||||
|
echo -e "${RED}[ERROR]${NC} package.json not found in $TARGET_DIR"
|
||||||
|
log "ERROR: package.json missing"
|
||||||
|
((ERRORS++))
|
||||||
else
|
else
|
||||||
cd "$SCRIPT_DIR"
|
echo -e "${GREEN}[INFO]${NC} Running npm install..."
|
||||||
|
log "Running npm install"
|
||||||
|
|
||||||
if [[ ! -f "package.json" ]]; then
|
if npm install --no-audit --no-fund; then
|
||||||
echo -e "${RED}[ERROR]${NC} package.json not found in $SCRIPT_DIR"
|
echo -e "${GREEN}[OK]${NC} Dependencies installed"
|
||||||
echo "Make sure you extracted the full NomadArch package."
|
|
||||||
log "ERROR: package.json missing"
|
|
||||||
ERRORS=$((ERRORS+1))
|
|
||||||
else
|
else
|
||||||
echo -e "${BLUE}[INFO]${NC} Running npm install (this may take a few minutes)..."
|
echo -e "${YELLOW}[WARN]${NC} npm install issues, trying legacy peer deps..."
|
||||||
log "Running npm install"
|
if npm install --legacy-peer-deps --no-audit --no-fund; then
|
||||||
|
echo -e "${GREEN}[OK]${NC} Dependencies installed (legacy mode)"
|
||||||
if npm install --no-audit --no-fund 2>&1; then
|
|
||||||
echo -e "${GREEN}[OK]${NC} Dependencies installed"
|
|
||||||
else
|
else
|
||||||
echo -e "${YELLOW}[WARN]${NC} npm install had issues, trying with legacy peer deps..."
|
echo -e "${RED}[ERROR]${NC} npm install failed"
|
||||||
if npm install --legacy-peer-deps --no-audit --no-fund 2>&1; then
|
log "ERROR: npm install failed"
|
||||||
echo -e "${GREEN}[OK]${NC} Dependencies installed (with legacy peer deps)"
|
((ERRORS++))
|
||||||
else
|
|
||||||
echo -e "${RED}[ERROR]${NC} npm install failed"
|
|
||||||
log "ERROR: npm install failed"
|
|
||||||
ERRORS=$((ERRORS+1))
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
# STEP 7: Build UI Assets
|
# STEP 6: OpenCode Setup
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "[STEP 6/8] OpenCode Setup..."
|
||||||
|
echo ""
|
||||||
|
echo -e "${CYAN}==============================================================${NC}"
|
||||||
|
echo -e "${CYAN}|${NC} NomadArch supports Binary-Free Mode! ${CYAN}|${NC}"
|
||||||
|
echo -e "${CYAN}|${NC} Using free cloud models: GPT-5 Nano, Grok Code, etc. ${CYAN}|${NC}"
|
||||||
|
echo -e "${CYAN}==============================================================${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 7/8] Building UI Assets..."
|
|
||||||
|
|
||||||
if [[ $NODE_OK -eq 0 || $NPM_OK -eq 0 ]]; then
|
echo -e "${GREEN}[OK]${NC} Using Binary-Free Mode (default)"
|
||||||
echo -e "${YELLOW}[SKIP]${NC} Skipping UI build (Node.js/npm not available)"
|
log "Using Binary-Free Mode"
|
||||||
elif [[ -f "$SCRIPT_DIR/packages/ui/dist/index.html" ]]; then
|
|
||||||
echo -e "${GREEN}[OK]${NC} UI build already exists"
|
# ---------------------------------------------------------------
|
||||||
|
# STEP 7: Build Assets
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
echo ""
|
||||||
|
echo "[STEP 7/8] Building Assets..."
|
||||||
|
|
||||||
|
if [[ -f "$TARGET_DIR/packages/ui/dist/index.html" ]]; then
|
||||||
|
echo -e "${GREEN}[OK]${NC} UI build exists"
|
||||||
else
|
else
|
||||||
echo -e "${BLUE}[INFO]${NC} Building UI (this may take 1-2 minutes)..."
|
echo -e "${GREEN}[INFO]${NC} Building UI..."
|
||||||
cd "$SCRIPT_DIR/packages/ui"
|
cd "$TARGET_DIR/packages/ui" || exit 1
|
||||||
if npm run build 2>&1; then
|
if npm run build; then
|
||||||
echo -e "${GREEN}[OK]${NC} UI assets built successfully"
|
echo -e "${GREEN}[OK]${NC} UI assets built"
|
||||||
else
|
else
|
||||||
echo -e "${RED}[ERROR]${NC} UI build failed"
|
echo -e "${RED}[ERROR]${NC} UI build failed"
|
||||||
log "ERROR: UI build failed"
|
log "ERROR: UI build failed"
|
||||||
ERRORS=$((ERRORS+1))
|
((ERRORS++))
|
||||||
fi
|
fi
|
||||||
cd "$SCRIPT_DIR"
|
cd "$TARGET_DIR" || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
# STEP 8: Health Check and Summary
|
# STEP 8: Health Check
|
||||||
# ═══════════════════════════════════════════════════════════════
|
# ---------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo "[STEP 8/8] Running Health Check..."
|
echo "[STEP 8/8] Running Health Check..."
|
||||||
|
|
||||||
HEALTH_ERRORS=0
|
HEALTH_OK=1
|
||||||
|
|
||||||
[[ -f "$SCRIPT_DIR/package.json" ]] || { echo -e "${RED}[FAIL]${NC} package.json missing"; HEALTH_ERRORS=$((HEALTH_ERRORS+1)); }
|
[[ -f "$TARGET_DIR/package.json" ]] || HEALTH_OK=0
|
||||||
[[ -d "$SCRIPT_DIR/packages/ui" ]] || { echo -e "${RED}[FAIL]${NC} packages/ui missing"; HEALTH_ERRORS=$((HEALTH_ERRORS+1)); }
|
[[ -d "$TARGET_DIR/packages/ui" ]] || HEALTH_OK=0
|
||||||
[[ -d "$SCRIPT_DIR/packages/server" ]] || { echo -e "${RED}[FAIL]${NC} packages/server missing"; HEALTH_ERRORS=$((HEALTH_ERRORS+1)); }
|
[[ -d "$TARGET_DIR/packages/server" ]] || HEALTH_OK=0
|
||||||
|
[[ -d "$TARGET_DIR/node_modules" ]] || HEALTH_OK=0
|
||||||
|
|
||||||
if [[ $NODE_OK -eq 1 && $NPM_OK -eq 1 ]]; then
|
if [[ $HEALTH_OK -eq 1 ]]; then
|
||||||
[[ -d "$SCRIPT_DIR/node_modules" ]] || { echo -e "${RED}[FAIL]${NC} node_modules missing"; HEALTH_ERRORS=$((HEALTH_ERRORS+1)); }
|
echo -e "${GREEN}[OK]${NC} All checks passed"
|
||||||
[[ -f "$SCRIPT_DIR/packages/ui/dist/index.html" ]] || { echo -e "${YELLOW}[WARN]${NC} UI build missing"; ((WARNINGS++)) || true; }
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $HEALTH_ERRORS -eq 0 ]]; then
|
|
||||||
echo -e "${GREEN}[OK]${NC} Health checks passed"
|
|
||||||
else
|
else
|
||||||
ERRORS=$((ERRORS+HEALTH_ERRORS))
|
echo -e "${RED}[ERROR]${NC} Health checks failed"
|
||||||
|
((ERRORS++))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Summary
|
# ---------------------------------------------------------------
|
||||||
|
# SUMMARY
|
||||||
|
# ---------------------------------------------------------------
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${CYAN}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
echo -e "${CYAN}==============================================================${NC}"
|
||||||
echo -e "${CYAN}║${NC} ${BOLD}INSTALLATION SUMMARY${NC} ${CYAN}║${NC}"
|
echo -e "${CYAN}|${NC} INSTALLATION SUMMARY ${CYAN}|${NC}"
|
||||||
echo -e "${CYAN}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
echo -e "${CYAN}==============================================================${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
echo " Install Directory: $TARGET_DIR"
|
echo " Target: $TARGET_DIR"
|
||||||
echo " Architecture: $ARCH ($ARCH_TYPE)"
|
echo " Mode: Binary-Free Mode"
|
||||||
echo " macOS Version: $MACOS_VERSION"
|
echo " Errors: $ERRORS"
|
||||||
[[ -n "${NODE_VERSION:-}" ]] && echo " Node.js: $NODE_VERSION"
|
echo " Warnings: $WARNINGS"
|
||||||
[[ -n "${NPM_VERSION:-}" ]] && echo " npm: $NPM_VERSION"
|
|
||||||
echo " Mode: Binary-Free Mode"
|
|
||||||
echo " Errors: $ERRORS"
|
|
||||||
echo " Warnings: $WARNINGS"
|
|
||||||
echo " Log File: $LOG_FILE"
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
if [[ $ERRORS -gt 0 ]]; then
|
if [[ $ERRORS -gt 0 ]]; then
|
||||||
echo -e "${RED}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
echo -e "${RED}==============================================================${NC}"
|
||||||
echo -e "${RED}║${NC} ${BOLD}INSTALLATION COMPLETED WITH ERRORS${NC} ${RED}║${NC}"
|
echo -e "${RED} INSTALLATION FAILED${NC}"
|
||||||
echo -e "${RED}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
echo -e "${RED}==============================================================${NC}"
|
||||||
echo ""
|
echo "Check the log file: $LOG_FILE"
|
||||||
echo "Review the errors above and check: $LOG_FILE"
|
exit 1
|
||||||
echo ""
|
|
||||||
echo "Common fixes:"
|
|
||||||
echo " 1. Install Homebrew: /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
|
|
||||||
echo " 2. Install Node.js: brew install node"
|
|
||||||
echo " 3. Restart terminal after Homebrew installation"
|
|
||||||
echo ""
|
|
||||||
log "Installation FAILED with $ERRORS errors"
|
|
||||||
else
|
else
|
||||||
echo -e "${GREEN}╔═══════════════════════════════════════════════════════════════╗${NC}"
|
echo -e "${GREEN}==============================================================${NC}"
|
||||||
echo -e "${GREEN}║${NC} ${BOLD}INSTALLATION SUCCESSFUL!${NC} ${GREEN}║${NC}"
|
echo -e "${GREEN} INSTALLATION SUCCESSFUL!${NC}"
|
||||||
echo -e "${GREEN}╚═══════════════════════════════════════════════════════════════╝${NC}"
|
echo -e "${GREEN}==============================================================${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
echo "To start NomadArch, run:"
|
echo "To start NomadArch, run:"
|
||||||
echo " ./Launch-Unix.sh"
|
echo -e " ${BOLD}./Launch-Mac.sh${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Available Free Models:"
|
exit 0
|
||||||
echo " - GPT-5 Nano (fast)"
|
|
||||||
echo " - Grok Code (coding)"
|
|
||||||
echo " - GLM-4.7 (general)"
|
|
||||||
echo " - Doubao (creative)"
|
|
||||||
echo ""
|
|
||||||
log "Installation SUCCESSFUL"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit $ERRORS
|
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
@echo off
|
@echo off
|
||||||
chcp 65001 >nul 2>&1
|
REM NomadArch Windows Installer - ASCII Safe Version
|
||||||
|
REM This installer uses only ASCII characters for maximum compatibility
|
||||||
|
|
||||||
setlocal enabledelayedexpansion
|
setlocal enabledelayedexpansion
|
||||||
|
|
||||||
title NomadArch Installer - Windows
|
title NomadArch Installer - Windows
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ╔═══════════════════════════════════════════════════════════════╗
|
echo ===============================================================
|
||||||
echo ║ NomadArch Installer for Windows ║
|
echo NomadArch Installer for Windows
|
||||||
echo ║ Version: 0.6.0 - Robust Edition ║
|
echo Version: 0.6.1 - Universal Edition
|
||||||
echo ╚═══════════════════════════════════════════════════════════════╝
|
echo ===============================================================
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
set SCRIPT_DIR=%~dp0
|
set SCRIPT_DIR=%~dp0
|
||||||
@@ -25,9 +27,9 @@ set NODE_INSTALLED_NOW=0
|
|||||||
|
|
||||||
echo [%date% %time%] ========== Installer started ========== >> "%LOG_FILE%"
|
echo [%date% %time%] ========== Installer started ========== >> "%LOG_FILE%"
|
||||||
|
|
||||||
REM ═══════════════════════════════════════════════════════════════
|
REM ---------------------------------------------------------------
|
||||||
REM STEP 1: OS and Architecture Detection
|
REM STEP 1: OS and Architecture Detection
|
||||||
REM ═══════════════════════════════════════════════════════════════
|
REM ---------------------------------------------------------------
|
||||||
echo [STEP 1/8] Detecting System...
|
echo [STEP 1/8] Detecting System...
|
||||||
|
|
||||||
for /f "tokens=2 delims==" %%a in ('wmic os get osarchitecture /value 2^>nul ^| find "="') do set ARCH_RAW=%%a
|
for /f "tokens=2 delims==" %%a in ('wmic os get osarchitecture /value 2^>nul ^| find "="') do set ARCH_RAW=%%a
|
||||||
@@ -45,9 +47,9 @@ echo [OK] Windows Version: !WIN_VER!
|
|||||||
echo [OK] Architecture: !ARCH!
|
echo [OK] Architecture: !ARCH!
|
||||||
echo [%date% %time%] OS: Windows !WIN_VER!, Arch: !ARCH! >> "%LOG_FILE%"
|
echo [%date% %time%] OS: Windows !WIN_VER!, Arch: !ARCH! >> "%LOG_FILE%"
|
||||||
|
|
||||||
REM ═══════════════════════════════════════════════════════════════
|
REM ---------------------------------------------------------------
|
||||||
REM STEP 2: Check Write Permissions
|
REM STEP 2: Check Write Permissions
|
||||||
REM ═══════════════════════════════════════════════════════════════
|
REM ---------------------------------------------------------------
|
||||||
echo.
|
echo.
|
||||||
echo [STEP 2/8] Checking Write Permissions...
|
echo [STEP 2/8] Checking Write Permissions...
|
||||||
|
|
||||||
@@ -72,9 +74,9 @@ if !ERRORLEVEL! neq 0 (
|
|||||||
)
|
)
|
||||||
echo [%date% %time%] Install target: %TARGET_DIR% >> "%LOG_FILE%"
|
echo [%date% %time%] Install target: %TARGET_DIR% >> "%LOG_FILE%"
|
||||||
|
|
||||||
REM ═══════════════════════════════════════════════════════════════
|
REM ---------------------------------------------------------------
|
||||||
REM STEP 3: Check and Install Node.js
|
REM STEP 3: Check and Install Node.js
|
||||||
REM ═══════════════════════════════════════════════════════════════
|
REM ---------------------------------------------------------------
|
||||||
echo.
|
echo.
|
||||||
echo [STEP 3/8] Checking Node.js...
|
echo [STEP 3/8] Checking Node.js...
|
||||||
|
|
||||||
@@ -98,7 +100,7 @@ if !NODE_OK! equ 0 (
|
|||||||
where winget >nul 2>&1
|
where winget >nul 2>&1
|
||||||
if !ERRORLEVEL! equ 0 (
|
if !ERRORLEVEL! equ 0 (
|
||||||
echo [INFO] Installing Node.js via winget...
|
echo [INFO] Installing Node.js via winget...
|
||||||
winget install -e --id OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements --silent
|
winget install -e --id OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements --silent 2>nul
|
||||||
if !ERRORLEVEL! equ 0 (
|
if !ERRORLEVEL! equ 0 (
|
||||||
set NODE_INSTALLED_NOW=1
|
set NODE_INSTALLED_NOW=1
|
||||||
echo [OK] Node.js installed via winget
|
echo [OK] Node.js installed via winget
|
||||||
@@ -112,7 +114,7 @@ if !NODE_OK! equ 0 (
|
|||||||
where choco >nul 2>&1
|
where choco >nul 2>&1
|
||||||
if !ERRORLEVEL! equ 0 (
|
if !ERRORLEVEL! equ 0 (
|
||||||
echo [INFO] Installing Node.js via Chocolatey...
|
echo [INFO] Installing Node.js via Chocolatey...
|
||||||
choco install nodejs-lts -y
|
choco install nodejs-lts -y 2>nul
|
||||||
if !ERRORLEVEL! equ 0 (
|
if !ERRORLEVEL! equ 0 (
|
||||||
set NODE_INSTALLED_NOW=1
|
set NODE_INSTALLED_NOW=1
|
||||||
echo [OK] Node.js installed via Chocolatey
|
echo [OK] Node.js installed via Chocolatey
|
||||||
@@ -125,17 +127,12 @@ if !NODE_OK! equ 0 (
|
|||||||
echo [INFO] Downloading Node.js installer directly...
|
echo [INFO] Downloading Node.js installer directly...
|
||||||
set NODE_INSTALLER=%TEMP_DIR%\node-installer.msi
|
set NODE_INSTALLER=%TEMP_DIR%\node-installer.msi
|
||||||
|
|
||||||
REM Download using PowerShell
|
REM Download using PowerShell with proper error handling
|
||||||
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
|
powershell -NoProfile -ExecutionPolicy Bypass -Command "$ProgressPreference = 'SilentlyContinue'; try { Invoke-WebRequest -Uri 'https://nodejs.org/dist/v20.10.0/node-v20.10.0-x64.msi' -OutFile '%TEMP_DIR%\node-installer.msi' -UseBasicParsing; exit 0 } catch { exit 1 }" 2>nul
|
||||||
"$ProgressPreference = 'SilentlyContinue'; " ^
|
|
||||||
"try { " ^
|
|
||||||
" Invoke-WebRequest -Uri 'https://nodejs.org/dist/v20.10.0/node-v20.10.0-x64.msi' -OutFile '%TEMP_DIR%\node-installer.msi' -UseBasicParsing; " ^
|
|
||||||
" exit 0 " ^
|
|
||||||
"} catch { exit 1 }"
|
|
||||||
|
|
||||||
if exist "%TEMP_DIR%\node-installer.msi" (
|
if exist "%TEMP_DIR%\node-installer.msi" (
|
||||||
echo [INFO] Running Node.js installer...
|
echo [INFO] Running Node.js installer...
|
||||||
msiexec /i "%TEMP_DIR%\node-installer.msi" /qn /norestart
|
msiexec /i "%TEMP_DIR%\node-installer.msi" /qn /norestart 2>nul
|
||||||
if !ERRORLEVEL! equ 0 (
|
if !ERRORLEVEL! equ 0 (
|
||||||
set NODE_INSTALLED_NOW=1
|
set NODE_INSTALLED_NOW=1
|
||||||
echo [OK] Node.js installed successfully
|
echo [OK] Node.js installed successfully
|
||||||
@@ -150,11 +147,11 @@ if !NODE_OK! equ 0 (
|
|||||||
|
|
||||||
if !NODE_INSTALLED_NOW! equ 1 (
|
if !NODE_INSTALLED_NOW! equ 1 (
|
||||||
echo.
|
echo.
|
||||||
echo ╔═══════════════════════════════════════════════════════════════╗
|
echo ===============================================================
|
||||||
echo ║ IMPORTANT: Node.js was just installed! ║
|
echo IMPORTANT: Node.js was just installed!
|
||||||
echo ║ Please CLOSE this window and run Install-Windows.bat again. ║
|
echo Please CLOSE this window and run Install-Windows.bat again.
|
||||||
echo ║ This is required for the PATH to update. ║
|
echo This is required for the PATH to update.
|
||||||
echo ╚═══════════════════════════════════════════════════════════════╝
|
echo ===============================================================
|
||||||
echo.
|
echo.
|
||||||
echo [%date% %time%] Node.js installed, restart required >> "%LOG_FILE%"
|
echo [%date% %time%] Node.js installed, restart required >> "%LOG_FILE%"
|
||||||
pause
|
pause
|
||||||
@@ -191,9 +188,9 @@ if !NPM_OK! equ 0 (
|
|||||||
goto :SUMMARY
|
goto :SUMMARY
|
||||||
)
|
)
|
||||||
|
|
||||||
REM ═══════════════════════════════════════════════════════════════
|
REM ---------------------------------------------------------------
|
||||||
REM STEP 4: Check Git (optional)
|
REM STEP 4: Check Git (optional)
|
||||||
REM ═══════════════════════════════════════════════════════════════
|
REM ---------------------------------------------------------------
|
||||||
echo.
|
echo.
|
||||||
echo [STEP 4/8] Checking Git (optional)...
|
echo [STEP 4/8] Checking Git (optional)...
|
||||||
|
|
||||||
@@ -206,9 +203,9 @@ if !ERRORLEVEL! equ 0 (
|
|||||||
set /a WARNINGS+=1
|
set /a WARNINGS+=1
|
||||||
)
|
)
|
||||||
|
|
||||||
REM ═══════════════════════════════════════════════════════════════
|
REM ---------------------------------------------------------------
|
||||||
REM STEP 5: Install npm Dependencies
|
REM STEP 5: Install npm Dependencies
|
||||||
REM ═══════════════════════════════════════════════════════════════
|
REM ---------------------------------------------------------------
|
||||||
echo.
|
echo.
|
||||||
echo [STEP 5/8] Installing Dependencies...
|
echo [STEP 5/8] Installing Dependencies...
|
||||||
|
|
||||||
@@ -238,26 +235,26 @@ if !ERRORLEVEL! neq 0 (
|
|||||||
)
|
)
|
||||||
echo [OK] Dependencies installed
|
echo [OK] Dependencies installed
|
||||||
|
|
||||||
REM ═══════════════════════════════════════════════════════════════
|
REM ---------------------------------------------------------------
|
||||||
REM STEP 6: OpenCode Binary (OPTIONAL)
|
REM STEP 6: OpenCode Binary (OPTIONAL)
|
||||||
REM ═══════════════════════════════════════════════════════════════
|
REM ---------------------------------------------------------------
|
||||||
echo.
|
echo.
|
||||||
echo [STEP 6/8] OpenCode Binary Setup...
|
echo [STEP 6/8] OpenCode Binary Setup...
|
||||||
echo.
|
echo.
|
||||||
echo ╔═══════════════════════════════════════════════════════════════╗
|
echo ===============================================================
|
||||||
echo ║ NomadArch supports Binary-Free Mode! ║
|
echo NomadArch supports Binary-Free Mode!
|
||||||
echo ║ You can skip the OpenCode binary and use free cloud models: ║
|
echo You can skip the OpenCode binary and use free cloud models:
|
||||||
echo ║ - GPT-5 Nano, Grok Code, GLM-4.7, Doubao, and more ║
|
echo - GPT-5 Nano, Grok Code, GLM-4.7, Doubao, and more
|
||||||
echo ╚═══════════════════════════════════════════════════════════════╝
|
echo ===============================================================
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
set SKIP_OPENCODE=1
|
set SKIP_OPENCODE=1
|
||||||
echo [OK] Using Binary-Free Mode (default)
|
echo [OK] Using Binary-Free Mode (default)
|
||||||
echo [%date% %time%] Using Binary-Free Mode >> "%LOG_FILE%"
|
echo [%date% %time%] Using Binary-Free Mode >> "%LOG_FILE%"
|
||||||
|
|
||||||
REM ═══════════════════════════════════════════════════════════════
|
REM ---------------------------------------------------------------
|
||||||
REM STEP 7: Build UI Assets
|
REM STEP 7: Build UI Assets
|
||||||
REM ═══════════════════════════════════════════════════════════════
|
REM ---------------------------------------------------------------
|
||||||
echo.
|
echo.
|
||||||
echo [STEP 7/8] Building UI Assets...
|
echo [STEP 7/8] Building UI Assets...
|
||||||
|
|
||||||
@@ -278,9 +275,9 @@ if exist "%SCRIPT_DIR%\packages\ui\dist\index.html" (
|
|||||||
echo [OK] UI assets built successfully
|
echo [OK] UI assets built successfully
|
||||||
)
|
)
|
||||||
|
|
||||||
REM ═══════════════════════════════════════════════════════════════
|
REM ---------------------------------------------------------------
|
||||||
REM STEP 8: Health Check and Summary
|
REM STEP 8: Health Check and Summary
|
||||||
REM ═══════════════════════════════════════════════════════════════
|
REM ---------------------------------------------------------------
|
||||||
echo.
|
echo.
|
||||||
echo [STEP 8/8] Running Health Check...
|
echo [STEP 8/8] Running Health Check...
|
||||||
|
|
||||||
@@ -320,9 +317,9 @@ if !HEALTH_OK! equ 1 (
|
|||||||
|
|
||||||
:SUMMARY
|
:SUMMARY
|
||||||
echo.
|
echo.
|
||||||
echo ╔═══════════════════════════════════════════════════════════════╗
|
echo ===============================================================
|
||||||
echo ║ INSTALLATION SUMMARY ║
|
echo INSTALLATION SUMMARY
|
||||||
echo ╚═══════════════════════════════════════════════════════════════╝
|
echo ===============================================================
|
||||||
echo.
|
echo.
|
||||||
echo Install Directory: %TARGET_DIR%
|
echo Install Directory: %TARGET_DIR%
|
||||||
echo Architecture: !ARCH!
|
echo Architecture: !ARCH!
|
||||||
@@ -335,9 +332,9 @@ echo Log File: %LOG_FILE%
|
|||||||
echo.
|
echo.
|
||||||
|
|
||||||
if !ERRORS! gtr 0 (
|
if !ERRORS! gtr 0 (
|
||||||
echo ╔═══════════════════════════════════════════════════════════════╗
|
echo ===============================================================
|
||||||
echo ║ INSTALLATION FAILED ║
|
echo INSTALLATION FAILED
|
||||||
echo ╚═══════════════════════════════════════════════════════════════╝
|
echo ===============================================================
|
||||||
echo.
|
echo.
|
||||||
echo Review the errors above and check the log file: %LOG_FILE%
|
echo Review the errors above and check the log file: %LOG_FILE%
|
||||||
echo.
|
echo.
|
||||||
@@ -349,9 +346,9 @@ if !ERRORS! gtr 0 (
|
|||||||
echo.
|
echo.
|
||||||
echo [%date% %time%] Installation FAILED with !ERRORS! errors >> "%LOG_FILE%"
|
echo [%date% %time%] Installation FAILED with !ERRORS! errors >> "%LOG_FILE%"
|
||||||
) else (
|
) else (
|
||||||
echo ╔═══════════════════════════════════════════════════════════════╗
|
echo ===============================================================
|
||||||
echo ║ INSTALLATION SUCCESSFUL! ║
|
echo INSTALLATION SUCCESSFUL!
|
||||||
echo ╚═══════════════════════════════════════════════════════════════╝
|
echo ===============================================================
|
||||||
echo.
|
echo.
|
||||||
echo To start NomadArch, run:
|
echo To start NomadArch, run:
|
||||||
echo Launch-Windows.bat
|
echo Launch-Windows.bat
|
||||||
|
|||||||
@@ -68,10 +68,23 @@ export function setupCliIPC(mainWindow: BrowserWindow, cliManager: CliProcessMan
|
|||||||
})
|
})
|
||||||
ipcMain.handle("users:createGuest", async () => {
|
ipcMain.handle("users:createGuest", async () => {
|
||||||
const user = createGuestUser()
|
const user = createGuestUser()
|
||||||
|
// Set up isolated environment for guest user
|
||||||
|
const root = getUserDataRoot(user.id)
|
||||||
|
cliManager.setUserEnv({
|
||||||
|
CODENOMAD_USER_DIR: root,
|
||||||
|
CLI_CONFIG: path.join(root, "config.json"),
|
||||||
|
})
|
||||||
|
await cliManager.stop()
|
||||||
|
const devMode = process.env.NODE_ENV === "development"
|
||||||
|
await cliManager.start({ dev: devMode })
|
||||||
|
// Set as active user
|
||||||
|
setActiveUser(user.id)
|
||||||
return user
|
return user
|
||||||
})
|
})
|
||||||
ipcMain.handle("users:login", async (_, payload: { id: string; password?: string }) => {
|
ipcMain.handle("users:login", async (_, payload: { id: string; password?: string }) => {
|
||||||
|
console.log("[IPC:users:login] Attempting login for:", payload.id, "password length:", payload.password?.length)
|
||||||
const ok = verifyPassword(payload.id, payload.password ?? "")
|
const ok = verifyPassword(payload.id, payload.password ?? "")
|
||||||
|
console.log("[IPC:users:login] verifyPassword result:", ok)
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
return { success: false }
|
return { success: false }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,10 +276,20 @@ export function deleteUser(userId: string) {
|
|||||||
export function verifyPassword(userId: string, password: string): boolean {
|
export function verifyPassword(userId: string, password: string): boolean {
|
||||||
const store = readStore()
|
const store = readStore()
|
||||||
const user = store.users.find((u) => u.id === userId)
|
const user = store.users.find((u) => u.id === userId)
|
||||||
if (!user) return false
|
if (!user) {
|
||||||
|
console.log("[verifyPassword] User not found:", userId)
|
||||||
|
return false
|
||||||
|
}
|
||||||
if (user.isGuest) return true
|
if (user.isGuest) return true
|
||||||
if (!user.salt || !user.passwordHash) return false
|
if (!user.salt || !user.passwordHash) {
|
||||||
return hashPassword(password, user.salt) === user.passwordHash
|
console.log("[verifyPassword] No salt or hash for user:", userId)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const computed = hashPassword(password, user.salt)
|
||||||
|
const matches = computed === user.passwordHash
|
||||||
|
console.log("[verifyPassword] userId:", userId, "password:", JSON.stringify(password), "len:", password.length)
|
||||||
|
console.log("[verifyPassword] computed:", computed, "stored:", user.passwordHash, "matches:", matches)
|
||||||
|
return matches
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUserDataRoot(userId: string) {
|
export function getUserDataRoot(userId: string) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Component, createSignal, onMount, For, Show } from "solid-js"
|
import { Component, createSignal, onMount, For, Show } from "solid-js"
|
||||||
import { Lock, User, LogIn, ShieldCheck, Cpu } from "lucide-solid"
|
import { Lock, User, ShieldCheck, Cpu, UserPlus, KeyRound, ArrowLeft, Ghost } from "lucide-solid"
|
||||||
import toast from "solid-toast"
|
import toast from "solid-toast"
|
||||||
import { isElectronHost } from "../../lib/runtime-env"
|
import { isElectronHost } from "../../lib/runtime-env"
|
||||||
import { setActiveUserId } from "../../lib/user-context"
|
import { setActiveUserId } from "../../lib/user-context"
|
||||||
@@ -14,43 +14,48 @@ interface LoginViewProps {
|
|||||||
onLoginSuccess: (user: UserRecord) => void
|
onLoginSuccess: (user: UserRecord) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ViewMode = "login" | "register" | "reset"
|
||||||
|
|
||||||
const LoginView: Component<LoginViewProps> = (props) => {
|
const LoginView: Component<LoginViewProps> = (props) => {
|
||||||
const [users, setUsers] = createSignal<UserRecord[]>([])
|
const [users, setUsers] = createSignal<UserRecord[]>([])
|
||||||
const [username, setUsername] = createSignal("")
|
const [username, setUsername] = createSignal("")
|
||||||
const [password, setPassword] = createSignal("")
|
const [password, setPassword] = createSignal("")
|
||||||
const [isLoggingIn, setIsLoggingIn] = createSignal(false)
|
const [confirmPassword, setConfirmPassword] = createSignal("")
|
||||||
const [isLoadingUsers, setIsLoadingUsers] = createSignal(true)
|
const [newPassword, setNewPassword] = createSignal("")
|
||||||
|
const [isLoading, setIsLoading] = createSignal(false)
|
||||||
|
const [mode, setMode] = createSignal<ViewMode>("login")
|
||||||
|
|
||||||
const getApi = () => (window as any).electronAPI || (window as any).electron
|
const getApi = () => {
|
||||||
|
const api = (window as any).electronAPI
|
||||||
const safeInvoke = async (method: string, ...args: any[]) => {
|
return api
|
||||||
const api = getApi()
|
|
||||||
if (!api) return null
|
|
||||||
const invoke = api.invoke || api.ipcRenderer?.invoke || (window as any).ipcRenderer?.invoke
|
|
||||||
if (!invoke) return null
|
|
||||||
const binder = api.invoke ? api : (api.ipcRenderer || (window as any).ipcRenderer)
|
|
||||||
return await invoke.call(binder, method, ...args)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
const loadUsers = async () => {
|
||||||
try {
|
try {
|
||||||
if (isElectronHost()) {
|
if (isElectronHost()) {
|
||||||
const userList = await safeInvoke("users:list")
|
const api = getApi()
|
||||||
if (userList && Array.isArray(userList)) {
|
if (api?.listUsers) {
|
||||||
setUsers(userList)
|
const userList = await api.listUsers()
|
||||||
if (userList.length > 0) {
|
if (userList && Array.isArray(userList)) {
|
||||||
setUsername(userList[0].name)
|
setUsers(userList)
|
||||||
|
if (userList.length > 0 && !username()) {
|
||||||
|
setUsername(userList[0].name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
setUsername("web-explorer")
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to fetch users:", error)
|
console.error("Failed to fetch users:", error)
|
||||||
} finally {
|
|
||||||
setIsLoadingUsers(false)
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
|
onMount(loadUsers)
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
setPassword("")
|
||||||
|
setConfirmPassword("")
|
||||||
|
setNewPassword("")
|
||||||
|
}
|
||||||
|
|
||||||
const handleLogin = async (e: Event) => {
|
const handleLogin = async (e: Event) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@@ -60,43 +65,204 @@ const LoginView: Component<LoginViewProps> = (props) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsLoggingIn(true)
|
setIsLoading(true)
|
||||||
try {
|
try {
|
||||||
if (isElectronHost()) {
|
if (isElectronHost()) {
|
||||||
const userList = await safeInvoke("users:list")
|
const api = getApi()
|
||||||
if (!userList || !Array.isArray(userList)) {
|
if (!api?.listUsers || !api?.loginUser) {
|
||||||
toast.error("Bridge failure: try restarting")
|
toast.error("API bridge not ready")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = userList.find((u: UserRecord) => u.name.toLowerCase() === name.toLowerCase())
|
const userList = await api.listUsers()
|
||||||
|
const user = userList?.find((u: UserRecord) => u.name.toLowerCase() === name.toLowerCase())
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
toast.error(`Identity "${name}" not found`)
|
toast.error(`Identity "${name}" not found`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await safeInvoke("users:login", {
|
const result = await api.loginUser({
|
||||||
id: user.id,
|
id: user.id,
|
||||||
password: password(),
|
password: password(),
|
||||||
})
|
})
|
||||||
|
|
||||||
if (result?.success) {
|
if (result?.success) {
|
||||||
toast.success(`Welcome back, ${result.user.name}!`)
|
toast.success(`Welcome back, ${result.user.name}!`)
|
||||||
setActiveUserId(result.user.id) // Proactively update local state
|
setActiveUserId(result.user.id)
|
||||||
props.onLoginSuccess(result.user)
|
props.onLoginSuccess(result.user)
|
||||||
} else {
|
} else {
|
||||||
toast.error("Invalid key for this identity")
|
toast.error("Invalid access key")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
toast.success("Web mode access granted")
|
toast.success("Web mode access granted")
|
||||||
props.onLoginSuccess({ id: "web-user", name: "Web Explorer" })
|
props.onLoginSuccess({ id: "web-user", name: username() || "Web Explorer" })
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Login failed:", error)
|
console.error("Login failed:", error)
|
||||||
toast.error("Decryption failed: check your key")
|
toast.error("Authentication failed")
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoggingIn(false)
|
setIsLoading(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleGuestLogin = async () => {
|
||||||
|
setIsLoading(true)
|
||||||
|
try {
|
||||||
|
const api = getApi()
|
||||||
|
if (api?.createGuest) {
|
||||||
|
const guestUser = await api.createGuest()
|
||||||
|
if (guestUser?.id) {
|
||||||
|
toast.success(`Welcome, ${guestUser.name}!`)
|
||||||
|
setActiveUserId(guestUser.id)
|
||||||
|
props.onLoginSuccess(guestUser)
|
||||||
|
} else {
|
||||||
|
toast.error("Failed to create guest session")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Web mode fallback
|
||||||
|
const guestId = `guest-${Date.now()}`
|
||||||
|
toast.success("Guest session started")
|
||||||
|
props.onLoginSuccess({ id: guestId, name: "Guest", isGuest: true })
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Guest login failed:", error)
|
||||||
|
toast.error("Guest login failed")
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleRegister = async (e: Event) => {
|
||||||
|
e.preventDefault()
|
||||||
|
const name = username().trim()
|
||||||
|
|
||||||
|
if (!name) {
|
||||||
|
toast.error("Username required")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (name.length < 3) {
|
||||||
|
toast.error("Username must be at least 3 characters")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!password()) {
|
||||||
|
toast.error("Password required")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (password().length < 4) {
|
||||||
|
toast.error("Password must be at least 4 characters")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (password() !== confirmPassword()) {
|
||||||
|
toast.error("Passwords do not match")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if user already exists
|
||||||
|
const existingUser = users().find(u => u.name.toLowerCase() === name.toLowerCase())
|
||||||
|
if (existingUser) {
|
||||||
|
toast.error(`Identity "${name}" already exists`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsLoading(true)
|
||||||
|
try {
|
||||||
|
const api = getApi()
|
||||||
|
if (!api?.createUser) {
|
||||||
|
toast.error("Registration unavailable")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const newUser = await api.createUser({
|
||||||
|
name: name,
|
||||||
|
password: password(),
|
||||||
|
})
|
||||||
|
|
||||||
|
if (newUser?.id) {
|
||||||
|
toast.success(`Identity "${name}" created successfully!`)
|
||||||
|
await loadUsers()
|
||||||
|
setMode("login")
|
||||||
|
setUsername(name)
|
||||||
|
resetForm()
|
||||||
|
} else {
|
||||||
|
toast.error("Failed to create identity")
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Registration failed:", error)
|
||||||
|
toast.error("Registration failed")
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleResetPassword = async (e: Event) => {
|
||||||
|
e.preventDefault()
|
||||||
|
const name = username().trim()
|
||||||
|
|
||||||
|
if (!name) {
|
||||||
|
toast.error("Select an identity first")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!password()) {
|
||||||
|
toast.error("Current password required")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!newPassword()) {
|
||||||
|
toast.error("New password required")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (newPassword().length < 4) {
|
||||||
|
toast.error("New password must be at least 4 characters")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const user = users().find(u => u.name.toLowerCase() === name.toLowerCase())
|
||||||
|
if (!user) {
|
||||||
|
toast.error(`Identity "${name}" not found`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsLoading(true)
|
||||||
|
try {
|
||||||
|
const api = getApi()
|
||||||
|
|
||||||
|
// First verify current password
|
||||||
|
const verifyResult = await api.loginUser({
|
||||||
|
id: user.id,
|
||||||
|
password: password(),
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!verifyResult?.success) {
|
||||||
|
toast.error("Current password is incorrect")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update password
|
||||||
|
const updateResult = await api.updateUser({
|
||||||
|
id: user.id,
|
||||||
|
password: newPassword(),
|
||||||
|
})
|
||||||
|
|
||||||
|
if (updateResult?.id) {
|
||||||
|
toast.success("Password updated successfully!")
|
||||||
|
setMode("login")
|
||||||
|
resetForm()
|
||||||
|
} else {
|
||||||
|
toast.error("Failed to update password")
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Password reset failed:", error)
|
||||||
|
toast.error("Password reset failed")
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const switchMode = (newMode: ViewMode) => {
|
||||||
|
setMode(newMode)
|
||||||
|
resetForm()
|
||||||
|
if (newMode === "register") {
|
||||||
|
setUsername("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,78 +274,250 @@ const LoginView: Component<LoginViewProps> = (props) => {
|
|||||||
<div class="absolute -bottom-[10%] -right-[10%] w-[40%] h-[40%] bg-purple-500/20 blur-[120px] rounded-full animate-pulse delay-700" />
|
<div class="absolute -bottom-[10%] -right-[10%] w-[40%] h-[40%] bg-purple-500/20 blur-[120px] rounded-full animate-pulse delay-700" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="relative w-full max-w-md px-6 py-12 bg-[#141414]/80 backdrop-blur-xl border border-white/10 rounded-3xl shadow-2xl">
|
<div class="relative w-full max-w-md px-6 py-10 bg-[#141414]/80 backdrop-blur-xl border border-white/10 rounded-3xl shadow-2xl">
|
||||||
{/* Logo & Header */}
|
{/* Logo & Header */}
|
||||||
<div class="flex flex-col items-center mb-10">
|
<div class="flex flex-col items-center mb-8">
|
||||||
<div class="w-20 h-20 mb-6 bg-gradient-to-br from-blue-500 via-indigo-600 to-purple-700 p-0.5 rounded-2xl shadow-lg transform rotate-3">
|
<div class="w-16 h-16 mb-4 bg-gradient-to-br from-blue-500 via-indigo-600 to-purple-700 p-0.5 rounded-2xl shadow-lg transform rotate-3">
|
||||||
<div class="w-full h-full bg-[#141414] rounded-2xl flex items-center justify-center">
|
<div class="w-full h-full bg-[#141414] rounded-2xl flex items-center justify-center">
|
||||||
<Cpu class="w-10 h-10 text-white" />
|
<Cpu class="w-8 h-8 text-white" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h1 class="text-3xl font-bold text-white tracking-tight mb-2">NomadArch</h1>
|
<h1 class="text-2xl font-bold text-white tracking-tight mb-1">NomadArch</h1>
|
||||||
<p class="text-gray-400 text-sm">Secure Neural Access Point</p>
|
<p class="text-gray-400 text-sm">
|
||||||
|
{mode() === "login" && "Secure Neural Access Point"}
|
||||||
|
{mode() === "register" && "Create New Identity"}
|
||||||
|
{mode() === "reset" && "Reset Access Key"}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form onSubmit={handleLogin} class="space-y-6">
|
{/* Back button for non-login modes */}
|
||||||
{/* User Selection */}
|
<Show when={mode() !== "login"}>
|
||||||
<div class="space-y-2">
|
|
||||||
<label class="text-xs font-semibold text-gray-500 uppercase tracking-wider ml-1">Identity</label>
|
|
||||||
<div class="relative group">
|
|
||||||
<div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
|
|
||||||
<User class="w-5 h-5 text-gray-500 group-focus-within:text-blue-500 transition-colors" />
|
|
||||||
</div>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
placeholder="Username"
|
|
||||||
value={username()}
|
|
||||||
onInput={(e) => setUsername(e.currentTarget.value)}
|
|
||||||
class="block w-full pl-12 pr-4 py-4 bg-[#1a1a1a] border border-white/5 rounded-2xl text-white appearance-none focus:outline-none focus:ring-2 focus:ring-blue-500/50 focus:border-blue-500/50 transition-all cursor-text"
|
|
||||||
list="identity-suggestions"
|
|
||||||
/>
|
|
||||||
<datalist id="identity-suggestions">
|
|
||||||
<For each={users()}>
|
|
||||||
{(user) => <option value={user.name} />}
|
|
||||||
</For>
|
|
||||||
</datalist>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Password Input */}
|
|
||||||
<div class="space-y-2">
|
|
||||||
<label class="text-xs font-semibold text-gray-500 uppercase tracking-wider ml-1">Access Key</label>
|
|
||||||
<div class="relative group">
|
|
||||||
<div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
|
|
||||||
<Lock class="w-5 h-5 text-gray-500 group-focus-within:text-blue-500 transition-colors" />
|
|
||||||
</div>
|
|
||||||
<input
|
|
||||||
type="password"
|
|
||||||
placeholder="Enter password..."
|
|
||||||
value={password()}
|
|
||||||
onInput={(e) => setPassword(e.currentTarget.value)}
|
|
||||||
required
|
|
||||||
class="block w-full pl-12 pr-4 py-4 bg-[#1a1a1a] border border-white/5 rounded-2xl text-white placeholder-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500/50 focus:border-blue-500/50 transition-all font-mono"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="button"
|
||||||
disabled={isLoggingIn() || !username()}
|
onClick={() => switchMode("login")}
|
||||||
class="w-full flex items-center justify-center gap-3 py-4 bg-gradient-to-r from-blue-600 via-indigo-600 to-purple-600 hover:from-blue-500 hover:to-purple-500 text-white font-bold rounded-2xl shadow-xl shadow-blue-900/20 transform active:scale-[0.98] transition-all disabled:opacity-50 disabled:cursor-not-allowed group"
|
class="flex items-center gap-2 text-gray-400 hover:text-white transition-colors mb-4"
|
||||||
>
|
>
|
||||||
<Show when={isLoggingIn()} fallback={
|
<ArrowLeft class="w-4 h-4" />
|
||||||
<>
|
<span class="text-sm">Back to login</span>
|
||||||
<ShieldCheck class="w-5 h-5 group-hover:scale-110 transition-transform" />
|
|
||||||
<span>Verify Identity</span>
|
|
||||||
</>
|
|
||||||
}>
|
|
||||||
<div class="w-5 h-5 border-2 border-white/30 border-t-white rounded-full animate-spin" />
|
|
||||||
<span>Decrypting...</span>
|
|
||||||
</Show>
|
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</Show>
|
||||||
|
|
||||||
<div class="mt-8 text-center text-xs text-gray-600">
|
{/* Login Form */}
|
||||||
|
<Show when={mode() === "login"}>
|
||||||
|
<form onSubmit={handleLogin} class="space-y-5">
|
||||||
|
<div class="space-y-1.5">
|
||||||
|
<label class="text-xs font-semibold text-gray-500 uppercase tracking-wider ml-1">Identity</label>
|
||||||
|
<div class="relative group">
|
||||||
|
<div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
|
||||||
|
<User class="w-5 h-5 text-gray-500 group-focus-within:text-blue-500 transition-colors" />
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Username"
|
||||||
|
value={username()}
|
||||||
|
onInput={(e) => setUsername(e.currentTarget.value)}
|
||||||
|
class="block w-full pl-12 pr-4 py-3.5 bg-[#1a1a1a] border border-white/5 rounded-2xl text-white focus:outline-none focus:ring-2 focus:ring-blue-500/50 transition-all"
|
||||||
|
list="identity-suggestions"
|
||||||
|
/>
|
||||||
|
<datalist id="identity-suggestions">
|
||||||
|
<For each={users()}>{(user) => <option value={user.name} />}</For>
|
||||||
|
</datalist>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-1.5">
|
||||||
|
<label class="text-xs font-semibold text-gray-500 uppercase tracking-wider ml-1">Access Key</label>
|
||||||
|
<div class="relative group">
|
||||||
|
<div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
|
||||||
|
<Lock class="w-5 h-5 text-gray-500 group-focus-within:text-blue-500 transition-colors" />
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
placeholder="Password"
|
||||||
|
value={password()}
|
||||||
|
onInput={(e) => setPassword(e.currentTarget.value)}
|
||||||
|
class="block w-full pl-12 pr-4 py-3.5 bg-[#1a1a1a] border border-white/5 rounded-2xl text-white placeholder-gray-600 focus:outline-none focus:ring-2 focus:ring-blue-500/50 transition-all font-mono"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={isLoading() || !username()}
|
||||||
|
class="w-full flex items-center justify-center gap-3 py-3.5 bg-gradient-to-r from-blue-600 via-indigo-600 to-purple-600 hover:from-blue-500 hover:to-purple-500 text-white font-bold rounded-2xl shadow-xl transform active:scale-[0.98] transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
||||||
|
>
|
||||||
|
<Show when={isLoading()} fallback={<><ShieldCheck class="w-5 h-5" /><span>Verify Identity</span></>}>
|
||||||
|
<div class="w-5 h-5 border-2 border-white/30 border-t-white rounded-full animate-spin" />
|
||||||
|
<span>Verifying...</span>
|
||||||
|
</Show>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div class="mt-6 flex flex-col gap-4">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={handleGuestLogin}
|
||||||
|
disabled={isLoading()}
|
||||||
|
class="w-full flex items-center justify-center gap-2 py-3 bg-[#1a1a1a] hover:bg-[#252525] border border-white/10 text-gray-300 hover:text-white font-medium rounded-2xl transition-all disabled:opacity-50"
|
||||||
|
>
|
||||||
|
<Ghost class="w-5 h-5" />
|
||||||
|
<span>Continue as Guest</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="flex items-center justify-between text-sm">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => switchMode("register")}
|
||||||
|
class="flex items-center gap-1.5 text-gray-400 hover:text-blue-400 transition-colors"
|
||||||
|
>
|
||||||
|
<UserPlus class="w-4 h-4" />
|
||||||
|
<span>Create Identity</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => switchMode("reset")}
|
||||||
|
class="flex items-center gap-1.5 text-gray-400 hover:text-purple-400 transition-colors"
|
||||||
|
>
|
||||||
|
<KeyRound class="w-4 h-4" />
|
||||||
|
<span>Reset Password</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Show>
|
||||||
|
|
||||||
|
{/* Register Form */}
|
||||||
|
<Show when={mode() === "register"}>
|
||||||
|
<form onSubmit={handleRegister} class="space-y-5">
|
||||||
|
<div class="space-y-1.5">
|
||||||
|
<label class="text-xs font-semibold text-gray-500 uppercase tracking-wider ml-1">Choose Username</label>
|
||||||
|
<div class="relative group">
|
||||||
|
<div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
|
||||||
|
<User class="w-5 h-5 text-gray-500 group-focus-within:text-green-500 transition-colors" />
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Enter username"
|
||||||
|
value={username()}
|
||||||
|
onInput={(e) => setUsername(e.currentTarget.value)}
|
||||||
|
class="block w-full pl-12 pr-4 py-3.5 bg-[#1a1a1a] border border-white/5 rounded-2xl text-white focus:outline-none focus:ring-2 focus:ring-green-500/50 transition-all"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-1.5">
|
||||||
|
<label class="text-xs font-semibold text-gray-500 uppercase tracking-wider ml-1">Choose Password</label>
|
||||||
|
<div class="relative group">
|
||||||
|
<div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
|
||||||
|
<Lock class="w-5 h-5 text-gray-500 group-focus-within:text-green-500 transition-colors" />
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
placeholder="Enter password"
|
||||||
|
value={password()}
|
||||||
|
onInput={(e) => setPassword(e.currentTarget.value)}
|
||||||
|
class="block w-full pl-12 pr-4 py-3.5 bg-[#1a1a1a] border border-white/5 rounded-2xl text-white placeholder-gray-600 focus:outline-none focus:ring-2 focus:ring-green-500/50 transition-all font-mono"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-1.5">
|
||||||
|
<label class="text-xs font-semibold text-gray-500 uppercase tracking-wider ml-1">Confirm Password</label>
|
||||||
|
<div class="relative group">
|
||||||
|
<div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
|
||||||
|
<Lock class="w-5 h-5 text-gray-500 group-focus-within:text-green-500 transition-colors" />
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
placeholder="Confirm password"
|
||||||
|
value={confirmPassword()}
|
||||||
|
onInput={(e) => setConfirmPassword(e.currentTarget.value)}
|
||||||
|
class="block w-full pl-12 pr-4 py-3.5 bg-[#1a1a1a] border border-white/5 rounded-2xl text-white placeholder-gray-600 focus:outline-none focus:ring-2 focus:ring-green-500/50 transition-all font-mono"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={isLoading() || !username() || !password() || !confirmPassword()}
|
||||||
|
class="w-full flex items-center justify-center gap-3 py-3.5 bg-gradient-to-r from-green-600 via-emerald-600 to-teal-600 hover:from-green-500 hover:to-teal-500 text-white font-bold rounded-2xl shadow-xl transform active:scale-[0.98] transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
||||||
|
>
|
||||||
|
<Show when={isLoading()} fallback={<><UserPlus class="w-5 h-5" /><span>Create Identity</span></>}>
|
||||||
|
<div class="w-5 h-5 border-2 border-white/30 border-t-white rounded-full animate-spin" />
|
||||||
|
<span>Creating...</span>
|
||||||
|
</Show>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</Show>
|
||||||
|
|
||||||
|
{/* Reset Password Form */}
|
||||||
|
<Show when={mode() === "reset"}>
|
||||||
|
<form onSubmit={handleResetPassword} class="space-y-5">
|
||||||
|
<div class="space-y-1.5">
|
||||||
|
<label class="text-xs font-semibold text-gray-500 uppercase tracking-wider ml-1">Identity</label>
|
||||||
|
<div class="relative group">
|
||||||
|
<div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
|
||||||
|
<User class="w-5 h-5 text-gray-500 group-focus-within:text-purple-500 transition-colors" />
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Username"
|
||||||
|
value={username()}
|
||||||
|
onInput={(e) => setUsername(e.currentTarget.value)}
|
||||||
|
class="block w-full pl-12 pr-4 py-3.5 bg-[#1a1a1a] border border-white/5 rounded-2xl text-white focus:outline-none focus:ring-2 focus:ring-purple-500/50 transition-all"
|
||||||
|
list="identity-suggestions-reset"
|
||||||
|
/>
|
||||||
|
<datalist id="identity-suggestions-reset">
|
||||||
|
<For each={users()}>{(user) => <option value={user.name} />}</For>
|
||||||
|
</datalist>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-1.5">
|
||||||
|
<label class="text-xs font-semibold text-gray-500 uppercase tracking-wider ml-1">Current Password</label>
|
||||||
|
<div class="relative group">
|
||||||
|
<div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
|
||||||
|
<Lock class="w-5 h-5 text-gray-500 group-focus-within:text-purple-500 transition-colors" />
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
placeholder="Enter current password"
|
||||||
|
value={password()}
|
||||||
|
onInput={(e) => setPassword(e.currentTarget.value)}
|
||||||
|
class="block w-full pl-12 pr-4 py-3.5 bg-[#1a1a1a] border border-white/5 rounded-2xl text-white placeholder-gray-600 focus:outline-none focus:ring-2 focus:ring-purple-500/50 transition-all font-mono"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-1.5">
|
||||||
|
<label class="text-xs font-semibold text-gray-500 uppercase tracking-wider ml-1">New Password</label>
|
||||||
|
<div class="relative group">
|
||||||
|
<div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
|
||||||
|
<KeyRound class="w-5 h-5 text-gray-500 group-focus-within:text-purple-500 transition-colors" />
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
placeholder="Enter new password"
|
||||||
|
value={newPassword()}
|
||||||
|
onInput={(e) => setNewPassword(e.currentTarget.value)}
|
||||||
|
class="block w-full pl-12 pr-4 py-3.5 bg-[#1a1a1a] border border-white/5 rounded-2xl text-white placeholder-gray-600 focus:outline-none focus:ring-2 focus:ring-purple-500/50 transition-all font-mono"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
disabled={isLoading() || !username() || !password() || !newPassword()}
|
||||||
|
class="w-full flex items-center justify-center gap-3 py-3.5 bg-gradient-to-r from-purple-600 via-violet-600 to-fuchsia-600 hover:from-purple-500 hover:to-fuchsia-500 text-white font-bold rounded-2xl shadow-xl transform active:scale-[0.98] transition-all disabled:opacity-50 disabled:cursor-not-allowed"
|
||||||
|
>
|
||||||
|
<Show when={isLoading()} fallback={<><KeyRound class="w-5 h-5" /><span>Reset Password</span></>}>
|
||||||
|
<div class="w-5 h-5 border-2 border-white/30 border-t-white rounded-full animate-spin" />
|
||||||
|
<span>Resetting...</span>
|
||||||
|
</Show>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</Show>
|
||||||
|
|
||||||
|
<div class="mt-6 text-center text-xs text-gray-600">
|
||||||
Powered by Antigravity OS v4.5 | Encrypted Connection
|
Powered by Antigravity OS v4.5 | Encrypted Connection
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -104,14 +104,11 @@ export async function initializeUserContext(): Promise<void> {
|
|||||||
console.log(`[UserContext] Initializing... host=${isElectronHost()}`)
|
console.log(`[UserContext] Initializing... host=${isElectronHost()}`)
|
||||||
try {
|
try {
|
||||||
if (isElectronHost()) {
|
if (isElectronHost()) {
|
||||||
const api = (window as any).electronAPI || (window as any).electron
|
const api = (window as any).electronAPI
|
||||||
if (api) {
|
if (api && api.getActiveUser) {
|
||||||
console.log(`[UserContext] Requesting active user from host IPC...`)
|
console.log(`[UserContext] Requesting active user via api.getActiveUser()...`)
|
||||||
const invoke = api.invoke || api.ipcRenderer?.invoke || (window as any).ipcRenderer?.invoke
|
const activeUser = await api.getActiveUser()
|
||||||
if (!invoke) throw new Error("No IPC invoke method found")
|
console.log(`[UserContext] getActiveUser result:`, activeUser)
|
||||||
|
|
||||||
const binder = api.invoke ? api : (api.ipcRenderer || (window as any).ipcRenderer)
|
|
||||||
const activeUser = await invoke.call(binder, "users:active")
|
|
||||||
|
|
||||||
if (activeUser?.id) {
|
if (activeUser?.id) {
|
||||||
console.log(`[UserContext] Host has active session: ${activeUser.id}`)
|
console.log(`[UserContext] Host has active session: ${activeUser.id}`)
|
||||||
@@ -121,7 +118,7 @@ export async function initializeUserContext(): Promise<void> {
|
|||||||
setActiveUserId(null)
|
setActiveUserId(null)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.warn(`[UserContext] Electron detected but no IPC bridge found. Falling back to web mode.`)
|
console.warn(`[UserContext] electronAPI.getActiveUser not found. Falling back to web mode.`)
|
||||||
await handleWebInit()
|
await handleWebInit()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user