From 5588c0306c8e9e2e657bb2c43188c6ee9aef3573 Mon Sep 17 00:00:00 2001 From: dfinke Date: Sat, 2 May 2020 16:47:36 -0400 Subject: [PATCH 1/3] added custom formatting example --- .../Top10-DataBar-TwoColorScale.ps1 | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Examples/ConditionalFormatting/Top10-DataBar-TwoColorScale.ps1 diff --git a/Examples/ConditionalFormatting/Top10-DataBar-TwoColorScale.ps1 b/Examples/ConditionalFormatting/Top10-DataBar-TwoColorScale.ps1 new file mode 100644 index 0000000..f462549 --- /dev/null +++ b/Examples/ConditionalFormatting/Top10-DataBar-TwoColorScale.ps1 @@ -0,0 +1,33 @@ +$xlfile = "$env:TEMP\test.xlsx" +Remove-Item $xlfile -ErrorAction SilentlyContinue + +$data = ConvertFrom-csv @" +Store,January,February,March,April,May,June +store27,99511,64582,45216,48690,64921,54066 +store82,22275,23708,28223,26699,41388,31648 +store41,24683,22583,97947,31999,39092,41201 +store16,16568,48040,68589,20394,63202,26197 +store21,99353,23470,28398,21788,94101,88608 +store86,66662,83321,27489,92627,54084,24278 +store07,92692,53300,29284,39643,33556,53885 +store58,68875,83705,66635,81025,30207,75570 +store01,21292,82341,81339,12505,29516,41634 +store82,74047,93325,25002,40113,76278,45707 +"@ + +Export-Excel -InputObject $data -Path $xlfile -TableName RawData -WorksheetName RawData +Export-Excel -InputObject $data -Path $xlfile -TableName TopData -WorksheetName StoresTop10Sales +Export-Excel -InputObject $data -Path $xlfile -TableName Databar -WorksheetName StoresSalesDataBar +Export-Excel -InputObject $data -Path $xlfile -TableName TwoColorScale -WorksheetName StoresSalesTwoColorScale + +$xl = Open-ExcelPackage -Path $xlfile + +Set-ExcelRange -Worksheet $xl.StoresTop10Sales -Range $xl.StoresTop10Sales.dimension.address -NumberFormat 'Currency' -AutoSize +Set-ExcelRange -Worksheet $xl.StoresSalesDataBar -Range $xl.StoresSalesDataBar.dimension.address -NumberFormat 'Currency' -AutoSize +Set-ExcelRange -Worksheet $xl.StoresSalesTwoColorScale -Range $xl.StoresSalesDataBar.dimension.address -NumberFormat 'Currency' -AutoSize + +Add-ConditionalFormatting -Worksheet $xl.StoresTop10Sales -Address $xl.StoresTop10Sales.dimension.address -RuleType Top -ForegroundColor white -BackgroundColor green -ConditionValue 10 +Add-ConditionalFormatting -Worksheet $xl.StoresSalesDataBar -Address $xl.StoresSalesDataBar.dimension.address -DataBarColor Red +Add-ConditionalFormatting -Worksheet $xl.StoresSalesTwoColorScale -Address $xl.StoresSalesDataBar.dimension.address -RuleType TwoColorScale + +Close-ExcelPackage $xl -Show \ No newline at end of file From f8b9cf7251683dc6e3b46221c42b2f73af1fe23e Mon Sep 17 00:00:00 2001 From: dfinke Date: Sun, 3 May 2020 14:58:02 -0400 Subject: [PATCH 2/3] Add Stale bot config --- .github/stale.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..872c4f5 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,17 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 30 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - security +# Label to use when marking an issue as stale +staleLabel: wontfix +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false \ No newline at end of file From a874e1385e37fac8a3675833689f2853c1b28d02 Mon Sep 17 00:00:00 2001 From: dfinke Date: Mon, 4 May 2020 09:43:19 -0400 Subject: [PATCH 3/3] Prevent install of Pester v5 --- CI/PS-CI.ps1 | 110 ++++++++++++++++++++++---------------------- appveyor.yml | 12 ++--- azure-pipelines.yml | 8 ++-- 3 files changed, 66 insertions(+), 64 deletions(-) diff --git a/CI/PS-CI.ps1 b/CI/PS-CI.ps1 index b37a8a4..5d6e0c9 100644 --- a/CI/PS-CI.ps1 +++ b/CI/PS-CI.ps1 @@ -1,4 +1,4 @@ -[cmdletbinding(DefaultParameterSetName='Scope')] +[cmdletbinding(DefaultParameterSetName = 'Scope')] Param( [Parameter(Mandatory = $true, ParameterSetName = 'ModulePath')] [ValidateNotNullOrEmpty()] @@ -10,7 +10,7 @@ Param( [string] $Scope = 'CurrentUser', - [Parameter(Mandatory=$true, ParameterSetName = 'PreCheckOnly')] + [Parameter(Mandatory = $true, ParameterSetName = 'PreCheckOnly')] [switch]$PreCheckOnly, [Parameter(ParameterSetName = 'ModulePath')] [Parameter(ParameterSetName = 'Scope')] @@ -30,7 +30,7 @@ Param( ) Function Show-Warning { param( - [Parameter(Position=0,ValueFromPipeline=$true)] + [Parameter(Position = 0, ValueFromPipeline = $true)] $message ) process { @@ -49,11 +49,11 @@ if (-not $psdpath -or $psdpath.count -gt 1) { throw "Did not find a unique PSD file " } else { - try {$null = Test-ModuleManifest -Path $psdpath -ErrorAction stop} - catch {throw $_ ; return} - $ModuleName = $psdpath.Name -replace '\.psd1$' , '' - $Settings = $(& ([scriptblock]::Create(($psdpath | Get-Content -Raw)))) - $approvedVerbs = Get-Verb | Select-Object -ExpandProperty verb + try { $null = Test-ModuleManifest -Path $psdpath -ErrorAction stop } + catch { throw $_ ; return } + $ModuleName = $psdpath.Name -replace '\.psd1$' , '' + $Settings = $(& ([scriptblock]::Create(($psdpath | Get-Content -Raw)))) + $approvedVerbs = Get-Verb | Select-Object -ExpandProperty verb $script:warningfile = Join-Path -Path $pwd -ChildPath "warnings.txt" } @@ -63,7 +63,7 @@ if (-not $SkipPreChecks) { #Check files in the manifest are present foreach ($file in $Settings.FileList) { if (-not (Test-Path $file)) { - Show-Warning "File $file in the manifest file list is not present" + Show-Warning "File $file in the manifest file list is not present" } } @@ -71,7 +71,7 @@ if (-not $SkipPreChecks) { # its name and any alias names in the manifest; function should have a param block and help should be in an MD file # We will want a regex which captures from "function verb-noun {" to its closing "}" # need to match each { to a } - $reg is based on https://stackoverflow.com/questions/7898310/using-regex-to-balance-match-parenthesis - $reg = [Regex]::new(@" + $reg = [Regex]::new(@" function\s*[-\w]+\s*{ # The function name and opening '{' (?: [^{}]+ # Match all non-braces @@ -84,56 +84,56 @@ if (-not $SkipPreChecks) { } # Functions closing '}' "@, 57) # 57 = compile,multi-line ignore case and white space. foreach ($file in (Get-Item .\Public\*.ps1)) { - $name = $file.name -replace(".ps1","") - if ($name -notmatch ("(\w+)-\w+")) {Show-Warning "$name in the public folder is not a verb-noun name"} - elseif ($Matches[1] -notin $approvedVerbs) {Show-Warning "$name in the public folder does not start with an approved verb"} - if(-not ($Settings.FunctionsToExport -ceq $name)) { + $name = $file.name -replace (".ps1", "") + if ($name -notmatch ("(\w+)-\w+")) { Show-Warning "$name in the public folder is not a verb-noun name" } + elseif ($Matches[1] -notin $approvedVerbs) { Show-Warning "$name in the public folder does not start with an approved verb" } + if (-not ($Settings.FunctionsToExport -ceq $name)) { Show-Warning ('File {0} in the public folder does not match an exported function in the manifest' -f $file.name) } else { $fileContent = Get-Content $file -Raw - $m = $reg.Matches($fileContent) - if ($m.Count -eq 0) {Show-Warning ('Could not find {0} function in {1}' -f $name, $file.name); continue} - elseif ($m.Count -ge 2) {Show-Warning ('Multiple functions in {0}' -f $item.name) ; Continue} + $m = $reg.Matches($fileContent) + if ($m.Count -eq 0) { Show-Warning ('Could not find {0} function in {1}' -f $name, $file.name); continue } + elseif ($m.Count -ge 2) { Show-Warning ('Multiple functions in {0}' -f $item.name) ; Continue } elseif ($m[0] -imatch "^\function\s" -and - $m[0] -cnotmatch "^\w+\s+$name") {Show-Warning ('function name does not match file name for {0}' -f $file.name)} + $m[0] -cnotmatch "^\w+\s+$name") { Show-Warning ('function name does not match file name for {0}' -f $file.name) } #$m[0] runs form the f of function to its final } -find the section up to param, check for aliases & comment-based help - $m2 = [regex]::Match($m[0],"^.*?param",17) # 17 = multi-line, ignnore case - if (-not $m2.Success) {Show-Warning "function $name has no param() block"} + $m2 = [regex]::Match($m[0], "^.*?param", 17) # 17 = multi-line, ignnore case + if (-not $m2.Success) { Show-Warning "function $name has no param() block" } else { if ($m2.value -match "(?