mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2026-08-09 17:41:14 +10:00
* Update Invoke-WPFGetInstalled.ps1 * Update Install-WinUtilWinget.ps1 * Update Install-WinUtilChoco.ps1 * Update Install-WinUtilChoco.ps1 * Update Install-WinUtilWinget.ps1 * Delete functions/private/Test-WinUtilPackageManager.ps1 * Update Install-WinUtilChoco.ps1 * Update Install-WinUtilWinget.ps1 * Update Install-WinUtilChoco.ps1 * Update Invoke-WPFGetInstalled.ps1 * Update Invoke-WPFGetInstalled.ps1 * Update Install-WinUtilChoco.ps1 * Update Install-WinUtilWinget.ps1 * Update Install-WinUtilWinget.ps1 * Update Install-WinUtilChoco.ps1 * Update Install-WinUtilWinget.ps1 * Update Install-WinUtilChoco.ps1 * Update Install-WinUtilWinget.ps1 * Update Install-WinUtilChoco.ps1 * Update Install-WinUtilChoco.ps1 * Update Install-WinUtilChoco.ps1 * Update Install-WinUtilChoco.ps1 * Update Install-WinUtilWinget.ps1 * Fixed lastrun.json * refactor: remove PackageManagers enum and unused custom exception classes * Update Invoke-WPFUIElements.ps1 * Update Get-WinUtilSelectedPackages.ps1 * Update Set-Preferences.ps1 * Update main.ps1 * Complete package manager enum removal Use string package-manager preferences throughout the remaining helpers and focused tests. Restore the existing Winget install flow and package-manager probe helper so PR 4606 keeps the current WinGet repair method. * Fix string keyed package split --------- Co-authored-by: Chris Titus <contact@christitus.com>
56 lines
1.6 KiB
PowerShell
56 lines
1.6 KiB
PowerShell
function Get-WinUtilSelectedPackages {
|
|
|
|
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[object] $PackageList,
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
[string] $Preference
|
|
)
|
|
|
|
if ($PackageList.count -eq 1) {
|
|
Invoke-WPFUIThread -ScriptBlock { Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" }
|
|
} else {
|
|
Invoke-WPFUIThread -ScriptBlock { Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" }
|
|
}
|
|
|
|
$packagesWinget = [System.Collections.ArrayList]::new()
|
|
$packagesChoco = [System.Collections.ArrayList]::new()
|
|
$packages = @{
|
|
Winget = $packagesWinget
|
|
Choco = $packagesChoco
|
|
}
|
|
|
|
function Add-PackageId {
|
|
param(
|
|
[System.Collections.ArrayList]$Target,
|
|
$PackageId
|
|
)
|
|
|
|
if ([string]::IsNullOrWhiteSpace([string]$PackageId) -or $PackageId -eq "na") {
|
|
return
|
|
}
|
|
|
|
if (-not $Target.Contains($PackageId)) {
|
|
$null = $Target.Add($PackageId)
|
|
}
|
|
}
|
|
|
|
foreach ($package in $PackageList) {
|
|
switch ($Preference) {
|
|
"Choco" {
|
|
if ([string]::IsNullOrWhiteSpace([string]$package.choco) -or $package.choco -eq "na") {
|
|
Add-PackageId -Target $packagesWinget -PackageId $package.winget
|
|
} else {
|
|
Add-PackageId -Target $packagesChoco -PackageId $package.choco
|
|
}
|
|
}
|
|
"Winget" {
|
|
Add-PackageId -Target $packagesWinget -PackageId $package.winget
|
|
}
|
|
}
|
|
}
|
|
|
|
return $packages
|
|
}
|