@sentry/bundler-plugins 11.16.0 → 11.18.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.
Files changed (48) hide show
  1. package/build/cjs/core/build-plugin-manager.js +5 -11
  2. package/build/cjs/core/build-plugin-manager.js.map +1 -1
  3. package/build/cjs/core/cli.js +10 -3
  4. package/build/cjs/core/cli.js.map +1 -1
  5. package/build/cjs/core/debug-id-upload.js +1 -1
  6. package/build/cjs/core/debug-id-upload.js.map +1 -1
  7. package/build/cjs/core/index.js +2 -0
  8. package/build/cjs/core/index.js.map +1 -1
  9. package/build/cjs/core/options-mapping.js +4 -7
  10. package/build/cjs/core/options-mapping.js.map +1 -1
  11. package/build/cjs/core/upload-credentials.js +49 -0
  12. package/build/cjs/core/upload-credentials.js.map +1 -0
  13. package/build/cjs/core/utils.js +40 -3
  14. package/build/cjs/core/utils.js.map +1 -1
  15. package/build/cjs/core/version.js +1 -1
  16. package/build/cjs/core/version.js.map +1 -1
  17. package/build/esm/core/build-plugin-manager.js +5 -10
  18. package/build/esm/core/build-plugin-manager.js.map +1 -1
  19. package/build/esm/core/cli.js +11 -4
  20. package/build/esm/core/cli.js.map +1 -1
  21. package/build/esm/core/debug-id-upload.js +1 -1
  22. package/build/esm/core/debug-id-upload.js.map +1 -1
  23. package/build/esm/core/index.js +2 -1
  24. package/build/esm/core/index.js.map +1 -1
  25. package/build/esm/core/options-mapping.js +5 -8
  26. package/build/esm/core/options-mapping.js.map +1 -1
  27. package/build/esm/core/upload-credentials.js +42 -0
  28. package/build/esm/core/upload-credentials.js.map +1 -0
  29. package/build/esm/core/utils.js +39 -4
  30. package/build/esm/core/utils.js.map +1 -1
  31. package/build/esm/core/version.js +1 -1
  32. package/build/esm/core/version.js.map +1 -1
  33. package/build/esm/package.json +1 -1
  34. package/build/types/core/build-plugin-manager.d.ts.map +1 -1
  35. package/build/types/core/cli.d.ts +5 -1
  36. package/build/types/core/cli.d.ts.map +1 -1
  37. package/build/types/core/debug-id-upload.d.ts.map +1 -1
  38. package/build/types/core/index.d.ts +1 -0
  39. package/build/types/core/index.d.ts.map +1 -1
  40. package/build/types/core/options-mapping.d.ts.map +1 -1
  41. package/build/types/core/types.d.ts +3 -0
  42. package/build/types/core/types.d.ts.map +1 -1
  43. package/build/types/core/upload-credentials.d.ts +18 -0
  44. package/build/types/core/upload-credentials.d.ts.map +1 -0
  45. package/build/types/core/utils.d.ts +8 -2
  46. package/build/types/core/utils.d.ts.map +1 -1
  47. package/build/types/core/version.d.ts +1 -1
  48. package/package.json +4 -4
@@ -1,3 +1,4 @@
1
+ const require_upload_credentials = require("./upload-credentials.js");
1
2
  const require_utils = require("./utils.js");
2
3
  let _sentry_core = require("@sentry/core");
3
4
  // src/core/options-mapping.ts
@@ -5,7 +6,7 @@ const SENTRY_SAAS_URL = "https://sentry.io";
5
6
  function normalizeUserOptions(userOptions) {
6
7
  const options = {
7
8
  org: userOptions.org ?? process.env["SENTRY_ORG"],
8
- project: userOptions.project ?? (process.env["SENTRY_PROJECT"]?.includes(",") ? process.env["SENTRY_PROJECT"].split(",").map((p) => p.trim()) : process.env["SENTRY_PROJECT"]),
9
+ project: userOptions.project ?? require_upload_credentials.parseProjectEnvVar(process.env["SENTRY_PROJECT"]),
9
10
  authToken: userOptions.authToken ?? process.env["SENTRY_AUTH_TOKEN"],
10
11
  url: userOptions.url ?? process.env["SENTRY_URL"],
11
12
  headers: userOptions.headers,
@@ -45,7 +46,7 @@ function normalizeUserOptions(userOptions) {
45
46
  ignoreEmpty: true,
46
47
  ignoreMissing: true
47
48
  };
48
- else if (process.env["VERCEL"] && vercelEnv !== "production" && !require_utils.canAutoDetectRepository()) options.release.setCommits = false;
49
+ else if (process.env["VERCEL"] && vercelEnv !== "production" && !require_utils.canAutoDetectRepository(options.release.vcsRemote)) options.release.setCommits = false;
49
50
  else options.release.setCommits = {
50
51
  shouldNotThrowOnFailure: true,
51
52
  auto: true,
@@ -80,11 +81,7 @@ function validateOptions(options, logger) {
80
81
  }
81
82
  if (setCommits.auto && setCommits.repo && setCommits) 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`.");
82
83
  }
83
- const sourcemaps = options.sourcemaps;
84
- if ((sourcemaps?.upload !== void 0 || sourcemaps?.injectDebugIds !== void 0) && sourcemaps?.disable !== void 0) logger.warn("`sourcemaps.disable` is ignored because `sourcemaps.upload` or `sourcemaps.injectDebugIds` is set.", "Please remove `sourcemaps.disable`.");
85
- if (sourcemaps?.injectDebugIds === false && sourcemaps.upload === true) logger.warn("`sourcemaps.upload` is set, but `sourcemaps.injectDebugIds` is `false`.", "Source maps are not uploaded, because the upload matches files by debug ID.");
86
- if (sourcemaps?.delete !== void 0 && sourcemaps.deleteSourcemapsAfterUpload !== void 0) logger.warn("`sourcemaps.deleteSourcemapsAfterUpload` is ignored because `sourcemaps.delete` is set.", "Please remove `sourcemaps.deleteSourcemapsAfterUpload`.");
87
- if (sourcemaps?.delete === false && sourcemaps.filesToDeleteAfterUpload !== void 0) logger.warn("`sourcemaps.filesToDeleteAfterUpload` still deletes the files it matches, although `sourcemaps.delete` is `false`.", "Remove `sourcemaps.filesToDeleteAfterUpload` to keep the source maps.");
84
+ (0, _sentry_core.warnOnConflictingSourceMapOptions)(options.sourcemaps, (message) => logger.warn(message));
88
85
  if (options.release?.deploy && typeof options.release.deploy === "object" && !options.release.deploy.env) {
89
86
  logger.error("The `deploy` option was specified but is missing the required `env` property.", "Please set the `env` property.");
90
87
  return false;
@@ -1 +1 @@
1
- {"version":3,"file":"options-mapping.js","names":["resolveReleaseName","getVercelEnv","readCommitEnvVar","canAutoDetectRepository"],"sources":["../../../src/core/options-mapping.ts"],"sourcesContent":["import { getVercelEnv } from '@sentry/core';\nimport type { Logger } from './logger';\nimport type {\n InternalOptions as UserOptions,\n SetCommitsOptions,\n RewriteSourcesHook,\n ResolveSourceMapHook,\n IncludeEntry,\n ModuleMetadata,\n ModuleMetadataCallback,\n} from './types';\nimport { canAutoDetectRepository, readCommitEnvVar, resolveReleaseName } from './utils';\n\nexport type NormalizedOptions = {\n org: string | undefined;\n project: string | string[] | undefined;\n authToken: string | undefined;\n url: string | undefined;\n headers: Record<string, string> | undefined;\n debug: boolean;\n silent: boolean;\n errorHandler: ((err: Error) => void) | undefined;\n telemetry: boolean;\n disable: boolean;\n sourcemaps:\n | {\n disable?: boolean | 'disable-upload';\n upload?: boolean;\n injectDebugIds?: boolean;\n delete?: boolean;\n assets?: string | string[];\n ignore?: string | string[];\n rewriteSources?: RewriteSourcesHook;\n resolveSourceMap?: ResolveSourceMapHook;\n filesToDeleteAfterUpload?: string | string[] | Promise<string | string[] | undefined>;\n deleteSourcemapsAfterUpload?: boolean | ((environment?: string) => boolean | undefined);\n sdkEnabledSourceMaps?: boolean | ((environment?: string) => boolean | undefined);\n }\n | undefined;\n release: {\n name: string | undefined;\n inject: boolean | 'html';\n create: boolean;\n finalize: boolean;\n vcsRemote: string;\n setCommits:\n | (SetCommitsOptions & {\n shouldNotThrowOnFailure?: boolean;\n })\n | false\n | undefined;\n dist?: string;\n deploy?:\n | {\n env: string;\n started?: number | string;\n finished?: number | string;\n time?: number;\n name?: string;\n url?: string;\n }\n | false;\n uploadLegacySourcemaps?: string | IncludeEntry | Array<string | IncludeEntry>;\n };\n bundleSizeOptimizations:\n | {\n excludeDebugStatements?: boolean;\n excludeTracing?: boolean;\n excludeChannelInjection?: boolean;\n excludeReplayCanvas?: boolean;\n excludeReplayShadowDom?: boolean;\n excludeReplayIframe?: boolean;\n excludeReplayWorker?: boolean;\n }\n | undefined;\n reactComponentAnnotation:\n | {\n enabled?: boolean;\n ignoredComponents?: string[];\n _experimentalInjectIntoHtml?: boolean;\n }\n | undefined;\n _metaOptions: {\n telemetry: {\n metaFramework: string | undefined;\n bundlerMajorVersion: string | undefined;\n };\n };\n applicationKey: string | undefined;\n moduleMetadata: ModuleMetadata | ModuleMetadataCallback | undefined;\n _experiments: {\n injectBuildInformation?: boolean;\n } & Record<string, unknown>;\n};\n\nexport const SENTRY_SAAS_URL = 'https://sentry.io';\n\n// oxlint-disable-next-line complexity\nexport function normalizeUserOptions(userOptions: UserOptions): NormalizedOptions {\n const options = {\n org: userOptions.org ?? process.env['SENTRY_ORG'],\n project:\n userOptions.project ??\n (process.env['SENTRY_PROJECT']?.includes(',')\n ? process.env['SENTRY_PROJECT'].split(',').map(p => p.trim())\n : process.env['SENTRY_PROJECT']),\n authToken: userOptions.authToken ?? process.env['SENTRY_AUTH_TOKEN'],\n // No sentry.io default: the CLI then uses the server an `sntrys_` org token was issued for, and\n // sentry.io otherwise. A default here would send self-hosted tokens to sentry.io.\n url: userOptions.url ?? process.env['SENTRY_URL'],\n headers: userOptions.headers,\n debug: userOptions.debug ?? false,\n silent: userOptions.silent ?? false,\n errorHandler: userOptions.errorHandler,\n telemetry: userOptions.telemetry ?? true,\n disable: userOptions.disable ?? false,\n sourcemaps: userOptions.sourcemaps,\n release: {\n ...userOptions.release,\n name: resolveReleaseName(userOptions.release?.name),\n inject: userOptions.release?.inject ?? true,\n create: userOptions.release?.create ?? true,\n finalize: userOptions.release?.finalize ?? true,\n vcsRemote: userOptions.release?.vcsRemote ?? process.env['SENTRY_VSC_REMOTE'] ?? 'origin',\n // oxlint-disable-next-line typescript/no-unnecessary-type-assertion -- rule false positive: the cast carries the internal `shouldNotThrowOnFailure` field; tsc errors without it\n setCommits: userOptions.release?.setCommits as\n | (SetCommitsOptions & { shouldNotThrowOnFailure?: boolean })\n | false\n | undefined,\n },\n bundleSizeOptimizations: userOptions.bundleSizeOptimizations,\n reactComponentAnnotation: userOptions.reactComponentAnnotation,\n _metaOptions: {\n telemetry: {\n metaFramework: userOptions._metaOptions?.telemetry?.metaFramework,\n bundlerMajorVersion: userOptions._metaOptions?.telemetry?.bundlerMajorVersion,\n },\n },\n applicationKey: userOptions.applicationKey,\n moduleMetadata: userOptions.moduleMetadata,\n _experiments: userOptions._experiments ?? {},\n };\n\n const vercelEnv = getVercelEnv();\n\n if (options.release.setCommits === undefined) {\n const vercelCommitSha = readCommitEnvVar('VERCEL_GIT_COMMIT_SHA');\n if (\n process.env['VERCEL'] &&\n vercelCommitSha &&\n process.env['VERCEL_GIT_REPO_SLUG'] &&\n process.env['VERCEL_GIT_REPO_OWNER'] &&\n // We only want to set commits for the production env because Sentry becomes extremely noisy (eg on slack) for\n // preview environments because the previous commit is always the \"stem\" commit of the preview/PR causing Sentry\n // to notify you for other people creating PRs.\n vercelEnv === 'production'\n ) {\n options.release.setCommits = {\n shouldNotThrowOnFailure: true,\n commit: vercelCommitSha,\n previousCommit: readCommitEnvVar('VERCEL_GIT_PREVIOUS_SHA'),\n repo: `${process.env['VERCEL_GIT_REPO_OWNER']}/${process.env['VERCEL_GIT_REPO_SLUG']}`,\n ignoreEmpty: true,\n ignoreMissing: true,\n };\n } else if (process.env['VERCEL'] && vercelEnv !== 'production' && !canAutoDetectRepository()) {\n // Vercel's own builders have no git remote and no other CI variables, so `--auto` can only fail there.\n // Builds that have either, such as `vercel build` in GitHub Actions, keep `--auto` below.\n options.release.setCommits = false;\n } else {\n options.release.setCommits = {\n shouldNotThrowOnFailure: true,\n auto: true,\n ignoreEmpty: true,\n ignoreMissing: true,\n };\n }\n }\n\n if (options.release.deploy === undefined && process.env['VERCEL'] && vercelEnv) {\n options.release.deploy = {\n env: vercelEnv,\n url: process.env['VERCEL_URL'] ? `https://${process.env['VERCEL_URL']}` : undefined,\n };\n }\n\n return options;\n}\n\n/**\n * Validates a few combinations of options that are not checked by Sentry CLI.\n *\n * For all other options, we can rely on Sentry CLI to validate them. In fact,\n * we can't validate them in the plugin because Sentry CLI might pick up options from\n * its config file.\n *\n * @param options the internal options\n * @param logger the logger\n *\n * @returns `true` if the options are valid, `false` otherwise\n */\nexport function validateOptions(options: NormalizedOptions, logger: Logger): boolean {\n const setCommits = options.release?.setCommits;\n if (setCommits) {\n if (!setCommits.auto && !(setCommits.repo && setCommits.commit)) {\n logger.error(\n 'The `setCommits` option was specified but is missing required properties.',\n 'Please set either `auto` or both, `repo` and `commit`.',\n );\n return false;\n }\n if (setCommits.auto && setCommits.repo && setCommits) {\n logger.warn(\n 'The `setCommits` options includes `auto` but also `repo` and `commit`.',\n 'Ignoring `repo` and `commit`.',\n 'Please only set either `auto` or both, `repo` and `commit`.',\n );\n }\n }\n\n const sourcemaps = options.sourcemaps;\n const usesFeatureOptions = sourcemaps?.upload !== undefined || sourcemaps?.injectDebugIds !== undefined;\n if (usesFeatureOptions && sourcemaps?.disable !== undefined) {\n logger.warn(\n '`sourcemaps.disable` is ignored because `sourcemaps.upload` or `sourcemaps.injectDebugIds` is set.',\n 'Please remove `sourcemaps.disable`.',\n );\n }\n if (sourcemaps?.injectDebugIds === false && sourcemaps.upload === true) {\n logger.warn(\n '`sourcemaps.upload` is set, but `sourcemaps.injectDebugIds` is `false`.',\n 'Source maps are not uploaded, because the upload matches files by debug ID.',\n );\n }\n if (sourcemaps?.delete !== undefined && sourcemaps.deleteSourcemapsAfterUpload !== undefined) {\n logger.warn(\n '`sourcemaps.deleteSourcemapsAfterUpload` is ignored because `sourcemaps.delete` is set.',\n 'Please remove `sourcemaps.deleteSourcemapsAfterUpload`.',\n );\n }\n if (sourcemaps?.delete === false && sourcemaps.filesToDeleteAfterUpload !== undefined) {\n logger.warn(\n '`sourcemaps.filesToDeleteAfterUpload` still deletes the files it matches, although `sourcemaps.delete` is `false`.',\n 'Remove `sourcemaps.filesToDeleteAfterUpload` to keep the source maps.',\n );\n }\n\n if (options.release?.deploy && typeof options.release.deploy === 'object' && !options.release.deploy.env) {\n logger.error(\n 'The `deploy` option was specified but is missing the required `env` property.',\n 'Please set the `env` property.',\n );\n return false;\n }\n\n if (options.project && Array.isArray(options.project)) {\n if (options.project.length === 0) {\n logger.error(\n 'The `project` option was specified as an array but is empty.',\n 'Please provide at least one project slug.',\n );\n return false;\n }\n // Check each project is a non-empty string\n const invalidProjects = options.project.filter(p => typeof p !== 'string' || p.trim() === '');\n if (invalidProjects.length > 0) {\n logger.error('The `project` option contains invalid project slugs.', 'All projects must be non-empty strings.');\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":";;;AA+FA,MAAa,kBAAkB;AAG/B,SAAgB,qBAAqB,aAA6C;CAChF,MAAM,UAAU;EACd,KAAK,YAAY,OAAO,QAAQ,IAAI;EACpC,SACE,YAAY,YACX,QAAQ,IAAI,iBAAiB,EAAE,SAAS,GAAG,IACxC,QAAQ,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,CAAC,KAAI,MAAK,EAAE,KAAK,CAAC,IAC1D,QAAQ,IAAI;EAClB,WAAW,YAAY,aAAa,QAAQ,IAAI;EAGhD,KAAK,YAAY,OAAO,QAAQ,IAAI;EACpC,SAAS,YAAY;EACrB,OAAO,YAAY,SAAS;EAC5B,QAAQ,YAAY,UAAU;EAC9B,cAAc,YAAY;EAC1B,WAAW,YAAY,aAAa;EACpC,SAAS,YAAY,WAAW;EAChC,YAAY,YAAY;EACxB,SAAS;GACP,GAAG,YAAY;GACf,MAAMA,cAAAA,mBAAmB,YAAY,SAAS,IAAI;GAClD,QAAQ,YAAY,SAAS,UAAU;GACvC,QAAQ,YAAY,SAAS,UAAU;GACvC,UAAU,YAAY,SAAS,YAAY;GAC3C,WAAW,YAAY,SAAS,aAAa,QAAQ,IAAI,wBAAwB;GAEjF,YAAY,YAAY,SAAS;EAInC;EACA,yBAAyB,YAAY;EACrC,0BAA0B,YAAY;EACtC,cAAc,EACZ,WAAW;GACT,eAAe,YAAY,cAAc,WAAW;GACpD,qBAAqB,YAAY,cAAc,WAAW;EAC5D,EACF;EACA,gBAAgB,YAAY;EAC5B,gBAAgB,YAAY;EAC5B,cAAc,YAAY,gBAAgB,CAAC;CAC7C;CAEA,MAAM,aAAA,GAAYC,aAAAA,aAAAA,CAAa;CAE/B,IAAI,QAAQ,QAAQ,eAAe,KAAA,GAAW;EAC5C,MAAM,kBAAkBC,cAAAA,iBAAiB,uBAAuB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F,IAAI,YAAY,WAAW,SAAS,WAAW,6BAA6B,KAAA,GAC1E,OAAO,KACL,sHACA,uEACF;CAGF,IAAI,QAAQ,SAAS,UAAU,OAAO,QAAQ,QAAQ,WAAW,YAAY,CAAC,QAAQ,QAAQ,OAAO,KAAK;EACxG,OAAO,MACL,iFACA,gCACF;EACA,OAAO;CACT;CAEA,IAAI,QAAQ,WAAW,MAAM,QAAQ,QAAQ,OAAO,GAAG;EACrD,IAAI,QAAQ,QAAQ,WAAW,GAAG;GAChC,OAAO,MACL,gEACA,2CACF;GACA,OAAO;EACT;EAGA,IADwB,QAAQ,QAAQ,QAAO,MAAK,OAAO,MAAM,YAAY,EAAE,KAAK,MAAM,EACxE,CAAC,CAAC,SAAS,GAAG;GAC9B,OAAO,MAAM,wDAAwD,yCAAyC;GAC9G,OAAO;EACT;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"options-mapping.js","names":["parseProjectEnvVar","resolveReleaseName","getVercelEnv","readCommitEnvVar","canAutoDetectRepository","warnOnConflictingSourceMapOptions"],"sources":["../../../src/core/options-mapping.ts"],"sourcesContent":["import { getVercelEnv, warnOnConflictingSourceMapOptions } from '@sentry/core';\nimport type { Logger } from './logger';\nimport type {\n InternalOptions as UserOptions,\n SetCommitsOptions,\n RewriteSourcesHook,\n ResolveSourceMapHook,\n IncludeEntry,\n ModuleMetadata,\n ModuleMetadataCallback,\n} from './types';\nimport { parseProjectEnvVar } from './upload-credentials';\nimport { canAutoDetectRepository, readCommitEnvVar, resolveReleaseName } from './utils';\n\nexport type NormalizedOptions = {\n org: string | undefined;\n project: string | string[] | undefined;\n authToken: string | undefined;\n url: string | undefined;\n headers: Record<string, string> | undefined;\n debug: boolean;\n silent: boolean;\n errorHandler: ((err: Error) => void) | undefined;\n telemetry: boolean;\n disable: boolean;\n sourcemaps:\n | {\n disable?: boolean | 'disable-upload';\n upload?: boolean;\n injectDebugIds?: boolean;\n delete?: boolean;\n assets?: string | string[];\n ignore?: string | string[];\n rewriteSources?: RewriteSourcesHook;\n resolveSourceMap?: ResolveSourceMapHook;\n filesToDeleteAfterUpload?: string | string[] | Promise<string | string[] | undefined>;\n deleteSourcemapsAfterUpload?: boolean | ((environment?: string) => boolean | undefined);\n sdkEnabledSourceMaps?: boolean | ((environment?: string) => boolean | undefined);\n }\n | undefined;\n release: {\n name: string | undefined;\n inject: boolean | 'html';\n create: boolean;\n finalize: boolean;\n vcsRemote: string;\n setCommits:\n | (SetCommitsOptions & {\n shouldNotThrowOnFailure?: boolean;\n })\n | false\n | undefined;\n dist?: string;\n deploy?:\n | {\n env: string;\n started?: number | string;\n finished?: number | string;\n time?: number;\n name?: string;\n url?: string;\n }\n | false;\n uploadLegacySourcemaps?: string | IncludeEntry | Array<string | IncludeEntry>;\n };\n bundleSizeOptimizations:\n | {\n excludeDebugStatements?: boolean;\n excludeTracing?: boolean;\n excludeChannelInjection?: boolean;\n excludeReplayCanvas?: boolean;\n excludeReplayShadowDom?: boolean;\n excludeReplayIframe?: boolean;\n excludeReplayWorker?: boolean;\n }\n | undefined;\n reactComponentAnnotation:\n | {\n enabled?: boolean;\n ignoredComponents?: string[];\n _experimentalInjectIntoHtml?: boolean;\n }\n | undefined;\n _metaOptions: {\n telemetry: {\n metaFramework: string | undefined;\n bundlerMajorVersion: string | undefined;\n };\n };\n applicationKey: string | undefined;\n moduleMetadata: ModuleMetadata | ModuleMetadataCallback | undefined;\n _experiments: {\n injectBuildInformation?: boolean;\n } & Record<string, unknown>;\n};\n\nexport const SENTRY_SAAS_URL = 'https://sentry.io';\n\n// oxlint-disable-next-line complexity\nexport function normalizeUserOptions(userOptions: UserOptions): NormalizedOptions {\n const options = {\n org: userOptions.org ?? process.env['SENTRY_ORG'],\n project: userOptions.project ?? parseProjectEnvVar(process.env['SENTRY_PROJECT']),\n authToken: userOptions.authToken ?? process.env['SENTRY_AUTH_TOKEN'],\n // No sentry.io default: the CLI then uses the server an `sntrys_` org token was issued for, and\n // sentry.io otherwise. A default here would send self-hosted tokens to sentry.io.\n url: userOptions.url ?? process.env['SENTRY_URL'],\n headers: userOptions.headers,\n debug: userOptions.debug ?? false,\n silent: userOptions.silent ?? false,\n errorHandler: userOptions.errorHandler,\n telemetry: userOptions.telemetry ?? true,\n disable: userOptions.disable ?? false,\n sourcemaps: userOptions.sourcemaps,\n release: {\n ...userOptions.release,\n name: resolveReleaseName(userOptions.release?.name),\n inject: userOptions.release?.inject ?? true,\n create: userOptions.release?.create ?? true,\n finalize: userOptions.release?.finalize ?? true,\n vcsRemote: userOptions.release?.vcsRemote ?? process.env['SENTRY_VSC_REMOTE'] ?? 'origin',\n // oxlint-disable-next-line typescript/no-unnecessary-type-assertion -- rule false positive: the cast carries the internal `shouldNotThrowOnFailure` field; tsc errors without it\n setCommits: userOptions.release?.setCommits as\n | (SetCommitsOptions & { shouldNotThrowOnFailure?: boolean })\n | false\n | undefined,\n },\n bundleSizeOptimizations: userOptions.bundleSizeOptimizations,\n reactComponentAnnotation: userOptions.reactComponentAnnotation,\n _metaOptions: {\n telemetry: {\n metaFramework: userOptions._metaOptions?.telemetry?.metaFramework,\n bundlerMajorVersion: userOptions._metaOptions?.telemetry?.bundlerMajorVersion,\n },\n },\n applicationKey: userOptions.applicationKey,\n moduleMetadata: userOptions.moduleMetadata,\n _experiments: userOptions._experiments ?? {},\n };\n\n const vercelEnv = getVercelEnv();\n\n if (options.release.setCommits === undefined) {\n const vercelCommitSha = readCommitEnvVar('VERCEL_GIT_COMMIT_SHA');\n if (\n process.env['VERCEL'] &&\n vercelCommitSha &&\n process.env['VERCEL_GIT_REPO_SLUG'] &&\n process.env['VERCEL_GIT_REPO_OWNER'] &&\n // We only want to set commits for the production env because Sentry becomes extremely noisy (eg on slack) for\n // preview environments because the previous commit is always the \"stem\" commit of the preview/PR causing Sentry\n // to notify you for other people creating PRs.\n vercelEnv === 'production'\n ) {\n options.release.setCommits = {\n shouldNotThrowOnFailure: true,\n commit: vercelCommitSha,\n previousCommit: readCommitEnvVar('VERCEL_GIT_PREVIOUS_SHA'),\n repo: `${process.env['VERCEL_GIT_REPO_OWNER']}/${process.env['VERCEL_GIT_REPO_SLUG']}`,\n ignoreEmpty: true,\n ignoreMissing: true,\n };\n } else if (\n process.env['VERCEL'] &&\n vercelEnv !== 'production' &&\n !canAutoDetectRepository(options.release.vcsRemote)\n ) {\n // Vercel's own builders have no git remote and no other CI variables, so commit association can only fail there.\n // Builds that have either, such as `vercel build` in GitHub Actions, keep `auto: true` below.\n options.release.setCommits = false;\n } else {\n options.release.setCommits = {\n shouldNotThrowOnFailure: true,\n auto: true,\n ignoreEmpty: true,\n ignoreMissing: true,\n };\n }\n }\n\n if (options.release.deploy === undefined && process.env['VERCEL'] && vercelEnv) {\n options.release.deploy = {\n env: vercelEnv,\n url: process.env['VERCEL_URL'] ? `https://${process.env['VERCEL_URL']}` : undefined,\n };\n }\n\n return options;\n}\n\n/**\n * Validates a few combinations of options that are not checked by Sentry CLI.\n *\n * For all other options, we can rely on Sentry CLI to validate them. In fact,\n * we can't validate them in the plugin because Sentry CLI might pick up options from\n * its config file.\n *\n * @param options the internal options\n * @param logger the logger\n *\n * @returns `true` if the options are valid, `false` otherwise\n */\nexport function validateOptions(options: NormalizedOptions, logger: Logger): boolean {\n const setCommits = options.release?.setCommits;\n if (setCommits) {\n if (!setCommits.auto && !(setCommits.repo && setCommits.commit)) {\n logger.error(\n 'The `setCommits` option was specified but is missing required properties.',\n 'Please set either `auto` or both, `repo` and `commit`.',\n );\n return false;\n }\n if (setCommits.auto && setCommits.repo && setCommits) {\n logger.warn(\n 'The `setCommits` options includes `auto` but also `repo` and `commit`.',\n 'Ignoring `repo` and `commit`.',\n 'Please only set either `auto` or both, `repo` and `commit`.',\n );\n }\n }\n\n warnOnConflictingSourceMapOptions(options.sourcemaps, message => logger.warn(message));\n\n if (options.release?.deploy && typeof options.release.deploy === 'object' && !options.release.deploy.env) {\n logger.error(\n 'The `deploy` option was specified but is missing the required `env` property.',\n 'Please set the `env` property.',\n );\n return false;\n }\n\n if (options.project && Array.isArray(options.project)) {\n if (options.project.length === 0) {\n logger.error(\n 'The `project` option was specified as an array but is empty.',\n 'Please provide at least one project slug.',\n );\n return false;\n }\n // Check each project is a non-empty string\n const invalidProjects = options.project.filter(p => typeof p !== 'string' || p.trim() === '');\n if (invalidProjects.length > 0) {\n logger.error('The `project` option contains invalid project slugs.', 'All projects must be non-empty strings.');\n return false;\n }\n }\n\n return true;\n}\n"],"mappings":";;;;AAgGA,MAAa,kBAAkB;AAG/B,SAAgB,qBAAqB,aAA6C;CAChF,MAAM,UAAU;EACd,KAAK,YAAY,OAAO,QAAQ,IAAI;EACpC,SAAS,YAAY,WAAWA,2BAAAA,mBAAmB,QAAQ,IAAI,iBAAiB;EAChF,WAAW,YAAY,aAAa,QAAQ,IAAI;EAGhD,KAAK,YAAY,OAAO,QAAQ,IAAI;EACpC,SAAS,YAAY;EACrB,OAAO,YAAY,SAAS;EAC5B,QAAQ,YAAY,UAAU;EAC9B,cAAc,YAAY;EAC1B,WAAW,YAAY,aAAa;EACpC,SAAS,YAAY,WAAW;EAChC,YAAY,YAAY;EACxB,SAAS;GACP,GAAG,YAAY;GACf,MAAMC,cAAAA,mBAAmB,YAAY,SAAS,IAAI;GAClD,QAAQ,YAAY,SAAS,UAAU;GACvC,QAAQ,YAAY,SAAS,UAAU;GACvC,UAAU,YAAY,SAAS,YAAY;GAC3C,WAAW,YAAY,SAAS,aAAa,QAAQ,IAAI,wBAAwB;GAEjF,YAAY,YAAY,SAAS;EAInC;EACA,yBAAyB,YAAY;EACrC,0BAA0B,YAAY;EACtC,cAAc,EACZ,WAAW;GACT,eAAe,YAAY,cAAc,WAAW;GACpD,qBAAqB,YAAY,cAAc,WAAW;EAC5D,EACF;EACA,gBAAgB,YAAY;EAC5B,gBAAgB,YAAY;EAC5B,cAAc,YAAY,gBAAgB,CAAC;CAC7C;CAEA,MAAM,aAAA,GAAYC,aAAAA,aAAAA,CAAa;CAE/B,IAAI,QAAQ,QAAQ,eAAe,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ACT;CAEA,IAAI,QAAQ,WAAW,MAAM,QAAQ,QAAQ,OAAO,GAAG;EACrD,IAAI,QAAQ,QAAQ,WAAW,GAAG;GAChC,OAAO,MACL,gEACA,2CACF;GACA,OAAO;EACT;EAGA,IADwB,QAAQ,QAAQ,QAAO,MAAK,OAAO,MAAM,YAAY,EAAE,KAAK,MAAM,EACxE,CAAC,CAAC,SAAS,GAAG;GAC9B,OAAO,MAAM,wDAAwD,yCAAyC;GAC9G,OAAO;EACT;CACF;CAEA,OAAO;AACT"}
@@ -0,0 +1,49 @@
1
+ const require_runtime = require("../_virtual/_rolldown/runtime.js");
2
+ const require_utils = require("./utils.js");
3
+ let path = require("path");
4
+ path = require_runtime.__toESM(path);
5
+ let fs = require("fs");
6
+ fs = require_runtime.__toESM(fs);
7
+ let dotenv = require("dotenv");
8
+ dotenv = require_runtime.__toESM(dotenv);
9
+ // src/core/upload-credentials.ts
10
+ /** The variables in `.env.sentry-build-plugin`, or `undefined` when the file does not exist. */
11
+ function readSentryBuildPluginEnvFile() {
12
+ try {
13
+ const dotenvFile = fs.readFileSync(path.join(process.cwd(), ".env.sentry-build-plugin"), "utf-8");
14
+ return dotenv.parse(dotenvFile);
15
+ } catch (e) {
16
+ if (typeof e === "object" && e && "code" in e && e.code !== "ENOENT") throw e;
17
+ return;
18
+ }
19
+ }
20
+ /** Reads `SENTRY_PROJECT`, which holds one project or a comma-separated list. */
21
+ function parseProjectEnvVar(value) {
22
+ return value?.includes(",") ? value.split(",").map((p) => p.trim()) : value;
23
+ }
24
+ /** The first credential the upload needs that is missing. */
25
+ function getMissingUploadCredential({ authToken, org, project }) {
26
+ if (!authToken) return "no-auth-token";
27
+ if (!org && !authToken.startsWith("sntrys_")) return "no-org";
28
+ if (!require_utils.getProjects(project)?.[0]) return "no-project";
29
+ }
30
+ /**
31
+ * Whether the plugin has the credentials to upload source maps. It reads the same environment
32
+ * variables and `.env.sentry-build-plugin` file as the plugin, so SDKs can call it before they
33
+ * create the plugin.
34
+ */
35
+ function hasSourceMapUploadCredentials(options) {
36
+ const envFile = readSentryBuildPluginEnvFile();
37
+ const env = (name) => envFile?.[name] ?? process.env[name];
38
+ return getMissingUploadCredential({
39
+ authToken: options?.authToken ?? env("SENTRY_AUTH_TOKEN"),
40
+ org: options?.org ?? env("SENTRY_ORG"),
41
+ project: options?.project ?? parseProjectEnvVar(env("SENTRY_PROJECT"))
42
+ }) === void 0;
43
+ }
44
+ exports.getMissingUploadCredential = getMissingUploadCredential;
45
+ exports.hasSourceMapUploadCredentials = hasSourceMapUploadCredentials;
46
+ exports.parseProjectEnvVar = parseProjectEnvVar;
47
+ exports.readSentryBuildPluginEnvFile = readSentryBuildPluginEnvFile;
48
+
49
+ //# sourceMappingURL=upload-credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload-credentials.js","names":["getProjects"],"sources":["../../../src/core/upload-credentials.ts"],"sourcesContent":["import * as dotenv from 'dotenv';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { getProjects } from './utils';\n\nexport type UploadCredentials = {\n authToken?: string;\n org?: string;\n project?: string | string[];\n};\n\n/** The variables in `.env.sentry-build-plugin`, or `undefined` when the file does not exist. */\nexport function readSentryBuildPluginEnvFile(): Record<string, string> | undefined {\n try {\n const dotenvFile = fs.readFileSync(path.join(process.cwd(), '.env.sentry-build-plugin'), 'utf-8');\n // NOTE: Do not use the dotenv.config API directly to read the dotenv file! For some ungodly reason, it falls back to reading `${process.cwd()}/.env` which is absolutely not what we want.\n return dotenv.parse(dotenvFile);\n } catch (e: unknown) {\n // Ignore \"file not found\" errors but throw all others\n if (typeof e === 'object' && e && 'code' in e && e.code !== 'ENOENT') {\n throw e;\n }\n return undefined;\n }\n}\n\n/** Reads `SENTRY_PROJECT`, which holds one project or a comma-separated list. */\nexport function parseProjectEnvVar(value: string | undefined): string | string[] | undefined {\n return value?.includes(',') ? value.split(',').map(p => p.trim()) : value;\n}\n\n/** The first credential the upload needs that is missing. */\nexport function getMissingUploadCredential({\n authToken,\n org,\n project,\n}: UploadCredentials): 'no-auth-token' | 'no-org' | 'no-project' | undefined {\n if (!authToken) {\n return 'no-auth-token';\n }\n if (!org && !authToken.startsWith('sntrys_')) {\n return 'no-org';\n }\n if (!getProjects(project)?.[0]) {\n return 'no-project';\n }\n return undefined;\n}\n\n/**\n * Whether the plugin has the credentials to upload source maps. It reads the same environment\n * variables and `.env.sentry-build-plugin` file as the plugin, so SDKs can call it before they\n * create the plugin.\n */\nexport function hasSourceMapUploadCredentials(options: UploadCredentials | undefined): boolean {\n const envFile = readSentryBuildPluginEnvFile();\n const env = (name: string): string | undefined => envFile?.[name] ?? process.env[name];\n\n return (\n getMissingUploadCredential({\n authToken: options?.authToken ?? env('SENTRY_AUTH_TOKEN'),\n org: options?.org ?? env('SENTRY_ORG'),\n project: options?.project ?? parseProjectEnvVar(env('SENTRY_PROJECT')),\n }) === undefined\n );\n}\n"],"mappings":";;;;;;;;;;AAYA,SAAgB,+BAAmE;CACjF,IAAI;EACF,MAAM,aAAa,GAAG,aAAa,KAAK,KAAK,QAAQ,IAAI,GAAG,0BAA0B,GAAG,OAAO;EAEhG,OAAO,OAAO,MAAM,UAAU;CAChC,SAAS,GAAY;EAEnB,IAAI,OAAO,MAAM,YAAY,KAAK,UAAU,KAAK,EAAE,SAAS,UAC1D,MAAM;EAER;CACF;AACF;;AAGA,SAAgB,mBAAmB,OAA0D;CAC3F,OAAO,OAAO,SAAS,GAAG,IAAI,MAAM,MAAM,GAAG,CAAC,CAAC,KAAI,MAAK,EAAE,KAAK,CAAC,IAAI;AACtE;;AAGA,SAAgB,2BAA2B,EACzC,WACA,KACA,WAC2E;CAC3E,IAAI,CAAC,WACH,OAAO;CAET,IAAI,CAAC,OAAO,CAAC,UAAU,WAAW,SAAS,GACzC,OAAO;CAET,IAAI,CAACA,cAAAA,YAAY,OAAO,CAAC,GAAG,IAC1B,OAAO;AAGX;;;;;;AAOA,SAAgB,8BAA8B,SAAiD;CAC7F,MAAM,UAAU,6BAA6B;CAC7C,MAAM,OAAO,SAAqC,UAAU,SAAS,QAAQ,IAAI;CAEjF,OACE,2BAA2B;EACzB,WAAW,SAAS,aAAa,IAAI,mBAAmB;EACxD,KAAK,SAAS,OAAO,IAAI,YAAY;EACrC,SAAS,SAAS,WAAW,mBAAmB,IAAI,gBAAgB,CAAC;CACvE,CAAC,MAAM,KAAA;AAEX"}
@@ -139,12 +139,16 @@ const CI_REPOSITORY_ENV_VARS = [
139
139
  "BUILD_REPOSITORY_URI"
140
140
  ];
141
141
  /**
142
- * Whether `set-commits --auto` can find the repository: from the `origin` git remote, or from CI variables.
142
+ * Whether commit association can find the repository: from the given git remote, or from CI variables.
143
143
  */
144
- function canAutoDetectRepository() {
144
+ function canAutoDetectRepository(remote = "origin") {
145
145
  if (CI_REPOSITORY_ENV_VARS.some((name) => process.env[name]) || process.env["NETLIFY"] && process.env["REPOSITORY_URL"]) return true;
146
146
  try {
147
- child_process.default.execSync("git remote get-url origin", {
147
+ child_process.default.execFileSync("git", [
148
+ "remote",
149
+ "get-url",
150
+ remote
151
+ ], {
148
152
  stdio: "ignore",
149
153
  windowsHide: true
150
154
  });
@@ -154,6 +158,37 @@ function canAutoDetectRepository() {
154
158
  }
155
159
  }
156
160
  /**
161
+ * Reads the `owner/repo` path of a git remote, e.g. `getsentry/sentry-javascript` for
162
+ * `git@github.com:getsentry/sentry-javascript.git`.
163
+ */
164
+ function getGitRemoteRepository(remote) {
165
+ let url;
166
+ try {
167
+ url = child_process.default.execFileSync("git", [
168
+ "remote",
169
+ "get-url",
170
+ remote
171
+ ], {
172
+ stdio: [
173
+ "ignore",
174
+ "pipe",
175
+ "ignore"
176
+ ],
177
+ windowsHide: true
178
+ }).toString().trim();
179
+ } catch {
180
+ return;
181
+ }
182
+ let repoPath;
183
+ try {
184
+ repoPath = new URL(url).pathname;
185
+ } catch {
186
+ repoPath = url.slice(url.indexOf(":") + 1);
187
+ }
188
+ const repository = repoPath.replace(/^\/+|\/+$/g, "").replace(/\.git$/, "");
189
+ return repository.includes("/") ? repository : void 0;
190
+ }
191
+ /**
157
192
  * Tries to guess a release name based on environmental data.
158
193
  */
159
194
  function determineReleaseName() {
@@ -280,9 +315,11 @@ exports.generateModuleMetadataInjectorCode = generateModuleMetadataInjectorCode;
280
315
  exports.generateReleaseInjectorCode = generateReleaseInjectorCode;
281
316
  exports.getBuildInformation = getBuildInformation;
282
317
  exports.getDependencies = getDependencies;
318
+ exports.getGitRemoteRepository = getGitRemoteRepository;
283
319
  exports.getPackageJson = getPackageJson;
284
320
  exports.getProjects = getProjects;
285
321
  exports.getTurborepoEnvPassthroughWarning = getTurborepoEnvPassthroughWarning;
322
+ exports.gitRevision = gitRevision;
286
323
  exports.parseMajorVersion = parseMajorVersion;
287
324
  exports.readCommitEnvVar = readCommitEnvVar;
288
325
  exports.replaceBooleanFlagsInCode = replaceBooleanFlagsInCode;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["path","os","fs","crypto","childProcess","getReleaseFromCommitEnv","readCoreCommitEnvVar","stringifyForCodeInjection","MagicString"],"sources":["../../../src/core/utils.ts"],"sourcesContent":["/* oxlint-disable max-lines */\nimport path from 'path';\nimport fs from 'fs';\nimport os from 'os';\nimport crypto from 'crypto';\nimport childProcess from 'child_process';\nimport type { SourceMap } from 'magic-string';\nimport MagicString from 'magic-string';\nimport {\n _INTERNAL_getReleaseFromCommitEnv as getReleaseFromCommitEnv,\n _INTERNAL_readCommitEnvVar as readCoreCommitEnvVar,\n} from '@sentry/core/server';\nimport { stringifyForCodeInjection } from '@sentry/core';\n\n/**\n * Checks whether the given input is already an array, and if it isn't, wraps it in one.\n *\n * @param maybeArray Input to turn into an array, if necessary\n * @returns The input, if already an array, or an array with the input as the only element, if not\n */\nexport function arrayify<T = unknown>(maybeArray: T | T[]): T[] {\n return Array.isArray(maybeArray) ? maybeArray : [maybeArray];\n}\n\ntype PackageJson = Record<string, unknown>;\n\n/**\n * Get the closes package.json from a given starting point upwards.\n * This handles a few edge cases:\n * * Check if a given file package.json appears to be an actual NPM package.json file\n * * Stop at the home dir, to avoid looking too deeply\n */\nexport function getPackageJson({ cwd, stopAt }: { cwd?: string; stopAt?: string } = {}): PackageJson | undefined {\n return lookupPackageJson(cwd ?? process.cwd(), path.normalize(stopAt ?? os.homedir()));\n}\n\nexport function parseMajorVersion(ver: string): number | undefined {\n let version = ver;\n // if it has a `v` prefix, remove it\n if (version.startsWith('v')) {\n version = version.slice(1);\n }\n\n // First, try simple lookup of exact, ~ and ^ versions\n const regex = /^[\\^~]?(\\d+)(\\.\\d+)?(\\.\\d+)?(-.+)?/;\n\n const match = version.match(regex);\n if (match) {\n return parseInt(match[1] as string, 10);\n }\n\n // Try to parse e.g. 1.x\n const coerced = parseInt(version, 10);\n if (!Number.isNaN(coerced)) {\n return coerced;\n }\n\n // Match <= and >= ranges.\n const gteLteRegex = /^[<>]=\\s*(\\d+)(\\.\\d+)?(\\.\\d+)?(-.+)?/;\n const gteLteMatch = version.match(gteLteRegex);\n if (gteLteMatch) {\n return parseInt(gteLteMatch[1] as string, 10);\n }\n\n // match < ranges\n const ltRegex = /^<\\s*(\\d+)(\\.\\d+)?(\\.\\d+)?(-.+)?/;\n const ltMatch = version.match(ltRegex);\n if (ltMatch) {\n // Two scenarios:\n // a) < 2.0.0 --> return 1\n // b) < 2.1.0 --> return 2\n\n const major = parseInt(ltMatch[1] as string, 10);\n\n if (\n // minor version > 0\n (typeof ltMatch[2] === 'string' && parseInt(ltMatch[2].slice(1), 10) > 0) ||\n // patch version > 0\n (typeof ltMatch[3] === 'string' && parseInt(ltMatch[3].slice(1), 10) > 0)\n ) {\n return major;\n }\n\n return major - 1;\n }\n\n // match > ranges\n const gtRegex = /^>\\s*(\\d+)(\\.\\d+)?(\\.\\d+)?(-.+)?/;\n const gtMatch = version.match(gtRegex);\n if (gtMatch) {\n // We always return the version here, even though it _may_ be incorrect\n // E.g. if given > 2.0.0, it should be 2 if there exists any 2.x.x version, else 3\n // Since there is no way for us to know this, we're going to assume any kind of patch/feature release probably exists\n return parseInt(gtMatch[1] as string, 10);\n }\n return undefined;\n}\n\n// This is an explicit list of packages where we want to include the (major) version number.\nconst PACKAGES_TO_INCLUDE_VERSION = [\n 'react',\n '@angular/core',\n 'vue',\n 'ember-source',\n 'svelte',\n '@sveltejs/kit',\n 'webpack',\n 'vite',\n 'gatsby',\n 'next',\n 'remix',\n 'rollup',\n 'esbuild',\n];\n\nexport function getDependencies(packageJson: PackageJson): {\n deps: string[];\n depsVersions: Record<string, number>;\n} {\n const dependencies: Record<string, string> = Object.assign(\n {},\n packageJson['devDependencies'] ?? {},\n packageJson['dependencies'] ?? {},\n );\n\n const deps = Object.keys(dependencies).sort();\n\n const depsVersions: Record<string, number> = deps.reduce(\n (depsVersions, depName) => {\n if (PACKAGES_TO_INCLUDE_VERSION.includes(depName)) {\n const version = dependencies[depName] as string;\n const majorVersion = parseMajorVersion(version);\n if (majorVersion) {\n depsVersions[depName] = majorVersion;\n }\n }\n return depsVersions;\n },\n {} as Record<string, number>,\n );\n\n return { deps, depsVersions };\n}\n\nfunction findPackageJson(cwd: string, stopAt: string): string | undefined {\n let dirName = path.resolve(cwd);\n\n for (;;) {\n // Stop if we reach this dir\n if (path.normalize(dirName) === stopAt) {\n return undefined;\n }\n\n const jsonPath = path.join(dirName, 'package.json');\n if (fs.existsSync(jsonPath)) {\n return jsonPath;\n }\n\n const parentDirName = path.dirname(dirName);\n // We reached the file system root\n if (parentDirName === dirName) {\n return undefined;\n }\n\n dirName = parentDirName;\n }\n}\n\nfunction lookupPackageJson(cwd: string, stopAt: string): PackageJson | undefined {\n const jsonPath = findPackageJson(cwd, stopAt);\n\n if (!jsonPath) {\n return undefined;\n }\n\n try {\n const jsonStr = fs.readFileSync(jsonPath, 'utf8');\n const json = JSON.parse(jsonStr) as PackageJson;\n\n // Ensure it is an actual package.json\n // This is very much not bulletproof, but should be good enough\n if ('name' in json || 'private' in json) {\n return json;\n }\n } catch {\n // Ignore and walk up\n }\n\n // Continue up the tree, if we find a fitting package.json\n const newCwd = path.dirname(path.resolve(`${jsonPath}/..`));\n return lookupPackageJson(newCwd, stopAt);\n}\n\n/**\n * Deterministically hashes a string and turns the hash into a uuid.\n */\nexport function stringToUUID(str: string): string {\n const sha256Hash = crypto.createHash('sha256').update(str).digest('hex');\n\n // Position 16 is fixed to either 8, 9, a, or b in the uuid v4 spec (10xx in binary)\n // RFC 4122 section 4.4\n const v4variant = ['8', '9', 'a', 'b'][sha256Hash.substring(16, 17).charCodeAt(0) % 4] as string;\n\n return `${sha256Hash.substring(0, 8)}-${sha256Hash.substring(8, 12)}-4${sha256Hash.substring(13, 16)}-${v4variant}${sha256Hash.substring(17, 20)}-${sha256Hash.substring(20, 32)}`.toLowerCase();\n}\n\nfunction gitRevision(): string | undefined {\n let gitRevision: string | undefined;\n try {\n gitRevision = childProcess\n .execSync('git rev-parse HEAD', { stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true })\n .toString()\n .trim();\n } catch {\n // noop\n }\n return gitRevision;\n}\n\n// Mirrors the CLI's `set-commits --auto` fallback for builds without an `origin` remote. Vercel is left out\n// because the CLI only reads `VERCEL_GIT_*` on production builds.\nconst CI_REPOSITORY_ENV_VARS = [\n 'GITHUB_REPOSITORY',\n 'CI_PROJECT_PATH',\n 'BITBUCKET_REPO_FULL_NAME',\n 'RENDER_GIT_REPO_SLUG',\n 'RAILWAY_GIT_REPO_NAME',\n 'CIRCLE_PROJECT_REPONAME',\n 'BUILDKITE_REPO',\n 'BUILD_REPOSITORY_URI',\n] as const;\n\n/**\n * Whether `set-commits --auto` can find the repository: from the `origin` git remote, or from CI variables.\n */\nexport function canAutoDetectRepository(): boolean {\n if (\n CI_REPOSITORY_ENV_VARS.some(name => process.env[name]) ||\n (process.env['NETLIFY'] && process.env['REPOSITORY_URL'])\n ) {\n return true;\n }\n try {\n childProcess.execSync('git remote get-url origin', { stdio: 'ignore', windowsHide: true });\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Tries to guess a release name based on environmental data.\n */\nexport function determineReleaseName(): string | undefined {\n return getReleaseFromCommitEnv(warnAboutPlaceholderCommitEnvVar) || gitRevision();\n}\n\n/**\n * Resolves the release name the way the bundler plugins do: the configured name, then the `SENTRY_RELEASE`\n * environment variable, then a name detected from CI environment variables or git.\n *\n * Framework SDKs that pass the release to the SDK at runtime use this to get the same name the plugin uses.\n */\nexport function resolveReleaseName(name?: string): string | undefined {\n return name ?? process.env['SENTRY_RELEASE'] ?? determineReleaseName();\n}\n\n// Release detection and commit association can read the same variable in one build.\nconst warnedPlaceholderEnvVars = new Set<string>();\n\nfunction warnAboutPlaceholderCommitEnvVar(name: string): void {\n if (warnedPlaceholderEnvVars.has(name)) {\n return;\n }\n warnedPlaceholderEnvVars.add(name);\n // This runs before the plugin logger exists, so `silent: true` does not suppress it. That is\n // deliberate: a warning that is easy to miss is how this misconfiguration went unnoticed.\n // eslint-disable-next-line no-console\n console.warn(\n `[@sentry/bundler-plugins] Ignoring the ${name} environment variable as a release name, because its value is its own name. Set the release explicitly, or fix the variable in your build environment.`,\n );\n}\n\n/**\n * Reads an environment variable that should hold a commit SHA, ignoring a value that is the\n * variable's own name. See `_INTERNAL_readCommitEnvVar` in `@sentry/core/server`.\n */\nexport function readCommitEnvVar(name: string): string | undefined {\n return readCoreCommitEnvVar(name, warnAboutPlaceholderCommitEnvVar);\n}\n\n/**\n * Generates code for the global injector which is responsible for setting the global\n * `SENTRY_RELEASE` & `SENTRY_BUILD_INFO` variables.\n */\nexport function generateReleaseInjectorCode({\n release,\n injectBuildInformation,\n}: {\n release: string;\n injectBuildInformation: boolean;\n}): CodeInjection {\n let code = `e.SENTRY_RELEASE={id:${stringifyForCodeInjection(release)}};`;\n\n if (injectBuildInformation) {\n const buildInfo = getBuildInformation();\n\n code += `e.SENTRY_BUILD_INFO=${stringifyForCodeInjection(buildInfo)};`;\n }\n\n return new CodeInjection(code);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function generateModuleMetadataInjectorCode(metadata: any): CodeInjection {\n // We are merging the metadata objects in case modules are bundled twice with the plugin\n // Use try-catch to avoid issues when bundlers rename global variables like 'window' to 'k'\n return new CodeInjection(\n `e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],${stringifyForCodeInjection(\n metadata,\n )});`,\n );\n}\n\nexport function getBuildInformation(): {\n deps: string[];\n depsVersions: Record<string, number>;\n nodeVersion: number | undefined;\n} {\n const packageJson = getPackageJson();\n\n const { deps, depsVersions } = packageJson ? getDependencies(packageJson) : { deps: [], depsVersions: {} };\n\n return {\n deps,\n depsVersions,\n nodeVersion: parseMajorVersion(process.version),\n };\n}\n\nexport function stripQueryAndHashFromPath(path: string): string {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return path.split('?')[0]!.split('#')[0]!;\n}\n\nexport function replaceBooleanFlagsInCode(\n code: string,\n replacementValues: Record<string, boolean | undefined>,\n): { code: string; map: SourceMap } | null {\n const ms = new MagicString(code);\n\n Object.keys(replacementValues).forEach(key => {\n const value = replacementValues[key];\n\n if (typeof value === 'boolean') {\n ms.replaceAll(key, JSON.stringify(value));\n }\n });\n\n if (ms.hasChanged()) {\n return {\n code: ms.toString(),\n map: ms.generateMap({ hires: 'boundary' }),\n };\n }\n\n return null;\n}\n\n// https://turbo.build/repo/docs/reference/system-environment-variables#environment-variables-in-tasks\nexport function getTurborepoEnvPassthroughWarning(envVarName: string): string {\n return process.env['TURBO_HASH']\n ? `\\nYou seem to be using Turborepo, did you forget to put ${envVarName} in \\`passThroughEnv\\`? https://turbo.build/repo/docs/reference/configuration#passthroughenv`\n : '';\n}\n\n/**\n * Gets the projects from the project option. This might be a single project or an array of projects.\n */\nexport function getProjects(project: string | string[] | undefined): string[] | undefined {\n if (Array.isArray(project)) {\n return project;\n }\n\n if (project) {\n return [project];\n }\n\n return undefined;\n}\n\n/**\n * Checks if a chunk contains only import/export statements and no substantial code.\n *\n * In Vite MPA (multi-page application) mode, HTML entry points create \"facade\" chunks\n * that only contain import statements to load shared modules. These should not have\n * Sentry code injected. However, in SPA mode, the main bundle also has an HTML facade\n * but contains substantial application code that SHOULD have debug IDs injected.\n *\n * @ref https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829\n * @ref https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/839\n */\nexport function containsOnlyImports(code: string): boolean {\n const codeWithoutImports = code\n // Remove side effect imports: import '/path'; or import \"./path\";\n // Using explicit negated character classes to avoid polynomial backtracking\n .replace(/^\\s*import\\s+(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`\\n]*`)[\\s;]*$/gm, '')\n // Remove named/default imports: import x from '/path'; import { x } from '/path';\n .replace(/^\\s*import\\b[^'\"`\\n]*\\bfrom\\s+(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`\\n]*`)[\\s;]*$/gm, '')\n // Remove re-exports: export * from '/path'; export { x } from '/path';\n .replace(/^\\s*export\\b[^'\"`\\n]*\\bfrom\\s+(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`\\n]*`)[\\s;]*$/gm, '')\n // Remove block comments\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n // Remove line comments\n .replace(/\\/\\/.*$/gm, '')\n // Remove \"use strict\" directives\n .replace(/[\"']use strict[\"']\\s*;?/g, '')\n .trim();\n\n return codeWithoutImports.length === 0;\n}\n\nexport class CodeInjection {\n // The code below is mostly ternary operators because it saves bundle size.\n // The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)\n private readonly header: string;\n private readonly footer: string;\n\n constructor(private body: string = '') {\n // `globalThis` is checked first so the other identifiers are never evaluated\n // where it exists. A downstream bundler that runs over an already-injected\n // chunk can turn a free `global` into a `const` it declares further down the\n // file (Nitro's node compat does this). Reading that binding from the top of\n // the file hits the temporal dead zone, and `typeof` throws there instead of\n // returning \"undefined\", so the whole injection was silently swallowed by the\n // `catch` below and the chunk registered no debug ID.\n this.header = `!function(){try{var e=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:{};`;\n this.footer = '}catch(e){}}();';\n }\n\n public code(): string {\n if (this.isEmpty()) {\n return '';\n }\n\n return this.header + this.body + this.footer;\n }\n\n public isEmpty(): boolean {\n return this.body.length === 0;\n }\n\n public append(code: CodeInjection | string): void {\n if (code instanceof CodeInjection) {\n this.body += code.body;\n } else {\n this.body += code;\n }\n }\n\n public clear(): void {\n this.body = '';\n }\n\n public clone(): CodeInjection {\n return new CodeInjection(this.body);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,SAAsB,YAA0B;CAC9D,OAAO,MAAM,QAAQ,UAAU,IAAI,aAAa,CAAC,UAAU;AAC7D;;;;;;;AAUA,SAAgB,eAAe,EAAE,KAAK,WAA8C,CAAC,GAA4B;CAC/G,OAAO,kBAAkB,OAAO,QAAQ,IAAI,GAAGA,KAAAA,QAAK,UAAU,UAAUC,GAAAA,QAAG,QAAQ,CAAC,CAAC;AACvF;AAEA,SAAgB,kBAAkB,KAAiC;CACjE,IAAI,UAAU;CAEd,IAAI,QAAQ,WAAW,GAAG,GACxB,UAAU,QAAQ,MAAM,CAAC;CAM3B,MAAM,QAAQ,QAAQ,MAAM,oCAAK;CACjC,IAAI,OACF,OAAO,SAAS,MAAM,IAAc,EAAE;CAIxC,MAAM,UAAU,SAAS,SAAS,EAAE;CACpC,IAAI,CAAC,OAAO,MAAM,OAAO,GACvB,OAAO;CAKT,MAAM,cAAc,QAAQ,MAAM,sCAAW;CAC7C,IAAI,aACF,OAAO,SAAS,YAAY,IAAc,EAAE;CAK9C,MAAM,UAAU,QAAQ,MAAM,kCAAO;CACrC,IAAI,SAAS;EAKX,MAAM,QAAQ,SAAS,QAAQ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B;CAEO,QAAc;EACnB,KAAK,OAAO;CACd;CAEO,QAAuB;EAC5B,OAAO,IAAI,cAAc,KAAK,IAAI;CACpC;AACF"}
1
+ {"version":3,"file":"utils.js","names":["path","os","fs","crypto","childProcess","getReleaseFromCommitEnv","readCoreCommitEnvVar","stringifyForCodeInjection","MagicString"],"sources":["../../../src/core/utils.ts"],"sourcesContent":["/* oxlint-disable max-lines */\nimport path from 'path';\nimport fs from 'fs';\nimport os from 'os';\nimport crypto from 'crypto';\nimport childProcess from 'child_process';\nimport type { SourceMap } from 'magic-string';\nimport MagicString from 'magic-string';\nimport {\n _INTERNAL_getReleaseFromCommitEnv as getReleaseFromCommitEnv,\n _INTERNAL_readCommitEnvVar as readCoreCommitEnvVar,\n} from '@sentry/core/server';\nimport { stringifyForCodeInjection } from '@sentry/core';\n\n/**\n * Checks whether the given input is already an array, and if it isn't, wraps it in one.\n *\n * @param maybeArray Input to turn into an array, if necessary\n * @returns The input, if already an array, or an array with the input as the only element, if not\n */\nexport function arrayify<T = unknown>(maybeArray: T | T[]): T[] {\n return Array.isArray(maybeArray) ? maybeArray : [maybeArray];\n}\n\ntype PackageJson = Record<string, unknown>;\n\n/**\n * Get the closes package.json from a given starting point upwards.\n * This handles a few edge cases:\n * * Check if a given file package.json appears to be an actual NPM package.json file\n * * Stop at the home dir, to avoid looking too deeply\n */\nexport function getPackageJson({ cwd, stopAt }: { cwd?: string; stopAt?: string } = {}): PackageJson | undefined {\n return lookupPackageJson(cwd ?? process.cwd(), path.normalize(stopAt ?? os.homedir()));\n}\n\nexport function parseMajorVersion(ver: string): number | undefined {\n let version = ver;\n // if it has a `v` prefix, remove it\n if (version.startsWith('v')) {\n version = version.slice(1);\n }\n\n // First, try simple lookup of exact, ~ and ^ versions\n const regex = /^[\\^~]?(\\d+)(\\.\\d+)?(\\.\\d+)?(-.+)?/;\n\n const match = version.match(regex);\n if (match) {\n return parseInt(match[1] as string, 10);\n }\n\n // Try to parse e.g. 1.x\n const coerced = parseInt(version, 10);\n if (!Number.isNaN(coerced)) {\n return coerced;\n }\n\n // Match <= and >= ranges.\n const gteLteRegex = /^[<>]=\\s*(\\d+)(\\.\\d+)?(\\.\\d+)?(-.+)?/;\n const gteLteMatch = version.match(gteLteRegex);\n if (gteLteMatch) {\n return parseInt(gteLteMatch[1] as string, 10);\n }\n\n // match < ranges\n const ltRegex = /^<\\s*(\\d+)(\\.\\d+)?(\\.\\d+)?(-.+)?/;\n const ltMatch = version.match(ltRegex);\n if (ltMatch) {\n // Two scenarios:\n // a) < 2.0.0 --> return 1\n // b) < 2.1.0 --> return 2\n\n const major = parseInt(ltMatch[1] as string, 10);\n\n if (\n // minor version > 0\n (typeof ltMatch[2] === 'string' && parseInt(ltMatch[2].slice(1), 10) > 0) ||\n // patch version > 0\n (typeof ltMatch[3] === 'string' && parseInt(ltMatch[3].slice(1), 10) > 0)\n ) {\n return major;\n }\n\n return major - 1;\n }\n\n // match > ranges\n const gtRegex = /^>\\s*(\\d+)(\\.\\d+)?(\\.\\d+)?(-.+)?/;\n const gtMatch = version.match(gtRegex);\n if (gtMatch) {\n // We always return the version here, even though it _may_ be incorrect\n // E.g. if given > 2.0.0, it should be 2 if there exists any 2.x.x version, else 3\n // Since there is no way for us to know this, we're going to assume any kind of patch/feature release probably exists\n return parseInt(gtMatch[1] as string, 10);\n }\n return undefined;\n}\n\n// This is an explicit list of packages where we want to include the (major) version number.\nconst PACKAGES_TO_INCLUDE_VERSION = [\n 'react',\n '@angular/core',\n 'vue',\n 'ember-source',\n 'svelte',\n '@sveltejs/kit',\n 'webpack',\n 'vite',\n 'gatsby',\n 'next',\n 'remix',\n 'rollup',\n 'esbuild',\n];\n\nexport function getDependencies(packageJson: PackageJson): {\n deps: string[];\n depsVersions: Record<string, number>;\n} {\n const dependencies: Record<string, string> = Object.assign(\n {},\n packageJson['devDependencies'] ?? {},\n packageJson['dependencies'] ?? {},\n );\n\n const deps = Object.keys(dependencies).sort();\n\n const depsVersions: Record<string, number> = deps.reduce(\n (depsVersions, depName) => {\n if (PACKAGES_TO_INCLUDE_VERSION.includes(depName)) {\n const version = dependencies[depName] as string;\n const majorVersion = parseMajorVersion(version);\n if (majorVersion) {\n depsVersions[depName] = majorVersion;\n }\n }\n return depsVersions;\n },\n {} as Record<string, number>,\n );\n\n return { deps, depsVersions };\n}\n\nfunction findPackageJson(cwd: string, stopAt: string): string | undefined {\n let dirName = path.resolve(cwd);\n\n for (;;) {\n // Stop if we reach this dir\n if (path.normalize(dirName) === stopAt) {\n return undefined;\n }\n\n const jsonPath = path.join(dirName, 'package.json');\n if (fs.existsSync(jsonPath)) {\n return jsonPath;\n }\n\n const parentDirName = path.dirname(dirName);\n // We reached the file system root\n if (parentDirName === dirName) {\n return undefined;\n }\n\n dirName = parentDirName;\n }\n}\n\nfunction lookupPackageJson(cwd: string, stopAt: string): PackageJson | undefined {\n const jsonPath = findPackageJson(cwd, stopAt);\n\n if (!jsonPath) {\n return undefined;\n }\n\n try {\n const jsonStr = fs.readFileSync(jsonPath, 'utf8');\n const json = JSON.parse(jsonStr) as PackageJson;\n\n // Ensure it is an actual package.json\n // This is very much not bulletproof, but should be good enough\n if ('name' in json || 'private' in json) {\n return json;\n }\n } catch {\n // Ignore and walk up\n }\n\n // Continue up the tree, if we find a fitting package.json\n const newCwd = path.dirname(path.resolve(`${jsonPath}/..`));\n return lookupPackageJson(newCwd, stopAt);\n}\n\n/**\n * Deterministically hashes a string and turns the hash into a uuid.\n */\nexport function stringToUUID(str: string): string {\n const sha256Hash = crypto.createHash('sha256').update(str).digest('hex');\n\n // Position 16 is fixed to either 8, 9, a, or b in the uuid v4 spec (10xx in binary)\n // RFC 4122 section 4.4\n const v4variant = ['8', '9', 'a', 'b'][sha256Hash.substring(16, 17).charCodeAt(0) % 4] as string;\n\n return `${sha256Hash.substring(0, 8)}-${sha256Hash.substring(8, 12)}-4${sha256Hash.substring(13, 16)}-${v4variant}${sha256Hash.substring(17, 20)}-${sha256Hash.substring(20, 32)}`.toLowerCase();\n}\n\nexport function gitRevision(): string | undefined {\n let gitRevision: string | undefined;\n try {\n gitRevision = childProcess\n .execSync('git rev-parse HEAD', { stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true })\n .toString()\n .trim();\n } catch {\n // noop\n }\n return gitRevision;\n}\n\n// Mirrors the CLI's `set-commits` fallback for builds without an `origin` remote. Vercel is left out\n// because the CLI only reads `VERCEL_GIT_*` on production builds.\nconst CI_REPOSITORY_ENV_VARS = [\n 'GITHUB_REPOSITORY',\n 'CI_PROJECT_PATH',\n 'BITBUCKET_REPO_FULL_NAME',\n 'RENDER_GIT_REPO_SLUG',\n 'RAILWAY_GIT_REPO_NAME',\n 'CIRCLE_PROJECT_REPONAME',\n 'BUILDKITE_REPO',\n 'BUILD_REPOSITORY_URI',\n] as const;\n\n/**\n * Whether commit association can find the repository: from the given git remote, or from CI variables.\n */\nexport function canAutoDetectRepository(remote = 'origin'): boolean {\n if (\n CI_REPOSITORY_ENV_VARS.some(name => process.env[name]) ||\n (process.env['NETLIFY'] && process.env['REPOSITORY_URL'])\n ) {\n return true;\n }\n try {\n childProcess.execFileSync('git', ['remote', 'get-url', remote], { stdio: 'ignore', windowsHide: true });\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Reads the `owner/repo` path of a git remote, e.g. `getsentry/sentry-javascript` for\n * `git@github.com:getsentry/sentry-javascript.git`.\n */\nexport function getGitRemoteRepository(remote: string): string | undefined {\n let url: string;\n try {\n url = childProcess\n .execFileSync('git', ['remote', 'get-url', remote], { stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true })\n .toString()\n .trim();\n } catch {\n return undefined;\n }\n\n let repoPath: string;\n try {\n repoPath = new URL(url).pathname;\n } catch {\n // scp-like syntax, `git@host:owner/repo.git`\n repoPath = url.slice(url.indexOf(':') + 1);\n }\n const repository = repoPath.replace(/^\\/+|\\/+$/g, '').replace(/\\.git$/, '');\n return repository.includes('/') ? repository : undefined;\n}\n\n/**\n * Tries to guess a release name based on environmental data.\n */\nexport function determineReleaseName(): string | undefined {\n return getReleaseFromCommitEnv(warnAboutPlaceholderCommitEnvVar) || gitRevision();\n}\n\n/**\n * Resolves the release name the way the bundler plugins do: the configured name, then the `SENTRY_RELEASE`\n * environment variable, then a name detected from CI environment variables or git.\n *\n * Framework SDKs that pass the release to the SDK at runtime use this to get the same name the plugin uses.\n */\nexport function resolveReleaseName(name?: string): string | undefined {\n return name ?? process.env['SENTRY_RELEASE'] ?? determineReleaseName();\n}\n\n// Release detection and commit association can read the same variable in one build.\nconst warnedPlaceholderEnvVars = new Set<string>();\n\nfunction warnAboutPlaceholderCommitEnvVar(name: string): void {\n if (warnedPlaceholderEnvVars.has(name)) {\n return;\n }\n warnedPlaceholderEnvVars.add(name);\n // This runs before the plugin logger exists, so `silent: true` does not suppress it. That is\n // deliberate: a warning that is easy to miss is how this misconfiguration went unnoticed.\n // eslint-disable-next-line no-console\n console.warn(\n `[@sentry/bundler-plugins] Ignoring the ${name} environment variable as a release name, because its value is its own name. Set the release explicitly, or fix the variable in your build environment.`,\n );\n}\n\n/**\n * Reads an environment variable that should hold a commit SHA, ignoring a value that is the\n * variable's own name. See `_INTERNAL_readCommitEnvVar` in `@sentry/core/server`.\n */\nexport function readCommitEnvVar(name: string): string | undefined {\n return readCoreCommitEnvVar(name, warnAboutPlaceholderCommitEnvVar);\n}\n\n/**\n * Generates code for the global injector which is responsible for setting the global\n * `SENTRY_RELEASE` & `SENTRY_BUILD_INFO` variables.\n */\nexport function generateReleaseInjectorCode({\n release,\n injectBuildInformation,\n}: {\n release: string;\n injectBuildInformation: boolean;\n}): CodeInjection {\n let code = `e.SENTRY_RELEASE={id:${stringifyForCodeInjection(release)}};`;\n\n if (injectBuildInformation) {\n const buildInfo = getBuildInformation();\n\n code += `e.SENTRY_BUILD_INFO=${stringifyForCodeInjection(buildInfo)};`;\n }\n\n return new CodeInjection(code);\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function generateModuleMetadataInjectorCode(metadata: any): CodeInjection {\n // We are merging the metadata objects in case modules are bundled twice with the plugin\n // Use try-catch to avoid issues when bundlers rename global variables like 'window' to 'k'\n return new CodeInjection(\n `e._sentryModuleMetadata=e._sentryModuleMetadata||{},e._sentryModuleMetadata[(new e.Error).stack]=function(e){for(var n=1;n<arguments.length;n++){var a=arguments[n];if(null!=a)for(var t in a)a.hasOwnProperty(t)&&(e[t]=a[t])}return e}({},e._sentryModuleMetadata[(new e.Error).stack],${stringifyForCodeInjection(\n metadata,\n )});`,\n );\n}\n\nexport function getBuildInformation(): {\n deps: string[];\n depsVersions: Record<string, number>;\n nodeVersion: number | undefined;\n} {\n const packageJson = getPackageJson();\n\n const { deps, depsVersions } = packageJson ? getDependencies(packageJson) : { deps: [], depsVersions: {} };\n\n return {\n deps,\n depsVersions,\n nodeVersion: parseMajorVersion(process.version),\n };\n}\n\nexport function stripQueryAndHashFromPath(path: string): string {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return path.split('?')[0]!.split('#')[0]!;\n}\n\nexport function replaceBooleanFlagsInCode(\n code: string,\n replacementValues: Record<string, boolean | undefined>,\n): { code: string; map: SourceMap } | null {\n const ms = new MagicString(code);\n\n Object.keys(replacementValues).forEach(key => {\n const value = replacementValues[key];\n\n if (typeof value === 'boolean') {\n ms.replaceAll(key, JSON.stringify(value));\n }\n });\n\n if (ms.hasChanged()) {\n return {\n code: ms.toString(),\n map: ms.generateMap({ hires: 'boundary' }),\n };\n }\n\n return null;\n}\n\n// https://turbo.build/repo/docs/reference/system-environment-variables#environment-variables-in-tasks\nexport function getTurborepoEnvPassthroughWarning(envVarName: string): string {\n return process.env['TURBO_HASH']\n ? `\\nYou seem to be using Turborepo, did you forget to put ${envVarName} in \\`passThroughEnv\\`? https://turbo.build/repo/docs/reference/configuration#passthroughenv`\n : '';\n}\n\n/**\n * Gets the projects from the project option. This might be a single project or an array of projects.\n */\nexport function getProjects(project: string | string[] | undefined): string[] | undefined {\n if (Array.isArray(project)) {\n return project;\n }\n\n if (project) {\n return [project];\n }\n\n return undefined;\n}\n\n/**\n * Checks if a chunk contains only import/export statements and no substantial code.\n *\n * In Vite MPA (multi-page application) mode, HTML entry points create \"facade\" chunks\n * that only contain import statements to load shared modules. These should not have\n * Sentry code injected. However, in SPA mode, the main bundle also has an HTML facade\n * but contains substantial application code that SHOULD have debug IDs injected.\n *\n * @ref https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/829\n * @ref https://github.com/getsentry/sentry-javascript-bundler-plugins/issues/839\n */\nexport function containsOnlyImports(code: string): boolean {\n const codeWithoutImports = code\n // Remove side effect imports: import '/path'; or import \"./path\";\n // Using explicit negated character classes to avoid polynomial backtracking\n .replace(/^\\s*import\\s+(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`\\n]*`)[\\s;]*$/gm, '')\n // Remove named/default imports: import x from '/path'; import { x } from '/path';\n .replace(/^\\s*import\\b[^'\"`\\n]*\\bfrom\\s+(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`\\n]*`)[\\s;]*$/gm, '')\n // Remove re-exports: export * from '/path'; export { x } from '/path';\n .replace(/^\\s*export\\b[^'\"`\\n]*\\bfrom\\s+(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`\\n]*`)[\\s;]*$/gm, '')\n // Remove block comments\n .replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n // Remove line comments\n .replace(/\\/\\/.*$/gm, '')\n // Remove \"use strict\" directives\n .replace(/[\"']use strict[\"']\\s*;?/g, '')\n .trim();\n\n return codeWithoutImports.length === 0;\n}\n\nexport class CodeInjection {\n // The code below is mostly ternary operators because it saves bundle size.\n // The checks are to support as many environments as possible. (Node.js, Browser, webworkers, etc.)\n private readonly header: string;\n private readonly footer: string;\n\n constructor(private body: string = '') {\n // `globalThis` is checked first so the other identifiers are never evaluated\n // where it exists. A downstream bundler that runs over an already-injected\n // chunk can turn a free `global` into a `const` it declares further down the\n // file (Nitro's node compat does this). Reading that binding from the top of\n // the file hits the temporal dead zone, and `typeof` throws there instead of\n // returning \"undefined\", so the whole injection was silently swallowed by the\n // `catch` below and the chunk registered no debug ID.\n this.header = `!function(){try{var e=\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof self?self:{};`;\n this.footer = '}catch(e){}}();';\n }\n\n public code(): string {\n if (this.isEmpty()) {\n return '';\n }\n\n return this.header + this.body + this.footer;\n }\n\n public isEmpty(): boolean {\n return this.body.length === 0;\n }\n\n public append(code: CodeInjection | string): void {\n if (code instanceof CodeInjection) {\n this.body += code.body;\n } else {\n this.body += code;\n }\n }\n\n public clear(): void {\n this.body = '';\n }\n\n public clone(): CodeInjection {\n return new CodeInjection(this.body);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,SAAsB,YAA0B;CAC9D,OAAO,MAAM,QAAQ,UAAU,IAAI,aAAa,CAAC,UAAU;AAC7D;;;;;;;AAUA,SAAgB,eAAe,EAAE,KAAK,WAA8C,CAAC,GAA4B;CAC/G,OAAO,kBAAkB,OAAO,QAAQ,IAAI,GAAGA,KAAAA,QAAK,UAAU,UAAUC,GAAAA,QAAG,QAAQ,CAAC,CAAC;AACvF;AAEA,SAAgB,kBAAkB,KAAiC;CACjE,IAAI,UAAU;CAEd,IAAI,QAAQ,WAAW,GAAG,GACxB,UAAU,QAAQ,MAAM,CAAC;CAM3B,MAAM,QAAQ,QAAQ,MAAM,oCAAK;CACjC,IAAI,OACF,OAAO,SAAS,MAAM,IAAc,EAAE;CAIxC,MAAM,UAAU,SAAS,SAAS,EAAE;CACpC,IAAI,CAAC,OAAO,MAAM,OAAO,GACvB,OAAO;CAKT,MAAM,cAAc,QAAQ,MAAM,sCAAW;CAC7C,IAAI,aACF,OAAO,SAAS,YAAY,IAAc,EAAE;CAK9C,MAAM,UAAU,QAAQ,MAAM,kCAAO;CACrC,IAAI,SAAS;EAKX,MAAM,QAAQ,SAAS,QAAQ,IAAc,EAAE;E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,EAAE,CAAC,CAEvF,QAAQ,4EAA4E,EAAE,CAAC,CAEvF,QAAQ,qBAAqB,EAAE,CAAC,CAEhC,QAAQ,aAAa,EAAE,CAAC,CAExB,QAAQ,4BAA4B,EAAE,CAAC,CACvC,KAEqB,CAAC,CAAC,WAAW;AACvC;AAEA,IAAa,gBAAb,MAAa,cAAc;CAMzB,YAAoB,OAAe,IAAI;EAAnB,KAAA,OAAA;EAQlB,KAAK,SAAS;EACd,KAAK,SAAS;CAChB;CAEO,OAAe;EACpB,IAAI,KAAK,QAAQ,GACf,OAAO;EAGT,OAAO,KAAK,SAAS,KAAK,OAAO,KAAK;CACxC;CAEO,UAAmB;EACxB,OAAO,KAAK,KAAK,WAAW;CAC9B;CAEO,OAAO,MAAoC;EAChD,IAAI,gBAAgB,eAClB,KAAK,QAAQ,KAAK;OAElB,KAAK,QAAQ;CAEjB;CAEO,QAAc;EACnB,KAAK,OAAO;CACd;CAEO,QAAuB;EAC5B,OAAO,IAAI,cAAc,KAAK,IAAI;CACpC;AACF"}
@@ -1,5 +1,5 @@
1
1
  // src/core/version.ts
2
- const LIB_VERSION = "11.16.0";
2
+ const LIB_VERSION = "11.18.0";
3
3
  exports.LIB_VERSION = LIB_VERSION;
4
4
 
5
5
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","names":[],"sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.16.0\";\n"],"mappings":";AAAA,MAAa,cAAc"}
1
+ {"version":3,"file":"version.js","names":[],"sources":["../../../src/core/version.ts"],"sourcesContent":["export const LIB_VERSION = \"11.18.0\";\n"],"mappings":";AAAA,MAAa,cAAc"}
@@ -7,13 +7,13 @@ import { defaultRewriteSourcesHook, prepareArtifactForUpload, prepareBundleForDe
7
7
  import { globFiles } from "./glob.js";
8
8
  import { decideSourceMapHandling, getSourceMapFeatures } from "./sourcemap-settings.js";
9
9
  import { createUploadFilter } from "./upload-filter.js";
10
+ import { getMissingUploadCredential, readSentryBuildPluginEnvFile } from "./upload-credentials.js";
10
11
  import { LIB_VERSION } from "./version.js";
11
12
  import * as path from "path";
12
13
  import * as fs from "fs";
13
14
  import * as os from "os";
14
15
  import { DEFAULT_ENVIRONMENT, closeSession, makeSession, setMeasurement, startSpan } from "@sentry/core";
15
16
  import { escape } from "glob";
16
- import * as dotenv from "dotenv";
17
17
  // src/core/build-plugin-manager.ts
18
18
  const _deployedReleases = /* @__PURE__ */ new Set();
19
19
  /**
@@ -27,13 +27,10 @@ function createSentryBuildPluginManager(userOptions, bundlerPluginMetaContext) {
27
27
  silent: userOptions.silent ?? false,
28
28
  debug: userOptions.debug ?? false
29
29
  });
30
- try {
31
- const dotenvFile = fs.readFileSync(path.join(process.cwd(), ".env.sentry-build-plugin"), "utf-8");
32
- const dotenvResult = dotenv.parse(dotenvFile);
30
+ const dotenvResult = readSentryBuildPluginEnvFile();
31
+ if (dotenvResult) {
33
32
  Object.assign(process.env, dotenvResult);
34
33
  logger.info("Using environment variables configured in \".env.sentry-build-plugin\".");
35
- } catch (e) {
36
- if (typeof e === "object" && e && "code" in e && e.code !== "ENOENT") throw e;
37
34
  }
38
35
  const options = normalizeUserOptions(userOptions);
39
36
  if (options.disable) return {
@@ -276,7 +273,7 @@ async emitBundlerPluginExecutionSignal() {
276
273
  if (options.release.setCommits !== false) try {
277
274
  await cliInstance.setCommits(releaseName, options.release.setCommits);
278
275
  } catch (e) {
279
- if (options.release.setCommits && "shouldNotThrowOnFailure" in options.release.setCommits && options.release.setCommits.shouldNotThrowOnFailure) logger.debug("An error occurred setting commits on release (this message can be ignored unless you commits on release are desired):", e);
276
+ if (options.release.setCommits && "shouldNotThrowOnFailure" in options.release.setCommits && options.release.setCommits.shouldNotThrowOnFailure) logger.debug("An error occurred setting commits on release (this message can be ignored unless you want commits set on the release):", e);
280
277
  else throw e;
281
278
  }
282
279
  if (options.release.finalize) await cliInstance.finalizeRelease(releaseName);
@@ -598,9 +595,7 @@ function getSourceMapUploadBlocker(options, isDevMode) {
598
595
  if (!getSourceMapFeatures(options).upload) return "disabled";
599
596
  if (Array.isArray(options.sourcemaps?.assets) && options.sourcemaps.assets.length === 0) return "no-assets";
600
597
  if (isDevMode) return "dev-mode";
601
- if (!options.authToken) return "no-auth-token";
602
- if (!options.org && !options.authToken.startsWith("sntrys_")) return "no-org";
603
- if (!getProjects(options.project)?.[0]) return "no-project";
598
+ return getMissingUploadCredential(options);
604
599
  }
605
600
  function canUploadSourceMaps(options, logger, isDevMode) {
606
601
  switch (getSourceMapUploadBlocker(options, isDevMode)) {