mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-24 17:30:59 -05:00
Implemented CurseForge publisher
This commit is contained in:
parent
b6f396ffd8
commit
6c9bd908cc
1 changed files with 31 additions and 0 deletions
31
src/publishing/curseforge-publisher.ts
Normal file
31
src/publishing/curseforge-publisher.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue