diff --git a/src/services/publish.schemas.ts b/src/services/publish.schemas.ts index d8734dd..b470f4c 100644 --- a/src/services/publish.schemas.ts +++ b/src/services/publish.schemas.ts @@ -51,10 +51,9 @@ export const PlatformResultSchema = z.object({ errors: z.array(z.string()), }); -export const PublishResultSchema = z.object({ - modrinth: PlatformResultSchema, - curseforge: PlatformResultSchema, -}); +export const PublishResultSchema = z.object(Object.fromEntries(platforms.map(platform => [ + platform, PlatformResultSchema +]))); // ── Inferred types ───────────────────────────────────── diff --git a/src/services/publish.ts b/src/services/publish.ts index 69811f2..28c9fe4 100644 --- a/src/services/publish.ts +++ b/src/services/publish.ts @@ -134,19 +134,19 @@ export const appRouter = t.router({ const ctx: PlatformContext = { input, config }; - const [modrinthSettled, curseforgeSettled] = await Promise.allSettled( - platforms.map(platform => runPlatform(platform, input.mcVersions[platform], ctx)) - ); + const results = await Promise.all(platforms.map(async (platform) => { + try { + const result = await runPlatform(platform, input.mcVersions[platform], ctx); + return {platform, result}; + } catch (err) { + return { + platform, + result: { success: 0, fail: 0, errors: [errorMessage(err)] } + } + } + })); - const modrinth: PlatformResult = modrinthSettled.status === "fulfilled" - ? modrinthSettled.value - : { success: 0, fail: 0, errors: [errorMessage(modrinthSettled.reason)] }; - - const curseforge: PlatformResult = curseforgeSettled.status === "fulfilled" - ? curseforgeSettled.value - : { success: 0, fail: 0, errors: [errorMessage(curseforgeSettled.reason)] }; - - return { modrinth, curseforge }; + return Object.fromEntries(results.map(result => [result.platform, result.result])); }), progress: t.procedure.subscription(async function* (opts) {