# Script de nettoyage complet du projet Flutter
# Usage: .\scripts\clean.ps1

Write-Host "🧹 Nettoyage du projet AfterWork..." -ForegroundColor Cyan

# Nettoyer Flutter
Write-Host "`n📦 Nettoyage Flutter..." -ForegroundColor Yellow
flutter clean

# Supprimer les dossiers de build
Write-Host "`n🗑️  Suppression des dossiers de build..." -ForegroundColor Yellow
$foldersToDelete = @(
    "build",
    "obj",
    ".dart_tool",
    "android\.gradle",
    "android\app\build",
    "ios\Pods",
    "ios\.symlinks",
    "linux\build",
    "macos\build",
    "windows\build"
)

foreach ($folder in $foldersToDelete) {
    if (Test-Path $folder) {
        Write-Host "  Suppression de $folder..." -ForegroundColor Gray
        Remove-Item -Path $folder -Recurse -Force -ErrorAction SilentlyContinue
    }
}

# Supprimer les fichiers temporaires
Write-Host "`n🗑️  Suppression des fichiers temporaires..." -ForegroundColor Yellow
$filesToDelete = @(
    "pubspec.lock"
)

foreach ($file in $filesToDelete) {
    if (Test-Path $file) {
        Write-Host "  Suppression de $file..." -ForegroundColor Gray
        Remove-Item -Path $file -Force -ErrorAction SilentlyContinue
    }
}

# Récupérer les dépendances
Write-Host "`n📥 Récupération des dépendances..." -ForegroundColor Yellow
flutter pub get

# Générer les fichiers si nécessaire
Write-Host "`n🔧 Génération des fichiers..." -ForegroundColor Yellow
# flutter pub run build_runner build --delete-conflicting-outputs

Write-Host "`n✅ Nettoyage terminé avec succès!" -ForegroundColor Green
Write-Host "`nVous pouvez maintenant lancer: flutter run" -ForegroundColor Cyan

