Compare commits

...

9 Commits

Author SHA1 Message Date
semantic-release-bot
a530624fb2 chore(release): 2.11.0 [skip ci]
# [2.11.0](https://github.com/revanced/revanced-cli/compare/v2.10.2...v2.11.0) (2022-09-20)

### Features

* section `acknowledgements` for issue templates ([0e3ecc3](0e3ecc3a51))
2022-09-20 22:37:23 +00:00
oSumAtrIX
0e3ecc3a51 feat: section acknowledgements for issue templates
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
2022-09-21 00:35:56 +02:00
semantic-release-bot
7fac75c6b6 chore(release): 2.10.2 [skip ci]
## [2.10.2](https://github.com/revanced/revanced-cli/compare/v2.10.1...v2.10.2) (2022-09-18)
2022-09-18 06:29:07 +00:00
oSumAtrIX
7ca0b35e45 build: bump patcher dependency version
Signed-off-by: oSumAtrIX <johan.melkonyan1@web.de>
2022-09-18 08:27:20 +02:00
Sculas
cb0fde4908 refactor: clarify config header 2022-09-12 12:24:36 +02:00
Sculas
75e810e42e chore: remove broken dir mappings
cc @oSumAtrIX: if you need this, don't push this file to remote.
2022-09-12 11:47:35 +02:00
semantic-release-bot
37cc77dfc5 chore(release): 2.10.1 [skip ci]
## [2.10.1](https://github.com/revanced/revanced-cli/compare/v2.10.0...v2.10.1) (2022-09-09)
2022-09-09 20:51:44 +00:00
Sculas
075bf406fd refactor: improve OptionsLoader a lot 2022-09-09 22:50:15 +02:00
Sculas
71c81510f7 build: update patcher dependency 2022-09-09 20:59:10 +02:00
7 changed files with 69 additions and 21 deletions

View File

@@ -59,3 +59,15 @@ body:
description: Add additional context here. description: Add additional context here.
validations: validations:
required: false required: false
- type: checkboxes
id: acknowledgements
attributes:
label: Acknowledgements
description: Your issue will be closed if you haven't done these steps.
options:
- label: I have searched the existing issues and this is a new and no duplicate or related to another open issue.
required: true
- label: I have written a short but informative title.
required: true
- label: I filled out all of the requested information in this issue properly.
required: true

View File

@@ -44,3 +44,15 @@ body:
description: Add additional context here. description: Add additional context here.
validations: validations:
required: false required: false
- type: checkboxes
id: acknowledgements
attributes:
label: Acknowledgements
description: Your issue will be closed if you haven't done these steps.
options:
- label: I have searched the existing issues and this is a new and no duplicate or related to another open issue.
required: true
- label: I have written a short but informative title.
required: true
- label: I filled out all of the requested information in this issue properly.
required: true

2
.idea/vcs.xml generated
View File

@@ -8,7 +8,5 @@
</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>

View File

@@ -1,3 +1,14 @@
# [2.11.0](https://github.com/revanced/revanced-cli/compare/v2.10.2...v2.11.0) (2022-09-20)
### Features
* section `acknowledgements` for issue templates ([0e3ecc3](https://github.com/revanced/revanced-cli/commit/0e3ecc3a51540b71072ae0be0eb94d115a5b1f92))
## [2.10.2](https://github.com/revanced/revanced-cli/compare/v2.10.1...v2.10.2) (2022-09-18)
## [2.10.1](https://github.com/revanced/revanced-cli/compare/v2.10.0...v2.10.1) (2022-09-09)
# [2.10.0](https://github.com/revanced/revanced-cli/compare/v2.9.10...v2.10.0) (2022-09-08) # [2.10.0](https://github.com/revanced/revanced-cli/compare/v2.9.10...v2.10.0) (2022-09-08)

View File

@@ -25,7 +25,7 @@ repositories {
dependencies { dependencies {
implementation(kotlin("reflect")) implementation(kotlin("reflect"))
implementation("app.revanced:revanced-patcher:4.2.3") implementation("app.revanced:revanced-patcher:4.4.2")
implementation("info.picocli:picocli:4.6.3") implementation("info.picocli:picocli:4.6.3")
implementation("com.android.tools.build:apksig:7.2.1") implementation("com.android.tools.build:apksig:7.2.1")
implementation("com.github.revanced:jadb:master-SNAPSHOT") // updated fork implementation("com.github.revanced:jadb:master-SNAPSHOT") // updated fork

View File

@@ -1,2 +1,2 @@
kotlin.code.style = official kotlin.code.style = official
version = 2.10.0 version = 2.11.0

View File

@@ -1,20 +1,19 @@
package app.revanced.utils package app.revanced.utils
import app.revanced.cli.command.MainCommand.logger import app.revanced.cli.command.MainCommand.logger
import app.revanced.patcher.Patcher
import app.revanced.patcher.data.Data import app.revanced.patcher.data.Data
import app.revanced.patcher.extensions.PatchExtensions.options import app.revanced.patcher.extensions.PatchExtensions.options
import app.revanced.patcher.extensions.PatchExtensions.patchName import app.revanced.patcher.extensions.PatchExtensions.patchName
import app.revanced.patcher.patch.Patch import app.revanced.patcher.patch.Patch
import cc.ekblad.toml.encodeTo import cc.ekblad.toml.encodeToString
import cc.ekblad.toml.model.TomlValue import cc.ekblad.toml.model.TomlValue
import cc.ekblad.toml.serialization.from import cc.ekblad.toml.serialization.from
import cc.ekblad.toml.tomlMapper import cc.ekblad.toml.tomlMapper
import java.io.File import java.io.File
private typealias PatchList = List<Class<out Patch<Data>>> private typealias PatchList = List<Class<out Patch<Data>>>
private typealias OptionsMap = Map<String, Map<String, Any>> private typealias OptionsMap = MutableMap<String, MutableMap<String, Any>>
private const val NULL = "null"
object OptionsLoader { object OptionsLoader {
@JvmStatic @JvmStatic
@@ -23,12 +22,9 @@ object OptionsLoader {
@JvmStatic @JvmStatic
fun init(file: File, patches: PatchList) { fun init(file: File, patches: PatchList) {
if (!file.exists()) file.createNewFile() if (!file.exists()) file.createNewFile()
val path = file.toPath() val map = mapper.decodeWithDefaults(generateDefaults(patches), TomlValue.from(file.toPath()))
val map = mapper.decodeWithDefaults(
generateDefaults(patches),
TomlValue.from(path)
).also { mapper.encodeTo(path, it) }
readAndSet(map, patches) readAndSet(map, patches)
save(map, file)
} }
private fun readAndSet(map: OptionsMap, patches: PatchList) { private fun readAndSet(map: OptionsMap, patches: PatchList) {
@@ -36,27 +32,46 @@ object OptionsLoader {
val patch = patches.find { it.patchName == patchName } ?: continue val patch = patches.find { it.patchName == patchName } ?: continue
val patchOptions = patch.options ?: continue val patchOptions = patch.options ?: continue
for ((key, value) in options) { for ((key, value) in options) {
if (value == "null") { // backwards compatibility, subject to removal
options.remove(key)
continue
}
try { try {
patchOptions[key] = value.let { patchOptions[key] = value
if (it == NULL) null else it
}
} catch (e: Exception) { } catch (e: Exception) {
logger.warn("Error while setting option $key for patch $patchName: ${e.message}") logger.error("Error while setting option $key for patch $patchName: ${e.message}")
e.printStackTrace() e.printStackTrace()
} }
} }
} }
} }
private fun save(map: OptionsMap, file: File) {
val toml = mapper.encodeToString(map)
file.writeText(
"""
# A list of options for each patch.
# This file does not contain all options by default.
# Run the CLI with the "--list --with-options" flags to see all available options.
# You can also run the CLI with the aforementioned flags and a patch name to see all available options for that patch.
# To set an option, add a line with the format "option = value" or set the value if the option already exists.
# To reset an option to its default value, delete the line.
# To reset all options to their default values, delete this file.
#
# This file was generated by ReVanced Patcher version ${Patcher.version}.
""".trimIndent() + "\n\n$toml"
)
}
private fun generateDefaults(patches: PatchList) = buildMap { private fun generateDefaults(patches: PatchList) = buildMap {
for (patch in patches) { for (patch in patches) {
val options = patch.options ?: continue val options = patch.options ?: continue
if (!options.iterator().hasNext()) continue if (!options.iterator().hasNext()) continue
put(patch.patchName, buildMap { put(patch.patchName, buildMap {
for (option in options) { for (option in options) {
put(option.key, option.value ?: NULL) put(option.key, option.value ?: continue)
} }
}) } as MutableMap)
} }
} } as MutableMap
} }