template generator

This commit is contained in:
moehreag 2024-06-08 17:27:05 +02:00
parent a54b219c9f
commit 6720aa156a
11 changed files with 230 additions and 37 deletions

View file

@ -15,7 +15,7 @@ import {
const members = [ const members = [
{ {
avatar: 'https://git.frogmc.dev/avatars/4f143e75d07e7d7396d8f2129ffb913e644e51f8dae9a171db9c3b522595799e', avatar: 'https://git.frogmc.dev/owlsys.png',
name: 'Owlsys', name: 'Owlsys',
title: 'Developer', title: 'Developer',
links: [ links: [
@ -23,7 +23,7 @@ const members = [
] ]
}, },
{ {
avatar: '', avatar: 'https://git.frogmc.dev/kode.png',
name: 'TheKodeToad', name: 'TheKodeToad',
title: 'Developer', title: 'Developer',
links: [ links: [
@ -31,7 +31,7 @@ const members = [
] ]
}, },
{ {
avatar: '', avatar: 'https://git.frogmc.dev/ecorous.png',
name: 'Ecorous', name: 'Ecorous',
title: 'Sysadmin', title: 'Sysadmin',
links: [ links: [
@ -39,7 +39,7 @@ const members = [
] ]
}, },
{ {
avatar: '', avatar: 'https://git.frogmc.dev/ampflower.png',
name: 'Ampflower', name: 'Ampflower',
title: 'Developer', title: 'Developer',
links: [ links: [
@ -47,7 +47,7 @@ const members = [
] ]
}, },
{ {
avatar: '', avatar: 'https://git.frogmc.dev/maemachinebroke.png',
name: 'MaeMachineBroke', name: 'MaeMachineBroke',
title: 'Moderator', title: 'Moderator',
links: [ links: [

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

View file

@ -17,6 +17,7 @@
"vue": "^3.4.27" "vue": "^3.4.27"
}, },
"dependencies": { "dependencies": {
"file-saver": "^2.0.5",
"jszip": "^3.10.1", "jszip": "^3.10.1",
"node-fetch": "^3.3.2" "node-fetch": "^3.3.2"
} }

View file

@ -8,6 +8,9 @@ importers:
.: .:
dependencies: dependencies:
file-saver:
specifier: ^2.0.5
version: 2.0.5
jszip: jszip:
specifier: ^3.10.1 specifier: ^3.10.1
version: 3.10.1 version: 3.10.1
@ -497,6 +500,9 @@ packages:
resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==} resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==}
engines: {node: ^12.20 || >= 14.13} engines: {node: ^12.20 || >= 14.13}
file-saver@2.0.5:
resolution: {integrity: sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==}
focus-trap@7.5.4: focus-trap@7.5.4:
resolution: {integrity: sha512-N7kHdlgsO/v+iD/dMoJKtsSqs5Dz/dXZVebRgJw23LDk+jMi/974zyiOYDziY2JPp8xivq9BmUGwIJMiuSBi7w==} resolution: {integrity: sha512-N7kHdlgsO/v+iD/dMoJKtsSqs5Dz/dXZVebRgJw23LDk+jMi/974zyiOYDziY2JPp8xivq9BmUGwIJMiuSBi7w==}
@ -1126,6 +1132,8 @@ snapshots:
node-domexception: 1.0.0 node-domexception: 1.0.0
web-streams-polyfill: 3.3.3 web-streams-polyfill: 3.3.3
file-saver@2.0.5: {}
focus-trap@7.5.4: focus-trap@7.5.4:
dependencies: dependencies:
tabbable: 6.2.0 tabbable: 6.2.0

View file

@ -13,7 +13,7 @@ repositories {
} }
minecraft(libs.versions.minecraft).loader("$loader_version") minecraft(libs.versions.minecraft).loader(libs.versions.loader)
java { java {
sourceCompatibility = JavaVersion.VERSION_21 sourceCompatibility = JavaVersion.VERSION_21

View file

@ -1,7 +1,9 @@
[versions] [versions]
minecraft = "$game_version" minecraft = "$game_version"
loader = "$loader_version"
[libraries] [libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
loader = { module = "dev.frogmc:frogloader", version.ref = "loader" }

View file

@ -1,6 +1,6 @@
#Mon May 13 10:13:59 CEST 2024 #Mon May 13 10:13:59 CEST 2024
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View file

@ -12,5 +12,5 @@ pluginManagement {
} }
} }
rootProject.name = "$mod_name" rootProject.name = "$mod_id"

View file

@ -5,15 +5,16 @@ format_version = "1.0.0"
id = "$mod_id" id = "$mod_id"
name = "$mod_name" name = "$mod_name"
version = "$version" version = "$version"
license = "CC0-1.0" license = "$license"
credits = [ credits = [
{ name = "You", roles = ["author", "other_role"] } { name = "You", roles = ["author", "other_role"] }
] ]
[frog.dependencies] [frog.dependencies]
depends = {
{ "id" = "minecraft", versions = "~$game_version", name = "Minecraft", link = "https://minecraft.net" }
{ "id" = "frogloader", versions = ">=$loader_version", name = "Frog Loader", link = "https://frogmc.dev" }
}
[frog.extensions] [frog.extensions]
mixin_config = "example_mod.mixins.json" mixin_config = "$mod_id.mixins.json"
frog_aw = "example_mod.accesswidener"
pre_launch = "com/example/frog/PreLaunch"

View file

@ -10,52 +10,233 @@ lastUpdated: false
<!-- This is a mess! Someone improve this please. --> <!-- This is a mess! Someone improve this please. -->
<script setup> <script setup>
import { ref } from 'vue' import JSZip from 'jszip'
import { ref, onMounted } from 'vue'
import { saveAs } from 'file-saver'
const gameVersion = ref('loading') const gameVersion = ref('loading')
const showSnapshots = ref(false) const showSnapshots = ref()
const versionSelector = ref() const versionSelector = ref()
const modIdRef = ref()
const modNameRef = ref()
const mavenGroupRef = ref()
const licenseRef = ref()
let releases = []
let snapshots = []
let versions = []
let latestLoader
let latestPhytotelma
async function getGameVersions() { async function getGameVersions() {
const response = await fetch("https://piston-meta.mojang.com/mc/game/version_manifest_v2.json") const response = await fetch("https://piston-meta.mojang.com/mc/game/version_manifest_v2.json")
return await response.json() return await response.json()
} }
function getVersions() {
versionSelector.value.innerHTML = ""
for (let version of releases) {
versionSelector.value.innerHTML += "<option value=\""+version.id+"\">"+version.id+"</option>"
}
if (showSnapshots.value) {
for (let version of snapshots) {
versionSelector.value.innerHTML += "<option value=\""+version.id+"\">"+version.id+"</option>"
}
}
}
onMounted(() => {
getGameVersions().then((v) => { getGameVersions().then((v) => {
//versionSelector.value.innerHTML = "" versions = v.versions
//const versions = ref(v.versions) for (let version of versions){
//for (let version of v.versions){ if (version.type === "snapshot"){
// if ((version.type === "snapshot") == showSnapshots.value){ snapshots.push(version)
// versionSelector.value.innerHTML += "\n<option value=\""+version.id+"\">"+version.id+"</option>" } else {
// } releases.push(version)
//} }
}
getVersions()
})
getLatestProjectVersions()
}) })
function getLatestProjectVersions() {
fetchVersionFromMaven("snapshots", "frogloader").then((v) => {
latestLoader = v
document.getElementById("frogLoaderVersionBadge").innerHTML = v
})
fetchVersionFromMaven("snapshots", "phytotelma").then((v) => {
latestPhytotelma = v
document.getElementById("phytotelmaVersionBadge").innerHTML = v
})
}
async function fetchVersionFromMaven(repository, name) {
const response = await fetch("https://maven.frogmc.dev/"+repository+"/dev/frogmc/"+name+"/maven-metadata.xml")
const text = await response.text()
const parser = new DOMParser()
const doc = parser.parseFromString(text, "text/xml")
return doc.getElementsByTagName("latest")[0].textContent
}
function generate() {
let zip = JSZip()
let gradle = zip.folder("gradle")
let wrapper = gradle.folder("wrapper")
let promises = []
promises.push(
readAsset("/resources/template/gradle/libs.versions.toml").then((data) => {
gradle.file("libs.versions.toml", data)
})
)
promises.push(
readAssetBinary("/resources/template/gradle/wrapper/gradle-wrapper.properties").then((data) => {
wrapper.file("gradle-wrapper.properties", data)
})
)
promises.push(
readAssetBinary("/resources/template/gradle/wrapper/gradle-wrapper.jar").then((data) => {
wrapper.file("gradle-wrapper.jar", data)
})
)
promises.push(
readAsset("/resources/template/.gitignore").then((data) => {
zip.file(".gitignore", data)
})
)
promises.push(
readAsset("/resources/template/build.gradle.kts").then((data) => {
zip.file("build.gradle.kts", data)
})
)
promises.push(
readAssetBinary("/resources/template/gradlew.sh").then((data) => {
zip.file("gradlew", data)
})
)
promises.push(
readAssetBinary("/resources/template/gradlew.bat").then((data) => {
zip.file("gradlew.bat", data)
})
)
promises.push(
readAsset("/resources/template/build.gradle.kts").then((data) => {
zip.file("build.gradle.kts", data)
})
)
promises.push(
readAsset("/resources/template/settings.gradle.kts").then((data) => {
zip.file("settings.gradle.kts", data)
})
)
let src = zip.folder("src")
let main = src.folder("main")
let java = main.folder("java")
let resources = main.folder("resources")
promises.push(
readAsset("/resources/template/src/main/resources/frog.mod.toml").then((data) => {
resources.file("frog.mod.toml", data)
})
)
promises.push(
readAsset("/resources/template/src/main/resources/example_mod.mixins.json").then((data) => {
resources.file(modIdRef.value+".mixins.json", data)
})
)
Promise.all(promises).then((values) => {
zip.generateAsync({type:"blob"}).then(function (blob) {
saveAs(blob, modIdRef.value+"_template.zip")
}, function (err) {
alert("Failed to download generated zip file, please report this!")
})
})
}
async function readAssetBinary(path) {
const response = await fetch(path)
return await response.blob()
}
async function readAsset(path){
const response = await fetch(path)
return await response.text().then((data) => {
data = data.replace(/\\$mod_id/g, modIdRef.value)
data = data.replace(/\\$mod_name/g, modNameRef.value)
data = data.replace(/\\$maven_group/g, mavenGroupRef.value)
data = data.replace(/\\$license/g, licenseRef.value)
data = data.replace(/\\$loader_version/g, latestLoader)
data = data.replace(/\\$phytotelma_version/g, latestPhytotelma)
data = data.replace(/\\$game_version/g, versionSelector.value.selected)
return data
})
}
</script> </script>
<style> <style>
select { select, input {
margin-left: 15px; margin-left: 15px;
margin-right: 15px;
padding: 1px 8px; padding: 1px 8px;
border-radius: 12px; border-radius: 12px;
}
select {
text-align: center; text-align: center;
} }
input {
border: 4px solid var(--vp-c-brand-soft);
}
.generate {
padding: 4px;
border: 4px solid var(--vp-c-brand-soft);
//border-color: var(--vp-c-brand-3);
border-radius: 18px;
}
.generate:hover {
border-color: var(--vp-c-brand-2);
}
</style> </style>
# {{ $frontmatter.title }} # {{ $frontmatter.title }}
### Inputs ## Inputs
<div id="inputs">
<table>
<tbody>
<tr>
<td>Mod Id</td>
<td><input v-model="modIdRef" /></td>
</tr>
<tr>
<td>Mod Name</td>
<td><input v-model="modNameRef" /></td>
</tr>
<tr>
<td>Maven Group</td>
<td><input v-model="mavenGroupRef" /></td>
</tr>
<tr>
<td>License (SPDX)</td>
<td><input v-model="licenseRef" /></td>
</tr>
<tr>
<td>Version</td>
<td>
<select v-model="gameVersion" ref="versionSelector">
<option value="loading">Loading Versions...</option>
</select>
<input type="checkbox" v-model="showSnapshots" @change="getVersions">Show snapshots</input>
</td>
</tr>
</tbody>
</table>
<button class="generate" @click="generate">Generate</button>
</div>
## Latest Versions
<input style="border: 4px solid var(--vp-c-brand-soft)" /> [FrogLoader](/contributing/tools.md#frogloader) <Badge type="tip" id="frogLoaderVersionBadge">Loading...</Badge>
<select v-model="gameVersion" ref="versionSelector">
<option v-for="v in versions" :value="v.id">{{ v.id }}</option>
</select>
<input type="checkbox" v-model="snapshotsEnabled">Show snapshots</input>
### Latest Versions
[Phytotelma](/contributing/tools.md#phytotelma) <Badge type="tip" id="phytotelmaVersionBadge">Loading...</Badge>