feat: add "latest" as possible version (#65)

This commit is contained in:
Leo Kettmeir 2024-07-12 13:32:45 +02:00 committed by GitHub
parent f99b7edee3
commit 2bca7ce523
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 0 deletions

View File

@ -30,6 +30,10 @@ function parseVersionRange(version) {
return { range: "latest", isCanary: true };
}
if (version == "latest") {
return { range: "latest", isCanary: false };
}
if (GIT_HASH_RE.test(version)) {
return { range: version, isCanary: true };
}
@ -92,6 +96,23 @@ async function resolveVersion({ range, isCanary }) {
return { version: range, isCanary: true };
}
if (range === "latest") {
const res = await fetchWithRetries(
"https://dl.deno.land/release-latest.txt",
);
if (res.status !== 200) {
throw new Error(
"Failed to fetch release version info from dl.deno.land. Please try again later.",
);
}
let version = (await res.text()).trim();
version = semver.clean(version);
if (version === null) {
return null;
}
return { version, isCanary: false };
}
const res = await fetchWithRetries("https://deno.com/versions.json");
if (res.status !== 200) {
throw new Error(