internal/Get-IsNewMyCorpVersionAvailable.ps1
|
<#
.SYNOPSIS Checks the PowerShell Gallery for a newer version of the MyCorp module and displays a message if a newer version is available. .DESCRIPTION Compares the installed version of the MyCorp module with the latest version available on the PowerShell Gallery. This is useful to let the user know if there are newer versions with updates and bug fixes. The function returns $true if a newer version is available, otherwise $false. .EXAMPLE Get-IsNewMyCorpVersionAvailable #> function Get-IsNewMyCorpVersionAvailable { [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Justification = 'Colors are beautiful')] [OutputType([bool])] [CmdletBinding()] param() try { $currentVersion = $ModuleInfo.ModuleVersion $latestVersion = (Find-Module -Name MyCorp).Version if ($currentVersion -lt $latestVersion) { Write-Host "🔥 FYI: A newer version of MyCorp is available! Run the commands below to update to the latest version." Write-Host "💥 Installed version: $currentVersion → Latest version: $latestVersion" -ForegroundColor DarkGray Write-Host "✨ Update-Module MyCorp" -NoNewline -ForegroundColor Green Write-Host " → Install the latest version of MyCorp." -ForegroundColor Yellow Write-Host "💫 Update-MyCorpTests" -NoNewline -ForegroundColor Green Write-Host " → Get the latest tests built by the MyCorp team and community." -ForegroundColor Yellow return $true } } catch { Write-Verbose -Message $_ } return $false } |