Skip to content

Commit 16a5bd6

Browse files
authored
Merge pull request #164 from fscpscollaborative/develop
Release merge
2 parents 05cc31b + d726815 commit 16a5bd6

24 files changed

Lines changed: 132 additions & 60 deletions

build/format-commentbasedhelp.ps1

Lines changed: 69 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
# based on https://gist.github.com/Splaxi/ff7485a24f6ed9937f3e8da76b5d4840
33
# See also https://github.com/fscpscollaborative/fscps.tools/wiki/Building-tools
44
$path = "$PSScriptRoot\..\fscps.tools"
5-
5+
# Path to the .psd1 file
6+
$psd1Path = "$path\fscps.tools.psd1"
7+
$psd1Data = Import-PowerShellDataFile -Path $psd1Path
8+
# Extract the Author field
9+
$author = $psd1Data.Author
610
function Get-Header ($text) {
711
$start = $text.IndexOf('<#')
812
$temp = $start - 2
@@ -13,25 +17,76 @@ function Get-Header ($text) {
1317
""
1418
}
1519
}
16-
17-
function Format-Help ($text) {
20+
function Format-Help ($text) {
21+
1822
$start = $text.IndexOf('<#')
1923
$end = $text.IndexOf('#>')
2024
$help = $text.SubString($start + 2, $end - $start - 3)
2125

22-
$skipfirst = $null # to avoid trailing spaces
26+
#$skipfirst = $null # to avoid trailing spaces
27+
$formattedHelp = @() # Collect formatted lines
28+
$indentLevel = 0 # Track indentation level
29+
30+
2331
foreach ($newline in $help.Split("`n")) {
24-
if (-not $skipfirst) { $skipfirst = $true; continue }
32+
#if (-not $skipfirst) { $skipfirst = $true; continue }
2533
$trimmed = $newline.Trim()
26-
foreach ($line in $trimmed) {
27-
if ($line.StartsWith(".")) {
28-
" $line"
29-
}
30-
else {
31-
" $line"
32-
}
34+
35+
# Adjust indentation based on closing braces
36+
if ($trimmed -match '^\}') { $indentLevel = [math]::Max(0, $indentLevel - 1) }
37+
38+
if ($trimmed.StartsWith("."))
39+
{
40+
$trimmed = " $($trimmed.Replace(" ", ''))"
41+
}
42+
elseif ($trimmed.StartsWith("-")) {
43+
$trimmed = " $($trimmed.Trim())"
44+
}
45+
elseif ($trimmed.StartsWith("@{")) {
46+
$trimmed = " $($trimmed.Trim())"
47+
}
48+
else {
49+
$trimmed = " $trimmed"
50+
}
51+
52+
# Apply indentation
53+
$indentedLine = (' ' * ($indentLevel * 4)) + $trimmed
54+
55+
$formattedHelp += $indentedLine
56+
57+
# Adjust indentation based on opening braces
58+
if ($trimmed -match '\{$') { $indentLevel++ }
59+
}
60+
$cnt = 0
61+
$lines = $formattedHelp.Split("`n")
62+
63+
foreach ($line in $lines) {
64+
if($cnt -eq 0 -and (($line -match '^[\s]*$'))) {
65+
$cnt++
66+
continue
67+
}
68+
69+
# Check for .NOTES node
70+
if ($line -match '\.NOTES') {
71+
$foundNotes = $true
3372
}
73+
74+
# Check if the author is already present
75+
if ($line -match [regex]::Escape($author)) {
76+
$foundAuthor = $true
77+
}
78+
79+
# If it's the last line and .NOTES exists but no author, add the author
80+
if ($cnt -eq $lines.Length - 1 -and $foundNotes -and -not $foundAuthor) {
81+
$line
82+
Write-Host "Adding author to .NOTES section."
83+
$line = " Author: $author"
84+
}
85+
86+
$line
87+
$cnt++
3488
}
89+
3590
}
3691

3792
function Get-Body ($text) {
@@ -40,9 +95,9 @@ function Get-Body ($text) {
4095
}
4196

4297
$files = New-Object System.Collections.ArrayList
43-
$filesPublic = Get-ChildItem -Path "$path\functions\*.ps1"
98+
$filesPublic = @(Get-ChildItem -Path "$path\functions\*.ps1")
4499
$files.AddRange($filesPublic)
45-
$filesInternal = Get-ChildItem -Path "$path\internal\functions\*.ps1"
100+
$filesInternal = @(Get-ChildItem -Path "$path\internal\functions\*.ps1")
46101
$files.AddRange($filesInternal)
47102

48103
foreach ($file in $files) {

docs/Get-FSCPSADOAgent.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,6 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
125125
- The function uses the Azure DevOps REST API to retrieve agent information.
126126
- An authentication token is required.
127127
- Handles errors and interruptions gracefully.
128+
Author: Oleksandr Nikolaiev (@onikolaiev)
128129
129130
## RELATED LINKS

docs/Get-FSCPSADOTestCase.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,6 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
140140
- The function uses the Azure DevOps REST API to retrieve test case information.
141141
- An authentication token is required.
142142
- Handles errors and interruptions gracefully.
143+
Author: Oleksandr Nikolaiev (@onikolaiev)
143144
144145
## RELATED LINKS

docs/Get-FSCPSADOTestCasesBySuite.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,5 +154,6 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
154154
- The function uses the Azure DevOps REST API to retrieve test cases.
155155
- An authentication token is required.
156156
- Handles errors and interruptions gracefully.
157+
Author: Oleksandr Nikolaiev (@onikolaiev)
157158
158159
## RELATED LINKS

docs/Get-FSCPSADOTestSuiteByTestCase.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,6 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
137137
- The function uses the Azure DevOps REST API to retrieve the test suite.
138138
- An authentication token is required.
139139
- Handles errors and interruptions gracefully.
140+
Author: Oleksandr Nikolaiev (@onikolaiev)
140141
141142
## RELATED LINKS

docs/Invoke-FSCPSAzureSignToolSignFile.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ Function to sign the files with KeyVault
2626
### EXAMPLE 1
2727
```
2828
Invoke-FSCPSAzureSignToolSignFile -Uri "https://my-vault.vault.azure.net" `
29-
-TenantId "01234567-abcd-ef012-0000-0123456789ab" `
30-
-CertificateName "my-key-name" `
31-
-ClientId "01234567-abcd-ef012-0000-0123456789ab" `
32-
-ClientSecret "secret" `
33-
-FILE "$filePath"
29+
-TenantId "01234567-abcd-ef012-0000-0123456789ab" `
30+
-CertificateName "my-key-name" `
31+
-ClientId "01234567-abcd-ef012-0000-0123456789ab" `
32+
-ClientSecret "secret" `
33+
-FILE "$filePath"
3434
```
3535

3636
This will sign the target file with the KeyVault certificate

docs/Invoke-FSCPSDigiCertSignFile.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ Function to sign the files with digicert
2727
### EXAMPLE 1
2828
```
2929
Invoke-FSCPSDigiCertSignFile -SM_API_KEY "$codeSignDigiCertAPISecretName" `
30-
-SM_CLIENT_CERT_FILE_URL "$codeSignDigiCertUrlSecretName" `
31-
-SM_CLIENT_CERT_PASSWORD $(ConvertTo-SecureString $codeSignDigiCertPasswordSecretName -AsPlainText -Force) `
32-
-SM_CODE_SIGNING_CERT_SHA1_HASH "$codeSignDigiCertHashSecretName" `
33-
-FILE "$filePath"
30+
-SM_CLIENT_CERT_FILE_URL "$codeSignDigiCertUrlSecretName" `
31+
-SM_CLIENT_CERT_PASSWORD $(ConvertTo-SecureString $codeSignDigiCertPasswordSecretName -AsPlainText -Force) `
32+
-SM_CODE_SIGNING_CERT_SHA1_HASH "$codeSignDigiCertHashSecretName" `
33+
-FILE "$filePath"
3434
```
3535

3636
This will sign the target file with the DigiCert certificate

docs/Invoke-FSCPSInstallModule.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@ Accept wildcard characters: False
5454
## NOTES
5555
- Real-time monitoring is disabled during the installation process to improve performance.
5656
- The "AzureRm" module is uninstalled if "Az" is specified.
57+
Author: Oleksandr Nikolaiev (@onikolaiev)
5758
5859
## RELATED LINKS

fscps.tools/fscps.tools.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ModuleVersion = '1.1.332'
2121
GUID = '6b3d02bf-e176-4052-9b40-5012339c20b3'
2222

2323
# Author of this module
24-
Author = 'Oleksandr Nikolaiev'
24+
Author = 'Oleksandr Nikolaiev (@onikolaiev)'
2525

2626
# Company or vendor of this module
2727
CompanyName = 'Ciellos Inc.'

fscps.tools/functions/Invoke-fscpsinstallmodule.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
This example installs and imports the "Az" and "Pester" modules in the current user scope.
1616
1717
.NOTES
18-
- Real-time monitoring is disabled during the installation process to improve performance.
19-
- The "AzureRm" module is uninstalled if "Az" is specified.
18+
- Real-time monitoring is disabled during the installation process to improve performance.
19+
- The "AzureRm" module is uninstalled if "Az" is specified.
20+
Author: Oleksandr Nikolaiev (@onikolaiev)
2021
#>
2122

2223
function Invoke-FSCPSInstallModule {

0 commit comments

Comments
 (0)