diff --git a/package-lock.json b/package-lock.json index ca33062..9ce6e08 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "setup-deno", - "version": "2.2.0", + "version": "2.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/installer.ts b/src/installer.ts index 8100845..559b426 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -1,4 +1,4 @@ -import type { Version, Arch, Platform } from "./types"; +import type { Version, Arch, Platform, DenoVersions } from "./types"; import * as os from "os"; import * as path from "path"; @@ -38,6 +38,8 @@ import * as io from "@actions/io"; import { v4 as uuidV4 } from "uuid"; import { HttpClient } from "@actions/http-client"; +import * as deprecatedVersions from "./versions-before-0.34.0.json"; + function getDenoArch(version: Version): Arch { return version === "nightly" ? "x86_64" @@ -131,19 +133,18 @@ async function queryLatestMatch(versionSpec: Version): Promise { } export async function getAvailableVersions(): Promise { - // a temporary workaround until a Release API is provided. (#11) const httpc = new HttpClient("setup-deno"); - const body = await ( - await httpc.get( - "https://raw.githubusercontent.com/denoland/deno/master/Releases.md" + const body = ( + await httpc.getJson( + "https://raw.githubusercontent.com/denoland/deno_website2/master/versions.json" ) - ).readBody(); - const matches = body.matchAll(/### (v?\d+\.\d+\.\d+)/g); + ).result; + + if (body === null) { + throw new Error("Unable to fetch Deno versions"); + } - return [...matches] - .map((m) => m[1]) - .filter((v) => v && v !== "v0.0.0") - .map((version) => (version.startsWith("v") ? version : "v" + version)); + return [...Object.keys(body.cli_to_std), ...deprecatedVersions]; } export function getDownloadUrl(version: Version): string { diff --git a/src/types.ts b/src/types.ts index dd5d4f4..0029864 100644 --- a/src/types.ts +++ b/src/types.ts @@ -17,3 +17,12 @@ export type ArchOld = "x64"; export type Arch = "x86_64" | ArchOld; export type Version = LiteralUnion<"nightly", string>; + +/** + * https://raw.githubusercontent.com/denoland/deno_website2/master/versions.json + */ +export interface DenoVersions { + std: string[]; + cli: string[]; + cli_to_std: Record; +} diff --git a/src/versions-before-0.34.0.json b/src/versions-before-0.34.0.json new file mode 100644 index 0000000..3017275 --- /dev/null +++ b/src/versions-before-0.34.0.json @@ -0,0 +1,69 @@ +[ + "v0.33.0", + "v0.32.0", + "v0.31.0", + "v0.30.0", + "v0.29.0", + "v0.28.1", + "v0.28.0", + "v0.27.0", + "v0.26.0", + "v0.25.0", + "v0.24.0", + "v0.23.0", + "v0.22.0", + "v0.21.0", + "v0.20.0", + "v0.19.0", + "v0.18.0", + "v0.17.0", + "v0.16.0", + "v0.15.0", + "v0.14.0", + "v0.13.0", + "v0.12.0", + "v0.11.0", + "v0.10.0", + "v0.9.0", + "v0.8.0", + "v0.7.0", + "v0.6.0", + "v0.5.0", + "v0.4.0", + "v0.3.10", + "v0.3.9", + "v0.3.8", + "v0.3.7", + "v0.3.6", + "v0.3.5", + "v0.3.4", + "v0.3.3", + "v0.3.2", + "v0.3.1", + "v0.3.0", + "v0.2.11", + "v0.2.10", + "v0.2.9", + "v0.2.8", + "v0.2.7", + "v0.2.6", + "v0.2.5", + "v0.2.4", + "v0.2.3", + "v0.2.2", + "v0.2.1", + "v0.2.0", + "v0.1.12", + "v0.1.11", + "v0.1.10", + "v0.1.9", + "v0.1.8", + "v0.1.7", + "v0.1.6", + "v0.1.5", + "v0.1.4", + "v0.1.3", + "v0.1.2", + "v0.1.1", + "v0.1.0" +] diff --git a/tsconfig.json b/tsconfig.json index b9c6d80..30428bf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,8 @@ "module": "CommonJS", "outDir": "./lib", "rootDir": "./src", - "strict": true + "strict": true, + "resolveJsonModule": true }, "exclude": ["node_modules", "**/*.test.ts"] }