Skip to content

Commit c22b2bd

Browse files
authored
Fixing issue with cmdlets incorrectly getting tagged as only available in nightly
This issue occurred because the master branch was not updated anymore based on the dev branch with every release. Changed the script now so that it takes the latest stable PnP PowerShell from the PowerShellGallery and compares against that instead of the master branch.
1 parent 6166eb6 commit c22b2bd

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

pages/Build-Site.ps1

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
#New-Item -Path "./dev/pages/cmdlets/released" -ItemType Directory
33
#New-Item -Path "./dev/pages/cmdlets/nightly" -ItemType Directory
44

5-
$nightlycmdlets = Get-ChildItem "./dev/documentation/*.md" | ForEach-Object { $_ | Select-Object -ExpandProperty Name }
6-
$releasedcmdlets = Get-ChildItem "./master/documentation/*.md" | ForEach-Object { $_ | Select-Object -ExpandProperty Name }
5+
$nightlycmdlets = Get-ChildItem "./dev/documentation/*.md" | ForEach-Object { $_ | Select-Object -ExpandProperty BaseName }
76

87
class FrontMatters {
98
[hashtable] GetHeader($path) {
@@ -27,7 +26,6 @@ class FrontMatters {
2726
return $header
2827
}
2928

30-
3129
[string] WriteHeader($path, $header) {
3230

3331
$c = get-content $path
@@ -68,18 +66,29 @@ $aliasCmdlets = @()
6866
Try {
6967
Write-Host "Generating documentation files for alias cmdlets" -ForegroundColor Yellow
7068
# Load the Module in a new PowerShell session
71-
$scriptBlock = {
72-
Write-Host "Installing latest nightly of PnP PowerShell"
69+
$scriptBlockNightlyRelease = {
70+
Write-Host "Installing latest nightly release of PnP PowerShell"
7371
Install-Module PnP.PowerShell -AllowPrerelease -Force
7472

7573
Write-Host "Retrieving PnP PowerShell alias cmdlets"
7674
$cmdlets = Get-Command -Module PnP.PowerShell | Where-Object CommandType -eq "Alias" | Select-Object -Property @{N="Alias";E={$_.Name}}, @{N="ReferencedCommand";E={$_.ReferencedCommand.Name}}
7775
$cmdlets
7876
Write-Host "$($cmdlets.Length) alias cmdlets retrieved"
7977
}
80-
$aliasCmdlets = Start-ThreadJob -ScriptBlock $scriptBlock | Receive-Job -Wait
78+
$aliasCmdlets = Start-ThreadJob -ScriptBlock $scriptBlockNightlyRelease | Receive-Job -Wait
79+
80+
$aliasCmdletsCount = $aliasCmdlets.Length
81+
82+
$scriptBlockStableRelease = {
83+
Write-Host "Installing latest stable release of PnP PowerShell"
84+
Install-Module PnP.PowerShell -AllowPrerelease -Force
8185

82-
$aliasCmdletsCount = $aliasCmdlets.Length
86+
Write-Host "Retrieving PnP PowerShell cmdlets"
87+
$cmdlets = Get-Command -Module PnP.PowerShell | Select-Object Name
88+
$cmdlets
89+
Write-Host "$($cmdlets.Length) cmdlets retrieved"
90+
}
91+
$stableReleaseCmdlets = Start-ThreadJob -ScriptBlock $scriptBlockStableRelease | Receive-Job -Wait
8392

8493
Write-Host "- Retrieving alias template page"
8594
$aliasTemplatePageContent = Get-Content -Path "./dev/pages/cmdlets/alias.template" -Raw
@@ -102,7 +111,7 @@ Write-Host "Copying documentation files to page cmdlets"
102111
Copy-Item -Path "./dev/documentation/*.md" -Destination "./dev/pages/cmdlets" -Force
103112

104113
foreach ($nightlycmdlet in $nightlycmdlets) {
105-
if (!$releasedcmdlets.Contains($nightlycmdlet)) {
114+
if (!$stableReleaseCmdlets.Contains($nightlycmdlet)) {
106115
Copy-Item "./dev/documentation/$nightlycmdlet" -Destination "./dev/pages/cmdlets" -Force | Out-Null
107116
# update the document to state it's only available in the nightly build
108117
$header = $fm.GetHeader("./dev/pages/cmdlets/$nightlycmdlet")
@@ -156,7 +165,7 @@ foreach ($cmdletPage in $cmdletPages)
156165
$cmdletIndexPageList += "- [$($cmdletPage.BaseName)]($($cmdletPage.Name))"
157166

158167
# Check if the cmdlet only exists in the nightly build
159-
if (!$releasedcmdlets.Contains($cmdletPage.Name))
168+
if (!$stableReleaseCmdlets.Contains($cmdletPage.BaseName))
160169
{
161170
# Add a 1 to the cmdlet name if it's only available in the nightly build
162171
$cmdletIndexPageList = $cmdletIndexPageList + " <sup>1</sup>"

0 commit comments

Comments
 (0)