-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ability to convert addons/addon files to json
- Loading branch information
1 parent
974778a
commit 956aec6
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import std/[json, sequtils, sugar] | ||
import api/cfcore | ||
import modpack/version | ||
|
||
proc initCfAddonFile(fileId: int, name: string, gameVersions: seq[string], releaseType: CfAddonFileReleaseType): CfAddonFile = | ||
result = CfAddonFile() | ||
result.fileId = fileId | ||
result.name = name | ||
result.releaseType = releaseType | ||
result.downloadUrl = "https://download-here.com/" & name | ||
result.gameVersions = gameVersions.map((x) => x.Version) | ||
|
||
proc initCfAddon(projectId: int, name: string, gameVersionLatestFiles: seq[tuple[version: Version, fileId: int]]): CfAddon = | ||
result = CfAddon() | ||
result.projectId = projectId | ||
result.name = name | ||
result.description = "description" | ||
result.websiteUrl = "https://website-url.com/" & name | ||
result.authors = @["user1", "user2"] | ||
result.downloads = 102039 | ||
result.popularity = 0.5 | ||
result.latestFiles = @[] | ||
result.gameVersionLatestFiles = gameVersionLatestFiles | ||
|
||
block: # AddonFile from/to JSON | ||
let addonFile = initCfAddonFile(300, "jei-1.0.2.jar", @["1.16.1", "1.16.2", "Forge"], CfAddonFileReleaseType.Beta) | ||
|
||
doAssert addonFile.toJson.addonFileFromForgeSvc.toJson == addonFile.toJson | ||
|
||
block: # Addon from/to JSON | ||
let addon = initCfAddon(200, "Just Enough Items (JEI)", @[(version: "1.16".Version, fileId: 2)]) | ||
|
||
doAssert addon.toJson.addonFromForgeSvc.toJson == addon.toJson |