-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now includes JREs
- Loading branch information
Showing
9 changed files
with
218 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
{ | ||
"tasks": { | ||
"update": "deno run -A update.ts", | ||
"fileinfo": "deno run -A fileinfo.ts" | ||
"start": "deno run -A src/main.ts", | ||
"fileinfo": "deno run -A src/fileinfo.ts" | ||
}, | ||
"imports": { | ||
"@david/dax": "jsr:@david/dax@^0.39.2", | ||
"@std/crypto": "jsr:@std/crypto@^0.218.2", | ||
"@std/encoding": "jsr:@std/encoding@^0.218.2", | ||
"@std/fmt": "jsr:@std/fmt@^0.218.2", | ||
"@std/ini": "jsr:@std/ini@^0.218.2", | ||
"@zip-js/zip-js": "jsr:@zip-js/zip-js@^2.7.37", | ||
"zod": "npm:zod@^3.22.4" | ||
"@david/dax": "jsr:@david/dax@^0.40.1", | ||
"@std/crypto": "jsr:@std/crypto@^0.223.0", | ||
"@std/dotenv": "jsr:@std/dotenv@^0.223.0", | ||
"@std/encoding": "jsr:@std/encoding@^0.223.0", | ||
"@std/fmt": "jsr:@std/fmt@^0.223.0", | ||
"@std/ini": "jsr:@std/ini@^0.223.0", | ||
"@zip-js/zip-js": "jsr:@zip-js/zip-js@^2.7.42", | ||
"zod": "npm:zod@^3.23.4" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import z from "zod"; | ||
import $ from "@david/dax"; | ||
|
||
export type JavaVersion = 8 | 17 | 21; | ||
|
||
const Release = z.object({ | ||
release_name: z.string(), | ||
release_link: z.string().url(), | ||
binary: z.object({ | ||
package: z.object({ | ||
name: z.string(), | ||
link: z.string(), | ||
size: z.number(), | ||
}), | ||
}), | ||
version: z.object({ | ||
openjdk_version: z.string(), | ||
}), | ||
}); | ||
type Release = z.infer<typeof Release>; | ||
|
||
const cache = new Map<JavaVersion, Release>(); | ||
|
||
export async function getJavaRelease(version: JavaVersion): Promise<Release> { | ||
const cached = cache.get(version); | ||
if (cached) return cached; | ||
|
||
const params = new URLSearchParams({ | ||
architecture: "x64", | ||
image_type: "jre", | ||
os: "windows", | ||
vendor: "eclipse", | ||
}); | ||
const url = `https://api.adoptium.net/v3/assets/latest/${version}/hotspot?${params}`; | ||
const release = z.tuple([Release]).parse(await $.request(url).json())[0]; | ||
cache.set(version, release); | ||
return release; | ||
} | ||
|
||
if (import.meta.main) { | ||
$.log(await getJavaRelease(21)); | ||
} |
Oops, something went wrong.