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>
124 lines
4.2 KiB
Bash
Executable File
124 lines
4.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Execute script pruning - move obsolete scripts to archive
|
|
# Usage: ./scripts/prune-scripts-execute.sh [--dry-run]
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
DRY_RUN="${1:---dry-run}"
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
|
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
|
|
log_warn() { echo -e "${YELLOW}[⚠]${NC} $1"; }
|
|
log_error() { echo -e "${RED}[✗]${NC} $1"; }
|
|
|
|
ARCHIVE_DIR="$PROJECT_ROOT/scripts/archive"
|
|
mkdir -p "$ARCHIVE_DIR"/{deprecated,backups,test,duplicates,experimental}
|
|
|
|
# Test scripts - move to archive/test
|
|
log_info "Identifying test scripts..."
|
|
TEST_SCRIPTS=$(find "$PROJECT_ROOT/scripts" -name "*test*.sh" -type f ! -path "*/node_modules/*" ! -path "*/.git/*" ! -path "*/archive/*" | grep -v "test-all\|test-suite\|integration-test" || true)
|
|
|
|
# Backup/old scripts - move to archive/backups
|
|
log_info "Identifying backup/old scripts..."
|
|
BACKUP_SCRIPTS=$(find "$PROJECT_ROOT/scripts" -type f ! -path "*/node_modules/*" ! -path "*/.git/*" ! -path "*/archive/*" \( -iname "*backup*.sh" -o -iname "*old*.sh" -o -iname "*temp*.sh" -o -iname "*deprecated*.sh" \) || true)
|
|
|
|
# Small scripts (< 10 lines) - review
|
|
log_info "Identifying small scripts..."
|
|
SMALL_SCRIPTS=$(find "$PROJECT_ROOT/scripts" -name "*.sh" -type f ! -path "*/node_modules/*" ! -path "*/.git/*" ! -path "*/archive/*" -exec sh -c 'file="$1"; lines=$(wc -l < "$file" 2>/dev/null || echo 0); if [ "$lines" -lt 10 ] && [ "$lines" -gt 0 ]; then echo "$file"; fi' _ {} \; || true)
|
|
|
|
# Count candidates
|
|
TEST_COUNT=$(echo "$TEST_SCRIPTS" | grep -c . || echo 0)
|
|
BACKUP_COUNT=$(echo "$BACKUP_SCRIPTS" | grep -c . || echo 0)
|
|
SMALL_COUNT=$(echo "$SMALL_SCRIPTS" | grep -c . || echo 0)
|
|
|
|
log_info "Found candidates:"
|
|
echo " - Test scripts: $TEST_COUNT"
|
|
echo " - Backup/old scripts: $BACKUP_COUNT"
|
|
echo " - Small scripts: $SMALL_COUNT"
|
|
echo " - Total: $((TEST_COUNT + BACKUP_COUNT + SMALL_COUNT))"
|
|
echo ""
|
|
|
|
if [[ "$DRY_RUN" != "--execute" ]]; then
|
|
log_warn "DRY RUN MODE - No files will be moved"
|
|
log_info "Use --execute to actually move files"
|
|
echo ""
|
|
|
|
log_info "Test scripts to archive:"
|
|
echo "$TEST_SCRIPTS" | head -10 | while read -r script; do
|
|
echo " → archive/test/$(basename "$script")"
|
|
done
|
|
if [ "$TEST_COUNT" -gt 10 ]; then
|
|
echo " ... and $((TEST_COUNT - 10)) more"
|
|
fi
|
|
echo ""
|
|
|
|
log_info "Backup/old scripts to archive:"
|
|
echo "$BACKUP_SCRIPTS" | head -10 | while read -r script; do
|
|
echo " → archive/backups/$(basename "$script")"
|
|
done
|
|
if [ "$BACKUP_COUNT" -gt 10 ]; then
|
|
echo " ... and $((BACKUP_COUNT - 10)) more"
|
|
fi
|
|
echo ""
|
|
|
|
log_info "Small scripts to review:"
|
|
echo "$SMALL_SCRIPTS" | while read -r script; do
|
|
lines=$(wc -l < "$script" 2>/dev/null || echo 0)
|
|
echo " → $script ($lines lines) - REVIEW"
|
|
done
|
|
echo ""
|
|
|
|
log_warn "Run with --execute to move files"
|
|
exit 0
|
|
fi
|
|
|
|
# Execute moves
|
|
log_info "Moving scripts to archive..."
|
|
moved=0
|
|
failed=0
|
|
|
|
# Move test scripts
|
|
if [ "$TEST_COUNT" -gt 0 ]; then
|
|
echo "$TEST_SCRIPTS" | while read -r script; do
|
|
if [ -f "$script" ]; then
|
|
dest="$ARCHIVE_DIR/test/$(basename "$script")"
|
|
if mv "$script" "$dest" 2>/dev/null; then
|
|
log_success "Moved: $(basename "$script")"
|
|
moved=$((moved + 1))
|
|
else
|
|
log_error "Failed: $(basename "$script")"
|
|
failed=$((failed + 1))
|
|
fi
|
|
fi
|
|
done
|
|
fi
|
|
|
|
# Move backup/old scripts
|
|
if [ "$BACKUP_COUNT" -gt 0 ]; then
|
|
echo "$BACKUP_SCRIPTS" | while read -r script; do
|
|
if [ -f "$script" ]; then
|
|
dest="$ARCHIVE_DIR/backups/$(basename "$script")"
|
|
if mv "$script" "$dest" 2>/dev/null; then
|
|
log_success "Moved: $(basename "$script")"
|
|
moved=$((moved + 1))
|
|
else
|
|
log_error "Failed: $(basename "$script")"
|
|
failed=$((failed + 1))
|
|
fi
|
|
fi
|
|
done
|
|
fi
|
|
|
|
log_success "Pruning complete!"
|
|
echo " Moved: $moved"
|
|
echo " Failed: $failed"
|