function New-PPTSettings { [CmdLetBinding()] Param ( $Path = (Get-Location).Path ) begin { $Path = @{ qualifier = (Split-Path -Path $Path -Qualifier) parent = (Split-Path -Path $Path) leaf = (Split-Path -Path $Path -Leaf) path = $Path pathBuild = (Join-Path -Path $Path -ChildPath 'Build') pathConfig = (Join-Path -Path $Path -ChildPath 'Build\config.json') sourcePath = (Join-Path -Path $PSScriptRoot -ChildPath 'source') sourceConfig = (Join-Path -Path $PSScriptRoot -ChildPath 'source\config.ps1') sourceIgnore = (Join-Path -Path $PSScriptRoot -ChildPath 'source\.gitignore') } $config = (Get-Content $Path.pathConfig | ConvertFrom-Json) If((Get-ChildItem -Path $Path.path -Name *.zip).Count -ge 1) { $index = 1 $solutions = Get-ChildItem -Path $Path.path -Name *.zip | Get-Item | ForEach-Object { @{ $index++ = @{ id = $index - 1 name = "$($_.Name)" fullname = $_.FullName directory = $_.Directory basename = $_.BaseName } } } do { #Write-Host "┌───────────────────────────────────────────────────────────────┐" -ForegroundColor Green #Write-Host "│" -ForegroundColor Green -NoNewLine; Write-Host "`t`tPACKAGES AVAILABLE IN CURRENT PROJECT`t`t" -ForegroundColor Cyan -NoNewline; Write-Host "│" -ForegroundColor Green #Write-Host "└───────────────────────────────────────────────────────────────┘" -ForegroundColor Green $solutions | %{"[ {0} ] {1}" -f $_.Values.id,$_.Values.basename} $solutionsId = Read-Host -Prompt "`nSelect Solution Package ($((1..$solutions.Values.id.Count) -join ','))" } while ($solutionsId -notin (1..$solutions.Values.id.Count)) $solutionSelectd = ($solutions | ?{$_.Values.id -eq $solutionsId}) $Path.leaf = $solutionSelectd.Values.basename } } process { foreach ($env in $config.env) { $settingsFile = "$($env.name.ToUpper()).$($env.env_id).$($Path.leaf).json" $IsSolutionPresent = Test-Path -Path "$($Path.path)\$($Path.leaf).zip" if($IsSolutionPresent) { Write-Host "[ Info ] " -ForegroundColor Green -nonewline; write-host "Generating Solution Settings File" -ForegroundColor Cyan & $Global:pptConfig.pacPath solution create-settings --solution-zip "$($Path.path)\$($Path.leaf).zip" --settings-file $settingsFile } else { Write-Host '[ Error ] ' -ForegroundColor Yellow -nonewline; write-host "Solution Package Missing: $($Path.path)\$($Path.leaf).zip" -ForegroundColor Yellow } } } end { } } # EXPORT ALIAS New-Alias -Name settings -Value New-PPTSettings -Description 'posh-PowerPlatformToolkit - New-PPTSettings alias' -Force