mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-21 16:00:59 -05:00
parent
69d94c54c3
commit
689f343a8c
2 changed files with 12 additions and 3 deletions
|
@ -3,6 +3,7 @@ import { Dependency } from "@/dependencies";
|
|||
import { PlatformType } from "@/platforms/platform-type";
|
||||
import { GenericPlatformUploader, GenericPlatformUploaderOptions } from "@/platforms/generic-platform-uploader";
|
||||
import { ArgumentError } from "@/utils/errors";
|
||||
import { stringEquals } from "@/utils/string-utils";
|
||||
import { CurseForgeDependency } from "./curseforge-dependency";
|
||||
import { CurseForgeDependencyType } from "./curseforge-dependency-type";
|
||||
import { CurseForgeEternalApiClient } from "./curseforge-eternal-api-client";
|
||||
|
@ -136,13 +137,17 @@ export class CurseForgeUploader extends GenericPlatformUploader<CurseForgeUpload
|
|||
*/
|
||||
private async convertToCurseForgeDependencies(dependencies: Dependency[], eternalApi: CurseForgeEternalApiClient): Promise<CurseForgeDependency[]> {
|
||||
const simpleDependencies = this.convertToSimpleDependencies(dependencies, CurseForgeDependencyType.fromDependencyType);
|
||||
const curseforgeDependencies = await Promise.all(simpleDependencies.map(async ([id, type]) => ({
|
||||
const curseForgeDependencies = await Promise.all(simpleDependencies.map(async ([id, type]) => ({
|
||||
slug: isCurseForgeProjectId(id)
|
||||
? await eternalApi.getProject(id).catch(() => undefined as CurseForgeProject).then(x => x?.slug)
|
||||
: id,
|
||||
|
||||
type,
|
||||
})));
|
||||
return curseforgeDependencies.filter(x => x.slug && x.type);
|
||||
const uniqueCurseForgeDependencies = curseForgeDependencies
|
||||
.filter(x => x.slug && x.type)
|
||||
.filter((x, i, self) => i === self.findIndex(y => stringEquals(x.slug, y.slug, { ignoreCase: true })));
|
||||
|
||||
return uniqueCurseForgeDependencies;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,7 +127,11 @@ export class ModrinthUploader extends GenericPlatformUploader<ModrinthUploaderOp
|
|||
project_id: await api.getProjectId(id).catch(() => undefined as string),
|
||||
dependency_type: type,
|
||||
})));
|
||||
return modrinthDependencies.filter(x => x.project_id && x.dependency_type);
|
||||
const uniqueModrinthDependencies = modrinthDependencies
|
||||
.filter(x => x.project_id && x.dependency_type)
|
||||
.filter((x, i, self) => i === self.findIndex(y => x.project_id === y.project_id));
|
||||
|
||||
return uniqueModrinthDependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue