Skip to content

Commit

Permalink
add update command
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkyAI committed Jan 24, 2021
1 parent 42b332d commit 182434d
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 27 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ subprojects {
className = "GeneratedConstants"
) {
field("BUILD") value versionSuffix
field("VERSION") value fullVersion
field("VERSION") value fullVersion.substringBefore('-')
field("FULL_VERSION") value fullVersion
field("MAVEN_URL") value "https://nikky.moe/maven"
field("MAVEN_GROUP") value group.toString()
Expand Down
4 changes: 0 additions & 4 deletions core/src/main/kotlin/voodoo/data/flat/FlatModPack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ data class FlatModPack(
this@FlatModPack
)

resolvedEntries.forEach { entry ->
logger.info { "RESOLVED: ${entry.id} $entry" }
}

"validate".watch {
resolvedEntries.forEach { lockEntry ->
val provider = Providers[lockEntry.providerType]
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/kotlin/voodoo/provider/JenkinsProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import kotlinx.coroutines.channels.SendChannel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.runBlocking
import voodoo.core.GeneratedConstants.VERSION
import voodoo.core.GeneratedConstants
import voodoo.data.EntryReportData
import voodoo.data.Quadruple
import voodoo.data.flat.FlatEntry
Expand All @@ -26,7 +26,7 @@ import java.util.*
*/

object JenkinsProvider : ProviderBase("Jenkins Provider") {
const val useragent = "voodoo/$VERSION (https://github.com/DaemonicLabs/Voodoo)"
const val useragent = "voodoo/${GeneratedConstants.FULL_VERSION} (https://github.com/DaemonicLabs/Voodoo)"

override suspend fun resolve(
entry: FlatEntry,
Expand Down
8 changes: 8 additions & 0 deletions samples/fabricpack/lock/0.0.3/lock.pack.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@
"projectID": 317514,
"fileID": 3174695
},
{
"type": "jenkins",
"id": "opencomputers",
"path": "mods",
"jenkinsUrl": "https://ci.cil.li/",
"job": "OpenComputers-MC1.12",
"buildNumber": 213
},
{
"type": "curse",
"id": "roughly-enough-items",
Expand Down
2 changes: 1 addition & 1 deletion util/download/src/main/kotlin/voodoo.util/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import io.ktor.client.features.json.serializer.KotlinxSerializer
import io.ktor.util.KtorExperimentalAPI
import voodoo.util.download.GeneratedConstants

const val useragent = "voodoo/${GeneratedConstants.VERSION} (https://github.com/DaemonicLabs/Voodoo)"
const val useragent = "voodoo/${GeneratedConstants.FULL_VERSION} (https://github.com/DaemonicLabs/Voodoo)"
// "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36" // ""voodoo/$VERSION (https://github.com/elytra/Voodoo)"

inline fun <T> useClient(createClient: () -> HttpClient = {
Expand Down
2 changes: 1 addition & 1 deletion voodoo/src/main/kotlin/voodoo/cli/CompileCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CompileCommand() : CliktCommand(
val config = Configuration.parse(rootDir = rootDir)

val packs: Map<Pair<String, MetaPack>, List<VersionPack>> = packFiles.map { packFile ->
val baseDir = packFile.absoluteFile.parentFile
val baseDir = rootDir.resolve(packFile.absoluteFile.parentFile)
val id = baseDir.name
val metaPackFile = baseDir.resolve(MetaPack.FILENAME)
val versionPack = VersionPack.parse(packFile = packFile)
Expand Down
50 changes: 50 additions & 0 deletions voodoo/src/main/kotlin/voodoo/cli/UpdateCommand.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package voodoo.cli

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.requireObject
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.slf4j.MDCContext
import mu.KotlinLogging
import mu.withLoggingContext
import voodoo.util.maven.MavenUtil
import voodoo.voodoo.GeneratedConstants
import java.io.StringWriter
import java.util.*

class UpdateCommand : CliktCommand(
name = "update",
help = "updates the version of voodoo"
) {
private val logger = KotlinLogging.logger {}
val cliContext by requireObject<CLIContext>()

override fun run(): Unit = withLoggingContext("command" to commandName) {
val rootDir = cliContext.rootDir

runBlocking(MDCContext()) {
val propertiesFile = rootDir.resolve("wrapper/wrapper.properties")
propertiesFile.absoluteFile.parentFile.mkdirs()

val properties = Properties().also { prop ->
propertiesFile.bufferedReader().use {
prop.load(it)
}
}

val version = MavenUtil.getLatestVersionFromMavenMetadata(
GeneratedConstants.MAVEN_URL,
GeneratedConstants.MAVEN_GROUP,
"voodoo"
)
val groupPath = GeneratedConstants.MAVEN_GROUP.replace('.', '/')
properties["distributionUrl"] =
"${GeneratedConstants.MAVEN_URL}/$groupPath/voodoo/$version/voodoo-$version-${GeneratedConstants.MAVEN_SHADOW_CLASSIFIER}.jar"
// prop["distributionPath"] = "wrapper/bin"

StringWriter().use {
properties.store(it, "generated by: voodoo generateWrapper")
propertiesFile.writeText(it.toString())
}
}
}
}
1 change: 1 addition & 0 deletions voodoo/src/main/kotlin/voodoo/cli/VoodooCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class VoodooCommand(invocation: String = "voodoo") : CliktCommand(
PackageCommand(),
LaunchCommand(),
GenerateSchemaCommand(),
UpdateCommand()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class LaunchMultiMCCommand(): CliktCommand(
//TODO: look up rootDir based on lockpack input file
val rootDir = cliContext.rootDir

val baseDir = packFile.absoluteFile.parentFile
val baseDir = rootDir.resolve(packFile.absoluteFile.parentFile)
val id = baseDir.name
stopwatch {
val metaPackFile = baseDir.resolve(MetaPack.FILENAME)
Expand Down
12 changes: 0 additions & 12 deletions wrapper/multimc-installer/build.gradle.kts

This file was deleted.

5 changes: 0 additions & 5 deletions wrapper/multimc-installer/src/main/resources/maven.properties

This file was deleted.

0 comments on commit 182434d

Please sign in to comment.