fix json creation

This commit is contained in:
moehreag 2024-06-17 16:45:51 +02:00
parent 4fde4f5e50
commit fd526f42d6
2 changed files with 21 additions and 24 deletions

View file

@ -1,3 +1,8 @@
---
- head:
---
# Client # Client
Here's how to install FrogLoader to your game. Here's how to install FrogLoader to your game.
@ -20,7 +25,6 @@ Insert section about the installer here
const instanceNameRef = ref() const instanceNameRef = ref()
const showSnapshots = ref() const showSnapshots = ref()
const versionSelector = ref() const versionSelector = ref()
const useSnapshots = ref()
let releases = [] let releases = []
let snapshots = [] let snapshots = []
let versions = [] let versions = []
@ -45,7 +49,7 @@ Insert section about the installer here
} }
async function fetchLibraries() { async function fetchLibraries() {
let response = await fetch("https://meta.frogmc.dev/v1/loader/versions/latest") let response = await fetch("https://meta.frogmc.dev/v1/loader/version/latest")
let json = await response.json() let json = await response.json()
loaderLibs = json loaderLibs = json
} }
@ -82,10 +86,10 @@ Insert section about the installer here
let versionResponse = await fetch(versionUrl) let versionResponse = await fetch(versionUrl)
let versionJson = await versionResponse.json() let versionJson = await versionResponse.json()
for (let lib of version.libraries) { for (let lib of versionJson.libraries) {
let matcher = lib.name.matcher(/org.lwjgl:lwjgl:(\d+\.\d+\.\d+.*)/) let matcher = lib.name.match(/org.lwjgl:lwjgl:(\d+\.\d+\.\d+.*)/)
if (matcher.matches()) { if (matcher != undefined) {
return matcher.group(1) return matcher[1]
} }
} }
} }
@ -104,7 +108,7 @@ Insert section about the installer here
} }
} }
function download(){ async function download(){
let missing = [] let missing = []
if (instanceNameRef.value === undefined){ if (instanceNameRef.value === undefined){
@ -121,10 +125,9 @@ Insert section about the installer here
let zip = JSZip() let zip = JSZip()
let promises = [] let promises = []
let lwjglVersion = getLwjglVersion() let lwjglVersion = await getLwjglVersion()
let platform = getPlatform() let platform = getPlatform()
promises.push( promises.push(
readAsset("/mmc-pack.json").then((data) => { readAsset("/mmc-pack.json").then((data) => {
if (lwjglVersion.split(".")[0] == 3) { if (lwjglVersion.split(".")[0] == 3) {
@ -154,17 +157,18 @@ Insert section about the installer here
readAsset("/patches/dev.frogmc.frogloader.json").then((data) => { readAsset("/patches/dev.frogmc.frogloader.json").then((data) => {
let json = JSON.parse(data) let json = JSON.parse(data)
let libs = json.libraries let libs = json.libraries
for (let lib in loaderLibs.libraries) { for (let lib of loaderLibs.libraries) {
libs.push({ let value = {
"download": { "download": {
"artifact": { "artifact": {
"url": lib.url "url": lib.url,
"size": lib.size "size": lib.size,
"sha1": lib.sha1 "sha1": lib.sha1
} }
}, },
"name": lib.name "name": lib.name
}) }
libs.push(value)
} }
zip.folder("patches").file("dev.frogmc.frogloader.json", JSON.stringify(json)) zip.folder("patches").file("dev.frogmc.frogloader.json", JSON.stringify(json))
}) })
@ -184,6 +188,7 @@ Insert section about the installer here
return await response.text().then((data) => { return await response.text().then((data) => {
return data.replaceAll("$instance_name", instanceNameRef.value) return data.replaceAll("$instance_name", instanceNameRef.value)
.replaceAll("$loader_version", loaderLibs.version) .replaceAll("$loader_version", loaderLibs.version)
.replaceAll("$game_version", versionSelector.value.value)
}) })
} }
@ -212,12 +217,6 @@ PR direct support to Prism
<input type="checkbox" v-model="showSnapshots" @change="getVersions">Show Snapshots</input> <input type="checkbox" v-model="showSnapshots" @change="getVersions">Show Snapshots</input>
</td> </td>
</tr> </tr>
<tr>
<td>Library Versions</td>
<td>
<input type="checkbox" v-model="useSnapshots">Use Snapshots (Beta Versions)</input>
</td>
</tr>
<tr> <tr>
<td></td> <td></td>
<td></td> <td></td>

View file

@ -2,21 +2,19 @@
"components": [ "components": [
{ {
"cachedName": "LWJGL $lwjgl_major", "cachedName": "LWJGL $lwjgl_major",
"cachedVersion": "$lwjlg_version",
"cachedVolatile": true, "cachedVolatile": true,
"dependencyOnly": true, "dependencyOnly": true,
"uid": "org.lwjgl$lwjgl_major", "uid": "org.lwjgl$lwjgl_major",
"version": "$lwjlg_version" "version": "$lwjgl_version"
}, },
{ {
"cachedName": "Minecraft", "cachedName": "Minecraft",
"cachedRequires": [ "cachedRequires": [
{ {
"suggests": "$lwjlg_version", "suggests": "$lwjgl_version",
"uid": "org.lwjgl$lwjgl_major" "uid": "org.lwjgl$lwjgl_major"
} }
], ],
"cachedVersion": "$game_version",
"important": true, "important": true,
"uid": "net.minecraft", "uid": "net.minecraft",
"version": "$game_version" "version": "$game_version"