Files
scripts/verify-structure.sh
2026-02-09 21:51:52 -08:00

78 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
# Verify scripts directory structure
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/init.sh"
log_heading "Verifying Scripts Structure"
errors=0
# Check directories exist
for dir in migration metrics metrics/collect dbis infrastructure utils lib lib/common lib/config; do
if [ -d "$SCRIPT_DIR/$dir" ]; then
log_success "Directory exists: $dir"
else
log_error "Directory missing: $dir"
((errors++))
fi
done
# Check library files
for lib in lib/common/colors.sh lib/common/logging.sh lib/common/utils.sh lib/common/validation.sh lib/common/error-handling.sh lib/config/env.sh lib/init.sh; do
if [ -f "$SCRIPT_DIR/$lib" ]; then
log_success "Library exists: $lib"
else
log_error "Library missing: $lib"
((errors++))
fi
done
# Count scripts
migration_count=$(find "$SCRIPT_DIR/migration" -name "*.sh" 2>/dev/null | wc -l)
metrics_count=$(find "$SCRIPT_DIR/metrics" -name "*.sh" 2>/dev/null | wc -l)
dbis_count=$(find "$SCRIPT_DIR/dbis" -name "*.sh" 2>/dev/null | wc -l)
infra_count=$(find "$SCRIPT_DIR/infrastructure" -name "*.sh" 2>/dev/null | wc -l)
utils_count=$(find "$SCRIPT_DIR/utils" -name "*.sh" 2>/dev/null | wc -l)
total=$((migration_count + metrics_count + dbis_count + infra_count + utils_count))
log_info "Script counts:"
log_info " Migration: $migration_count"
log_info " Metrics: $metrics_count"
log_info " DBIS: $dbis_count"
log_info " Infrastructure: $infra_count"
log_info " Utils: $utils_count"
log_info " Total: $total"
if [ $total -eq 30 ]; then
log_success "All 30 scripts found"
else
log_error "Expected 30 scripts, found $total"
((errors++))
fi
# Check scripts are executable (exclude verification script itself)
executable_count=$(find "$SCRIPT_DIR" -name "*.sh" -type f ! -path "*/lib/*" ! -name "verify-structure.sh" -executable 2>/dev/null | wc -l)
if [ $executable_count -eq $total ]; then
log_success "All scripts are executable"
else
log_error "Expected $total executable scripts, found $executable_count"
((errors++))
fi
# Check scripts use libraries (exclude verification script itself)
scripts_with_libs=$(grep -r "source.*lib/init.sh" "$SCRIPT_DIR" --include="*.sh" ! -path "*/lib/*" ! -name "verify-structure.sh" 2>/dev/null | wc -l)
if [ $scripts_with_libs -eq $total ]; then
log_success "All scripts use libraries"
else
log_warn "Some scripts may not use libraries: $scripts_with_libs/$total"
fi
if [ $errors -eq 0 ]; then
log_success "Verification complete - All checks passed!"
exit 0
else
log_error "Verification failed - $errors errors found"
exit 1
fi