From dfc40c35a520c6e70f3807a17850bd0115e16ec1 Mon Sep 17 00:00:00 2001 From: Champii Date: Sat, 24 May 2025 13:40:33 +0200 Subject: [PATCH] Revert "Add comprehensive cross-platform setup scripts" This reverts commit f992921e650f2072aa5da358c4583ec60c59b698. --- SETUP.md | 312 ---------------------------------------- setup | 105 -------------- setup.ps1 | 344 -------------------------------------------- setup.sh | 420 ------------------------------------------------------ 4 files changed, 1181 deletions(-) delete mode 100644 SETUP.md delete mode 100755 setup delete mode 100644 setup.ps1 delete mode 100755 setup.sh diff --git a/SETUP.md b/SETUP.md deleted file mode 100644 index 9f72c044..00000000 --- a/SETUP.md +++ /dev/null @@ -1,312 +0,0 @@ -# MutAnt Project Setup Guide - -This guide provides comprehensive instructions for setting up the MutAnt project development environment on different platforms. - -## Quick Start - -The easiest way to set up the project is to use the automated setup scripts: - -### Cross-Platform (Recommended) -```bash -./setup -``` - -### Platform-Specific Scripts - -#### Linux/macOS -```bash -./setup.sh -``` - -#### Windows (PowerShell) -```powershell -.\setup.ps1 -``` - -## Setup Script Options - -All setup scripts support the following options: - -- `--skip-tests` - Skip running tests during setup -- `--skip-web` - Skip web dependencies setup (Node.js, pnpm, webpack) -- `--skip-ant` - Skip Autonomi CLI installation -- `--help` - Show help message - -### Examples - -```bash -# Skip tests and web setup -./setup --skip-tests --skip-web - -# Only install Rust dependencies -./setup --skip-web --skip-ant -``` - -## What the Setup Scripts Install - -### System Dependencies -- **Build tools**: GCC, Make, or Visual Studio Build Tools (Windows) -- **SSL libraries**: OpenSSL development libraries -- **Process tools**: procps (for pgrep command) -- **Basic tools**: curl, wget, git, unzip - -### Rust Toolchain -- **Rust stable and nightly**: Latest versions via rustup -- **Components**: clippy (linting), rustfmt (formatting) -- **WASM tools**: wasm-pack for WebAssembly builds - -### Node.js Environment (if not skipped) -- **Node.js**: Latest LTS version -- **Package managers**: npm and pnpm -- **Build tools**: webpack and related dependencies - -### Autonomi CLI (if not skipped) -- **antup**: Autonomi installer tool -- **ant**: Autonomi CLI client - -### Project Build -- **Workspace build**: All Rust crates in the workspace -- **Code quality**: Runs clippy and rustfmt -- **Web build**: WASM module compilation (if web not skipped) -- **Tests**: Unit tests to verify installation (if not skipped) - -## Manual Installation - -If you prefer to install dependencies manually or the automated scripts don't work for your system: - -### 1. Install Rust - -```bash -# Install rustup -curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - -# Install toolchains and components -rustup install stable nightly -rustup default stable -rustup component add clippy rustfmt - -# Install wasm-pack -curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -``` - -### 2. Install System Dependencies - -#### Ubuntu/Debian -```bash -sudo apt-get update -sudo apt-get install -y build-essential pkg-config libssl-dev procps curl git wget unzip -``` - -#### CentOS/RHEL/Fedora -```bash -sudo yum groupinstall -y "Development Tools" -sudo yum install -y openssl-devel procps-ng curl git wget unzip -``` - -#### macOS -```bash -# Install Homebrew if not present -/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - -# Install dependencies -brew install openssl curl git wget -``` - -#### Windows -```powershell -# Install Chocolatey -Set-ExecutionPolicy Bypass -Scope Process -Force -iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - -# Install dependencies -choco install -y git curl wget 7zip vcredist-all -choco install -y visualstudio2022buildtools visualstudio2022-workload-vctools -``` - -### 3. Install Node.js (for web interface) - -#### Linux/macOS -```bash -# Using Node Version Manager (recommended) -curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash -nvm install --lts -nvm use --lts - -# Install pnpm -npm install -g pnpm -``` - -#### Windows -```powershell -choco install -y nodejs -npm install -g pnpm -``` - -### 4. Install Autonomi CLI - -```bash -# Install antup -curl -sSf https://raw.githubusercontent.com/maidsafe/antup/main/install.sh | sh - -# Install ant client -antup client -``` - -### 5. Build the Project - -```bash -# Build all workspace crates -cargo build --workspace - -# Run code quality checks -cargo clippy --workspace --all-targets --all-features -- -D warnings -cargo fmt --all - -# Build web interface (optional) -cd mutant-web -wasm-pack build --target web --out-dir pkg -pnpm install -pnpm run build -cd .. - -# Run tests -cargo test --workspace --lib -``` - -## Post-Installation Setup - -### 1. Configure Autonomi Wallet - -You need an Autonomi wallet to store and retrieve data: - -```bash -# Create a new wallet -ant wallet create - -# Or import an existing wallet -ant wallet import YOUR_PRIVATE_KEY_HERE -``` - -### 2. Install CLI Tools - -```bash -# Install the CLI and daemon -cargo install --path mutant-cli -cargo install --path mutant-daemon -``` - -### 3. Verify Installation - -```bash -# Check CLI installation -mutant --help - -# Check daemon installation -mutant-daemon --help - -# Test basic functionality (requires wallet setup) -mutant ls -``` - -## Development Environment - -### Local Testnet - -For development and testing, you can run a local Autonomi testnet: - -```bash -# Start local testnet -./scripts/manage_local_testnet.sh start - -# Check status -./scripts/manage_local_testnet.sh status - -# Stop testnet -./scripts/manage_local_testnet.sh stop -``` - -### Running Tests - -```bash -# Unit tests only -cargo test --workspace --lib - -# Integration tests with local testnet -./scripts/run_tests_with_env.sh - -# Specific test -./scripts/run_tests_with_env.sh test_name -``` - -### Web Development - -```bash -cd mutant-web - -# Install dependencies -pnpm install - -# Development server -pnpm run serve - -# Build for production -pnpm run build -``` - -## Troubleshooting - -### Common Issues - -#### Rust Installation Issues -- **Permission denied**: Make sure you have write access to `~/.cargo` -- **PATH not updated**: Restart your terminal or run `source ~/.cargo/env` -- **Old Rust version**: Run `rustup update` to get the latest version - -#### Build Failures -- **Missing system dependencies**: Install build tools for your platform -- **SSL errors**: Install OpenSSL development libraries -- **WASM build fails**: Make sure wasm-pack is installed and in PATH - -#### Network Issues -- **ant CLI not found**: Make sure `~/.local/bin` is in your PATH -- **Connection failures**: Check your internet connection and firewall settings - -#### Windows-Specific Issues -- **PowerShell execution policy**: Run `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser` -- **Visual Studio Build Tools**: Make sure C++ build tools are installed -- **Long path issues**: Enable long path support in Windows - -### Getting Help - -If you encounter issues not covered here: - -1. Check the [project README](README.md) for additional information -2. Look at existing [GitHub issues](https://github.com/Champii/Mutant/issues) -3. Create a new issue with: - - Your operating system and version - - Error messages (full output) - - Steps you've already tried - -## Environment Variables - -The following environment variables can be used to customize the setup: - -- `CARGO_HOME` - Cargo installation directory (default: `~/.cargo`) -- `RUSTUP_HOME` - Rustup installation directory (default: `~/.rustup`) -- `XDG_DATA_HOME` - Data directory for local testnet (default: `~/.local/share`) - -## Security Considerations - -- **Private keys**: Never commit private keys to version control -- **Wallet security**: Keep your wallet private key secure and backed up -- **Network access**: The project requires internet access for Autonomi network -- **Local testnet**: Only use test keys with local testnet, never mainnet keys - -## Next Steps - -After successful setup: - -1. Read the [Getting Started Guide](docs/mutant_lib/getting_started.md) -2. Explore the [API Documentation](docs/mutant_lib/api_reference.md) -3. Check out the [Architecture Overview](docs/mutant_lib/architecture.md) -4. Try the [CLI Examples](README.md#command-line-interface-cli) diff --git a/setup b/setup deleted file mode 100755 index a3d279a1..00000000 --- a/setup +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/bash - -# Cross-platform setup script for MutAnt project -# This script detects the platform and runs the appropriate setup script - -set -e - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' # No Color - -log_info() { - echo -e "${BLUE}[INFO]${NC} $1" -} - -log_success() { - echo -e "${GREEN}[SUCCESS]${NC} $1" -} - -log_error() { - echo -e "${RED}[ERROR]${NC} $1" -} - -show_help() { - echo "MutAnt Project Setup Script" - echo "" - echo "This script automatically detects your platform and runs the appropriate setup." - echo "" - echo "Usage: ./setup [OPTIONS]" - echo "" - echo "Options:" - echo " --skip-tests Skip running tests" - echo " --skip-web Skip web dependencies setup" - echo " --skip-ant Skip Autonomi CLI installation" - echo " --help, -h Show this help message" - echo "" - echo "Platform-specific scripts:" - echo " Linux/macOS: ./setup.sh" - echo " Windows: .\setup.ps1" - echo "" -} - -main() { - # Check for help flag - for arg in "$@"; do - if [[ "$arg" == "--help" ]] || [[ "$arg" == "-h" ]]; then - show_help - exit 0 - fi - done - - log_info "MutAnt Project Setup - Platform Detection" - - # Detect platform and run appropriate script - if [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]] || [[ -n "$WINDIR" ]]; then - log_info "Windows detected - running PowerShell setup script" - - # Check if PowerShell is available - if command -v powershell &> /dev/null; then - # Convert arguments for PowerShell - PS_ARGS="" - for arg in "$@"; do - case $arg in - --skip-tests) - PS_ARGS="$PS_ARGS -SkipTests" - ;; - --skip-web) - PS_ARGS="$PS_ARGS -SkipWeb" - ;; - --skip-ant) - PS_ARGS="$PS_ARGS -SkipAnt" - ;; - esac - done - - powershell -ExecutionPolicy Bypass -File setup.ps1 $PS_ARGS - else - log_error "PowerShell not found. Please install PowerShell or run setup.ps1 manually." - exit 1 - fi - - elif [[ "$OSTYPE" == "linux-gnu"* ]] || [[ "$OSTYPE" == "darwin"* ]]; then - log_info "Unix-like system detected - running bash setup script" - - # Make sure the script is executable - chmod +x setup.sh - - # Run the bash setup script with all arguments - ./setup.sh "$@" - - else - log_error "Unsupported platform: $OSTYPE" - log_info "Please run the appropriate setup script manually:" - log_info " - Linux/macOS: ./setup.sh" - log_info " - Windows: .\\setup.ps1" - exit 1 - fi - - log_success "Platform-specific setup completed!" -} - -main "$@" diff --git a/setup.ps1 b/setup.ps1 deleted file mode 100644 index 6ce4b3d3..00000000 --- a/setup.ps1 +++ /dev/null @@ -1,344 +0,0 @@ -# MutAnt Project Setup Script for Windows -# This script sets up all dependencies needed to build and run the MutAnt project on Windows - -param( - [switch]$SkipTests, - [switch]$SkipWeb, - [switch]$SkipAnt, - [switch]$Help -) - -# Colors for output -$Red = "Red" -$Green = "Green" -$Yellow = "Yellow" -$Blue = "Blue" - -# Logging functions -function Log-Info { - param([string]$Message) - Write-Host "[INFO] $Message" -ForegroundColor $Blue -} - -function Log-Success { - param([string]$Message) - Write-Host "[SUCCESS] $Message" -ForegroundColor $Green -} - -function Log-Warning { - param([string]$Message) - Write-Host "[WARNING] $Message" -ForegroundColor $Yellow -} - -function Log-Error { - param([string]$Message) - Write-Host "[ERROR] $Message" -ForegroundColor $Red -} - -function Show-Help { - Write-Host "MutAnt Project Setup Script for Windows" - Write-Host "" - Write-Host "Usage: .\setup.ps1 [OPTIONS]" - Write-Host "" - Write-Host "Options:" - Write-Host " -SkipTests Skip running tests" - Write-Host " -SkipWeb Skip web dependencies setup" - Write-Host " -SkipAnt Skip Autonomi CLI installation" - Write-Host " -Help Show this help message" - Write-Host "" -} - -function Test-Administrator { - $currentUser = [Security.Principal.WindowsIdentity]::GetCurrent() - $principal = New-Object Security.Principal.WindowsPrincipal($currentUser) - return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -} - -function Install-Chocolatey { - Log-Info "Checking for Chocolatey..." - - if (!(Get-Command choco -ErrorAction SilentlyContinue)) { - Log-Info "Installing Chocolatey..." - Set-ExecutionPolicy Bypass -Scope Process -Force - [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 - iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - - # Refresh environment variables - $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") - } else { - Log-Info "Chocolatey is already installed" - } -} - -function Install-SystemDependencies { - Log-Info "Installing system dependencies..." - - # Install basic tools - $packages = @( - "git", - "curl", - "wget", - "7zip", - "vcredist-all" - ) - - foreach ($package in $packages) { - Log-Info "Installing $package..." - choco install $package -y - } - - # Install Visual Studio Build Tools if not present - if (!(Get-Command cl -ErrorAction SilentlyContinue)) { - Log-Info "Installing Visual Studio Build Tools..." - choco install visualstudio2022buildtools -y - choco install visualstudio2022-workload-vctools -y - } - - Log-Success "System dependencies installed" -} - -function Install-Rust { - Log-Info "Installing Rust toolchain..." - - if (Get-Command rustc -ErrorAction SilentlyContinue) { - Log-Info "Rust is already installed. Version: $(rustc --version)" - Log-Info "Updating Rust toolchain..." - rustup update - } else { - Log-Info "Installing Rust via rustup..." - - # Download and run rustup installer - $rustupUrl = "https://win.rustup.rs/x86_64" - $rustupPath = "$env:TEMP\rustup-init.exe" - - Invoke-WebRequest -Uri $rustupUrl -OutFile $rustupPath - Start-Process -FilePath $rustupPath -ArgumentList "-y" -Wait - - # Refresh environment variables - $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") - } - - # Install required toolchains and components - Log-Info "Installing Rust stable and nightly toolchains..." - rustup install stable - rustup install nightly - rustup default stable - - Log-Info "Installing Rust components..." - rustup component add clippy - rustup component add rustfmt - - # Install wasm-pack - Log-Info "Installing wasm-pack..." - if (!(Get-Command wasm-pack -ErrorAction SilentlyContinue)) { - choco install wasm-pack -y - } else { - Log-Info "wasm-pack is already installed" - } - - Log-Success "Rust toolchain installed and configured" -} - -function Install-NodeJS { - Log-Info "Installing Node.js..." - - if (Get-Command node -ErrorAction SilentlyContinue) { - Log-Info "Node.js is already installed. Version: $(node --version)" - } else { - Log-Info "Installing Node.js via Chocolatey..." - choco install nodejs -y - - # Refresh environment variables - $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") - } - - # Install pnpm - if (!(Get-Command pnpm -ErrorAction SilentlyContinue)) { - Log-Info "Installing pnpm..." - npm install -g pnpm - } - - Log-Success "Node.js and package managers installed" -} - -function Install-AntCLI { - Log-Info "Installing Autonomi CLI (ant)..." - - if (Get-Command ant -ErrorAction SilentlyContinue) { - Log-Info "ant CLI is already installed" - } else { - Log-Info "Installing ant CLI via antup..." - - # Download and run antup installer - $antupUrl = "https://raw.githubusercontent.com/maidsafe/antup/main/install.ps1" - $antupScript = "$env:TEMP\antup-install.ps1" - - try { - Invoke-WebRequest -Uri $antupUrl -OutFile $antupScript - & $antupScript - - # Install the client - if (Get-Command antup -ErrorAction SilentlyContinue) { - antup client - } - } catch { - Log-Warning "Failed to install ant CLI automatically. Please install manually from https://github.com/maidsafe/antup" - } - } - - Log-Success "Autonomi CLI installation completed" -} - -function Build-RustWorkspace { - Log-Info "Building Rust workspace..." - - # Check if we're in the right directory - if (!(Test-Path "Cargo.toml")) { - Log-Error "Cargo.toml not found. Please run this script from the project root." - exit 1 - } - - # Build all workspace members - Log-Info "Building all workspace crates..." - cargo build --workspace - - # Run clippy for code quality - Log-Info "Running clippy for code quality checks..." - cargo clippy --workspace --all-targets --all-features -- -D warnings - - # Format code - Log-Info "Formatting code..." - cargo fmt --all - - Log-Success "Rust workspace built successfully" -} - -function Setup-WebDependencies { - Log-Info "Setting up web dependencies..." - - if (Test-Path "mutant-web") { - Set-Location "mutant-web" - - # Install Node.js dependencies - if (Test-Path "package.json") { - Log-Info "Installing Node.js dependencies with pnpm..." - pnpm install - } - - # Build WASM module - Log-Info "Building WASM module..." - wasm-pack build --target web --out-dir pkg - - Set-Location ".." - Log-Success "Web dependencies setup completed" - } else { - Log-Warning "mutant-web directory not found, skipping web setup" - } -} - -function Setup-DevEnvironment { - Log-Info "Setting up development environment..." - - # Create necessary directories - $configDir = "$env:USERPROFILE\.config\mutant" - if (!(Test-Path $configDir)) { - New-Item -ItemType Directory -Path $configDir -Force | Out-Null - } - - Log-Success "Development environment setup completed" -} - -function Run-Tests { - Log-Info "Running tests to verify installation..." - - # Build tests first - Log-Info "Building tests..." - cargo test --workspace --no-run - - # Run unit tests (skip integration tests that require network) - Log-Info "Running unit tests..." - cargo test --workspace --lib - - Log-Success "Tests completed successfully" -} - -function Main { - Write-Host "==========================================" -ForegroundColor $Blue - Write-Host " MutAnt Project Setup Script (Windows)" -ForegroundColor $Blue - Write-Host "==========================================" -ForegroundColor $Blue - Write-Host "" - - if ($Help) { - Show-Help - return - } - - # Check if running as administrator - if (!(Test-Administrator)) { - Log-Warning "This script should be run as Administrator for best results." - Log-Info "Some installations may fail without administrator privileges." - $continue = Read-Host "Continue anyway? (y/N)" - if ($continue -ne "y" -and $continue -ne "Y") { - Log-Info "Exiting. Please run as Administrator." - return - } - } - - try { - # Install Chocolatey first - Install-Chocolatey - - # Install dependencies - Install-SystemDependencies - Install-Rust - - if (!$SkipWeb) { - Install-NodeJS - } - - if (!$SkipAnt) { - Install-AntCLI - } - - # Build project - Build-RustWorkspace - - if (!$SkipWeb) { - Setup-WebDependencies - } - - # Setup development environment - Setup-DevEnvironment - - # Run tests - if (!$SkipTests) { - Run-Tests - } - - Write-Host "" - Write-Host "==========================================" -ForegroundColor $Green - Log-Success "Setup completed successfully!" - Write-Host "==========================================" -ForegroundColor $Green - Write-Host "" - Write-Host "Next steps:" - Write-Host "1. Restart your PowerShell/Command Prompt to refresh environment variables" - Write-Host "2. Configure ant wallet: ant wallet create (or import existing)" - Write-Host "3. Build and install CLI tools:" - Write-Host " cargo install --path mutant-cli" - Write-Host " cargo install --path mutant-daemon" - Write-Host "4. Start using MutAnt: mutant --help" - Write-Host "" - Write-Host "For development:" - Write-Host "- Build web interface: cd mutant-web && pnpm run build" - Write-Host "- Run tests: cargo test --workspace" - Write-Host "" - - } catch { - Log-Error "Setup failed with error: $($_.Exception.Message)" - Log-Error "Please check the error messages above and try again." - exit 1 - } -} - -# Run main function -Main diff --git a/setup.sh b/setup.sh deleted file mode 100755 index e67f0392..00000000 --- a/setup.sh +++ /dev/null @@ -1,420 +0,0 @@ -#!/bin/bash - -# MutAnt Project Setup Script -# This script sets up all dependencies needed to build and run the MutAnt project - -set -e # Exit on any error - -# Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' # No Color - -# Logging functions -log_info() { - echo -e "${BLUE}[INFO]${NC} $1" -} - -log_success() { - echo -e "${GREEN}[SUCCESS]${NC} $1" -} - -log_warning() { - echo -e "${YELLOW}[WARNING]${NC} $1" -} - -log_error() { - echo -e "${RED}[ERROR]${NC} $1" -} - -# Detect OS -detect_os() { - if [[ "$OSTYPE" == "linux-gnu"* ]]; then - OS="linux" - if command -v apt-get &> /dev/null; then - PACKAGE_MANAGER="apt" - elif command -v yum &> /dev/null; then - PACKAGE_MANAGER="yum" - elif command -v pacman &> /dev/null; then - PACKAGE_MANAGER="pacman" - elif command -v zypper &> /dev/null; then - PACKAGE_MANAGER="zypper" - else - log_error "Unsupported Linux distribution. Please install dependencies manually." - exit 1 - fi - elif [[ "$OSTYPE" == "darwin"* ]]; then - OS="macos" - PACKAGE_MANAGER="brew" - elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then - OS="windows" - PACKAGE_MANAGER="choco" - else - log_error "Unsupported operating system: $OSTYPE" - exit 1 - fi - - log_info "Detected OS: $OS with package manager: $PACKAGE_MANAGER" -} - -# Install system dependencies -install_system_deps() { - log_info "Installing system dependencies..." - - case $PACKAGE_MANAGER in - "apt") - sudo apt-get update -y - sudo apt-get install -y \ - curl \ - git \ - build-essential \ - pkg-config \ - libssl-dev \ - procps \ - wget \ - unzip - ;; - "yum") - sudo yum update -y - sudo yum groupinstall -y "Development Tools" - sudo yum install -y \ - curl \ - git \ - openssl-devel \ - procps-ng \ - wget \ - unzip - ;; - "pacman") - sudo pacman -Syu --noconfirm - sudo pacman -S --noconfirm \ - curl \ - git \ - base-devel \ - openssl \ - procps-ng \ - wget \ - unzip - ;; - "zypper") - sudo zypper refresh - sudo zypper install -y \ - curl \ - git \ - gcc \ - make \ - openssl-devel \ - procps \ - wget \ - unzip - ;; - "brew") - if ! command -v brew &> /dev/null; then - log_info "Installing Homebrew..." - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" - fi - brew update - brew install \ - curl \ - git \ - openssl \ - wget - ;; - "choco") - if ! command -v choco &> /dev/null; then - log_error "Chocolatey not found. Please install Chocolatey first: https://chocolatey.org/install" - exit 1 - fi - choco install -y \ - curl \ - git \ - wget \ - unzip - ;; - esac - - log_success "System dependencies installed" -} - -# Install Rust toolchain -install_rust() { - log_info "Installing Rust toolchain..." - - if command -v rustc &> /dev/null; then - log_info "Rust is already installed. Version: $(rustc --version)" - log_info "Updating Rust toolchain..." - rustup update - else - log_info "Installing Rust via rustup..." - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - source "$HOME/.cargo/env" - fi - - # Ensure we have the latest stable and nightly toolchains - log_info "Installing Rust stable and nightly toolchains..." - rustup install stable - rustup install nightly - rustup default stable - - # Install required components - log_info "Installing Rust components..." - rustup component add clippy - rustup component add rustfmt - - # Install wasm-pack for web builds - log_info "Installing wasm-pack..." - if ! command -v wasm-pack &> /dev/null; then - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - else - log_info "wasm-pack is already installed" - fi - - log_success "Rust toolchain installed and configured" -} - -# Install Node.js and npm -install_nodejs() { - log_info "Installing Node.js..." - - if command -v node &> /dev/null; then - log_info "Node.js is already installed. Version: $(node --version)" - else - case $PACKAGE_MANAGER in - "apt") - curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - - sudo apt-get install -y nodejs - ;; - "yum") - curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash - - sudo yum install -y nodejs npm - ;; - "pacman") - sudo pacman -S --noconfirm nodejs npm - ;; - "zypper") - sudo zypper install -y nodejs npm - ;; - "brew") - brew install node - ;; - "choco") - choco install -y nodejs - ;; - esac - fi - - # Install pnpm if not present - if ! command -v pnpm &> /dev/null; then - log_info "Installing pnpm..." - npm install -g pnpm - fi - - log_success "Node.js and package managers installed" -} - -# Install Autonomi CLI (ant) -install_ant_cli() { - log_info "Installing Autonomi CLI (ant)..." - - if command -v ant &> /dev/null; then - log_info "ant CLI is already installed. Version: $(ant --version 2>/dev/null || echo 'unknown')" - else - log_info "Installing ant CLI via antup..." - curl -sSf https://raw.githubusercontent.com/maidsafe/antup/main/install.sh | sh - - # Add to PATH if not already there - if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then - echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$HOME/.bashrc" - export PATH="$HOME/.local/bin:$PATH" - fi - - # Install the client - if command -v antup &> /dev/null; then - antup client - else - log_warning "antup installation may have failed. Please check manually." - fi - fi - - log_success "Autonomi CLI installation completed" -} - -# Build Rust workspace -build_rust_workspace() { - log_info "Building Rust workspace..." - - # Check if we're in the right directory - if [[ ! -f "Cargo.toml" ]]; then - log_error "Cargo.toml not found. Please run this script from the project root." - exit 1 - fi - - # Build all workspace members - log_info "Building all workspace crates..." - cargo build --workspace - - # Run clippy for code quality - log_info "Running clippy for code quality checks..." - cargo clippy --workspace --all-targets --all-features -- -D warnings - - # Format code - log_info "Formatting code..." - cargo fmt --all - - log_success "Rust workspace built successfully" -} - -# Setup web dependencies -setup_web_dependencies() { - log_info "Setting up web dependencies..." - - if [[ -d "mutant-web" ]]; then - cd mutant-web - - # Install Node.js dependencies - if [[ -f "package.json" ]]; then - log_info "Installing Node.js dependencies with pnpm..." - pnpm install - fi - - # Build WASM module - log_info "Building WASM module..." - wasm-pack build --target web --out-dir pkg - - cd .. - log_success "Web dependencies setup completed" - else - log_warning "mutant-web directory not found, skipping web setup" - fi -} - -# Setup development environment -setup_dev_environment() { - log_info "Setting up development environment..." - - # Make scripts executable - if [[ -d "scripts" ]]; then - chmod +x scripts/*.sh - log_info "Made scripts executable" - fi - - # Create necessary directories - mkdir -p ~/.config/mutant - - log_success "Development environment setup completed" -} - -# Run tests to verify installation -run_tests() { - log_info "Running tests to verify installation..." - - # Build tests first - log_info "Building tests..." - cargo test --workspace --no-run - - # Run unit tests (skip integration tests that require network) - log_info "Running unit tests..." - cargo test --workspace --lib - - log_success "Tests completed successfully" -} - -# Main setup function -main() { - echo "==========================================" - echo " MutAnt Project Setup Script" - echo "==========================================" - echo "" - - # Parse command line arguments - SKIP_TESTS=false - SKIP_WEB=false - SKIP_ANT=false - - while [[ $# -gt 0 ]]; do - case $1 in - --skip-tests) - SKIP_TESTS=true - shift - ;; - --skip-web) - SKIP_WEB=true - shift - ;; - --skip-ant) - SKIP_ANT=true - shift - ;; - --help|-h) - echo "Usage: $0 [OPTIONS]" - echo "" - echo "Options:" - echo " --skip-tests Skip running tests" - echo " --skip-web Skip web dependencies setup" - echo " --skip-ant Skip Autonomi CLI installation" - echo " --help, -h Show this help message" - echo "" - exit 0 - ;; - *) - log_error "Unknown option: $1" - echo "Use --help for usage information" - exit 1 - ;; - esac - done - - # Detect operating system - detect_os - - # Install dependencies - install_system_deps - install_rust - - if [[ "$SKIP_WEB" != true ]]; then - install_nodejs - fi - - if [[ "$SKIP_ANT" != true ]]; then - install_ant_cli - fi - - # Build project - build_rust_workspace - - if [[ "$SKIP_WEB" != true ]]; then - setup_web_dependencies - fi - - # Setup development environment - setup_dev_environment - - # Run tests - if [[ "$SKIP_TESTS" != true ]]; then - run_tests - fi - - echo "" - echo "==========================================" - log_success "Setup completed successfully!" - echo "==========================================" - echo "" - echo "Next steps:" - echo "1. Source your shell configuration: source ~/.bashrc (or restart terminal)" - echo "2. Configure ant wallet: ant wallet create (or import existing)" - echo "3. Build and install CLI tools:" - echo " cargo install --path mutant-cli" - echo " cargo install --path mutant-daemon" - echo "4. Start using MutAnt: mutant --help" - echo "" - echo "For development:" - echo "- Run local testnet: ./scripts/manage_local_testnet.sh start" - echo "- Run integration tests: ./scripts/run_tests_with_env.sh" - echo "- Build web interface: cd mutant-web && pnpm run build" - echo "" -} - -# Run main function -main "$@"