84 lines
3.0 KiB
PowerShell
84 lines
3.0 KiB
PowerShell
$ErrorActionPreference = "Stop"
|
|
|
|
Write-Host ""
|
|
Write-Host "=== YouTube Personal - Fix Android Wakelock 18.10.2 ===" -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."
|
|
}
|
|
|
|
# Fermer l'application Windows si elle tourne et peut verrouiller build/.dart_tool.
|
|
Get-Process -Name "youtube_personal" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
|
|
|
|
$pubspecPath = ".\pubspec.yaml"
|
|
$backupPath = ".\pubspec.yaml.before_wakelock_18_10_2"
|
|
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_wakelock_18_10_2"
|
|
if (-not (Test-Path $lockBackup)) {
|
|
Copy-Item ".\pubspec.lock" $lockBackup
|
|
Write-Host "[OK] Sauvegarde lock : $lockBackup" -ForegroundColor Green
|
|
}
|
|
}
|
|
|
|
Write-Host "[1/3] Verrouillage de wakelock_plus sur 1.5.2..." -ForegroundColor Yellow
|
|
$content = Get-Content $pubspecPath -Raw
|
|
|
|
if ($content -match '(?m)^\s*wakelock_plus\s*:\s*.*$') {
|
|
$content = [regex]::Replace(
|
|
$content,
|
|
'(?m)^(\s*)wakelock_plus\s*:\s*.*$',
|
|
'${1}wakelock_plus: 1.5.2',
|
|
1
|
|
)
|
|
} else {
|
|
$dependencyAnchor = '(?m)^dependencies\s*:\s*$'
|
|
if ($content -notmatch $dependencyAnchor) {
|
|
throw "Section dependencies introuvable dans pubspec.yaml."
|
|
}
|
|
$content = [regex]::Replace(
|
|
$content,
|
|
$dependencyAnchor,
|
|
"dependencies:`r`n wakelock_plus: 1.5.2",
|
|
1
|
|
)
|
|
}
|
|
Set-Content -Path $pubspecPath -Value $content -Encoding UTF8
|
|
Write-Host "[OK] wakelock_plus = 1.5.2" -ForegroundColor Green
|
|
|
|
Write-Host "[2/3] Resolution des dependances..." -ForegroundColor Yellow
|
|
flutter pub get
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "flutter pub get a echoue."
|
|
}
|
|
|
|
Write-Host "[3/3] Verification des versions resolues..." -ForegroundColor Yellow
|
|
$deps = flutter pub deps --style=compact 2>&1 | Out-String
|
|
$wakeline = ($deps -split "`r?`n" | Where-Object { $_ -match 'wakelock_plus\s' } | Select-Object -First 1)
|
|
$fileline = ($deps -split "`r?`n" | Where-Object { $_ -match 'file_picker\s' } | Select-Object -First 1)
|
|
if ($wakeline) { Write-Host "[INFO] $wakeline" -ForegroundColor DarkGray }
|
|
if ($fileline) { Write-Host "[INFO] $fileline" -ForegroundColor DarkGray }
|
|
|
|
if ($deps -notmatch 'wakelock_plus\s+1\.5\.2') {
|
|
throw "wakelock_plus 1.5.2 n'est pas la version resolue. Verifie pubspec.yaml / dependency_overrides."
|
|
}
|
|
if ($deps -notmatch 'file_picker\s+12\.0\.0') {
|
|
Write-Host "[ATTENTION] file_picker 12.0.0 n'apparait pas dans les dependances resolues." -ForegroundColor Yellow
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "[OK] Correctif 18.10.2 applique." -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "Teste Android avec :" -ForegroundColor Cyan
|
|
Write-Host "flutter run -d f10778d8"
|
|
Write-Host ""
|
|
Write-Host "Puis APK release avec :" -ForegroundColor Cyan
|
|
Write-Host "flutter build apk --release"
|
|
Write-Host ""
|