|
| 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