@ucdjs/release-scripts 0.1.0-beta.52 → 0.1.0-beta.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +26 -3
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -2257,6 +2257,16 @@ function toNPMError(operation, error, code) {
2257
2257
  status: formatted.status
2258
2258
  };
2259
2259
  }
2260
+ function classifyPublishErrorCode(error) {
2261
+ const formatted = formatUnknownError(error);
2262
+ const combined = [formatted.message, formatted.stderr].filter(Boolean).join("\n");
2263
+ if (combined.includes("E403") || combined.toLowerCase().includes("access token expired or revoked")) return "E403";
2264
+ if (combined.includes("EPUBLISHCONFLICT") || combined.includes("E409") || combined.includes("409 Conflict") || combined.includes("Failed to save packument")) return "EPUBLISHCONFLICT";
2265
+ if (combined.includes("EOTP")) return "EOTP";
2266
+ }
2267
+ function wait(ms) {
2268
+ return new Promise((resolve) => setTimeout(resolve, ms));
2269
+ }
2260
2270
  /**
2261
2271
  * Get the NPM registry URL
2262
2272
  * Respects NPM_CONFIG_REGISTRY environment variable, defaults to npmjs.org
@@ -2328,7 +2338,13 @@ async function publishPackage(packageName, version, workspaceRoot, options) {
2328
2338
  if (publishTag) args.push("--tag", publishTag);
2329
2339
  const env = { ...process.env };
2330
2340
  if (options.npm.provenance) env.NPM_CONFIG_PROVENANCE = "true";
2331
- try {
2341
+ const maxAttempts = 4;
2342
+ const backoffMs = [
2343
+ 3e3,
2344
+ 8e3,
2345
+ 15e3
2346
+ ];
2347
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) try {
2332
2348
  await runIfNotDry("pnpm", args, { nodeOptions: {
2333
2349
  cwd: workspaceRoot,
2334
2350
  stdio: "inherit",
@@ -2336,9 +2352,16 @@ async function publishPackage(packageName, version, workspaceRoot, options) {
2336
2352
  } });
2337
2353
  return ok(void 0);
2338
2354
  } catch (error) {
2339
- const errorMessage = formatUnknownError(error).message;
2340
- return err(toNPMError("publishPackage", error, errorMessage.includes("E403") ? "E403" : errorMessage.includes("EPUBLISHCONFLICT") ? "EPUBLISHCONFLICT" : errorMessage.includes("EOTP") ? "EOTP" : void 0));
2355
+ const code = classifyPublishErrorCode(error);
2356
+ if (code === "EPUBLISHCONFLICT" && attempt < maxAttempts) {
2357
+ const delay = backoffMs[attempt - 1] ?? backoffMs[backoffMs.length - 1];
2358
+ logger.warn(`Publish conflict for ${packageName}@${version} (attempt ${attempt}/${maxAttempts}). Retrying in ${Math.ceil(delay / 1e3)}s...`);
2359
+ await wait(delay);
2360
+ continue;
2361
+ }
2362
+ return err(toNPMError("publishPackage", error, code));
2341
2363
  }
2364
+ return err(toNPMError("publishPackage", /* @__PURE__ */ new Error(`Failed to publish ${packageName}@${version} after ${maxAttempts} attempts`), "EPUBLISHCONFLICT"));
2342
2365
  }
2343
2366
 
2344
2367
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucdjs/release-scripts",
3
- "version": "0.1.0-beta.52",
3
+ "version": "0.1.0-beta.53",
4
4
  "description": "@ucdjs release scripts",
5
5
  "type": "module",
6
6
  "license": "MIT",