Files
proxmox/scripts/analyze-reduction-potential.sh
defiQUG fbda1b4beb
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
docs: Ledger Live integration, contract deploy learnings, NEXT_STEPS updates
- 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>
2026-02-12 15:46:57 -08:00

167 lines
5.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Analyze potential for further script reduction
# Identifies consolidation opportunities
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
source "$SCRIPT_DIR/lib/logging.sh" 2>/dev/null || true
OUTPUT_FILE="${PROJECT_ROOT}/docs/00-meta/SCRIPT_REDUCTION_POTENTIAL.md"
log_header "Analyzing Script Reduction Potential"
# Count scripts by category
FIX_SCRIPTS=$(find "$PROJECT_ROOT/scripts" -name "fix-*.sh" -type f ! -path "*/archive/*" | wc -l)
CHECK_SCRIPTS=$(find "$PROJECT_ROOT/scripts" -name "check-*.sh" -o -name "verify-*.sh" -o -name "validate-*.sh" -type f ! -path "*/archive/*" | wc -l)
LIST_SCRIPTS=$(find "$PROJECT_ROOT/scripts" -name "list-*.sh" -o -name "show-*.sh" -o -name "get-*.sh" -type f ! -path "*/archive/*" | wc -l)
DEPLOY_SCRIPTS=$(find "$PROJECT_ROOT/scripts" -name "deploy-*.sh" -o -name "setup-*.sh" -o -name "install-*.sh" -type f ! -path "*/archive/*" | wc -l)
CONFIG_SCRIPTS=$(find "$PROJECT_ROOT/scripts" -name "configure-*.sh" -o -name "config-*.sh" -type f ! -path "*/archive/*" | wc -l)
MIGRATE_SCRIPTS=$(find "$PROJECT_ROOT/scripts" -name "migrate-*.sh" -type f ! -path "*/archive/*" | wc -l)
SMALL_SCRIPTS=$(find "$PROJECT_ROOT/scripts" -name "*.sh" -type f ! -path "*/node_modules/*" ! -path "*/.git/*" ! -path "*/archive/*" ! -path "*/lib/*" -exec sh -c 'file="$1"; lines=$(wc -l < "$file" 2>/dev/null || echo 0); if [ "$lines" -lt 50 ] && [ "$lines" -gt 0 ]; then echo "$file"; fi' _ {} \; | wc -l)
TOTAL=$(find "$PROJECT_ROOT/scripts" -name "*.sh" -type f ! -path "*/node_modules/*" ! -path "*/.git/*" ! -path "*/archive/*" ! -path "*/lib/*" | wc -l)
cat > "$OUTPUT_FILE" <<EOF
# Script Reduction Potential Analysis
**Date:** $(date +%Y-%m-%d)
**Current Total:** $TOTAL active scripts
**Goal:** Further reduce through consolidation and modularization
---
## Current Breakdown
- **Fix Scripts:** $FIX_SCRIPTS
- **Check/Verify Scripts:** $CHECK_SCRIPTS
- **List/Show Scripts:** $LIST_SCRIPTS
- **Deploy/Setup Scripts:** $DEPLOY_SCRIPTS
- **Config Scripts:** $CONFIG_SCRIPTS
- **Migrate Scripts:** $MIGRATE_SCRIPTS
- **Small Scripts (< 50 lines):** $SMALL_SCRIPTS
---
## Reduction Opportunities
### 1. Fix Scripts Consolidation ($FIX_SCRIPTS scripts)
**Opportunity:** Many fix scripts could be consolidated into:
- \`fix-all-issues.sh\` - Master fix script
- \`fix-service-issues.sh\` - Service-specific fixes
- \`fix-network-issues.sh\` - Network fixes
- \`fix-config-issues.sh\` - Configuration fixes
**Potential Reduction:** 50-70% (consolidate similar fixes)
### 2. Check/Verify Scripts Consolidation ($CHECK_SCRIPTS scripts)
**Opportunity:** Create unified verification framework:
- \`verify-all.sh\` - Master verification script
- \`verify-service.sh [service]\` - Service-specific verification
- \`verify-network.sh\` - Network verification
- \`verify-config.sh\` - Configuration verification
**Potential Reduction:** 60-80% (use parameters instead of separate scripts)
### 3. List/Show Scripts Consolidation ($LIST_SCRIPTS scripts)
**Opportunity:** Create unified listing tool:
- \`list.sh [type] [filter]\` - Unified listing with parameters
- Types: vms, containers, services, networks, configs
**Potential Reduction:** 70-90% (single script with parameters)
### 4. Deploy/Setup Scripts Consolidation ($DEPLOY_SCRIPTS scripts)
**Opportunity:** Create deployment framework:
- \`deploy.sh [component] [options]\` - Unified deployment
- \`setup.sh [component] [options]\` - Unified setup
**Potential Reduction:** 40-60% (framework with component selection)
### 5. Config Scripts Consolidation ($CONFIG_SCRIPTS scripts)
**Opportunity:** Create configuration framework:
- \`configure.sh [component] [action]\` - Unified configuration
- Use shared configuration modules
**Potential Reduction:** 50-70% (framework approach)
### 6. Small Scripts (< 50 lines) ($SMALL_SCRIPTS scripts)
**Opportunity:** Many small scripts could be:
- Merged into larger utility scripts
- Converted to functions in shared modules
- Combined with similar functionality
**Potential Reduction:** 30-50% (merge into utilities)
---
## Estimated Total Reduction
**Conservative Estimate:**
- Fix scripts: 50% reduction
- Check scripts: 60% reduction
- List scripts: 70% reduction
- Deploy scripts: 40% reduction
- Config scripts: 50% reduction
- Small scripts: 30% reduction
**Total Potential Reduction:** ~200-300 scripts (25-40%)
**Target:** 460-560 scripts (from 760)
---
## Implementation Strategy
### Phase 1: Create Unified Frameworks
1. Create \`verify-all.sh\` with service/component parameters
2. Create \`list.sh\` with type/filter parameters
3. Create \`fix-all.sh\` with issue-type parameters
4. Create \`configure.sh\` with component/action parameters
### Phase 2: Migrate to Frameworks
1. Identify scripts that fit framework patterns
2. Convert to function calls or parameters
3. Archive original scripts
4. Update documentation
### Phase 3: Merge Small Scripts
1. Group small scripts by functionality
2. Merge into utility scripts
3. Create shared function libraries
4. Archive originals
### Phase 4: Final Cleanup
1. Remove truly obsolete scripts
2. Consolidate remaining duplicates
3. Update all references
4. Final verification
---
## Benefits
1. **Easier Maintenance** - Fewer scripts to maintain
2. **Consistent Patterns** - Unified interfaces
3. **Better Documentation** - Clearer structure
4. **Faster Development** - Reusable frameworks
5. **Reduced Complexity** - Simpler codebase
---
**Status:** Analysis complete, ready for consolidation planning
EOF
log_success "Analysis complete: $OUTPUT_FILE"
echo ""
log_info "Summary:"
echo " - Total scripts: $TOTAL"
echo " - Potential reduction: 200-300 scripts (25-40%)"
echo " - Target: 460-560 scripts"