Files
youtube_personal/APPLIQUER_FIX_MEMOIRE_18_10_4.ps1
T

105 lines
3.9 KiB
PowerShell

$ErrorActionPreference = "Stop"
Write-Host ""
Write-Host "=== YouTube Personal - Memoire 18.10.4 / Fix package_info_plus ===" -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."
}
Get-Process -Name "youtube_personal" -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
$pubspecPath = ".\pubspec.yaml"
$backupPath = ".\pubspec.yaml.before_memory_18_10_4"
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_4"
if (-not (Test-Path $lockBackup)) {
Copy-Item ".\pubspec.lock" $lockBackup
Write-Host "[OK] Sauvegarde lock : $lockBackup" -ForegroundColor Green
}
}
$content = Get-Content $pubspecPath -Raw
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 "[1/4] Versions Android compatibles..." -ForegroundColor Yellow
Set-DependencyLine "package_info_plus" "8.3.1"
Set-DependencyLine "wakelock_plus" "1.5.2"
Set-DependencyLine "file_selector" "1.1.0"
Set-DependencyLine "file_saver" "0.3.1"
$content = [regex]::Replace($content, '(?m)^\s*file_picker\s*:\s*.*(?:\r?\n)?', '')
Set-Content -Path $pubspecPath -Value $content -Encoding UTF8
Write-Host "[OK] package_info_plus = 8.3.1" -ForegroundColor Green
Write-Host "[OK] wakelock_plus = 1.5.2" -ForegroundColor Green
Write-Host "[OK] file_selector = 1.1.0" -ForegroundColor Green
Write-Host "[OK] file_saver = 0.3.1" -ForegroundColor Green
Write-Host "[OK] file_picker absent" -ForegroundColor Green
Write-Host "[2/4] Nettoyage des fichiers generes Flutter..." -ForegroundColor Yellow
$registrant = ".\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java"
if (Test-Path $registrant) {
Remove-Item $registrant -Force -ErrorAction SilentlyContinue
Write-Host "[OK] GeneratedPluginRegistrant.java supprime; Flutter le regenerera." -ForegroundColor Green
}
foreach ($path in @(".\.flutter-plugins-dependencies", ".\.dart_tool")) {
if (Test-Path $path) {
try {
Remove-Item $path -Recurse -Force -ErrorAction Stop
Write-Host "[OK] Supprime : $path" -ForegroundColor Green
} catch {
Write-Host "[INFO] Impossible de supprimer completement $path; poursuite." -ForegroundColor DarkYellow
}
}
}
Write-Host "[3/4] Resolution des dependances..." -ForegroundColor Yellow
flutter pub get
if ($LASTEXITCODE -ne 0) {
throw "flutter pub get a echoue. Sauvegarde disponible : $backupPath"
}
Write-Host "[4/4] Verification des versions resolues..." -ForegroundColor Yellow
$deps = flutter pub deps --style=compact 2>&1
$deps | Select-String -Pattern "package_info_plus|wakelock_plus|file_selector|file_saver|win32" | ForEach-Object { Write-Host $_.Line }
Write-Host ""
Write-Host "[OK] Correctif Memoire 18.10.4 applique." -ForegroundColor Green
Write-Host ""
Write-Host "Teste Android :" -ForegroundColor Cyan
Write-Host "flutter run -d f10778d8"
Write-Host ""
Write-Host "Puis APK release :" -ForegroundColor Cyan
Write-Host "flutter build apk --release"
Write-Host ""