Skip to content

Commit 1819ad1

Browse files
committed
fix: warn about missing SENTRY_ORG and SENTRY_PROJECT vars on Turborepo
1 parent c4462a3 commit 1819ad1

File tree

1 file changed

+10
-7
lines changed
  • packages/bundler-plugin-core/src

1 file changed

+10
-7
lines changed

packages/bundler-plugin-core/src/index.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,10 @@ export function sentryUnpluginFactory({
321321
}
322322
// https://turbo.build/repo/docs/reference/system-environment-variables#environment-variables-in-tasks
323323
const isRunningInTurboRepo = Boolean(process.env["TURBO_HASH"]);
324-
const TUROBOREPO_PASSTHROUGH_TOKEN_MSG = isRunningInTurboRepo
325-
? "\nYou seem to be using Truborepo, did you forget to put `SENTRY_AUTH_TOKEN` in `passThroughEnv`? https://turbo.build/repo/docs/reference/configuration#passthroughenv"
326-
: "";
324+
const getTruboRepoEnvPassthroughWarning = (envVarName: string) =>
325+
isRunningInTurboRepo
326+
? `\nYou seem to be using Truborepo, did you forget to put ${envVarName} in \`passThroughEnv\`? https://turbo.build/repo/docs/reference/configuration#passthroughenv`
327+
: "";
327328
if (!options.release.name) {
328329
logger.debug(
329330
"No release name provided. Will not create release. Please set the `release.name` option to identify your release."
@@ -333,15 +334,17 @@ export function sentryUnpluginFactory({
333334
} else if (!options.authToken) {
334335
logger.warn(
335336
"No auth token provided. Will not create release. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/" +
336-
TUROBOREPO_PASSTHROUGH_TOKEN_MSG
337+
getTruboRepoEnvPassthroughWarning("SENTRY_AUTH_TOKEN")
337338
);
338339
} else if (!options.org && !options.authToken.startsWith("sntrys_")) {
339340
logger.warn(
340-
"No organization slug provided. Will not create release. Please set the `org` option to your Sentry organization slug."
341+
"No organization slug provided. Will not create release. Please set the `org` option to your Sentry organization slug." +
342+
getTruboRepoEnvPassthroughWarning("SENTRY_ORG")
341343
);
342344
} else if (!options.project) {
343345
logger.warn(
344-
"No project provided. Will not create release. Please set the `project` option to your Sentry project slug."
346+
"No project provided. Will not create release. Please set the `project` option to your Sentry project slug." +
347+
getTruboRepoEnvPassthroughWarning("SENTRY_PROJECT")
345348
);
346349
} else {
347350
plugins.push(
@@ -384,7 +387,7 @@ export function sentryUnpluginFactory({
384387
} else if (!options.authToken) {
385388
logger.warn(
386389
"No auth token provided. Will not upload source maps. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/" +
387-
TUROBOREPO_PASSTHROUGH_TOKEN_MSG
390+
getTruboRepoEnvPassthroughWarning
388391
);
389392
} else if (!options.org && !options.authToken.startsWith("sntrys_")) {
390393
logger.warn(

0 commit comments

Comments
 (0)