Add TTL cache for game version/loader APIs and enrich upload metadata
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { curseforgeClient } from "@/services/clients";
|
||||
import { uploadFile } from "@/lib/curseforge";
|
||||
import { uploadFile, getGameVersions } from "@/lib/curseforge";
|
||||
import { resolveVersionName, buildJarPath } from "@/lib/utils/format";
|
||||
import { readJarBlob } from "@/lib/utils/file";
|
||||
import type { UploadMetadata } from "@/types";
|
||||
@@ -26,11 +26,24 @@ export async function publishCurseForgeVersion(
|
||||
|
||||
const primaryBlob = readJarBlob(primaryPath);
|
||||
|
||||
const gameVersions = await getGameVersions(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 metadata: UploadMetadata = {
|
||||
changelog: input.changelog,
|
||||
changelogType: "markdown",
|
||||
displayName,
|
||||
releaseType: input.versionType,
|
||||
gameVersions: [
|
||||
resolveId(mcVersion),
|
||||
...config.curseforge.loaders.map(resolveId),
|
||||
...config.curseforge.environment.map(resolveId),
|
||||
],
|
||||
relations: config.curseforge.relations,
|
||||
};
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ export async function publishModrinthVersion(
|
||||
project_id: config.modrinth.project_id,
|
||||
name: versionName,
|
||||
version_number: versionNumber,
|
||||
changelog: input.changelog,
|
||||
game_versions: [mcVersion],
|
||||
version_type: input.versionType,
|
||||
loaders: config.modrinth.loaders,
|
||||
|
||||
Reference in New Issue
Block a user