Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands - CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround - CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check - NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere - MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates - LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference Co-authored-by: Cursor <cursoragent@cursor.com>
3.1 KiB
3.1 KiB
Script Pruning & Modularization - Complete
Last Updated: 2026-01-31
Document Version: 1.0
Status: Active Documentation
Date: 2026-01-22
Status: 🟢 Infrastructure Complete, Ready for Execution
✅ Completed Infrastructure
1. Archive Structure Created
scripts/archive/
├── deprecated/ # Old versions
├── backups/ # Backup scripts
├── test/ # Test scripts
├── duplicates/ # Duplicate functionality
└── experimental/ # Experimental scripts
2. Pruning Script Created
- File:
scripts/prune-scripts-execute.sh - Features:
- Dry-run mode (default)
- Execute mode (--execute)
- Categorizes scripts automatically
- Moves to appropriate archive directories
3. Shared Modules Created
scripts/lib/ip-config.sh
- Centralized IP address loading
- Fallback values if config missing
- Automatic PROJECT_ROOT detection
scripts/lib/logging.sh
- Consistent logging functions
- Color-coded output
- Section headers
- Debug mode support
scripts/lib/proxmox-api.sh
- Proxmox API helper functions
- Container status checks
- List containers
- Token-based authentication
scripts/lib/ssh-helpers.sh
- SSH connection utilities
- Container execution helpers
- Connection testing
- Timeout handling
4. Example Script
- File:
scripts/example-using-modules.sh - Demonstrates module usage
- Shows best practices
📊 Analysis Results
Candidates Identified:
- Test Scripts: 34 scripts
- Backup/Old Scripts: 18 scripts
- Small Scripts: 1 script (< 10 lines)
- Total Candidates: 50+ scripts
Estimated Impact:
- Current: 800 scripts
- After pruning: ~750 scripts (6% reduction)
- After duplicate removal: ~400-500 scripts (30-40% reduction)
🚀 Next Steps
Phase 1: Execute Pruning (Ready)
# Dry run first
./scripts/prune-scripts-execute.sh --dry-run
# Execute pruning
./scripts/prune-scripts-execute.sh --execute
Phase 2: Identify Duplicates
- Compare similar scripts
- Identify common patterns
- Plan consolidation
Phase 3: Update Scripts to Use Modules
- Replace hardcoded IPs with module sourcing
- Replace custom logging with shared module
- Replace SSH code with helpers
Phase 4: Remove Duplicates
- Consolidate similar scripts
- Keep best version
- Archive others
📈 Expected Benefits
Before:
- 800 scripts
- 590 need IP centralization
- Many duplicates
- Inconsistent patterns
After:
- ~400-500 scripts (30-40% reduction)
- ~200-300 need IP centralization (50% reduction)
- Shared modules reduce duplication
- Consistent patterns
- Easier maintenance
🎯 Module Usage Pattern
#!/usr/bin/env bash
set -euo pipefail
# Load shared modules
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/ip-config.sh"
source "$SCRIPT_DIR/lib/logging.sh"
source "$SCRIPT_DIR/lib/proxmox-api.sh"
source "$SCRIPT_DIR/lib/ssh-helpers.sh"
# Use modules
log_info "Using IP: $PROXMOX_HOST_ML110"
check_container_status 5000
Status: ✅ Infrastructure complete, ready for pruning execution