67 lines
2.9 KiB
PowerShell
67 lines
2.9 KiB
PowerShell
Function Test-CallProgetForPackages {
|
|
param (
|
|
[ArgumentCompleter({
|
|
param ( $commandName,
|
|
$parameterName,
|
|
$wordToComplete,
|
|
$commandAst,
|
|
$fakeBoundParameters )
|
|
$p = $fakeBoundParameters.Package
|
|
$p = "$p".ToLower()
|
|
$feed = $fakeBoundParameters.Feed
|
|
if ([string]::IsNullOrWhiteSpace($feed)) {
|
|
$feed = 'https://packagerepo.orb.alkamitech.com/nuget/choco.dev/'
|
|
}
|
|
if ($feed.EndsWith('/')) {
|
|
$feed = $feed.TrimEnd("/")
|
|
}
|
|
$response = Invoke-RestMethod "$feed/Packages()?`$filter=startswith(tolower(Id),'$p') and IsAbsoluteLatestVersion&`$top=1000"
|
|
$packages = $response.title."#text"
|
|
return $packages | Sort-Object
|
|
})]
|
|
[Alias("Id")]
|
|
[Alias("PackageId")]
|
|
[Alias("PackageName")]
|
|
[Alias("Name")]
|
|
[string]$Package,
|
|
[ArgumentCompleter({
|
|
param ( $commandName,
|
|
$parameterName,
|
|
$wordToComplete,
|
|
$commandAst,
|
|
$fakeBoundParameters )
|
|
$p = $fakeBoundParameters.Package
|
|
$p = "$p".ToLower()
|
|
$feed = $fakeBoundParameters.Feed
|
|
if ([string]::IsNullOrWhiteSpace($feed)) {
|
|
$feed = 'https://packagerepo.orb.alkamitech.com/nuget/choco.dev/'
|
|
}
|
|
if ($feed.EndsWith('/')) {
|
|
$feed = $feed.TrimEnd("/")
|
|
}
|
|
$response = Invoke-RestMethod "$feed/Packages()?`$filter=tolower(Id) eq '$p'&`$orderby=Version desc&`$top=1000"
|
|
Write-Host "Invoke-RestMethod `"$feed/Packages()?`$filter=tolower(Id) eq '$p'&`$orderby=Version desc&`$top=1000`""
|
|
$versions = $response.properties.Version
|
|
return $versions
|
|
})]
|
|
[Alias("V")]
|
|
[Alias("PackageVersion")]
|
|
[string]$Version,
|
|
[ArgumentCompleter({
|
|
param ( $commandName,
|
|
$parameterName,
|
|
$wordToComplete,
|
|
$commandAst,
|
|
$fakeBoundParameters )
|
|
$configPath = Join-Path -Path (Get-ChocolateyInstallPath) -ChildPath "config\chocolatey.config"
|
|
if (Test-Path -Path $configPath) {
|
|
$config = [xml](Get-Content -Path $configPath)
|
|
return ($config.chocolatey.sources.source | Where-Object {$_.Disabled -ne 'true'}).value
|
|
}
|
|
return @('https://packagerepo.orb.alkamitech.com/nuget/choco.dev/')
|
|
})]
|
|
[Alias("Source")]
|
|
[string]$Feed
|
|
)
|
|
}
|