Implemented CurseForge publisher

This commit is contained in:
Kir_Antipov 2021-09-24 17:08:51 +03:00
parent b6f396ffd8
commit 6c9bd908cc

View file

@ -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<void> {
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;
}
}
}
}