|
| 1 | +# Ordin Project Cleanup Script |
| 2 | +# Safely removes build artifacts and temporary files |
| 3 | + |
| 4 | +Write-Host "Starting Ordin Project Cleanup..." -ForegroundColor Cyan |
| 5 | + |
| 6 | +# Kill any running Rscript processes that might lock files |
| 7 | +Write-Host "`nStopping Rscript processes..." -ForegroundColor Yellow |
| 8 | +Get-Process -Name "Rscript" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue |
| 9 | +Start-Sleep -Seconds 2 |
| 10 | + |
| 11 | +# Kill any running Electron/Ordin processes |
| 12 | +Write-Host "Stopping Electron/Ordin processes..." -ForegroundColor Yellow |
| 13 | +Get-Process -Name "ordin" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue |
| 14 | +Start-Sleep -Seconds 2 |
| 15 | + |
| 16 | +# Remove temporary command files |
| 17 | +Write-Host "`nRemoving temporary files..." -ForegroundColor Yellow |
| 18 | +$tempFiles = @("11.6.2", "electron-forge", "npm", "ordin@3.0.0", "taskkill", "wsl", "test-path-resolution.js") |
| 19 | +foreach ($file in $tempFiles) { |
| 20 | + if (Test-Path $file) { |
| 21 | + Remove-Item $file -Force -ErrorAction SilentlyContinue |
| 22 | + Write-Host " Removed: $file" -ForegroundColor Green |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +# Remove out folder (build artifacts) |
| 27 | +Write-Host "`nRemoving build artifacts (out folder)..." -ForegroundColor Yellow |
| 28 | +if (Test-Path "out") { |
| 29 | + try { |
| 30 | + Remove-Item "out" -Recurse -Force -ErrorAction Stop |
| 31 | + Write-Host " Removed: out/" -ForegroundColor Green |
| 32 | + } catch { |
| 33 | + Write-Host " Could not remove 'out' folder - files may be locked" -ForegroundColor Red |
| 34 | + Write-Host " Try closing all applications and run this script again" -ForegroundColor Red |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +# Remove r-win folder (R portable installation used for building) |
| 39 | +Write-Host "`nRemoving R portable build folder..." -ForegroundColor Yellow |
| 40 | +if (Test-Path "r-win") { |
| 41 | + try { |
| 42 | + Remove-Item "r-win" -Recurse -Force -ErrorAction Stop |
| 43 | + Write-Host " Removed: r-win/" -ForegroundColor Green |
| 44 | + } catch { |
| 45 | + Write-Host " Could not remove 'r-win' folder - files may be locked" -ForegroundColor Red |
| 46 | + } |
| 47 | +} |
| 48 | + |
| 49 | +# Remove archive folder if empty |
| 50 | +Write-Host "`nChecking archive folder..." -ForegroundColor Yellow |
| 51 | +if (Test-Path "archive") { |
| 52 | + $archiveItems = Get-ChildItem "archive" -ErrorAction SilentlyContinue |
| 53 | + if ($archiveItems.Count -eq 0) { |
| 54 | + Remove-Item "archive" -Force -ErrorAction SilentlyContinue |
| 55 | + Write-Host " Removed empty: archive/" -ForegroundColor Green |
| 56 | + } else { |
| 57 | + Write-Host " Keeping archive/ (contains files)" -ForegroundColor Cyan |
| 58 | + } |
| 59 | +} |
| 60 | + |
| 61 | +# Check node_modules |
| 62 | +Write-Host "`nChecking node_modules..." -ForegroundColor Yellow |
| 63 | +if (Test-Path "node_modules") { |
| 64 | + Write-Host " Keeping node_modules/ (run 'npm prune' to clean unused packages)" -ForegroundColor Cyan |
| 65 | +} |
| 66 | + |
| 67 | +Write-Host "`nCleanup complete!" -ForegroundColor Green |
| 68 | +Write-Host "`nPreserved:" -ForegroundColor Cyan |
| 69 | +Write-Host " - Source code (src/, shiny/)" -ForegroundColor White |
| 70 | +Write-Host " - Documentation (docs/, README.md, CHANGELOG.md)" -ForegroundColor White |
| 71 | +Write-Host " - Configuration (package.json, .gitignore)" -ForegroundColor White |
| 72 | +Write-Host " - Sample data (sample-data/)" -ForegroundColor White |
| 73 | +Write-Host " - Build scripts (setup.bat, setup.sh, etc.)" -ForegroundColor White |
0 commit comments