From 6c9bd908cc788ec8b9cbe7f33536982649624e0a Mon Sep 17 00:00:00 2001 From: Kir_Antipov Date: Fri, 24 Sep 2021 17:08:51 +0300 Subject: [PATCH] Implemented CurseForge publisher --- src/publishing/curseforge-publisher.ts | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/publishing/curseforge-publisher.ts diff --git a/src/publishing/curseforge-publisher.ts b/src/publishing/curseforge-publisher.ts new file mode 100644 index 0000000..9905415 --- /dev/null +++ b/src/publishing/curseforge-publisher.ts @@ -0,0 +1,31 @@ +import { File } from "../utils/file-utils"; +import ModPublisher from "./mod-publisher"; +import PublisherTarget from "./publisher-target"; +import { convertToCurseForgeVersions, uploadFile } from "../utils/curseforge-utils"; + +export default class CurseForgePublisher extends ModPublisher { + public get target(): PublisherTarget { + return PublisherTarget.CurseForge; + } + + protected async publishMod(id: string, token: string, name: string, _version: string, channel: string, loaders: string[], gameVersions: string[], java: string[], changelog: string, files: File[]): Promise { + let parentFileId = undefined; + const versions = await convertToCurseForgeVersions(gameVersions, loaders, java, token); + + for (const file of files) { + const data = { + changelog, + changelogType: "markdown", + displayName: name, + parentFileID: parentFileId, + releaseType: channel, + gameVersions: parentFileId ? undefined : versions + }; + + const fileId = await uploadFile(id, data, file, token); + if (!parentFileId) { + parentFileId = fileId; + } + } + } +} \ No newline at end of file