Skip to content

Commit

Permalink
Refactor Update-WingetPackage function to improve URL handling and su…
Browse files Browse the repository at this point in the history
…bmission logic
  • Loading branch information
Utesgui committed Nov 26, 2024
1 parent abef765 commit 42a6a06
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions modules/WingetMaintainerModule/Public/Update-WingetPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ function Update-WingetPackage {

if ($latestVersion -and $latestVersionURL) {
$Latest = @{
Version = $latestVersion
URLs = $latestVersionURL.split(",").trim().split(" ")
Version = $latestVersion
URLs = $latestVersionURL.split(",").trim().split(" ")
ReleaseNotes = $releaseNotes
}
}
Expand Down Expand Up @@ -62,8 +62,8 @@ function Update-WingetPackage {
Switch ($With) {
"Komac" {
Install-Komac
.\komac.exe update $wingetPackage --version $Latest.Version --urls ($Latest.URLs).split(" ") --dry-run ($resolves -match '^\d+$' ? "--resolves" : $null ) ($resolves -match '^\d+$' ? $resolves : $null ) -t $gitToken --output "$ManifestOutPath"
#.\komac.exe update $wingetPackage --version $Latest.Version --urls ($Latest.URLs).split(" ") ($Submit -eq $true ? '-s' : '--dry-run') ($resolves -match '^\d+$' ? "--resolves" : $null ) ($resolves -match '^\d+$' ? $resolves : $null ) -t $gitToken --output "$ManifestOutPath"
#.\komac.exe update $wingetPackage --version $Latest.Version --urls ($Latest.URLs).split(" ") --dry-run ($resolves -match '^\d+$' ? "--resolves" : $null ) ($resolves -match '^\d+$' ? $resolves : $null ) -t $gitToken --output "$ManifestOutPath"
.\komac.exe update $wingetPackage --version $Latest.Version --urls ($Latest.URLs).split(" ") ($Submit -eq $true -and !$releaseNotes ? '-s' : '--dry-run') ($resolves -match '^\d+$' ? "--resolves" : $null ) ($resolves -match '^\d+$' ? $resolves : $null ) -t $gitToken --output "$ManifestOutPath"
}
"WinGetCreate" {
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
Expand All @@ -74,9 +74,9 @@ function Update-WingetPackage {
Write-Error "wingetcreate not downloaded"
exit 1
}
.\wingetcreate.exe update $wingetPackage -v $Latest.Version -u ($Latest.URLs).split(" ") --prtitle $prMessage -t $gitToken -o $ManifestOutPath
#.\wingetcreate.exe update $wingetPackage -v $Latest.Version -u ($Latest.URLs).split(" ") --prtitle $prMessage -t $gitToken -o $ManifestOutPath

#.\wingetcreate.exe update $wingetPackage ($Submit -eq $true ? "-s" : $null ) -v $Latest.Version -u ($Latest.URLs).split(" ") --prtitle $prMessage -t $gitToken -o $ManifestOutPath
.\wingetcreate.exe update $wingetPackage ($Submit -eq $true -and !$releaseNotes ? "-s" : $null ) -v $Latest.Version -u ($Latest.URLs).split(" ") --prtitle $prMessage -t $gitToken -o $ManifestOutPath
}
default {
Write-Error "Invalid value \"$With\" for -With parameter. Valid values are 'Komac' and 'WinGetCreate'"
Expand All @@ -91,12 +91,11 @@ function Update-WingetPackage {
$newFile = get-content -path $file.FullName
$newFile
}
}

if ($Submit -eq $true) {
Write-Host "Submitting PR for $wingetPackage Version $($Latest.Version)"
wingetcreate.exe submit --prtitle $prMessage -t $gitToken $ManifestOutPath
}
if ($Submit -eq $true) {
Write-Host "Submitting PR for $wingetPackage Version $($Latest.Version)"
wingetcreate.exe submit --prtitle $prMessage -t $gitToken "$($ManifestOutPath)manifests/$($wingetPackage.Substring(0, 1).ToLower())/$($wingetPackage.replace(".","/"))/$($Latest.Version)"
}
}
}
}
}

0 comments on commit 42a6a06

Please sign in to comment.