diff options
Diffstat (limited to 'editors/code')
| -rw-r--r-- | editors/code/src/installation/fetch_artifact_release_info.ts (renamed from editors/code/src/installation/fetch_latest_artifact_release_info.ts) | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/editors/code/src/installation/fetch_latest_artifact_release_info.ts b/editors/code/src/installation/fetch_artifact_release_info.ts index 29ee029a7..7d497057a 100644 --- a/editors/code/src/installation/fetch_latest_artifact_release_info.ts +++ b/editors/code/src/installation/fetch_artifact_release_info.ts | |||
| @@ -3,24 +3,30 @@ import { GithubRepo, ArtifactReleaseInfo } from "./interfaces"; | |||
| 3 | 3 | ||
| 4 | const GITHUB_API_ENDPOINT_URL = "https://api.github.com"; | 4 | const GITHUB_API_ENDPOINT_URL = "https://api.github.com"; |
| 5 | 5 | ||
| 6 | |||
| 6 | /** | 7 | /** |
| 7 | * Fetches the latest release from GitHub `repo` and returns metadata about | 8 | * Fetches the release with `releaseTag` (or just latest release when not specified) |
| 8 | * `artifactFileName` shipped with this release or `null` if no such artifact was published. | 9 | * from GitHub `repo` and returns metadata about `artifactFileName` shipped with |
| 10 | * this release or `null` if no such artifact was published. | ||
| 9 | */ | 11 | */ |
| 10 | export async function fetchLatestArtifactReleaseInfo( | 12 | export async function fetchArtifactReleaseInfo( |
| 11 | repo: GithubRepo, artifactFileName: string | 13 | repo: GithubRepo, artifactFileName: string, releaseTag?: string |
| 12 | ): Promise<null | ArtifactReleaseInfo> { | 14 | ): Promise<null | ArtifactReleaseInfo> { |
| 13 | 15 | ||
| 14 | const repoOwner = encodeURIComponent(repo.owner); | 16 | const repoOwner = encodeURIComponent(repo.owner); |
| 15 | const repoName = encodeURIComponent(repo.name); | 17 | const repoName = encodeURIComponent(repo.name); |
| 16 | 18 | ||
| 17 | const apiEndpointPath = `/repos/${repoOwner}/${repoName}/releases/latest`; | 19 | const apiEndpointPath = releaseTag |
| 20 | ? `/repos/${repoOwner}/${repoName}/releases/tags/${releaseTag}` | ||
| 21 | : `/repos/${repoOwner}/${repoName}/releases/latest`; | ||
| 22 | |||
| 18 | const requestUrl = GITHUB_API_ENDPOINT_URL + apiEndpointPath; | 23 | const requestUrl = GITHUB_API_ENDPOINT_URL + apiEndpointPath; |
| 19 | 24 | ||
| 20 | // We skip runtime type checks for simplicity (here we cast from `any` to `GithubRelease`) | 25 | // We skip runtime type checks for simplicity (here we cast from `any` to `GithubRelease`) |
| 21 | 26 | ||
| 22 | console.log("Issuing request for released artifacts metadata to", requestUrl); | 27 | console.log("Issuing request for released artifacts metadata to", requestUrl); |
| 23 | 28 | ||
| 29 | // FIXME: handle non-ok response | ||
| 24 | const response: GithubRelease = await fetch(requestUrl, { | 30 | const response: GithubRelease = await fetch(requestUrl, { |
| 25 | headers: { Accept: "application/vnd.github.v3+json" } | 31 | headers: { Accept: "application/vnd.github.v3+json" } |
| 26 | }) | 32 | }) |
