-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
feat: Add advanced dynamic search for package managers #4955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vyas-devgna
wants to merge
15
commits into
ChrisTitusTech:main
Choose a base branch
from
vyas-devgna:package-manager-search
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f897afd
refactor: optimize UI elements rendering, search filtering, and servi…
4aa35f0
fix: resolve review feedback on PR #4906
19e9123
fix: keep the Win11 ISO log outside the work directory
vyas-devgna f67bbdb
test: assert category markers survive the empty-search reset
vyas-devgna 1df1824
fix: restore UI tweak filtering support for ScrollViewers and StackPa…
vyas-devgna 2809531
feat: Add advanced dynamic search for package managers
vyas-devgna 4387dec
fix: correct package-manager invocation count assertion (2 calls x 2 …
vyas-devgna 7fe5239
fix: track in-flight package manager searches and collapse UI when cu…
vyas-devgna c3321c7
test: update xaml sync property whitelist for package manager UI state
vyas-devgna 20489cc
fix(UI): clear in-flight search keys on stale exits to fix search hang
vyas-devgna d50ec31
Fix PR 4955 review comments: search logic, service validation, ISO logs
vyas-devgna 465be87
fix(UI): Always collapse Package Manager Results by default
vyas-devgna 3d339a0
Address PR #4955 review and implement #4997
vyas-devgna dd11821
Address CodeRabbit PR reviews
vyas-devgna 6a38729
Address remaining CodeRabbit PR reviews and fix tests
vyas-devgna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| function Find-WinUtilPackageManagerApps { | ||
| <# | ||
| .SYNOPSIS | ||
| Searches the repository of the currently selected package manager (Winget or Choco). | ||
|
|
||
| .DESCRIPTION | ||
| Executes a search query against Winget or Chocolatey CLI and parses output | ||
| into custom objects with Name and Id properties. Handles errors gracefully. | ||
|
|
||
| .PARAMETER SearchString | ||
| The term to search for in the package manager repository. | ||
|
|
||
| .PARAMETER ManagerPreference | ||
| The selected package manager preference ("Winget" or "Choco"). | ||
|
|
||
| .NOTES | ||
| - Keep parser lightweight and fail safe without external dependencies. | ||
| #> | ||
| param( | ||
| [Parameter(Mandatory = $false)] | ||
| [string]$SearchString = "", | ||
|
|
||
| [Parameter(Mandatory = $false)] | ||
| [string]$ManagerPreference = "Winget" | ||
| ) | ||
|
|
||
| if ([string]::IsNullOrWhiteSpace($SearchString)) { | ||
| return ,@() | ||
| } | ||
|
|
||
| $results = [System.Collections.Generic.List[PSObject]]::new() | ||
|
|
||
| try { | ||
| if ($ManagerPreference -eq "Choco") { | ||
| if (-not (Get-Command choco -ErrorAction SilentlyContinue)) { | ||
| return ,@() | ||
| } | ||
|
|
||
| # choco --limit-output provides id|version format | ||
| $out = @(choco search $SearchString --limit-output 2>&1) | ||
| if ($LASTEXITCODE -ne 0) { return ,@() } | ||
| foreach ($line in $out) { | ||
| if ([string]::IsNullOrWhiteSpace($line)) { continue } | ||
| $parts = [string]$line -split '\|' | ||
| if ($parts.Count -ge 2 -and -not [string]::IsNullOrWhiteSpace($parts[0])) { | ||
| $id = $parts[0].Trim() | ||
| if ($id -notmatch '\s') { | ||
| $results.Add([pscustomobject]@{ | ||
| Name = $id | ||
| Id = $id | ||
| }) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| else { | ||
| if (-not (Get-Command winget -ErrorAction SilentlyContinue)) { | ||
| return ,@() | ||
| } | ||
|
|
||
| $originalEncoding = [Console]::OutputEncoding | ||
| try { | ||
| try { | ||
| [Console]::OutputEncoding = [System.Text.UTF8Encoding]::new() | ||
| } catch { | ||
| # Ignore encoding failure, proceed with search | ||
| } | ||
| $out = @(winget search $SearchString --accept-source-agreements --disable-interactivity 2>&1) | ||
| if ($LASTEXITCODE -ne 0) { return ,@() } | ||
| } | ||
| finally { | ||
| try { [Console]::OutputEncoding = $originalEncoding } catch {} | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| $lines = ($out -join "`n") -split '\r?\n' | ||
| $dashIndex = -1 | ||
| for ($i = 0; $i -lt $lines.Count; $i++) { | ||
| if ($lines[$i] -match '^-{3,}') { | ||
| $dashIndex = $i | ||
| break | ||
| } | ||
| } | ||
|
|
||
| if ($dashIndex -ge 0) { | ||
| for ($i = $dashIndex + 1; $i -lt $lines.Count; $i++) { | ||
| $l = $lines[$i].Trim() | ||
| if ([string]::IsNullOrWhiteSpace($l)) { continue } | ||
|
|
||
| $cols = @($l -split '\s{2,}') | ||
| if ($cols.Count -ge 2) { | ||
| $name = $cols[0].Trim() | ||
| $id = $cols[1].Trim() | ||
| if ($name -and $id -and ($id -notmatch '\s')) { | ||
| $results.Add([pscustomobject]@{ | ||
| Name = $name | ||
| Id = $id | ||
| }) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| catch { | ||
| Write-Warning "Find-WinUtilPackageManagerApps: Search failed for manager '$ManagerPreference': $_" | ||
| return ,@() | ||
| } | ||
|
|
||
| return ,($results.ToArray()) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On default WinGet installs,
winget searchcan return rows from bothwingetandmsstoresources (Microsoft documents--sourceas the way to narrow search results). This command neither constrains the source nor parses the Source column, so the dynamic entry later stores only$res.Id;Install-WinUtilProgramWingetthen forces--source wingetunless the ID is prefixed withmsstore:. Store-only results surfaced here will be selectable but fail to install, so either search only--source wingetor carry the parsed source through.Useful? React with 👍 / 👎.