Skip to content

Commit

Permalink
Merge pull request #90 from jakkulabs/development
Browse files Browse the repository at this point in the history
PowervRA v1.5.1
  • Loading branch information
jonathanmedd committed Dec 21, 2016
2 parents ec54c27 + 5c7f94e commit 874e941
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
.PARAMETER Description
Content Package Description
.PARAMETER ContentId
A list content Ids to include in the Package
.PARAMETER Id
A list of content Ids to include in the Package
.PARAMETER ContentName
A list of content names to include in the Package
Expand All @@ -28,11 +28,14 @@
System.Management.Automation.PSObject
.EXAMPLE
New-vRAPackage -Name Package01 -Description "This is Content Package 01" -ContentId "58e10956-172a-48f6-9373-932f99eab37a","0c74b085-dbc1-4fea-9cbf-a1601f668a1f"
New-vRAPackage -Name Package01 -Description "This is Content Package 01" -Id "58e10956-172a-48f6-9373-932f99eab37a","0c74b085-dbc1-4fea-9cbf-a1601f668a1f"
.EXAMPLE
New-vRAPackage -Name Package01 -Description "This is Content Package 01" -ContentName "Blueprint01","Blueprint02"
.EXAMPLE
Get-vRAContent | New-vRAPackage -Name Package01 - Description "This is Content Package 01"
.EXAMPLE
$JSON = @"
{
Expand All @@ -56,9 +59,10 @@
[ValidateNotNullOrEmpty()]
[String]$Description,

[Parameter(Mandatory=$true,ParameterSetName="ById")]
[Parameter(Mandatory=$true,ParameterSetName="ById", ValueFromPipelineByPropertyName=$true)]
[ValidateNotNullOrEmpty()]
[String[]]$ContentId,
[Alias("ContentId")]
[String[]]$Id,

[Parameter(Mandatory=$true,ParameterSetName="ByName")]
[ValidateNotNullOrEmpty()]
Expand All @@ -74,50 +78,40 @@

xRequires -Version 7.0

$Object = [PSCustomObject] @{

name = $Name
description = $Description
contents = @()
}

}

process {

switch ($PsCmdlet.ParameterSetName)
{
"ById" {
"ById" {

$Object = [pscustomObject] @{
foreach ($CId in $Id) {

name = $Name
description = $Description
contents = @()
}

foreach ($Id in $ContentId) {

$Object.contents += $Id
Write-Verbose -Message "Adding content with id $($CId) to package"
$Object.contents += $CId

}

$Body = $Object | ConvertTo-Json

break
}

"ByName" {

$Object = [pscustomObject] @{

name = $Name
description = $Description
contents = @()
}

foreach ($CName in $ContentName) {

Write-Verbose -Message "Adding content with id $($CName) to package"
$Id = (Get-vRAContent -Name $CName).Id

$Object.contents += $Id

}

$Body = $Object | ConvertTo-Json

break
}
Expand All @@ -132,6 +126,11 @@
break
}
}
}
end {

# --- Convert PSCustomObject to a string
$Body = $Object | ConvertTo-Json

if ($PSCmdlet.ShouldProcess($Name)){

Expand All @@ -141,10 +140,7 @@
Invoke-vRARestMethod -Method POST -URI $URI -Body $Body -Verbose:$VerbosePreference | Out-Null

# --- Output the Successful Result
Get-vRAPackage -Name $Name
}
}
end {

Get-vRAPackage -Name $Name -Verbose:$VerbosePreference
}
}
}
Binary file modified PowervRA/PowervRA.psd1
Binary file not shown.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1.4.0.{build}
version: 1.5.1.{build}
branches:
only:
- master
Expand Down
24 changes: 19 additions & 5 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
The build task that needs to be executed. The value of this parameter can be:
- Build
- Release
- PrepareRelease
- Analyze
- UpdateModuleManifest
- UpdateDocumentation
Expand All @@ -35,6 +35,16 @@
The BumpVersion will increment the version of the Module Manifest based on the $BumpVersion setting provided in build.settings.ps1.
By default this is patch.
.PARAMETER Version
The part of the version you wish to bump for this release.
Possible values are:
- NONE
- PATCH
- MINOR
- MAJOR
.INPUTS
System.String
Expand All @@ -45,7 +55,7 @@
.\build.ps1
.Example
.\build.ps1 -Task Release
.\build.ps1 -Task PrepareRelease
.Example
.\build.ps1 -Task Analyze
Expand All @@ -69,12 +79,16 @@
Param (

[Parameter()]
[ValidateSet("Build", "Release", "Analyze", "UpdateModuleManifest", "UpdateDocumentation", "BumpVersion", "Test")]
[String]$Task = "Build"
[ValidateSet("Build", "PrepareRelease", "Analyze", "UpdateModuleManifest", "UpdateDocumentation", "BumpVersion", "Test")]
[String]$Task = "Build",

[Parameter()]
[ValidateSet("PATCH", "MINOR", "MAJOR")]
[String]$Version

)

# --- Start Build
Invoke-psake -buildFile "$($PSScriptRoot)\build.psake.ps1" -taskList $Task -nologo -Verbose:$VerbosePreference
Invoke-psake -buildFile "$($PSScriptRoot)\build.psake.ps1" -taskList $Task -parameters @{"Version"=$Version} -nologo -Verbose:$VerbosePreference

exit ( [int]( -not $psake.build_success ) )
44 changes: 32 additions & 12 deletions build.psake.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# --- Dot source build.settings.ps1
. $PSScriptRoot\build.settings.ps1

# --- Add any parameters from build.ps1
properties {

$BumpVersion = $Version

}

# --- Define the build tasks
Task Default -depends Build
Task Build -depends Analyze, UpdateModuleManifest, UpdateDocumentation
Task Release -depends Build, Test, BumpVersion
Task PrepareRelease -depends Build, BumpVersion

Task Analyze {

Expand Down Expand Up @@ -112,16 +119,15 @@ Task UpdateDocumentation {
return
}

if (!(Test-Path -LiteralPath $DocsDirectory)) {
New-Item $DocsDirectory -ItemType Directory | Out-Null
}
if (Test-Path -LiteralPath $DocsDirectory) {

Remove-Item -Path $DocsDirectory -Recurse -Force

if (Get-ChildItem -LiteralPath $DocsDirectory -Filter *.md -Recurse) {
Get-ChildItem -LiteralPath $DocsDirectory -Directory | ForEach-Object {
Update-MarkdownHelp -Path $_.FullName -Verbose:$VerbosePreference | Out-Null
}
}


New-Item $DocsDirectory -ItemType Directory | Out-Null

# --- ErrorAction set to SilentlyContinue so this command will not overwrite an existing MD file.
New-MarkdownHelp -Module $ModuleName -Locale $DefaultLocale -OutputFolder $DocsDirectory -NoMetadata `
-ErrorAction SilentlyContinue -Verbose:$VerbosePreference | Out-Null
Expand Down Expand Up @@ -204,7 +210,7 @@ Task BumpVersion {

switch ($BumpVersion) {

'Major' {
'MAJOR' {

Write-Verbose -Message "Bumping module major release number"

Expand All @@ -216,7 +222,7 @@ Task BumpVersion {

}

'Minor' {
'MINOR' {

Write-Verbose -Message "Bumping module minor release number"

Expand All @@ -227,7 +233,7 @@ Task BumpVersion {

}

'Patch' {
'PATCH' {

Write-Verbose -Message "Bumping module patch release number"

Expand All @@ -236,17 +242,31 @@ Task BumpVersion {
break
}

default {

Write-Verbose -Message "Not bumping module version"
break

}

}

# --- Build the new version string
$ModuleVersion = "$($MajorVersion).$($MinorVersion).$($PatchVersion)"

if ($ModuleVersion -gt $CurrentModuleVersion) {
if ([version]$ModuleVersion -gt [version]$CurrentModuleVersion) {

# --- Fix taken from: https://github.com/RamblingCookieMonster/BuildHelpers/blob/master/BuildHelpers/Public/Step-ModuleVersion.ps1
New-ModuleManifest -Path $ModuleManifestPath -ModuleVersion $ModuleVersion @ModuleManifest -Verbose:$VerbosePreference
Write-Verbose -Message "Module version updated to $($ModuleVersion)"

# --- Update appveyor build version
$AppveyorYMLPath = "$($PSScriptRoot)\appveyor.yml"
$AppveyorVersion = "$($ModuleVersion).{build}"
$NewAppveyorYML = Get-Content -Path $AppveyorYMLPath | ForEach-Object { $_ -replace '^version: .+$', "version: $($AppveyorVersion)";}
$NewAppveyorYML | Set-Content -Path $AppveyorYMLPath -Force
Write-Verbose -Message "Appveyor build version set to $($AppveyorVersion)"

}

}
Expand Down
5 changes: 0 additions & 5 deletions build.settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ Properties {
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseDeclaredVarsMoreThanAssigments', '')]
$ModuleCopyright = '(c) 2016 Jakku Labs. All rights reserved.'

# --- Setting to use when calling the BumpVersion task. This can either be Major, Minor or Patch.
# --- This setting should eventually be parameterised
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseDeclaredVarsMoreThanAssigments', '')]
$BumpVersion = "Patch"

# ----------------------- Basic properties --------------------------------

[System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseDeclaredVarsMoreThanAssigments', '')]
Expand Down
17 changes: 11 additions & 6 deletions docs/New-vRAPackage.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Create a vRA Content Package

### ById (Default)
```
New-vRAPackage -Name <String> [-Description <String>] -ContentId <String[]> [-WhatIf] [-Confirm]
New-vRAPackage -Name <String> [-Description <String>] -Id <String[]> [-WhatIf] [-Confirm]
```

### ByName
Expand All @@ -27,7 +27,7 @@ Create a vRA Package

### -------------------------- EXAMPLE 1 --------------------------
```
New-vRAPackage -Name Package01 -Description "This is Content Package 01" -ContentId "58e10956-172a-48f6-9373-932f99eab37a","0c74b085-dbc1-4fea-9cbf-a1601f668a1f"
New-vRAPackage -Name Package01 -Description "This is Content Package 01" -Id "58e10956-172a-48f6-9373-932f99eab37a","0c74b085-dbc1-4fea-9cbf-a1601f668a1f"
```

### -------------------------- EXAMPLE 2 --------------------------
Expand All @@ -37,6 +37,11 @@ New-vRAPackage -Name Package01 -Description "This is Content Package 01" -Conten

### -------------------------- EXAMPLE 3 --------------------------
```
Get-vRAContent | New-vRAPackage -Name Package01 - Description "This is Content Package 01"
```

### -------------------------- EXAMPLE 4 --------------------------
```
$JSON = @"
```

Expand Down Expand Up @@ -80,18 +85,18 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -ContentId
A list content Ids to include in the Package
### -Id
A list of content Ids to include in the Package
```yaml
Type: String[]
Parameter Sets: ById
Aliases:
Aliases: ContentId

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
Expand Down

0 comments on commit 874e941

Please sign in to comment.