First root script converted to a module cmdlet. Behavior is unchanged; the code moves mostly verbatim: - Update-KHDB (the function) -> src/Elysium/Public/Update-ElysiumKhdb.ps1, exported, with comment-based help and [CmdletBinding()]. It now sets TLS 1.2 itself, since the module may be imported without the script. - Manifest/shard/merge/validation helpers -> Private/Khdb.ps1. - HTTP download helpers (Azure SAS, native SigV4 S3, retry) -> Private/Storage.ps1; Get-BooleanSetting -> Private/Settings.ps1. - The per-script Start/Stop-*Transcript pair -> one shared Start/Stop-ElysiumTranscript in Private/Transcript.ps1 (the other scripts switch to it as they are converted). - $scriptRoot becomes $InstallRoot: the repo root in both the module (two levels above src/Elysium) and the Elysium.Common.ps1 loader. Settings, KHDB and Reports stay where they are for now. Update-KHDB.ps1 is now a thin wrapper: relaunch under pwsh as before, import the module from src/Elysium, call Update-ElysiumKhdb with the bound parameters. The menu and direct invocations are unchanged. Tests: manifest validation, out-of-order merge, empty KHDB, and an end-to-end Update-ElysiumKhdb run against a fake Azure container with only Invoke-DownloadWithRetry mocked - first sync (case and HASH:count normalization, ordered merge), no-op second run (manifest only), one changed shard plus removal of a shard the manifest no longer lists. 14/14 Pester tests pass. Separately, the wrapper ran the real HTTP code against a local stand-in for an S3-compatible endpoint, on both the serial and the PowerShell 7 parallel path (helpers injected into runspaces from module scope), and produced the same merged KHDB.
9 lines
563 B
PowerShell
9 lines
563 B
PowerShell
# Transitional loader. The shared helpers now live in the Elysium module (src/Elysium/Private);
|
|
# root scripts that dot-source this file keep getting them in their own scope until each script
|
|
# is converted to a module cmdlet.
|
|
$script:ElysiumVersion = (Import-PowerShellDataFile -Path (Join-Path -Path $PSScriptRoot -ChildPath 'src/Elysium/Elysium.psd1')).ModuleVersion
|
|
$script:InstallRoot = $PSScriptRoot
|
|
foreach ($helperFile in Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'src/Elysium/Private') -Filter '*.ps1') {
|
|
. $helperFile.FullName
|
|
}
|