OneGet/Find-Package.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
function Find-Package { param ( [string] $Name, [string] $RequiredVersion, [string] $MinimumVersion, [string] $MaximumVersion ) Write-Debug ($LocalizedData.ProviderDebugMessage -f ' Find-Package') $allVersions = Get-AllVersionsOption $validVersions = Validate-VersionParameters -Name $Name ` -MinimumVersion $MinimumVersion ` -MaximumVersion $MaximumVersion ` -RequiredVersion $RequiredVersion ` -AllVersions:$allVersions if (-not $validVersions) { return } $nameContainsWildCard = [System.Management.Automation.WildcardPattern]::ContainsWildcardCharacters($Name) $filterRequired = $false $nameContainWildCard = $false if (-not $Name) { # if a user does not provide a name, the entire repo will be searched; let's not do that Write-Error ($LocalizedData.SearchingEntireRepo) return } $progress = 5 Write-Progress -Activity $LocalizedData.SearchingForPackage -PercentComplete $progress -Id $script:FindPackageProgressId $force = Get-ForceOption $packageSources = @(Resolve-PackageSource -Force $force) if ($packageSources) { # choco does not support wildcard search, so remove them from start & end of the name and filter later $arguments = @( $Name.Trim('*','?') ) if ($RequiredVersion -or (Get-PrereleaseOption)) { $arguments += '--prerelease' } # choco does not support version search, so we'll find all-versions first and filter later if ($allVersions -or $RequiredVersion -or $MinimumVersion -or $MaximumVersion) { $arguments += '--allversions' } $packageSourceScriptBlock = { param ([Array]$ChocoArguments) $location = $_.Location $ChocoArguments += "--source='$($location)'" Invoke-Chocolatey -Command 'search' -Arguments $ChocoArguments -Force $force | ForEach-Object { New-Object -TypeName 'PSCustomObject' -Property @{ Package = $_ Location = $location } } } if ($packageSources.Length -eq 1) { $_ = $packageSources[0] $chocoPackages = $packageSourceScriptBlock.Invoke(@(,$Arguments)) } else { #$chocoPackages = $packageSources | ForEach-Parallel -ScriptBlock $packageSourceScriptBlock -ArgumentList $Arguments $progressStep = (70 - $progress) / $packageSources.Length $index = 0 $chocoPackages = $packageSources | ForEach-Object { $packageSourceScriptBlock.Invoke(@(,$Arguments)) $index++ Write-Progress -Activity $LocalizedData.SearchingForPackage -PercentComplete ([System.Math]::Min(70, $progress + ($index * $progressStep))) -Id $script:FindPackageProgressId } } } $chocoPackagesPerLocation = $chocoPackages | Group-Object -Property 'Location' $progress = 70 Write-Progress -Activity $LocalizedData.SearchingForPackage -PercentComplete $progress -Id $script:FindPackageProgressId $chocoPackagesPerLocation | ForEach-Object { $location = $_.Name Process-Package -Packages $_.Group.Package ` -Name $Name -NameContainsWildCard $nameContainsWildCard ` -Source $_.Name ` -RequiredVersion $RequiredVersion ` -MinimumVersion $MinimumVersion ` -MaximumVersion $MaximumVersion ` -ProgressStart $progress -ProgressEnd 100 -ProgressId $script:FindPackageProgressId } Write-Progress -Activity $LocalizedData.Complete -PercentComplete 100 -Completed -Id $script:FindPackageProgressId } <# TODO: use --verbose to get detailed package-info, including Summary choco list --verbose notepadplusplus 7.5 [Approved] Title: Notepad++ | Published: 15-Aug-17 Package approved by flcdrg on Aug 21 2017 02:03:23. Package testing status: Passing on Aug 16 2017 00:44:02. Number of Downloads: 910176 | Downloads for this version: 11520 Package url Chocolatey Package Source: https://github.com/chocolatey/chocolatey-coreteampackages/tree/master/automatic/notepadplusplus Package Checksum: 'JtblQAkYWV19lypc1xrnmY7EWK47qSqNr8a85dy5RiZHxtAWYuhR45UilqXbV41wJodBWzQug7sHLyC3+5ILtw==' (SHA512) Tags: notepad notepadplusplus notepad-plus-plus editor text development foss Software Site: https://notepad-plus-plus.org/ Software License: https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/LICENSE Software Source: https://github.com/notepad-plus-plus/notepad-plus-plus Mailing List: https://notepad-plus-plus.org/community/ Issues: https://github.com/notepad-plus-plus/notepad-plus-plus/issues Summary: Notepad++ is a free (as in "free speech" and also as in "free beer") source code editor and Notepad replacement that supports several languages. Description: Notepad++ is a free (as in "free speech" and also as in "free beer") source code editor and Notepad replacement that supports several languages. Running in the MS Windows environment, its use i s governed by GPL License. Based on the powerful editing component Scintilla, Notepad++ is written in C++ and uses pure Win32 API and STL which ensures a higher execution speed and smaller program size. By optimizing as many routine s as possible without losing user friendliness, Notepad++ is trying to reduce the world carbon dioxide emissions. When using less CPU power, the PC can throttle down and reduce power consumption, resulting i n a greener environment. ## Features * Syntax Highlighting and Syntax Folding * User Defined Syntax Highlighting and Folding: [screenshot 1](https://notepad-plus-plus.org/assets/images/scsh/ulds_folder.gif), [screenshot 2](https://notepad-plus-plus.org/assets/images/scsh/ulds_keywor ds.gif), [screenshot 3](https://notepad-plus-plus.org/assets/images/scsh/ulds_comment.gif) and [screenshot 4](https://notepad-plus-plus.org/assets/images/scsh/ulds_op.gif) * PCRE (Perl Compatible Regular Expression) Search/Replace * GUI entirely customizable: [minimalist](https://notepad-plus-plus.org/assets/images/scsh/scsh_gui_minimalist.png), [tab with close button](https://notepad-plus-plus.org/assets/images/scsh/scsh_gui_tabClo seButton.png), [multi-line tab](https://notepad-plus-plus.org/assets/images/scsh/scsh_gui_multiLineTab.png), [vertical tab](https://notepad-plus-plus.org/assets/images/scsh/scsh_gui_verticalTab.png) and [ver tical document list](https://notepad-plus-plus.org/assets/images/scsh/scsh_gui_verticalDocList.png) * [Document Map](https://notepad-plus-plus.org/assets/images/docMap.png) * Auto-completion: Word completion, Function completion and Function parameters hint * Multi-Document (Tab interface) * Multi-View * WYSIWYG (Printing) * Zoom in and zoom out * Multi-Language environment supported * Bookmark * Macro recording and playback * Launch with different [arguments](https://notepad-plus-plus.org/assets/images/scsh/scsh_cmdlineArguments.png) ## Notes - To force the installation of x32 version, use the `--x86` argument with `choco install`. Release Notes: https://notepad-plus-plus.org/news #> |