# Scripts Modularization - Implementation Checklist **Date**: 2025-01-27 **Total Scripts**: 30 **Status**: Ready to Begin --- ## ✅ Phase 1: Script Migration (30 scripts) ### Migration Scripts (6 scripts) - [ ] `migrate-readme.sh` → `migration/migrate-readme.sh` - [ ] `migrate-terraform.sh` → `migration/migrate-terraform.sh` - [ ] `migrate-to-api-gateway.sh` → `migration/migrate-to-api-gateway.sh` - [ ] `migrate-to-k8s.sh` → `migration/migrate-to-k8s.sh` - [ ] `migrate-to-monitoring.sh` → `migration/migrate-to-monitoring.sh` - [ ] `migrate-to-shared-packages.sh` → `migration/migrate-to-shared-packages.sh` ### Metrics Scripts (10 scripts) - [ ] `collect-code-metrics.sh` → `metrics/collect/collect-code-metrics.sh` - [ ] `collect-deployment-metrics.sh` → `metrics/collect/collect-deployment-metrics.sh` - [ ] `collect-developer-metrics.sh` → `metrics/collect/collect-developer-metrics.sh` - [ ] `collect-infrastructure-metrics.sh` → `metrics/collect/collect-infrastructure-metrics.sh` - [ ] `collect-operational-metrics.sh` → `metrics/collect/collect-operational-metrics.sh` - [ ] `collect-service-metrics.sh` → `metrics/collect/collect-service-metrics.sh` - [ ] `track-all-metrics.sh` → `metrics/track-all-metrics.sh` - [ ] `track-success-metrics.sh` → `metrics/track-success-metrics.sh` - [ ] `update-metrics.sh` → `metrics/update-metrics.sh` - [ ] `generate-metrics-report.sh` → `metrics/generate-metrics-report.sh` ### DBIS Scripts (4 scripts) - [ ] `automate-dbis-migration.sh` → `dbis/automate-dbis-migration.sh` - [ ] `migrate-all-dbis-projects.sh` → `dbis/migrate-all-dbis-projects.sh` - [ ] `migrate-dbis-project.sh` → `dbis/migrate-dbis-project.sh` - [ ] `test-dbis-migration.sh` → `dbis/test-dbis-migration.sh` ### Infrastructure Scripts (2 scripts) - [ ] `setup-shared-infrastructure.sh` → `infrastructure/setup-shared-infrastructure.sh` - [ ] `setup.sh` → `infrastructure/setup.sh` ### Utility Scripts (8 scripts) - [ ] `analyze-costs.sh` → `utils/analyze-costs.sh` - [ ] `optimize-builds.sh` → `utils/optimize-builds.sh` - [ ] `deps-analyze.sh` → `utils/deps-analyze.sh` - [ ] `deps-audit.sh` → `utils/deps-audit.sh` - [ ] `build-all.sh` → `utils/build-all.sh` - [ ] `test-all.sh` → `utils/test-all.sh` - [ ] `verify-all.sh` → `utils/verify-all.sh` - [ ] `cleanup.sh` → `utils/cleanup.sh` **Command to move all at once:** ```bash cd /home/intlc/projects/scripts mv migrate-readme.sh migrate-terraform.sh migrate-to-*.sh migration/ mv collect-*.sh metrics/collect/ mv track-*.sh update-metrics.sh generate-metrics-report.sh metrics/ mv *dbis*.sh dbis/ mv setup*.sh infrastructure/ mv analyze-costs.sh optimize-builds.sh deps-*.sh build-all.sh test-all.sh verify-all.sh cleanup.sh utils/ ``` --- ## ✅ Phase 2: Update Scripts to Use Libraries (30 scripts) For each script, add this at the top (after shebang): ```bash SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/../lib/init.sh" ``` ### Migration Scripts (6) - [ ] `migration/migrate-readme.sh` - [ ] `migration/migrate-terraform.sh` - [ ] `migration/migrate-to-api-gateway.sh` - [ ] `migration/migrate-to-k8s.sh` - [ ] `migration/migrate-to-monitoring.sh` - [ ] `migration/migrate-to-shared-packages.sh` ### Metrics Scripts (10) - [ ] `metrics/collect/collect-code-metrics.sh` - [ ] `metrics/collect/collect-deployment-metrics.sh` - [ ] `metrics/collect/collect-developer-metrics.sh` - [ ] `metrics/collect/collect-infrastructure-metrics.sh` - [ ] `metrics/collect/collect-operational-metrics.sh` - [ ] `metrics/collect/collect-service-metrics.sh` - [ ] `metrics/track-all-metrics.sh` - [ ] `metrics/track-success-metrics.sh` - [ ] `metrics/update-metrics.sh` - [ ] `metrics/generate-metrics-report.sh` ### DBIS Scripts (4) - [ ] `dbis/automate-dbis-migration.sh` - [ ] `dbis/migrate-all-dbis-projects.sh` - [ ] `dbis/migrate-dbis-project.sh` - [ ] `dbis/test-dbis-migration.sh` ### Infrastructure Scripts (2) - [ ] `infrastructure/setup-shared-infrastructure.sh` - [ ] `infrastructure/setup.sh` ### Utility Scripts (8) - [ ] `utils/analyze-costs.sh` - [ ] `utils/optimize-builds.sh` - [ ] `utils/deps-analyze.sh` - [ ] `utils/deps-audit.sh` - [ ] `utils/build-all.sh` - [ ] `utils/test-all.sh` - [ ] `utils/verify-all.sh` - [ ] `utils/cleanup.sh` **Replace patterns:** - `echo "..."` → `log_info "..."` or `log_error "..."` or `log_success "..."` or `log_warn "..."` - `command -v tool` → `require_command tool` or `check_command tool` - `mkdir -p dir` → `ensure_dir dir` - Add `validate_project_name "$1"` where appropriate - Add `set_error_trap` for error handling --- ## ✅ Phase 3: Update References ### Documentation Files - [ ] `README.md` (project root) - [ ] `QUICK_START_GUIDE.md` - [ ] `PROJECT_INDEX.md` - [ ] `INTEGRATION_TASKS_LIST.md` - [ ] All files in `docs/` directory ### CI/CD Workflows - [ ] `.github/workflows/ci-pilot-template.yml` - [ ] `.github/workflows/publish-shared-packages.yml` - [ ] `.github/workflows/infrastructure-deploy.yml` - [ ] `.github/workflows/metrics-collection.yml` ### Search and Update ```bash # Find all references grep -r "scripts/migrate-to-k8s.sh" . --exclude-dir=node_modules grep -r "scripts/collect-" . --exclude-dir=node_modules grep -r "scripts/track-" . --exclude-dir=node_modules grep -r "scripts/setup.sh" . --exclude-dir=node_modules ``` --- ## ✅ Phase 4: Testing ### Library Tests - [ ] Test `lib/init.sh` loads correctly - [ ] Test each library function individually - [ ] Test logging functions output correctly - [ ] Test validation functions work ### Script Tests - [ ] Test each migration script with `--help` or no args - [ ] Test each metrics script - [ ] Test each DBIS script - [ ] Test each infrastructure script - [ ] Test each utility script ### Integration Tests - [ ] Test scripts from project root - [ ] Test scripts calling other scripts - [ ] Test error handling - [ ] Test input validation ### Make Executable ```bash find scripts -name "*.sh" -exec chmod +x {} \; ``` --- ## ✅ Phase 5: Quality Assurance ### Linting ```bash find scripts -name "*.sh" -exec shellcheck {} \; ``` - [ ] Fix all shellcheck warnings - [ ] Fix syntax errors - [ ] Verify shebang lines ### Consistency - [ ] All scripts use libraries - [ ] All scripts have help text - [ ] All scripts validate inputs - [ ] All scripts use logging functions --- ## ✅ Phase 6: Final Verification - [ ] All 30 scripts moved - [ ] All 30 scripts updated - [ ] All scripts tested - [ ] All documentation updated - [ ] All references updated - [ ] All scripts executable - [ ] No linting errors - [ ] No broken paths --- ## 📊 Progress Summary **Phase 1 (Migration)**: 0/30 (0%) **Phase 2 (Updates)**: 0/30 (0%) **Phase 3 (References)**: 0% **Phase 4 (Testing)**: 0% **Phase 5 (QA)**: 0% **Phase 6 (Verification)**: 0% **Overall Progress**: 0% --- ## 🚀 Quick Start ### 1. Move All Scripts ```bash cd /home/intlc/projects/scripts mv migrate-readme.sh migrate-terraform.sh migrate-to-*.sh migration/ mv collect-*.sh metrics/collect/ mv track-*.sh update-metrics.sh generate-metrics-report.sh metrics/ mv *dbis*.sh dbis/ mv setup*.sh infrastructure/ mv analyze-costs.sh optimize-builds.sh deps-*.sh build-all.sh test-all.sh verify-all.sh cleanup.sh utils/ ``` ### 2. Make All Executable ```bash find scripts -name "*.sh" -exec chmod +x {} \; ``` ### 3. Update First Script (Example) ```bash # Edit migration/migrate-to-k8s.sh # Add after shebang: SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/../lib/init.sh" # Replace echo with log_info, log_error, etc. # Add validate_project_name "$1" ``` ### 4. Test ```bash ./scripts/migration/migrate-to-k8s.sh test-project ``` --- **Status**: Ready to Begin **Next Action**: Start Phase 1 - Move Scripts