Fix minor issues
parent
8db80b0c1c
commit
838cc42c99
|
@ -8,6 +8,5 @@ function Get-WAUAvailableVersion {
|
||||||
#Get latest stable info
|
#Get latest stable info
|
||||||
$WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest'
|
$WAUurl = 'https://api.github.com/repos/Romanitho/Winget-AutoUpdate/releases/latest'
|
||||||
}
|
}
|
||||||
$Script:WAULatestVersion = ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v","")
|
$Script:WAUAvailableVersion = ((Invoke-WebRequest $WAUurl -UseBasicParsing | ConvertFrom-Json)[0].tag_name).Replace("v","")
|
||||||
return [version]$WAULatestVersion
|
|
||||||
}
|
}
|
|
@ -2,5 +2,5 @@ function Get-WAUCurrentVersion{
|
||||||
#Get current installed version
|
#Get current installed version
|
||||||
[xml]$About = Get-Content "$WorkingDir\config\about.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
|
[xml]$About = Get-Content "$WorkingDir\config\about.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
|
||||||
$Script:WAUCurrentVersion = $About.app.version
|
$Script:WAUCurrentVersion = $About.app.version
|
||||||
return [version]$WAUCurrentVersion
|
Write-Log "WAU Current version : $WAUCurrentVersion"
|
||||||
}
|
}
|
|
@ -3,12 +3,12 @@ function Get-WAUUpdateStatus{
|
||||||
[xml]$UpdateStatus = Get-Content "$WorkingDir\config\config.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
|
[xml]$UpdateStatus = Get-Content "$WorkingDir\config\config.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
#Check if AutoUpdate is enabled
|
#Check if AutoUpdate is enabled
|
||||||
if ($true -eq $UpdateStatus.app.WAUautoupdate){
|
if ($true -eq [System.Convert]::ToBoolean($UpdateStatus.app.WAUautoupdate)){
|
||||||
Write-Log "WAU AutoUpdate is Enabled" "Green"
|
Write-Log "WAU AutoUpdate is enabled" "Green"
|
||||||
$Script:WAUautoupdate = $true
|
$Script:WAUautoupdate = $true
|
||||||
|
|
||||||
#Check if pre-release versions are enabled
|
#Check if pre-release versions are enabled
|
||||||
if ($true -eq $UpdateStatus.app.WAUprerelease){
|
if ($true -eq [System.Convert]::ToBoolean($UpdateStatus.app.WAUprerelease)){
|
||||||
Write-Log "WAU AutoUpdate Pre-release enabled" "Cyan"
|
Write-Log "WAU AutoUpdate Pre-release enabled" "Cyan"
|
||||||
$Script:WAUprerelease = $true
|
$Script:WAUprerelease = $true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
function Update-WAU ($VersionToUpdate){
|
function Update-WAU {
|
||||||
#Send available update notification
|
#Send available update notification
|
||||||
$Title = $NotifLocale.local.outputs.output[2].title -f "Winget-AutoUpdate"
|
$Title = $NotifLocale.local.outputs.output[2].title -f "Winget-AutoUpdate"
|
||||||
$Message = $NotifLocale.local.outputs.output[2].message -f $CurrentVersion, $LatestVersion.Replace("v","")
|
$Message = $NotifLocale.local.outputs.output[2].message -f $WAUCurrentVersion, $WAUAvailableVersion
|
||||||
$MessageType = "info"
|
$MessageType = "info"
|
||||||
$Balise = "Winget-AutoUpdate"
|
$Balise = "Winget-AutoUpdate"
|
||||||
Start-NotifTask $Title $Message $MessageType $Balise
|
Start-NotifTask $Title $Message $MessageType $Balise
|
||||||
|
@ -14,8 +14,8 @@ function Update-WAU ($VersionToUpdate){
|
||||||
New-Item $ZipFile -ItemType File -Force | Out-Null
|
New-Item $ZipFile -ItemType File -Force | Out-Null
|
||||||
|
|
||||||
#Download the zip
|
#Download the zip
|
||||||
Write-Log "Starting downloading the GitHub Repository version $VersionToUpdate"
|
Write-Log "Starting downloading the GitHub Repository version $WAUAvailableVersion"
|
||||||
Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/archive/refs/tags/v$($VersionToUpdate).zip/" -OutFile $ZipFile
|
Invoke-RestMethod -Uri "https://github.com/Romanitho/Winget-AutoUpdate/archive/refs/tags/v$($WAUAvailableVersion).zip/" -OutFile $ZipFile
|
||||||
Write-Log "Download finished" "Green"
|
Write-Log "Download finished" "Green"
|
||||||
|
|
||||||
#Extract Zip File
|
#Extract Zip File
|
||||||
|
@ -37,12 +37,12 @@ function Update-WAU ($VersionToUpdate){
|
||||||
|
|
||||||
#Set new version to about.xml
|
#Set new version to about.xml
|
||||||
[xml]$XMLconf = Get-content "$WorkingDir\config\about.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
|
[xml]$XMLconf = Get-content "$WorkingDir\config\about.xml" -Encoding UTF8 -ErrorAction SilentlyContinue
|
||||||
$XMLconf.app.version = $VersionToUpdate
|
$XMLconf.app.version = $WAUAvailableVersion
|
||||||
$XMLconf.Save("$WorkingDir\config\about.xml")
|
$XMLconf.Save("$WorkingDir\config\about.xml")
|
||||||
|
|
||||||
#Send success Notif
|
#Send success Notif
|
||||||
$Title = $NotifLocale.local.outputs.output[3].title -f "Winget-AutoUpdate"
|
$Title = $NotifLocale.local.outputs.output[3].title -f "Winget-AutoUpdate"
|
||||||
$Message = $NotifLocale.local.outputs.output[3].message -f $LatestVersion
|
$Message = $NotifLocale.local.outputs.output[3].message -f $WAUAvailableVersion
|
||||||
$MessageType = "success"
|
$MessageType = "success"
|
||||||
$Balise = "Winget-AutoUpdate"
|
$Balise = "Winget-AutoUpdate"
|
||||||
Start-NotifTask $Title $Message $MessageType $Balise
|
Start-NotifTask $Title $Message $MessageType $Balise
|
||||||
|
|
|
@ -16,18 +16,18 @@ Get-NotifLocale
|
||||||
|
|
||||||
#Check network connectivity
|
#Check network connectivity
|
||||||
if (Test-Network){
|
if (Test-Network){
|
||||||
|
#Get Current Version
|
||||||
|
Get-WAUCurrentVersion
|
||||||
#Check if WAU update feature is enabled
|
#Check if WAU update feature is enabled
|
||||||
Get-WAUUpdateStatus
|
Get-WAUUpdateStatus
|
||||||
#If yes then check WAU update
|
#If yes then check WAU update
|
||||||
if ($true -eq $WAUautoupdate){
|
if ($true -eq $WAUautoupdate){
|
||||||
#Get Current Version
|
|
||||||
$WAUCurrentVersion = Get-WAUCurrentVersion
|
|
||||||
#Get Available Version
|
#Get Available Version
|
||||||
$WAUAvailableVersion = Get-WAUAvailableVersion
|
Get-WAUAvailableVersion
|
||||||
#Compare
|
#Compare
|
||||||
if ($WAUAvailableVersion -gt $WAUCurrentVersion){
|
if ($WAUAvailableVersion -gt $WAUCurrentVersion){
|
||||||
#If new version is available, update it
|
#If new version is available, update it
|
||||||
Update-WAU $WAUAvailableVersion
|
Update-WAU
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue