From de5bb6caf0ed30771768a18e0eb4a45a23e441c4 Mon Sep 17 00:00:00 2001 From: dmealo Date: Mon, 17 Feb 2025 19:55:53 -0500 Subject: [PATCH] Bump minor version to 24, improve local setup (undo-local) reliability, update module version format logic, and enhance module removal checks, complete round of work to optimize build for local testing (run Local.ps1 for quick testing, Local.ps1 -Package -Analyze for pre PR test of packaging, etc) --- Build.ps1 | 14 +++++++------- Undo-Local.ps1 | 25 +++++++++++++++++++++---- src/AzKube/AzKube.psd1 | 8 ++++---- src/AzKube/private/Aks-Utilities.ps1 | 4 ++-- src/AzKube/public/Set-AksClusters.ps1 | 13 ++++++++++--- 5 files changed, 44 insertions(+), 20 deletions(-) diff --git a/Build.ps1 b/Build.ps1 index 09dd135..682d54f 100644 --- a/Build.ps1 +++ b/Build.ps1 @@ -14,7 +14,7 @@ param ( [Parameter()] [Int16] - $minorVersion = 23, + $minorVersion = 24, [Parameter()] [Int16] @@ -54,14 +54,14 @@ Process { Push-Location src/AzKube # Increment the module version to the format yymmdd.hhmm.ss - if ($Package) { + # if ($Package) { $moduleVersion = $("$majorVersion.$minorVersion.$patchVersion") - } - else { - $moduleVersion = $(Get-Date).ToString('yyMMdd.HHmm.ss') - } + # } + # else { + # $moduleVersion = $(Get-Date).ToString('yyMMdd.HHmm.ss') + # } # $moduleVersion = $("$majorVersion.$minorVersion.$patchVersion+$((Get-Date).ToString('yyMMdd.HHmm.ss'))") - Write-Host "Incrementing module version to $moduleVersion" + Write-Host "Setting module version to $moduleVersion" # Create the module manifest diff --git a/Undo-Local.ps1 b/Undo-Local.ps1 index 8ee657a..3d64c84 100644 --- a/Undo-Local.ps1 +++ b/Undo-Local.ps1 @@ -3,12 +3,19 @@ # .\Undo-Local.ps1 # +$nugetRepoPath = "$PSScriptRoot\src\AzKube\NuGetRepo" + # Remove the module from the local repository if (Get-Module -Name AzKube) { Remove-Module -Name AzKube -Force # Verify the module is removed - Get-Module -Name AzKube + if (!(Get-Module -Name AzKube -ErrorAction SilentlyContinue)) { + Write-Host "The AzKube module has been removed" + } + else { + Write-Host "The AzKube module has not been removed" + } } # Uninstall the module @@ -22,11 +29,21 @@ Unregister-PSRepository -Name AzKubeRepo -ErrorAction SilentlyContinue Push-Location $PSScriptRoot # Remove the NuGet repository -Remove-Item -Path ./src/AzKube/NuGetRepo -Force -Recurse +if (Test-Path $nugetRepoPath) { + Remove-Item -Path $nugetRepoPath -Force -Recurse +} # Remove the module from the PSModulePath -$path = (Resolve-Path '.').Path +$path = (Resolve-Path './src/AzKube').Path +$path if ($env:PSModulePath -like "*$path*") { - $env:PSModulePath = $env:PSModulePath -replace ";$path", "" + $escapedAzKubePath = $path -replace "\\", "\\\\\\\\" + $escapedAzKubePath + $escapedPSModulePath = $env:PSModulePath -replace "\\", "\\\\" + $removedPath = $escapedPSModulePath -replace ";$escapedAzKubePath", "" + $removedPath + if ($removedPath -ne '') { + $env:PSModulePath = $removedPath -replace "\\\\\\\\", "\" + } } Pop-Location \ No newline at end of file diff --git a/src/AzKube/AzKube.psd1 b/src/AzKube/AzKube.psd1 index 0a4dc25..986b457 100644 --- a/src/AzKube/AzKube.psd1 +++ b/src/AzKube/AzKube.psd1 @@ -12,7 +12,7 @@ RootModule = './AzKube.psm1' # Version number of this module. -ModuleVersion = '0.22.0' +ModuleVersion = '0.24.0' # Supported PSEditions # CompatiblePSEditions = @() @@ -101,7 +101,7 @@ PrivateData = @{ # LicenseUri = '' # A URL to the main website for this project. - # ProjectUri = '' + ProjectUri = 'https://github.com/dmealo/AzKube' # A URL to an icon representing this module. # IconUri = '' @@ -120,10 +120,10 @@ PrivateData = @{ } # End of PSData hashtable -} # End of PrivateData hashtable + } # End of PrivateData hashtable # HelpInfo URI of this module -# HelpInfoURI = '' +HelpInfoURI = 'https://github.com/dmealo/AzKube/README.md' # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. # DefaultCommandPrefix = '' diff --git a/src/AzKube/private/Aks-Utilities.ps1 b/src/AzKube/private/Aks-Utilities.ps1 index 6f18dbe..e370ea0 100644 --- a/src/AzKube/private/Aks-Utilities.ps1 +++ b/src/AzKube/private/Aks-Utilities.ps1 @@ -111,16 +111,16 @@ function Install-AzModule { # Install PSMenu if not already installed function Install-PSMenu { - Write-Host "Installing PSMenu module..." if (-not (Get-Command Show-Menu -ErrorAction SilentlyContinue)) { + Write-Host "Installing PSMenu module..." Install-Module -Name PSMenu -Force } } # Function to install kubectl using WinGet if not already installed function Install-Kubectl { - Write-Host "Installing kubectl using WinGet..." if (-not (Get-Command kubectl -ErrorAction SilentlyContinue)) { + Write-Host "Installing kubectl using WinGet..." winget install --id Kubernetes.kubectl -e } } diff --git a/src/AzKube/public/Set-AksClusters.ps1 b/src/AzKube/public/Set-AksClusters.ps1 index 7f8e217..4e3fa58 100644 --- a/src/AzKube/public/Set-AksClusters.ps1 +++ b/src/AzKube/public/Set-AksClusters.ps1 @@ -35,11 +35,20 @@ function Set-AksClusters { $SkipTestActions ) + Clear-Host + + $appTitle = "AzKube" + $Title = " | Starting..." + . "$PSScriptRoot\..\private\Aks-Utilities.ps1" . "$PSScriptRoot\..\private\Aks-Ui-Utilities.ps1" $ProxyUrl = Get-DefaultProxyUrl -ProxyUrl $ProxyUrl + Write-Host + Write-Host $appTitle -ForegroundColor Blue -NoNewline + Write-Host $Title -ForegroundColor Cyan + Install-AzureCli Install-PsMenu @@ -48,9 +57,6 @@ function Set-AksClusters { do { # Create and use a new TenantList object to get all tenants Clear-Host - Write-Host - Write-Host "Loading interface..." -ForegroundColor Cyan - Clear-Host if ($global:SelectedTenant) { # Use the saved tenant to initialize your tenant list $tenant.SelectedTenant = $global:SelectedTenant @@ -62,6 +68,7 @@ function Set-AksClusters { $global:SelectedTenant = $tenant.SelectedTenant } } + # Display or select tenant if not already set $tenant.DisplaySelectedTenant()