Private/_GlobalVariables.ps1

# _GlobalVariables.ps1

set-alias nano 'C:\Program Files\Git\usr\bin\nano.exe'

function Set-ProjectVariables {
    param (
        
    )
    
    if (!$global:devops_projectFile) {
        Write-Verbose "Setting Project Variables (Empty)"
        $global:devops_projectTitle = "(No Project Selected)"
        $global:devops_projectLocation = "(No Project Selected)"
        $global:devops_gitRepo = "(No Project Selected)"
        $global:devops_selectedSubscriptionName = "(No Project Selected)"  
        $global:devops_selectedSubscription = $null      
        $global:devops_AzureKeyVault = "(No Project Selected)"
        $global:devops_ClientID = "(No Project Selected)"
        $global:devops_TenantID = "(No Project Selected)"
        $global:devops_DevOpsProduct = "(No Project Selected)"
        $global:devops_Branch = "(No Project Selected)"
        $global:devops_DataverseSolutionsAdded = $false

    }
    else {
        Write-Verbose "Setting Project Variables"
        $global:devops_projectTitle = $global:devops_projectFile.gitRepo    
        $global:devops_projectLocation = $global:devops_configFile.Projects[$global:devops_projectConfigID].ProjectLocation    
        $global:devops_gitRepo = $global:devops_projectFile.gitRepo
        $global:devops_selectedSubscriptionName = $global:devops_projectFile.selectedSubscriptionName
        $global:devops_selectedSubscription = $global:devops_projectFile.selectedSubscription        
        $global:devops_AzureKeyVault = $global:devops_projectFile.AzureKeyVaultName
        $global:devops_ClientID = $global:devops_projectFile.ClientID
        $global:devops_TenantID = $global:devops_projectFile.TenantID
        $global:devops_DevOpsProduct = $global:devops_projectFile.DevOpsProduct
        if ($global:devops_projectFile.DataverseSolutions.Count -gt 0) {
            $global:devops_DataverseSolutionsAdded = $true
        }
        $global:devops_Branch = git branch --show-current
        $global:devops_BaseBranch = $global:devops_projectFile.BaseBranch
        $global:devops_FullTool = $true
    }    
}

function Set-ToolVariables {
    param (
        
    )
    Write-Verbose "Setting Tool Variables"
    if (!(Test-Path "$env:APPDATA\Capgemini.PowerPlatform.DevOps")) {
        New-Item -Path "$env:APPDATA\Capgemini.PowerPlatform.DevOps" -ItemType Directory
    }
    if (!(Test-Path "$env:APPDATA\Capgemini.PowerPlatform.DevOps\devopsConfig.json")) {
        Copy-Item (Join-Path $PSScriptRoot "\devopsConfig.json") -Destination "$env:APPDATA\Capgemini.PowerPlatform.DevOps\devopsConfig.json"
    }

    #Tool Specific
    $global:devops_continue = $true
    $global:devops_devMode = $false
    $global:devops_message

    $global:devops_logo = @"
 
  ##### ###### ###### ###### #######
 # # ## ##### #### ###### # # ### # # ### # # # # # # # #
 # # # # # # # # ## ## # ## # # # # # # # # # #
 # # # # # # ##### # ## # # # # # # ###### ###### # # # #
 # ###### ##### # ### # # # # # # # # # # # # # #
 # # # # # # # # # # # # ## # # # # # # #
  ##### # # # #### ###### # # ### # # ### # # ###### #######
 
"@


    $global:devops_projectFile
    $global:devops_configFile = Get-Content ("$env:APPDATA\Capgemini.PowerPlatform.DevOps\devopsConfig.json") | ConvertFrom-Json
    [string]$getVersion = Get-ManifestValue (Join-Path $PSScriptRoot "\..\Capgemini.PowerPlatform.DevOps.psd1") -PropertyName 'ModuleVersion' -Passthru
    [version]$global:devops_version = $getVersion.Replace("'", "") 
    $global:devops_isDocker = (Test-InsideDockerContainer)
    if (!$global:devops_isDocker -and (!($host.Name -match 'ConsoleHost'))) {
        $global:devops_isDocker = $true
    }    
}