DanGough / Nevergreen

This module is an alternative to Evergreen, and allows you to find the latest version and download URL for various Windows apps. Evergreen uses API queries to obtain its data whereas this module is more focussed on web scraping. This is more prone to breaking when websites are changed, hence the name.
The Unlicense
77 stars 18 forks source link

[New App Request] LyX (On Proposals list) #86

Open AScott-WWF opened 4 months ago

AScott-WWF commented 4 months ago

Script:

# Get-LyX.ps1

# Define AppName
$AppName = "LyX"

$ReleaseUrl = "https://www.lyx.org/Download"
$InstallInstructionsUrl = "https://wiki.lyx.org/Windows/LyXWinInstaller"

Write-Verbose "Obtaining $($AppName) Release Versions from $($ReleaseUrl)...`n"

# Main script to fetch and process links
$AppVersions = @(
    @{AppName = $($AppName); Type = 'exe'; Pattern = '\.exe'}
)

foreach ($AppVersion in $AppVersions) {
    $SearchCount = 1 # This may need increasing as future versions are released

    #Build each link with File Type specific versions
    $URL = Get-Link -Uri $ReleaseUrl -Headers $Headers -MatchProperty href -Pattern $AppVersion.Pattern
    Write-Verbose "URL :: $($URL)"
    [version]$Version = Get-Version -String $URL

    $ReleaseNotesUrl = "https://wiki.lyx.org/LyX/NewInLyX24"
    Write-Verbose "$($AppName) (Version: $($Version)) Release notes are available here: $($ReleaseNotesUrl)"

    do {
        if ($URL) {
            New-NevergreenApp -Name $($AppVersion.AppName) -Version $($Version) -Uri $($URL) -Architecture 'x64' -Type $($AppVersion.Type)
            break
        }

        $SearchCount--
    } until ($SearchCount -eq 0)

    if ($SearchCount -eq 0) {
        Write-Warning "Could not find release for $($AppName) $($AppVersion.Type)"
    }
}

Write-Verbose "$($AppName) Install instructions are available here: $($InstallInstructionsUrl)"