fix: display codename for patch names
This commit is contained in:
parent
4779defeb5
commit
10c53f720d
|
@ -1,7 +1,8 @@
|
||||||
# ReVanced Patches
|
# ReVanced Patches
|
||||||
|
|
||||||
🧩 Official patches by ReVanced
|
🧩 Official patches by ReVanced
|
||||||
|
|
||||||
# Patch list
|
# List of available patches
|
||||||
|
|
||||||
| 💊 Patch | 📜 Description | 🎯 Target Package | 🏹 Target Version |
|
| 💊 Patch | 📜 Description | 🎯 Target Package | 🏹 Target Version |
|
||||||
|:--------:|:--------------:|:-----------------:|:-----------------:|
|
|:--------:|:--------------:|:-----------------:|:-----------------:|
|
||||||
|
|
|
@ -1,41 +1,38 @@
|
||||||
package app.revanced.patches.meta.readme
|
package app.revanced.meta.readme
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
import kotlin.io.writeText
|
|
||||||
import kotlin.collections.first
|
|
||||||
import app.revanced.patcher.util.patch.implementation.JarPatchBundle
|
|
||||||
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
|
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
|
||||||
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
|
||||||
import app.revanced.patcher.extensions.PatchExtensions.description
|
import app.revanced.patcher.extensions.PatchExtensions.description
|
||||||
|
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
||||||
|
import app.revanced.patcher.util.patch.implementation.JarPatchBundle
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
class Generator {
|
class Generator {
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
val buildDir = File("build/libs/")
|
val buildDir = File("build/libs/")
|
||||||
val buildJar = buildDir.listFiles().first { it.name.startsWith("revanced-patches-") && it.name.endsWith(".jar") }
|
val buildJar =
|
||||||
|
buildDir.listFiles()?.first { it.name.startsWith("revanced-patches-") && it.name.endsWith(".jar") }!!
|
||||||
|
|
||||||
val bundle = JarPatchBundle(buildJar.absolutePath).loadPatches()
|
val bundle = JarPatchBundle(buildJar.absolutePath).loadPatches()
|
||||||
|
|
||||||
val table = StringBuilder()
|
val patches = StringBuilder()
|
||||||
|
|
||||||
for (patch in bundle) {
|
for (patch in bundle) {
|
||||||
val humanName =
|
val patchName = patch.patchName
|
||||||
patch.patchName.split('-').map { it.replaceFirstChar { it.uppercase() } }.joinToString(" ")
|
|
||||||
|
|
||||||
val compatiblePackage = patch.compatiblePackages?.first()
|
val compatiblePackage = patch.compatiblePackages?.first()
|
||||||
val latestVersion = compatiblePackage?.versions?.maxByOrNull { it.replace(".", "").toInt() } ?: "all"
|
val latestVersion = compatiblePackage?.versions?.maxByOrNull { it.replace(".", "").toInt() } ?: "all"
|
||||||
|
|
||||||
table.appendLine("|$humanName|${patch.description}|`${compatiblePackage?.name}`|$latestVersion|")
|
patches.appendLine("| `$patchName` | ${patch.description} | `${compatiblePackage?.name}`| $latestVersion |")
|
||||||
}
|
}
|
||||||
|
|
||||||
val readMeTemplateFile = File("README-template.md")
|
val readMeTemplateFile = File("README-template.md")
|
||||||
val readMeTemplate = Template(readMeTemplateFile.readText())
|
val readmeTemplate = Template(readMeTemplateFile.readText())
|
||||||
|
|
||||||
readMeTemplate.replaceVariable("table", table.toString())
|
readmeTemplate.replaceVariable("table", patches.toString())
|
||||||
|
|
||||||
val readMeFile = File("README.md")
|
val readme = File("README.md")
|
||||||
readMeFile.writeText(readMeTemplate.toString())
|
readme.writeText(readmeTemplate.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package app.revanced.patches.meta.readme
|
package app.revanced.meta.readme
|
||||||
|
|
||||||
class Template(val template: String) {
|
class Template(template: String) {
|
||||||
val result: StringBuilder = StringBuilder(template)
|
val result: StringBuilder = StringBuilder(template)
|
||||||
|
|
||||||
fun replaceVariable(name: String, value: String) {
|
fun replaceVariable(name: String, value: String) {
|
||||||
val regex = Regex("\\{\\{\\s?$name\\s?\\}\\}")
|
val regex = Regex("{{\\s?$name\\s?}}")
|
||||||
val range = regex.find(result)!!.range
|
val range = regex.find(result)!!.range
|
||||||
|
|
||||||
result.replace(range.start, range.endInclusive + 1, value)
|
result.replace(range.first, range.last + 1, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String = result.toString()
|
override fun toString(): String = result.toString()
|
||||||
|
|
Loading…
Reference in a new issue