From 002921c645ed505e2c1f3eecb9da044b91cbf30a Mon Sep 17 00:00:00 2001 From: Romain <96626929+Romanitho@users.noreply.github.com> Date: Sun, 27 Mar 2022 12:20:33 +0200 Subject: [PATCH] minor changes --- Winget-AutoUpdate/config/about.xml | 2 +- .../functions/Get-WAUUpdateStatus.ps1 | 6 +++--- Winget-AutoUpdate/functions/Update-WAU.ps1 | 17 ++++++++--------- Winget-AutoUpdate/winget-upgrade.ps1 | 8 ++++---- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Winget-AutoUpdate/config/about.xml b/Winget-AutoUpdate/config/about.xml index 93c99de..09ebf9e 100644 --- a/Winget-AutoUpdate/config/about.xml +++ b/Winget-AutoUpdate/config/about.xml @@ -1,7 +1,7 @@ Winget-AutoUpdate (WAU) - 1.6.2 + 1.6.3 Romanitho https://github.com/Romanitho/Winget-AutoUpdate diff --git a/Winget-AutoUpdate/functions/Get-WAUUpdateStatus.ps1 b/Winget-AutoUpdate/functions/Get-WAUUpdateStatus.ps1 index e18dfe1..57772b7 100644 --- a/Winget-AutoUpdate/functions/Get-WAUUpdateStatus.ps1 +++ b/Winget-AutoUpdate/functions/Get-WAUUpdateStatus.ps1 @@ -4,12 +4,12 @@ function Get-WAUUpdateStatus{ #Check if AutoUpdate is enabled if ($true -eq [System.Convert]::ToBoolean($UpdateStatus.app.WAUautoupdate)){ - Write-Log "WAU AutoUpdate is enabled" "Green" + Write-Log "WAU AutoUpdate is Enabled. Current version : $WAUCurrentVersion" "Green" $Script:WAUautoupdate = $true #Check if pre-release versions are enabled if ($true -eq [System.Convert]::ToBoolean($UpdateStatus.app.WAUprerelease)){ - Write-Log "WAU AutoUpdate Pre-release enabled" "Cyan" + Write-Log "WAU AutoUpdate Pre-release versions is Enabled" "Cyan" $Script:WAUprerelease = $true } else{ @@ -17,7 +17,7 @@ function Get-WAUUpdateStatus{ } } else{ - Write-Log "WAU AutoUpdate is Disabled" "Grey" + Write-Log "WAU AutoUpdate is Disabled. Current version : $WAUCurrentVersion" "Grey" $Script:WAUautoupdate = $false } } \ No newline at end of file diff --git a/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Winget-AutoUpdate/functions/Update-WAU.ps1 index 87edde1..d225929 100644 --- a/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -14,33 +14,32 @@ function Update-WAU { New-Item $ZipFile -ItemType File -Force | Out-Null #Download the zip - Write-Log "Starting downloading the GitHub Repository version $WAUAvailableVersion" + Write-Log "Downloading the GitHub Repository version $WAUAvailableVersion" "Cyan" Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/archive/refs/tags/v$($WAUAvailableVersion).zip/" -OutFile $ZipFile - Write-Log "Download finished" "Green" #Extract Zip File - Write-Log "Starting unzipping the WAU GitHub Repository" + Write-Log "Unzipping the WAU GitHub Repository" "Cyan" $location = "$WorkingDir\WAU_update" Expand-Archive -Path $ZipFile -DestinationPath $location -Force Get-ChildItem -Path $location -Recurse | Unblock-File - Write-Log "Unzip finished" "Green" + Write-Log "Updating WAU" "Yellow" $TempPath = (Resolve-Path "$location\*\Winget-AutoUpdate\")[0].Path if ($TempPath){ Copy-Item -Path "$TempPath\*" -Destination "$WorkingDir\" -Exclude "icons" -Recurse -Force } - #Remove update zip file - Write-Log "Cleaning temp files" + #Remove update zip file and update temp folder + Write-Log "Done. Cleaning temp files" "Cyan" Remove-Item -Path $ZipFile -Force -ErrorAction SilentlyContinue - #Remove update folder Remove-Item -Path $location -Recurse -Force -ErrorAction SilentlyContinue - #Set new version to about.xml + #Set new version to 'about.xml' [xml]$XMLconf = Get-content "$WorkingDir\config\about.xml" -Encoding UTF8 -ErrorAction SilentlyContinue $XMLconf.app.version = $WAUAvailableVersion $XMLconf.Save("$WorkingDir\config\about.xml") #Send success Notif + Write-Log "WAU Update completed." "Green" $Title = $NotifLocale.local.outputs.output[3].title -f "Winget-AutoUpdate" $Message = $NotifLocale.local.outputs.output[3].message -f $WAUAvailableVersion $MessageType = "success" @@ -59,6 +58,6 @@ function Update-WAU { $MessageType = "error" $Balise = "Winget-AutoUpdate" Start-NotifTask $Title $Message $MessageType $Balise - Write-Log "WAU Update failed" + Write-Log "WAU Update failed" "Red" } } diff --git a/Winget-AutoUpdate/winget-upgrade.ps1 b/Winget-AutoUpdate/winget-upgrade.ps1 index fb2e98c..f526a31 100644 --- a/Winget-AutoUpdate/winget-upgrade.ps1 +++ b/Winget-AutoUpdate/winget-upgrade.ps1 @@ -25,13 +25,13 @@ if (Test-Network){ #Get Available Version Get-WAUAvailableVersion #Compare - if ($WAUAvailableVersion -gt $WAUCurrentVersion){ + if ([version]$WAUAvailableVersion -gt [version]$WAUCurrentVersion){ #If new version is available, update it - Write-Log "WAU Current version: $WAUCurrentVersion - Available version: $WAUAvailableVersion" "Yellow" + Write-Log "WAU Available version: $WAUAvailableVersion" "Yellow" Update-WAU } else{ - Write-Log "WAU Current version : $WAUCurrentVersion - Up to date." "Green" + Write-Log "WAU is up to date." "Green" } } @@ -39,7 +39,7 @@ if (Test-Network){ $toSkip = Get-ExcludedApps #Get outdated Winget packages - Write-Log "Checking available updates..." "yellow" + Write-Log "Checking application updates on Winget Repository..." "yellow" $outdated = Get-WingetOutdatedApps #Log list of app to update