-override mods (.txt) too

pull/245/head
KnifMelti 2022-12-08 17:53:37 +01:00
parent e5d155f16d
commit ddd852abc6
3 changed files with 31 additions and 14 deletions

View File

@ -4,6 +4,7 @@ function Test-Mods ($app) {
#Takes care of a null situation
$ModsPreInstall = $null
$ModsOverride = $null
$ModsUpgrade = $null
$ModsInstall = $null
$ModsInstalled = $null
@ -13,6 +14,9 @@ function Test-Mods ($app) {
if (Test-Path "$Mods\$app-preinstall.ps1") {
$ModsPreInstall = "$Mods\$app-preinstall.ps1"
}
if (Test-Path "$Mods\$app-override.txt") {
$ModsOverride = Get-Content "$Mods\$app-override.txt" -Raw
}
if (Test-Path "$Mods\$app-install.ps1") {
$ModsInstall = "$Mods\$app-install.ps1"
$ModsUpgrade = "$Mods\$app-install.ps1"
@ -25,6 +29,6 @@ function Test-Mods ($app) {
}
}
return $ModsPreInstall, $ModsUpgrade, $ModsInstall, $ModsInstalled
return $ModsPreInstall, $ModsOverride, $ModsUpgrade, $ModsInstall, $ModsInstalled
}

View File

@ -7,7 +7,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
$ExternalMods = "$ModsPath"
#Get File Names Locally
$InternalModsNames = Get-ChildItem -Path $LocalMods -Name -Recurse -Include *.ps1
$InternalModsNames = Get-ChildItem -Path $LocalMods -Name -Recurse -Include *.ps1, *.txt
# If path is URL
if ($ExternalMods -like "http*") {
@ -35,8 +35,8 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
#Loop through all links
$WebResponse.Links | Select-Object -ExpandProperty href | ForEach-Object {
#Check for .ps1 in listing/HREF:s in an index page pointing to .ps1
if ($_ -like "*.ps1") {
#Check for .ps1/.txt in listing/HREF:s in an index page pointing to .ps1/.txt
if (($_ -like "*.ps1") -or ($_ -like "*.txt")) {
try {
$dateExternalMod = ""
$dateLocalMod =""
@ -67,9 +67,9 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
}
# If path is UNC or local
else {
if (Test-Path -Path $ExternalMods"\*.ps1") {
if ((Test-Path -Path $ExternalMods"\*.ps1") -or (Test-Path -Path $ExternalMods"\*.txt")) {
#Get File Names Externally
$ExternalModsNames = Get-ChildItem -Path $ExternalMods -Name -Recurse -Include *.ps1
$ExternalModsNames = Get-ChildItem -Path $ExternalMods -Name -Recurse -Include *.ps1, *.txt
#Delete Local Mods that don't exist Externally
foreach ($Mod in $InternalModsNames){
If($Mod -notin $ExternalModsNames ){

View File

@ -17,7 +17,10 @@ Function Update-App ($app) {
Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Balise $Balise -Button1Action $ReleaseNoteURL -Button1Text $Button1Text
#Check if mods exist for preinstall/install/upgrade
$ModsPreInstall, $ModsUpgrade, $ModsInstall, $ModsInstalled = Test-Mods $($app.Id)
$ModsPreInstall, $ModsOverride, $ModsUpgrade, $ModsInstall, $ModsInstalled = Test-Mods $($app.Id)
#Winget upgrade
Write-Log "########## WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '$($App.Id)' ##########" "Gray"
#If PreInstall script exist
if ($ModsPreInstall) {
@ -25,12 +28,15 @@ Function Update-App ($app) {
& "$ModsPreInstall"
}
#Winget upgrade
Write-Log "########## WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '$($App.Id)' ##########" "Gray"
#Run Winget Upgrade command
Write-Log "-> Running: Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h"
& $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
if ($ModsOverride) {
Write-Log "-> Running (overriding default): Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride"
& $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride | Tee-Object -file $LogFile -Append
}
else {
Write-Log "-> Running: Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h"
& $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
}
if ($ModsUpgrade) {
Write-Log "Modifications for $($app.Id) during upgrade are being applied..." "Yellow"
@ -54,8 +60,15 @@ Function Update-App ($app) {
#If app failed to upgrade, run Install command
Write-Log "-> An upgrade for $($app.Name) failed, now trying an install instead..." "Yellow"
Write-Log "-> Running: Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h"
& $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
if ($ModsOverride) {
Write-Log "-> Running (overriding default): Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride"
& $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride | Tee-Object -file $LogFile -Append
}
else {
Write-Log "-> Running: Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h"
& $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
}
if ($ModsInstall) {
Write-Log "Modifications for $($app.Id) during install are being applied..." "Yellow"