mirror of
https://github.com/revanced/revanced-patches
synced 2024-11-30 17:42:52 +01:00
fix: display codename for patch names
This commit is contained in:
parent
4779defeb5
commit
10c53f720d
@ -1,7 +1,8 @@
|
||||
# ReVanced Patches
|
||||
|
||||
🧩 Official patches by ReVanced
|
||||
|
||||
# Patch list
|
||||
# List of available patches
|
||||
|
||||
| 💊 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.patchName
|
||||
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 {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
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 table = StringBuilder()
|
||||
val patches = StringBuilder()
|
||||
|
||||
for (patch in bundle) {
|
||||
val humanName =
|
||||
patch.patchName.split('-').map { it.replaceFirstChar { it.uppercase() } }.joinToString(" ")
|
||||
|
||||
val patchName = patch.patchName
|
||||
val compatiblePackage = patch.compatiblePackages?.first()
|
||||
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 readMeTemplate = Template(readMeTemplateFile.readText())
|
||||
val readmeTemplate = Template(readMeTemplateFile.readText())
|
||||
|
||||
readMeTemplate.replaceVariable("table", table.toString())
|
||||
readmeTemplate.replaceVariable("table", patches.toString())
|
||||
|
||||
val readMeFile = File("README.md")
|
||||
readMeFile.writeText(readMeTemplate.toString())
|
||||
val readme = File("README.md")
|
||||
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)
|
||||
|
||||
fun replaceVariable(name: String, value: String) {
|
||||
val regex = Regex("\\{\\{\\s?$name\\s?\\}\\}")
|
||||
val regex = Regex("{{\\s?$name\\s?}}")
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user