mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-25 09:51:01 -05:00
CurseForgePublisher
makes use of relations
now
I hope so...
This commit is contained in:
parent
5e7fd885b0
commit
6e417e8ee2
1 changed files with 21 additions and 2 deletions
|
@ -2,13 +2,23 @@ import { File } from "../../utils/file";
|
|||
import ModPublisher from "../mod-publisher";
|
||||
import PublisherTarget from "../publisher-target";
|
||||
import { convertToCurseForgeVersions, uploadFile } from "../../utils/curseforge-utils";
|
||||
import Dependency from "../../metadata/dependency";
|
||||
import DependencyKind from "../../metadata/dependency-kind";
|
||||
|
||||
const forgeDependencyKinds = new Map([
|
||||
[DependencyKind.Depends, "requiredDependency"],
|
||||
[DependencyKind.Recommends, "optionalDependency"],
|
||||
[DependencyKind.Suggests, "optionalDependency"],
|
||||
[DependencyKind.Includes, "embeddedLibrary"],
|
||||
[DependencyKind.Breaks, "incompatible"],
|
||||
]);
|
||||
|
||||
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> {
|
||||
protected async publishMod(id: string, token: string, name: string, _version: string, channel: string, loaders: string[], gameVersions: string[], java: string[], changelog: string, files: File[], dependencies: Dependency[]): Promise<void> {
|
||||
let parentFileId = undefined;
|
||||
const versions = await convertToCurseForgeVersions(gameVersions, loaders, java, token);
|
||||
|
||||
|
@ -19,7 +29,16 @@ export default class CurseForgePublisher extends ModPublisher {
|
|||
displayName: (parentFileId || !name) ? file.name : name,
|
||||
parentFileID: parentFileId,
|
||||
releaseType: channel,
|
||||
gameVersions: parentFileId ? undefined : versions
|
||||
gameVersions: parentFileId ? undefined : versions,
|
||||
relations: parentFileId ? undefined : {
|
||||
projects: dependencies
|
||||
.filter((x, _, self) => x.kind !== DependencyKind.Suggests || !self.find(y => y.id === x.id && y.kind !== DependencyKind.Suggests))
|
||||
.map(x => ({
|
||||
slug: x.getProjectSlug(this.target),
|
||||
type: forgeDependencyKinds.get(x.kind)
|
||||
}))
|
||||
.filter(x => x.slug && x.type)
|
||||
}
|
||||
};
|
||||
|
||||
const fileId = await uploadFile(id, data, file, token);
|
||||
|
|
Loading…
Reference in a new issue