Refactor: Cleanup app removal, remove legacy app list generator and CustomAppsList file support (#662)

* remove support for uninstalling old sunset apps

* Add color legend on app removal screen

* Remove legacy app list generator and custom apps file support
Replaced by GUI config export/import, dynamic RemovalMethod, and
CLI app removal settings saved to LastUsedSettings.json.

* Verify app removal by checking actual installation state instead of trusting winget output
This commit is contained in:
Jeffrey
2026-06-22 22:13:01 +02:00
committed by GitHub
parent 71e3f2e44d
commit d1fe541b62
22 changed files with 865 additions and 477 deletions

View File

@@ -2,7 +2,7 @@
function LoadAppsDetailsFromJson {
param (
[switch]$OnlyInstalled,
[string]$InstalledList = "",
[object[]]$InstalledList = $null,
[switch]$InitialCheckedFromJson
)
@@ -24,22 +24,19 @@ function LoadAppsDetailsFromJson {
if ($OnlyInstalled) {
$isInstalled = $false
foreach ($appId in $appIdArray) {
if (($InstalledList -like ("*$appId*")) -or (Get-AppxPackage -Name $appId)) {
# Check Get-AppxPackage first (fast, no process launch)
if (Get-AppxPackage -Name $appId) {
$isInstalled = $true
break
}
if (($appId -eq "Microsoft.Edge") -and ($InstalledList -like "* Microsoft.Edge *")) {
$isInstalled = $true
break
}
if (($appId -eq "Microsoft.OneDrive") -and (
(Test-Path "$env:ProgramFiles\Microsoft OneDrive\OneDrive.exe") -or
(Test-Path "$env:LOCALAPPDATA\Microsoft\OneDrive\OneDrive.exe")
)) {
# Then check the pre-fetched winget list
if ($InstalledList -and (Test-AppInWingetList -appId $appId -InstalledList $InstalledList)) {
$isInstalled = $true
break
}
}
if (-not $isInstalled) { continue }
}
@@ -59,6 +56,7 @@ function LoadAppsDetailsFromJson {
Description = $appData.Description
SelectedByDefault = $appData.SelectedByDefault
Recommendation = $appData.Recommendation
RemovalMethod = if ($appData.RemovalMethod -and $appData.RemovalMethod -eq 'WinGet') { 'WinGet' } else { 'Appx' }
}
}

View File

@@ -1,4 +1,19 @@
# Returns list of apps from the specified file, it trims the app names and removes any comments
<#
.SYNOPSIS
Returns a list of app IDs from the specified JSON file.
.DESCRIPTION
Reads an Apps.json file and returns the AppIds for every entry where
SelectedByDefault is $true. Each app entry may declare a single AppId
or an array of AppIds; both forms are handled transparently.
.PARAMETER appsFilePath
Path to a JSON file in the Config/Apps.json format.
.OUTPUTS
System.String[]. An array of app ID strings, or an empty array if the
file does not exist or contains no selected-by-default apps.
#>
function LoadAppsFromFile {
param (
$appsFilePath
@@ -11,30 +26,14 @@ function LoadAppsFromFile {
}
try {
# Check if file is JSON or text format
if ($appsFilePath -like "*.json") {
# JSON file format
$jsonContent = Get-Content -Path $appsFilePath -Raw | ConvertFrom-Json
Foreach ($appData in $jsonContent.Apps) {
# Handle AppId as array (could be single or multiple IDs)
$appIdArray = if ($appData.AppId -is [array]) { $appData.AppId } else { @($appData.AppId) }
$appIdArray = $appIdArray | ForEach-Object { $_.Trim() } | Where-Object { $_.length -gt 0 }
$selectedByDefault = $appData.SelectedByDefault
if ($selectedByDefault -and $appIdArray.Count -gt 0) {
$appsList += $appIdArray
}
}
}
else {
# Legacy text file format
Foreach ($app in (Get-Content -Path $appsFilePath | Where-Object { $_ -notmatch '^#.*' -and $_ -notmatch '^\s*$' } )) {
if (-not ($app.IndexOf('#') -eq -1)) {
$app = $app.Substring(0, $app.IndexOf('#'))
}
$app = $app.Trim()
$appString = $app.Trim('*')
$appsList += $appString
$jsonContent = Get-Content -Path $appsFilePath -Raw | ConvertFrom-Json
Foreach ($appData in $jsonContent.Apps) {
# Handle AppId as array (could be single or multiple IDs)
$appIdArray = if ($appData.AppId -is [array]) { $appData.AppId } else { @($appData.AppId) }
$appIdArray = $appIdArray | ForEach-Object { $_.Trim() } | Where-Object { $_.length -gt 0 }
$selectedByDefault = $appData.SelectedByDefault
if ($selectedByDefault -and $appIdArray.Count -gt 0) {
$appsList += $appIdArray
}
}

View File

@@ -1,20 +0,0 @@
# Saves the provided appsList to the CustomAppsList file
function SaveCustomAppsListToFile {
param (
$appsList
)
if ($script:Params.ContainsKey("WhatIf")) {
Write-Host "[WhatIf] Save custom apps list to file" -ForegroundColor Cyan
return
}
$script:SelectedApps = $appsList
# Create file that stores selected apps if it doesn't exist
if (-not (Test-Path $script:CustomAppsListFilePath)) {
$null = New-Item $script:CustomAppsListFilePath -ItemType File
}
Set-Content -Path $script:CustomAppsListFilePath -Value $script:SelectedApps
}