Skip to content

Commit

Permalink
Release v2.4
Browse files Browse the repository at this point in the history
Merge pull request #159 from lipkau/release/v2.4
  • Loading branch information
lipkau authored Dec 12, 2018
2 parents 3a72a1a + 401912b commit b176b23
Show file tree
Hide file tree
Showing 14 changed files with 483 additions and 140 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ about: Create a report to help us improve
<!-- The following code snip is a recommendation. You can just paste the output here. -->

> ```powershell
> Get-Module AtlassianPS.Configuration -ListAvailable | Select Name, Version
> Get-Module ConfluencePS -ListAvailable | Select Name, Version
> $PSVersionTable
> ```
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

.

## [2.4] 2018-12-12

### Added

- Added `-Vertical` to `ConvertTo-Table` (#148, [@brianbunke])
- Added support for TLS1.2 (#155, [@lipkau])

### Changed

- Changed productive module files to be compiled into single `.psm1` file (#133, [@lipkau])
- Fixed `ConvertTo-Table` for empty cells (#144, [@FelixMelchert])
- Changed CI/CD pipeline from AppVeyor to Azure DevOps (#150, [@lipkau])
- Fixed trailing slash in ApiURi parameter (#153, [@lipkau])

## [2.3] 2018-03-22

### Added
Expand Down Expand Up @@ -167,6 +181,7 @@ No changelog available for version `1.0` of ConfluencePS. `1.0` was created in l
[@colhal]: https://github.com/colhal
[@Dejulia489]: https://github.com/Dejulia489
[@ebekker]: https://github.com/ebekker
[@FelixMelchert]: https://github.com/FelixMelchert
[@jkknorr]: https://github.com/jkknorr
[@JohnAdders]: https://github.com/JohnAdders
[@kittholland]: https://github.com/kittholland
Expand Down
3 changes: 1 addition & 2 deletions ConfluencePS.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ task InstallDependencies {

# Synopsis: Get the next version for the build
task GetNextVersion {
$manifestVersion = [Version](Get-Metadata -Path $env:BHPSModuleManifest)
try {
$env:CurrentOnlineVersion = [Version](Find-Module -Name $env:BHProjectName).Version
$manifestVersion = [Version](Get-Metadata -Path $env:BHPSModuleManifest)
$nextOnlineVersion = Get-NextNugetPackageVersion -Name $env:BHProjectName

if ( ($manifestVersion.Major -gt $nextOnlineVersion.Major) -or
Expand Down Expand Up @@ -250,7 +250,6 @@ task Test Init, {
}
$testResults = Invoke-Pester @parameter

Write-Host (Get-Childitem $env:BHProjectPath)
Assert-True ($testResults.FailedCount -eq 0) "$($testResults.FailedCount) Pester test(s) failed."
}
catch {
Expand Down
2 changes: 1 addition & 1 deletion ConfluencePS/ConfluencePS.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'ConfluencePS.psm1'

# Version number of this module.
ModuleVersion = '2.3'
ModuleVersion = '2.4'

# ID used to uniquely identify this module
GUID = '20d32089-48ef-464d-ba73-6ada240e26b3'
Expand Down
26 changes: 26 additions & 0 deletions ConfluencePS/Private/Set-TlsLevel.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function Set-TlsLevel {
[CmdletBinding( SupportsShouldProcess = $false )]
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSUseShouldProcessForStateChangingFunctions', '')]
param (
[Parameter(Mandatory, ParameterSetName = 'Set')]
[Switch]$Tls12,

[Parameter(Mandatory, ParameterSetName = 'Revert')]
[Switch]$Revert
)

begin {
switch ($PSCmdlet.ParameterSetName) {
"Set" {
$Script:OriginalTlsSettings = [Net.ServicePointManager]::SecurityProtocol

[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
}
"Revert" {
if ($Script:OriginalTlsSettings) {
[Net.ServicePointManager]::SecurityProtocol = $Script:OriginalTlsSettings
}
}
}
}
}
53 changes: 33 additions & 20 deletions ConfluencePS/Public/ConvertTo-Table.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,58 @@ function ConvertTo-Table {
)]
$Content,

[switch]$NoHeader
[Switch]$Vertical,

[Switch]$NoHeader
)

BEGIN {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"

$RowArray = New-Object System.Collections.ArrayList
$sb = [System.Text.StringBuilder]::new()
}

PROCESS {
Write-Debug "[$($MyInvocation.MyCommand.Name)] ParameterSetName: $($PsCmdlet.ParameterSetName)"
Write-Debug "[$($MyInvocation.MyCommand.Name)] PSBoundParameters: $($PSBoundParameters | Out-String)"

If ($NoHeader) {
$HeaderGenerated = $true
}
$HeaderGenerated = $NoHeader

# This ForEach needed if the content wasn't piped in
$Content | ForEach-Object {
# First row enclosed by ||, all other rows by |
If (!$HeaderGenerated) {
$_.PSObject.Properties |
ForEach-Object -Begin {$Header = ""} `
-Process {$Header += "||$($_.Name)"} `
-End {$Header += "||"}
$RowArray.Add($Header) | Out-Null
$HeaderGenerated = $true
If ($Vertical) {
If ($HeaderGenerated) {$pipe = '|'}
Else {$pipe = '||'}

# Put an empty row between multiple tables (objects)
If ($Spacer) {
$null = $sb.AppendLine('')
}

$_.PSObject.Properties | ForEach-Object {
$row = ("$pipe {0} $pipe {1} |" -f $_.Name, $_.Value) -replace "\|\s\s", "| "
$null = $sb.AppendLine($row)
}

$Spacer = $true
} Else {
# Header row enclosed by ||
If (-not $HeaderGenerated) {
$null = $sb.AppendLine("|| {0} ||" -f ($_.PSObject.Properties.Name -join " || "))
$HeaderGenerated = $true
}

# All other rows enclosed by |
$row = ("| " + ($_.PSObject.Properties.Value -join " | ") + " |") -replace "\|\s\s", "| "
$null = $sb.AppendLine($row)
}
$_.PSObject.Properties |
ForEach-Object -Begin {$Row = ""} `
-Process {if ($($_.value)) {$Row += "|$($_.Value)"} else {$Row += "| "}} `
-End {$Row += "|"}
$RowArray.Add($Row) | Out-Null
}
}

END {
$RowArray | Out-String
# Return the array as one large, multi-line string
$sb.ToString()

Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function ened"
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function ended"
}
}
1 change: 0 additions & 1 deletion ConfluencePS/Public/Get-Label.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ function Get-Label {
$InputObject = Get-Page -PageID $_page -ApiURi $apiURi -Credential $Credential
}
$iwParameters["Uri"] = $resourceApi -f $_page
Write-debug "Hey"
$output = New-Object -TypeName ConfluencePS.ContentLabelSet
$output.Page = $InputObject
$output.Labels += (Invoke-Method @iwParameters)
Expand Down
9 changes: 9 additions & 0 deletions ConfluencePS/Public/Invoke-Method.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ function Invoke-Method {
BEGIN {
Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function started"

Set-TlsLevel -Tls12

# Sanitize double slash `//`
# Happens when the BaseUri is the domain name
# [Uri]"http://google.com" vs [Uri]"http://google.com/foo"
$URi = $URi -replace '(?<!:)\/\/', '/'

# pass input to local variable
# this allows to use the PSBoundParameters for recursion
$_headers = @{ # Set any default headers
Expand Down Expand Up @@ -253,6 +260,8 @@ function Invoke-Method {
}

END {
Set-TlsLevel -Revert

Write-Verbose "[$($MyInvocation.MyCommand.Name)] Function ended"
}
}
18 changes: 18 additions & 0 deletions Tests/ConfluencePS.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,22 @@ Describe "General project validation" -Tag Unit {
[Version](Get-Metadata -Path $env:BHManifestToTest -PropertyName ModuleVersion) | Should -Not -BeNullOrEmpty
[Version](Get-Metadata -Path $env:BHManifestToTest -PropertyName ModuleVersion) | Should -BeOfType [Version]
}

It "module is imported with default prefix" {
$prefix = Get-Metadata -Path $env:BHManifestToTest -PropertyName DefaultCommandPrefix

Import-Module $env:BHManifestToTest -Force -ErrorAction Stop
(Get-Command -Module $env:BHProjectName).Name | ForEach-Object {
$_ | Should -Match "\-$prefix"
}
}

It "module is imported with custom prefix" {
$prefix = "Wiki"

Import-Module $env:BHManifestToTest -Prefix $prefix -Force -ErrorAction Stop
(Get-Command -Module $env:BHProjectName).Name | ForEach-Object {
$_ | Should -Match "\-$prefix"
}
}
}
Loading

0 comments on commit b176b23

Please sign in to comment.