# Legacy names are used only to discover and migrate older installations. function Convert-RuenLegacyText([string]$Text) { return $Text.Replace('BradStockUI','RuenUI').Replace('BRADSTOCKUI','RUENUI').Replace('BRADUI','RUENUI').Replace('BradTargetTargetTarget','RuenTargetTargetTarget') } function Add-RuenMigration([string]$Root, $Plan) { $changes = New-Object 'System.Collections.Generic.List[object]' $legacy = 'BradStockUI' $oldAddon = 'Interface/AddOns/' + $legacy if (Test-Path -LiteralPath (Join-Path $Root $oldAddon)) { $changes.Add([pscustomobject]@{path=$oldAddon;source=$null;text=$null;removeOnly=$true}) } $accounts = Join-Path $Root 'WTF/Account' if (Test-Path -LiteralPath $accounts) { Assert-NoNestedLinks $accounts $files = @(Get-ChildItem -LiteralPath $accounts -Recurse -File) foreach ($file in $files) { $relative = $file.FullName.Substring($Root.Length).TrimStart([char[]]'\/').Replace('\','/') if ($file.Directory.Name -eq 'SavedVariables' -and $file.Name -in @(($legacy+'.lua'),($legacy+'.lua.bak'))) { $newPath = $relative.Replace($legacy+'.lua','RuenUI.lua') if (-not (Test-Path -LiteralPath (Join-Path $Root $newPath))) { $changes.Add([pscustomobject]@{path=$newPath;source=$null;text=(Convert-RuenLegacyText ([IO.File]::ReadAllText($file.FullName)))}) } $changes.Add([pscustomobject]@{path=$relative;source=$null;text=$null;removeOnly=$true}) } elseif ($file.Name -eq 'bindings-cache.wtf' -or ($file.Directory.Name -eq 'SavedVariables' -and $file.Name -in @('RuenUI.lua','RuenUI.lua.bak'))) { $text = [IO.File]::ReadAllText($file.FullName) $updated = Convert-RuenLegacyText $text if ($updated -ne $text) { $changes.Add([pscustomobject]@{path=$relative;source=$null;text=$updated}) } } elseif ($file.Name -eq 'AddOns.txt') { $text = [IO.File]::ReadAllText($file.FullName) if ($text -match '(?m)^BradStockUI\s*:') { $lines = @($text -split '\r?\n' | Where-Object { $_ -and $_ -notmatch '^(BradStockUI|RuenUI)\s*:' }) $changes.Add([pscustomobject]@{path=$relative;source=$null;text=(($lines + 'RuenUI: enabled') -join "`r`n")+"`r`n"}) } } } } foreach ($change in $changes) { $existing = @($Plan | Where-Object { $_.path -eq $change.path }) # A full install may already have a more complete enabled-addon list. if (@($existing | Where-Object { -not $_.PSObject.Properties['backupOnly'] }).Count) { continue } foreach ($item in $existing) { [void]$Plan.Remove($item) } $Plan.Add($change) } }