mirror of
https://github.com/revanced/revanced-cli.git
synced 2025-05-02 15:44:27 +02:00
Compare commits
4 Commits
main
...
v5.0.2-dev
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f29eda8674 | ||
![]() |
bba90fede8 | ||
![]() |
1717cc66f7 | ||
![]() |
0c53a2d1d7 |
14
CHANGELOG.md
14
CHANGELOG.md
@ -1,3 +1,17 @@
|
|||||||
|
## [5.0.2-dev.2](https://github.com/ReVanced/revanced-cli/compare/v5.0.2-dev.1...v5.0.2-dev.2) (2025-04-25)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Do not print patch description if null ([bba90fe](https://github.com/ReVanced/revanced-cli/commit/bba90fede85e4632efb9509e5bcf9091a9435549))
|
||||||
|
|
||||||
|
## [5.0.2-dev.1](https://github.com/ReVanced/revanced-cli/compare/v5.0.1...v5.0.2-dev.1) (2025-04-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Group `mount` and `install` options into an argument group ([#364](https://github.com/ReVanced/revanced-cli/issues/364)) ([0c53a2d](https://github.com/ReVanced/revanced-cli/commit/0c53a2d1d75d3d934d134594751fe6cd0b000d1a))
|
||||||
|
|
||||||
## [5.0.1](https://github.com/ReVanced/revanced-cli/compare/v5.0.0...v5.0.1) (2025-04-14)
|
## [5.0.1](https://github.com/ReVanced/revanced-cli/compare/v5.0.0...v5.0.1) (2025-04-14)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
org.gradle.parallel = true
|
org.gradle.parallel = true
|
||||||
org.gradle.caching = true
|
org.gradle.caching = true
|
||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
version = 5.0.1
|
version = 5.0.2-dev.2
|
||||||
|
@ -85,58 +85,55 @@ internal object ListPatchesCommand : Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun PatchOption<*>.buildString() =
|
fun PatchOption<*>.buildString() = buildString {
|
||||||
|
appendLine("Title: $title")
|
||||||
|
description?.let { appendLine("Description: $it") }
|
||||||
|
appendLine("Required: $required")
|
||||||
|
default?.let {
|
||||||
|
appendLine("Key: $key")
|
||||||
|
append("Default: $it")
|
||||||
|
} ?: append("Key: $key")
|
||||||
|
|
||||||
|
values?.let { values ->
|
||||||
|
appendLine("\nPossible values:")
|
||||||
|
append(values.map { "${it.value} (${it.key})" }.joinToString("\n").prependIndent("\t"))
|
||||||
|
}
|
||||||
|
|
||||||
|
append("\nType: $type")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun IndexedValue<Patch<*>>.buildString() = let { (index, patch) ->
|
||||||
buildString {
|
buildString {
|
||||||
appendLine("Title: $title")
|
if (withIndex) appendLine("Index: $index")
|
||||||
description?.let { appendLine("Description: $it") }
|
|
||||||
appendLine("Required: $required")
|
|
||||||
default?.let {
|
|
||||||
appendLine("Key: $key")
|
|
||||||
append("Default: $it")
|
|
||||||
} ?: append("Key: $key")
|
|
||||||
|
|
||||||
values?.let { values ->
|
append("Name: ${patch.name}")
|
||||||
appendLine("\nPossible values:")
|
|
||||||
append(values.map { "${it.value} (${it.key})" }.joinToString("\n").prependIndent("\t"))
|
if (withDescriptions) patch.description?.let { append("\nDescription: $it") }
|
||||||
|
|
||||||
|
append("\nEnabled: ${patch.use}")
|
||||||
|
|
||||||
|
if (withOptions && patch.options.isNotEmpty()) {
|
||||||
|
appendLine("\nOptions:")
|
||||||
|
append(
|
||||||
|
patch.options.values.joinToString("\n\n") { option ->
|
||||||
|
option.buildString()
|
||||||
|
}.prependIndent("\t"),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
append("\nType: $type")
|
if (withPackages && patch.compatiblePackages != null) {
|
||||||
}
|
appendLine("\nCompatible packages:")
|
||||||
|
append(
|
||||||
fun IndexedValue<Patch<*>>.buildString() =
|
patch.compatiblePackages!!.joinToString("\n") {
|
||||||
let { (index, patch) ->
|
it.buildString()
|
||||||
buildString {
|
}.prependIndent("\t"),
|
||||||
if (withIndex) appendLine("Index: $index")
|
)
|
||||||
|
|
||||||
append("Name: ${patch.name}")
|
|
||||||
|
|
||||||
if (withDescriptions) append("\nDescription: ${patch.description}")
|
|
||||||
|
|
||||||
append("\nEnabled: ${patch.use}")
|
|
||||||
|
|
||||||
if (withOptions && patch.options.isNotEmpty()) {
|
|
||||||
appendLine("\nOptions:")
|
|
||||||
append(
|
|
||||||
patch.options.values.joinToString("\n\n") { option ->
|
|
||||||
option.buildString()
|
|
||||||
}.prependIndent("\t"),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (withPackages && patch.compatiblePackages != null) {
|
|
||||||
appendLine("\nCompatible packages:")
|
|
||||||
append(
|
|
||||||
patch.compatiblePackages!!.joinToString("\n") {
|
|
||||||
it.buildString()
|
|
||||||
}.prependIndent("\t"),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun Patch<*>.filterCompatiblePackages(name: String) =
|
fun Patch<*>.filterCompatiblePackages(name: String) = compatiblePackages?.any { (compatiblePackageName, _) -> compatiblePackageName == name }
|
||||||
compatiblePackages?.any { (compatiblePackageName, _) -> compatiblePackageName == name }
|
?: withUniversalPatches
|
||||||
?: withUniversalPatches
|
|
||||||
|
|
||||||
val patches = loadPatchesFromJar(patchesFiles).withIndex().toList()
|
val patches = loadPatchesFromJar(patchesFiles).withIndex().toList()
|
||||||
|
|
||||||
|
@ -115,21 +115,27 @@ internal object PatchCommand : Runnable {
|
|||||||
this.outputFilePath = outputFilePath?.absoluteFile
|
this.outputFilePath = outputFilePath?.absoluteFile
|
||||||
}
|
}
|
||||||
|
|
||||||
@CommandLine.Option(
|
@ArgGroup(exclusive = false, multiplicity = "0..1")
|
||||||
names = ["-i", "--install"],
|
internal var installation: Installation? = null
|
||||||
description = ["Serial of the ADB device to install to. If not specified, the first connected device will be used."],
|
|
||||||
// Empty string to indicate that the first connected device should be used.
|
|
||||||
fallbackValue = "",
|
|
||||||
arity = "0..1",
|
|
||||||
)
|
|
||||||
private var deviceSerial: String? = null
|
|
||||||
|
|
||||||
@CommandLine.Option(
|
internal class Installation {
|
||||||
names = ["--mount"],
|
@CommandLine.Option(
|
||||||
description = ["Install the patched APK file by mounting."],
|
names = ["-i", "--install"],
|
||||||
showDefaultValue = ALWAYS,
|
required = true,
|
||||||
)
|
description = ["Serial of the ADB device to install to. If not specified, the first connected device will be used."],
|
||||||
private var mount: Boolean = false
|
fallbackValue = "", // Empty string is used to select the first of connected devices.
|
||||||
|
arity = "0..1",
|
||||||
|
)
|
||||||
|
internal var deviceSerial: String? = null
|
||||||
|
|
||||||
|
@CommandLine.Option(
|
||||||
|
names = ["--mount"],
|
||||||
|
required = false,
|
||||||
|
description = ["Install the patched APK file by mounting."],
|
||||||
|
showDefaultValue = ALWAYS,
|
||||||
|
)
|
||||||
|
internal var mount: Boolean = false
|
||||||
|
}
|
||||||
|
|
||||||
@CommandLine.Option(
|
@CommandLine.Option(
|
||||||
names = ["--keystore"],
|
names = ["--keystore"],
|
||||||
@ -245,11 +251,11 @@ internal object PatchCommand : Runnable {
|
|||||||
keyStoreFilePath ?: outputFilePath.parentFile
|
keyStoreFilePath ?: outputFilePath.parentFile
|
||||||
.resolve("${outputFilePath.nameWithoutExtension}.keystore")
|
.resolve("${outputFilePath.nameWithoutExtension}.keystore")
|
||||||
|
|
||||||
val installer = if (deviceSerial != null) {
|
val installer = if (installation?.deviceSerial != null) {
|
||||||
val deviceSerial = deviceSerial!!.ifEmpty { null }
|
val deviceSerial = installation?.deviceSerial!!.ifEmpty { null }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mount) {
|
if (installation?.mount == true) {
|
||||||
AdbRootInstaller(deviceSerial)
|
AdbRootInstaller(deviceSerial)
|
||||||
} else {
|
} else {
|
||||||
AdbInstaller(deviceSerial)
|
AdbInstaller(deviceSerial)
|
||||||
@ -332,7 +338,7 @@ internal object PatchCommand : Runnable {
|
|||||||
apk.copyTo(temporaryFilesPath.resolve(apk.name), overwrite = true).apply {
|
apk.copyTo(temporaryFilesPath.resolve(apk.name), overwrite = true).apply {
|
||||||
patcherResult.applyTo(this)
|
patcherResult.applyTo(this)
|
||||||
}.let { patchedApkFile ->
|
}.let { patchedApkFile ->
|
||||||
if (!mount) {
|
if (installation?.mount != true) {
|
||||||
ApkUtils.signApk(
|
ApkUtils.signApk(
|
||||||
patchedApkFile,
|
patchedApkFile,
|
||||||
outputFilePath,
|
outputFilePath,
|
||||||
@ -355,7 +361,7 @@ internal object PatchCommand : Runnable {
|
|||||||
|
|
||||||
// region Install.
|
// region Install.
|
||||||
|
|
||||||
deviceSerial?.let {
|
installation?.deviceSerial?.let {
|
||||||
runBlocking {
|
runBlocking {
|
||||||
when (val result = installer!!.install(Installer.Apk(outputFilePath, packageName))) {
|
when (val result = installer!!.install(Installer.Apk(outputFilePath, packageName))) {
|
||||||
RootInstallerResult.FAILURE -> logger.severe("Failed to mount the patched APK file")
|
RootInstallerResult.FAILURE -> logger.severe("Failed to mount the patched APK file")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user