Files
playlet-piped/playlet-lib/src/components/Services/ApplicationInfo/LatestLibVersionJob.bs
T
2025-09-19 08:55:24 -04:00

29 lines
936 B
Plaintext

import "pkg:/source/services/HttpClient.bs"
import "pkg:/source/utils/CancellationUtils.bs"
@job("LatestLibVersionJob")
function ExecuteJob() as void
cancellation = JobGetCancellation()
latest = GetLatestPlayletLibVersionFromGithubReleases(cancellation)
JobSuccessData({
latest: latest
})
end function
function GetLatestPlayletLibVersionFromGithubReleases(cancellation as dynamic) as string
response = HttpClient.Head("https://github.com/iBicha/playlet/releases/latest").Cancellation(cancellation).Await()
if response.StatusCode() = 200
headers = response.Headers()
if headers.location <> invalid
' bs:disable-next-line NO_OPTIONAL_CHAINING
regex = /\/v?(\d+\.\d+\.\d+)/
match = regex.match(headers.location)
if match.Count() = 2
return match[1]
end if
end if
end if
return "N/A"
end function