$ErrorActionPreference = "Stop" Write-Host "" Write-Host "=== YouTube Personal - Memoire 18.10.3 / Dependances stables ===" -ForegroundColor Cyan Write-Host "Projet : $PWD" Write-Host "" if (-not (Test-Path ".\pubspec.yaml")) { throw "pubspec.yaml introuvable. Lance ce script depuis la racine du projet Flutter." } if (-not (Test-Path ".\lib\services\memory_backup_service.dart")) { throw "memory_backup_service.dart introuvable. Extrais d'abord tout le ZIP dans la racine du projet." } Get-Process -Name "youtube_personal" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue $pubspecPath = ".\pubspec.yaml" $backupPath = ".\pubspec.yaml.before_memory_18_10_3" if (-not (Test-Path $backupPath)) { Copy-Item $pubspecPath $backupPath Write-Host "[OK] Sauvegarde pubspec : $backupPath" -ForegroundColor Green } if (Test-Path ".\pubspec.lock") { $lockBackup = ".\pubspec.lock.before_memory_18_10_3" if (-not (Test-Path $lockBackup)) { Copy-Item ".\pubspec.lock" $lockBackup Write-Host "[OK] Sauvegarde lock : $lockBackup" -ForegroundColor Green } } $content = Get-Content $pubspecPath -Raw Write-Host "[1/5] Suppression de file_picker..." -ForegroundColor Yellow $content = [regex]::Replace($content, '(?m)^\s*file_picker\s*:\s*.*(?:\r?\n)?', '') function Set-DependencyLine { param([string]$Name, [string]$Version) $pattern = "(?m)^(\s*)" + [regex]::Escape($Name) + "\s*:\s*.*$" if ($script:content -match $pattern) { $script:content = [regex]::Replace( $script:content, $pattern, '${1}' + $Name + ': ' + $Version, 1 ) } else { $anchor = '(?m)^dependencies\s*:\s*$' if ($script:content -notmatch $anchor) { throw "Section dependencies introuvable dans pubspec.yaml." } $script:content = [regex]::Replace( $script:content, $anchor, "dependencies:`r`n $Name`: $Version", 1 ) } } Write-Host "[2/5] Versions stables et compatibles..." -ForegroundColor Yellow Set-DependencyLine "wakelock_plus" "1.5.2" Set-DependencyLine "package_info_plus" "9.0.1" Set-DependencyLine "file_selector" "1.1.0" Set-DependencyLine "file_saver" "0.3.1" Set-Content -Path $pubspecPath -Value $content -Encoding UTF8 Write-Host "[OK] file_picker supprime" -ForegroundColor Green Write-Host "[OK] wakelock_plus = 1.5.2" -ForegroundColor Green Write-Host "[OK] package_info_plus = 9.0.1" -ForegroundColor Green Write-Host "[OK] file_selector = 1.1.0" -ForegroundColor Green Write-Host "[OK] file_saver = 0.3.1" -ForegroundColor Green Write-Host "[3/5] Nettoyage du cache de plugins..." -ForegroundColor Yellow $registrant = ".\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java" if (Test-Path $registrant) { Remove-Item $registrant -Force Write-Host "[OK] Ancien GeneratedPluginRegistrant.java supprime." -ForegroundColor Green } if (Test-Path ".\.flutter-plugins-dependencies") { Remove-Item ".\.flutter-plugins-dependencies" -Force -ErrorAction SilentlyContinue } Write-Host "[4/5] Resolution des dependances..." -ForegroundColor Yellow flutter pub get if ($LASTEXITCODE -ne 0) { throw "flutter pub get a echoue. Sauvegarde disponible : $backupPath" } Write-Host "[5/5] Formatage du service memoire..." -ForegroundColor Yellow dart format ".\lib\services\memory_backup_service.dart" if ($LASTEXITCODE -ne 0) { throw "dart format a echoue." } Write-Host "" Write-Host "[OK] Correctif Memoire 18.10.3 applique." -ForegroundColor Green Write-Host "" Write-Host "Teste maintenant :" -ForegroundColor Cyan Write-Host "flutter run -d f10778d8" Write-Host "" Write-Host "Puis, si le test est bon :" -ForegroundColor Cyan Write-Host "flutter build apk --release" Write-Host ""