mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-08-23 07:56:31 +00:00
* Fix backward compatibility for old-style JSON config imports * Refactor sidebar UI generation and add tests for Get-WinUtilVariables * Fix appnavigation config test following UI generation refactor * Restore global sync state in variables tests * fix(impex): migrate supported legacy selections Keep modern imports strict while allowing legacy backups to skip retired entries with clear logging and user feedback. Add fixtures covering partial and all-retired imports. * test: strengthen UI and global state coverage Exercise app category rendering through Initialize-WPFUI and restore global sync without leaking test state. * fix(impex): ignore legacy metadata fields Limit legacy selection migration to supported WPF key families so unrelated string metadata does not produce false retired-setting warnings. * docs: clarify legacy config imports Distinguish strict modern flat imports from partial legacy object migration, including single-setting export shape and historical groups. --------- Co-authored-by: Chris Titus <contact@christitus.com>
84 lines
2.5 KiB
PowerShell
84 lines
2.5 KiB
PowerShell
function Update-WinUtilSelections {
|
|
param(
|
|
[Parameter(Mandatory)]
|
|
[string[]]$flatJson,
|
|
|
|
[switch]$Replace,
|
|
|
|
[switch]$SkipUnknown
|
|
)
|
|
|
|
$nextSelections = @{
|
|
selectedApps = [System.Collections.Generic.List[string]]::new()
|
|
selectedTweaks = [System.Collections.Generic.List[string]]::new()
|
|
selectedToggles = [System.Collections.Generic.List[string]]::new()
|
|
selectedFeatures = [System.Collections.Generic.List[string]]::new()
|
|
selectedAppx = [System.Collections.Generic.List[string]]::new()
|
|
}
|
|
|
|
foreach ($cbkey in $flatJson) {
|
|
|
|
$listName = switch -Regex ($cbkey) {
|
|
'^WPFInstall' { 'selectedApps' }
|
|
'^WPFTweaks' { 'selectedTweaks' }
|
|
'^WPFToggle' { 'selectedToggles' }
|
|
'^WPFFeature' { 'selectedFeatures' }
|
|
'^WPFAppx' { 'selectedAppx' }
|
|
}
|
|
|
|
if (-not $listName) {
|
|
if ($SkipUnknown) {
|
|
$cbkey
|
|
continue
|
|
}
|
|
throw "Unsupported selection key '$cbkey'."
|
|
}
|
|
|
|
$isKnownSelection = switch ($listName) {
|
|
'selectedApps' {
|
|
$sync.configs.applicationsHashtable.ContainsKey($cbkey)
|
|
}
|
|
'selectedTweaks' {
|
|
$null -ne $sync.configs.tweaks.PSObject.Properties[$cbkey]
|
|
}
|
|
'selectedToggles' {
|
|
$null -ne $sync.configs.tweaks.PSObject.Properties[$cbkey]
|
|
}
|
|
'selectedFeatures' {
|
|
$null -ne $sync.configs.feature.PSObject.Properties[$cbkey]
|
|
}
|
|
'selectedAppx' {
|
|
$sync.configs.appxHashtable.ContainsKey($cbkey)
|
|
}
|
|
}
|
|
|
|
if (-not $isKnownSelection) {
|
|
if ($SkipUnknown) {
|
|
$cbkey
|
|
continue
|
|
}
|
|
throw "Unknown selection key '$cbkey'."
|
|
}
|
|
|
|
$nextSelections[$listName].Add($cbkey)
|
|
}
|
|
|
|
$validSelectionCount = ($nextSelections.Values | ForEach-Object { $_.Count } | Measure-Object -Sum).Sum
|
|
if ($SkipUnknown -and $validSelectionCount -eq 0) {
|
|
return
|
|
}
|
|
|
|
if ($Replace) {
|
|
foreach ($listName in $nextSelections.Keys) {
|
|
$sync[$listName] = $nextSelections[$listName]
|
|
}
|
|
return
|
|
}
|
|
|
|
foreach ($listName in $nextSelections.Keys) {
|
|
foreach ($cbkey in $nextSelections[$listName]) {
|
|
$sync.$listName.Add($cbkey)
|
|
}
|
|
}
|
|
}
|