#!/usr/bin/env bash set -euo pipefail # Global MEV Tools Manager # This script provides tools to manage development environments across multiple projects SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" GLOBAL_CONFIG_DIR="$HOME/.config/mev-tools" # Create global config directory mkdir -p "$GLOBAL_CONFIG_DIR" # Function to display usage usage() { echo "Usage: $0 [COMMAND]" echo "Global tools for MEV development" echo "" echo "Commands:" echo " install - Install global tools to PATH" echo " setup-project - Setup a new project with standardized structure" echo " update-tools - Update all global tools" echo " check-env - Check if development environment is properly configured" echo " help - Show this help" echo "" echo "Examples:" echo " $0 install # Install tools to local bin" echo " $0 setup-project my-project # Create new project" } # Function to install global tools install_tools() { echo "Installing global tools..." # Create local bin directory mkdir -p "$HOME/bin" # Copy tools to bin (this script and others) cp "$SCRIPT_DIR/../../scripts/test-runner.sh" "$HOME/bin/test-runner" 2>/dev/null || echo "test-runner not found in expected location" cp "$SCRIPT_DIR/../../scripts/build.sh" "$HOME/bin/build-tool" 2>/dev/null || echo "build-tool not found in expected location" cp "$SCRIPT_DIR/../../scripts/setup-dev.sh" "$HOME/bin/dev-setup" 2>/dev/null || echo "dev-setup not found in expected location" cp "$SCRIPT_DIR/../../scripts/performance-profile.sh" "$HOME/bin/perf-profile" 2>/dev/null || echo "perf-profile not found in expected location" # Make them executable chmod +x "$HOME/bin/test-runner" "$HOME/bin/build-tool" "$HOME/bin/dev-setup" "$HOME/bin/perf-profile" 2>/dev/null || true # Add to PATH if not already there if [[ ":$PATH:" != *":$HOME/bin:"* ]]; then echo "Adding $HOME/bin to PATH..." echo 'export PATH="$HOME/bin:$PATH"' >> "$HOME/.bashrc" echo "Please run 'source ~/.bashrc' or restart your shell to update PATH" fi echo "Tools installed successfully!" echo "Available tools:" echo " test-runner - Universal test runner" echo " build-tool - Universal build tool" echo " dev-setup - Development environment setup" echo " perf-profile - Performance profiling tool" } # Function to setup a new project setup_project() { PROJECT_NAME="${1:-}" if [ -z "$PROJECT_NAME" ]; then echo "Usage: $0 setup-project " exit 1 fi echo "Creating new project: $PROJECT_NAME" "$SCRIPT_DIR/../../scripts/create-project-template.sh" "$PROJECT_NAME" } # Function to update tools update_tools() { echo "Updating global tools..." echo "Note: In a real implementation, this would update tools from a central repository." echo "For now, please manually update the scripts." } # Function to check environment check_env() { echo "Checking development environment..." # Check Go if command -v go &> /dev/null; then echo "✓ Go $(go version | cut -d' ' -f3) installed" else echo "✗ Go not installed" exit 1 fi # Check Git if command -v git &> /dev/null; then echo "✓ Git $(git --version | cut -d' ' -f3) installed" else echo "✗ Git not installed" exit 1 fi # Check for global tools if command -v test-runner &> /dev/null; then echo "✓ test-runner available in PATH" else echo "⚠ test-runner not available in PATH" fi if command -v build-tool &> /dev/null; then echo "✓ build-tool available in PATH" else echo "⚠ build-tool not available in PATH" fi echo "Environment check completed." } # Main command router case "${1:-}" in "install") install_tools ;; "setup-project") setup_project "$2" ;; "update-tools") update_tools ;; "check-env") check_env ;; "help"|"-h"|"--help") usage ;; *) usage if [ $# -gt 0 ]; then exit 1 fi ;; esac