Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New App Request] HL7 Spy #111

Open
alex-harvey-z3q opened this issue Sep 11, 2024 · 6 comments
Open

[New App Request] HL7 Spy #111

alex-harvey-z3q opened this issue Sep 11, 2024 · 6 comments

Comments

@alex-harvey-z3q
Copy link

https://hl7spy.ca/blog/

I would appreciate some guidance so that I can raise the PR myself for this and a number of other apps!

@AScott-WWF
Copy link

AScott-WWF commented Sep 12, 2024

You could have a look at some of the other scripts in the Nevergreen Module Apps folder (https://github.com/DanGough/Nevergreen/tree/main/Nevergreen/Apps) as examples how you can create this for yourself.

Hint: You should look at the Page Source for the Webpage (for example in Firefox open: view-source:https://hl7spy.ca/blog/), find in the page the code that surrounds the Download button so you have an idea how to build the regex search for URLPattern).

To save you the effort, I have quickly knocked up the script for you (see below)

Until this is included in a future Nevergreen release, you will need to save it as Get-InnerHarbourHL7Spy.ps1 into your local NeverGreen Modules Apps folder, then either run silently: Get-NevergreenApp InnerHarbourHL7Spy or to get more verbose output (formatting the results into a table) Get-NevergreenApp InnerHarbourHL7Spy -Verbose | Format-Table
Dan Gough will review and may include this in a future release when he has the time:

N.B. This script will work so long as the latest version is always listed first on this page (as it is currently), But, if Inner Harbour Software decide to change the page layout or the URL in the future, this script will break, so may need fixing / updating in the future.
To protect this from breaking, you may be able to request this is added to the Evergreen PowerShell Module but only if Inner Harbour Software have an update API URL or a fixed url to a file (xml or json) that always holds the latest release information, but you would need to track down the information so it could be considered in Evergreen.

# Get-InnerHarbourHL7Spy.ps1

# Define AppName
$AppName = "HL7Spy"

$ReleaseUrl = "https://hl7spy.ca/blog/"
$ReleaseNotesUrl = "https://hl7spy.ca/release-history/" #N.B. This does not always appear to be kept upto date
$InstallInstructionsUrl = "https://conevity.atlassian.net/wiki/spaces/HL7Spy4/pages/626065447/Download+Installation"

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

# Main script to fetch and process links
$AppVersions = @(
    @{AppName = "$($AppName)"; Type = 'exe'; URLPattern = 'HL7Spy\.(\d+\.\d+(\.\d+))'}
)

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

    $URL = Set-UriPrefix -Uri (Get-Link -Uri $ReleaseUrl -MatchProperty href -Pattern $AppVersion.URLPattern) -Prefix 'https://hl7spy.ca/'
    [version]$Version = Get-Version -String $URL
    
    do {
        if ($URL) {
            New-NevergreenApp -Name $($AppVersion.AppName) -Architecture 'x64' -Version $($Version) -Uri $($URL) -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 ""
Write-Verbose "$($AppName) Install instructions are available here: $($InstallInstructionsUrl)"
Write-Verbose "$($AppName) (Version: $($Version)) Release notes are available here: $($ReleaseNotesUrl)"

@DanGough
Copy link
Owner

BTW, I am toying with some different ways to make all of this a lot simpler, so that scraping a page for an app can be done in a single command. I'll have to have a think about how to handle apps where you want more than one major version returned though!

@alex-harvey-z3q
Copy link
Author

Thank you @AScott-WWF this is making a bit more sense to me! I suppose we could make this a bit safer and more defensive if we had logic for computing the greatest version in a list of semantic versions? We don't already have that?

alex-harvey-z3q pushed a commit to alex-harvey-z3q/Nevergreen that referenced this issue Sep 14, 2024
Adds a plugin Get-InnerHarbourHL7Spy.ps1 and a new private function
Parse-SemVer for interrogating SemVers.

https://hl7spy.ca/blog/
@alex-harvey-z3q
Copy link
Author

Let me know what you think of the PR. I tried to make it a bit more defensive as mentioned.

@DanGough
Copy link
Owner

BTW, [version]'1.2.3.4' will already return an object with separate properties for major/minor/etc.

I have some functions for sanitising and converting versions that I'd like to bring in, along with a generic scraping function that would drastically simplify most of the app scripts in this project. I'll be looking to do a major update later this year!

alex-harvey-z3q added a commit to alex-harvey-z3q/Nevergreen that referenced this issue Sep 14, 2024
Adds a plugin Get-InnerHarbourHL7Spy.ps1 and a new private function
Parse-SemVer for interrogating SemVers.

https://hl7spy.ca/blog/
alex-harvey-z3q added a commit to alex-harvey-z3q/Nevergreen that referenced this issue Sep 14, 2024
Adds a plugin Get-InnerHarbourHL7Spy.ps1 and a new private function
Parse-SemVer for interrogating SemVers.

https://hl7spy.ca/blog/
alex-harvey-z3q added a commit to alex-harvey-z3q/Nevergreen that referenced this issue Sep 14, 2024
Adds a plugin Get-InnerHarbourHL7Spy.ps1 and a new private function
Parse-SemVer for interrogating SemVers.

https://hl7spy.ca/blog/
@alex-harvey-z3q
Copy link
Author

A new version of the PR after that insight. #113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants