diff --git a/src/lib/curseforge/client.ts b/src/lib/curseforge/client.ts index 917f750..8c4a7dc 100644 --- a/src/lib/curseforge/client.ts +++ b/src/lib/curseforge/client.ts @@ -79,23 +79,18 @@ export class CurseForgeClient { if (isPublishDryRun()) { return interceptUpload("CurseForge", "POST", url, body) as Promise; } - // ⚠️ 真实上传已暂时禁用,防止调试期间误传。 - // 恢复方式:删除下面的 throw,并取消注释 fetch 代码块。 - throw new Error( - "真实上传已暂时禁用,请设置 PUBLISH_DRY_RUN=1 使用模拟发布", - ); - // const res = await fetch(url, { - // method: "POST", - // headers: this.uploadHeaders(), - // body, - // }); - // if (!res.ok) { - // const reqBody = summarizeFormData(body); - // const resBody = await readErrorBody(res); - // throw new Error( - // `CurseForge Upload POST ${path} failed: ${res.status} ${res.statusText}\n\n--Request--:\n${reqBody}\n\n--Response--:\n${resBody}`, - // ); - // } - // return res.json() as Promise; + const res = await fetch(url, { + method: "POST", + headers: this.uploadHeaders(), + body, + }); + if (!res.ok) { + const reqBody = summarizeFormData(body); + const resBody = await readErrorBody(res); + throw new Error( + `CurseForge Upload POST ${path} failed: ${res.status} ${res.statusText}\n\n--Request--:\n${reqBody}\n\n--Response--:\n${resBody}`, + ); + } + return res.json() as Promise; } } diff --git a/src/lib/modrinth/client.ts b/src/lib/modrinth/client.ts index a6f4191..8d5bd02 100644 --- a/src/lib/modrinth/client.ts +++ b/src/lib/modrinth/client.ts @@ -46,23 +46,18 @@ export class ModrinthClient { if (isPublishDryRun()) { return interceptUpload("Modrinth", "POST", url, body) as Promise; } - // ⚠️ 真实上传已暂时禁用,防止调试期间误传。 - // 恢复方式:删除下面的 throw,并取消注释 fetch 代码块。 - throw new Error( - "真实上传已暂时禁用,请设置 PUBLISH_DRY_RUN=1 使用模拟发布", - ); - // const res = await fetch(url, { - // method: "POST", - // headers: this.headers(), - // body, - // }); - // if (!res.ok) { - // const reqBody = summarizeFormData(body); - // const resBody = await readErrorBody(res); - // throw new Error( - // `Modrinth API POST ${path} failed: ${res.status} ${res.statusText}\n\n--Request--:\n${reqBody}\n\n--Response--:\n${resBody}`, - // ); - // } - // return res.json() as Promise; + const res = await fetch(url, { + method: "POST", + headers: this.headers(), + body, + }); + if (!res.ok) { + const reqBody = summarizeFormData(body); + const resBody = await readErrorBody(res); + throw new Error( + `Modrinth API POST ${path} failed: ${res.status} ${res.statusText}\n\n--Request--:\n${reqBody}\n\n--Response--:\n${resBody}`, + ); + } + return res.json() as Promise; } }