PowerCraft.Sites.psm1
|
# PowerCraft.Sites — thin PowerShell shell over the PowerCraft.Sites.Core kernel (D-002). # The shell owns binding, output shaping, and safety affordances; every algorithm lives # in the kernel. lib/ is populated by build.ps1 (local kernel build for this slice). $script:ModuleRoot = $PSScriptRoot $libDir = Join-Path $PSScriptRoot 'lib' $kernelDll = Join-Path $libDir 'PowerCraft.Sites.Core.dll' if (-not (Test-Path -LiteralPath $kernelDll)) { throw "PowerCraft.Sites kernel not found at '$kernelDll'. Run build.ps1 at the repository root to populate module/lib/." } foreach ($dll in Get-ChildItem -Path $libDir -Filter '*.dll' | Sort-Object Name) { try { Add-Type -Path $dll.FullName -ErrorAction Stop } catch { # Framework-provided assemblies (e.g. System.Text.Json) may already be loaded by # the PowerShell runtime; that is fine. Anything else is a real failure. if ($_.Exception -is [System.IO.FileLoadException] -or $_.Exception.Message -match 'already (been )?loaded') { Write-Verbose "Skipped $($dll.Name): already provided by the runtime." } else { throw } } } # Private: resolve a -Theme argument to a theme directory. A path wins; otherwise the # name is looked up among the themes bundled with the module. function Resolve-PCSiteThemePath { [CmdletBinding()] param( [Parameter(Mandatory)] [string]$Theme ) if (Test-Path -LiteralPath $Theme -PathType Container) { return (Resolve-Path -LiteralPath $Theme).Path } $bundled = Join-Path $script:ModuleRoot (Join-Path 'themes' $Theme) if (Test-Path -LiteralPath $bundled -PathType Container) { return $bundled } throw "Theme '$Theme' not found: not a directory, and no bundled theme at '$bundled'." } foreach ($function in Get-ChildItem -Path (Join-Path $PSScriptRoot 'Public') -Filter '*.ps1' | Sort-Object Name) { . $function.FullName } Export-ModuleMember -Function 'Build-PCSite', 'Test-PCSite' |