Tools : ReimportCorrectif.ps1 (protocole de reimport, etapes 1 a 6)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
edujiro5972 2026-09-29 02:09:36 +02:00
parent e174857024
commit 9cf045e54e

View file

@ -0,0 +1,88 @@
<#
.SYNOPSIS
Protocole de reimport sous controle renforce (Docs/Migration/05_Correctifs_Isoles.md, section 3),
etapes 1 a 6, pour un correctif applique par commandlet.
.DESCRIPTION
1. tag git <Id>-avant + Snapshot des assets cibles
2. photographie avant (LPDumpFunction) de chaque graphe cible
3. simulation -DryRun ; arret si le nombre de lignes de rapport attendues n'est pas atteint
4. application reelle
5. photographie apres + diff
6. LPCheckMeshAssignment + CompileAllBlueprints
Les preuves vont dans Docs/Migration/etat/<Id>_*. Ne commite pas : la validation reste humaine
(lecture du diff), puis journal + commit + tag <Id>-apres.
.EXAMPLE
.\Tools\ReimportCorrectif.ps1 -Id L4-CX-B02 -Commandlet LPFixEditableTextBoxFont `
-Assets Content\UI\StatMenu.uasset,Content\UI\CharGen.uasset `
-Graphs StatMenu:EventGraph,CharGen:EventGraph -ExpectPattern 'LogLPFixFont: Warning: \w+ ::' -ExpectCount 6
#>
param(
[Parameter(Mandatory)][string]$Id,
[Parameter(Mandatory)][string]$Commandlet,
[Parameter(Mandatory)][string[]]$Assets,
[Parameter(Mandatory)][string[]]$Graphs, # "Blueprint:Graphe"
[Parameter(Mandatory)][string]$ExpectPattern, # ligne de rapport comptee a la simulation
[Parameter(Mandatory)][int]$ExpectCount,
[string]$ApplyArgs = '',
[string]$DryRunArgs = '-DryRun',
[string]$ProjectRoot = (Split-Path $PSScriptRoot -Parent)
)
$ErrorActionPreference = 'Stop'
Set-Location $ProjectRoot
$etat = Join-Path $ProjectRoot 'Docs\Migration\etat'
$portage = Join-Path $ProjectRoot 'Saved\Logs\portage'
function Last-Log([string]$cmd) { Get-ChildItem (Join-Path $portage "${Id}_${cmd}_*.log") | Sort-Object Name | Select-Object -Last 1 }
function Report-Lines([string]$log) {
Get-Content $log | Where-Object { $_ -match 'LogLP' -and $_ -notmatch 'LogInit: Display' } | ForEach-Object { $_ -replace '^\[[^\]]+\]\[\s*\d+\]', '' }
}
function Dump([string]$when) {
foreach ($g in $Graphs) {
$bp, $fn = $g -split ':', 2
& "$PSScriptRoot\RunCommandlet.ps1" -Lot $Id -Commandlet LPDumpFunction -Args "-BP=$bp -Fn=$fn -Pins" | Out-Null
$log = Last-Log 'LPDumpFunction'
Get-Content $log.FullName | Where-Object { $_ -match 'LogLPDump' -and $_ -notmatch 'LogInit: Display' } |
ForEach-Object { $_ -replace '^\[[^\]]+\]\[\s*\d+\]LogLPDump: (Warning|Display): ', '' } |
Set-Content (Join-Path $etat "${Id}_dump_${when}_${bp}_${fn}.txt") -Encoding utf8
}
Remove-Item (Join-Path $etat "${Id}_LPDumpFunction_*.txt") -ErrorAction SilentlyContinue
}
# 1
if (git status --short) { throw 'Arbre git non propre : commiter ou annuler avant un reimport.' }
git tag "$Id-avant"
& "$PSScriptRoot\Snapshot.ps1" -Lot $Id -Path $Assets | Out-Null
# 2
Dump 'avant'
# 3
& "$PSScriptRoot\RunCommandlet.ps1" -Lot $Id -Commandlet $Commandlet -Args $DryRunArgs | Out-Null
$dry = Report-Lines (Last-Log $Commandlet).FullName
$dry | Set-Content (Join-Path $etat "${Id}_dryrun.txt") -Encoding utf8
$found = @($dry | Where-Object { $_ -match $ExpectPattern }).Count
Remove-Item (Join-Path $etat "${Id}_${Commandlet}_*.txt") -ErrorAction SilentlyContinue
Write-Host "Simulation : $found ligne(s) attendue(s) trouvee(s) sur $ExpectCount"
if ($found -ne $ExpectCount) { throw "Simulation non conforme ($found au lieu de $ExpectCount) : arret, rien n'a ete ecrit." }
foreach ($a in $Assets) { Write-Host "avant $a $((Get-FileHash $a -Algorithm MD5).Hash)" }
# 4
& "$PSScriptRoot\RunCommandlet.ps1" -Lot $Id -Commandlet $Commandlet -Args $ApplyArgs | Out-Null
Report-Lines (Last-Log $Commandlet).FullName | Set-Content (Join-Path $etat "${Id}_application.txt") -Encoding utf8
Remove-Item (Join-Path $etat "${Id}_${Commandlet}_*.txt") -ErrorAction SilentlyContinue
foreach ($a in $Assets) { Write-Host "apres $a $((Get-FileHash $a -Algorithm MD5).Hash)" }
# 5
Dump 'apres'
foreach ($g in $Graphs) {
$bp, $fn = $g -split ':', 2
$av = Get-Content (Join-Path $etat "${Id}_dump_avant_${bp}_${fn}.txt")
$ap = Get-Content (Join-Path $etat "${Id}_dump_apres_${bp}_${fn}.txt")
$diff = Compare-Object $av $ap | ForEach-Object { '{0} {1}' -f $_.SideIndicator, $_.InputObject }
$diff | Set-Content (Join-Path $etat "${Id}_diff_${bp}_${fn}.txt") -Encoding utf8
Write-Host "diff $bp::$fn : $($av.Count) -> $($ap.Count) lignes, $(@($diff).Count) ligne(s) differente(s)"
}
# 6
& "$PSScriptRoot\RunCommandlet.ps1" -Lot $Id -Commandlet LPCheckMeshAssignment | Out-Null
Get-Content (Last-Log 'LPCheckMeshAssignment').FullName | Where-Object { $_ -match 'LogLPCheckMesh: Warning: \w+ ::' -and $_ -notmatch 'LogInit' } |
ForEach-Object { 'orpheline : ' + ($_ -replace '^.*Warning:\s+', '') }
& "$PSScriptRoot\RunCommandlet.ps1" -Lot $Id -Commandlet CompileAllBlueprints | Out-Null
Get-Content (Last-Log 'CompileAllBlueprints').FullName | Where-Object { $_ -match 'Compiling Completed|chec de la compilation' } | ForEach-Object { $_ -replace '^\[[^\]]+\]\[\s*\d+\]', '' }