@sentry/bundler-plugin-core 4.4.0 → 4.5.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.
@@ -7986,12 +7986,27 @@ function getTurborepoEnvPassthroughWarning(envVarName) {
7986
7986
  return process.env["TURBO_HASH"] ? "\nYou seem to be using Turborepo, did you forget to put ".concat(envVarName, " in `passThroughEnv`? https://turbo.build/repo/docs/reference/configuration#passthroughenv") : "";
7987
7987
  }
7988
7988
 
7989
+ /**
7990
+ * Gets the projects from the project option. This might be a single project or an array of projects.
7991
+ */
7992
+ function getProjects(project) {
7993
+ if (Array.isArray(project)) {
7994
+ return project;
7995
+ }
7996
+ if (project) {
7997
+ return [project];
7998
+ }
7999
+ return undefined;
8000
+ }
8001
+
7989
8002
  var SENTRY_SAAS_URL = "https://sentry.io";
7990
8003
  function normalizeUserOptions(userOptions) {
7991
- var _userOptions$org, _userOptions$project, _userOptions$authToke, _ref, _userOptions$url, _userOptions$debug, _userOptions$silent, _userOptions$telemetr, _userOptions$disable, _ref2, _userOptions$release$, _userOptions$release, _userOptions$release$2, _userOptions$release2, _userOptions$release$3, _userOptions$release3, _userOptions$release$4, _userOptions$release4, _ref3, _userOptions$release$5, _userOptions$release5, _userOptions$release6, _userOptions$_metaOpt, _userOptions$_metaOpt2, _userOptions$_experim;
8004
+ var _userOptions$org, _userOptions$project, _process$env$SENTRY_P, _userOptions$authToke, _ref, _userOptions$url, _userOptions$debug, _userOptions$silent, _userOptions$telemetr, _userOptions$disable, _ref2, _userOptions$release$, _userOptions$release, _userOptions$release$2, _userOptions$release2, _userOptions$release$3, _userOptions$release3, _userOptions$release$4, _userOptions$release4, _ref3, _userOptions$release$5, _userOptions$release5, _userOptions$release6, _userOptions$_metaOpt, _userOptions$_metaOpt2, _userOptions$_experim;
7992
8005
  var options = {
7993
8006
  org: (_userOptions$org = userOptions.org) !== null && _userOptions$org !== void 0 ? _userOptions$org : process.env["SENTRY_ORG"],
7994
- project: (_userOptions$project = userOptions.project) !== null && _userOptions$project !== void 0 ? _userOptions$project : process.env["SENTRY_PROJECT"],
8007
+ project: (_userOptions$project = userOptions.project) !== null && _userOptions$project !== void 0 ? _userOptions$project : (_process$env$SENTRY_P = process.env["SENTRY_PROJECT"]) !== null && _process$env$SENTRY_P !== void 0 && _process$env$SENTRY_P.includes(",") ? process.env["SENTRY_PROJECT"].split(",").map(function (p) {
8008
+ return p.trim();
8009
+ }) : process.env["SENTRY_PROJECT"],
7995
8010
  authToken: (_userOptions$authToke = userOptions.authToken) !== null && _userOptions$authToke !== void 0 ? _userOptions$authToke : process.env["SENTRY_AUTH_TOKEN"],
7996
8011
  url: (_ref = (_userOptions$url = userOptions.url) !== null && _userOptions$url !== void 0 ? _userOptions$url : process.env["SENTRY_URL"]) !== null && _ref !== void 0 ? _ref : SENTRY_SAAS_URL,
7997
8012
  headers: userOptions.headers,
@@ -8080,6 +8095,20 @@ function validateOptions(options, logger) {
8080
8095
  logger.error("The `deploy` option was specified but is missing the required `env` property.", "Please set the `env` property.");
8081
8096
  return false;
8082
8097
  }
8098
+ if (options.project && Array.isArray(options.project)) {
8099
+ if (options.project.length === 0) {
8100
+ logger.error("The `project` option was specified as an array but is empty.", "Please provide at least one project slug.");
8101
+ return false;
8102
+ }
8103
+ // Check each project is a non-empty string
8104
+ var invalidProjects = options.project.filter(function (p) {
8105
+ return typeof p !== "string" || p.trim() === "";
8106
+ });
8107
+ if (invalidProjects.length > 0) {
8108
+ logger.error("The `project` option contains invalid project slugs.", "All projects must be non-empty strings.");
8109
+ return false;
8110
+ }
8111
+ }
8083
8112
  return true;
8084
8113
  }
8085
8114
 
@@ -8270,7 +8299,7 @@ function createSentryInstance(options, shouldSendTelemetry, buildTool) {
8270
8299
  dsn: "https://4c2bae7d9fbc413e8f7385f55c515d51@o1.ingest.sentry.io/6690737",
8271
8300
  tracesSampleRate: 1,
8272
8301
  sampleRate: 1,
8273
- release: "4.4.0",
8302
+ release: "4.5.0",
8274
8303
  integrations: [],
8275
8304
  tracePropagationTargets: ["sentry.io/api"],
8276
8305
  stackParser: stackParser,
@@ -8337,7 +8366,7 @@ function setTelemetryDataOnScope(options, scope, buildTool) {
8337
8366
  scope.setTag("ci", !!process.env["CI"]);
8338
8367
  scope.setTags({
8339
8368
  organization: org,
8340
- project: project,
8369
+ project: Array.isArray(project) ? project.join(", ") : project !== null && project !== void 0 ? project : "undefined",
8341
8370
  bundler: buildTool
8342
8371
  });
8343
8372
  scope.setUser({
@@ -8353,7 +8382,7 @@ function allowedToSendTelemetry(_x) {
8353
8382
  */
8354
8383
  function _allowedToSendTelemetry() {
8355
8384
  _allowedToSendTelemetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
8356
- var _cliInfo$split$, _cliInfo$split$$repla;
8385
+ var _getProjects, _cliInfo$split$, _cliInfo$split$$repla;
8357
8386
  var silent, org, project, authToken, url, headers, telemetry, release, cli, cliInfo, cliInfoUrl;
8358
8387
  return _regeneratorRuntime().wrap(function _callee$(_context) {
8359
8388
  while (1) switch (_context.prev = _context.next) {
@@ -8375,7 +8404,7 @@ function _allowedToSendTelemetry() {
8375
8404
  url: url,
8376
8405
  authToken: authToken,
8377
8406
  org: org,
8378
- project: project,
8407
+ project: (_getProjects = getProjects(project)) === null || _getProjects === void 0 ? void 0 : _getProjects[0],
8379
8408
  vcsRemote: release.vcsRemote,
8380
8409
  silent: silent,
8381
8410
  headers: headers
@@ -8712,10 +8741,12 @@ function defaultRewriteSourcesHook(source) {
8712
8741
  }
8713
8742
 
8714
8743
  function createCliInstance(options) {
8744
+ var _getProjects;
8715
8745
  return new SentryCli(null, {
8716
8746
  authToken: options.authToken,
8717
8747
  org: options.org,
8718
- project: options.project,
8748
+ // Default to the first project if multiple projects are specified
8749
+ project: (_getProjects = getProjects(options.project)) === null || _getProjects === void 0 ? void 0 : _getProjects[0],
8719
8750
  silent: options.silent,
8720
8751
  url: options.url,
8721
8752
  vcsRemote: options.release.vcsRemote,
@@ -8877,7 +8908,13 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8877
8908
  });
8878
8909
 
8879
8910
  // Set the User-Agent that Sentry CLI will use when interacting with Sentry
8880
- process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.4.0");
8911
+ process.env["SENTRY_PIPELINE"] = "".concat(bundlerPluginMetaContext.buildTool, "-plugin/", "4.5.0");
8912
+
8913
+ // Propagate debug flag to Sentry CLI via environment variable
8914
+ // Only set if not already defined to respect user's explicit configuration
8915
+ if (options.debug && !process.env["SENTRY_LOG_LEVEL"]) {
8916
+ process.env["SENTRY_LOG_LEVEL"] = "debug";
8917
+ }
8881
8918
 
8882
8919
  // Not a bulletproof check but should be good enough to at least sometimes determine
8883
8920
  // if the plugin is called in dev/watch mode or for a prod build. The important part
@@ -8999,9 +9036,11 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
8999
9036
  bundleMetadata["_sentryBundlerPluginAppKey:".concat(options.applicationKey)] = true;
9000
9037
  }
9001
9038
  if (typeof options.moduleMetadata === "function") {
9039
+ var _getProjects2;
9002
9040
  var args = {
9003
9041
  org: options.org,
9004
- project: options.project,
9042
+ project: (_getProjects2 = getProjects(options.project)) === null || _getProjects2 === void 0 ? void 0 : _getProjects2[0],
9043
+ projects: getProjects(options.project),
9005
9044
  release: options.release.name
9006
9045
  };
9007
9046
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
@@ -9109,7 +9148,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9109
9148
  logger.warn("No organization slug provided. Will not create release. Please set the `org` option to your Sentry organization slug." + getTurborepoEnvPassthroughWarning("SENTRY_ORG"));
9110
9149
  return _context7.abrupt("return");
9111
9150
  case 20:
9112
- if (options.project) {
9151
+ if (!(!options.project || Array.isArray(options.project) && options.project.length === 0)) {
9113
9152
  _context7.next = 23;
9114
9153
  break;
9115
9154
  }
@@ -9150,6 +9189,9 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9150
9189
  return cliInstance.releases.uploadSourceMaps(options.release.name, {
9151
9190
  include: normalizedInclude,
9152
9191
  dist: options.release.dist,
9192
+ // @ts-expect-error - projects is not a valid option for uploadSourceMaps but is implemented in the CLI
9193
+ // Remove once https://github.com/getsentry/sentry-cli/pull/2856 is released
9194
+ projects: getProjects(options.project),
9153
9195
  // We want this promise to throw if the sourcemaps fail to upload so that we know about it.
9154
9196
  // see: https://github.com/getsentry/sentry-cli/pull/2605
9155
9197
  live: "rejectOnError"
@@ -9352,6 +9394,9 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9352
9394
  dist: options.release.dist
9353
9395
  }],
9354
9396
  ignore: ignorePaths,
9397
+ // @ts-expect-error - projects is not a valid option for uploadSourceMaps but is implemented in the CLI
9398
+ // Remove once https://github.com/getsentry/sentry-cli/pull/2856 is released
9399
+ projects: getProjects(options.project),
9355
9400
  live: "rejectOnError"
9356
9401
  });
9357
9402
  case 3:
@@ -9541,6 +9586,9 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9541
9586
  rewrite: false,
9542
9587
  dist: options.release.dist
9543
9588
  }],
9589
+ // @ts-expect-error - projects is not a valid option for uploadSourceMaps but is implemented in the CLI
9590
+ // Remove once https://github.com/getsentry/sentry-cli/pull/2856 is released
9591
+ projects: getProjects(options.project),
9544
9592
  live: "rejectOnError"
9545
9593
  });
9546
9594
  case 3:
@@ -9572,6 +9620,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9572
9620
  case 34:
9573
9621
  _context18.prev = 34;
9574
9622
  if (folderToCleanUp && !((_process$env2 = process.env) !== null && _process$env2 !== void 0 && _process$env2["SENTRY_TEST_OVERRIDE_TEMP_DIR"])) {
9623
+ logger.debug("Cleaning up temporary files...");
9575
9624
  void startSpan({
9576
9625
  name: "cleanup",
9577
9626
  scope: sentryScope
@@ -9580,7 +9629,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9580
9629
  while (1) switch (_context17.prev = _context17.next) {
9581
9630
  case 0:
9582
9631
  if (!folderToCleanUp) {
9583
- _context17.next = 3;
9632
+ _context17.next = 4;
9584
9633
  break;
9585
9634
  }
9586
9635
  _context17.next = 3;
@@ -9589,22 +9638,27 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9589
9638
  force: true
9590
9639
  });
9591
9640
  case 3:
9641
+ logger.debug("Temporary folder deleted: ".concat(folderToCleanUp));
9642
+ case 4:
9592
9643
  case "end":
9593
9644
  return _context17.stop();
9594
9645
  }
9595
9646
  }, _callee17);
9596
9647
  })));
9597
9648
  }
9649
+ logger.debug("Freeing upload dependencies...");
9598
9650
  freeUploadDependencyOnBuildArtifacts();
9599
- _context18.next = 39;
9651
+ logger.debug("Flushing telemetry data...");
9652
+ _context18.next = 41;
9600
9653
  return safeFlushTelemetry(sentryClient);
9601
- case 39:
9654
+ case 41:
9655
+ logger.debug("Telemetry flushed. Plugin upload process complete.");
9602
9656
  return _context18.finish(34);
9603
- case 40:
9657
+ case 43:
9604
9658
  case "end":
9605
9659
  return _context18.stop();
9606
9660
  }
9607
- }, _callee18, null, [[2, 30, 34, 40]]);
9661
+ }, _callee18, null, [[2, 30, 34, 43]]);
9608
9662
  })));
9609
9663
  case 8:
9610
9664
  case "end":
@@ -9678,7 +9732,7 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
9678
9732
  };
9679
9733
  }
9680
9734
  function canUploadSourceMaps(options, logger, isDevMode) {
9681
- var _options$sourcemaps10;
9735
+ var _options$sourcemaps10, _getProjects3;
9682
9736
  if ((_options$sourcemaps10 = options.sourcemaps) !== null && _options$sourcemaps10 !== void 0 && _options$sourcemaps10.disable) {
9683
9737
  logger.debug("Source map upload was disabled. Will not upload sourcemaps using debug ID process.");
9684
9738
  return false;
@@ -9695,7 +9749,7 @@ function canUploadSourceMaps(options, logger, isDevMode) {
9695
9749
  logger.warn("No org provided. Will not upload source maps. Please set the `org` option to your Sentry organization slug." + getTurborepoEnvPassthroughWarning("SENTRY_ORG"));
9696
9750
  return false;
9697
9751
  }
9698
- if (!options.project) {
9752
+ if (!((_getProjects3 = getProjects(options.project)) !== null && _getProjects3 !== void 0 && _getProjects3[0])) {
9699
9753
  logger.warn("No project provided. Will not upload source maps. Please set the `project` option to your Sentry project slug." + getTurborepoEnvPassthroughWarning("SENTRY_PROJECT"));
9700
9754
  return false;
9701
9755
  }