mirror of
https://github.com/ReVanced/revanced-cli.git
synced 2026-01-18 17:03:58 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1bcd1fdaf | ||
|
|
206f2029d7 | ||
|
|
04e0027c08 | ||
|
|
e76983e01c | ||
|
|
11d67bc1ea | ||
|
|
cabd32fda4 | ||
|
|
61235d7c41 | ||
|
|
817154dd66 | ||
|
|
c76da7e5ff | ||
|
|
d946333c96 | ||
|
|
97a036bfbc | ||
|
|
153d8ce746 | ||
|
|
5cd3ea291c |
1
.github/workflows/release.yml
vendored
1
.github/workflows/release.yml
vendored
@@ -1,5 +1,6 @@
|
|||||||
name: Release
|
name: Release
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|||||||
2
.idea/vcs.xml
generated
2
.idea/vcs.xml
generated
@@ -8,5 +8,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/../revanced-patcher" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/../revanced-patches" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
21
CHANGELOG.md
21
CHANGELOG.md
@@ -1,3 +1,24 @@
|
|||||||
|
## [1.1.5](https://github.com/revanced/revanced-cli/compare/v1.1.4...v1.1.5) (2022-05-27)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* invalid code flow when adding patches ([206f202](https://github.com/revanced/revanced-cli/commit/206f2029d7498b6474c16a47cbe451c170fdd31f))
|
||||||
|
|
||||||
|
## [1.1.4](https://github.com/revanced/revanced-cli/compare/v1.1.3...v1.1.4) (2022-05-26)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* migrate from `PatchLoader.load(...)` to `JarPatchBundle(...).loadPatches()` ([cabd32f](https://github.com/revanced/revanced-cli/commit/cabd32fda41d32616a61ae450c60e1ee7c35bc59))
|
||||||
|
|
||||||
|
## [1.1.3](https://github.com/revanced/revanced-cli/compare/v1.1.2...v1.1.3) (2022-05-25)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* only accept directories when looking for files in resource patch ([c76da7e](https://github.com/revanced/revanced-cli/commit/c76da7e5ffa208860eea008dad358e4e3bb3d735))
|
||||||
|
|
||||||
## [1.1.2](https://github.com/revanced/revanced-cli/compare/v1.1.1...v1.1.2) (2022-05-22)
|
## [1.1.2](https://github.com/revanced/revanced-cli/compare/v1.1.1...v1.1.2) (2022-05-22)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.6.20"
|
kotlin("jvm") version "1.6.21"
|
||||||
id("com.github.johnrengelman.shadow") version "7.1.2"
|
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||||
java
|
java
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
@@ -23,15 +23,15 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(kotlin("stdlib"))
|
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.6.21")
|
||||||
implementation("app.revanced:revanced-patcher:+")
|
implementation("app.revanced:revanced-patcher:1.0.0-dev.17")
|
||||||
implementation("app.revanced:revanced-patches:+")
|
implementation("app.revanced:revanced-patches:1.0.0-dev.11")
|
||||||
|
|
||||||
implementation("info.picocli:picocli:+")
|
implementation("info.picocli:picocli:4.6.3")
|
||||||
|
|
||||||
implementation("com.github.li-wjohnson:jadb:master-SNAPSHOT") // using a fork instead.
|
implementation("com.github.li-wjohnson:jadb:master-SNAPSHOT") // using a fork instead.
|
||||||
implementation("org.bouncycastle:bcpkix-jdk15on:+")
|
implementation("org.bouncycastle:bcpkix-jdk15on:1.70")
|
||||||
implementation(kotlin("reflect"))
|
implementation("org.jetbrains.kotlin:kotlin-reflect:1.6.21")
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
kotlin.code.style = official
|
kotlin.code.style = official
|
||||||
version = 1.1.2
|
version = 1.1.5
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package app.revanced.cli
|
|||||||
|
|
||||||
import app.revanced.patcher.annotation.Name
|
import app.revanced.patcher.annotation.Name
|
||||||
import app.revanced.patcher.extensions.findAnnotationRecursively
|
import app.revanced.patcher.extensions.findAnnotationRecursively
|
||||||
import app.revanced.patcher.util.patch.PatchLoader
|
import app.revanced.patcher.util.patch.implementation.JarPatchBundle
|
||||||
import app.revanced.utils.adb.Adb
|
import app.revanced.utils.adb.Adb
|
||||||
import app.revanced.utils.patcher.addPatchesFiltered
|
import app.revanced.utils.patcher.addPatchesFiltered
|
||||||
import app.revanced.utils.signature.Signature
|
import app.revanced.utils.signature.Signature
|
||||||
@@ -20,7 +20,7 @@ internal object MainCommand : Runnable {
|
|||||||
internal var includedPatches = arrayOf<String>()
|
internal var includedPatches = arrayOf<String>()
|
||||||
|
|
||||||
@Option(names = ["-p", "--patches"], description = ["One or more bundles of patches"])
|
@Option(names = ["-p", "--patches"], description = ["One or more bundles of patches"])
|
||||||
internal var patchBundles = arrayOf<File>()
|
internal var patchBundles = arrayOf<String>()
|
||||||
|
|
||||||
@Option(names = ["-t", "--temp-dir"], description = ["Temporal resource cache directory"], required = true)
|
@Option(names = ["-t", "--temp-dir"], description = ["Temporal resource cache directory"], required = true)
|
||||||
internal lateinit var cacheDirectory: String
|
internal lateinit var cacheDirectory: String
|
||||||
@@ -54,13 +54,13 @@ internal object MainCommand : Runnable {
|
|||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (listOnly) {
|
if (listOnly) {
|
||||||
for (patchBundle in patchBundles)
|
for (patchBundlePath in patchBundles)
|
||||||
for (it in PatchLoader.loadFromFile(patchBundle))
|
for (it in JarPatchBundle(patchBundlePath).loadPatches())
|
||||||
println(
|
println(
|
||||||
"[available] ${
|
"[available] ${
|
||||||
it.javaClass.findAnnotationRecursively(
|
it.findAnnotationRecursively(
|
||||||
Name::class.java
|
Name::class.java
|
||||||
)?.name ?: Name::class.java.name
|
)?.name ?: it::class.java.name
|
||||||
}"
|
}"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import app.revanced.utils.patcher.applyPatchesPrint
|
|||||||
import app.revanced.utils.patcher.mergeFiles
|
import app.revanced.utils.patcher.mergeFiles
|
||||||
import app.revanced.utils.signing.Signer
|
import app.revanced.utils.signing.Signer
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.FileFilter
|
||||||
|
|
||||||
internal class Patcher {
|
internal class Patcher {
|
||||||
internal companion object {
|
internal companion object {
|
||||||
@@ -30,7 +31,7 @@ internal class Patcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (MainCommand.patchResources) {
|
if (MainCommand.patchResources) {
|
||||||
for (file in File(MainCommand.cacheDirectory).resolve("build/").listFiles()?.first()?.listFiles()!!) {
|
for (file in File(MainCommand.cacheDirectory).resolve("build/").listFiles(FileFilter { it.isDirectory })?.first()?.listFiles()!!) {
|
||||||
if (!file.isDirectory) {
|
if (!file.isDirectory) {
|
||||||
zipFileSystem.replaceFile(file.name, file.readBytes())
|
zipFileSystem.replaceFile(file.name, file.readBytes())
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
package app.revanced.patch
|
|
||||||
|
|
||||||
@@ -7,7 +7,7 @@ import app.revanced.patcher.annotation.Name
|
|||||||
import app.revanced.patcher.data.base.Data
|
import app.revanced.patcher.data.base.Data
|
||||||
import app.revanced.patcher.extensions.findAnnotationRecursively
|
import app.revanced.patcher.extensions.findAnnotationRecursively
|
||||||
import app.revanced.patcher.patch.base.Patch
|
import app.revanced.patcher.patch.base.Patch
|
||||||
import app.revanced.patcher.util.patch.PatchLoader
|
import app.revanced.patcher.util.patch.implementation.JarPatchBundle
|
||||||
|
|
||||||
fun Patcher.addPatchesFiltered(
|
fun Patcher.addPatchesFiltered(
|
||||||
packageCompatibilityFilter: Boolean = true,
|
packageCompatibilityFilter: Boolean = true,
|
||||||
@@ -19,12 +19,12 @@ fun Patcher.addPatchesFiltered(
|
|||||||
|
|
||||||
MainCommand.patchBundles.forEach { bundle ->
|
MainCommand.patchBundles.forEach { bundle ->
|
||||||
val includedPatches = mutableListOf<Patch<Data>>()
|
val includedPatches = mutableListOf<Patch<Data>>()
|
||||||
PatchLoader.loadFromFile(bundle).forEach patch@{ p ->
|
JarPatchBundle(bundle).loadPatches().forEach patch@{ p ->
|
||||||
val patch = p.getDeclaredConstructor().newInstance()
|
val patch = p.getDeclaredConstructor().newInstance()
|
||||||
|
|
||||||
val compatibilityAnnotation = patch.javaClass.findAnnotationRecursively(Compatibility::class.java)
|
val compatibilityAnnotation = patch.javaClass.findAnnotationRecursively(Compatibility::class.java)
|
||||||
|
|
||||||
val patchName = patch.javaClass.findAnnotationRecursively(Name::class.java)?.name ?: Name::class.java.name
|
val patchName = patch.javaClass.findAnnotationRecursively(Name::class.java)?.name ?: patch.javaClass.name
|
||||||
|
|
||||||
val prefix = "[skipped] $patchName"
|
val prefix = "[skipped] $patchName"
|
||||||
|
|
||||||
@@ -41,15 +41,16 @@ fun Patcher.addPatchesFiltered(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (compatiblePackage in compatibilityAnnotation.compatiblePackages) {
|
compatibilityAnnotation.compatiblePackages.forEach { compatiblePackage ->
|
||||||
if (packageCompatibilityFilter && compatiblePackage.name != packageName) {
|
if (packageCompatibilityFilter && compatiblePackage.name != packageName) {
|
||||||
println("$prefix: Package name not matching ${compatiblePackage.name}.")
|
println("$prefix: Package name not matching ${compatiblePackage.name}.")
|
||||||
return@patch
|
return@patch
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!packageVersionCompatibilityFilter || compatiblePackage.versions.any { it == packageVersion }) continue
|
if (packageVersionCompatibilityFilter && !compatiblePackage.versions.any { it == packageVersion }) {
|
||||||
println("$prefix: Unsupported version.")
|
println("$prefix: Unsupported version.")
|
||||||
return@patch
|
return@patch
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,8 +62,13 @@ fun Patcher.addPatchesFiltered(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Patcher.applyPatchesPrint() {
|
fun Patcher.applyPatchesPrint() {
|
||||||
for ((patch, result) in this.applyPatches()) {
|
this.applyPatches().forEach { (patch, result) ->
|
||||||
println("[${if (result.isFailure) "error" else "success"}] $patch")
|
if (result.isSuccess) {
|
||||||
|
println("[success] $patch")
|
||||||
|
return@forEach
|
||||||
|
}
|
||||||
|
println("[error] $patch:")
|
||||||
|
result.exceptionOrNull()!!.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user