switch the prism instance generator to use the meta

This commit is contained in:
moehreag 2024-06-17 13:10:43 +02:00
parent 607b11f55c
commit 47bda46ae8
2 changed files with 23 additions and 130 deletions

View file

@ -24,6 +24,7 @@ Insert section about the installer here
let releases = [] let releases = []
let snapshots = [] let snapshots = []
let versions = [] let versions = []
let loaderLibs
let latestThyroxine let latestThyroxine
let latestThyroxineUrl let latestThyroxineUrl
let latestThyroxineSnapshot let latestThyroxineSnapshot
@ -51,56 +52,10 @@ Insert section about the installer here
} }
} }
function getLatestProjectVersions() { async function fetchLibraries() {
return Promise.all([ let response = await fetch("https://meta.frogmc.dev/v1/loader/versions/latest")
fetchVersionFromMaven("releases", "frogloader").then((v) => { let json = await response.json()
latestLoader = v loaderLibs = json
fetchVersionUrlFromMaven("releases", "frogloader", v).then((v) => {
latestLoader = v
})
}),
fetchVersionFromMaven("snapshots", "frogloader").then((v) => {
latestLoaderSnapshot = v
fetchVersionUrlFromMaven("snapshots", "frogloader", v).then((v) => {
latestLoaderSnapshotUrl = v
})
}),
fetchVersionFromMaven("releases", "thyroxine").then((v) => {
latestThyroxine = v
fetchVersionUrlFromMaven("releases", "thyroxine", v).then((v) => {
latestThyroxineUrl = v
})
}),
fetchVersionFromMaven("snapshots", "thyroxine").then((v) => {
latestThyroxineSnapshot = v
fetchVersionUrlFromMaven("snapshots", "thyroxine", v).then((v) => {
latestThyroxineSnapshotUrl = v
})
})
])
}
async function fetchVersionFromMaven(repository, name) {
const response = await fetch("https://maven.frogmc.dev/"+repository+"/dev/frogmc/"+name+"/maven-metadata.xml")
if (!response.ok){
return Promise.reject("No Version found for artifact "+name+" in repository "+repository)
}
const text = await response.text()
const parser = new DOMParser()
const doc = parser.parseFromString(text, "text/xml")
return doc.getElementsByTagName("latest")[0].textContent
}
async function fetchVersionUrlFromMaven(repository, name, version) {
const response = await fetch("https://maven.frogmc.dev/"+repository+"/dev/frogmc/"+name+"/"+version+"/maven-metadata.xml")
if (!response.ok){
return "https://maven.frogmc.dev/"+repository+"/dev/frogmc/"+name+"/"+version+"/"+name+"-"+version+".jar"
}
const text = await response.text()
const parser = new DOMParser()
const doc = parser.parseFromString(text, "text/xml")
console.log(doc)
return doc.getElementsByTagName("snapshotVersion")[0].getElementsByTagName("value")[0].textContent
} }
onMounted(() => { onMounted(() => {
@ -116,7 +71,7 @@ Insert section about the installer here
} }
getVersions() getVersions()
}), }),
getLatestProjectVersions() fetchLibraries()
]).then((unused) => { ]).then((unused) => {
let button = document.getElementById("download") let button = document.getElementById("download")
button.innerHTML = "Download" button.innerHTML = "Download"
@ -205,10 +160,21 @@ Insert section about the installer here
promises.push( promises.push(
readAsset("/patches/dev.frogmc.frogloader.json").then((data) => { readAsset("/patches/dev.frogmc.frogloader.json").then((data) => {
data = data.replaceAll("$thyroxine_version", useSnapshots.value ? latestThyroxineSnapshot : latestThyroxine) let json = JSON.parse(data)
data = data.replaceAll("$loader_url", useSnapshots.value ? latestLoaderSnapshotUrl : latestLoaderUrl) let libs = json.libraries
data = data.replaceAll("$thyroxine_url", useSnapshots.value ? latestThyroxineSnapshotUrl : latestThyroxineUrl) for (let lib in loaderLibs.libraries) {
zip.folder("patches").file("dev.frogmc.frogloader.json", data) libs.push({
"download": {
"artifact": {
"url": lib.url
"size": lib.size
"sha1": lib.sha1
}
},
"name": lib.name
})
}
zip.folder("patches").file("dev.frogmc.frogloader.json", JSON.stringify(json))
}) })
) )
@ -225,7 +191,7 @@ Insert section about the installer here
const response = await fetch(assetBaseUrl+path) const response = await fetch(assetBaseUrl+path)
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", useSnapshots.value ? latestLoaderSnapshot : latestLoader) .replaceAll("$loader_version", loaderLibs.version)
}) })
} }
@ -234,10 +200,6 @@ Insert section about the installer here
} }
</script> </script>
::: warning Dependencies for a generator here
- loader libraries in meta
:::
Add an instance generator to the installer and describe it here\ Add an instance generator to the installer and describe it here\
**or**\ **or**\
PR direct support to Prism PR direct support to Prism

View file

@ -3,76 +3,7 @@
"name": "FrogLoader", "name": "FrogLoader",
"uid": "dev.frogmc.frogloader", "uid": "dev.frogmc.frogloader",
"version": "$loader_version", "version": "$loader_version",
"libraries": [ "libraries": [ ],
{
"downloads": {
"artifact": {
"url": "$loader_url"
}
},
"name": "dev.frogmc:frogloader:$loader_version"
},
{
"name": "dev.frogmc:thyroxine:$thyroxine_version",
"downloads": {
"artifact": {
"url": "$thyroxine_url"
}
}
},
{
"name": "net.fabricmc:sponge-mixin:0.14.0+mixin.0.8.6",
"url": "https://maven.fabricmc.net"
},
{
"name": "io.github.llamalad7:mixinextras-common:0.3.6",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "com.electronwill.night-config:toml:3.7.2",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "com.electronwill.night-config:core:3.7.2",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.ow2.asm:asm:9.7",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.ow2.asm:asm-commons:9.7",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.ow2.asm:asm-tree:9.7",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.ow2.asm:asm-util:9.7",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.ow2.asm:asm-analysis:9.7",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.slf4j:slf4j-api:2.0.13",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.apache.logging.log4j:log4j-slf4j2-impl:2.23.1",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.apache.logging.log4j:log4j-api:2.23.1",
"url": "https://repo.maven.apache.org/maven2"
},
{
"name": "org.apache.logging.log4j:log4j-core:2.23.1",
"url": "https://repo.maven.apache.org/maven2"
}
],
"mainClass": "dev.frogmc.frogloader.impl.launch.client.FrogClient", "mainClass": "dev.frogmc.frogloader.impl.launch.client.FrogClient",
"type": "snapshot" "type": "snapshot"
} }