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