Skip to content

Commit

Permalink
add curse importing
Browse files Browse the repository at this point in the history
  • Loading branch information
NikkyAI committed Jan 30, 2021
1 parent 59416cc commit bbc3c08
Show file tree
Hide file tree
Showing 19 changed files with 369 additions and 107 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/PUBLISH_SNAPSHOT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,15 @@ jobs:
voodoo-${{ env.VERSION }}.jar:voodoo/build/libs/voodoo-${{ env.VERSION }}-all.jar
multimc-installer-${{ env.VERSION }}.jar:multimc/installer/build/libs/multimc-installer-${{ env.VERSION }}-all.jar
server-installer-${{ env.VERSION }}.jar:server-installer/build/libs/server-installer-${{ env.VERSION }}-all.jar
empty_voodoo_project.zip:empty_voodoo_project.zip
empty_voodoo_project.zip:empty_voodoo_project.zip
- name: Send Webhook Notification
if: always()
env:
JOB_STATUS: ${{ job.status }}
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
HOOK_OS_NAME: ${{ runner.os }}
WORKFLOW_NAME: ${{ github.workflow }}
run: |
git clone https://github.com/DiscordHooks/github-actions-discord-webhook.git webhook
bash webhook/send.sh $JOB_STATUS $WEBHOOK_URL
shell: bash
2 changes: 1 addition & 1 deletion core/src/main/kotlin/voodoo/builder/Resolve.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ suspend fun resolve(
val provider = voodoo.provider.Providers.forEntry(entry)!!

entry.takeUnless { it is FlatEntry.Noop }?.let { entry ->
val lockEntry = provider.resolve(entry, modPack.mcVersion, addEntries)
val lockEntry = provider.resolve(entry, modPack, addEntries)
logger.debug("received locked entry: $lockEntry")

logger.debug("validating: $lockEntry")
Expand Down
15 changes: 12 additions & 3 deletions core/src/main/kotlin/voodoo/curse/CurseClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.json.Json
import mu.KLogging
import voodoo.data.ModloaderPattern
import voodoo.data.curse.Addon
import voodoo.data.curse.AddonFile
import voodoo.data.curse.FileID
Expand Down Expand Up @@ -96,7 +97,7 @@ object CurseClient : KLogging() {
slug?.let {
filters += "slug: \"$it\""
}
logger.info("post $url $filters")
logger.info { "post $url $filters" }
val requestBody = GraphQLRequest(
query = """{
| addons(${filters.joinToString(", ")}) {
Expand Down Expand Up @@ -266,7 +267,7 @@ object CurseClient : KLogging() {
private val getAddonCache: MutableMap<ProjectID, Addon?> = HashMap(1 shl 0)

suspend fun getAddon(addonId: ProjectID, fail: Boolean = true): Addon? {
if (!addonId.valid) throw IllegalStateException("invalid project id")
if (!addonId.valid) throw IllegalStateException("invalid project id: $addonId")
return getAddonCache.getOrPut(addonId) { getAddonCall(addonId, fail) }
}

Expand Down Expand Up @@ -408,7 +409,8 @@ object CurseClient : KLogging() {

suspend fun findFile(
entry: FlatEntry.Curse,
mcVersion: String
mcVersion: String,
modloader: ModloaderPattern?
): Triple<ProjectID, FileID, String> {
val mcVersions = listOf(mcVersion) + entry.validMcVersions
val slug = entry.id // TODO: maybe make into separate property
Expand All @@ -417,6 +419,13 @@ object CurseClient : KLogging() {
var addonId = entry.projectID
val fileNameRegex = entry.fileNameRegex

if(modloader is ModloaderPattern.Forge) {
entry.invalidMcVersions += "Fabric"
}
if(modloader is ModloaderPattern.Fabric) {
entry.invalidMcVersions += "Forge"
}

val addon = if (!addonId.valid) {
// slug.takeUnless { it.isBlank() }
// ?.let { getAddonBySlug(it) }
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/kotlin/voodoo/provider/CurseProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package voodoo.provider

import com.eyeem.watchadoin.Stopwatch
import kotlinx.coroutines.channels.SendChannel
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.runBlocking
import voodoo.curse.CurseClient
import voodoo.curse.CurseClient.findFile
Expand All @@ -16,6 +15,7 @@ import voodoo.data.curse.CurseDependencyType
import voodoo.data.curse.FileID
import voodoo.data.curse.ProjectID
import voodoo.data.flat.FlatEntry
import voodoo.data.flat.FlatModPack
import voodoo.data.lock.LockEntry
import voodoo.memoize
import voodoo.util.download
Expand All @@ -38,11 +38,11 @@ object CurseProvider : ProviderBase("Curse Provider") {

override suspend fun resolve(
entry: FlatEntry,
mcVersion: String,
modPack: FlatModPack,
addEntry: SendChannel<FlatEntry>
): LockEntry {
entry as FlatEntry.Curse
val (projectID, fileID, path) = findFile(entry, mcVersion)
val (projectID, fileID, path) = findFile(entry, modPack.mcVersion, modPack.modloader)

// synchronized(resolved) {
// logger.info("resolved: ${resolved.count()} unique entries")
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/kotlin/voodoo/provider/DirectProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package voodoo.provider

import com.eyeem.watchadoin.Stopwatch
import kotlinx.coroutines.channels.SendChannel
import kotlinx.coroutines.flow.FlowCollector
import voodoo.data.EntryReportData
import voodoo.data.flat.FlatEntry
import voodoo.data.flat.FlatModPack
import voodoo.data.lock.LockEntry
import voodoo.util.download
import java.io.File
Expand All @@ -18,7 +18,7 @@ import java.net.URL
object DirectProvider : ProviderBase("Direct Provider") {
override suspend fun resolve(
entry: FlatEntry,
mcVersion: String,
modPack: FlatModPack,
addEntry: SendChannel<FlatEntry>
): LockEntry {
entry as FlatEntry.Direct
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 @@ -3,12 +3,12 @@ package voodoo.provider
import com.eyeem.watchadoin.Stopwatch
import kotlinx.coroutines.channels.SendChannel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.runBlocking
import voodoo.core.GeneratedConstants
import voodoo.data.EntryReportData
import voodoo.data.Quadruple
import voodoo.data.flat.FlatEntry
import voodoo.data.flat.FlatModPack
import voodoo.data.lock.LockEntry
import voodoo.memoize
import voodoo.util.download
Expand All @@ -30,7 +30,7 @@ object JenkinsProvider : ProviderBase("Jenkins Provider") {

override suspend fun resolve(
entry: FlatEntry,
mcVersion: String,
modPack: FlatModPack,
addEntry: SendChannel<FlatEntry>
): LockEntry {
entry as FlatEntry.Jenkins
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/kotlin/voodoo/provider/LocalProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package voodoo.provider

import com.eyeem.watchadoin.Stopwatch
import kotlinx.coroutines.channels.SendChannel
import kotlinx.coroutines.flow.FlowCollector
import voodoo.data.EntryReportData
import voodoo.data.flat.FlatEntry
import voodoo.data.flat.FlatModPack
import voodoo.data.lock.LockEntry
import java.io.File

Expand All @@ -16,7 +16,7 @@ import java.io.File
object LocalProvider : ProviderBase("Local Provider") {
override suspend fun resolve(
entry: FlatEntry,
mcVersion: String,
modPack: FlatModPack,
addEntry: SendChannel<FlatEntry>
): LockEntry {
entry as FlatEntry.Local
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/kotlin/voodoo/provider/NoopProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package voodoo.provider

import com.eyeem.watchadoin.Stopwatch
import kotlinx.coroutines.channels.SendChannel
import kotlinx.coroutines.flow.FlowCollector
import voodoo.data.EntryReportData
import voodoo.data.flat.FlatEntry
import voodoo.data.flat.FlatModPack
import voodoo.data.lock.LockEntry
import java.io.File

Expand All @@ -16,7 +16,7 @@ import java.io.File
object NoopProvider : ProviderBase("Noop Provider") {
override suspend fun resolve(
entry: FlatEntry,
mcVersion: String,
modPack: FlatModPack,
addEntry: SendChannel<FlatEntry>
): LockEntry {
entry as FlatEntry.Noop
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/kotlin/voodoo/provider/ProviderBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package voodoo.provider

import com.eyeem.watchadoin.Stopwatch
import kotlinx.coroutines.channels.SendChannel
import kotlinx.coroutines.flow.FlowCollector
import mu.KLogging
import voodoo.data.DependencyType
import voodoo.data.EntryReportData
import voodoo.data.flat.FlatEntry
import voodoo.data.flat.FlatModPack
import voodoo.data.lock.LockEntry
import java.io.File
import java.time.Instant
Expand All @@ -26,7 +26,11 @@ abstract class ProviderBase(

open fun reset() {}

open suspend fun resolve(entry: FlatEntry, mcVersion: String, addEntry: SendChannel<FlatEntry>): LockEntry {
open suspend fun resolve(
entry: FlatEntry,
modPack: FlatModPack,
addEntry: SendChannel<FlatEntry>
): LockEntry {
logger.info("[$name] resolve ${entry.id}")
throw NotImplementedError("unable to resolve")
}
Expand Down
37 changes: 2 additions & 35 deletions samples/config.json5
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,17 @@
"section": "RESOURCE_PACKS",
"mcVersions": []
},
"Fabric15": {
"section": "MODS",
"categories": [
"Fabric"
],
"mcVersions": [
"1.15",
"1.15.1",
"1.15.2"
]
},
"Fabric16": {
"Fabric": {
"section": "MODS",
"categories": [
"Fabric"
],
"mcVersions": [
"1.16",
"1.16.1",
"1.16.2",
"1.16.3",
"1.16.4"
]
}
},
"forgeGenerators": {
"Forge": {
"mcVersions": [
"1.12.2",
"1.15.2",
"1.16.4",
"1.16.5"
]
},
"Forge_12_2": {
"mcVersions": [
"1.12.2"
]
},
"Forge_15_2": {
"mcVersions": [
"1.15.2"
]
}
"Forge": {},
},
"fabricGenerators": {
"Fabric": {
Expand Down
20 changes: 10 additions & 10 deletions samples/fabricpack/152Version.voodoo.json5
Original file line number Diff line number Diff line change
Expand Up @@ -10,60 +10,60 @@
"mods": [
{
"type": "curse",
"projectName": "Fabric15/fabric-api"
"projectName": "Fabric/fabric-api"
},
{
"type": "curse",
"projectName": "Fabric15/betternether"
"projectName": "Fabric/betternether"
},
{
"type": "curse",
"projectName": "Fabric15/tab-inventory-fabric"
"projectName": "Fabric/tab-inventory-fabric"
},
{
"type": "curse",
"projectName": "Fabric15/campanion"
"projectName": "Fabric/campanion"
},
{
"type": "curse",
"applyOverrides": [
"client"
],
"projectName": "Fabric15/roughly-enough-items"
"projectName": "Fabric/roughly-enough-items"
},
{
"type": "curse",
"applyOverrides": [
"client"
],
"projectName": "Fabric15/roughly-enough-resources"
"projectName": "Fabric/roughly-enough-resources"
},
{
"type": "curse",
"applyOverrides": [
"client"
],
"projectName": "Fabric15/modmenu"
"projectName": "Fabric/modmenu"
},
{
"type": "curse",
"applyOverrides": [
"client",
"optionalStarred"
],
"projectName": "Fabric15/mouse-wheelie"
"projectName": "Fabric/mouse-wheelie"
},
{
"type": "curse",
"applyOverrides": [
"client",
"optionalStarred"
],
"projectName": "Fabric15/appleskin"
"projectName": "Fabric/appleskin"
},
{
"type": "curse",
"projectName": "Fabric15/hwyla"
"projectName": "Fabric/hwyla"
}
]
}
22 changes: 11 additions & 11 deletions samples/fabricpack/164Version.voodoo.json5
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
"intermediateMappings": "Fabric/1.16.4"
},
"mods": [
"curse=Fabric16/fabric-api",
"curse=Fabric16/betternether",
"curse=Fabric16/betternether",
"curse=Fabric/fabric-api",
"curse=Fabric/betternether",
"curse=Fabric/betternether",
// comment
{
"type": "curse",
"projectName": "Fabric16/tab-inventory-fabric",
"projectName": "Fabric/tab-inventory-fabric",
"validMcVersions": ["1.16", "1.16.1", "1.16.2", "1.16.3"]
},
{
"type": "curse",
"projectName": "Fabric16/campanion",
"projectName": "Fabric/campanion",
},
"curse:client=Fabric16/roughly-enough-items",
"curse:client=Fabric16/roughly-enough-resources",
"curse:client=Fabric16/modmenu",
"curse:client,optionalStarred=Fabric16/mouse-wheelie",
"curse:client,optionalStarred=Fabric16/appleskin",
"curse:client=Fabric/roughly-enough-items",
"curse:client=Fabric/roughly-enough-resources",
"curse:client=Fabric/modmenu",
"curse:client,optionalStarred=Fabric/mouse-wheelie",
"curse:client,optionalStarred=Fabric/appleskin",
{
"type": "curse",
"projectName": "Fabric16/hwyla",
"projectName": "Fabric/hwyla",
"validMcVersions": ["1.16.3"]
},
{
Expand Down
2 changes: 1 addition & 1 deletion samples/fabricpack/lock/0.0.3/lock.pack.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"fabric-api": "REQUIRED"
},
"projectID": 310111,
"fileID": 3175580
"fileID": 3183996
},
{
"type": "curse",
Expand Down
Loading

0 comments on commit bbc3c08

Please sign in to comment.