feat: add "latest" as possible version

This commit is contained in:
crowlkats 2024-07-12 13:12:51 +02:00
parent f99b7edee3
commit 8b818baf75
No known key found for this signature in database
GPG Key ID: A82C9D461FC483E8

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,19 @@ 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.",
);
}
const version = (await res.text()).trim();
return { version, isCanary: false };
}
const res = await fetchWithRetries("https://deno.com/versions.json");
if (res.status !== 200) {
throw new Error(