Skip to content

Commit e4ee5eb

Browse files
Update the module catalog generator for Modules
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 5a8e8ee commit e4ee5eb

4 files changed

Lines changed: 67 additions & 7 deletions

File tree

.github/actions/update-index/src/Helper.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ function Update-ModuleList {
831831
$moduleRepos = $Repos | Where-Object {
832832
$_.Type -eq 'Module' -and $_.Owner -eq 'PSModule'
833833
} | Sort-Object Name
834-
$catalogFolderPath = Join-Path 'docs\content\Modules\Catalog' 'Repositories'
834+
$catalogFolderPath = Join-Path 'docs\content\Modules' 'Repositories'
835835
if (-not (Test-Path $catalogFolderPath)) {
836836
Write-Host "Creating catalog folder [$catalogFolderPath]"
837837
$null = New-Item -Path $catalogFolderPath -ItemType Directory
@@ -921,7 +921,7 @@ function Update-ModuleList {
921921

922922
LogGroup 'Write module catalog table to docs index' {
923923
$moduleTable = $moduleCatalogTableTemplate.Replace('{{ ROWS }}', $moduleTableRows.TrimEnd())
924-
Update-MDSection -Path '.\docs\content\Modules\Catalog\index.md' -Name 'MODULE_CATALOG' -Content $moduleTable
924+
Update-MDSection -Path '.\docs\content\Modules\index.md' -Name 'MODULE_CATALOG' -Content $moduleTable
925925
Write-Host 'Module catalog table update completed'
926926
}
927927
}

.github/actions/update-index/templates/module-catalog/v2-table.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<table>
44
<tr>
55
<th width="24%">Name</th>
6-
<th width="12%"><img src="../../assets/images/module-catalog/githubtags.svg" alt="Version" title="Version" width="16" height="16"></th>
7-
<th width="24%"><img src="../../assets/images/module-catalog/package-variant-closed-check.svg" alt="Process version" title="Process version" width="16" height="16"></th>
8-
<th width="10%"><img src="../../assets/images/module-catalog/githubissues.svg" alt="Issues" title="Issues" width="16" height="16"></th>
9-
<th width="10%"><img src="../../assets/images/module-catalog/githubpullrequests.svg" alt="Pull requests" title="Pull requests" width="16" height="16"></th>
10-
<th width="10%"><img src="../../assets/images/module-catalog/githubstars.svg" alt="Stars" title="Stars" width="16" height="16"></th>
6+
<th width="12%"><img src="../assets/images/module-catalog/githubtags.svg" alt="Version" title="Version" width="16" height="16"></th>
7+
<th width="24%"><img src="../assets/images/module-catalog/package-variant-closed-check.svg" alt="Process version" title="Process version" width="16" height="16"></th>
8+
<th width="10%"><img src="../assets/images/module-catalog/githubissues.svg" alt="Issues" title="Issues" width="16" height="16"></th>
9+
<th width="10%"><img src="../assets/images/module-catalog/githubpullrequests.svg" alt="Pull requests" title="Pull requests" width="16" height="16"></th>
10+
<th width="10%"><img src="../assets/images/module-catalog/githubstars.svg" alt="Stars" title="Stars" width="16" height="16"></th>
1111
</tr>
1212
{{ ROWS }}</table>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute(
2+
'PSUseDeclaredVarsMoreThanAssignments',
3+
'',
4+
Justification = 'The temporary path is assigned before assertions and cleanup.'
5+
)]
6+
[CmdletBinding()]
7+
param()
8+
9+
BeforeAll {
10+
Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath '../src/Helper.psm1') -Force
11+
}
12+
13+
Describe 'Update-ModuleList' {
14+
Context 'catalog page at the Modules root' {
15+
It 'Update-ModuleList - writes the catalog index and repository page to the new Modules paths' {
16+
$testRoot = Join-Path ([System.IO.Path]::GetTempPath()) ("update-index-test-$([guid]::NewGuid())")
17+
$modulesPath = Join-Path $testRoot 'docs/content/Modules'
18+
$catalogIndexPath = Join-Path $modulesPath 'index.md'
19+
New-Item -ItemType Directory -Path $modulesPath -Force | Out-Null
20+
Set-Content -Path $catalogIndexPath -Value @(
21+
'# Modules'
22+
''
23+
'<!-- MODULE_CATALOG_START -->'
24+
'<!-- MODULE_CATALOG_END -->'
25+
)
26+
27+
try {
28+
Push-Location $testRoot
29+
InModuleScope Helper {
30+
Mock Get-RepositoryVersion { '1.2.3' }
31+
Mock Get-RepositoryReadmeContent { '# Example`nExample module summary.' }
32+
Mock Get-MarkdownSummary { 'Example module summary.' }
33+
Mock Get-WorkflowReference { 'v1.2.3' }
34+
Mock Get-ProcessReferenceStatus { 'up-to-date' }
35+
Mock Get-OpenItemCount { 0 }
36+
37+
Update-ModuleList -Repos @(
38+
[pscustomobject]@{
39+
Type = 'Module'
40+
Owner = 'PSModule'
41+
Name = 'Example'
42+
Description = 'Example module.'
43+
DefaultBranch = 'main'
44+
Stars = 1
45+
}
46+
)
47+
}
48+
49+
$catalogContent = Get-Content -Path $catalogIndexPath -Raw
50+
Test-Path (Join-Path $modulesPath 'Repositories/Example.md') | Should -BeTrue
51+
$catalogContent | Should -Match '\./Repositories/Example\.md'
52+
$catalogContent | Should -Match '\.\./assets/images/module-catalog/githubtags\.svg'
53+
} finally {
54+
Pop-Location
55+
Remove-Item -LiteralPath $testRoot -Recurse -Force -ErrorAction SilentlyContinue
56+
}
57+
}
58+
}
59+
}

.github/workflows/Test-Actions.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
run: |
3737
Install-PSResource -Name Pester -Version '[5.7.1,6.0.0)' -Repository PSGallery -TrustRepository
3838
Install-PSResource -Name PSSemVer -Repository PSGallery -TrustRepository
39+
Install-PSResource -Name GitHub -Version '[0.43.1,0.44.0)' -Repository PSGallery -TrustRepository
3940
4041
- name: Run action unit tests
4142
shell: pwsh

0 commit comments

Comments
 (0)