Skip to content

Commit 0a9960f

Browse files
Add website artifact export support (#524)
* Add website artifact export support * Support older builder docs configuration
1 parent 3077dcc commit 0a9960f

3 files changed

Lines changed: 141 additions & 4 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ Lib/Core/*
2323
*.json
2424
*.html
2525
.claude/*
26-
CLAUDE.MD
26+
CLAUDE.MD
27+
WebsiteArtifacts/
28+
en-US/

Build/Build-Module.ps1

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,19 @@
7070
# when creating PSD1 use special style without comments and with only required parameters
7171
New-ConfigurationFormat -ApplyTo 'DefaultPSD1', 'OnMergePSD1' -PSD1Style 'Minimal'
7272
# configuration for documentation, at the same time it enables documentation processing
73-
New-ConfigurationDocumentation -Enable:$false -StartClean -UpdateWhenNew -PathReadme 'Docs\Readme.md' -Path 'Docs'
73+
$documentationConfiguration = @{
74+
Enable = $true
75+
StartClean = $true
76+
UpdateWhenNew = $true
77+
PathReadme = 'Docs\Readme.md'
78+
Path = 'Docs'
79+
}
80+
81+
if ((Get-Command New-ConfigurationDocumentation).Parameters.ContainsKey('SyncExternalHelpToProjectRoot')) {
82+
$documentationConfiguration.SyncExternalHelpToProjectRoot = $true
83+
}
84+
85+
New-ConfigurationDocumentation @documentationConfiguration
7486

7587
New-ConfigurationImportModule -ImportSelf
7688

@@ -80,7 +92,7 @@
8092
MergeModuleOnBuild = $true
8193
MergeFunctionsFromApprovedModules = $true
8294
CertificateThumbprint = '483292C9E317AA13B07BB7A96AE9D1A5ED9E7703'
83-
RefreshPSD1Only = $true
95+
RefreshPSD1Only = $env:RefreshPSD1Only -eq 'true'
8496
}
8597

8698
New-ConfigurationBuild @newConfigurationBuildSplat
@@ -93,4 +105,4 @@
93105
# options for publishing to github/psgallery
94106
#New-ConfigurationPublish -Type PowerShellGallery -FilePath 'C:\Support\Important\PowerShellGalleryAPI.txt' -Enabled:$true
95107
#New-ConfigurationPublish -Type GitHub -FilePath 'C:\Support\Important\GitHubAPI.txt' -UserName 'EvotecIT' -Enabled:$true
96-
} -ExitCode
108+
} -ExitCode

Build/Export-WebsiteArtifacts.ps1

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
[CmdletBinding()]
2+
param(
3+
[switch]$SkipBuild,
4+
[string]$ArtifactsRoot = (Join-Path $PSScriptRoot '..\WebsiteArtifacts')
5+
)
6+
7+
$ErrorActionPreference = 'Stop'
8+
9+
$repoRoot = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
10+
$moduleName = 'PSWriteHTML'
11+
$slug = 'pswritehtml'
12+
$helpCandidates = @(
13+
(Join-Path $repoRoot "en-US\$moduleName-help.xml"),
14+
(Join-Path $repoRoot "Artefacts\Unpacked\$moduleName\en-US\$moduleName-help.xml")
15+
)
16+
$examplesSource = Join-Path $repoRoot 'Examples'
17+
$placeholderMarkers = @(
18+
'{{ Fill in the Synopsis }}',
19+
'{{ Fill in the Description }}',
20+
'{{ Add example code here }}',
21+
'{{ Add example description here }}'
22+
)
23+
24+
function Find-HelpFile {
25+
foreach ($candidate in $helpCandidates) {
26+
if (Test-Path -LiteralPath $candidate -PathType Leaf) {
27+
return [System.IO.Path]::GetFullPath($candidate)
28+
}
29+
}
30+
31+
return $null
32+
}
33+
34+
function Test-PlaceholderContent {
35+
param(
36+
[Parameter(Mandatory)]
37+
[string]$Path
38+
)
39+
40+
foreach ($marker in $placeholderMarkers) {
41+
$match = Select-String -Path $Path -Pattern ([regex]::Escape($marker)) -SimpleMatch -List -ErrorAction SilentlyContinue
42+
if ($match) {
43+
throw "Placeholder API content detected in '$Path' ($marker)."
44+
}
45+
}
46+
}
47+
48+
$helpPath = Find-HelpFile
49+
if (-not $helpPath -and -not $SkipBuild) {
50+
$previousRefresh = $env:RefreshPSD1Only
51+
try {
52+
$env:RefreshPSD1Only = 'false'
53+
& (Join-Path $PSScriptRoot 'Build-Module.ps1')
54+
} finally {
55+
if ($null -eq $previousRefresh) {
56+
Remove-Item Env:RefreshPSD1Only -ErrorAction SilentlyContinue
57+
} else {
58+
$env:RefreshPSD1Only = $previousRefresh
59+
}
60+
}
61+
$helpPath = Find-HelpFile
62+
}
63+
64+
if (-not $helpPath) {
65+
throw "Unable to find $moduleName external help. Run .\Build\Build-Module.ps1 first."
66+
}
67+
68+
Test-PlaceholderContent -Path $helpPath
69+
70+
$resolvedArtifactsRoot = [System.IO.Path]::GetFullPath($ArtifactsRoot)
71+
$apiRoot = Join-Path $resolvedArtifactsRoot 'apidocs\powershell'
72+
$examplesTarget = Join-Path $apiRoot 'examples'
73+
74+
if (Test-Path -LiteralPath $apiRoot) {
75+
Remove-Item -LiteralPath $apiRoot -Recurse -Force
76+
}
77+
78+
New-Item -ItemType Directory -Path $apiRoot -Force | Out-Null
79+
Copy-Item -LiteralPath $helpPath -Destination (Join-Path $apiRoot "$moduleName-help.xml") -Force
80+
81+
if (Test-Path -LiteralPath $examplesSource -PathType Container) {
82+
Copy-Item -LiteralPath $examplesSource -Destination $examplesTarget -Recurse -Force
83+
}
84+
85+
$psd1Path = Join-Path $repoRoot "$moduleName.psd1"
86+
$version = $null
87+
if (Test-Path -LiteralPath $psd1Path -PathType Leaf) {
88+
$version = (Import-PowerShellDataFile -Path $psd1Path).ModuleVersion.ToString()
89+
}
90+
91+
$commit = (& git -C $repoRoot rev-parse HEAD).Trim()
92+
$manifest = [ordered]@{
93+
slug = $slug
94+
name = $moduleName
95+
description = 'PSWriteHTML website artifacts for the Evotec multi-project hub.'
96+
mode = 'hub-full'
97+
contentMode = 'hybrid'
98+
status = 'active'
99+
listed = $true
100+
version = $version
101+
generatedAt = (Get-Date).ToString('o')
102+
commit = $commit
103+
links = [ordered]@{
104+
source = 'https://github.com/EvotecIT/PSWriteHTML'
105+
}
106+
surfaces = [ordered]@{
107+
docs = $true
108+
apiPowerShell = $true
109+
apiDotNet = $false
110+
examples = $false
111+
}
112+
artifacts = [ordered]@{
113+
api = 'WebsiteArtifacts/apidocs'
114+
docs = 'Website/content/project-docs'
115+
examples = 'Examples'
116+
}
117+
}
118+
119+
$manifestPath = Join-Path $resolvedArtifactsRoot 'project-manifest.json'
120+
New-Item -ItemType Directory -Path $resolvedArtifactsRoot -Force | Out-Null
121+
$manifest | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath $manifestPath -Encoding UTF8
122+
123+
Write-Host "Exported website artifacts -> $resolvedArtifactsRoot" -ForegroundColor Green

0 commit comments

Comments
 (0)