117 lines
4.4 KiB
PowerShell
117 lines
4.4 KiB
PowerShell
$ErrorActionPreference = "Stop"
|
|
|
|
Write-Host ""
|
|
Write-Host "=== YouTube Personal - Memoire 18.10.5 / Couple de dependances compatible ===" -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. Le patch Memoire 18.10 doit deja etre installe."
|
|
}
|
|
|
|
$pubspecPath = ".\pubspec.yaml"
|
|
$backupPath = ".\pubspec.yaml.before_memory_18_10_5"
|
|
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_5"
|
|
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] Fix du couple wakelock/package_info..." -ForegroundColor Yellow
|
|
$content = [regex]::Replace($content, '(?m)^\s*file_picker\s*:\s*.*(?:\r?\n)?', '')
|
|
Set-DependencyLine "wakelock_plus" "1.3.3"
|
|
Set-DependencyLine "package_info_plus" "8.3.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] wakelock_plus = 1.3.3" -ForegroundColor Green
|
|
Write-Host "[OK] package_info_plus = 8.3.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 "[OK] file_picker absent" -ForegroundColor Green
|
|
|
|
Write-Host "[2/4] Suppression des anciens fichiers de registration 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." -ForegroundColor Green
|
|
}
|
|
if (Test-Path ".\.flutter-plugins-dependencies") {
|
|
Remove-Item ".\.flutter-plugins-dependencies" -Force -ErrorAction SilentlyContinue
|
|
Write-Host "[OK] .flutter-plugins-dependencies supprime." -ForegroundColor Green
|
|
}
|
|
|
|
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 | Out-String
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Impossible de verifier les dependances resolues."
|
|
}
|
|
|
|
$checks = @(
|
|
@{ Name = "wakelock_plus"; Version = "1.3.3" },
|
|
@{ Name = "package_info_plus"; Version = "8.3.1" },
|
|
@{ Name = "file_selector"; Version = "1.1.0" },
|
|
@{ Name = "file_saver"; Version = "0.3.1" }
|
|
)
|
|
|
|
foreach ($check in $checks) {
|
|
$pattern = "(?m)\b" + [regex]::Escape($check.Name) + "\s+" + [regex]::Escape($check.Version) + "\b"
|
|
if ($deps -match $pattern) {
|
|
Write-Host "[OK] $($check.Name) $($check.Version) resolu" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "[ATTENTION] $($check.Name) $($check.Version) non confirme dans flutter pub deps" -ForegroundColor Yellow
|
|
}
|
|
}
|
|
|
|
Write-Host ""
|
|
Write-Host "[OK] Correctif Memoire 18.10.5 applique." -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "Teste Android :" -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 ""
|