Private/_GlobalVariables.ps1

#
# _GlobalVariabls.ps1
#
#Initialise Global Variables
#Project Specific



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
    }    
}

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

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

    $global:devops_logo = @"
____ ____ _ _ __ ____ ___
| _ \ _____ _____ _ __ | _ \| | __ _| |_ / _| ___ _ __ _ __ ___ | _ \ _____ __/ _ \ _ __ ___
| |_) / _ \ \ /\ / / _ \ '__| | |_) | |/ _` | __| |_ / _ \| '__| '_ ` _ \ | | | |/ _ \ \ / / | | | '_ \/ __|
| __/ (_) \ V V / __/ | | __/| | (_| | |_| _| (_) | | | | | | | | | |_| | __/\ V /| |_| | |_) \__ \
|_| \___/ \_/\_/ \___|_| |_| |_|\__,_|\__|_| \___/|_| |_| |_| |_| |____/ \___| \_/ \___/| .__/|___/
                                                                                                 |_|
 
"@


    $global:devops_projectFile
    $global:devops_configFile = Get-Content ("$env:APPDATA\Microsoft.PowerPlatform.DevOps\devopsConfig.json") | ConvertFrom-Json
    [string]$getVersion = Get-ManifestValue (Join-Path $PSScriptRoot "\..\Microsoft.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
    }    
}