-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanup.ps1
More file actions
137 lines (122 loc) Β· 4.67 KB
/
cleanup.ps1
File metadata and controls
137 lines (122 loc) Β· 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# Simple Menu - Project Cleanup Script
# Helps maintain the organized project structure
param(
[switch]$DryRun = $false,
[switch]$Verbose = $false
)
$ErrorActionPreference = "Continue"
Write-Host "π§Ή Simple Menu - Project Cleanup" -ForegroundColor Cyan
Write-Host "=================================" -ForegroundColor Cyan
Write-Host ""
if ($DryRun) {
Write-Host "π DRY RUN MODE - No changes will be made" -ForegroundColor Yellow
Write-Host ""
}
# Define cleanup tasks
$CleanupTasks = @(
@{
Name = "Docker containers and images"
Command = {
docker system prune -af --volumes 2>$null
docker image prune -af 2>$null
}
Description = "Remove unused Docker containers, networks, and images"
},
@{
Name = "Node modules cleanup"
Command = {
if (Test-Path "Backend\node_modules") {
if (-not $DryRun) { Remove-Item "Backend\node_modules" -Recurse -Force }
Write-Host " ββ Removed Backend\node_modules" -ForegroundColor Gray
}
if (Test-Path "Frontend\front\node_modules") {
if (-not $DryRun) { Remove-Item "Frontend\front\node_modules" -Recurse -Force }
Write-Host " ββ Removed Frontend\front\node_modules" -ForegroundColor Gray
}
}
Description = "Remove node_modules directories"
},
@{
Name = "Log files cleanup"
Command = {
Get-ChildItem -Path . -Include "*.log" -Recurse | ForEach-Object {
Write-Host " ββ Found log file: $($_.FullName)" -ForegroundColor Gray
if (-not $DryRun) { Remove-Item $_.FullName -Force }
}
}
Description = "Remove log files throughout the project"
},
@{
Name = "Temporary files cleanup"
Command = {
$TempPatterns = @("*.tmp", "*.temp", "*~", ".DS_Store", "Thumbs.db")
foreach ($pattern in $TempPatterns) {
Get-ChildItem -Path . -Include $pattern -Recurse | ForEach-Object {
Write-Host " ββ Found temp file: $($_.FullName)" -ForegroundColor Gray
if (-not $DryRun) { Remove-Item $_.FullName -Force }
}
}
}
Description = "Remove temporary and system files"
},
@{
Name = "Database cleanup"
Command = {
if (Test-Path "Backend\prisma\dev.db-journal") {
Write-Host " ββ Found SQLite journal file" -ForegroundColor Gray
if (-not $DryRun) { Remove-Item "Backend\prisma\dev.db-journal" -Force }
}
}
Description = "Clean up database temporary files"
}
)
# Execute cleanup tasks
foreach ($task in $CleanupTasks) {
Write-Host "π§ $($task.Name)" -ForegroundColor Green
Write-Host " $($task.Description)" -ForegroundColor White
try {
& $task.Command
Write-Host " β
Completed" -ForegroundColor Green
}
catch {
Write-Host " β οΈ Warning: $($_.Exception.Message)" -ForegroundColor Yellow
}
Write-Host ""
}
# Project structure validation
Write-Host "π Project Structure Validation" -ForegroundColor Green
Write-Host "Checking organized directory structure..." -ForegroundColor White
$RequiredDirs = @("Backend", "Frontend", "docker", "monitoring", "scripts", "docs")
$MissingDirs = @()
foreach ($dir in $RequiredDirs) {
if (Test-Path $dir) {
Write-Host " β
$dir" -ForegroundColor Green
} else {
Write-Host " β $dir (Missing)" -ForegroundColor Red
$MissingDirs += $dir
}
}
if ($MissingDirs.Count -gt 0) {
Write-Host ""
Write-Host "β οΈ Missing directories detected. Run this to fix:" -ForegroundColor Yellow
Write-Host " New-Item -ItemType Directory -Path '$($MissingDirs -join "', '")' -Force" -ForegroundColor Cyan
}
Write-Host ""
Write-Host "π― Project Organization Summary" -ForegroundColor Cyan
Write-Host "==============================="-ForegroundColor Cyan
$RootFiles = Get-ChildItem -Path . -File | Where-Object { $_.Name -notmatch '\.(md|yml|json|ps1|sh|txt|gitignore)$' }
if ($RootFiles.Count -gt 0) {
Write-Host "β οΈ Files that might need organization:" -ForegroundColor Yellow
$RootFiles | ForEach-Object {
Write-Host " β’ $($_.Name)" -ForegroundColor Gray
}
} else {
Write-Host "β
Root directory is clean and organized" -ForegroundColor Green
}
Write-Host ""
Write-Host "π Cleanup completed!" -ForegroundColor Green
if ($DryRun) {
Write-Host ""
Write-Host "π‘ To execute the cleanup, run:" -ForegroundColor Cyan
Write-Host " .\cleanup.ps1" -ForegroundColor White
}