feat: transition aliuhook versioning to semver
This commit is contained in:
parent
8ba1f6d60b
commit
b206041146
5 changed files with 12 additions and 18 deletions
|
|
@ -7,12 +7,15 @@ import io.ktor.http.HttpStatusCode
|
|||
class AliucordMavenRepository(
|
||||
private val maven: MavenService,
|
||||
) {
|
||||
suspend fun getAliuhookVersion(): ApiResponse<String> {
|
||||
suspend fun getAliuhookVersion(): ApiResponse<SemVer> {
|
||||
return maven.getArtifactMetadata(BASE_URL, ALIUHOOK).transform {
|
||||
"<release>(.+?)</release>".toRegex()
|
||||
val versionString = "<release>(.+?)</release>".toRegex()
|
||||
.find(it)
|
||||
?.groupValues?.get(1)
|
||||
?: return ApiResponse.Error(ApiError(HttpStatusCode.OK, "No version in the aliuhook artifact metadata"))
|
||||
|
||||
SemVer.parseOrNull(versionString)
|
||||
?: return ApiResponse.Error(ApiError(HttpStatusCode.OK, "Invalid latest aliuhook version!"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -20,8 +23,7 @@ class AliucordMavenRepository(
|
|||
private const val BASE_URL = "https://maven.aliucord.com/snapshots"
|
||||
private const val ALIUHOOK = "com.aliucord:Aliuhook"
|
||||
|
||||
fun getAliuhookUrl(version: String): String {
|
||||
return MavenService.getAARUrl(BASE_URL, "$ALIUHOOK:$version")
|
||||
}
|
||||
fun getAliuhookUrl(version: String): String =
|
||||
"$BASE_URL/com/aliucord/Aliuhook/$version/Aliuhook-$version.aar"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class PathManager(context: Context) {
|
|||
/**
|
||||
* Resolve a specific path for a versioned cached Aliuhook build
|
||||
*/
|
||||
fun cachedAliuhookAAR(version: String) = externalCacheDir
|
||||
fun cachedAliuhookAAR(version: SemVer) = externalCacheDir
|
||||
.resolve("aliuhook").apply { mkdirs() }
|
||||
.resolve("$version.aar")
|
||||
|
||||
|
|
|
|||
|
|
@ -14,13 +14,4 @@ class MavenService(
|
|||
url("$baseUrl/${coords}/maven-metadata.xml")
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getAARUrl(baseUrl: String, coords: String): String {
|
||||
val parts = coords.split("[:.]".toRegex())
|
||||
val artifact = parts[parts.lastIndex - 1]
|
||||
val version = parts.last()
|
||||
return "$baseUrl/${parts.joinToString("/")}/$artifact-$version.aar"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ data class InstallMetadata(
|
|||
/**
|
||||
* Version (commit hash) of the Aliuhook build that was injected into the APK.
|
||||
*/
|
||||
val aliuhookVersion: String,
|
||||
val aliuhookVersion: SemVer,
|
||||
|
||||
/**
|
||||
* Version of the injector build that was injected into the APK.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import androidx.compose.runtime.Stable
|
|||
import com.aliucord.manager.R
|
||||
import com.aliucord.manager.domain.repository.AliucordMavenRepository
|
||||
import com.aliucord.manager.manager.PathManager
|
||||
import com.aliucord.manager.network.utils.SemVer
|
||||
import com.aliucord.manager.network.utils.getOrThrow
|
||||
import com.aliucord.manager.patcher.StepRunner
|
||||
import com.aliucord.manager.patcher.steps.base.DownloadStep
|
||||
|
|
@ -25,11 +26,11 @@ class DownloadAliuhookStep : DownloadStep(), IDexProvider, KoinComponent {
|
|||
/**
|
||||
* This is populated right before the download starts (ref: [execute])
|
||||
*/
|
||||
lateinit var targetVersion: String
|
||||
lateinit var targetVersion: SemVer
|
||||
private set
|
||||
|
||||
override val localizedName = R.string.patch_step_dl_aliuhook
|
||||
override val targetUrl get() = AliucordMavenRepository.getAliuhookUrl(targetVersion)
|
||||
override val targetUrl get() = AliucordMavenRepository.getAliuhookUrl(targetVersion.toString())
|
||||
override val targetFile get() = paths.cachedAliuhookAAR(targetVersion)
|
||||
|
||||
override suspend fun execute(container: StepRunner) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue