ps/Modules/Alkami.PowerShell.SDK/Public/Get-FeatureSets.ps1

88 lines
2.6 KiB
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
function Get-FeatureSets() {
$defaultFeatures = "features,api"
if ($Latest) {
$Features = (Get-SavedInstallVersions)[1]
$Version = Get-LatestVersionManifest
if ([string]::IsNullOrWhiteSpace($Features) -or $Features.Count -lt 2) {
$Features = ($defaultFeatures -split ',')
}
}
Write-Host "$logLead : You selected the version [$Version]"
if ($null -ne $Features) {
foreach ($feature in $Features) {
Write-Host "$logLead : You selected to install all packages in [$feature]"
}
}
if ($Features -eq 0) {
# Override a bug from syntactic doing-things
$Features = ($defaultFeatures -split ',')
}
#$manifestFolder = (Join-Path -Path (Split-Path $PSScriptRoot -Parent) -ChildPath "Manifests")
#"Manifest folder: $manifestFolder" | Out-Default -Transcript | Out-Null
#if (!(Test-Path -Path $manifestFolder)) {
# $manifestFolder = (Join-Path -Path $PSScriptRoot -ChildPath "Manifests")
#}
$manifestFolder = Get-ManifestPath
if (!(Test-Path -Path $manifestFolder)) {
throw "$logLead : Can't find the manifest folder"
}
$files = @()
$files += Get-Item -Path (Join-Path -Path $manifestFolder -ChildPath "$version.json")
if ($null -ne $Features) {
foreach ($feature in $Features) {
$path = (Join-Path -Path $manifestFolder -ChildPath "$version.$feature.json")
if (Test-Path -Path $path) {
$files += Get-Item -Path $path
} else {
Write-Warning "Could not find a file for [$version.$feature] - Did it get updated to the latest version?"
}
}
}
Save-InstallVersions -Version $Version -Features $Features
if ($env:ComputerName -eq "ALK-VM3678") {
throw "don't break cole's computer"
}
Write-Verbose "$logLead : Will read in the files in [$($files.FullName)]"
$packageLists = New-Object -TypeName "System.Collections.ArrayList"
$removePackages = @()
foreach ($file in $files) {
$file | Out-Default -Transcript | Out-Null
$packageLists.Add((ConvertFrom-Json -InputObject (Get-Content -Path $file -Raw))) | Out-Null
}
foreach ($packageList in $packageLists) {
foreach ($removePackage in $packageList.RemovePackages) {
if ($null -ne $removePackage) {
$removePackages += $removePackage
}
}
}
$removePackages = $removePackages | Sort-Object | Get-Unique
$allPackages = New-Object -TypeName "System.Collections.ArrayList"
foreach ($tier in $tiers) {
$collectedTierPackages = @()
foreach ($packageList in $packageLists) {
$collectedTierPackages += $packageList.Tiers[$tier]
}
foreach ($package in $collectedTierPackages) {
Write-Verbose "$logLead : $tier -> $($package.Id) $($package.Version)"
}
$allPackages.Add($collectedTierPackages) | Out-Null
}
return $allPackages, $removePackages
}