template generator
This commit is contained in:
parent
a54b219c9f
commit
6720aa156a
10
about.md
10
about.md
|
@ -15,7 +15,7 @@ import {
|
|||
|
||||
const members = [
|
||||
{
|
||||
avatar: 'https://git.frogmc.dev/avatars/4f143e75d07e7d7396d8f2129ffb913e644e51f8dae9a171db9c3b522595799e',
|
||||
avatar: 'https://git.frogmc.dev/owlsys.png',
|
||||
name: 'Owlsys',
|
||||
title: 'Developer',
|
||||
links: [
|
||||
|
@ -23,7 +23,7 @@ const members = [
|
|||
]
|
||||
},
|
||||
{
|
||||
avatar: '',
|
||||
avatar: 'https://git.frogmc.dev/kode.png',
|
||||
name: 'TheKodeToad',
|
||||
title: 'Developer',
|
||||
links: [
|
||||
|
@ -31,7 +31,7 @@ const members = [
|
|||
]
|
||||
},
|
||||
{
|
||||
avatar: '',
|
||||
avatar: 'https://git.frogmc.dev/ecorous.png',
|
||||
name: 'Ecorous',
|
||||
title: 'Sysadmin',
|
||||
links: [
|
||||
|
@ -39,7 +39,7 @@ const members = [
|
|||
]
|
||||
},
|
||||
{
|
||||
avatar: '',
|
||||
avatar: 'https://git.frogmc.dev/ampflower.png',
|
||||
name: 'Ampflower',
|
||||
title: 'Developer',
|
||||
links: [
|
||||
|
@ -47,7 +47,7 @@ const members = [
|
|||
]
|
||||
},
|
||||
{
|
||||
avatar: '',
|
||||
avatar: 'https://git.frogmc.dev/maemachinebroke.png',
|
||||
name: 'MaeMachineBroke',
|
||||
title: 'Moderator',
|
||||
links: [
|
||||
|
|
BIN
favicon.ico
Normal file
BIN
favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.9 KiB |
|
@ -17,6 +17,7 @@
|
|||
"vue": "^3.4.27"
|
||||
},
|
||||
"dependencies": {
|
||||
"file-saver": "^2.0.5",
|
||||
"jszip": "^3.10.1",
|
||||
"node-fetch": "^3.3.2"
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@ importers:
|
|||
|
||||
.:
|
||||
dependencies:
|
||||
file-saver:
|
||||
specifier: ^2.0.5
|
||||
version: 2.0.5
|
||||
jszip:
|
||||
specifier: ^3.10.1
|
||||
version: 3.10.1
|
||||
|
@ -497,6 +500,9 @@ packages:
|
|||
resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==}
|
||||
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:
|
||||
resolution: {integrity: sha512-N7kHdlgsO/v+iD/dMoJKtsSqs5Dz/dXZVebRgJw23LDk+jMi/974zyiOYDziY2JPp8xivq9BmUGwIJMiuSBi7w==}
|
||||
|
||||
|
@ -1126,6 +1132,8 @@ snapshots:
|
|||
node-domexception: 1.0.0
|
||||
web-streams-polyfill: 3.3.3
|
||||
|
||||
file-saver@2.0.5: {}
|
||||
|
||||
focus-trap@7.5.4:
|
||||
dependencies:
|
||||
tabbable: 6.2.0
|
||||
|
|
|
@ -13,7 +13,7 @@ repositories {
|
|||
|
||||
}
|
||||
|
||||
minecraft(libs.versions.minecraft).loader("$loader_version")
|
||||
minecraft(libs.versions.minecraft).loader(libs.versions.loader)
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
[versions]
|
||||
|
||||
minecraft = "$game_version"
|
||||
loader = "$loader_version"
|
||||
|
||||
[libraries]
|
||||
|
||||
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
|
||||
loader = { module = "dev.frogmc:frogloader", version.ref = "loader" }
|
|
@ -1,6 +1,6 @@
|
|||
#Mon May 13 10:13:59 CEST 2024
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
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
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
|
@ -12,5 +12,5 @@ pluginManagement {
|
|||
}
|
||||
}
|
||||
|
||||
rootProject.name = "$mod_name"
|
||||
rootProject.name = "$mod_id"
|
||||
|
||||
|
|
|
@ -5,15 +5,16 @@ format_version = "1.0.0"
|
|||
id = "$mod_id"
|
||||
name = "$mod_name"
|
||||
version = "$version"
|
||||
license = "CC0-1.0"
|
||||
license = "$license"
|
||||
credits = [
|
||||
{ name = "You", roles = ["author", "other_role"] }
|
||||
]
|
||||
|
||||
[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]
|
||||
mixin_config = "example_mod.mixins.json"
|
||||
frog_aw = "example_mod.accesswidener"
|
||||
pre_launch = "com/example/frog/PreLaunch"
|
||||
mixin_config = "$mod_id.mixins.json"
|
||||
|
|
227
template.md
227
template.md
|
@ -10,52 +10,233 @@ lastUpdated: false
|
|||
|
||||
<!-- This is a mess! Someone improve this please. -->
|
||||
<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 showSnapshots = ref(false)
|
||||
const showSnapshots = 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() {
|
||||
const response = await fetch("https://piston-meta.mojang.com/mc/game/version_manifest_v2.json")
|
||||
return await response.json()
|
||||
}
|
||||
|
||||
getGameVersions().then((v) => {
|
||||
//versionSelector.value.innerHTML = ""
|
||||
//const versions = ref(v.versions)
|
||||
//for (let version of v.versions){
|
||||
// if ((version.type === "snapshot") == showSnapshots.value){
|
||||
// versionSelector.value.innerHTML += "\n<option value=\""+version.id+"\">"+version.id+"</option>"
|
||||
// }
|
||||
//}
|
||||
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) => {
|
||||
versions = v.versions
|
||||
for (let version of versions){
|
||||
if (version.type === "snapshot"){
|
||||
snapshots.push(version)
|
||||
} 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>
|
||||
<style>
|
||||
select {
|
||||
select, input {
|
||||
margin-left: 15px;
|
||||
margin-right: 15px;
|
||||
padding: 1px 8px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
select {
|
||||
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>
|
||||
|
||||
# {{ $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)" />
|
||||
|
||||
|
||||
<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
|
||||
[FrogLoader](/contributing/tools.md#frogloader) <Badge type="tip" id="frogLoaderVersionBadge">Loading...</Badge>
|
||||
|
||||
[Phytotelma](/contributing/tools.md#phytotelma) <Badge type="tip" id="phytotelmaVersionBadge">Loading...</Badge>
|
||||
|
||||
|
|
Loading…
Reference in a new issue