diff --git a/Changelog.md b/Changelog.md index 3a10fa8..0777ff6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,14 @@ # Changelog for WingetTools +## v1.0.0 + ++ Fixed bug with `Get-WGUpgrade` that had bad formatting when running the command either first thing in the day, or when some sort of caching was getting cleared. ++ Added command `Test-WGVersion` and format file `wgversion.format.ps1xml`. ++ Updated `Get-WGReleaseNote` to include the online link. ++ Modified the object typename for `Get-WGReleaseNote` to align it with other object names in this module. __*This is a breaking change.*__ ++ Updated help documentation. ++ Updated `README.md`. + ## v0.7.0 + Added `Get-WGUpgrade` and `Invoke-WGUpgrade`. diff --git a/README.md b/README.md index 89ab8f7..78e70f3 100644 --- a/README.md +++ b/README.md @@ -81,15 +81,9 @@ Available : 0.51.1 ![install upgrade](images/install-upgrade.png) -There is a known issue that when you run `Get-WGUpgrade` on a new day, there is extra garbage in the output. - -![get-wgupgrade bug](images/get-wgupgrade-bug.png) - -This is under investigation. - ## [Invoke-WGUpgrade](docs/Invoke-WGUpgrade.md) -Invoke-WGUpgrade will run the winget upgrade process using silent installation and accepting all licenses and agreements. It supports `-Whatif`. +`Invoke-WGUpgrade` will run the winget upgrade process using silent installation and accepting all licenses and agreements. It supports `-Whatif`. ```dos PS C:\> Get-WGUpgrade -Name p* | Invoke-WGUpgrade -WhatIf @@ -99,6 +93,27 @@ What if: Performing the operation "Upgrade from 0.47.0 to 0.51.1" on target "Mic Be aware, that winget may still have a problem running the upgrade due to issues isolating upgrade packages. +## [Test-WGVersion](docs/Test-WGVersion.md) + +The test command is an easy way to determine if an update for winget itself is available from Github. + +```dos +PS C:\> Test-WGVersion + +Installed Online Update Command +--------- ------ ------ ------- +1.1.13405 1.1.12653 False C:\Users\Jeff\AppData\Local\Microsoft\Windo… +``` + +If an update is available and you are running the command in the PowerShell console or VSCode, the `Update` value will be displayed in green. + +You can use the `-Quiet` parameter to return a Boolean result. + +```dos +PS C:\> Test-WGVersion -Quiet +False +``` + ## Issues If there are problems with commands in this module, try running the winget command directly. Report problems to the module's Github repository at . diff --git a/WingetTools.psd1 b/WingetTools.psd1 index c33638a..c8267f5 100644 --- a/WingetTools.psd1 +++ b/WingetTools.psd1 @@ -5,7 +5,7 @@ @{ RootModule = 'WingetTools.psm1' - ModuleVersion = '0.7.0' + ModuleVersion = '1.0.0' CompatiblePSEditions = @('Desktop', 'Core') GUID = '1130bb85-58d1-487d-9763-c38011f9613d' Author = 'Jeff Hicks' @@ -17,9 +17,13 @@ # Type files (.ps1xml) to be loaded when importing this module # TypesToProcess = @() - FormatsToProcess = @('formats\wgpackage.format.ps1xml', 'formats\wingetupgrade.format.ps1xml') - FunctionsToExport = 'Get-WGPackage', 'Install-Winget', 'Get-WGReleaseNote', 'Get-WGInstalled', - 'Invoke-WGUpgrade', 'Get-WGUpgrade' + FormatsToProcess = @( + 'formats\wgpackage.format.ps1xml', + 'formats\wgversion.format.ps1xml', + 'formats\wingetupgrade.format.ps1xml' + ) + FunctionsToExport = 'Get-WGPackage', 'Install-Winget', 'Get-WGReleaseNote', + 'Get-WGInstalled','Invoke-WGUpgrade', 'Get-WGUpgrade','Test-WGVersion' AliasesToExport = 'wglatest', 'iwg' PrivateData = @{ diff --git a/docs/Get-WGReleaseNote.md b/docs/Get-WGReleaseNote.md index 6f53d05..7364cae 100644 --- a/docs/Get-WGReleaseNote.md +++ b/docs/Get-WGReleaseNote.md @@ -44,6 +44,7 @@ Notes : This release represents our Windows Package Manager 1.release #797 Silent install of "winget install git.git" is not working #1497 Make rename retry more frequently for longer, then try making a hardlink +Link : https://github.com/microsoft/winget-cli/releases/tag/v1.1.12653 ``` The default output. @@ -151,7 +152,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### System.String -### ReleaseNote +### WGReleaseNote ## NOTES @@ -160,3 +161,5 @@ Learn more about PowerShell: http://jdhitsolutions.com/blog/essential-powershell ## RELATED LINKS [Install-WinGet](Install-WinGet.md) + +[Test-WGVersion](Test-WGVersion.md) diff --git a/docs/Invoke-WGUpgrade.md b/docs/Invoke-WGUpgrade.md index c89c778..d6c0591 100644 --- a/docs/Invoke-WGUpgrade.md +++ b/docs/Invoke-WGUpgrade.md @@ -63,6 +63,14 @@ What if: Performing the operation "Upgrade from 0.47.0 to 0.51.1" on target "Mic You can pipe output from Get-WGUpgrade to this command. +### Example 3 + +```powershell +PS C:\> Get-WGUpgrade | Out-GridView -OutputMode Multiple | Invoke-WGUpgrade +``` + +Pipe the list of available upgrades to Out-Gridview where you can select items. Invoke-WGUpgrade will then install the selected upgrades. + ## PARAMETERS ### -Confirm diff --git a/docs/Test-WGVersion.md b/docs/Test-WGVersion.md new file mode 100644 index 0000000..f9e2350 --- /dev/null +++ b/docs/Test-WGVersion.md @@ -0,0 +1,83 @@ +--- +external help file: WingetTools-help.xml +Module Name: WingetTools +online version: +schema: 2.0.0 +--- + +# Test-WGVersion + +## SYNOPSIS + +Test Winget version + +## SYNTAX + +```yaml +Test-WGVersion [-Quiet] [] +``` + +## DESCRIPTION + +Test-WGVersion is a simple command you use to discover if you need to update winget. + +## EXAMPLES + +### Example 1 + +```powershell +PS C:\> Test-WGVersion + +Installed Online Update Command +--------- ------ ------ ------- +1.1.13405 1.1.12653 False C:\Users\Jeff\AppData\Local\Microsoft\Windo… +``` + +The default output is an object showing the currently installed version and the latest stable version online. If an update is available, and you are running in the PowerShell console or VS Code, the Update value will be displayed in Green. + +### Example 2 + +```powershell +PS C:\> Test-WGVersion -Quiet +False +``` + +Run the test and get a simple, Boolean result indicating if an update is available. + +## PARAMETERS + +### -Quiet + +Get a Boolean result indicating if an update is available. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### CommonParameters + +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.Management.Automation.SwitchParameter + +## OUTPUTS + +### Boolean + +### WGVersion + +## NOTES + +## RELATED LINKS + +[Get-WGReleaseNote](Get-WGReleaseNote.md) diff --git a/en-US/WingetTools-help.xml b/en-US/WingetTools-help.xml index c95cf8d..0e13e59 100644 --- a/en-US/WingetTools-help.xml +++ b/en-US/WingetTools-help.xml @@ -477,7 +477,7 @@ DAX Studio DaxStudio.DaxStudio 2.16.2.632 - ReleaseNote + WGReleaseNote @@ -509,7 +509,8 @@ Notes : This release represents our Windows Package Manager 1.release # Bugs #797 Silent install of "winget install git.git" is not working #1497 Make rename retry more frequently for longer, then try - making a hardlink + making a hardlink +Link : https://github.com/microsoft/winget-cli/releases/tag/v1.1.12653 The default output. @@ -562,6 +563,10 @@ Notes : This release is the first development build after the Windows Install-WinGet + + Test-WGVersion + + @@ -1059,6 +1064,13 @@ What if: Performing the operation "Upgrade from 0.47.0 to 0.51.1" on target "Mic You can pipe output from Get-WGUpgrade to this command. + + -------------------------- Example 3 -------------------------- + PS C:\> Get-WGUpgrade | Out-GridView -OutputMode Multiple | Invoke-WGUpgrade + + Pipe the list of available upgrades to Out-Gridview where you can select items. Invoke-WGUpgrade will then install the selected upgrades. + + @@ -1067,4 +1079,107 @@ What if: Performing the operation "Upgrade from 0.47.0 to 0.51.1" on target "Mic + + + Test-WGVersion + Test + WGVersion + + Test Winget version + + + + Test-WGVersion is a simple command you use to discover if you need to update winget. + + + + Test-WGVersion + + Quiet + + Get a Boolean result indicating if an update is available. + + + SwitchParameter + + + False + + + + + + Quiet + + Get a Boolean result indicating if an update is available. + + SwitchParameter + + SwitchParameter + + + False + + + + + + System.Management.Automation.SwitchParameter + + + + + + + + + + Boolean + + + + + + + + WGVersion + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> Test-WGVersion + +Installed Online Update Command +--------- ------ ------ ------- +1.1.13405 1.1.12653 False C:\Users\Jeff\AppData\Local\Microsoft\Windo… + + The default output is an object showing the currently installed version and the latest stable version online. If an update is available, and you are running in the PowerShell console or VS Code, the Update value will be displayed in Green. + + + + -------------------------- Example 2 -------------------------- + PS C:\> Test-WGVersion -Quiet +False + + Run the test and get a simple, Boolean result indicating if an update is available. + + + + + + Get-WGReleaseNote + + + + \ No newline at end of file diff --git a/formats/wgversion.format.ps1xml b/formats/wgversion.format.ps1xml new file mode 100644 index 0000000..664076b --- /dev/null +++ b/formats/wgversion.format.ps1xml @@ -0,0 +1,75 @@ + + + + + + default + + WGVersion + + + + + + + 12 + left + + + + 12 + left + + + + 9 + left + + + + 63 + left + + + + + + + + Installed + + + Online + + + + if ($host.name -match "console|vscode" -AND ($_.Update)) { + + "$([char]27)[92m$($_.Update)$([char]27)[0m" + } + else { + $_.Update + } + + + + Command + + + + + + + + \ No newline at end of file diff --git a/functions/Get-WGReleaseNote.ps1 b/functions/Get-WGReleaseNote.ps1 index 406eaa5..4f7fe43 100644 --- a/functions/Get-WGReleaseNote.ps1 +++ b/functions/Get-WGReleaseNote.ps1 @@ -2,7 +2,7 @@ Function Get-WGReleaseNote { [CmdletBinding()] [alias("wglatest")] [outputtype([System.String])] - [outputtype("ReleaseNote")] + [outputtype("WGReleaseNote")] Param( [Parameter(HelpMessage = "Create a markdown document.")] [alias("md")] @@ -18,21 +18,20 @@ Function Get-WGReleaseNote { Try { Write-Verbose "[$((Get-Date).TimeofDay)] Getting information from $uri" - $get = Invoke-RestMethod -uri $uri -Method Get -ErrorAction stop + $get = Invoke-RestMethod -Uri $uri -Method Get -ErrorAction stop if ($Preview) { Write-Verbose "[$((Get-Date).TimeofDay)] Getting latest preview release" - $data = $get | Where-Object {$_.PreRelease} | Select-Object -first 1 + $data = $get | Where-Object { $_.PreRelease } | Select-Object -First 1 } else { Write-Verbose "[$((Get-Date).TimeofDay)] Getting latest stable release" - $data = $get | Where-Object {-not $_.PreRelease} | Select-Object -first 1 - + $data = $get | Where-Object { -not $_.PreRelease } | Select-Object -First 1 } $data | Select-Object -Property Name, tag_name, published_at, prerelease, - @{Name = "bodyLength"; Expression = {$_.body.length}} | Out-String | Write-Verbose + @{Name = "bodyLength"; Expression = { $_.body.length } } | Out-String | Write-Verbose if ($online) { Write-Verbose "[$((Get-Date).TimeofDay)] Opening $($data.html_url) in your web browser." @@ -62,12 +61,13 @@ $($data.body.trim()) Write-Verbose "[$((Get-Date).TimeofDay)] Creating ReleaseNote" [pscustomobject]@{ - PSTypename = "ReleaseNote" + PSTypename = "WGReleaseNote" Name = $data.name Version = $data.tag_name Published = $($data.published_at -as [datetime]) - Prerelease = If ($data.prerelease -eq 'true') {$True} else {$false} + Prerelease = If ($data.prerelease -eq 'true') { $True } else { $false } Notes = $data.body.trim() + Link = $data.html_url } } } #try diff --git a/functions/Get-WingetUpgrade.ps1 b/functions/Get-WingetUpgrade.ps1 index 1234df1..e41e31a 100644 --- a/functions/Get-WingetUpgrade.ps1 +++ b/functions/Get-WingetUpgrade.ps1 @@ -14,7 +14,7 @@ Function Get-WGUpgrade { Write-Verbose "Starting $($MyInvocation.MyCommand)" #create a list to hold the results $list = [System.Collections.Generic.list[object]]::New() - $up = (winget upgrade).trim() | Where-Object { $_ -match "\d+\.\d+" } + $up = (winget upgrade).trim() | Where-Object { $_ -match "\d+\.\d+\s(?!MB)" } Write-Verbose "Found $($up.count) available upgrades" diff --git a/functions/Test-WGVersion.ps1 b/functions/Test-WGVersion.ps1 new file mode 100644 index 0000000..3d02e90 --- /dev/null +++ b/functions/Test-WGVersion.ps1 @@ -0,0 +1,43 @@ + + +Function Test-WGVersion { + [cmdletbinding()] + [OutputType("Boolean", "WGVersion")] + Param( + [Parameter(ValueFromPipeline)] + [switch]$Quiet + ) + Begin { + Write-Verbose "[$((Get-Date).TimeofDay) BEGIN ] Starting $($myinvocation.mycommand)" + } #begin + + Process { + #not using Get-Appx package because it doesn't work in older versions of PowerShell 7 + [version]$local = (winget --version).replace("v", "") + Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Found installed version $local" + $note = Get-WGReleaseNote + [version]$remote = $note.version.replace("v", "") + + if ($quiet) { + Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Getting boolean result" + $remote -gt $local + } + else { + Write-Verbose "[$((Get-Date).TimeofDay) PROCESS] Getting full result" + [PSCustomObject]@{ + PSTypeName = "WGVersion" + Installed = $local + Online = $remote + Update = $remote -gt $local + Command = (Get-Command winget).source + Link = $note.link + } + } + + } #process + + End { + Write-Verbose "[$((Get-Date).TimeofDay) END ] Ending $($myinvocation.mycommand)" + } #end + +} #close Test-WGVersion \ No newline at end of file