From 5a8d073be1e360172dc1f7fe112bdd034b7f9209 Mon Sep 17 00:00:00 2001 From: mdaneri Date: Tue, 2 Apr 2024 02:37:08 -0700 Subject: [PATCH 1/8] first drop --- docs/pwshsupportpolicy.md | 30 +++++++++ pode.build.ps1 | 15 ++++- src/Pode.psd1 | 19 +++--- src/Pode.psm1 | 50 +++++++++++---- src/Private/Server.ps1 | 4 ++ src/Private/Version.ps1 | 127 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 225 insertions(+), 20 deletions(-) create mode 100644 docs/pwshsupportpolicy.md create mode 100644 src/Private/Version.ps1 diff --git a/docs/pwshsupportpolicy.md b/docs/pwshsupportpolicy.md new file mode 100644 index 000000000..53bac88f6 --- /dev/null +++ b/docs/pwshsupportpolicy.md @@ -0,0 +1,30 @@ +# Pode PowerShell Version Support Policy + +## Overview +This document details the support policy for PowerShell versions as they relate to Pode releases. Our aim is to provide clarity on which versions of PowerShell are supported by each release of Pode, ensuring a secure, efficient, and compatible development environment. + +## Policy Statement +Pode commits to supporting PowerShell versions that are not end of life (EOL) at the moment of each Pode release. This dynamic approach allows Pode to adapt to the evolving PowerShell ecosystem, ensuring compatibility with recent and supported PowerShell versions while maintaining a high security standard. + +### Support Lifecycle +- For each Pode release, support is extended to versions of PowerShell that are not EOL at the time of release. +- Subsequent Pode releases may not support previously compatible PowerShell versions if those versions have reached EOL in the interim. +- This policy applies to all versions of PowerShell, including PowerShell Core (versions 7.x) and Windows PowerShell 5.1. +- Windows Powershell 5.1 will be supported by any Pode version released prior the Jan 7 2027 + +### Example +- **Pode 2.10 Release (April 2024)**: Supports PowerShell Core 7.2, 7.3, 7.4, and Windows PowerShell 5.1, assuming none are EOL at the time of release. +- **Pode 2.11 Release (Late 2024)**: With PowerShell Core 7.2 and 7.3 reaching EOL, support for these versions would be discontinued. Pode 2.11 would then support PowerShell Core 7.4 and any newer, non-EOL versions, along with Windows PowerShell 5.1. + +## Testing Strategy +Pode is tested against the PowerShell versions it supports at the time of each release. Testing focuses on ensuring compatibility with non-EOL versions of PowerShell, reflecting the policy stated above. + +## Warning Mechanism +A warning mechanism within Pode detects the PowerShell version in use at runtime. If a version no longer supported by the current release of Pode is detected—due to reaching EOL—a warning will be issued, advising on the potential risks and recommending an update to a supported version. + +## Version Updates and Communication +Updates to the PowerShell version support policy will be documented in Pode’s release notes and official documentation. Users are encouraged to review these sources to stay informed about which PowerShell versions are supported by their version of Pode. + +## Feedback and Contributions +Feedback on Pode's PowerShell version support policy is invaluable. We welcome suggestions and contributions from our community to help refine and improve our approach. Please share your thoughts through our GitHub repository or community forums. + diff --git a/pode.build.ps1 b/pode.build.ps1 index 930714a38..2561e707a 100644 --- a/pode.build.ps1 +++ b/pode.build.ps1 @@ -130,6 +130,18 @@ function Invoke-PodeBuildDotnetBuild($target ) { } +function Get-PwshCoreEndOfLife { + param( + [switch] $RecentCycle + ) + $eol = invoke-restmethod -Uri 'https://endoflife.date/api/powershell.json' -Headers @{Accept = 'application/json' } + $expired = $eol.Where({ (get-date $_.eol) -lt (get-date) }) + if ($RecentCycle){ + return $expired[0].cycle + }else { + return $expired + } +} <# # Helper Tasks @@ -137,7 +149,8 @@ function Invoke-PodeBuildDotnetBuild($target ) { # Synopsis: Stamps the version onto the Module Task StampVersion { - (Get-Content ./pkg/Pode.psd1) | ForEach-Object { $_ -replace '\$version\$', $Version } | Set-Content ./pkg/Pode.psd1 + $pwshCoreEndOfLife = Get-PwshCoreEndOfLife -RecentCycle + (Get-Content ./pkg/Pode.psd1) | ForEach-Object { $_ -replace '\$version\$', $Version -replace '\$versionUntested\$', $pwshCoreEndOfLife -replace '\$buildyear\$', ((get-date).Year) } | Set-Content ./pkg/Pode.psd1 (Get-Content ./pkg/Pode.Internal.psd1) | ForEach-Object { $_ -replace '\$version\$', $Version } | Set-Content ./pkg/Pode.Internal.psd1 (Get-Content ./packers/choco/pode_template.nuspec) | ForEach-Object { $_ -replace '\$version\$', $Version } | Set-Content ./packers/choco/pode.nuspec (Get-Content ./packers/choco/tools/ChocolateyInstall_template.ps1) | ForEach-Object { $_ -replace '\$version\$', $Version } | Set-Content ./packers/choco/tools/ChocolateyInstall.ps1 diff --git a/src/Pode.psd1 b/src/Pode.psd1 index 048df39cd..773752512 100644 --- a/src/Pode.psd1 +++ b/src/Pode.psd1 @@ -20,13 +20,13 @@ Author = 'Matthew Kelly (Badgerati)' # Copyright statement for this module - Copyright = 'Copyright (c) 2017-2023 Matthew Kelly (Badgerati), licensed under the MIT License.' + Copyright = 'Copyright (c) 2017-$buildyear$ Matthew Kelly (Badgerati), licensed under the MIT License.' # Description of the functionality provided by this module Description = 'A Cross-Platform PowerShell framework for creating web servers to host REST APIs and Websites. Pode also has support for being used in Azure Functions and AWS Lambda.' # Minimum version of the Windows PowerShell engine required by this module - PowerShellVersion = '5.0' + PowerShellVersion = '5.1' # Functions to export from this Module FunctionsToExport = @( @@ -456,14 +456,16 @@ # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. PrivateData = @{ - PSData = @{ + PSData = @{ # Tags applied to this module. These help with module discovery in online galleries. - Tags = @('powershell', 'web', 'server', 'http', 'listener', 'rest', 'api', 'tcp', 'smtp', 'websites', - 'powershell-core', 'windows', 'unix', 'linux', 'pode', 'PSEdition_Core', 'cross-platform', - 'file-monitoring', 'multithreaded', 'schedule', 'middleware', 'session', - 'authentication', 'authorisation', 'arm', 'raspberry-pi', 'aws-lambda', - 'azure-functions', 'websockets', 'swagger', 'openapi', 'webserver', 'secrets', 'fim') + Tags = @( + 'powershell', 'web', 'server', 'http', 'https', 'listener', 'rest', 'api', 'tcp', + 'smtp', 'websites', 'powershell-core', 'windows', 'unix', 'linux', 'pode', 'PSEdition_Core', + 'cross-platform', 'file-monitoring', 'multithreaded', 'schedule', 'middleware', 'session', + 'authentication', 'authorisation', 'authorization', 'arm', 'raspberry-pi', 'aws-lambda', + 'azure-functions', 'websockets', 'swagger', 'openapi', 'webserver', 'secrets', 'fim' + ) # A URL to the license for this module. LicenseUri = 'https://raw.githubusercontent.com/Badgerati/Pode/master/LICENSE.txt' @@ -478,5 +480,6 @@ ReleaseNotes = 'https://github.com/Badgerati/Pode/releases/tag/v$version$' } + PwshCoreVersionUntested = '$versionUntested$' } } \ No newline at end of file diff --git a/src/Pode.psm1 b/src/Pode.psm1 index 8d2aea415..daa3c6986 100644 --- a/src/Pode.psm1 +++ b/src/Pode.psm1 @@ -5,17 +5,35 @@ $root = Split-Path -Parent -Path $MyInvocation.MyCommand.Path Add-Type -AssemblyName System.Web Add-Type -AssemblyName System.Net.Http -# netstandard2 for <7.2 -if ($PSVersionTable.PSVersion -lt [version]'7.2.0') { - Add-Type -LiteralPath "$($root)/Libs/netstandard2.0/Pode.dll" -ErrorAction Stop -} -# net6 for =7.2 -elseif ($PSVersionTable.PSVersion -lt [version]'7.3.0') { - Add-Type -LiteralPath "$($root)/Libs/net6.0/Pode.dll" -ErrorAction Stop +# Construct the path to the module manifest (.psd1 file) +$moduleManifestPath = Join-Path -Path $PSScriptRoot -ChildPath 'Pode.psd1' + +# Import the module manifest to access its properties +$moduleManifest = Import-PowerShellDataFile -Path $moduleManifestPath + +$podeDll = [AppDomain]::CurrentDomain.GetAssemblies() | Where-Object { $_.GetName().Name -like 'Pode' } + +if ($podeDll) { + if ( $moduleManifest.ModuleVersion -ne '$version$') { + $moduleVersion = ([version]::new($moduleManifest.ModuleVersion + '.0')) + if ( $podeDll.GetName().Version.CompareTo($moduleVersion) -ne 0) { + throw "An existing incompatible Pode.DLL version $($podeDll.GetName().Version) is loaded. Version $moduleVersion is required. Open a new Powershell/pwsh session and retry." + } + } } -# net7 for >7.2 else { - Add-Type -LiteralPath "$($root)/Libs/net7.0/Pode.dll" -ErrorAction Stop + if ($PSVersionTable.PSVersion -ge [version]'7.4.0') { + Add-Type -LiteralPath "$($root)/Libs/net8.0/Pode.dll" -ErrorAction Stop + } + elseif ($PSVersionTable.PSVersion -ge [version]'7.3.0') { + Add-Type -LiteralPath "$($root)/Libs/net7.0/Pode.dll" -ErrorAction Stop + } + elseif ($PSVersionTable.PSVersion -ge [version]'7.2.0') { + Add-Type -LiteralPath "$($root)/Libs/net6.0/Pode.dll" -ErrorAction Stop + } + else { + Add-Type -LiteralPath "$($root)/Libs/netstandard2.0/Pode.dll" -ErrorAction Stop + } } # load private functions @@ -24,11 +42,21 @@ Get-ChildItem "$($root)/Private/*.ps1" | ForEach-Object { . ([System.IO.Path]::G # only import public functions $sysfuncs = Get-ChildItem Function: +# only import public alias +$sysaliases = Get-ChildItem Alias: + # load public functions Get-ChildItem "$($root)/Public/*.ps1" | ForEach-Object { . ([System.IO.Path]::GetFullPath($_)) } # get functions from memory and compare to existing to find new functions added $funcs = Get-ChildItem Function: | Where-Object { $sysfuncs -notcontains $_ } - +$aliases = Get-ChildItem Alias: | Where-Object { $sysaliases -notcontains $_ } # export the module's public functions -Export-ModuleMember -Function ($funcs.Name) \ No newline at end of file +if ($funcs) { + if ($aliases) { + Export-ModuleMember -Function ($funcs.Name) -Alias $aliases.Name + } + else { + Export-ModuleMember -Function ($funcs.Name) + } +} diff --git a/src/Private/Server.ps1 b/src/Private/Server.ps1 index 261c8ddb5..ee2d8fefe 100644 --- a/src/Private/Server.ps1 +++ b/src/Private/Server.ps1 @@ -140,8 +140,12 @@ function Start-PodeInternalServer { # run running event hooks Invoke-PodeEvent -Type Running + # Check if the running version of Powershell is EOL + $null = Test-PSVersionEOL + # state what endpoints are being listened on if ($endpoints.Length -gt 0) { + Write-PodeHost "Pode Web Framework $(Get-PodeVersion) (pid:$PID)" -ForegroundColor Yellow Write-PodeHost "Listening on the following $($endpoints.Length) endpoint(s) [$($PodeContext.Threads.General) thread(s)]:" -ForegroundColor Yellow $endpoints | ForEach-Object { $flags = @() diff --git a/src/Private/Version.ps1 b/src/Private/Version.ps1 new file mode 100644 index 000000000..daf589dfc --- /dev/null +++ b/src/Private/Version.ps1 @@ -0,0 +1,127 @@ +<# +.SYNOPSIS +Retrieves the PowerShell module manifest object for the specified module. + +.DESCRIPTION +This function constructs the path to a PowerShell module manifest file (.psd1) located in the parent directory of the script root. It then imports the module manifest file to access its properties and returns the manifest object. This can be useful for scripts that need to dynamically discover and utilize module metadata, such as version, dependencies, and exported functions. + +.PARAMETERS +This function does not accept any parameters. + +.EXAMPLE +$manifest = Get-ModuleManifest +This example calls the `Get-ModuleManifest` function to retrieve the module manifest object and stores it in the variable `$manifest`. + +#> +function Get-ModuleManifest { + # Construct the path to the module manifest (.psd1 file) + $moduleManifestPath = Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'Pode.psd1' + + # Import the module manifest to access its properties + $moduleManifest = Import-PowerShellDataFile -Path $moduleManifestPath + return $moduleManifest +} + + +<# +.SYNOPSIS +Gets the version of the Pode module. + +.DESCRIPTION +The Get-PodeVersion function checks the version of the Pode module specified in the module manifest. If the module version is not a placeholder value ('$version$'), it returns the actual version prefixed with 'v.'. If the module version is the placeholder value, indicating the development branch, it returns '[develop branch]'. + +.PARAMETER None +This function does not accept any parameters. + +.OUTPUTS +System.String +Returns a string indicating the version of the Pode module or '[develop branch]' if on a development version. + +.EXAMPLE +PS> $moduleManifest = @{ ModuleVersion = '1.2.3' } +PS> Get-PodeVersion + +Returns 'v.1.2.3'. + +.EXAMPLE +PS> $moduleManifest = @{ ModuleVersion = '$version$' } +PS> Get-PodeVersion + +Returns '[develop branch]'. + +.NOTES +This function assumes that $moduleManifest is a hashtable representing the loaded module manifest, with a key of ModuleVersion. + +#> +function Get-PodeVersion { + $moduleManifest = Get-ModuleManifest + if ($moduleManifest.ModuleVersion -ne '$version$') { + return "v.$($moduleManifest.ModuleVersion)" + } + else { + return '[develop branch]' + } +} + +<# +.SYNOPSIS +Tests if the Pode module is from the development branch. + +.DESCRIPTION +The Test-PodeDevelop function checks if the Pode module's version matches the placeholder value ('$version$'), which is used to indicate the development branch of the module. It returns $true if the version matches, indicating the module is from the development branch, and $false otherwise. + +.PARAMETER None +This function does not accept any parameters. + +.OUTPUTS +System.Boolean +Returns $true if the Pode module version is '$version$', indicating the development branch. Returns $false for any other version. + +.EXAMPLE +PS> $moduleManifest = @{ ModuleVersion = '$version$' } +PS> Test-PodeDevelop + +Returns $true, indicating the development branch. + +.EXAMPLE +PS> $moduleManifest = @{ ModuleVersion = '1.2.3' } +PS> Test-PodeDevelop + +Returns $false, indicating a specific release version. + +.NOTES +This function assumes that $moduleManifest is a hashtable representing the loaded module manifest, with a key of ModuleVersion. + +#> +function Test-PodeDevelop { + return (Get-ModuleManifest).ModuleVersion -eq '$version$' +} + + +<# +.SYNOPSIS +Tests if the current PowerShell version is considered End-of-Life (EOL). + +.DESCRIPTION +The Test-PSVersionEOL function checks if the PowerShell session is running on the Core edition and if the version is earlier than $moduleManifest.PrivateData.PwshCoreVersionUntested. If both conditions are met, it indicates that the PowerShell version is EOL. A warning message is displayed, noting that while Pode should still function, it has not been tested on EOL versions. + +.PARAMETER None +This function does not accept any parameters. + +.EXAMPLE +PS> Test-PSVersionEOL + +If running on PowerShell Core version earlier than $moduleManifest.PrivateData.PwshCoreVersionUntested, you will see a warning message indicating the version is EOL. + +#> +function Test-PSVersionEOL { + $moduleManifest = Get-ModuleManifest + if ($moduleManifest.ModuleVersion -ne '$version$') { + # Check if the PowerShell edition is Core and the version is earlier than the last version tested + if ($PSVersionTable.PSEdition -eq 'Core' -and $PSVersionTable.PSVersion -lt [version]$moduleManifest.PrivateData.PwshCoreVersionUntested) { + Write-Host "This PowerShell version $($PSVersionTable.PSVersion) was EOL when Pode $(Get-PodeVersion) was released. Pode should work but has not been tested." -ForegroundColor Yellow + return $true + } + } + return $false +} From f75476ebd3bf1cb718bf8ecbbe594294baa1a096 Mon Sep 17 00:00:00 2001 From: mdaneri Date: Wed, 3 Apr 2024 08:14:22 -0700 Subject: [PATCH 2/8] Remove duplicated .Net build --- pode.build.ps1 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pode.build.ps1 b/pode.build.ps1 index 2561e707a..533b9d5f7 100644 --- a/pode.build.ps1 +++ b/pode.build.ps1 @@ -118,10 +118,6 @@ function Invoke-PodeBuildDotnetBuild($target ) { else { $AssemblyVersion = '' } - dotnet build --configuration Release --self-contained --framework $target $AssemblyVersion - if (!$?) { - throw "dotnet build failed for $($target)" - } dotnet publish --configuration Release --self-contained --framework $target $AssemblyVersion --output ../Libs/$target if (!$?) { From 9e2ddafb4b1b8cac36752881061ea1cea1da3837 Mon Sep 17 00:00:00 2001 From: mdaneri Date: Fri, 5 Apr 2024 02:37:55 -0700 Subject: [PATCH 3/8] first review --- docs/pwshsupportpolicy.md | 6 +- examples/web-auth-apikey-jwt.ps1 | 2 +- pode.build.ps1 | 4 +- src/Pode.psd1 | 1 + src/Pode.psm1 | 6 +- src/Private/Helpers.ps1 | 91 +++++++++++++++++++++- src/Private/Server.ps1 | 4 +- src/Private/Version.ps1 | 127 ------------------------------- src/Public/Utilities.ps1 | 43 +++++++++++ 9 files changed, 145 insertions(+), 139 deletions(-) delete mode 100644 src/Private/Version.ps1 diff --git a/docs/pwshsupportpolicy.md b/docs/pwshsupportpolicy.md index 53bac88f6..6ff727173 100644 --- a/docs/pwshsupportpolicy.md +++ b/docs/pwshsupportpolicy.md @@ -9,12 +9,12 @@ Pode commits to supporting PowerShell versions that are not end of life (EOL) at ### Support Lifecycle - For each Pode release, support is extended to versions of PowerShell that are not EOL at the time of release. - Subsequent Pode releases may not support previously compatible PowerShell versions if those versions have reached EOL in the interim. -- This policy applies to all versions of PowerShell, including PowerShell Core (versions 7.x) and Windows PowerShell 5.1. +- This policy applies to all versions of PowerShell, including PowerShell (version 7.x), PowerShell Core (versions 6.x) and Windows PowerShell 5.1. - Windows Powershell 5.1 will be supported by any Pode version released prior the Jan 7 2027 ### Example -- **Pode 2.10 Release (April 2024)**: Supports PowerShell Core 7.2, 7.3, 7.4, and Windows PowerShell 5.1, assuming none are EOL at the time of release. -- **Pode 2.11 Release (Late 2024)**: With PowerShell Core 7.2 and 7.3 reaching EOL, support for these versions would be discontinued. Pode 2.11 would then support PowerShell Core 7.4 and any newer, non-EOL versions, along with Windows PowerShell 5.1. +- **Pode 2.10 Release (April 2024)**: Supports PowerShell 7.2, 7.3, 7.4, and Windows PowerShell 5.1, assuming none are EOL at the time of release. +- **Pode 2.11 Release (Late 2024)**: With PowerShell 7.2 and 7.3 reaching EOL, support for these versions would be discontinued. Pode 2.11 would then support PowerShell Core 7.4 and any newer, non-EOL versions, along with Windows PowerShell 5.1. ## Testing Strategy Pode is tested against the PowerShell versions it supports at the time of each release. Testing focuses on ensuring compatibility with non-EOL versions of PowerShell, reflecting the policy stated above. diff --git a/examples/web-auth-apikey-jwt.ps1 b/examples/web-auth-apikey-jwt.ps1 index 9c39f2aa8..0b94b8dcd 100644 --- a/examples/web-auth-apikey-jwt.ps1 +++ b/examples/web-auth-apikey-jwt.ps1 @@ -27,7 +27,7 @@ Import-Module "$($path)/src/Pode.psm1" -Force -ErrorAction Stop Start-PodeServer -Threads 2 { # listen on localhost:8085 - Add-PodeEndpoint -Address * -Port 8085 -Protocol Http + Add-PodeEndpoint -Address localhost -Port 8085 -Protocol Http New-PodeLoggingMethod -File -Name 'requests' | Enable-PodeRequestLogging New-PodeLoggingMethod -Terminal | Enable-PodeErrorLogging diff --git a/pode.build.ps1 b/pode.build.ps1 index 533b9d5f7..25063da8e 100644 --- a/pode.build.ps1 +++ b/pode.build.ps1 @@ -126,7 +126,7 @@ function Invoke-PodeBuildDotnetBuild($target ) { } -function Get-PwshCoreEndOfLife { +function Get-PodeBuildPwshEOL { param( [switch] $RecentCycle ) @@ -145,7 +145,7 @@ function Get-PwshCoreEndOfLife { # Synopsis: Stamps the version onto the Module Task StampVersion { - $pwshCoreEndOfLife = Get-PwshCoreEndOfLife -RecentCycle + $pwshCoreEndOfLife = Get-PodeBuildPwshEOL -RecentCycle (Get-Content ./pkg/Pode.psd1) | ForEach-Object { $_ -replace '\$version\$', $Version -replace '\$versionUntested\$', $pwshCoreEndOfLife -replace '\$buildyear\$', ((get-date).Year) } | Set-Content ./pkg/Pode.psd1 (Get-Content ./pkg/Pode.Internal.psd1) | ForEach-Object { $_ -replace '\$version\$', $Version } | Set-Content ./pkg/Pode.Internal.psd1 (Get-Content ./packers/choco/pode_template.nuspec) | ForEach-Object { $_ -replace '\$version\$', $Version } | Set-Content ./packers/choco/pode.nuspec diff --git a/src/Pode.psd1 b/src/Pode.psd1 index 773752512..87b2fe8b1 100644 --- a/src/Pode.psd1 +++ b/src/Pode.psd1 @@ -293,6 +293,7 @@ 'Get-PodeEndpoint', 'Pode', 'Get-PodeServerDefaultSecret', + 'Get-PodeVersion', # openapi 'Enable-PodeOpenApi', diff --git a/src/Pode.psm1 b/src/Pode.psm1 index daa3c6986..d1a1d315b 100644 --- a/src/Pode.psm1 +++ b/src/Pode.psm1 @@ -6,17 +6,17 @@ Add-Type -AssemblyName System.Web Add-Type -AssemblyName System.Net.Http # Construct the path to the module manifest (.psd1 file) -$moduleManifestPath = Join-Path -Path $PSScriptRoot -ChildPath 'Pode.psd1' +$moduleManifestPath = Join-Path -Path $root -ChildPath 'Pode.psd1' # Import the module manifest to access its properties $moduleManifest = Import-PowerShellDataFile -Path $moduleManifestPath -$podeDll = [AppDomain]::CurrentDomain.GetAssemblies() | Where-Object { $_.GetName().Name -like 'Pode' } +$podeDll = [AppDomain]::CurrentDomain.GetAssemblies() | Where-Object { $_.GetName().Name -eq 'Pode' } if ($podeDll) { if ( $moduleManifest.ModuleVersion -ne '$version$') { $moduleVersion = ([version]::new($moduleManifest.ModuleVersion + '.0')) - if ( $podeDll.GetName().Version.CompareTo($moduleVersion) -ne 0) { + if ($podeDll.GetName().Version -ne $moduleVersion) { throw "An existing incompatible Pode.DLL version $($podeDll.GetName().Version) is loaded. Version $moduleVersion is required. Open a new Powershell/pwsh session and retry." } } diff --git a/src/Private/Helpers.ps1 b/src/Private/Helpers.ps1 index 6a2e9529f..ec6b4f546 100644 --- a/src/Private/Helpers.ps1 +++ b/src/Private/Helpers.ps1 @@ -2899,4 +2899,93 @@ function Test-PodePlaceholders { } return ($Path -imatch $Placeholder) -} \ No newline at end of file +} + + +<# +.SYNOPSIS +Retrieves the PowerShell module manifest object for the specified module. + +.DESCRIPTION +This function constructs the path to a PowerShell module manifest file (.psd1) located in the parent directory of the script root. It then imports the module manifest file to access its properties and returns the manifest object. This can be useful for scripts that need to dynamically discover and utilize module metadata, such as version, dependencies, and exported functions. + +.PARAMETERS +This function does not accept any parameters. + +.EXAMPLE +$manifest = Get-PodeModuleManifest +This example calls the `Get-PodeModuleManifest` function to retrieve the module manifest object and stores it in the variable `$manifest`. + +#> +function Get-PodeModuleManifest { + # Construct the path to the module manifest (.psd1 file) + $moduleManifestPath = Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'Pode.psd1' + + # Import the module manifest to access its properties + $moduleManifest = Import-PowerShellDataFile -Path $moduleManifestPath + return $moduleManifest +} + + +<# +.SYNOPSIS +Tests if the Pode module is from the development branch. + +.DESCRIPTION +The Test-PodeVersionDev function checks if the Pode module's version matches the placeholder value ('$version$'), which is used to indicate the development branch of the module. It returns $true if the version matches, indicating the module is from the development branch, and $false otherwise. + +.PARAMETER None +This function does not accept any parameters. + +.OUTPUTS +System.Boolean +Returns $true if the Pode module version is '$version$', indicating the development branch. Returns $false for any other version. + +.EXAMPLE +PS> $moduleManifest = @{ ModuleVersion = '$version$' } +PS> Test-PodeVersionDev + +Returns $true, indicating the development branch. + +.EXAMPLE +PS> $moduleManifest = @{ ModuleVersion = '1.2.3' } +PS> Test-PodeVersionDev + +Returns $false, indicating a specific release version. + +.NOTES +This function assumes that $moduleManifest is a hashtable representing the loaded module manifest, with a key of ModuleVersion. + +#> +function Test-PodeVersionDev { + return (Get-PodeModuleManifest).ModuleVersion -eq '$version$' +} + + +<# +.SYNOPSIS +Tests if the current PowerShell version is considered End-of-Life (EOL). + +.DESCRIPTION +The Test-PodeVersionPwshEOL function checks if the PowerShell session is running on the Core edition and if the version is earlier than $moduleManifest.PrivateData.PwshCoreVersionUntested. If both conditions are met, it indicates that the PowerShell version is EOL. A warning message is displayed, noting that while Pode should still function, it has not been tested on EOL versions. + +.PARAMETER None +This function does not accept any parameters. + +.EXAMPLE +PS> Test-PodeVersionPwshEOL + +If running on PowerShell Core version earlier than $moduleManifest.PrivateData.PwshCoreVersionUntested, you will see a warning message indicating the version is EOL. + +#> +function Test-PodeVersionPwshEOL { + $moduleManifest = Get-PodeModuleManifest + if ($moduleManifest.ModuleVersion -ne '$version$') { + # Check if the PowerShell edition is Core and the version is earlier than the last version tested + if ($PSVersionTable.PSEdition -eq 'Core' -and $PSVersionTable.PSVersion -lt [version]$moduleManifest.PrivateData.PwshCoreVersionUntested) { + Write-Host "[WARNING] This PowerShell version $($PSVersionTable.PSVersion) was EOL when Pode $(Get-PodeVersion) was released. Pode should work but has not been tested." -ForegroundColor Yellow + return $true + } + } + return $false +} diff --git a/src/Private/Server.ps1 b/src/Private/Server.ps1 index ee2d8fefe..2bfbe12bc 100644 --- a/src/Private/Server.ps1 +++ b/src/Private/Server.ps1 @@ -141,11 +141,11 @@ function Start-PodeInternalServer { Invoke-PodeEvent -Type Running # Check if the running version of Powershell is EOL - $null = Test-PSVersionEOL + $null = Test-PodeVersionPwshEOL # state what endpoints are being listened on if ($endpoints.Length -gt 0) { - Write-PodeHost "Pode Web Framework $(Get-PodeVersion) (pid:$PID)" -ForegroundColor Yellow + Write-PodeHost "Pode $(Get-PodeVersion) (PID: $($PID))" -ForegroundColor Yellow Write-PodeHost "Listening on the following $($endpoints.Length) endpoint(s) [$($PodeContext.Threads.General) thread(s)]:" -ForegroundColor Yellow $endpoints | ForEach-Object { $flags = @() diff --git a/src/Private/Version.ps1 b/src/Private/Version.ps1 deleted file mode 100644 index daf589dfc..000000000 --- a/src/Private/Version.ps1 +++ /dev/null @@ -1,127 +0,0 @@ -<# -.SYNOPSIS -Retrieves the PowerShell module manifest object for the specified module. - -.DESCRIPTION -This function constructs the path to a PowerShell module manifest file (.psd1) located in the parent directory of the script root. It then imports the module manifest file to access its properties and returns the manifest object. This can be useful for scripts that need to dynamically discover and utilize module metadata, such as version, dependencies, and exported functions. - -.PARAMETERS -This function does not accept any parameters. - -.EXAMPLE -$manifest = Get-ModuleManifest -This example calls the `Get-ModuleManifest` function to retrieve the module manifest object and stores it in the variable `$manifest`. - -#> -function Get-ModuleManifest { - # Construct the path to the module manifest (.psd1 file) - $moduleManifestPath = Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -ChildPath 'Pode.psd1' - - # Import the module manifest to access its properties - $moduleManifest = Import-PowerShellDataFile -Path $moduleManifestPath - return $moduleManifest -} - - -<# -.SYNOPSIS -Gets the version of the Pode module. - -.DESCRIPTION -The Get-PodeVersion function checks the version of the Pode module specified in the module manifest. If the module version is not a placeholder value ('$version$'), it returns the actual version prefixed with 'v.'. If the module version is the placeholder value, indicating the development branch, it returns '[develop branch]'. - -.PARAMETER None -This function does not accept any parameters. - -.OUTPUTS -System.String -Returns a string indicating the version of the Pode module or '[develop branch]' if on a development version. - -.EXAMPLE -PS> $moduleManifest = @{ ModuleVersion = '1.2.3' } -PS> Get-PodeVersion - -Returns 'v.1.2.3'. - -.EXAMPLE -PS> $moduleManifest = @{ ModuleVersion = '$version$' } -PS> Get-PodeVersion - -Returns '[develop branch]'. - -.NOTES -This function assumes that $moduleManifest is a hashtable representing the loaded module manifest, with a key of ModuleVersion. - -#> -function Get-PodeVersion { - $moduleManifest = Get-ModuleManifest - if ($moduleManifest.ModuleVersion -ne '$version$') { - return "v.$($moduleManifest.ModuleVersion)" - } - else { - return '[develop branch]' - } -} - -<# -.SYNOPSIS -Tests if the Pode module is from the development branch. - -.DESCRIPTION -The Test-PodeDevelop function checks if the Pode module's version matches the placeholder value ('$version$'), which is used to indicate the development branch of the module. It returns $true if the version matches, indicating the module is from the development branch, and $false otherwise. - -.PARAMETER None -This function does not accept any parameters. - -.OUTPUTS -System.Boolean -Returns $true if the Pode module version is '$version$', indicating the development branch. Returns $false for any other version. - -.EXAMPLE -PS> $moduleManifest = @{ ModuleVersion = '$version$' } -PS> Test-PodeDevelop - -Returns $true, indicating the development branch. - -.EXAMPLE -PS> $moduleManifest = @{ ModuleVersion = '1.2.3' } -PS> Test-PodeDevelop - -Returns $false, indicating a specific release version. - -.NOTES -This function assumes that $moduleManifest is a hashtable representing the loaded module manifest, with a key of ModuleVersion. - -#> -function Test-PodeDevelop { - return (Get-ModuleManifest).ModuleVersion -eq '$version$' -} - - -<# -.SYNOPSIS -Tests if the current PowerShell version is considered End-of-Life (EOL). - -.DESCRIPTION -The Test-PSVersionEOL function checks if the PowerShell session is running on the Core edition and if the version is earlier than $moduleManifest.PrivateData.PwshCoreVersionUntested. If both conditions are met, it indicates that the PowerShell version is EOL. A warning message is displayed, noting that while Pode should still function, it has not been tested on EOL versions. - -.PARAMETER None -This function does not accept any parameters. - -.EXAMPLE -PS> Test-PSVersionEOL - -If running on PowerShell Core version earlier than $moduleManifest.PrivateData.PwshCoreVersionUntested, you will see a warning message indicating the version is EOL. - -#> -function Test-PSVersionEOL { - $moduleManifest = Get-ModuleManifest - if ($moduleManifest.ModuleVersion -ne '$version$') { - # Check if the PowerShell edition is Core and the version is earlier than the last version tested - if ($PSVersionTable.PSEdition -eq 'Core' -and $PSVersionTable.PSVersion -lt [version]$moduleManifest.PrivateData.PwshCoreVersionUntested) { - Write-Host "This PowerShell version $($PSVersionTable.PSVersion) was EOL when Pode $(Get-PodeVersion) was released. Pode should work but has not been tested." -ForegroundColor Yellow - return $true - } - } - return $false -} diff --git a/src/Public/Utilities.ps1 b/src/Public/Utilities.ps1 index 5ba286b9b..c7f291a1d 100644 --- a/src/Public/Utilities.ps1 +++ b/src/Public/Utilities.ps1 @@ -988,6 +988,7 @@ New-PodeCron -Every Quarter # every 1st #> function New-PodeCron { [CmdletBinding()] + [OutputType([String])] param( [Parameter()] [ValidateRange(0, 59)] @@ -1165,4 +1166,46 @@ function New-PodeCron { # build and return return "$($cron.Minute) $($cron.Hour) $($cron.Date) $($cron.Month) $($cron.Day)" +} + + + +<# +.SYNOPSIS +Gets the version of the Pode module. + +.DESCRIPTION +The Get-PodeVersion function checks the version of the Pode module specified in the module manifest. If the module version is not a placeholder value ('$version$'), it returns the actual version prefixed with 'v.'. If the module version is the placeholder value, indicating the development branch, it returns '[develop branch]'. + +.PARAMETER None +This function does not accept any parameters. + +.OUTPUTS +System.String +Returns a string indicating the version of the Pode module or '[develop branch]' if on a development version. + +.EXAMPLE +PS> $moduleManifest = @{ ModuleVersion = '1.2.3' } +PS> Get-PodeVersion + +Returns 'v.1.2.3'. + +.EXAMPLE +PS> $moduleManifest = @{ ModuleVersion = '$version$' } +PS> Get-PodeVersion + +Returns '[develop branch]'. + +.NOTES +This function assumes that $moduleManifest is a hashtable representing the loaded module manifest, with a key of ModuleVersion. + +#> +function Get-PodeVersion { + $moduleManifest = Get-PodeModuleManifest + if ($moduleManifest.ModuleVersion -ne '$version$') { + return "v$($moduleManifest.ModuleVersion)" + } + else { + return '[dev]' + } } \ No newline at end of file From 48db23039ccd88e26748f4ee1f00c5f709610c32 Mon Sep 17 00:00:00 2001 From: mdaneri Date: Fri, 5 Apr 2024 10:35:46 -0700 Subject: [PATCH 4/8] second --- pode.build.ps1 | 31 +++++++++------------ src/Pode.psd1 | 3 +- src/Private/Helpers.ps1 | 59 +++++++++++++++++++++++++++++++--------- src/Private/Version.ps1 | 0 src/Public/Utilities.ps1 | 6 ++-- 5 files changed, 64 insertions(+), 35 deletions(-) create mode 100644 src/Private/Version.ps1 diff --git a/pode.build.ps1 b/pode.build.ps1 index 25063da8e..99c7e8158 100644 --- a/pode.build.ps1 +++ b/pode.build.ps1 @@ -126,16 +126,11 @@ function Invoke-PodeBuildDotnetBuild($target ) { } -function Get-PodeBuildPwshEOL { - param( - [switch] $RecentCycle - ) +function Get-PodeBuildPwshEOL { $eol = invoke-restmethod -Uri 'https://endoflife.date/api/powershell.json' -Headers @{Accept = 'application/json' } - $expired = $eol.Where({ (get-date $_.eol) -lt (get-date) }) - if ($RecentCycle){ - return $expired[0].cycle - }else { - return $expired + return @{ + eol = ($eol | Where-Object { [datetime]$_.eol -lt [datetime]::Now }).cycle -join ',' + supported = ($eol | Where-Object { [datetime]$_.eol -ge [datetime]::Now }).cycle -join ',' } } @@ -145,8 +140,8 @@ function Get-PodeBuildPwshEOL { # Synopsis: Stamps the version onto the Module Task StampVersion { - $pwshCoreEndOfLife = Get-PodeBuildPwshEOL -RecentCycle - (Get-Content ./pkg/Pode.psd1) | ForEach-Object { $_ -replace '\$version\$', $Version -replace '\$versionUntested\$', $pwshCoreEndOfLife -replace '\$buildyear\$', ((get-date).Year) } | Set-Content ./pkg/Pode.psd1 + $pwshVersions = Get-PodeBuildPwshEOL + (Get-Content ./pkg/Pode.psd1) | ForEach-Object { $_ -replace '\$version\$', $Version -replace '\$versionUntested\$', $pwshVersions.eol -replace '\$versionSupported\$', $pwshVersions.supported -replace '\$buildyear\$', ((get-date).Year) } | Set-Content ./pkg/Pode.psd1 (Get-Content ./pkg/Pode.Internal.psd1) | ForEach-Object { $_ -replace '\$version\$', $Version } | Set-Content ./pkg/Pode.Internal.psd1 (Get-Content ./packers/choco/pode_template.nuspec) | ForEach-Object { $_ -replace '\$version\$', $Version } | Set-Content ./packers/choco/pode.nuspec (Get-Content ./packers/choco/tools/ChocolateyInstall_template.ps1) | ForEach-Object { $_ -replace '\$version\$', $Version } | Set-Content ./packers/choco/tools/ChocolateyInstall.ps1 @@ -443,13 +438,13 @@ Task DocsBuild DocsDeps, DocsHelpBuild, { } # Synopsis: Clean the build enviroment -Task Clean CleanPkg,CleanDeliverable,CleanLibs,CleanListener +Task Clean CleanPkg, CleanDeliverable, CleanLibs, CleanListener # Synopsis: Clean the Deliverable folder Task CleanDeliverable { $path = './deliverable' if (Test-Path -Path $path -PathType Container) { - Write-Host "Removing ./deliverable folder" + Write-Host 'Removing ./deliverable folder' Remove-Item -Path $path -Recurse -Force | Out-Null } Write-Host "Cleanup $path done" @@ -459,16 +454,16 @@ Task CleanDeliverable { Task CleanPkg { $path = './pkg' if ((Test-Path -Path $path -PathType Container )) { - Write-Host "Removing ./pkg folder" + Write-Host 'Removing ./pkg folder' Remove-Item -Path $path -Recurse -Force | Out-Null } if ((Test-Path -Path .\packers\choco\tools\ChocolateyInstall.ps1 -PathType Leaf )) { - Write-Host "Removing .\packers\choco\tools\ChocolateyInstall.ps1" + Write-Host 'Removing .\packers\choco\tools\ChocolateyInstall.ps1' Remove-Item -Path .\packers\choco\tools\ChocolateyInstall.ps1 } if ((Test-Path -Path .\packers\choco\pode.nuspec -PathType Leaf )) { - Write-Host "Removing .\packers\choco\pode.nuspec" + Write-Host 'Removing .\packers\choco\pode.nuspec' Remove-Item -Path .\packers\choco\pode.nuspec } Write-Host "Cleanup $path done" @@ -479,7 +474,7 @@ Task CleanLibs { $path = './src/Libs' if (Test-Path -Path $path -PathType Container) { Write-Host "Removing $path contents" - Remove-Item -Path $path -Recurse -Force | Out-Null + Remove-Item -Path $path -Recurse -Force | Out-Null } Write-Host "Cleanup $path done" } @@ -489,7 +484,7 @@ Task CleanListener { $path = './src/Listener/bin' if (Test-Path -Path $path -PathType Container) { Write-Host "Removing $path contents" - Remove-Item -Path $path -Recurse -Force | Out-Null + Remove-Item -Path $path -Recurse -Force | Out-Null } Write-Host "Cleanup $path done" } diff --git a/src/Pode.psd1 b/src/Pode.psd1 index 87b2fe8b1..13c34db44 100644 --- a/src/Pode.psd1 +++ b/src/Pode.psd1 @@ -481,6 +481,7 @@ ReleaseNotes = 'https://github.com/Badgerati/Pode/releases/tag/v$version$' } - PwshCoreVersionUntested = '$versionUntested$' + PwshVersionsUntested = '$versionUntested$' + PwshVersionSupported = '$versionSupported$' } } \ No newline at end of file diff --git a/src/Private/Helpers.ps1 b/src/Private/Helpers.ps1 index ec6b4f546..d9fce2bee 100644 --- a/src/Private/Helpers.ps1 +++ b/src/Private/Helpers.ps1 @@ -2961,31 +2961,64 @@ function Test-PodeVersionDev { return (Get-PodeModuleManifest).ModuleVersion -eq '$version$' } - <# .SYNOPSIS -Tests if the current PowerShell version is considered End-of-Life (EOL). +Tests the running PowerShell version for compatibility with Pode, identifying end-of-life (EOL) and untested versions. .DESCRIPTION -The Test-PodeVersionPwshEOL function checks if the PowerShell session is running on the Core edition and if the version is earlier than $moduleManifest.PrivateData.PwshCoreVersionUntested. If both conditions are met, it indicates that the PowerShell version is EOL. A warning message is displayed, noting that while Pode should still function, it has not been tested on EOL versions. +The `Test-PodeVersionPwshEOL` function checks the current PowerShell version against a list of versions that were either supported or EOL at the time of the Pode release. It uses the module manifest to determine which PowerShell versions are considered EOL and which are officially supported. If the current version is EOL or was not tested with the current release of Pode, the function generates a warning. This function aids in maintaining best practices for using supported PowerShell versions with Pode. -.PARAMETER None -This function does not accept any parameters. +.PARAMETER ReportUntested +If specified, the function will report if the current PowerShell version was not available and thus untested at the time of the Pode release. This is useful for identifying potential compatibility issues with newer versions of PowerShell. + +.OUTPUTS +A hashtable containing two keys: +- `eol`: A boolean indicating if the current PowerShell version was EOL at the time of the Pode release. +- `supported`: A boolean indicating if the current PowerShell version was officially supported by Pode at the time of the release. + +.EXAMPLE +Test-PodeVersionPwshEOL + +Checks the current PowerShell version against Pode's supported and EOL versions list. Outputs a warning if the version is EOL or untested, and returns a hashtable indicating the compatibility status. .EXAMPLE -PS> Test-PodeVersionPwshEOL +Test-PodeVersionPwshEOL -ReportUntested + +Similar to the basic usage, but also reports if the current PowerShell version was untested because it was not available at the time of the Pode release. -If running on PowerShell Core version earlier than $moduleManifest.PrivateData.PwshCoreVersionUntested, you will see a warning message indicating the version is EOL. +.NOTES +This function is part of the Pode module's utilities to ensure compatibility and encourage the use of supported PowerShell versions. #> function Test-PodeVersionPwshEOL { + param( + [switch] $ReportUntested + ) $moduleManifest = Get-PodeModuleManifest - if ($moduleManifest.ModuleVersion -ne '$version$') { - # Check if the PowerShell edition is Core and the version is earlier than the last version tested - if ($PSVersionTable.PSEdition -eq 'Core' -and $PSVersionTable.PSVersion -lt [version]$moduleManifest.PrivateData.PwshCoreVersionUntested) { - Write-Host "[WARNING] This PowerShell version $($PSVersionTable.PSVersion) was EOL when Pode $(Get-PodeVersion) was released. Pode should work but has not been tested." -ForegroundColor Yellow - return $true + if ($moduleManifest.ModuleVersion -eq '$version$') { + return @{ + eol = $false + supported = $true } } - return $false + + $psVersion = $PSVersionTable.PSVersion + $eolVersions = $moduleManifest.PrivateData.PwshVersionsUntested -split ',' + $isEol = "$($psVersion.Major).$($psVersion.Minor)" -in $eolVersions + + if ($isEol) { + Write-PodeHost "[WARNING] The running version of PowerShell $($PSVersionTable.PSVersion), was EOL when Pode $(Get-PodeVersion) was released. Pode should work but has not been tested on this version of PowerShell." -ForegroundColor Yellow + } + + $SupportedVersions = $moduleManifest.PrivateData.PwshVersionSupported -split ',' + $isSupported = "$($psVersion.Major).$($psVersion.Minor)" -in $SupportedVersions + + if (! $isSupported -and $ReportUntested) { + Write-PodeHost "[WARNING] The running version of PowerShell $($PSVersionTable.PSVersion), was not available when Pode $(Get-PodeVersion) was released. Pode should work but has not been tested on this version of PowerShell." -ForegroundColor Yellow + } + + return @{ + eol = $isEol + supported = $isSupported + } } diff --git a/src/Private/Version.ps1 b/src/Private/Version.ps1 new file mode 100644 index 000000000..e69de29bb diff --git a/src/Public/Utilities.ps1 b/src/Public/Utilities.ps1 index c7f291a1d..5b7f9395f 100644 --- a/src/Public/Utilities.ps1 +++ b/src/Public/Utilities.ps1 @@ -1182,19 +1182,19 @@ This function does not accept any parameters. .OUTPUTS System.String -Returns a string indicating the version of the Pode module or '[develop branch]' if on a development version. +Returns a string indicating the version of the Pode module or '[dev]' if on a development version. .EXAMPLE PS> $moduleManifest = @{ ModuleVersion = '1.2.3' } PS> Get-PodeVersion -Returns 'v.1.2.3'. +Returns 'v1.2.3'. .EXAMPLE PS> $moduleManifest = @{ ModuleVersion = '$version$' } PS> Get-PodeVersion -Returns '[develop branch]'. +Returns '[dev]'. .NOTES This function assumes that $moduleManifest is a hashtable representing the loaded module manifest, with a key of ModuleVersion. From a72b753459c243551e5c90f387033ca3ca4055cd Mon Sep 17 00:00:00 2001 From: mdaneri <17148649+mdaneri@users.noreply.github.com> Date: Fri, 5 Apr 2024 21:26:47 +0000 Subject: [PATCH 5/8] third --- pode.build.ps1 | 2 +- src/Pode.psd1 | 4 ++-- src/Private/Helpers.ps1 | 2 +- src/Private/Version.ps1 | 0 4 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 src/Private/Version.ps1 diff --git a/pode.build.ps1 b/pode.build.ps1 index 99c7e8158..9e9bc00c1 100644 --- a/pode.build.ps1 +++ b/pode.build.ps1 @@ -141,7 +141,7 @@ function Get-PodeBuildPwshEOL { # Synopsis: Stamps the version onto the Module Task StampVersion { $pwshVersions = Get-PodeBuildPwshEOL - (Get-Content ./pkg/Pode.psd1) | ForEach-Object { $_ -replace '\$version\$', $Version -replace '\$versionUntested\$', $pwshVersions.eol -replace '\$versionSupported\$', $pwshVersions.supported -replace '\$buildyear\$', ((get-date).Year) } | Set-Content ./pkg/Pode.psd1 + (Get-Content ./pkg/Pode.psd1) | ForEach-Object { $_ -replace '\$version\$', $Version -replace '\$versionsUntested\$', $pwshVersions.eol -replace '\$versionsSupported\$', $pwshVersions.supported -replace '\$buildyear\$', ((get-date).Year) } | Set-Content ./pkg/Pode.psd1 (Get-Content ./pkg/Pode.Internal.psd1) | ForEach-Object { $_ -replace '\$version\$', $Version } | Set-Content ./pkg/Pode.Internal.psd1 (Get-Content ./packers/choco/pode_template.nuspec) | ForEach-Object { $_ -replace '\$version\$', $Version } | Set-Content ./packers/choco/pode.nuspec (Get-Content ./packers/choco/tools/ChocolateyInstall_template.ps1) | ForEach-Object { $_ -replace '\$version\$', $Version } | Set-Content ./packers/choco/tools/ChocolateyInstall.ps1 diff --git a/src/Pode.psd1 b/src/Pode.psd1 index 13c34db44..0ae9c5923 100644 --- a/src/Pode.psd1 +++ b/src/Pode.psd1 @@ -481,7 +481,7 @@ ReleaseNotes = 'https://github.com/Badgerati/Pode/releases/tag/v$version$' } - PwshVersionsUntested = '$versionUntested$' - PwshVersionSupported = '$versionSupported$' + PwshVersionsUntested = '$versionsUntested$' + PwshVersionSupported = '$versionsSupported$' } } \ No newline at end of file diff --git a/src/Private/Helpers.ps1 b/src/Private/Helpers.ps1 index d9fce2bee..06132da2c 100644 --- a/src/Private/Helpers.ps1 +++ b/src/Private/Helpers.ps1 @@ -3013,7 +3013,7 @@ function Test-PodeVersionPwshEOL { $SupportedVersions = $moduleManifest.PrivateData.PwshVersionSupported -split ',' $isSupported = "$($psVersion.Major).$($psVersion.Minor)" -in $SupportedVersions - if (! $isSupported -and $ReportUntested) { + if ((! $isSupported) -and (! $isEol) -and $ReportUntested) { Write-PodeHost "[WARNING] The running version of PowerShell $($PSVersionTable.PSVersion), was not available when Pode $(Get-PodeVersion) was released. Pode should work but has not been tested on this version of PowerShell." -ForegroundColor Yellow } diff --git a/src/Private/Version.ps1 b/src/Private/Version.ps1 deleted file mode 100644 index e69de29bb..000000000 From eef1d2d71a04c03406176aec2eba8496b22facb8 Mon Sep 17 00:00:00 2001 From: mdaneri Date: Sat, 6 Apr 2024 00:28:12 -0700 Subject: [PATCH 6/8] third --- src/Pode.psd1 | 6 ++++-- src/Private/Helpers.ps1 | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Pode.psd1 b/src/Pode.psd1 index 0ae9c5923..eb92f99b5 100644 --- a/src/Pode.psd1 +++ b/src/Pode.psd1 @@ -481,7 +481,9 @@ ReleaseNotes = 'https://github.com/Badgerati/Pode/releases/tag/v$version$' } - PwshVersionsUntested = '$versionsUntested$' - PwshVersionSupported = '$versionsSupported$' + PwshVersions = @{ + Untested = '$versionsUntested$' + Supported = '$versionsSupported$' + } } } \ No newline at end of file diff --git a/src/Private/Helpers.ps1 b/src/Private/Helpers.ps1 index 06132da2c..e03814988 100644 --- a/src/Private/Helpers.ps1 +++ b/src/Private/Helpers.ps1 @@ -3003,14 +3003,14 @@ function Test-PodeVersionPwshEOL { } $psVersion = $PSVersionTable.PSVersion - $eolVersions = $moduleManifest.PrivateData.PwshVersionsUntested -split ',' + $eolVersions = $moduleManifest.PrivateData.PwshVersions.Untested -split ',' $isEol = "$($psVersion.Major).$($psVersion.Minor)" -in $eolVersions if ($isEol) { Write-PodeHost "[WARNING] The running version of PowerShell $($PSVersionTable.PSVersion), was EOL when Pode $(Get-PodeVersion) was released. Pode should work but has not been tested on this version of PowerShell." -ForegroundColor Yellow } - $SupportedVersions = $moduleManifest.PrivateData.PwshVersionSupported -split ',' + $SupportedVersions = $moduleManifest.PrivateData.PwshVersion.Supported -split ',' $isSupported = "$($psVersion.Major).$($psVersion.Minor)" -in $SupportedVersions if ((! $isSupported) -and (! $isEol) -and $ReportUntested) { From 448edc702ca7e37e5af77b124387bd1a709eb0aa Mon Sep 17 00:00:00 2001 From: mdaneri <17148649+mdaneri@users.noreply.github.com> Date: Sun, 7 Apr 2024 09:02:39 +0000 Subject: [PATCH 7/8] forth review --- src/Private/Helpers.ps1 | 6 +++--- src/Private/Server.ps1 | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Private/Helpers.ps1 b/src/Private/Helpers.ps1 index 8def263b8..7deb3edbc 100644 --- a/src/Private/Helpers.ps1 +++ b/src/Private/Helpers.ps1 @@ -3044,14 +3044,14 @@ function Test-PodeVersionPwshEOL { $isEol = "$($psVersion.Major).$($psVersion.Minor)" -in $eolVersions if ($isEol) { - Write-PodeHost "[WARNING] The running version of PowerShell $($PSVersionTable.PSVersion), was EOL when Pode $(Get-PodeVersion) was released. Pode should work but has not been tested on this version of PowerShell." -ForegroundColor Yellow + Write-PodeHost "[WARNING] Pode $(Get-PodeVersion) has not been tested on PowerShell $($PSVersionTable.PSVersion), as it is EOL." -ForegroundColor Yellow } - $SupportedVersions = $moduleManifest.PrivateData.PwshVersion.Supported -split ',' + $SupportedVersions = $moduleManifest.PrivateData.PwshVersions.Supported -split ',' $isSupported = "$($psVersion.Major).$($psVersion.Minor)" -in $SupportedVersions if ((! $isSupported) -and (! $isEol) -and $ReportUntested) { - Write-PodeHost "[WARNING] The running version of PowerShell $($PSVersionTable.PSVersion), was not available when Pode $(Get-PodeVersion) was released. Pode should work but has not been tested on this version of PowerShell." -ForegroundColor Yellow + Write-PodeHost "[WARNING] Pode $(Get-PodeVersion) has not been tested on PowerShell $($PSVersionTable.PSVersion), as it was not available when Pode was released." -ForegroundColor Yellow } return @{ diff --git a/src/Private/Server.ps1 b/src/Private/Server.ps1 index 2bfbe12bc..3627c734a 100644 --- a/src/Private/Server.ps1 +++ b/src/Private/Server.ps1 @@ -8,6 +8,10 @@ function Start-PodeInternalServer { ) try { + # Check if the running version of Powershell is EOL + Write-PodeHost "Pode $(Get-PodeVersion) (PID: $($PID))" -ForegroundColor Cyan + $null = Test-PodeVersionPwshEOL -ReportUntested + # setup temp drives for internal dirs Add-PodePSInbuiltDrives @@ -140,12 +144,8 @@ function Start-PodeInternalServer { # run running event hooks Invoke-PodeEvent -Type Running - # Check if the running version of Powershell is EOL - $null = Test-PodeVersionPwshEOL - # state what endpoints are being listened on if ($endpoints.Length -gt 0) { - Write-PodeHost "Pode $(Get-PodeVersion) (PID: $($PID))" -ForegroundColor Yellow Write-PodeHost "Listening on the following $($endpoints.Length) endpoint(s) [$($PodeContext.Threads.General) thread(s)]:" -ForegroundColor Yellow $endpoints | ForEach-Object { $flags = @() From 58dd0adc9c78268506a372cd6093f91e0f2359ef Mon Sep 17 00:00:00 2001 From: mdaneri <17148649+mdaneri@users.noreply.github.com> Date: Sun, 7 Apr 2024 19:33:48 +0000 Subject: [PATCH 8/8] final drop --- docs/{ => Getting-Started}/pwshsupportpolicy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename docs/{ => Getting-Started}/pwshsupportpolicy.md (98%) diff --git a/docs/pwshsupportpolicy.md b/docs/Getting-Started/pwshsupportpolicy.md similarity index 98% rename from docs/pwshsupportpolicy.md rename to docs/Getting-Started/pwshsupportpolicy.md index 6ff727173..d2060cbe0 100644 --- a/docs/pwshsupportpolicy.md +++ b/docs/Getting-Started/pwshsupportpolicy.md @@ -1,4 +1,4 @@ -# Pode PowerShell Version Support Policy +# PowerShell Support Policy ## Overview This document details the support policy for PowerShell versions as they relate to Pode releases. Our aim is to provide clarity on which versions of PowerShell are supported by each release of Pode, ensuring a secure, efficient, and compatible development environment.