Lib/git_software.psm1

<#
    .SYNOPSIS
        Initialize Git Environment
 
    .DESCRIPTION
        Initialize Git Environment. Preparation script for downloading the NAF repo. Includes all git related
        software for cloning.
 
    .NOTES
        Author : hillesheim@n-dimensions.de
        Version : 2.5
        DateLastChanged : 2023-09-22
#>
 

Using Module .\helper.psm1; 

Write-Host "Load nested module 'git_software' ... "; 

#region DECLARATION
    
    #region TYPES
    #endregion

    #region VARIABLES_USER
        
    #endregion

    #region VARIABLES_SYSTEM

    [String] $psScriptFilePath = $MyInvocation.MyCommand.Definition; 
    [String] $psScriptFolderPath = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent; 
        
    #endregion

#endregion

#region FUNCTIONS_PUBLIC

Function Install-GitSoftware {

    # Select job
    $enumJobSteps_GitSoftware = "JobSteps_GitSoftware" -as [System.Type]; 
    [JobSteps_GitSoftware[]] $selection = `
        Show-EnumSelection `
            -Enum $enumJobSteps_GitSoftware `
            -Default $defaultJobSteps_GitSoftware `
            -Title "Job Steps: Please Select"
    Write-Host ("Selected job steps: "); 
    $selection `
        | ForEach-Object {
            Write-Host ("- {0}" -f $_); 
        }   

    # Edit script
    If ($selection -contains [JobSteps_GitSoftware]::OpenScriptEditor) {
        Open-ScriptEditor `
            -Filepath $psScriptFilePath 
    }
 
    # Install choco, allow global confirmation
    If ($selection -contains [JobSteps_GitSoftware]::InstallChoco) {
        Write-Host ("- Install choco, allow global confirmation ... " ); 
        [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; 
        iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
        choco feature enable -n allowGlobalConfirmation; 
    }
    
    # Choco upgrade all
    If ($selection -contains [JobSteps_GitSoftware]::ChocoUpgradeAll) {
        Write-Host ("- Choco upgrade all ... " ); 
        choco upgrade all; 
    }

    # Install git
    If ($selection -contains [JobSteps_GitSoftware]::InstallGit) {
        Write-Host ("- Install git ... " ); 
        choco install git;         
    }

    # Install github desktop
    If ($selection -contains [JobSteps_GitSoftware]::InstallGithubDesktop) {
        Write-Host ("- Install github desktop ... " ); 
        choco install github-desktop; 
    }

    # Install github client
    If ($selection -contains [JobSteps_GitSoftware]::InstallGithubClient) {
        Write-Host ("- Install github client ... " ); 
        choco install gh; 
    }   

    # Install PowerShell 7
    If ($selection -contains [JobSteps_GitSoftware]::InstallPowerShell7) {
        Write-Host ( "- Install 'PowerShell 7' ... " );  
        choco install powershell-core; 
    }   

    # Install VS Code
    If ($selection -contains [JobSteps_GitSoftware]::InstallVsCode) {
        Write-Host ("- Install VS Code ... " ); 
        choco install vscode; 
    }
    
    # Restart
    If ($selection -contains [JobSteps_GitSoftware]::Restart) {
        Write-Host ("- Restart ... " ); 
        Restart-Computer -Force; 
    }    

    # Abort
    If($selection -contains [JobSteps_GitSoftware]::Abort) {
        Return; 
    }

    # Run another job
    $userInput = Read-Host("Run another job (y|n)? Press ENTER for 'y'"); 
    If("" -eq $userInput ) {
        Install-GitSoftware; 
    }

}

#endregion

#region FUNCTIONS_PRIVATE

#endregion

#region EXPORT

Export-ModuleMember -Function 'Install-GitSoftware'; 

#endregion