Fix Minecraft version resolution to CurseForge publisher
This commit is contained in:
parent
d88b1e0485
commit
bf716627a1
@ -1,5 +1,5 @@
|
||||
import { curseforgeClient } from "@/services/clients";
|
||||
import { uploadFile, getGameVersions } from "@/lib/curseforge";
|
||||
import { uploadFile, getGameVersions, getMinecraftVersions } from "@/lib/curseforge";
|
||||
import { resolveVersionName } from "@/lib/utils/format";
|
||||
import type { UploadMetadata } from "@/types";
|
||||
import { PlatformPublishFn } from "../publish.schemas";
|
||||
@ -10,12 +10,18 @@ export const publishCurseForgeVersion: PlatformPublishFn = async (ctx, mcVersion
|
||||
const displayName = resolveVersionName(config.curseforge.version_name, config, input.version, mcVersion);
|
||||
|
||||
const gameVersions = await getGameVersions(curseforgeClient);
|
||||
const minecraftVersions = await getMinecraftVersions(curseforgeClient);
|
||||
|
||||
const resolveId = (name: string): number => {
|
||||
const found = gameVersions.find((v) => v.name === name);
|
||||
if (!found) throw new Error(`Game version "${name}" not found in CurseForge`);
|
||||
return found.id;
|
||||
};
|
||||
const resolveMinecraftVersionId = (name: string): number => {
|
||||
const found = minecraftVersions.find((v) => v.versionString === name);
|
||||
if (!found) throw new Error(`Minecraft version "${name}" not found in CurseForge`);
|
||||
return found.gameVersionId;
|
||||
};
|
||||
|
||||
const metadata: UploadMetadata = {
|
||||
changelog: input.changelog,
|
||||
|
||||
@ -58,6 +58,7 @@ export const MinecraftGameVersionSchema = z.object({
|
||||
/** 版本类型状态:1=Normal 2=Deleted */
|
||||
gameVersionTypeStatus: z.union([z.literal(1), z.literal(2)]),
|
||||
}).pick({
|
||||
gameVersionId: true,
|
||||
versionString: true,
|
||||
});
|
||||
export type MinecraftGameVersion = z.infer<typeof MinecraftGameVersionSchema>;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user