-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Update-VSTeamNuGetPackageVersion (#358)
Added Update-VSTeamNuGetPackageVersion Updated changelog and version to 7.1.0
- Loading branch information
1 parent
a2a8722
commit 07a284a
Showing
9 changed files
with
161 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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,73 @@ | ||
<!-- #include "./common/header.md" --> | ||
|
||
# Update-VSTeamNuGetPackageVersion | ||
|
||
## SYNOPSIS | ||
|
||
<!-- #include "./synopsis/Update-VSTeamNuGetPackageVersion.md" --> | ||
|
||
## SYNTAX | ||
|
||
## DESCRIPTION | ||
|
||
<!-- #include "./synopsis/Update-VSTeamNuGetPackageVersion.md" --> | ||
|
||
## EXAMPLES | ||
|
||
### Example 1 | ||
|
||
```powershell | ||
Get-VSTeamPackageVersion -feedName ber -packageId 0d64db64-c7b7-412e-83f4-68c5f2bfc3d8 | Update-VSTeamNuGetPackageVersion -FeedId ber -PackageName Trackyon.Ber -isListed $false | ||
``` | ||
|
||
This command un-lists every version of Trackyon.Ber in the ber feed. | ||
|
||
## PARAMETERS | ||
|
||
### FeedId | ||
|
||
Name or Id of the feed. | ||
|
||
```yaml | ||
Type: String | ||
Required: True | ||
Aliases: feedName | ||
``` | ||
### PackageName | ||
Name of the package to update. This cannot be the id. | ||
```yaml | ||
Type: String | ||
Required: True | ||
``` | ||
### PackageVersion | ||
Version of the package to update. | ||
```yaml | ||
Type: String[] | ||
Required: True | ||
Aliases: Version | ||
Accept pipeline input: true (ByValue, ByPropertyName) | ||
``` | ||
<!-- #include "./params/forcegroup.md" --> | ||
## INPUTS | ||
## OUTPUTS | ||
## NOTES | ||
<!-- #include "./common/prerequisites.md" --> | ||
## RELATED LINKS | ||
<!-- #include "./common/related.md" --> | ||
[Get-VSTeamPackage](Get-VSTeamPackage.md) | ||
[Get-VSTeamPackageVersion](Get-VSTeamPackageVersion.md) |
This file contains 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 @@ | ||
Set mutable state on a package version. |
This file contains 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
This file contains 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,40 @@ | ||
function Update-VSTeamNuGetPackageVersion { | ||
[CmdletBinding(SupportsShouldProcess = $true, ConfirmImpact = "Medium", | ||
HelpUri = 'https://methodsandpractices.github.io/vsteam-docs/docs/modules/vsteam/commands/Update-VSTeamNuGetPackageVersion')] | ||
param ( | ||
[parameter(Mandatory)] | ||
[Alias("feedName")] | ||
[string] $FeedId, | ||
|
||
[parameter(Mandatory)] | ||
[string] $PackageName, | ||
|
||
[parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] | ||
[Alias("Version")] | ||
[string[]] $PackageVersion, | ||
|
||
[parameter(Mandatory = $true)] | ||
[bool] $isListed, | ||
|
||
[switch] $Force | ||
) | ||
process { | ||
foreach ($item in $PackageVersion) { | ||
if ($Force -or $pscmdlet.ShouldProcess($item, "update version")) { | ||
|
||
$obj = @{ | ||
listed = $isListed | ||
} | ||
|
||
$body = $obj | ConvertTo-Json -Compress | ||
|
||
_callAPI -Method PATCH -SubDomain pkgs ` | ||
-Area "packaging/feeds/$FeedId/nuget" ` | ||
-Resource "packages/$PackageName/versions" ` | ||
-Id $item ` | ||
-Body $body ` | ||
-Version $(_getApiVersion Packaging) | Out-Null | ||
} | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
34 changes: 34 additions & 0 deletions
34
Tests/function/tests/Update-VSTeamNuGetPackageVersion.Tests.ps1
This file contains 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,34 @@ | ||
Set-StrictMode -Version Latest | ||
|
||
Describe 'VSTeamNuGetPackageVersion' { | ||
BeforeAll { | ||
. "$PSScriptRoot\_testInitialize.ps1" $PSCommandPath | ||
} | ||
|
||
Context 'Update-VSTeamNuGetPackageVersion' { | ||
BeforeAll { | ||
$env:Team_TOKEN = '1234' | ||
Mock _callAPI { Open-SampleFile 'Get-VSTeamPackageVersion.json' -Index 0 } | ||
} | ||
|
||
AfterAll { | ||
$env:TEAM_TOKEN = $null | ||
} | ||
|
||
# id : 36c9353b-e250-4c57-b040-513c186c3905 | ||
# area : nuget | ||
# resourceName : Versions | ||
# routeTemplate : {project}/_apis/packaging/feeds/{feedId}/{area}/packages/{packageName}/{resource}/{packageVersion} | ||
It 'Should unlist version' { | ||
Update-VSTeamNuGetPackageVersion -FeedId 'feedName' -packageName 'packageName' -packageVersion '1137.0.0' -isListed $false -Force | ||
|
||
Should -Invoke _callAPI -Exactly 1 -Scope It -ParameterFilter { | ||
$Method -eq 'Patch' -and | ||
$Area -eq 'packaging/feeds/feedName/nuget' -and | ||
$Resource -eq 'packages/packageName/Versions' -and | ||
$subDomain -eq 'pkgs' -and | ||
$version -eq [vsteam_lib.Versions]::Packaging | ||
} | ||
} | ||
} | ||
} |
This file contains 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