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
71 stars 16 forks source link

[New App Request] Eclipse (on Proposals list) #83

Open AScott-WWF opened 2 days ago

AScott-WWF commented 2 days ago

Script

# Get-Eclipse.ps1

# Define AppName
$AppName = "Eclipse"

# Main script to fetch and process links
$ReleaseUrl = "https://www.eclipse.org/downloads/packages/"
$InstallInstructionsUrl = "https://wiki.eclipse.org/Eclipse/Installation"

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

$AppVersions = @(
    @{Product ='IDE for Enterprise Java and Web Developers'; Platform = 'Windows'; Type = 'zip'; Pattern = '([^"]*eclipse-jee-[^"]*\.zip)'; VersionPattern = '-(\d{4}-\d{2}-[a-z])-'}
    @{Product ='IDE for Java Developers'; Platform = 'Windows'; Type = 'zip'; Pattern = '([^"]*eclipse-java-[^"]*\.zip)'; VersionPattern = '-(\d{4}-\d{2}-[a-z])-'}
    @{Product ='IDE for C/C++ Developers'; Platform = 'Windows'; Type = 'zip'; Pattern = '([^"]*eclipse-cpp-[^"]*\.zip)'; VersionPattern = '-(\d{4}-\d{2}-[a-z])-'}
    @{Product ='IDE for Eclipse Committers'; Platform = 'Windows'; Type = 'zip'; Pattern = '([^"]*eclipse-committers-[^"]*\.zip)'; VersionPattern = '-(\d{4}-\d{2}-[a-z])-'}
    @{Product ='IDE for Java and DSL Developers'; Platform = 'Windows'; Type = 'zip'; Pattern = '([^"]*eclipse-dsl-[^"]*\.zip)'; VersionPattern = '-(\d{4}-\d{2}-[a-z])-'}
    @{Product ='IDE for PHP Developers'; Platform = 'Windows'; Type = 'zip'; Pattern = '([^"]*eclipse-php-[^"]*\.zip)'; VersionPattern = '-(\d{4}-\d{2}-[a-z])-'}
    @{Product ='IDE for Embedded C/C++ Developers'; Platform = 'Windows'; Type = 'zip'; Pattern = '([^"]*eclipse-embedcpp-[^"]*\.zip)'; VersionPattern = '-(\d{4}-\d{2}-[a-z])-'}
    @{Product ='IDE for RCP and RAP Developers'; Platform = 'Windows'; Type = 'zip'; Pattern = '([^"]*eclipse-rcp-[^"]*\.zip)'; VersionPattern = '-(\d{4}-\d{2}-[a-z])-'}
    @{Product ='Modeling Tools'; Platform = 'Windows'; Type = 'zip'; Pattern = '([^"]*eclipse-modeling-[^"]*\.zip)'; VersionPattern = '-(\d{4}-\d{2}-[a-z])-'}
    @{Product ='IDE for Scout Developers'; Platform = 'Windows'; Type = 'zip'; Pattern = '([^"]*eclipse-scout-[^"]*\.zip)'; VersionPattern = '-(\d{4}-\d{2}-[a-z])-'}
)

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

    #Build each link with File Type specific versions
    $Prefix = "https://download.eclipse.org" # Default domain, but site appears to randomly select mirror or prefers users to download from a specific (default) mirror.
    $Prefix = "https://eclipse.mirror.liteserver.nl" # Default mirror
    $URL = Set-UriPrefix -Uri ((Get-Link -Uri $ReleaseUrl -MatchProperty href -Pattern $($AppVersion.Pattern)).split('file=')[1]) -Prefix $($Prefix)
    $Version = (Get-Version -String $URL -Pattern $($AppVersion.VersionPattern)).Replace('-R',' R')

    $ReleaseNotesUrl = "https://eclipseide.org/release/noteworthy/"

    do {
        if ($URL) {
            New-NevergreenApp -Name "$($AppName) $($AppVersion.Product)" -Platform $($AppVersion.Platform) -Version $Version -Uri $URL -Architecture 'multi' -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 "Information:`n"
Write-Verbose "$($AppName) (Version: $($Version)) release notes are available here: $($ReleaseNotesUrl)"
Write-Verbose "$($AppName) Install instructions are available here: $($InstallInstructionsUrl)"