Skip to content

Commit 987c88e

Browse files
committed
Merge branch 'development' into main
2 parents a7eb44b + eec6259 commit 987c88e

File tree

2 files changed

+12
-41
lines changed

2 files changed

+12
-41
lines changed

src/api/cfapi.nim

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ import cfcore, http
1515
const
1616
## base url of the cfproxy endpoint
1717
addonsBaseUrl = "https://cfproxy.bmpm.workers.dev"
18-
## base url of the curse metadata api endpoint
19-
## used for retrieving mods by their slug, which isn't possible with the curse api
20-
addonsSlugBaseUrl = "https://curse.nikky.moe/graphql"
2118

2219
type
2320
CfApiError* = object of HttpRequestError
@@ -52,15 +49,13 @@ proc fetchAddons*(projectIds: seq[int]): Future[seq[CfAddon]] {.async.} =
5249

5350
proc fetchAddon*(slug: string): Future[CfAddon] {.async.} =
5451
## get the addon matching the `slug`.
55-
let reqBody = %* {
56-
"query": "{ addons(slug: \"" & slug & "\") { id }}"
57-
}
58-
let curseProxyInfo = await post(addonsSlugBaseUrl.Url, body = $reqBody)
59-
let addons = curseProxyInfo.parseJson["data"]["addons"]
60-
if addons.len == 0:
61-
raise newException(CfApiError, "addon with slug '" & slug & "' not found")
62-
let projectId = addons[0]["id"].getInt()
63-
return await fetchAddon(projectId)
52+
let url = addonsBaseUrl & "/v1/mods/search?gameId=432&pageSize=50&sortField=6&sortOrder=desc&slug=" & slug
53+
try:
54+
return get(url.Url).await.parseJson["data"][0].addonFromForgeSvc
55+
except HttpRequestError:
56+
raise newException(CfApiError, "addon with slug '" & $slug & "' not found.")
57+
except IndexDefect:
58+
raise newException(CfApiError, "addon with slug '" & $slug & "' not found. Please add the addon using the project id instead.")
6459

6560
proc fetchAddonFiles*(projectId: int): Future[seq[CfAddonFile]] {.async.} =
6661
## get all addon files associated with the given `projectId`.

tests/cmd/tremove/tremove_without_dependencies.nim

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
discard """
2-
joinable: false
2+
joinable: false
33
batchable: false
44
input: '''
55
y
@@ -26,16 +26,6 @@ let manifestJson = %* {
2626
"author": "testauthor",
2727
"name": "testmodpack123",
2828
"files": [
29-
{
30-
"projectID": 60089,
31-
"fileID": 3202662,
32-
"required": true,
33-
"__meta": {
34-
"name": "Mouse Tweaks",
35-
"explicit": true,
36-
"dependencies": []
37-
}
38-
},
3929
{
4030
"projectID": 238222,
4131
"fileID": 3383205,
@@ -46,18 +36,6 @@ let manifestJson = %* {
4636
"dependencies": []
4737
}
4838
},
49-
{
50-
"projectID": 240630,
51-
"fileID": 3336760,
52-
"required": true,
53-
"__meta": {
54-
"name": "Just Enough Resources (JER)",
55-
"explicit": true,
56-
"dependencies": [
57-
238222
58-
]
59-
}
60-
},
6139
{
6240
"projectID": 243121,
6341
"fileID": 3366626,
@@ -88,11 +66,9 @@ block:
8866

8967
createDir("./modpack")
9068
writeFile("./modpack/manifest.json", manifestJson.pretty)
91-
paxRemove("mouse", strategy = "recommended")
69+
paxRemove("jei", strategy = "recommended")
9270

9371
let manifest = readFile("./modpack/manifest.json").parseJson
94-
doAssert manifest["files"].getElems().len == 4
95-
doAssert manifest["files"][0]["__meta"]["name"].getStr() == "Just Enough Items (JEI)"
96-
doAssert manifest["files"][1]["__meta"]["name"].getStr() == "Just Enough Resources (JER)"
97-
doAssert manifest["files"][2]["__meta"]["name"].getStr() == "Quark"
98-
doAssert manifest["files"][3]["__meta"]["name"].getStr() == "AutoRegLib"
72+
doAssert manifest["files"].getElems().len == 2
73+
doAssert manifest["files"][0]["__meta"]["name"].getStr() == "Quark"
74+
doAssert manifest["files"][1]["__meta"]["name"].getStr() == "AutoRegLib"

0 commit comments

Comments
 (0)