49 lines
1.8 KiB
PowerShell
49 lines
1.8 KiB
PowerShell
|
function Get-PackageFileList {
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
Returns the json object of a package's file contents.
|
||
|
#>
|
||
|
[CmdletBinding()]
|
||
|
Param(
|
||
|
[Parameter(Mandatory=$true)]
|
||
|
[string]$FeedSource,
|
||
|
[Parameter(Mandatory=$true)]
|
||
|
[string]$Name,
|
||
|
[Parameter(Mandatory=$true)]
|
||
|
[string]$Version,
|
||
|
[Parameter(Mandatory=$false)]
|
||
|
[PSCredential]$Credential = $null
|
||
|
)
|
||
|
|
||
|
$loglead = (Get-LogLeadName)
|
||
|
|
||
|
|
||
|
# Make sure the input feed URL is a nuget feed.
|
||
|
$url = $feedSource.Replace("\", "/")
|
||
|
if($url -notlike "https://*/nuget/*") {
|
||
|
Write-Error "$loglead : Feed URL must be in the format of `"https://feed.com/nuget/feed.name`""
|
||
|
return
|
||
|
}
|
||
|
|
||
|
# If a PSCredential is specified build a basic authentication header.
|
||
|
$headers = (Get-BasicAuthHeader -Credential $Credential)
|
||
|
|
||
|
# Parse out the base proget URL and the feed name.
|
||
|
$searchString = "/nuget/"
|
||
|
$index = $url.IndexOf($searchString)
|
||
|
$baseUrl = $url.Substring(0,$index)
|
||
|
$feedName = $url.Substring($index + $searchString.Length)
|
||
|
$feedName = $feedName.TrimEnd('/')
|
||
|
Write-Verbose "$loglead : Base URL: $baseUrl"
|
||
|
Write-Verbose "$loglead : Feed Name: $feedname"
|
||
|
|
||
|
# Query for all the files in the package.
|
||
|
# Note: This is a query for the filenames/contents of the package, and not a query to download a particular file.
|
||
|
$filesUrl = "$baseUrl/package-files/list?packageId=$($name)&version=$($version)&feedName=$($feedName)"
|
||
|
Write-Host "$loglead : Querying for package files at endpoint: $filesUrl"
|
||
|
|
||
|
$response = Invoke-ProgetRequest -URI $filesUrl -Headers $headers
|
||
|
$return = (ConvertFrom-Json -InputObject $response)
|
||
|
Write-Host "$loglead : Completed querying package files at endpoint: $filesUrl"
|
||
|
return $return
|
||
|
}
|