Skip to content

Commit

Permalink
Update building
Browse files Browse the repository at this point in the history
Now includes JREs
  • Loading branch information
RuiNtD committed Apr 24, 2024
1 parent 57fca13 commit ec0549e
Show file tree
Hide file tree
Showing 9 changed files with 218 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ WaitForProgram=false
WaitForOtherInstances=false

[Environment]
PRISMLAUNCHER_JAVA_PATHS="..\..\CommonFiles\Java\bin\javaw.exe;..\..\CommonFiles\Java64\bin\javaw.exe;..\..\CommonFiles\JDK\bin\javaw.exe;..\..\CommonFiles\JDK64\bin\javaw.exe;..\..\CommonFiles\OpenJDK\bin\javaw.exe;..\..\CommonFiles\OpenJDK64\bin\javaw.exe;..\..\CommonFiles\OpenJDKJRE\bin\javaw.exe;..\..\CommonFiles\OpenJDKJRE64\bin\javaw.exe"
PRISMLAUNCHER_JAVA_PATHS="..\..\CommonFiles\Java\bin\javaw.exe;..\..\CommonFiles\Java64\bin\javaw.exe;..\..\CommonFiles\JDK\bin\javaw.exe;..\..\CommonFiles\JDK64\bin\javaw.exe;..\..\CommonFiles\OpenJDK\bin\javaw.exe;..\..\CommonFiles\OpenJDK64\bin\javaw.exe;..\..\CommonFiles\OpenJDKJRE\bin\javaw.exe;..\..\CommonFiles\OpenJDKJRE64\bin\javaw.exe;..\App\jre8\bin\javaw.exe;..\App\jre17\bin\javaw.exe;..\App\jre21\bin\javaw.exe"
19 changes: 10 additions & 9 deletions deno.json
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"
}
}
139 changes: 72 additions & 67 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
42 changes: 42 additions & 0 deletions src/java.ts
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));
}
Loading

0 comments on commit ec0549e

Please sign in to comment.