Major Changes: - NEW: Scripts 09 & 10 for KPI calculation and enhanced reporting - NEW: Shell script wrappers (01-10) for easier execution - NEW: R packages flextable and officer for enhanced Word reports - NEW: DEPLOYMENT_README.md with complete deployment guide - RENAMED: Numbered R scripts (02, 03, 04) for clarity - REMOVED: Old package management scripts (using renv only) - UPDATED: Workflow now uses scripts 09->10 instead of 05 Files Changed: 90+ files New Packages: flextable, officer New Scripts: 09_run_calculate_kpis.sh, 10_run_kpi_report.sh Documentation: DEPLOYMENT_README.md, EMAIL_TO_ADMIN.txt See DEPLOYMENT_README.md for full deployment instructions.
208 lines
6.8 KiB
PowerShell
208 lines
6.8 KiB
PowerShell
# SmartCane Repository Cleanup Script
|
|
# This script will delete unnecessary files and move experimental scripts
|
|
# Review this script before running: .\cleanup_repo.ps1
|
|
|
|
Write-Host "🧹 SmartCane Repository Cleanup" -ForegroundColor Cyan
|
|
Write-Host "================================" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
$deletedCount = 0
|
|
$movedCount = 0
|
|
$errors = @()
|
|
|
|
# ============================================================================
|
|
# PART 1: DELETE FILES
|
|
# ============================================================================
|
|
|
|
Write-Host "📁 PART 1: Deleting files..." -ForegroundColor Yellow
|
|
Write-Host ""
|
|
|
|
# A) Test & Debug Scripts
|
|
$testFiles = @(
|
|
"r_app/test_benchmarks.R",
|
|
"r_app/test_harvest.R",
|
|
"r_app/test_kpis_esa.R",
|
|
"r_app/debug_kpis.R",
|
|
"r_app/quick_layout_test.R",
|
|
"r_app/run_minimal_test.R"
|
|
)
|
|
|
|
Write-Host "Deleting test and debug scripts..." -ForegroundColor Gray
|
|
foreach ($file in $testFiles) {
|
|
if (Test-Path $file) {
|
|
Remove-Item $file -Force
|
|
Write-Host " ✓ Deleted: $file" -ForegroundColor Green
|
|
$deletedCount++
|
|
} else {
|
|
Write-Host " ⚠ Not found: $file" -ForegroundColor DarkGray
|
|
}
|
|
}
|
|
|
|
# B) Output Files (.Rout)
|
|
$routFiles = @(
|
|
"r_app/02_ci_extraction.Rout",
|
|
"r_app/03_interpolate_growth_model.Rout",
|
|
"r_app/04_mosaic_creation.Rout"
|
|
)
|
|
|
|
Write-Host "`nDeleting .Rout files..." -ForegroundColor Gray
|
|
foreach ($file in $routFiles) {
|
|
if (Test-Path $file) {
|
|
Remove-Item $file -Force
|
|
Write-Host " ✓ Deleted: $file" -ForegroundColor Green
|
|
$deletedCount++
|
|
} else {
|
|
Write-Host " ⚠ Not found: $file" -ForegroundColor DarkGray
|
|
}
|
|
}
|
|
|
|
# C) Temporary PDF Files
|
|
$pdfFiles = @(
|
|
"Rplots.pdf",
|
|
"r_app/Rplots.pdf"
|
|
)
|
|
|
|
Write-Host "`nDeleting temporary PDF files..." -ForegroundColor Gray
|
|
foreach ($file in $pdfFiles) {
|
|
if (Test-Path $file) {
|
|
Remove-Item $file -Force
|
|
Write-Host " ✓ Deleted: $file" -ForegroundColor Green
|
|
$deletedCount++
|
|
} else {
|
|
Write-Host " ⚠ Not found: $file" -ForegroundColor DarkGray
|
|
}
|
|
}
|
|
|
|
# D) Old/Deprecated Scripts
|
|
$oldScripts = @(
|
|
"r_app/ci_extraction.R",
|
|
"r_app/interpolate_growth_model.R",
|
|
"r_app/mosaic_creation.R",
|
|
"r_app/installPackages.R",
|
|
"r_app/packages.R",
|
|
"generated_package_config.R"
|
|
)
|
|
|
|
Write-Host "`nDeleting old/deprecated scripts..." -ForegroundColor Gray
|
|
foreach ($file in $oldScripts) {
|
|
if (Test-Path $file) {
|
|
Remove-Item $file -Force
|
|
Write-Host " ✓ Deleted: $file" -ForegroundColor Green
|
|
$deletedCount++
|
|
} else {
|
|
Write-Host " ⚠ Not found: $file" -ForegroundColor DarkGray
|
|
}
|
|
}
|
|
|
|
# E) Generated Word Documents
|
|
$wordDocs = @(
|
|
"r_app/CI_report.docx",
|
|
"r_app/CI_report2.docx",
|
|
"r_app/CI_report_age_filtered.docx",
|
|
"r_app/CI_report_last_week.docx",
|
|
"r_app/CI_report_week38_corrected.docx",
|
|
"r_app/CI_report_with_kpis_aura.docx",
|
|
"r_app/CI_report_with_kpis_esa.docx",
|
|
"r_app/05_CI_report_dashboard_planet.docx",
|
|
"r_app/10_CI_report_with_kpis_simple.docx",
|
|
"r_app/script5_test.docx",
|
|
"r_app/test_kpi_grid.docx",
|
|
"r_app/output/aura/crop_analysis_AURA_w36vs35_20250916_1631.docx",
|
|
"r_app/output/reports/CI_report_with_kpis_simple_test.docx",
|
|
"r_app/output/CI_report_2x3_layout.docx",
|
|
"r_app/output/CI_report_consolidated.docx",
|
|
"r_app/output/CI_report_layout_test.docx",
|
|
"r_app/output/test_clean.docx",
|
|
"r_app/output/test_grid.docx",
|
|
"r_app/output/test_kables.docx",
|
|
"r_app/output/test_merged.docx"
|
|
)
|
|
|
|
Write-Host "`nDeleting generated Word documents (keeping word-styles-reference-var1.docx)..." -ForegroundColor Gray
|
|
foreach ($file in $wordDocs) {
|
|
if (Test-Path $file) {
|
|
Remove-Item $file -Force
|
|
Write-Host " ✓ Deleted: $file" -ForegroundColor Green
|
|
$deletedCount++
|
|
} else {
|
|
Write-Host " ⚠ Not found: $file" -ForegroundColor DarkGray
|
|
}
|
|
}
|
|
|
|
# ============================================================================
|
|
# PART 2: MOVE FILES TO EXPERIMENTS
|
|
# ============================================================================
|
|
|
|
Write-Host "`n`n📁 PART 2: Moving files to experiments..." -ForegroundColor Yellow
|
|
Write-Host ""
|
|
|
|
# Create destination directories
|
|
$destDirs = @(
|
|
"r_app/experiments/reports",
|
|
"r_app/experiments/legacy_package_management"
|
|
)
|
|
|
|
foreach ($dir in $destDirs) {
|
|
if (!(Test-Path $dir)) {
|
|
New-Item -ItemType Directory -Path $dir -Force | Out-Null
|
|
Write-Host " Created directory: $dir" -ForegroundColor Cyan
|
|
}
|
|
}
|
|
|
|
# Move experimental Rmd files
|
|
$rmdFiles = @(
|
|
@{Source="r_app/CI_report_dashboard_planet.Rmd"; Dest="r_app/experiments/reports/"},
|
|
@{Source="r_app/CI_report_dashboard_planet_enhanced.Rmd"; Dest="r_app/experiments/reports/"},
|
|
@{Source="r_app/CI_report_executive_summary.Rmd"; Dest="r_app/experiments/reports/"},
|
|
@{Source="r_app/simple_kpi_report.Rmd"; Dest="r_app/experiments/reports/"},
|
|
@{Source="r_app/test_kpi_grid.Rmd"; Dest="r_app/experiments/reports/"},
|
|
@{Source="r_app/test_minimal.Rmd"; Dest="r_app/experiments/reports/"}
|
|
)
|
|
|
|
Write-Host "Moving experimental Rmd files..." -ForegroundColor Gray
|
|
foreach ($file in $rmdFiles) {
|
|
if (Test-Path $file.Source) {
|
|
Move-Item $file.Source $file.Dest -Force
|
|
Write-Host " ✓ Moved: $($file.Source) → $($file.Dest)" -ForegroundColor Green
|
|
$movedCount++
|
|
} else {
|
|
Write-Host " ⚠ Not found: $($file.Source)" -ForegroundColor DarkGray
|
|
}
|
|
}
|
|
|
|
# Move legacy package management scripts
|
|
$legacyFiles = @(
|
|
@{Source="r_app/extract_current_versions.R"; Dest="r_app/experiments/legacy_package_management/"},
|
|
@{Source="r_app/package_manager.R"; Dest="r_app/experiments/legacy_package_management/"}
|
|
)
|
|
|
|
Write-Host "`nMoving legacy package management scripts..." -ForegroundColor Gray
|
|
foreach ($file in $legacyFiles) {
|
|
if (Test-Path $file.Source) {
|
|
Move-Item $file.Source $file.Dest -Force
|
|
Write-Host " ✓ Moved: $($file.Source) → $($file.Dest)" -ForegroundColor Green
|
|
$movedCount++
|
|
} else {
|
|
Write-Host " ⚠ Not found: $($file.Source)" -ForegroundColor DarkGray
|
|
}
|
|
}
|
|
|
|
# ============================================================================
|
|
# SUMMARY
|
|
# ============================================================================
|
|
|
|
Write-Host "`n`n📊 CLEANUP SUMMARY" -ForegroundColor Cyan
|
|
Write-Host "==================" -ForegroundColor Cyan
|
|
Write-Host "Files deleted: $deletedCount" -ForegroundColor Green
|
|
Write-Host "Files moved: $movedCount" -ForegroundColor Green
|
|
|
|
if ($errors.Count -gt 0) {
|
|
Write-Host "`n⚠️ Errors encountered: $($errors.Count)" -ForegroundColor Red
|
|
foreach ($err in $errors) {
|
|
Write-Host " $err" -ForegroundColor Red
|
|
}
|
|
}
|
|
|
|
Write-Host "`n✅ Cleanup completed!" -ForegroundColor Green
|
|
Write-Host "`nNext step: Update .gitignore (see instructions)" -ForegroundColor Yellow
|