Skip to main content
Glama
migrate-project-comprehensive.sh•11.5 kB
#!/bin/bash # EuConquisto Composer MCP - COMPREHENSIVE Project Migration Script # This script handles BOTH file reorganization AND inter-file reference updates set -e PROJECT_ROOT="/Users/ricardokawasaki/Desktop/euconquisto-composer-mcp-poc" BACKUP_DIR="${PROJECT_ROOT}_backup_$(date +%Y%m%d_%H%M%S)" MIGRATION_LOG="${PROJECT_ROOT}/comprehensive-migration.log" cd "$PROJECT_ROOT" echo "šŸ”„ EuConquisto Composer MCP - COMPREHENSIVE Project Migration" echo "==============================================================" echo "šŸ“ Project: $PROJECT_ROOT" echo "šŸ’¾ Backup: $BACKUP_DIR" echo "šŸ“ Log: $MIGRATION_LOG" echo "" echo "āš ļø This script will:" echo " 1. Create full backup" echo " 2. Reorganize file structure" echo " 3. Update ALL inter-file references" echo " 4. Validate the result" echo "" # Confirm before proceeding read -p "Do you want to proceed? (y/N): " -n 1 -r echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then echo "Migration cancelled." exit 1 fi # Initialize log echo "Comprehensive migration started at $(date)" > "$MIGRATION_LOG" # PHASE 1: Create backup and git state echo "šŸ”’ PHASE 1: Creating Backup and Git State" echo "========================================" echo "Creating full project backup..." | tee -a "$MIGRATION_LOG" cp -r "$PROJECT_ROOT" "$BACKUP_DIR" echo "āœ… Backup created: $BACKUP_DIR" | tee -a "$MIGRATION_LOG" # Initialize git if not already initialized if [ ! -d ".git" ]; then git init git add -A git commit -m "Initial commit - pre-migration" else git add -A git commit -m "Pre-migration snapshot" || true fi # Tag current state git tag v4.0.3-pre-migration || true echo "āœ… Git state preserved" | tee -a "$MIGRATION_LOG" # PHASE 2: Create directory structure echo "" echo "šŸ“ PHASE 2: Creating Clean Directory Structure" echo "=============================================" # Create directories mkdir -p bin config archive/legacy logs temp mkdir -p src/server src/content src/browser src/auth src/types src/utils mkdir -p tests/unit tests/integration tests/e2e echo "āœ… Directory structure created" | tee -a "$MIGRATION_LOG" # PHASE 3: File migration with reference tracking echo "" echo "šŸ“¦ PHASE 3: File Migration with Reference Tracking" echo "=================================================" # Move executable scripts to bin/ echo "Moving executable scripts to bin/" | tee -a "$MIGRATION_LOG" for script in start-*.sh; do if [ -f "$script" ]; then echo " Moving $script to bin/" | tee -a "$MIGRATION_LOG" mv "$script" "bin/" fi done # Move configuration files to config/ echo "Moving configuration files to config/" | tee -a "$MIGRATION_LOG" [ -f "claude-desktop-config.json" ] && mv "claude-desktop-config.json" "config/" [ -f "claude-desktop-config-working.json" ] && mv "claude-desktop-config-working.json" "config/" [ -f "project.json" ] && mv "project.json" "config/" # Archive versioned files echo "Archiving versioned files..." | tee -a "$MIGRATION_LOG" for file in *-v*.* *-fixed.* *-clean.* *-BACKUP.*; do if [ -f "$file" ]; then echo " Archiving $file" | tee -a "$MIGRATION_LOG" mv "$file" "archive/legacy/" fi done # Archive versioned files from dist/ if [ -d "dist" ]; then for file in dist/*-v*.* dist/*-fixed.* dist/*-clean.* dist/*-BACKUP.*; do if [ -f "$file" ]; then echo " Archiving $(basename "$file")" | tee -a "$MIGRATION_LOG" mv "$file" "archive/legacy/" fi done fi # Move test files from root echo "Moving test files to tests/" | tee -a "$MIGRATION_LOG" for test in test-*.js test-*.json; do if [ -f "$test" ]; then echo " Moving $test to tests/" | tee -a "$MIGRATION_LOG" mv "$test" "tests/" fi done # Move composition examples to archive for comp in *composition*.js *composition*.json; do if [ -f "$comp" ]; then echo " Moving $comp to archive/" | tee -a "$MIGRATION_LOG" mv "$comp" "archive/" fi done # Move debug files to logs/ for debug in debug-*.png *.webm; do if [ -f "$debug" ]; then echo " Moving $debug to logs/" | tee -a "$MIGRATION_LOG" mv "$debug" "logs/" fi done # Archive poorly organized directories for dir in dist-clean dist-test fixes integration preview; do if [ -d "$dir" ]; then echo " Archiving directory $dir" | tee -a "$MIGRATION_LOG" mv "$dir" "archive/" fi done # Move miscellaneous files [ -f "final-validation-test.js" ] && mv "final-validation-test.js" "tests/" [ -f "create-ballistics-lesson.js" ] && mv "create-ballistics-lesson.js" "archive/" # Archive duplicate documentation in root for doc in CLAUDE-DESKTOP-*.md MIGRATION-STATUS.md PRODUCTION-READY.md PROJECT-ORGANIZATION.md REFERENCE-FIXES.md; do if [ -f "$doc" ]; then echo " Archiving $doc" | tee -a "$MIGRATION_LOG" mv "$doc" "archive/" fi done # PHASE 4: Create .gitignore echo "" echo "🚫 PHASE 4: Creating .gitignore" echo "==============================" cat > .gitignore << 'EOF' # Dependencies node_modules/ npm-debug.log* yarn-debug.log* yarn-error.log* # Build outputs dist/ build/ # Runtime data logs/ *.log temp/ *.tmp # Environment variables .env .env.local .env.development.local .env.test.local .env.production.local # IDE files .vscode/ .idea/ *.swp *.swo *~ # OS generated files .DS_Store .DS_Store? ._* .Spotlight-V100 .Trashes ehthumbs.db Thumbs.db # Debug files debug-*.png *.webm screenshots/ # Test outputs coverage/ .nyc_output/ # Temporary test files test-composition-*.json *-temp.* # Browser automation artifacts playwright-report/ test-results/ # JWT tokens (security) *jwt*.txt *.pem *.key # Backup files *-backup.* *.backup *.ref-backup # Migration files *_backup_* migration*.log reference-updates.log EOF echo "āœ… .gitignore created" | tee -a "$MIGRATION_LOG" # PHASE 5: Update ALL inter-file references echo "" echo "šŸ”— PHASE 5: Updating Inter-File References" echo "=========================================" # Update package.json echo "Updating package.json..." | tee -a "$MIGRATION_LOG" cp package.json package.json.backup sed -i.tmp 's|"main": ".*"|"main": "dist/browser-automation-api-direct-save-v4.0.3.js"|' package.json sed -i.tmp 's|start-\([^"]*\)\.sh|bin/start-\1.sh|g' package.json rm -f package.json.tmp # Update TypeScript imports in src/ echo "Updating TypeScript imports..." | tee -a "$MIGRATION_LOG" find src -name "*.ts" -o -name "*.js" | while read -r file; do if grep -q "from ['\"]\./" "$file" 2>/dev/null; then # Most imports within src/ should remain the same since we're not restructuring src/ internally # But update any references that might be broken sed -i.tmp "s|from ['\"]\.\/lib\/|from \"./lib/|g" "$file" sed -i.tmp "s|from ['\"]\.\/interfaces\/|from \"./interfaces/|g" "$file" sed -i.tmp "s|from ['\"]\.\/utils\/|from \"./utils/|g" "$file" rm -f "${file}.tmp" fi done # Update shell scripts in bin/ echo "Updating shell scripts..." | tee -a "$MIGRATION_LOG" for script in bin/*.sh; do if [ -f "$script" ]; then sed -i.tmp 's|node dist/|node ../dist/|g' "$script" sed -i.tmp 's|npx tsx src/|npx tsx ../src/|g' "$script" sed -i.tmp 's|node tools/servers/|node ../tools/servers/|g' "$script" sed -i.tmp 's|tools/servers/jwt-redirect-server|../tools/servers/jwt-redirect-server|g' "$script" rm -f "${script}.tmp" fi done # Update configuration files echo "Updating configuration files..." | tee -a "$MIGRATION_LOG" for config in config/*.json; do if [ -f "$config" ]; then sed -i.tmp 's|/start-working-implementation.sh|/bin/start-working-implementation.sh|g' "$config" sed -i.tmp 's|/start-mcp-|/bin/start-mcp-|g' "$config" rm -f "${config}.tmp" fi done # Update tool scripts echo "Updating tool scripts..." | tee -a "$MIGRATION_LOG" for tool in tools/**/*.js tools/**/*.ts tools/*.js; do if [ -f "$tool" ]; then sed -i.tmp 's|from.*"\./dist/|from "../../dist/|g' "$tool" sed -i.tmp "s|require('\./dist/|require('../../dist/|g" "$tool" sed -i.tmp 's|from.*"\./src/|from "../../src/|g' "$tool" sed -i.tmp "s|require('\./src/|require('../../src/|g" "$tool" rm -f "${tool}.tmp" fi done # Update test files echo "Updating test files..." | tee -a "$MIGRATION_LOG" for test in tests/**/*.js tests/**/*.ts tests/*.js tests/*.ts; do if [ -f "$test" ]; then sed -i.tmp 's|from.*"\.\.\/src\/|from "../src/|g' "$test" sed -i.tmp "s|require('\.\.\/src\/|require('../src/|g" "$test" rm -f "${test}.tmp" fi done # Update specific critical files if [ -f "tools/validate-mcp-server.js" ]; then sed -i.tmp 's|dist/index.js|../dist/index.js|g' "tools/validate-mcp-server.js" sed -i.tmp 's|src/index.ts|../src/index.ts|g' "tools/validate-mcp-server.js" rm -f "tools/validate-mcp-server.js.tmp" fi echo "āœ… Inter-file references updated" | tee -a "$MIGRATION_LOG" # PHASE 6: Validation echo "" echo "āœ… PHASE 6: Validation" echo "=====================" # Check if main entry point exists main_entry=$(node -p "require('./package.json').main" 2>/dev/null) if [ -f "$main_entry" ]; then echo "āœ… Package.json main entry point exists: $main_entry" | tee -a "$MIGRATION_LOG" else echo "āŒ Package.json main entry point missing: $main_entry" | tee -a "$MIGRATION_LOG" fi # Check if startup scripts exist for script in bin/*.sh; do if [ -f "$script" ] && [ -x "$script" ]; then echo "āœ… Startup script is executable: $script" | tee -a "$MIGRATION_LOG" else echo "āŒ Startup script issue: $script" | tee -a "$MIGRATION_LOG" fi done # PHASE 7: Git commit echo "" echo "šŸ’¾ PHASE 7: Git Commit" echo "=====================" git add -A git commit -m "feat: comprehensive project reorganization - Reorganized file structure following Node.js best practices - Updated ALL inter-file references (imports, configs, scripts) - Created proper .gitignore - Archived versioned files to archive/legacy/ - Updated package.json entry points - Fixed shell script paths - Updated configuration file references - Validated all critical file paths This is a comprehensive migration that maintains all functionality while providing a clean, maintainable project structure." git tag v4.1.0-comprehensive-migration echo "āœ… Changes committed and tagged" | tee -a "$MIGRATION_LOG" # PHASE 8: Final summary echo "" echo "šŸŽ‰ COMPREHENSIVE MIGRATION COMPLETED" echo "==================================" echo "āœ… Backup created: $BACKUP_DIR" echo "āœ… Files reorganized and references updated" echo "āœ… Git tagged: v4.1.0-comprehensive-migration" echo "āœ… All inter-file references handled" echo "" echo "šŸ“Š Summary:" echo " - Root files: $(find . -maxdepth 1 -type f | wc -l) (should be ~10-15)" echo " - Archived files: $(find archive -type f | wc -l)" echo " - Executable scripts: $(find bin -type f | wc -l)" echo " - Configuration files: $(find config -type f | wc -l)" echo "" echo "šŸ”„ Next Steps:" echo "1. Test functionality: bin/start-working-implementation.sh" echo "2. Update Claude Desktop config: config/claude-desktop-working.json" echo "3. Verify all imports and references work correctly" echo "4. Remove backup directory after successful testing" echo "" echo "šŸ“ Complete log: $MIGRATION_LOG" echo "Comprehensive migration completed at $(date)" >> "$MIGRATION_LOG"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rkm097git/euconquisto-composer-mcp-poc'

If you have feedback or need assistance with the MCP directory API, please join our Discord server