generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: display codename for patch names
- Loading branch information
Showing
3 changed files
with
19 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters