browser-extension-manager 1.3.14 → 1.3.15

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.
@@ -320,42 +320,23 @@ async function publishToEdge() {
320
320
  'X-ClientID': clientId,
321
321
  };
322
322
 
323
- // Step 1: Try to submit first to check if there's a pending submission
324
- // This is faster than uploading first, since upload always succeeds
325
- logger.log('[edge] Checking for pending submissions...');
323
+ // Helper to parse Edge API response (handles empty bodies)
324
+ async function parseEdgeResponse(response, label) {
325
+ const text = await response.text();
326
+ logger.log(`[edge] ${label} - Status: ${response.status}, Body: ${text || '(empty)'}`);
326
327
 
327
- const publishUrl = `https://api.addons.microsoftedge.microsoft.com/v1/products/${productId}/submissions`;
328
- const checkResponse = await fetch(publishUrl, {
329
- method: 'POST',
330
- headers: {
331
- ...edgeHeaders,
332
- 'Content-Type': 'application/json',
333
- },
334
- body: JSON.stringify({
335
- notes: `Check for pending submission`,
336
- }),
337
- });
338
-
339
- const checkData = await checkResponse.json().catch(() => null);
340
-
341
- // Log the response for debugging
342
- logger.log(`[edge] Submission check response: ${JSON.stringify(checkData)}`);
343
-
344
- // Check if there's a pending submission blocking us
345
- if (checkData && checkData.status === 'Failed') {
346
- if (checkData.errorCode === 'InProgressSubmission') {
347
- throw new Error('Extension already has a pending submission in review. Wait for it to complete before publishing again.');
348
- }
349
- if (checkData.errorCode === 'UnpublishInProgress') {
350
- throw new Error('Extension is being unpublished. Wait for unpublish to complete before publishing.');
328
+ if (!text) {
329
+ return { status: response.status, data: null };
351
330
  }
352
- // If it failed for another reason (like no draft package), that's expected - continue to upload
353
- if (checkData.errorCode !== 'NoDraftPackage' && checkData.errorCode !== 'NoPackageToPublish') {
354
- logger.log(`[edge] Check failed with: ${checkData.errorCode} - ${checkData.message}`);
331
+
332
+ try {
333
+ return { status: response.status, data: JSON.parse(text) };
334
+ } catch (e) {
335
+ return { status: response.status, data: text };
355
336
  }
356
337
  }
357
338
 
358
- // Step 2: Upload the package
339
+ // Step 1: Upload the package first
359
340
  logger.log('[edge] Uploading to Microsoft Edge Add-ons...');
360
341
 
361
342
  const zipBuffer = jetpack.read(PATHS.chromium.zip, 'buffer');
@@ -370,17 +351,16 @@ async function publishToEdge() {
370
351
  body: zipBuffer,
371
352
  });
372
353
 
354
+ const upload = await parseEdgeResponse(uploadResponse, 'Upload response');
355
+
373
356
  if (!uploadResponse.ok) {
374
- const errorText = await uploadResponse.text();
375
- throw new Error(`Edge upload error: ${uploadResponse.status} - ${errorText}`);
357
+ throw new Error(`Edge upload error: ${upload.status} - ${JSON.stringify(upload.data)}`);
376
358
  }
377
359
 
378
- const uploadData = await uploadResponse.json().catch(() => null);
379
- logger.log(`[edge] Upload response: ${JSON.stringify(uploadData)}`);
380
-
381
360
  logger.log('[edge] Package uploaded, submitting for review...');
382
361
 
383
- // Step 3: Submit for review
362
+ // Step 2: Submit for review - this is where we'll get InProgressSubmission if there's a pending review
363
+ const publishUrl = `https://api.addons.microsoftedge.microsoft.com/v1/products/${productId}/submissions`;
384
364
  const publishResponse = await fetch(publishUrl, {
385
365
  method: 'POST',
386
366
  headers: {
@@ -392,25 +372,33 @@ async function publishToEdge() {
392
372
  }),
393
373
  });
394
374
 
395
- const publishData = await publishResponse.json().catch(() => null);
396
-
397
- // Log the full response
398
- logger.log(`[edge] Publish response: ${JSON.stringify(publishData)}`);
375
+ const publish = await parseEdgeResponse(publishResponse, 'Publish response');
399
376
 
400
- // Check for HTTP errors
377
+ // Check for HTTP errors (4xx, 5xx)
401
378
  if (!publishResponse.ok) {
402
- throw new Error(`Edge publish error: ${publishResponse.status} - ${JSON.stringify(publishData)}`);
403
- }
404
-
405
- // Check for API-level failures (HTTP 200 but status: "Failed")
406
- if (publishData && publishData.status === 'Failed') {
407
- if (publishData.errorCode === 'InProgressSubmission') {
379
+ // Check if it's a 409 Conflict or similar indicating in-progress submission
380
+ if (publish.status === 409) {
408
381
  throw new Error('Extension already has a pending submission in review. Wait for it to complete before publishing again.');
409
382
  }
410
- if (publishData.errorCode === 'UnpublishInProgress') {
411
- throw new Error('Extension is being unpublished. Wait for unpublish to complete before publishing.');
383
+ throw new Error(`Edge publish error: ${publish.status} - ${JSON.stringify(publish.data)}`);
384
+ }
385
+
386
+ // Check for API-level failures (HTTP 200/202 but status: "Failed" in body)
387
+ if (publish.data && typeof publish.data === 'object') {
388
+ if (publish.data.status === 'Failed') {
389
+ if (publish.data.errorCode === 'InProgressSubmission') {
390
+ throw new Error('Extension already has a pending submission in review. Wait for it to complete before publishing again.');
391
+ }
392
+ if (publish.data.errorCode === 'UnpublishInProgress') {
393
+ throw new Error('Extension is being unpublished. Wait for unpublish to complete before publishing.');
394
+ }
395
+ throw new Error(`Edge publish failed: ${publish.data.message || publish.data.errorCode || 'Unknown error'}`);
412
396
  }
413
- throw new Error(`Edge publish failed: ${publishData.message || publishData.errorCode || 'Unknown error'}`);
397
+ }
398
+
399
+ // HTTP 202 Accepted means submission was queued successfully
400
+ if (publish.status === 202) {
401
+ logger.log('[edge] Submission accepted and queued for review');
414
402
  }
415
403
 
416
404
  logger.log('[edge] Upload complete');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-extension-manager",
3
- "version": "1.3.14",
3
+ "version": "1.3.15",
4
4
  "description": "Browser Extension Manager dependency manager",
5
5
  "main": "dist/index.js",
6
6
  "exports": {