public/Version/Get-Version.ps1
using module '..\..\modules\Enums.psm1' using module '..\..\modules\VersionChecker.psm1' function Get-Version { [CmdletBinding()] param( [OPERATOR[]]$operator, [string[]]$brand, [ENVIRONMENT[]]$environment, [MODULE[]]$module, [int]$tokenIatCorrectionMilliseconds=-1000, [switch]$forceSecurityProtocol) $versionChecker = [VersionChecker]::new([Config]::Load(), $tokenIatCorrectionMilliseconds, $forceSecurityProtocol) #region Warm-up $warmUpModules = @() $withSubmodules = $versionChecker.GetModulesWithSubmodule() Write-Debug ('With submodules: {0}' -f [string]$withSubmodules) if ($module){ foreach ($m in $module) { if ($m -in $withSubmodules) { $warmUpModules += $m } } } else { $warmUpModules = $withSubmodules } Write-Debug ('Warm up modules: {0}' -f [string]$warmUpModules) # Find all unique submodule keys $allKeys = @() foreach ($instance in $versionChecker.FindInstances($operator, $environment, $brand, $warmUpModules)) { $instance.GetVersions($warmUpModules, $versionChecker.applicationModules) $subItems = $instance.GetSubmodules($warmUpModules) foreach ($item in $subItems) { if (-not ($item -in $allKeys)) { $allKeys += $item } } } Write-Debug ("All sub-keys: " + [string]$allKeys) #endregion if ($null -eq $module) { $checked = $instance.modules; Write-Debug 'Taking all from the instance...' } else { $checked = $module; Write-Debug 'Taking from the input...'} Write-Debug ("Checking modules: " + [string]$checked) foreach ($instance in $versionChecker.FindInstances($operator, $environment, $brand, $checked)) { foreach ($m in $checked) { $instance.GetVersions($m, $versionChecker.applicationModules) $version = $instance.ToOutput($m) if ($version){ foreach ($key in $allKeys){ if (-not $version.$key) { $version | Add-Member $key '' } } Write-Output $version } } } } |