Skip to content

Commit

Permalink
!deploy v2.33.2 ready for release (#243)
Browse files Browse the repository at this point in the history
## 2.33.2 - 2019-10-06

* [Issue #242](#242)
    * Fixed: Error handling around `[System.Console]::CursorVisible` on `Start-GSDriveFileUpload`, `Wait-GSDriveFileUpload` and `Write-InlineProgress`
    * Cleaned up verbose handling on `Stop-GSDriveFileUpload` due to file uploads showing as Failed even though they were successful.
* Miscellaneous
    * Updated build.ps1 script for better verbose output
  • Loading branch information
scrthq authored Oct 7, 2019
2 parents 6d7a989 + d984abd commit d9d6b11
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 40 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* [PSGSuite - ChangeLog](#psgsuite---changelog)
* [2.33.2 - 2019-10-06](#2332---2019-10-06)
* [2.33.1 - 2019-10-06](#2331---2019-10-06)
* [2.33.0 - 2019-09-26](#2330---2019-09-26)
* [2.32.3 - 2019-09-18](#2323---2019-09-18)
Expand Down Expand Up @@ -102,6 +103,14 @@

# PSGSuite - ChangeLog

## 2.33.2 - 2019-10-06

* [Issue #242](https://github.com/scrthq/PSGSuite/issues/242)
* Fixed: Error handling around `[System.Console]::CursorVisible` on `Start-GSDriveFileUpload`, `Wait-GSDriveFileUpload` and `Write-InlineProgress`
* Cleaned up verbose handling on `Stop-GSDriveFileUpload` due to file uploads showing as Failed even though they were successful.
* Miscellaneous
* Updated build.ps1 script for better verbose output

## 2.33.1 - 2019-10-06

* [Issue #235](https://github.com/scrthq/PSGSuite/issues/235)
Expand Down
2 changes: 1 addition & 1 deletion PSGSuite/PSGSuite.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PSGSuite.psm1'

# Version number of this module.
ModuleVersion = '2.33.1'
ModuleVersion = '2.33.2'

# ID used to uniquely identify this module
GUID = '9d751152-e83e-40bb-a6db-4c329092aaec'
Expand Down
29 changes: 25 additions & 4 deletions PSGSuite/Private/Write-InlineProgress.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,14 @@ function Write-InlineProgress {
Remove-Variable -Name 'lastProgressString' -Scope 'Script' -ErrorAction SilentlyContinue
[console]::WriteLine()
}
[console]::CursorVisible = $true
try {
[System.Console]::CursorVisible = $true
}
catch {
if ($Error[0].Exception.Message -eq 'Exception setting "CursorVisible": "The handle is invalid."') {
$Global:Error.Remove($Global:Error[0])
}
}
}
else {
if ($Completed) {
Expand All @@ -135,7 +142,14 @@ function Write-InlineProgress {

$cursorPosition = $host.UI.RawUI.CursorPosition
#$cursorPositionY = $host.UI.RawUI.CursorPosition.Y
[console]::CursorVisible=$false
try {
[System.Console]::CursorVisible = $false
}
catch {
if ($Error[0].Exception.Message -eq 'Exception setting "CursorVisible": "The handle is invalid."') {
$Global:Error.Remove($Global:Error[0])
}
}
$windowWidth = [console]::WindowWidth

# if screen is very small, don't display the percent
Expand Down Expand Up @@ -231,12 +245,19 @@ function Write-InlineProgress {
if ($Completed) {
# do some clean-up and jump to the next line
Remove-Variable -Name 'lastProgressString' -Scope 'Script' -ErrorAction SilentlyContinue
[console]::CursorVisible = $true
try {
[System.Console]::CursorVisible = $true
}
catch {
if ($Error[0].Exception.Message -eq 'Exception setting "CursorVisible": "The handle is invalid."') {
$Global:Error.Remove($Global:Error[0])
}
}
[console]::WriteLine()
}
}
}
else {
Write-Warning 'This function is not compatible with PowerShell ISE.'
}
}
}
23 changes: 20 additions & 3 deletions PSGSuite/Public/Drive/Start-GSDriveFileUpload.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ function Start-GSDriveFileUpload {
$throttleCount = 0
$totalThrottleCount = 0
$totalFiles = 0
$successParam = @{
Successful = $false
}
}
Process {
if ($User -ceq 'me') {
Expand Down Expand Up @@ -217,9 +220,14 @@ function Start-GSDriveFileUpload {
}
}
finally {
if ($Host.Name -and $Host.Name -notlike "Windows*PowerShell*ISE*") {
try {
[System.Console]::CursorVisible = $true
}
catch {
if ($Error[0].Exception.Message -eq 'Exception setting "CursorVisible": "The handle is invalid."') {
$Global:Error.Remove($Global:Error[0])
}
}
}
}
End {
Expand All @@ -233,6 +241,7 @@ function Start-GSDriveFileUpload {
$failedFiles = $fullStatusList | Where-Object {$_.Status -eq "Failed"}
if (!$failedFiles) {
Write-Verbose "All files uploaded to Google Drive successfully! Total time: $("{0:c}" -f ((Get-Date) - $start) -replace "\..*")"
$successParam['Successful'] = $true
}
elseif ($RetryCount) {
$totalRetries = 0
Expand Down Expand Up @@ -312,6 +321,7 @@ function Start-GSDriveFileUpload {
}
elseif (!$failedFiles) {
Write-Verbose "All files uploaded to Google Drive successfully! Total time: $("{0:c}" -f ((Get-Date) - $start) -replace "\..*")"
$successParam['Successful'] = $true
}
}
}
Expand All @@ -325,9 +335,16 @@ function Start-GSDriveFileUpload {
}
finally {
if ($Host.Name -and $Host.Name -notlike "Windows*PowerShell*ISE*") {
[System.Console]::CursorVisible = $true
try {
[System.Console]::CursorVisible = $true
}
catch {
if ($Error[0].Exception.Message -eq 'Exception setting "CursorVisible": "The handle is invalid."') {
$Global:Error.Remove($Global:Error[0])
}
}
}
Stop-GSDriveFileUpload
Stop-GSDriveFileUpload @successParam
}
}
}
Expand Down
15 changes: 12 additions & 3 deletions PSGSuite/Public/Drive/Stop-GSDriveFileUpload.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,30 @@ function Stop-GSDriveFileUpload {
.DESCRIPTION
Stops all Drive file uploads in progress and disposes of all streams.
.PARAMETER Successful
If $true, hides any failed task verbose output
.EXAMPLE
Stop-GSDriveFileUpload
Stops all Drive file uploads in progress and disposes of all streams.
#>
[cmdletbinding()]
Param ()
Param (
[Parameter(DontShow)]
[Switch]
$Successful
)
Begin {
Write-Verbose "Stopping all remaining Drive file uploads!"
}
Process {
foreach ($task in $script:DriveUploadTasks | Where-Object {$_.Stream -and -not $_.StreamDisposed}) {
try {
$progress = {$task.Request.GetProgress()}.InvokeReturnAsIs()
Write-Verbose "[$($progress.Status)] Stopping stream of Task Id [$($task.Id)] | File [$($task.File.FullName)]"
if (-not $Successful) {
$progress = {$task.Request.GetProgress()}.InvokeReturnAsIs()
Write-Verbose "[$($progress.Status)] Stopping stream of Task Id [$($task.Id)] | File [$($task.File.FullName)]"
}
$task.Stream.Dispose()
$task.StreamDisposed = $true
}
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ All other functions are either intact or have an alias included to support backw

[Full CHANGELOG here](https://github.com/scrthq/PSGSuite/blob/master/CHANGELOG.md)

#### 2.33.2 - 2019-10-06

* [Issue #242](https://github.com/scrthq/PSGSuite/issues/242)
* Fixed: Error handling around `[System.Console]::CursorVisible` on `Start-GSDriveFileUpload`, `Wait-GSDriveFileUpload` and `Write-InlineProgress`
* Cleaned up verbose handling on `Stop-GSDriveFileUpload` due to file uploads showing as Failed even though they were successful.
* Miscellaneous
* Updated build.ps1 script for better verbose output

#### 2.33.1 - 2019-10-06

* [Issue #235](https://github.com/scrthq/PSGSuite/issues/235)
Expand Down
10 changes: 1 addition & 9 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $Dependencies = @{
Configuration = '1.3.1'
psake = '4.9.0'
}
if ($env:SYSTEM_STAGENAME -eq 'Build') {
if ($env:SYSTEM_STAGENAME -eq 'Build' -or -not (Test-Path Env:\TF_BUILD)) {
$Dependencies['PowerShellGet'] = '2.2.1'
}
$update = @{}
Expand Down Expand Up @@ -137,14 +137,6 @@ else {
" + NuGet API key is not null : $($null -ne $env:NugetApiKey)`n" +
" + Commit message matches '!deploy' : $($env:BUILD_SOURCEVERSIONMESSAGE -match '!deploy') [$env:BUILD_SOURCEVERSIONMESSAGE]"| Write-Host -ForegroundColor Green
}
<#
if (-not (Get-Module BuildHelpers -ListAvailable | Where-Object {$_.Version -eq '2.0.1'})) {
Write-Verbose "Installing BuildHelpers v2.0.1" -Verbose
Install-Module 'BuildHelpers' -RequiredVersion 2.0.1 -Scope CurrentUser -Repository PSGallery -AllowClobber -SkipPublisherCheck -Force
}
Write-Verbose "Importing BuildHelpers v2.0.1" -Verbose
Import-Module 'BuildHelpers' -RequiredVersion 2.0.1
#>
Write-BuildLog "Resolving necessary modules"
$moduleDependencies.Name | Resolve-Module -UpdateModules -Verbose
Write-BuildLog "Modules resolved"
Expand Down
14 changes: 7 additions & 7 deletions ci/AzurePipelinesHelpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ Set-Alias -Name Summary -Value Add-EnvironmentSummary -Force
function Write-BuildWarning {
param(
[parameter(Mandatory,Position = 0,ValueFromRemainingArguments,ValueFromPipeline)]
[System.Object]
[System.String]
$Message
)
Process {
Write-Warning $Message
if ($IsCI) {
if ((Test-Path Env:\TF_BUILD)) {
Write-Host "##vso[task.logissue type=warning;]$Message"
}
else {
Expand All @@ -248,14 +248,14 @@ function Write-BuildWarning {
function Write-BuildError {
param(
[parameter(Mandatory,Position = 0,ValueFromRemainingArguments,ValueFromPipeline)]
[System.Object]
[System.String]
$Message
)
Process {
Write-Error $Message
if ($IsCI) {
if ((Test-Path Env:\TF_BUILD)) {
Write-Host "##vso[task.logissue type=error;]$Message"
}
throw $Message
}
}

Expand Down Expand Up @@ -388,14 +388,14 @@ function Set-EnvironmentVariable {
)
$fullVal = $Value -join " "
Set-Item -Path Env:\$Name -Value $fullVal -Force
if ($IsCI) {
if ((Test-Path Env:\TF_BUILD)) {
"##vso[task.setvariable variable=$Name]$fullVal" | Write-Host
}
}
Set-Alias -Name SetEnv -Value Set-EnvironmentVariable -Force

function Set-BuildVariables {
$gitVars = if ($IsCI) {
$gitVars = if ((Test-Path Env:\TF_BUILD)) {
@{
BHBranchName = $env:BUILD_SOURCEBRANCHNAME
BHPSModuleManifest = "$env:BuildScriptPath\$env:BuildProjectName\$env:BuildProjectName.psd1"
Expand Down
32 changes: 19 additions & 13 deletions psake.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ task Compile -depends Clean {
$functionsToExport = @()
$sutLib = [System.IO.Path]::Combine($sut,'lib')
$aliasesToExport = (. $sut\Aliases\PSGSuite.Aliases.ps1).Keys
if ("$env:NoNugetRestore" -ne 'True') {
if (-not (Test-Path $outputModVerDir)) {
$modDir = New-Item -Path $outputModDir -ItemType Directory -ErrorAction SilentlyContinue
New-Item -Path $outputModVerDir -ItemType Directory -ErrorAction SilentlyContinue | Out-Null
}
Expand All @@ -100,13 +100,22 @@ task Compile -depends Clean {
Write-BuildLog 'Creating psm1...'
$psm1 = Copy-Item -Path (Join-Path -Path $sut -ChildPath 'PSGSuite.psm1') -Destination (Join-Path -Path $outputModVerDir -ChildPath "$($ENV:BHProjectName).psm1") -PassThru

Get-ChildItem -Path (Join-Path -Path $sut -ChildPath 'Private') -Recurse -File | ForEach-Object {
"$(Get-Content $_.FullName -Raw)`n" | Add-Content -Path $psm1 -Encoding UTF8
}
Get-ChildItem -Path (Join-Path -Path $sut -ChildPath 'Public') -Recurse -File | ForEach-Object {
"$(Get-Content $_.FullName -Raw)`nExport-ModuleMember -Function '$($_.BaseName)'`n" | Add-Content -Path $psm1 -Encoding UTF8
$functionsToExport += $_.BaseName
foreach ($scope in @('Private','Public')) {
Write-BuildLog "Copying contents from files in source folder to PSM1: $($scope)"
$gciPath = Join-Path $sut $scope
if (Test-Path $gciPath) {
Get-ChildItem -Path $gciPath -Filter "*.ps1" -Recurse -File | ForEach-Object {
Write-BuildLog "Working on: $scope$([System.IO.Path]::DirectorySeparatorChar)$($_.FullName.Replace("$gciPath$([System.IO.Path]::DirectorySeparatorChar)",'') -replace '\.ps1$')"
[System.IO.File]::AppendAllText($psm1,("$([System.IO.File]::ReadAllText($_.FullName))`n"))
if ($scope -eq 'Public') {
$functionsToExport += $_.BaseName
[System.IO.File]::AppendAllText($psm1,("Export-ModuleMember -Function '$($_.BaseName)'`n"))
}
}
}
}


Invoke-CommandWithLog {Remove-Module $env:BHProjectName -ErrorAction SilentlyContinue -Force -Verbose:$false}

if ("$env:NoNugetRestore" -ne 'True') {
Expand Down Expand Up @@ -331,10 +340,7 @@ Task Import -Depends Compile {
} -description 'Imports the newly compiled module'

$pesterScriptBlock = {
'Pester' | Foreach-Object {
Install-Module -Name $_ -Repository PSGallery -Scope CurrentUser -AllowClobber -SkipPublisherCheck -Confirm:$false -ErrorAction Stop -Force
Import-Module -Name $_ -Verbose:$false -ErrorAction Stop -Force
}
'Pester' | Resolve-Module -UpdateModules -Verbose
Push-Location
Set-Location -PassThru $outputModDir
if (-not $ENV:BHProjectPath) {
Expand Down Expand Up @@ -368,8 +374,8 @@ $pesterScriptBlock = {
$testResults = Invoke-Pester @pesterParams
' Pester invocation complete!'
if ($testResults.FailedCount -gt 0) {
$testResults | Format-List
Write-Error -Message 'One or more Pester tests failed. Build cannot continue!'
$testResults.TestResult | Where-Object {-not $_.Passed} | Format-List
Write-BuildError -Message 'One or more Pester tests failed. Build cannot continue!'
}
Pop-Location
$env:PSModulePath = $origModulePath
Expand Down

0 comments on commit d9d6b11

Please sign in to comment.