chore: Merge branch dev to main (#309)

This commit is contained in:
oSumAtrIX 2024-03-06 20:12:35 +01:00 committed by GitHub
commit 164d09dec1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 897 additions and 5012 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

@ -0,0 +1,25 @@
name: Build pull request
on:
workflow_dispatch:
pull_request:
branches:
- dev
jobs:
release:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache Gradle
uses: burrunan/gradle-cache-action@v1
- name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew build --no-daemon

View File

@ -6,10 +6,6 @@ on:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
jobs:
release:
@ -24,25 +20,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 }}

View File

@ -11,7 +11,7 @@ jobs:
name: Dispatch event to documentation repository
if: github.ref == 'refs/heads/main'
steps:
- uses: peter-evans/repository-dispatch@v2
- uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.DOCUMENTATION_REPO_ACCESS_TOKEN }}
repository: revanced/revanced-documentation

3
.gitignore vendored
View File

@ -120,3 +120,6 @@ node_modules/
# ReVanced CLI
revanced-cache/
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,12 @@
## [4.4.1-dev.2](https://github.com/ReVanced/revanced-cli/compare/v4.4.1-dev.1...v4.4.1-dev.2) (2024-03-04)
### Bug Fixes
* Bump dependencies to support BCS keystore ([1c10a77](https://github.com/ReVanced/revanced-cli/commit/1c10a7760d76ea850260ca49b448be7ad121de44))
## [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

@ -64,14 +64,14 @@ This document describes how to contribute to ReVanced CLI.
## 📖 Resources to help you get started
* The [documentation](/docs) explains how to use ReVanced CLI
* [Our backlog](https://github.com/orgs/ReVanced/projects/12) is where we keep track of what we're working on
* [Issues](https://github.com/ReVanced/revanced-cli/issues) are where we keep track of bugs and feature requests
- The [documentation](/docs) explains how to use ReVanced CLI
- [Our backlog](https://github.com/orgs/ReVanced/projects/12) is where we keep track of what we're working on
- [Issues](https://github.com/ReVanced/revanced-cli/issues) are where we keep track of bugs and feature requests
## 🙏 Submitting a feature request
Features can be requested by opening an issue using the
[Feature request issue template](https://github.com/ReVanced/revanced-cli/issues/new?assignees=&labels=Feature+request&projects=&template=feature-request.yml&title=feat%3A+).
[Feature request issue template](https://github.com/ReVanced/revanced-cli/issues/new?assignees=&labels=Feature+request&projects=&template=feature_request.yml&title=feat%3A+).
> **Note**
> Requests can be accepted or rejected at the discretion of maintainers of ReVanced CLI.
@ -80,7 +80,7 @@ Features can be requested by opening an issue using the
## 🐞 Submitting a bug report
If you encounter a bug while using ReVanced CLI, open an issue using the
[Bug report issue template](https://github.com/ReVanced/revanced-cli/issues/new?assignees=&labels=Bug+report&projects=&template=bug-report.yml&title=bug%3A+).
[Bug report issue template](https://github.com/ReVanced/revanced-cli/issues/new?assignees=&labels=Bug+report&projects=&template=bug_report.yml&title=bug%3A+).
## 📝 How to contribute
@ -88,7 +88,7 @@ If you encounter a bug while using ReVanced CLI, open an issue using the
with the maintainers of ReVanced CLI. This will help you determine whether your change is acceptable
and whether it is worth your time to implement it
2. Development happens on the `dev` branch. Fork the repository and create your branch from `dev`
3. Commit your changes.
3. Commit your changes
4. Submit a pull request to the `dev` branch of the repository and reference issues
that your pull request closes in the description of your pull request
5. Our team will review your pull request and provide feedback. Once your pull request is approved,

View File

@ -67,13 +67,23 @@ Command line application to use ReVanced.
## ❓ About
ReVanced CLI is a command line application to patch apps using ReVanced.
ReVanced CLI also comes with commands to uninstall or install patched apps and list patches from supplied patch bundles.
ReVanced CLI is a command line application that uses [ReVanced Patcher](https://github.com/revanced/revanced-patcher) to patch Android apps.
## 🚀 Download
## 💪 Features
Some of the features ReVanced CLI provides are:
- 💉 **Patch apps**: Harness ReVanced Patcher to patch Android apps
- 💾 **Install and uninstall apps**: Install and uninstall Apps via ADB,
using the Android package manager, or by mounting using root permissions
- 📃 **List patches from patch bundles**: List available patches, compatible packages, and versions
- 💪 **Flexibility and functionality**: Apply any combination of patches to any version of Android apps
## 🔽 Download
You can download the most recent version of ReVanced CLI from
[here](https://github.com/ReVanced/revanced-cli/releases/latest). Learn how to use ReVanced CLI by following the [documentation](/docs).
[here](https://github.com/ReVanced/revanced-cli/releases/latest).
Learn how to use ReVanced CLI by following the [documentation](/docs).
## 📚 Everything else
@ -84,10 +94,14 @@ You can find the contribution guidelines [here](CONTRIBUTING.md).
### 🛠️ Building
In order to build ReVanced CLI, you can follow the [documentation](/docs).
To build a ReVanced CLI, you can follow the [documentation](/docs).
### 📃 Documentation
You can find the documentation of ReVanced CLI [here](/docs).
## 📜 Licence
ReVanced CLI is licensed under the GPLv3 licence. Please see the [licence file](LICENSE) for more information.
ReVanced CLI is licensed under the GPLv3 license. Please see the [license file](LICENSE) for more information.
[tl;dr](https://www.tldrlegal.com/license/gnu-general-public-license-v3-gpl-3) you may copy, distribute and modify ReVanced CLI as long as you track changes/dates in source files.
Any modifications to ReVanced CLI must also be made available under the GPL along with build & install instructions.
Any modifications to ReVanced CLI must also be made available under the GPL, along with build & install instructions.

View File

@ -1,15 +1,31 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
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 {
@ -21,7 +37,15 @@ dependencies {
testImplementation(libs.kotlin.test)
}
kotlin { jvmToolchain(11) }
kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}
java {
targetCompatibility = JavaVersion.VERSION_11
}
tasks {
test {
@ -36,9 +60,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 +67,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,36 +34,29 @@ ReVanced CLI is divided into the following fundamental commands:
revanced-patches.jar [<patch-bundle> ...]
```
> [!NOTE]
> ** 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.
> 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:
> [!NOTE]
> **💡 Tip**
> 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]
> **⚠️ 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.
@ -73,20 +66,31 @@ without any need for intervention when using the `patch` command.
```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]
> **❗ Caution**
> Ensure that the same app you are patching and mounting over is installed on your device:
>
> ```bash
> adb install app.apk
> ```
> [!NOTE]
```bash
java -jar revanced-cli.jar patch \
--patch-bundle revanced-patches.jar \
--include "Some patch" \
--ii 123 \
--exclude "Some other patch" \
-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`.
@ -100,17 +104,6 @@ without any need for intervention when using the `patch` command.
> 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.
```bash
java -jar revanced-cli.jar patch \
--patch-bundle revanced-patches.jar \
--include "Some patch" \
--ii 123 \
--exclude "Some other patch" \
--device-serial <device-serial> \
--mount \
app.apk
```
- ### 🗑️ Uninstall an app
```bash
@ -119,9 +112,9 @@ without any need for intervention when using the `patch` command.
[<device-serial>]
```
> [!NOTE]
> **💡 Tip**
> You can unmount an APK file
by adding the option `--unmount`.
> by adding the option `--unmount`.
- ### 📦 Install an app
@ -131,6 +124,6 @@ by adding the option `--unmount`.
[<device-serial>]
```
> [!NOTE]
> **💡 Tip**
> You can mount an APK file
> by supplying the package name of the app to mount the supplied APK file over the option `--mount`.
> 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.2

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.1.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 =
@ -259,13 +273,12 @@ internal object PatchCommand : Runnable {
}
// endregion
Patcher(
PatcherOptions(
val (packageName, patcherResult) = Patcher(
PatcherConfig(
apk,
resourceCachePath,
temporaryFilesPath,
aaptBinaryPath?.path,
resourceCachePath.absolutePath,
temporaryFilesPath.absolutePath,
true,
),
).use { patcher ->
@ -282,10 +295,9 @@ internal object PatchCommand : Runnable {
// region Patch
val patcherResult =
patcher.apply {
patcher.context.packageMetadata.packageName to patcher.apply {
acceptIntegrations(integrations)
acceptPatches(filteredPatches.toList())
acceptPatches(filteredPatches)
// Execute patches.
runBlocking {
@ -299,20 +311,17 @@ internal object PatchCommand : Runnable {
}
}
}.get()
// endregion
}
// 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 +330,6 @@ internal object PatchCommand : Runnable {
signer,
),
)
} else {
alignedFile.renameTo(outputFilePath)
}
logger.info("Saved to $outputFilePath")
@ -333,14 +340,13 @@ internal object PatchCommand : Runnable {
deviceSerial?.let { serial ->
AdbManager.getAdbManager(deviceSerial = serial.ifEmpty { null }, mount)
}?.install(AdbManager.Apk(outputFilePath, patcher.context.packageMetadata.packageName))
}?.install(AdbManager.Apk(outputFilePath, packageName))
// endregion
}
if (purge) {
logger.info("Purging temporary files")
purge(resourceCachePath)
purge(temporaryFilesPath)
}
}