Skip to content

Commit

Permalink
Added Update-VSTeamNuGetPackageVersion (#358)
Browse files Browse the repository at this point in the history
Added Update-VSTeamNuGetPackageVersion
Updated changelog and version to 7.1.0
  • Loading branch information
DarqueWarrior authored Oct 2, 2020
1 parent a2a8722 commit 07a284a
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 8 deletions.
73 changes: 73 additions & 0 deletions .docs/Update-VSTeamNuGetPackageVersion.md
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)
1 change: 1 addition & 0 deletions .docs/synopsis/Update-VSTeamNuGetPackageVersion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Set mutable state on a package version.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Changelog

## Next
## 7.1.0

Added:

- Get-VSTeamPackage to return packages of a feed.
- Show-VSTeamPackage to open package in default browser.
- Get-VSTeamPackageVersion to return all the versions of a package.
- Update-VSTeamNuGetPackageVersion to list and un-list versions.

## 7.0.1

Expand Down
40 changes: 40 additions & 0 deletions Source/Public/Update-VSTeamNuGetPackageVersion.ps1
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
}
}
}
}
2 changes: 1 addition & 1 deletion Source/VSTeam.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'VSTeam.psm1'

# Version number of this module.
ModuleVersion = '7.0.1'
ModuleVersion = '7.1.0'

# Supported PSEditions
CompatiblePSEditions = @('Core', 'Desktop')
Expand Down
6 changes: 6 additions & 0 deletions Source/formats/vsteam_lib.PackageVersion.TableView.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<TableColumnHeader>
<Label>Version</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Listed</Label>
</TableColumnHeader>
<TableColumnHeader>
<Label>Publish Date</Label>
</TableColumnHeader>
Expand All @@ -26,6 +29,9 @@
<TableColumnItem>
<PropertyName>Version</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>IsListed</PropertyName>
</TableColumnItem>
<TableColumnItem>
<PropertyName>PublishDate</PropertyName>
</TableColumnItem>
Expand Down
5 changes: 1 addition & 4 deletions Tests/function/tests/Update-VSTeamExtension.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ Set-StrictMode -Version Latest
Describe 'VSTeamExtension' {
BeforeAll {
. "$PSScriptRoot\_testInitialize.ps1" $PSCommandPath

Mock _getInstance { return 'https://dev.azure.com/test' }
}

Context 'Update-VSTeamExtension' {
Expand All @@ -21,10 +19,9 @@ Describe 'VSTeamExtension' {
Update-VSTeamExtension -PublisherId 'test' -ExtensionId 'test' -ExtensionState disabled -Force

Should -Invoke _callAPI -Exactly 1 -Scope It -ParameterFilter {
$Method -eq 'Post' -and
$Method -eq 'Patch' -and
$subDomain -eq 'extmgmt' -and
$version -eq [vsteam_lib.Versions]::ExtensionsManagement
$Url -like "*https://extmgmt.dev.azure.com/test/_apis/_apis/extensionmanagement/installedextensionsbyname/test/test*"
}
}
}
Expand Down
34 changes: 34 additions & 0 deletions Tests/function/tests/Update-VSTeamNuGetPackageVersion.Tests.ps1
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
}
}
}
}
5 changes: 3 additions & 2 deletions Tests/integration/tests/040_Format.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ Describe 'Table Formats for Provider classes' -Tag 'integration' {
$cols = Get-Columns -TypeName vsteam_lib.PackageVersion

$cols[0] | Should -Be 'Version'
$cols[1] | Should -Be 'Publish Date'
$cols[1] | Should -Be 'Listed'
$cols[2] | Should -Be 'Publish Date'
}
}
}
}

0 comments on commit 07a284a

Please sign in to comment.