Skip to content

Commit

Permalink
AVPRIndex: Add getPreviewIndex function
Browse files Browse the repository at this point in the history
-> downloads the currently released preview index from the github release.
  • Loading branch information
kMutagene committed Mar 12, 2024
1 parent b3cd454 commit c86a92b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/AVPRIndex/AVPRIndex.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/RELEASE_NOTES.md"))</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageVersion>0.0.4</PackageVersion>
<PackageVersion>0.0.5</PackageVersion>
</PropertyGroup>

<ItemGroup>
Expand All @@ -31,6 +31,7 @@

<ItemGroup>
<PackageReference Include="YamlDotNet" Version="15.1.2" />
<PackageReference Include="FsHttp" Version="14.5.0" />
</ItemGroup>

</Project>
22 changes: 11 additions & 11 deletions src/AVPRIndex/AVPRRepo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ open System.Text.Json
open Domain
open Globals
open Frontmatter
open FsHttp

type AVPRRepo =

Expand All @@ -26,17 +27,16 @@ type AVPRRepo =
lastUpdated = Utils.truncateDateTime DateTimeOffset.Now // take local time with offset if file will be changed with this commit
)
)

///! Paths are relative to the root of the project, since the script is executed from the repo root in CI
/// Path is adjustable by passing `RepoRoot`
static member getIndexedPackages(?RepoRoot: string) =

let path =
defaultArg
(RepoRoot |> Option.map (fun p -> Path.Combine(p, PACKAGE_INDEX_RELATIVE_PATH)))
PACKAGE_INDEX_RELATIVE_PATH
static member getPreviewIndex() =
try
http {
GET "https://github.com/nfdi4plants/arc-validate-package-registry/releases/download/preview-index/arc-validate-package-index.json"
}
|> Request.send
|> Response.deserializeJson<ValidationPackageIndex[]>
with e as exn ->
printfn $"Failed to fetch current preview index: {exn.Message}"
[||]

path
|> File.ReadAllText
|> JsonSerializer.Deserialize<ValidationPackageIndex[]>

4 changes: 4 additions & 0 deletions src/AVPRIndex/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v0.0.5

- Add `getPreviewIndex` function that downloads the currently released preview index from the github release.

## v0.0.4

- Replace line endings when parsing frontmatter
Expand Down

0 comments on commit c86a92b

Please sign in to comment.