@sentry/bundler-plugin-core 4.1.1 → 4.3.0

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.
package/dist/cjs/index.js CHANGED
@@ -8102,7 +8102,7 @@ function normalizeUserOptions(userOptions) {
8102
8102
  * @returns `true` if the options are valid, `false` otherwise
8103
8103
  */
8104
8104
  function validateOptions(options, logger) {
8105
- var _options$release, _options$release2, _options$release3;
8105
+ var _options$release, _options$release2;
8106
8106
  var setCommits = (_options$release = options.release) === null || _options$release === void 0 ? void 0 : _options$release.setCommits;
8107
8107
  if (setCommits) {
8108
8108
  if (!setCommits.auto && !(setCommits.repo && setCommits.commit)) {
@@ -8113,7 +8113,7 @@ function validateOptions(options, logger) {
8113
8113
  logger.warn("The `setCommits` options includes `auto` but also `repo` and `commit`.", "Ignoring `repo` and `commit`.", "Please only set either `auto` or both, `repo` and `commit`.");
8114
8114
  }
8115
8115
  }
8116
- if ((_options$release2 = options.release) !== null && _options$release2 !== void 0 && _options$release2.deploy && !((_options$release3 = options.release) !== null && _options$release3 !== void 0 && _options$release3.deploy.env)) {
8116
+ if ((_options$release2 = options.release) !== null && _options$release2 !== void 0 && _options$release2.deploy && _typeof(options.release.deploy) === "object" && !options.release.deploy.env) {
8117
8117
  logger.error("The `deploy` option was specified but is missing the required `env` property.", "Please set the `env` property.");
8118
8118
  return false;
8119
8119
  }
@@ -8307,7 +8307,7 @@ function createSentryInstance(options, shouldSendTelemetry, buildTool) {
8307
8307
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
8308
8308
  tracesSampleRate: 1,
8309
8309
  sampleRate: 1,
8310
- release: "4.1.1",
8310
+ release: "4.3.0",
8311
8311
  integrations: [],
8312
8312
  tracePropagationTargets: ["sentry.io/api"],
8313
8313
  stackParser: stackParser,
@@ -8752,7 +8752,7 @@ function createCliInstance(options) {
8752
8752
  silent: options.silent,
8753
8753
  url: options.url,
8754
8754
  vcsRemote: options.release.vcsRemote,
8755
- headers: _objectSpread2({}, getTraceData())
8755
+ headers: _objectSpread2(_objectSpread2({}, getTraceData()), options.headers)
8756
8756
  });
8757
8757
  }
8758
8758
 
@@ -8910,7 +8910,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8910
8910
  });
8911
8911
 
8912
8912
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
8913
- process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.1.1");
8913
+ process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.3.0");
8914
8914
 
8915
8915
  // Not a bulletproof check but should be good enough to at least sometimes determine
8916
8916
  // if the plugin is called in dev/watch mode or for a prod build. The important part
@@ -9302,77 +9302,116 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9302
9302
  }))();
9303
9303
  },
9304
9304
  /**
9305
- * Uploads sourcemaps using the "Debug ID" method. This function takes a list of build artifact paths that will be uploaded
9305
+ * Uploads sourcemaps using the "Debug ID" method.
9306
+ *
9307
+ * By default, this prepares bundles in a temporary folder before uploading. You can opt into an
9308
+ * in-place, direct upload path by setting `prepareArtifacts` to `false`. If `prepareArtifacts` is set to
9309
+ * `false`, no preparation (e.g. adding `//# debugId=...` and writing adjusted source maps) is performed and no temp folder is used.
9310
+ *
9311
+ * @param buildArtifactPaths - The paths of the build artifacts to upload
9312
+ * @param opts - Optional flags to control temp folder usage and preparation
9306
9313
  */
9307
- uploadSourcemaps: function uploadSourcemaps(buildArtifactPaths) {
9308
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
9309
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
9310
- while (1) switch (_context18.prev = _context18.next) {
9314
+ uploadSourcemaps: function uploadSourcemaps(buildArtifactPaths, opts) {
9315
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
9316
+ var _options$sourcemaps;
9317
+ var assets;
9318
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
9319
+ while (1) switch (_context19.prev = _context19.next) {
9311
9320
  case 0:
9312
9321
  if (canUploadSourceMaps(options, logger, isDevMode)) {
9313
- _context18.next = 2;
9322
+ _context19.next = 2;
9314
9323
  break;
9315
9324
  }
9316
- return _context18.abrupt("return");
9325
+ return _context19.abrupt("return");
9317
9326
  case 2:
9318
- _context18.next = 4;
9327
+ // Early exit if assets is explicitly set to an empty array
9328
+ assets = (_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.assets;
9329
+ if (!(Array.isArray(assets) && assets.length === 0)) {
9330
+ _context19.next = 6;
9331
+ break;
9332
+ }
9333
+ logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
9334
+ return _context19.abrupt("return");
9335
+ case 6:
9336
+ _context19.next = 8;
9319
9337
  return startSpan(
9320
9338
  // This is `forceTransaction`ed because this span is used in dashboards in the form of indexed transactions.
9321
9339
  {
9322
9340
  name: "debug-id-sourcemap-upload",
9323
9341
  scope: sentryScope,
9324
9342
  forceTransaction: true
9325
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
9326
- var folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps, tmpUploadFolder, assets, globAssets, globResult, debugIdChunkFilePaths, numUploadedFiles, _process$env2;
9327
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
9328
- while (1) switch (_context17.prev = _context17.next) {
9343
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
9344
+ var _opts$prepareArtifact;
9345
+ var shouldPrepare, folderToCleanUp, freeUploadDependencyOnBuildArtifacts, _options$sourcemaps2, _options$sourcemaps3, _options$sourcemaps4, _options$sourcemaps5, pathsToUpload, ignorePaths, globAssets, globResult, debugIdChunkFilePaths, tmpUploadFolder, _process$env2;
9346
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
9347
+ while (1) switch (_context18.prev = _context18.next) {
9329
9348
  case 0:
9349
+ // If we're not using a temp folder, we must not prepare artifacts in-place (to avoid mutating user files)
9350
+ shouldPrepare = (_opts$prepareArtifact = opts === null || opts === void 0 ? void 0 : opts.prepareArtifacts) !== null && _opts$prepareArtifact !== void 0 ? _opts$prepareArtifact : true;
9330
9351
  // It is possible that this writeBundle hook (which calls this function) is called multiple times in one build (for example when reusing the plugin, or when using build tooling like `@vitejs/plugin-legacy`)
9331
9352
  // Therefore we need to actually register the execution of this hook as dependency on the sourcemap files.
9332
9353
  freeUploadDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
9333
- _context17.prev = 1;
9334
- _context17.next = 4;
9354
+ _context18.prev = 2;
9355
+ if (shouldPrepare) {
9356
+ _context18.next = 11;
9357
+ break;
9358
+ }
9359
+ // Direct CLI upload from existing artifact paths (no globbing, no preparation)
9360
+
9361
+ if (assets) {
9362
+ pathsToUpload = Array.isArray(assets) ? assets : [assets];
9363
+ logger.debug("Direct upload mode: passing user-provided assets directly to CLI: ".concat(pathsToUpload.join(", ")));
9364
+ } else {
9365
+ // Use original paths e.g. like ['.next/server'] directly –> preferred way when no globbing is done
9366
+ pathsToUpload = buildArtifactPaths;
9367
+ }
9368
+ ignorePaths = (_options$sourcemaps2 = options.sourcemaps) !== null && _options$sourcemaps2 !== void 0 && _options$sourcemaps2.ignore ? Array.isArray((_options$sourcemaps3 = options.sourcemaps) === null || _options$sourcemaps3 === void 0 ? void 0 : _options$sourcemaps3.ignore) ? (_options$sourcemaps4 = options.sourcemaps) === null || _options$sourcemaps4 === void 0 ? void 0 : _options$sourcemaps4.ignore : [(_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.ignore] : [];
9369
+ _context18.next = 8;
9335
9370
  return startSpan({
9336
- name: "mkdtemp",
9371
+ name: "upload",
9337
9372
  scope: sentryScope
9338
9373
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
9339
- var _process$env;
9374
+ var _options$release$name;
9375
+ var cliInstance;
9340
9376
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
9341
9377
  while (1) switch (_context10.prev = _context10.next) {
9342
9378
  case 0:
9343
- _context10.t0 = (_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env["SENTRY_TEST_OVERRIDE_TEMP_DIR"];
9344
- if (_context10.t0) {
9345
- _context10.next = 5;
9346
- break;
9347
- }
9348
- _context10.next = 4;
9349
- return fs__namespace.promises.mkdtemp(path__namespace.join(os__namespace.tmpdir(), "sentry-bundler-plugin-upload-"));
9350
- case 4:
9351
- _context10.t0 = _context10.sent;
9352
- case 5:
9353
- return _context10.abrupt("return", _context10.t0);
9354
- case 6:
9379
+ cliInstance = createCliInstance(options);
9380
+ _context10.next = 3;
9381
+ return cliInstance.releases.uploadSourceMaps((_options$release$name = options.release.name) !== null && _options$release$name !== void 0 ? _options$release$name : "undefined", {
9382
+ include: [{
9383
+ paths: pathsToUpload,
9384
+ rewrite: true,
9385
+ dist: options.release.dist
9386
+ }],
9387
+ ignore: ignorePaths,
9388
+ live: "rejectOnError"
9389
+ });
9390
+ case 3:
9355
9391
  case "end":
9356
9392
  return _context10.stop();
9357
9393
  }
9358
9394
  }, _callee10);
9359
9395
  })));
9360
- case 4:
9361
- tmpUploadFolder = _context17.sent;
9362
- folderToCleanUp = tmpUploadFolder;
9363
- assets = (_options$sourcemaps = options.sourcemaps) === null || _options$sourcemaps === void 0 ? void 0 : _options$sourcemaps.assets;
9396
+ case 8:
9397
+ logger.info("Successfully uploaded source maps to Sentry");
9398
+ _context18.next = 28;
9399
+ break;
9400
+ case 11:
9401
+ // Prepare artifacts in temp folder before uploading
9402
+
9364
9403
  if (assets) {
9365
9404
  globAssets = assets;
9366
9405
  } else {
9367
9406
  logger.debug("No `sourcemaps.assets` option provided, falling back to uploading detected build artifacts.");
9368
9407
  globAssets = buildArtifactPaths;
9369
9408
  }
9370
- _context17.next = 10;
9409
+ _context18.next = 14;
9371
9410
  return startSpan({
9372
9411
  name: "glob",
9373
9412
  scope: sentryScope
9374
9413
  }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
9375
- var _options$sourcemaps2;
9414
+ var _options$sourcemaps6;
9376
9415
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
9377
9416
  while (1) switch (_context11.prev = _context11.next) {
9378
9417
  case 0:
@@ -9380,7 +9419,8 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9380
9419
  return glob.glob(globAssets, {
9381
9420
  absolute: true,
9382
9421
  nodir: true,
9383
- ignore: (_options$sourcemaps2 = options.sourcemaps) === null || _options$sourcemaps2 === void 0 ? void 0 : _options$sourcemaps2.ignore
9422
+ // We need individual files for preparation
9423
+ ignore: (_options$sourcemaps6 = options.sourcemaps) === null || _options$sourcemaps6 === void 0 ? void 0 : _options$sourcemaps6.ignore
9384
9424
  });
9385
9425
  case 2:
9386
9426
  return _context11.abrupt("return", _context11.sent);
@@ -9390,241 +9430,255 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9390
9430
  }
9391
9431
  }, _callee11);
9392
9432
  })));
9393
- case 10:
9394
- globResult = _context17.sent;
9433
+ case 14:
9434
+ globResult = _context18.sent;
9395
9435
  debugIdChunkFilePaths = globResult.filter(function (debugIdChunkFilePath) {
9396
9436
  return !!stripQueryAndHashFromPath(debugIdChunkFilePath).match(/\.(js|mjs|cjs)$/);
9397
9437
  }); // The order of the files output by glob() is not deterministic
9398
9438
  // Ensure order within the files so that {debug-id}-{chunkIndex} coupling is consistent
9399
9439
  debugIdChunkFilePaths.sort();
9400
- if (!(Array.isArray(assets) && assets.length === 0)) {
9401
- _context17.next = 17;
9402
- break;
9403
- }
9404
- logger.debug("Empty `sourcemaps.assets` option provided. Will not upload sourcemaps with debug ID.");
9405
- _context17.next = 25;
9406
- break;
9407
- case 17:
9408
9440
  if (!(debugIdChunkFilePaths.length === 0)) {
9409
- _context17.next = 21;
9441
+ _context18.next = 21;
9410
9442
  break;
9411
9443
  }
9412
9444
  logger.warn("Didn't find any matching sources for debug ID upload. Please check the `sourcemaps.assets` option.");
9413
- _context17.next = 25;
9445
+ _context18.next = 28;
9414
9446
  break;
9415
9447
  case 21:
9416
- _context17.next = 23;
9448
+ _context18.next = 23;
9449
+ return startSpan({
9450
+ name: "mkdtemp",
9451
+ scope: sentryScope
9452
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
9453
+ var _process$env;
9454
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
9455
+ while (1) switch (_context12.prev = _context12.next) {
9456
+ case 0:
9457
+ _context12.t0 = (_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env["SENTRY_TEST_OVERRIDE_TEMP_DIR"];
9458
+ if (_context12.t0) {
9459
+ _context12.next = 5;
9460
+ break;
9461
+ }
9462
+ _context12.next = 4;
9463
+ return fs__namespace.promises.mkdtemp(path__namespace.join(os__namespace.tmpdir(), "sentry-bundler-plugin-upload-"));
9464
+ case 4:
9465
+ _context12.t0 = _context12.sent;
9466
+ case 5:
9467
+ return _context12.abrupt("return", _context12.t0);
9468
+ case 6:
9469
+ case "end":
9470
+ return _context12.stop();
9471
+ }
9472
+ }, _callee12);
9473
+ })));
9474
+ case 23:
9475
+ tmpUploadFolder = _context18.sent;
9476
+ folderToCleanUp = tmpUploadFolder;
9477
+
9478
+ // Prepare into temp folder, then upload
9479
+ _context18.next = 27;
9417
9480
  return startSpan({
9418
9481
  name: "prepare-bundles",
9419
9482
  scope: sentryScope
9420
9483
  }, /*#__PURE__*/function () {
9421
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(prepBundlesSpan) {
9484
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(prepBundlesSpan) {
9422
9485
  var preparationTasks, workers, worker, workerIndex, files, stats, uploadSize;
9423
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
9424
- while (1) switch (_context15.prev = _context15.next) {
9486
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
9487
+ while (1) switch (_context16.prev = _context16.next) {
9425
9488
  case 0:
9426
9489
  // Preparing the bundles can be a lot of work and doing it all at once has the potential of nuking the heap so
9427
9490
  // instead we do it with a maximum of 16 concurrent workers
9428
9491
  preparationTasks = debugIdChunkFilePaths.map(function (chunkFilePath, chunkIndex) {
9429
- return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
9430
- var _options$sourcemaps$r, _options$sourcemaps3, _options$sourcemaps4;
9431
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
9432
- while (1) switch (_context12.prev = _context12.next) {
9492
+ return /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
9493
+ var _options$sourcemaps$r, _options$sourcemaps7, _options$sourcemaps8;
9494
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
9495
+ while (1) switch (_context13.prev = _context13.next) {
9433
9496
  case 0:
9434
- _context12.next = 2;
9435
- return prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, chunkIndex, logger, (_options$sourcemaps$r = (_options$sourcemaps3 = options.sourcemaps) === null || _options$sourcemaps3 === void 0 ? void 0 : _options$sourcemaps3.rewriteSources) !== null && _options$sourcemaps$r !== void 0 ? _options$sourcemaps$r : defaultRewriteSourcesHook, (_options$sourcemaps4 = options.sourcemaps) === null || _options$sourcemaps4 === void 0 ? void 0 : _options$sourcemaps4.resolveSourceMap);
9497
+ _context13.next = 2;
9498
+ return prepareBundleForDebugIdUpload(chunkFilePath, tmpUploadFolder, chunkIndex, logger, (_options$sourcemaps$r = (_options$sourcemaps7 = options.sourcemaps) === null || _options$sourcemaps7 === void 0 ? void 0 : _options$sourcemaps7.rewriteSources) !== null && _options$sourcemaps$r !== void 0 ? _options$sourcemaps$r : defaultRewriteSourcesHook, (_options$sourcemaps8 = options.sourcemaps) === null || _options$sourcemaps8 === void 0 ? void 0 : _options$sourcemaps8.resolveSourceMap);
9436
9499
  case 2:
9437
9500
  case "end":
9438
- return _context12.stop();
9501
+ return _context13.stop();
9439
9502
  }
9440
- }, _callee12);
9503
+ }, _callee13);
9441
9504
  }));
9442
9505
  });
9443
9506
  workers = [];
9444
9507
  worker = /*#__PURE__*/function () {
9445
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
9508
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
9446
9509
  var task;
9447
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
9448
- while (1) switch (_context13.prev = _context13.next) {
9510
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
9511
+ while (1) switch (_context14.prev = _context14.next) {
9449
9512
  case 0:
9450
9513
  if (!(preparationTasks.length > 0)) {
9451
- _context13.next = 7;
9514
+ _context14.next = 7;
9452
9515
  break;
9453
9516
  }
9454
9517
  task = preparationTasks.shift();
9455
9518
  if (!task) {
9456
- _context13.next = 5;
9519
+ _context14.next = 5;
9457
9520
  break;
9458
9521
  }
9459
- _context13.next = 5;
9522
+ _context14.next = 5;
9460
9523
  return task();
9461
9524
  case 5:
9462
- _context13.next = 0;
9525
+ _context14.next = 0;
9463
9526
  break;
9464
9527
  case 7:
9465
9528
  case "end":
9466
- return _context13.stop();
9529
+ return _context14.stop();
9467
9530
  }
9468
- }, _callee13);
9531
+ }, _callee14);
9469
9532
  }));
9470
9533
  return function worker() {
9471
- return _ref7.apply(this, arguments);
9534
+ return _ref8.apply(this, arguments);
9472
9535
  };
9473
9536
  }();
9474
9537
  for (workerIndex = 0; workerIndex < 16; workerIndex++) {
9475
9538
  workers.push(worker());
9476
9539
  }
9477
- _context15.next = 6;
9540
+ _context16.next = 6;
9478
9541
  return Promise.all(workers);
9479
9542
  case 6:
9480
- _context15.next = 8;
9543
+ _context16.next = 8;
9481
9544
  return fs__namespace.promises.readdir(tmpUploadFolder);
9482
9545
  case 8:
9483
- files = _context15.sent;
9546
+ files = _context16.sent;
9484
9547
  stats = files.map(function (file) {
9485
9548
  return fs__namespace.promises.stat(path__namespace.join(tmpUploadFolder, file));
9486
9549
  });
9487
- _context15.next = 12;
9550
+ _context16.next = 12;
9488
9551
  return Promise.all(stats);
9489
9552
  case 12:
9490
- uploadSize = _context15.sent.reduce(function (accumulator, _ref8) {
9491
- var size = _ref8.size;
9553
+ uploadSize = _context16.sent.reduce(function (accumulator, _ref9) {
9554
+ var size = _ref9.size;
9492
9555
  return accumulator + size;
9493
9556
  }, 0);
9494
9557
  setMeasurement("files", files.length, "none", prepBundlesSpan);
9495
9558
  setMeasurement("upload_size", uploadSize, "byte", prepBundlesSpan);
9496
- _context15.next = 17;
9559
+ _context16.next = 17;
9497
9560
  return startSpan({
9498
9561
  name: "upload",
9499
9562
  scope: sentryScope
9500
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
9501
- var _options$release$name;
9563
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
9564
+ var _options$release$name2;
9502
9565
  var cliInstance;
9503
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
9504
- while (1) switch (_context14.prev = _context14.next) {
9566
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
9567
+ while (1) switch (_context15.prev = _context15.next) {
9505
9568
  case 0:
9506
9569
  cliInstance = createCliInstance(options);
9507
- _context14.next = 3;
9508
- return cliInstance.releases.uploadSourceMaps((_options$release$name = options.release.name) !== null && _options$release$name !== void 0 ? _options$release$name : "undefined",
9509
- // unfortunately this needs a value for now but it will not matter since debug IDs overpower releases anyhow
9510
- {
9570
+ _context15.next = 3;
9571
+ return cliInstance.releases.uploadSourceMaps((_options$release$name2 = options.release.name) !== null && _options$release$name2 !== void 0 ? _options$release$name2 : "undefined", {
9511
9572
  include: [{
9512
9573
  paths: [tmpUploadFolder],
9513
9574
  rewrite: false,
9514
9575
  dist: options.release.dist
9515
9576
  }],
9516
- // We want this promise to throw if the sourcemaps fail to upload so that we know about it.
9517
- // see: https://github.com/getsentry/sentry-cli/pull/2605
9518
9577
  live: "rejectOnError"
9519
9578
  });
9520
9579
  case 3:
9521
9580
  case "end":
9522
- return _context14.stop();
9581
+ return _context15.stop();
9523
9582
  }
9524
- }, _callee14);
9583
+ }, _callee15);
9525
9584
  })));
9526
9585
  case 17:
9527
- return _context15.abrupt("return", files.length);
9528
- case 18:
9529
9586
  case "end":
9530
- return _context15.stop();
9587
+ return _context16.stop();
9531
9588
  }
9532
- }, _callee15);
9589
+ }, _callee16);
9533
9590
  }));
9534
9591
  return function (_x) {
9535
- return _ref5.apply(this, arguments);
9592
+ return _ref6.apply(this, arguments);
9536
9593
  };
9537
9594
  }());
9538
- case 23:
9539
- numUploadedFiles = _context17.sent;
9540
- if (numUploadedFiles > 0) {
9541
- logger.info("Successfully uploaded source maps to Sentry");
9542
- }
9543
- case 25:
9544
- _context17.next = 31;
9545
- break;
9546
9595
  case 27:
9547
- _context17.prev = 27;
9548
- _context17.t0 = _context17["catch"](1);
9596
+ logger.info("Successfully uploaded source maps to Sentry");
9597
+ case 28:
9598
+ _context18.next = 34;
9599
+ break;
9600
+ case 30:
9601
+ _context18.prev = 30;
9602
+ _context18.t0 = _context18["catch"](2);
9549
9603
  sentryScope.captureException('Error in "debugIdUploadPlugin" writeBundle hook');
9550
- handleRecoverableError(_context17.t0, false);
9551
- case 31:
9552
- _context17.prev = 31;
9604
+ handleRecoverableError(_context18.t0, false);
9605
+ case 34:
9606
+ _context18.prev = 34;
9553
9607
  if (folderToCleanUp && !((_process$env2 = process.env) !== null && _process$env2 !== void 0 && _process$env2["SENTRY_TEST_OVERRIDE_TEMP_DIR"])) {
9554
9608
  void startSpan({
9555
9609
  name: "cleanup",
9556
9610
  scope: sentryScope
9557
- }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
9558
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
9559
- while (1) switch (_context16.prev = _context16.next) {
9611
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
9612
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
9613
+ while (1) switch (_context17.prev = _context17.next) {
9560
9614
  case 0:
9561
9615
  if (!folderToCleanUp) {
9562
- _context16.next = 3;
9616
+ _context17.next = 3;
9563
9617
  break;
9564
9618
  }
9565
- _context16.next = 3;
9619
+ _context17.next = 3;
9566
9620
  return fs__namespace.promises.rm(folderToCleanUp, {
9567
9621
  recursive: true,
9568
9622
  force: true
9569
9623
  });
9570
9624
  case 3:
9571
9625
  case "end":
9572
- return _context16.stop();
9626
+ return _context17.stop();
9573
9627
  }
9574
- }, _callee16);
9628
+ }, _callee17);
9575
9629
  })));
9576
9630
  }
9577
9631
  freeUploadDependencyOnBuildArtifacts();
9578
- _context17.next = 36;
9632
+ _context18.next = 39;
9579
9633
  return safeFlushTelemetry(sentryClient);
9580
- case 36:
9581
- return _context17.finish(31);
9582
- case 37:
9634
+ case 39:
9635
+ return _context18.finish(34);
9636
+ case 40:
9583
9637
  case "end":
9584
- return _context17.stop();
9638
+ return _context18.stop();
9585
9639
  }
9586
- }, _callee17, null, [[1, 27, 31, 37]]);
9640
+ }, _callee18, null, [[2, 30, 34, 40]]);
9587
9641
  })));
9588
- case 4:
9642
+ case 8:
9589
9643
  case "end":
9590
- return _context18.stop();
9644
+ return _context19.stop();
9591
9645
  }
9592
- }, _callee18);
9646
+ }, _callee19);
9593
9647
  }))();
9594
9648
  },
9595
9649
  /**
9596
9650
  * Will delete artifacts based on the passed `sourcemaps.filesToDeleteAfterUpload` option.
9597
9651
  */
9598
9652
  deleteArtifacts: function deleteArtifacts() {
9599
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
9600
- var _options$sourcemaps5, filesToDelete, filePathsToDelete;
9601
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
9602
- while (1) switch (_context19.prev = _context19.next) {
9653
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
9654
+ var _options$sourcemaps9, filesToDelete, filePathsToDelete;
9655
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
9656
+ while (1) switch (_context20.prev = _context20.next) {
9603
9657
  case 0:
9604
- _context19.prev = 0;
9605
- _context19.next = 3;
9606
- return (_options$sourcemaps5 = options.sourcemaps) === null || _options$sourcemaps5 === void 0 ? void 0 : _options$sourcemaps5.filesToDeleteAfterUpload;
9658
+ _context20.prev = 0;
9659
+ _context20.next = 3;
9660
+ return (_options$sourcemaps9 = options.sourcemaps) === null || _options$sourcemaps9 === void 0 ? void 0 : _options$sourcemaps9.filesToDeleteAfterUpload;
9607
9661
  case 3:
9608
- filesToDelete = _context19.sent;
9662
+ filesToDelete = _context20.sent;
9609
9663
  if (!(filesToDelete !== undefined)) {
9610
- _context19.next = 14;
9664
+ _context20.next = 14;
9611
9665
  break;
9612
9666
  }
9613
- _context19.next = 7;
9667
+ _context20.next = 7;
9614
9668
  return glob.glob(filesToDelete, {
9615
9669
  absolute: true,
9616
9670
  nodir: true
9617
9671
  });
9618
9672
  case 7:
9619
- filePathsToDelete = _context19.sent;
9673
+ filePathsToDelete = _context20.sent;
9620
9674
  logger.debug("Waiting for dependencies on generated files to be freed before deleting...");
9621
- _context19.next = 11;
9675
+ _context20.next = 11;
9622
9676
  return waitUntilBuildArtifactDependenciesAreFreed();
9623
9677
  case 11:
9624
9678
  filePathsToDelete.forEach(function (filePathToDelete) {
9625
9679
  logger.debug("Deleting asset after upload: ".concat(filePathToDelete));
9626
9680
  });
9627
- _context19.next = 14;
9681
+ _context20.next = 14;
9628
9682
  return Promise.all(filePathsToDelete.map(function (filePathToDelete) {
9629
9683
  return fs__namespace.promises.rm(filePathToDelete, {
9630
9684
  force: true
@@ -9634,31 +9688,31 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9634
9688
  });
9635
9689
  }));
9636
9690
  case 14:
9637
- _context19.next = 22;
9691
+ _context20.next = 22;
9638
9692
  break;
9639
9693
  case 16:
9640
- _context19.prev = 16;
9641
- _context19.t0 = _context19["catch"](0);
9694
+ _context20.prev = 16;
9695
+ _context20.t0 = _context20["catch"](0);
9642
9696
  sentryScope.captureException('Error in "sentry-file-deletion-plugin" buildEnd hook');
9643
- _context19.next = 21;
9697
+ _context20.next = 21;
9644
9698
  return safeFlushTelemetry(sentryClient);
9645
9699
  case 21:
9646
9700
  // We throw by default if we get here b/c not being able to delete
9647
9701
  // source maps could leak them to production
9648
- handleRecoverableError(_context19.t0, true);
9702
+ handleRecoverableError(_context20.t0, true);
9649
9703
  case 22:
9650
9704
  case "end":
9651
- return _context19.stop();
9705
+ return _context20.stop();
9652
9706
  }
9653
- }, _callee19, null, [[0, 16]]);
9707
+ }, _callee20, null, [[0, 16]]);
9654
9708
  }))();
9655
9709
  },
9656
9710
  createDependencyOnBuildArtifacts: createDependencyOnBuildArtifacts
9657
9711
  };
9658
9712
  }
9659
9713
  function canUploadSourceMaps(options, logger, isDevMode) {
9660
- var _options$sourcemaps6;
9661
- if ((_options$sourcemaps6 = options.sourcemaps) !== null && _options$sourcemaps6 !== void 0 && _options$sourcemaps6.disable) {
9714
+ var _options$sourcemaps10;
9715
+ if ((_options$sourcemaps10 = options.sourcemaps) !== null && _options$sourcemaps10 !== void 0 && _options$sourcemaps10.disable) {
9662
9716
  logger.debug("Source map upload was disabled. Will not upload sourcemaps using debug ID process.");
9663
9717
  return false;
9664
9718
  }