1
mirror of https://github.com/revanced/revanced-cli synced 2025-11-19 15:33:27 +01:00

Compare commits

...

13 Commits

Author SHA1 Message Date
semantic-release-bot
4f1982e3ad chore(release): 4.4.1-dev.1 [skip ci]
## [4.4.1-dev.1](https://github.com/ReVanced/revanced-cli/compare/v4.4.0...v4.4.1-dev.1) (2024-02-21)
2024-02-21 03:58:27 +00:00
oSumAtrIX
f1d7d0dc62 build: Sign release artifacts 2024-02-21 04:52:53 +01:00
oSumAtrIX
40c90f5c1b build: Bump Gradle 2024-02-15 02:34:10 +01:00
oSumAtrIX
30b46bcb0f build(Needs bump): Bump dependencies 2024-02-15 02:34:10 +01:00
oSumAtrIX
b6f63c7d9d docs: Fix blockquote highlights not rendering
As of 14. Nov 2023 GitHub has decided to disable nested highlighted blockquotes: https://github.com/orgs/community/discussions/16925.
2024-02-04 18:35:41 +01:00
oSumAtrIX
b5bd988a1d ci: Use latest Node.js LTS version to fix builds 2024-01-26 22:52:38 +01:00
oSumAtrIX
95c998b0a6 ci: Add dependabot 2024-01-26 01:45:45 +01:00
oSumAtrIX
24a8f6575c build: Bump dependencies 2024-01-26 01:42:04 +01:00
oSumAtrIX
55f0c01e5a docs: Fix grammatic error 2024-01-12 11:45:39 +01:00
oSumAtrIX
ee1e96b2d5 docs: Simplify patch command 2024-01-12 09:42:05 +01:00
oSumAtrIX
0fc1d571e8 docs: Add JRE links to obtain 2024-01-11 23:37:20 +01:00
oSumAtrIX
4933fe0314 build: Bump dependencies 2024-01-10 09:33:54 +01:00
oSumAtrIX
2e2ddac273 chore: Add local.properties to .gitignore 2024-01-10 09:33:54 +01:00
15 changed files with 785 additions and 4948 deletions

3
.editorconfig Normal file
View File

@@ -0,0 +1,3 @@
[*.{kt,kts}]
ktlint_code_style = intellij_idea
ktlint_standard_no-wildcard-imports = disabled

22
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,22 @@
version: 2
updates:
- package-ecosystem: github-actions
labels: []
directory: /
target-branch: dev
schedule:
interval: monthly
- package-ecosystem: npm
labels: []
directory: /
target-branch: dev
schedule:
interval: monthly
- package-ecosystem: gradle
labels: []
directory: /
target-branch: dev
schedule:
interval: monthly

View File

@@ -24,25 +24,30 @@ jobs:
persist-credentials: false
fetch-depth: 0
- name: Cache Node modules
uses: actions/cache@v3
with:
path: |
node_modules
key: npm-${{ hashFiles('package-lock.json') }}
- name: Cache Gradle
uses: burrunan/gradle-cache-action@v1
- name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Cleaning is necessary to avoid uploading two identical artifacts with different versions
run: ./gradlew clean --no-daemon
run: ./gradlew build clean
- name: Setup semantic-release
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "lts/*"
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
fingerprint: ${{ env.GPG_FINGERPRINT }}
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.REPOSITORY_PUSH_ACCESS }}

5
.gitignore vendored
View File

@@ -119,4 +119,7 @@ node_modules/
# ReVanced CLI
revanced-cache/
options.toml
options.toml
# Generated by an Android project (such as ReVanced Integrations)
local.properties

View File

@@ -31,7 +31,7 @@
{
"assets": [
{
"path": "build/libs/*all.jar"
"path": "build/libs/*-all*"
}
],
successComment: false

View File

@@ -1,3 +1,5 @@
## [4.4.1-dev.1](https://github.com/ReVanced/revanced-cli/compare/v4.4.0...v4.4.1-dev.1) (2024-02-21)
# [4.4.0](https://github.com/ReVanced/revanced-cli/compare/v4.3.0...v4.4.0) (2023-12-28)

View File

@@ -1,15 +1,29 @@
plugins {
kotlin("jvm") version "1.9.10"
alias(libs.plugins.kotlin)
alias(libs.plugins.shadow)
application
`maven-publish`
signing
}
group = "app.revanced"
application {
mainClass = "app.revanced.cli.command.MainCommandKt"
}
repositories {
mavenCentral()
mavenLocal()
google()
maven { url = uri("https://jitpack.io") }
maven {
// A repository must be speficied for some reason. "registry" is a dummy.
url = uri("https://maven.pkg.github.com/revanced/registry")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
}
}
}
dependencies {
@@ -36,9 +50,6 @@ tasks {
}
shadowJar {
manifest {
attributes("Main-Class" to "app.revanced.cli.command.MainCommandKt")
}
minimize {
exclude(dependency("org.jetbrains.kotlin:.*"))
exclude(dependency("org.bouncycastle:.*"))
@@ -46,25 +57,29 @@ tasks {
}
}
build {
publish {
dependsOn(shadowJar)
}
}
/*
Dummy task to hack gradle-semantic-release-plugin to release this project.
// Needed by gradle-semantic-release-plugin.
// Tracking: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435
Explanation:
SemVer is a standard for versioning libraries.
For that reason the semantic-release plugin uses the "publish" task to publish libraries.
However, this subproject is not a library, and the "publish" task is not available for this subproject.
Because semantic-release is not designed to handle this case, we need to hack it.
// The maven-publish is also necessary to make the signing plugin work.
publishing {
repositories {
mavenLocal()
}
RE: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435
*/
register<DefaultTask>("publish") {
group = "publishing"
description = "Dummy task to hack gradle-semantic-release-plugin to release ReVanced CLI"
dependsOn(build)
publications {
create<MavenPublication>("revanced-cli-publication") {
from(components["java"])
}
}
}
signing {
useGpgCmd()
sign(publishing.publications["revanced-cli-publication"])
}

View File

@@ -4,7 +4,7 @@ To use ReVanced CLI, you will need to fulfill specific requirements.
## 🤝 Requirements
- Java Runtime Environment 11 (Azul Zulu JRE or OpenJDK)
- Java Runtime Environment 11 ([Azul Zulu JRE](https://www.azul.com/downloads/?version=java-11-lts&package=jdk#zulu) or [OpenJDK](https://jdk.java.net/archive/))
- [Android Debug Bridge (ADB)](https://developer.android.com/studio/command-line/adb) if you want to install the patched APK file on your device
- An ABI other than ARMv7 such as x86 or x86-64 (or a custom AAPT binary that supports ARMv7)

View File

@@ -1,6 +1,6 @@
# 🛠️ Using ReVanced CLI
Learn how to ReVanced CLI.
Learn how to use ReVanced CLI.
## 🔨 Usage
@@ -34,71 +34,51 @@ ReVanced CLI is divided into the following fundamental commands:
revanced-patches.jar [<patch-bundle> ...]
```
> [!NOTE]
> A default `options.json` file will be automatically created if it does not exist
without any need for intervention when using the `patch` command.
> ** Note**
> A default `options.json` file will be automatically created if it does not exist
without any need for intervention when using the `patch` command.
- ### 💉 Patch an app
You can patch apps by supplying patch bundles and the app to patch.
After patching, ReVanced CLI can install the patched app on your device using two methods:
> **💡 Tip**
> For ReVanced CLI to be able to install the patched app on your device, make sure ADB is working:
>
> ```bash
> adb shell exit
> ```
>
> If you want to mount the patched app on top of the un-patched app, make sure you have root permissions:
>
> ```bash
> adb shell su -c exit
> ```
>
> [!NOTE]
> For ReVanced CLI to be able to install the patched app on your device, make sure ADB is working:
>
> ```bash
> adb shell exit
> ```
>
> To get your device's serial, run the following command:
>
> ```bash
> adb devices
> ```
>
> If you want to mount the patched app on top of the un-patched app, make sure you have root permissions:
>
> ```bash
> adb shell su -c exit
> ```
>
> [!WARNING]
> Some patches may require integrations
> such as [ReVanced Integrations](https://github.com/revanced/revanced-integrations).
> Supply them with the option `--merge`. ReVanced Patcher will automatically determine if they are necessary.
> **⚠️ Warning**
> Some patches may require integrations
> such as [ReVanced Integrations](https://github.com/revanced/revanced-integrations).
> Supply them with the option `--merge`. ReVanced Patcher will automatically determine if they are necessary.
- #### 👾 Patch an app and install it on your device regularly
```bash
java -jar revanced-cli.jar patch \
--patch-bundle revanced-patches.jar \
--device-serial <device-serial> \
-d \
input.apk
```
- #### 👾 Patch an app and mount it on top of the un-patched app with root permissions
> [!IMPORTANT]
> Ensure that the same app you are patching and mounting over is installed on your device:
>
> ```bash
> adb install app.apk
> ```
> [!NOTE]
> You can use the option `--ii` to include or `--ie` to exclude
> patches by their index in relation to supplied patch bundles,
> similarly to the option `--include` and `--exclude`.
>
> This is useful in case two patches have the same name, and you must include or exclude one.
> The patch index is calculated by the position of the patch in the list of patches
> from patch bundles supplied using the option `--patch-bundle`.
>
> You can list all patches with their indices using the command `list-patches`.
>
> Keep in mind that the indices can change based on the order of the patch bundles supplied,
> as well if the patch bundles are updated because patches can be added or removed.
> **❗ Caution**
> Ensure that the same app you are patching and mounting over is installed on your device:
>
> ```bash
> adb install app.apk
> ```
```bash
java -jar revanced-cli.jar patch \
@@ -106,10 +86,24 @@ without any need for intervention when using the `patch` command.
--include "Some patch" \
--ii 123 \
--exclude "Some other patch" \
--device-serial <device-serial> \
-d \
--mount \
app.apk
```
> **💡 Tip**
> You can use the option `--ii` to include or `--ie` to exclude
> patches by their index in relation to supplied patch bundles,
> similarly to the option `--include` and `--exclude`.
>
> This is useful in case two patches have the same name, and you must include or exclude one.
> The patch index is calculated by the position of the patch in the list of patches
> from patch bundles supplied using the option `--patch-bundle`.
>
> You can list all patches with their indices using the command `list-patches`.
>
> Keep in mind that the indices can change based on the order of the patch bundles supplied,
> as well if the patch bundles are updated because patches can be added or removed.
- ### 🗑️ Uninstall an app
@@ -119,9 +113,9 @@ without any need for intervention when using the `patch` command.
[<device-serial>]
```
> [!NOTE]
> You can unmount an APK file
by adding the option `--unmount`.
> **💡 Tip**
> You can unmount an APK file
by adding the option `--unmount`.
- ### 📦 Install an app
@@ -131,6 +125,6 @@ by adding the option `--unmount`.
[<device-serial>]
```
> [!NOTE]
> You can mount an APK file
> by supplying the package name of the app to mount the supplied APK file over the option `--mount`.
> **💡 Tip**
> You can mount an APK file
> by supplying the app's package name to mount the supplied APK file over the option `-mount`.

View File

@@ -1,4 +1,4 @@
org.gradle.parallel = true
org.gradle.caching = true
kotlin.code.style = official
version = 4.4.0
version = 4.4.1-dev.1

View File

@@ -1,13 +1,13 @@
[versions]
shadow = "8.1.1"
kotlin-test = "1.9.20"
kotlin = "1.9.22"
kotlinx-coroutines-core = "1.7.3"
picocli = "4.7.3"
revanced-patcher = "19.1.0"
revanced-library = "1.4.0"
picocli = "4.7.5"
revanced-patcher = "19.3.1"
revanced-library = "2.0.0"
[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin-test" }
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines-core" }
picocli = { module = "info.picocli:picocli", version.ref = "picocli" }
revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" }
@@ -15,3 +15,4 @@ revanced-library = { module = "app.revanced:revanced-library", version.ref = "re
[plugins]
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionSha256Sum=3e1af3ae886920c3ac87f7a91f816c0c7c436f276a6eefdb3da152100fef72ae
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionSha256Sum=9631d53cf3e74bfa726893aee1f8994fee4e060c401335946dba2156f440f24c
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dist

5433
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,9 @@
{
"devDependencies": {
"@saithodev/semantic-release-backmerge": "^3.2.1",
"@saithodev/semantic-release-backmerge": "^4.0.1",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"gradle-semantic-release-plugin": "^1.8.0",
"semantic-release": "^22.0.8"
"gradle-semantic-release-plugin": "^1.9.1",
"semantic-release": "^23.0.2"
}
}

View File

@@ -1,13 +1,15 @@
package app.revanced.cli.command
import app.revanced.library.ApkUtils
import app.revanced.library.ApkUtils.applyTo
import app.revanced.library.ApkUtils.sign
import app.revanced.library.Options
import app.revanced.library.Options.setOptions
import app.revanced.library.adb.AdbManager
import app.revanced.patcher.PatchBundleLoader
import app.revanced.patcher.PatchSet
import app.revanced.patcher.Patcher
import app.revanced.patcher.PatcherOptions
import app.revanced.patcher.PatcherConfig
import kotlinx.coroutines.runBlocking
import picocli.CommandLine
import picocli.CommandLine.Help.Visibility.ALWAYS
@@ -30,9 +32,9 @@ internal object PatchCommand : Runnable {
private lateinit var apk: File
private var integrations = listOf<File>()
private var integrations = setOf<File>()
private var patchBundles = emptyList<File>()
private var patchBundles = emptySet<File>()
@CommandLine.Option(
names = ["-i", "--include"],
@@ -91,7 +93,8 @@ internal object PatchCommand : Runnable {
@CommandLine.Option(
names = ["-d", "--device-serial"],
description = ["ADB device serial to install to. If not supplied, the first connected device will be used."],
fallbackValue = "", // Empty string to indicate that the first connected device should be used.
// Empty string to indicate that the first connected device should be used.
fallbackValue = "",
arity = "0..1",
)
private var deviceSerial: String? = null
@@ -144,6 +147,17 @@ internal object PatchCommand : Runnable {
description = ["Path to temporary resource cache directory."],
)
private var resourceCachePath: File? = null
set(value) {
logger.warning("The --resource-cache option is deprecated. Use --temporary-files-patch instead.")
field = value
temporaryFilesPath = value
}
@CommandLine.Option(
names = ["-t", "--temporary-files-path"],
description = ["Path to temporary files directory."],
)
private var temporaryFilesPath: File? = null
private var aaptBinaryPath: File? = null
@@ -194,11 +208,11 @@ internal object PatchCommand : Runnable {
required = true,
)
@Suppress("unused")
private fun setPatchBundles(patchBundles: Array<File>) {
private fun setPatchBundles(patchBundles: Set<File>) {
patchBundles.firstOrNull { !it.exists() }?.let {
throw CommandLine.ParameterException(spec.commandLine(), "Patch bundle ${it.name} does not exist")
}
this.patchBundles = patchBundles.toList()
this.patchBundles = patchBundles
}
@CommandLine.Option(
@@ -224,9 +238,9 @@ internal object PatchCommand : Runnable {
"${apk.nameWithoutExtension}-patched.${apk.extension}",
)
val resourceCachePath =
resourceCachePath ?: outputFilePath.parentFile.resolve(
"${outputFilePath.nameWithoutExtension}-resource-cache",
val temporaryFilesPath =
temporaryFilesPath ?: outputFilePath.parentFile.resolve(
"${outputFilePath.nameWithoutExtension}-temporary-files",
)
val optionsFile =
@@ -261,11 +275,11 @@ internal object PatchCommand : Runnable {
// endregion
Patcher(
PatcherOptions(
PatcherConfig(
apk,
resourceCachePath,
temporaryFilesPath,
aaptBinaryPath?.path,
resourceCachePath.absolutePath,
temporaryFilesPath.absolutePath,
true,
),
).use { patcher ->
@@ -285,7 +299,7 @@ internal object PatchCommand : Runnable {
val patcherResult =
patcher.apply {
acceptIntegrations(integrations)
acceptPatches(filteredPatches.toList())
acceptPatches(filteredPatches)
// Execute patches.
runBlocking {
@@ -304,15 +318,12 @@ internal object PatchCommand : Runnable {
// region Save
val alignedFile =
resourceCachePath.resolve(apk.name).apply {
ApkUtils.copyAligned(apk, this, patcherResult)
}
apk.copyTo(outputFilePath, overwrite = true)
patcherResult.applyTo(outputFilePath)
if (!mount) {
ApkUtils.sign(
alignedFile,
outputFilePath,
outputFilePath.sign(
ApkUtils.SigningOptions(
keystoreFilePath,
keyStorePassword,
@@ -321,8 +332,6 @@ internal object PatchCommand : Runnable {
signer,
),
)
} else {
alignedFile.renameTo(outputFilePath)
}
logger.info("Saved to $outputFilePath")
@@ -340,7 +349,7 @@ internal object PatchCommand : Runnable {
if (purge) {
logger.info("Purging temporary files")
purge(resourceCachePath)
purge(temporaryFilesPath)
}
}