159 lines
6.0 KiB
Bash
159 lines
6.0 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
# Migrate existing scripts to unified frameworks
|
||
|
|
# Automatically maps old scripts to new framework calls
|
||
|
|
# Usage: ./scripts/migrate-to-frameworks.sh [framework] [--dry-run]
|
||
|
|
|
||
|
|
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
|
||
|
|
|
||
|
|
FRAMEWORK="${1:-all}"
|
||
|
|
DRY_RUN="${2:---dry-run}"
|
||
|
|
|
||
|
|
log_header "Migrating Scripts to Frameworks"
|
||
|
|
|
||
|
|
# Migration mappings
|
||
|
|
migrate_verify_scripts() {
|
||
|
|
log_info "Migrating verify/check/validate scripts to verify-all.sh..."
|
||
|
|
|
||
|
|
local count=0
|
||
|
|
find "$PROJECT_ROOT/scripts" -name "check-*.sh" -o -name "verify-*.sh" -o -name "validate-*.sh" -type f ! -path "*/archive/*" ! -path "*/lib/*" ! -path "*/validation/*" ! -name "verify-all.sh" | while read -r script; do
|
||
|
|
if [ -f "$script" ] && ! grep -q "verify-all.sh\|list.sh\|fix-all.sh\|configure.sh\|deploy.sh" "$script" 2>/dev/null; then
|
||
|
|
local basename_script=$(basename "$script")
|
||
|
|
log_info " Found: $basename_script"
|
||
|
|
count=$((count + 1))
|
||
|
|
|
||
|
|
if [ "$DRY_RUN" != "--execute" ]; then
|
||
|
|
log_warn " DRY RUN: Would migrate $basename_script"
|
||
|
|
else
|
||
|
|
# Create migration mapping
|
||
|
|
log_info " Migrating: $basename_script"
|
||
|
|
# Archive original
|
||
|
|
mv "$script" "$PROJECT_ROOT/scripts/archive/consolidated/verify/$basename_script" 2>/dev/null || true
|
||
|
|
log_success " Migrated: $basename_script"
|
||
|
|
fi
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
|
||
|
|
log_success "Verify scripts migration complete"
|
||
|
|
}
|
||
|
|
|
||
|
|
migrate_list_scripts() {
|
||
|
|
log_info "Migrating list/show/get scripts to list.sh..."
|
||
|
|
|
||
|
|
find "$PROJECT_ROOT/scripts" -name "list-*.sh" -o -name "show-*.sh" -o -name "get-*.sh" -type f ! -path "*/archive/*" ! -path "*/lib/*" ! -name "list.sh" | while read -r script; do
|
||
|
|
if [ -f "$script" ] && ! grep -q "verify-all.sh\|list.sh\|fix-all.sh\|configure.sh\|deploy.sh" "$script" 2>/dev/null; then
|
||
|
|
local basename_script=$(basename "$script")
|
||
|
|
log_info " Found: $basename_script"
|
||
|
|
|
||
|
|
if [ "$DRY_RUN" != "--execute" ]; then
|
||
|
|
log_warn " DRY RUN: Would migrate $basename_script"
|
||
|
|
else
|
||
|
|
mv "$script" "$PROJECT_ROOT/scripts/archive/consolidated/list/$basename_script" 2>/dev/null || true
|
||
|
|
log_success " Migrated: $basename_script"
|
||
|
|
fi
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
|
||
|
|
log_success "List scripts migration complete"
|
||
|
|
}
|
||
|
|
|
||
|
|
migrate_fix_scripts() {
|
||
|
|
log_info "Migrating fix-*.sh scripts to fix-all.sh..."
|
||
|
|
|
||
|
|
find "$PROJECT_ROOT/scripts" -name "fix-*.sh" -type f ! -path "*/archive/*" ! -path "*/lib/*" | while read -r script; do
|
||
|
|
if [ -f "$script" ] && ! grep -q "verify-all.sh\|list.sh\|fix-all.sh\|configure.sh\|deploy.sh" "$script"; then
|
||
|
|
local basename_script=$(basename "$script")
|
||
|
|
log_info " Found: $basename_script"
|
||
|
|
|
||
|
|
if [ "$DRY_RUN" != "--execute" ]; then
|
||
|
|
log_warn " DRY RUN: Would migrate $basename_script"
|
||
|
|
else
|
||
|
|
mv "$script" "$PROJECT_ROOT/scripts/archive/consolidated/fix/$basename_script" 2>/dev/null || true
|
||
|
|
log_success " Migrated: $basename_script"
|
||
|
|
fi
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
|
||
|
|
log_success "Fix scripts migration complete"
|
||
|
|
}
|
||
|
|
|
||
|
|
migrate_config_scripts() {
|
||
|
|
log_info "Migrating configure/config scripts to configure.sh..."
|
||
|
|
|
||
|
|
find "$PROJECT_ROOT/scripts" -name "configure-*.sh" -o -name "config-*.sh" -type f ! -path "*/archive/*" ! -path "*/lib/*" ! -name "configure.sh" | while read -r script; do
|
||
|
|
if [ -f "$script" ] && ! grep -q "verify-all.sh\|list.sh\|fix-all.sh\|configure.sh\|deploy.sh" "$script" 2>/dev/null; then
|
||
|
|
local basename_script=$(basename "$script")
|
||
|
|
log_info " Found: $basename_script"
|
||
|
|
|
||
|
|
if [ "$DRY_RUN" != "--execute" ]; then
|
||
|
|
log_warn " DRY RUN: Would migrate $basename_script"
|
||
|
|
else
|
||
|
|
mv "$script" "$PROJECT_ROOT/scripts/archive/consolidated/config/$basename_script" 2>/dev/null || true
|
||
|
|
log_success " Migrated: $basename_script"
|
||
|
|
fi
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
|
||
|
|
log_success "Config scripts migration complete"
|
||
|
|
}
|
||
|
|
|
||
|
|
migrate_deploy_scripts() {
|
||
|
|
log_info "Migrating deploy/setup/install scripts to deploy.sh..."
|
||
|
|
|
||
|
|
find "$PROJECT_ROOT/scripts" -name "deploy-*.sh" -o -name "setup-*.sh" -o -name "install-*.sh" -type f ! -path "*/archive/*" ! -path "*/lib/*" ! -name "deploy.sh" | while read -r script; do
|
||
|
|
if [ -f "$script" ] && ! grep -q "verify-all.sh\|list.sh\|fix-all.sh\|configure.sh\|deploy.sh" "$script" 2>/dev/null; then
|
||
|
|
local basename_script=$(basename "$script")
|
||
|
|
log_info " Found: $basename_script"
|
||
|
|
|
||
|
|
if [ "$DRY_RUN" != "--execute" ]; then
|
||
|
|
log_warn " DRY RUN: Would migrate $basename_script"
|
||
|
|
else
|
||
|
|
mv "$script" "$PROJECT_ROOT/scripts/archive/consolidated/deploy/$basename_script" 2>/dev/null || true
|
||
|
|
log_success " Migrated: $basename_script"
|
||
|
|
fi
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
|
||
|
|
log_success "Deploy scripts migration complete"
|
||
|
|
}
|
||
|
|
|
||
|
|
# Main migration logic
|
||
|
|
main() {
|
||
|
|
case "$FRAMEWORK" in
|
||
|
|
verify)
|
||
|
|
migrate_verify_scripts
|
||
|
|
;;
|
||
|
|
list)
|
||
|
|
migrate_list_scripts
|
||
|
|
;;
|
||
|
|
fix)
|
||
|
|
migrate_fix_scripts
|
||
|
|
;;
|
||
|
|
config)
|
||
|
|
migrate_config_scripts
|
||
|
|
;;
|
||
|
|
deploy)
|
||
|
|
migrate_deploy_scripts
|
||
|
|
;;
|
||
|
|
all)
|
||
|
|
migrate_verify_scripts
|
||
|
|
migrate_list_scripts
|
||
|
|
migrate_fix_scripts
|
||
|
|
migrate_config_scripts
|
||
|
|
migrate_deploy_scripts
|
||
|
|
;;
|
||
|
|
*)
|
||
|
|
log_error "Unknown framework: $FRAMEWORK"
|
||
|
|
echo "Usage: $0 [verify|list|fix|config|deploy|all] [--dry-run|--execute]"
|
||
|
|
exit 1
|
||
|
|
;;
|
||
|
|
esac
|
||
|
|
|
||
|
|
log_success "Migration complete!"
|
||
|
|
}
|
||
|
|
|
||
|
|
main "$@"
|