@sentry/wizard 6.1.0 → 6.1.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.1.1
4
+
5
+ - fix(apple): Added methods to add and update Sentry build phase script ([#1029](https://github.com/getsentry/sentry-wizard/pull/1029))
6
+ - ref(angular,nextjs): Install SDK package with version `@^9` ([#1047](https://github.com/getsentry/sentry-wizard/pull/1047))
7
+
3
8
  ## 6.1.0
4
9
 
5
10
  - feat(nextjs): Add option to enable logs to be sent to Sentry ([#1031](https://github.com/getsentry/sentry-wizard/pull/1031))
@@ -110,7 +110,7 @@ Apologies for the inconvenience!`);
110
110
  const sdkAlreadyInstalled = (0, package_json_1.hasPackageInstalled)('@sentry/angular', packageJson);
111
111
  Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);
112
112
  await (0, clack_1.installPackage)({
113
- packageName: '@sentry/angular',
113
+ packageName: '@sentry/angular@^9',
114
114
  packageNameDisplayLabel: '@sentry/angular',
115
115
  alreadyInstalled: sdkAlreadyInstalled,
116
116
  });
@@ -1 +1 @@
1
- {"version":3,"file":"angular-wizard.js","sourceRoot":"","sources":["../../../src/angular/angular-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AAEnC,kDAA0B;AAE1B,4CAAwD;AACxD,0CAYwB;AACxB,wDAA+E;AAC/E,mCAAiD;AAEjD,qDAAuC;AACvC,2CAAiE;AACjE,2CAA8C;AAC9C,uEAAsE;AACtE,sDAAuE;AACvE,2DAA6D;AAE7D,MAAM,6BAA6B,GAAG,QAAQ,CAAC;AAC/C,MAAM,oCAAoC,GAAG,QAAQ,CAAC;AAE/C,KAAK,UAAU,gBAAgB,CAAC,OAAsB;IAC3D,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,C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CAAC;AAED,SAAgB,iBAAiB,CAAC,uBAAgC;IAChE,IAAI,GAAG,GAAG,eAAK,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;IAE1E,IAAI,uBAAuB,EAAE;QAC3B,GAAG,IAAI,qEAAqE,eAAK,CAAC,IAAI,CACpF,UAAU,CACX,mDAAmD,CAAC;KACtD;IAED,GAAG,IAAI;4DACmD,CAAC;IAE3D,OAAO,GAAG,CAAC;AACb,CAAC;AAbD,8CAaC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\n\nimport chalk from 'chalk';\nimport type { WizardOptions } from '../utils/types';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport {\n abortIfCancelled,\n askShouldCreateExampleComponent,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n featureSelectionPrompt,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n printWelcome,\n runPrettierIfInstalled,\n abort,\n} from '../utils/clack';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { gte, minVersion, SemVer } from 'semver';\n\nimport * as Sentry from '@sentry/node';\nimport { initializeSentryOnApplicationEntry } from './sdk-setup';\nimport { updateAppConfig } from './sdk-setup';\nimport { runSourcemapsWizard } from '../sourcemaps/sourcemaps-wizard';\nimport { addSourcemapEntryToAngularJSON } from './codemods/sourcemaps';\nimport { createExampleComponent } from './example-component';\n\nconst MIN_SUPPORTED_ANGULAR_VERSION = '14.0.0';\nconst MIN_SUPPORTED_WIZARD_ANGULAR_VERSION = '17.0.0';\n\nexport async function runAngularWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'angular',\n wizardOptions: options,\n },\n () => runAngularWizardWithTelemetry(options),\n );\n}\n\nasync function runAngularWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Angular Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const packageJson = await getPackageDotJson();\n\n await ensurePackageIsInstalled(packageJson, '@angular/core', 'Angular');\n\n let installedAngularVersion = getPackageVersion('@angular/core', packageJson);\n\n if (!installedAngularVersion) {\n clack.log.warn('Could not determine installed Angular version.');\n\n installedAngularVersion = await abortIfCancelled(\n clack.text({\n message: `Please enter your installed Angular major version (e.g. ${chalk.cyan(\n '18',\n )} for Angular 18)`,\n validate(value) {\n if (!value) {\n return 'Angular version is required';\n }\n\n try {\n if (!minVersion(value)) {\n return `Invalid Angular version provided: ${value}`;\n }\n } catch (error) {\n return `Invalid Angular version provided: ${value}`;\n }\n },\n }),\n );\n }\n\n Sentry.setTag('angular-version', installedAngularVersion);\n\n const installedMinVersion = minVersion(installedAngularVersion) as SemVer;\n\n const sdkSupportsAngularVersion = gte(\n installedMinVersion,\n MIN_SUPPORTED_ANGULAR_VERSION,\n );\n\n const wizardSupportsAngularVersion = gte(\n installedMinVersion,\n MIN_SUPPORTED_WIZARD_ANGULAR_VERSION,\n );\n\n if (!sdkSupportsAngularVersion) {\n Sentry.setTag('angular-version-compatible', false);\n\n clack.log.warn(\n `Angular version ${chalk.cyan(\n MIN_SUPPORTED_ANGULAR_VERSION,\n )} or higher is required for the Sentry SDK.`,\n );\n clack.log.warn(\n `Please refer to Sentry's version compatibility table for more information:\n\n${chalk.underline(\n 'https://docs.sentry.io/platforms/javascript/guides/angular/#angular-version-compatibility',\n)}\n`,\n );\n\n return abort('Exiting the wizard.', 0);\n }\n\n if (!wizardSupportsAngularVersion) {\n Sentry.setTag('angular-wizard-version-compatible', false);\n\n clack.log.warn(\n `The Sentry Angular Wizard requires Angular version ${chalk.cyan(\n MIN_SUPPORTED_WIZARD_ANGULAR_VERSION,\n )} or higher.`,\n );\n clack.log.warn(\n `Your Angular version (${installedAngularVersion}) is compatible with the Sentry SDK but you need to set it up manually by following our documentation:\n\n${chalk.underline('https://docs.sentry.io/platforms/javascript/guides/angular')}\n\nApologies for the inconvenience!`,\n );\n\n return abort('Exiting the wizard.', 0);\n }\n\n const { selectedProject, authToken, sentryUrl, selfHosted } =\n await getOrAskForProjectData(options, 'javascript-angular');\n\n const dsn = selectedProject.keys[0].dsn.public;\n\n const sdkAlreadyInstalled = hasPackageInstalled(\n '@sentry/angular',\n packageJson,\n );\n\n Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);\n\n await installPackage({\n packageName: '@sentry/angular',\n packageNameDisplayLabel: '@sentry/angular',\n alreadyInstalled: sdkAlreadyInstalled,\n });\n\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Sentry Session Replay',\n )} to get a video-like reproduction of errors during a user session?`,\n enabledHint: 'recommended, but increases bundle size',\n },\n {\n id: 'logs',\n prompt: `Do you want to enable ${chalk.bold(\n 'Logs',\n )} to send your application logs to Sentry?`,\n enabledHint: 'recommended',\n },\n ] as const);\n\n await traceStep(\n 'Initialize Sentry on Angular application entry point',\n async () => {\n await initializeSentryOnApplicationEntry(dsn, selectedFeatures);\n },\n );\n\n await traceStep('Update Angular project configuration', async () => {\n await updateAppConfig(installedMinVersion, selectedFeatures.performance);\n });\n\n await traceStep('Setup for sourcemap uploads', async () => {\n await addSourcemapEntryToAngularJSON();\n\n if (!options.preSelectedProject) {\n options.preSelectedProject = {\n authToken,\n selfHosted,\n project: {\n organization: {\n id: selectedProject.organization.id,\n name: selectedProject.organization.name,\n slug: selectedProject.organization.slug,\n },\n id: selectedProject.id,\n slug: selectedProject.slug,\n keys: [\n {\n dsn: {\n public: dsn,\n },\n },\n ],\n },\n };\n\n options.url = sentryUrl;\n }\n\n await runSourcemapsWizard(options, 'angular');\n });\n\n const shouldCreateExampleComponent = await askShouldCreateExampleComponent();\n\n Sentry.setTag('create-example-component', shouldCreateExampleComponent);\n\n if (shouldCreateExampleComponent) {\n await traceStep(\n 'create-example-component',\n async () =>\n await createExampleComponent({\n url: sentryUrl,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n }),\n );\n }\n\n await traceStep('Run Prettier', async () => {\n await runPrettierIfInstalled({ cwd: undefined });\n });\n\n clack.outro(buildOutroMessage(shouldCreateExampleComponent));\n}\n\nexport function buildOutroMessage(createdExampleComponent: boolean): string {\n let msg = chalk.green('\\nSuccessfully installed the Sentry Angular SDK!');\n\n if (createdExampleComponent) {\n msg += `\\n\\nYou can validate your setup by starting your dev environment (${chalk.cyan(\n 'ng serve',\n )}) and throwing an error in the example component.`;\n }\n\n msg += `\\n\\nCheck out the SDK documentation for further configuration:\nhttps://docs.sentry.io/platforms/javascript/guides/angular/`;\n\n return msg;\n}\n"]}
1
+ {"version":3,"file":"angular-wizard.js","sourceRoot":"","sources":["../../../src/angular/angular-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AAEnC,kDAA0B;AAE1B,4CAAwD;AACxD,0CAYwB;AACxB,wDAA+E;AAC/E,mCAAiD;AAEjD,qDAAuC;AACvC,2CAAiE;AACjE,2CAA8C;AAC9C,uEAAsE;AACtE,sDAAuE;AACvE,2DAA6D;AAE7D,MAAM,6BAA6B,GAAG,QAAQ,CAAC;AAC/C,MAAM,oCAAoC,GAAG,QAAQ,CAAC;AAE/C,KAAK,UAAU,gBAAgB,CAAC,OAAsB;IAC3D,OAAO,IAAA,yBAAa,EAClB;QACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;QACjC,WAAW,EAAE,SAAS;QACtB,aAAa,EAAE,OAAO;KACvB,EACD,GAAG,EAAE,CAAC,6BAA6B,CAAC,OAAO,CAAC,CAC7C,CAAC;AACJ,CAAC;AATD,4CASC;AAED,KAAK,UAAU,6B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AC,IAAI,CACpF,UAAU,CACX,mDAAmD,CAAC;KACtD;IAED,GAAG,IAAI;4DACmD,CAAC;IAE3D,OAAO,GAAG,CAAC;AACb,CAAC;AAbD,8CAaC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\n\nimport chalk from 'chalk';\nimport type { WizardOptions } from '../utils/types';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport {\n abortIfCancelled,\n askShouldCreateExampleComponent,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n featureSelectionPrompt,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n printWelcome,\n runPrettierIfInstalled,\n abort,\n} from '../utils/clack';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { gte, minVersion, SemVer } from 'semver';\n\nimport * as Sentry from '@sentry/node';\nimport { initializeSentryOnApplicationEntry } from './sdk-setup';\nimport { updateAppConfig } from './sdk-setup';\nimport { runSourcemapsWizard } from '../sourcemaps/sourcemaps-wizard';\nimport { addSourcemapEntryToAngularJSON } from './codemods/sourcemaps';\nimport { createExampleComponent } from './example-component';\n\nconst MIN_SUPPORTED_ANGULAR_VERSION = '14.0.0';\nconst MIN_SUPPORTED_WIZARD_ANGULAR_VERSION = '17.0.0';\n\nexport async function runAngularWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'angular',\n wizardOptions: options,\n },\n () => runAngularWizardWithTelemetry(options),\n );\n}\n\nasync function runAngularWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Angular Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const packageJson = await getPackageDotJson();\n\n await ensurePackageIsInstalled(packageJson, '@angular/core', 'Angular');\n\n let installedAngularVersion = getPackageVersion('@angular/core', packageJson);\n\n if (!installedAngularVersion) {\n clack.log.warn('Could not determine installed Angular version.');\n\n installedAngularVersion = await abortIfCancelled(\n clack.text({\n message: `Please enter your installed Angular major version (e.g. ${chalk.cyan(\n '18',\n )} for Angular 18)`,\n validate(value) {\n if (!value) {\n return 'Angular version is required';\n }\n\n try {\n if (!minVersion(value)) {\n return `Invalid Angular version provided: ${value}`;\n }\n } catch (error) {\n return `Invalid Angular version provided: ${value}`;\n }\n },\n }),\n );\n }\n\n Sentry.setTag('angular-version', installedAngularVersion);\n\n const installedMinVersion = minVersion(installedAngularVersion) as SemVer;\n\n const sdkSupportsAngularVersion = gte(\n installedMinVersion,\n MIN_SUPPORTED_ANGULAR_VERSION,\n );\n\n const wizardSupportsAngularVersion = gte(\n installedMinVersion,\n MIN_SUPPORTED_WIZARD_ANGULAR_VERSION,\n );\n\n if (!sdkSupportsAngularVersion) {\n Sentry.setTag('angular-version-compatible', false);\n\n clack.log.warn(\n `Angular version ${chalk.cyan(\n MIN_SUPPORTED_ANGULAR_VERSION,\n )} or higher is required for the Sentry SDK.`,\n );\n clack.log.warn(\n `Please refer to Sentry's version compatibility table for more information:\n\n${chalk.underline(\n 'https://docs.sentry.io/platforms/javascript/guides/angular/#angular-version-compatibility',\n)}\n`,\n );\n\n return abort('Exiting the wizard.', 0);\n }\n\n if (!wizardSupportsAngularVersion) {\n Sentry.setTag('angular-wizard-version-compatible', false);\n\n clack.log.warn(\n `The Sentry Angular Wizard requires Angular version ${chalk.cyan(\n MIN_SUPPORTED_WIZARD_ANGULAR_VERSION,\n )} or higher.`,\n );\n clack.log.warn(\n `Your Angular version (${installedAngularVersion}) is compatible with the Sentry SDK but you need to set it up manually by following our documentation:\n\n${chalk.underline('https://docs.sentry.io/platforms/javascript/guides/angular')}\n\nApologies for the inconvenience!`,\n );\n\n return abort('Exiting the wizard.', 0);\n }\n\n const { selectedProject, authToken, sentryUrl, selfHosted } =\n await getOrAskForProjectData(options, 'javascript-angular');\n\n const dsn = selectedProject.keys[0].dsn.public;\n\n const sdkAlreadyInstalled = hasPackageInstalled(\n '@sentry/angular',\n packageJson,\n );\n\n Sentry.setTag('sdk-already-installed', sdkAlreadyInstalled);\n\n await installPackage({\n packageName: '@sentry/angular@^9',\n packageNameDisplayLabel: '@sentry/angular',\n alreadyInstalled: sdkAlreadyInstalled,\n });\n\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Sentry Session Replay',\n )} to get a video-like reproduction of errors during a user session?`,\n enabledHint: 'recommended, but increases bundle size',\n },\n {\n id: 'logs',\n prompt: `Do you want to enable ${chalk.bold(\n 'Logs',\n )} to send your application logs to Sentry?`,\n enabledHint: 'recommended',\n },\n ] as const);\n\n await traceStep(\n 'Initialize Sentry on Angular application entry point',\n async () => {\n await initializeSentryOnApplicationEntry(dsn, selectedFeatures);\n },\n );\n\n await traceStep('Update Angular project configuration', async () => {\n await updateAppConfig(installedMinVersion, selectedFeatures.performance);\n });\n\n await traceStep('Setup for sourcemap uploads', async () => {\n await addSourcemapEntryToAngularJSON();\n\n if (!options.preSelectedProject) {\n options.preSelectedProject = {\n authToken,\n selfHosted,\n project: {\n organization: {\n id: selectedProject.organization.id,\n name: selectedProject.organization.name,\n slug: selectedProject.organization.slug,\n },\n id: selectedProject.id,\n slug: selectedProject.slug,\n keys: [\n {\n dsn: {\n public: dsn,\n },\n },\n ],\n },\n };\n\n options.url = sentryUrl;\n }\n\n await runSourcemapsWizard(options, 'angular');\n });\n\n const shouldCreateExampleComponent = await askShouldCreateExampleComponent();\n\n Sentry.setTag('create-example-component', shouldCreateExampleComponent);\n\n if (shouldCreateExampleComponent) {\n await traceStep(\n 'create-example-component',\n async () =>\n await createExampleComponent({\n url: sentryUrl,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n }),\n );\n }\n\n await traceStep('Run Prettier', async () => {\n await runPrettierIfInstalled({ cwd: undefined });\n });\n\n clack.outro(buildOutroMessage(shouldCreateExampleComponent));\n}\n\nexport function buildOutroMessage(createdExampleComponent: boolean): string {\n let msg = chalk.green('\\nSuccessfully installed the Sentry Angular SDK!');\n\n if (createdExampleComponent) {\n msg += `\\n\\nYou can validate your setup by starting your dev environment (${chalk.cyan(\n 'ng serve',\n )}) and throwing an error in the example component.`;\n }\n\n msg += `\\n\\nCheck out the SDK documentation for further configuration:\nhttps://docs.sentry.io/platforms/javascript/guides/angular/`;\n\n return msg;\n}\n"]}
@@ -4,9 +4,24 @@ exports.getFastlaneSnippet = exports.getObjcSnippet = exports.getSwiftSnippet =
4
4
  function getRunScriptTemplate(orgSlug, projectSlug, uploadSource, includeHomebrewPath) {
5
5
  // eslint-disable-next-line no-useless-escape
6
6
  const includeHomebrew = includeHomebrewPath
7
- ? '\\nif [[ "$(uname -m)" == arm64 ]]; then\\nexport PATH="/opt/homebrew/bin:$PATH"\\nfi'
7
+ ? `
8
+ if [[ "$(uname -m)" == arm64 ]]; then
9
+ export PATH="/opt/homebrew/bin:$PATH"
10
+ fi
11
+ `
8
12
  : '';
9
- return `# This script is responsible for uploading debug symbols and source context for Sentry.${includeHomebrew}\\nif which sentry-cli >/dev/null; then\\nexport SENTRY_ORG=${orgSlug}\\nexport SENTRY_PROJECT=${projectSlug}\\nERROR=$(sentry-cli debug-files upload ${uploadSource ? '--include-sources ' : ''}"$DWARF_DSYM_FOLDER_PATH" 2>&1 >/dev/null)\\nif [ ! $? -eq 0 ]; then\\necho "warning: sentry-cli - $ERROR"\\nfi\\nelse\\necho "warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases"\\nfi\\n`;
13
+ return `# This script is responsible for uploading debug symbols and source context for Sentry.${includeHomebrew}
14
+ if which sentry-cli >/dev/null; then
15
+ export SENTRY_ORG=${orgSlug}
16
+ export SENTRY_PROJECT=${projectSlug}
17
+ ERROR=$(sentry-cli debug-files upload ${uploadSource ? '--include-sources ' : ''}"$DWARF_DSYM_FOLDER_PATH" 2>&1 >/dev/null)
18
+ if [ ! $? -eq 0 ]; then
19
+ echo "warning: sentry-cli - $ERROR"
20
+ fi
21
+ else
22
+ echo "warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases"
23
+ fi
24
+ `;
10
25
  }
11
26
  exports.getRunScriptTemplate = getRunScriptTemplate;
12
27
  exports.scriptInputPath = '"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}"';
@@ -1 +1 @@
1
- {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAqB,EACrB,mBAA4B;IAE5B,6CAA6C;IAC7C,MAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC,uFAAuF;QACzF,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,0FAA0F,eAAe,+DAA+D,OAAO,4BAA4B,WAAW,4CAC3N,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACxC,2OAA2O,CAAC;AAC9O,CAAC;AAbD,oDAaC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW;IACzC,OAAO;6BACoB,GAAG;;;;;;;;;;;;;;;;;;;;;;iEAsBiC,CAAC;AAClE,CAAC;AAzBD,0CAyBC;AAED,SAAgB,cAAc,CAAC,GAAW;IACxC,OAAO;0BACiB,GAAG;;;;;;;;;;;;;;;;;;;;;;2DAsB8B,CAAC;AAC5D,CAAC;AAzBD,wCAyBC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,OAAe;IAC7D,OAAO;mBACU,GAAG;uBACC,OAAO;;MAExB,CAAC;AACP,CAAC;AAND,gDAMC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n uploadSource: boolean,\n includeHomebrewPath: boolean,\n): string {\n // eslint-disable-next-line no-useless-escape\n const includeHomebrew = includeHomebrewPath\n ? '\\\\nif [[ \"$(uname -m)\" == arm64 ]]; then\\\\nexport PATH=\"/opt/homebrew/bin:$PATH\"\\\\nfi'\n : '';\n return `# This script is responsible for uploading debug symbols and source context for Sentry.${includeHomebrew}\\\\nif which sentry-cli >/dev/null; then\\\\nexport SENTRY_ORG=${orgSlug}\\\\nexport SENTRY_PROJECT=${projectSlug}\\\\nERROR=$(sentry-cli debug-files upload ${\n uploadSource ? '--include-sources ' : ''\n }\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\\\\nif [ ! $? -eq 0 ]; then\\\\necho \"warning: sentry-cli - $ERROR\"\\\\nfi\\\\nelse\\\\necho \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\\\\nfi\\\\n`;\n}\n\nexport const scriptInputPath =\n '\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"';\n\nexport function getSwiftSnippet(dsn: string): string {\n return ` SentrySDK.start { options in\n options.dsn = \"${dsn}\"\n options.debug = true // Enabled debug when first installing is always helpful\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = true\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = {\n $0.sessionSampleRate = 1.0 // We recommend adjusting this value in production.\n $0.lifecycle = .trace\n }\n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\\n`;\n}\n\nexport function getObjcSnippet(dsn: string): string {\n return ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"${dsn}\";\n options.debug = YES; // Enabled debug when first installing is always helpful\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = YES;\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = @1.0;\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = ^(SentryProfileOptions *profiling) {\n profiling.sessionSampleRate = 1.0; // We recommend adjusting this value in production.\n profiling.lifecycle = SentryProfilingLifecycleTrace;\n };\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\\n`;\n}\n\nexport function getFastlaneSnippet(org: string, project: string): string {\n return ` sentry_cli(\n org_slug: '${org}',\n project_slug: '${project}',\n include_sources: true\n )`;\n}\n"]}
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/apple/templates.ts"],"names":[],"mappings":";;;AAAA,SAAgB,oBAAoB,CAClC,OAAe,EACf,WAAmB,EACnB,YAAqB,EACrB,mBAA4B;IAE5B,6CAA6C;IAC7C,MAAM,eAAe,GAAG,mBAAmB;QACzC,CAAC,CAAC;;;;CAIL;QACG,CAAC,CAAC,EAAE,CAAC;IACP,OAAO,0FAA0F,eAAe;;sBAE5F,OAAO;0BACH,WAAW;0CAEjC,YAAY,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,EACxC;;;;;;;CAOD,CAAC;AACF,CAAC;AA5BD,oDA4BC;AAEY,QAAA,eAAe,GAC1B,6FAA6F,CAAC;AAEhG,SAAgB,eAAe,CAAC,GAAW;IACzC,OAAO;6BACoB,GAAG;;;;;;;;;;;;;;;;;;;;;;iEAsBiC,CAAC;AAClE,CAAC;AAzBD,0CAyBC;AAED,SAAgB,cAAc,CAAC,GAAW;IACxC,OAAO;0BACiB,GAAG;;;;;;;;;;;;;;;;;;;;;;2DAsB8B,CAAC;AAC5D,CAAC;AAzBD,wCAyBC;AAED,SAAgB,kBAAkB,CAAC,GAAW,EAAE,OAAe;IAC7D,OAAO;mBACU,GAAG;uBACC,OAAO;;MAExB,CAAC;AACP,CAAC;AAND,gDAMC","sourcesContent":["export function getRunScriptTemplate(\n orgSlug: string,\n projectSlug: string,\n uploadSource: boolean,\n includeHomebrewPath: boolean,\n): string {\n // eslint-disable-next-line no-useless-escape\n const includeHomebrew = includeHomebrewPath\n ? `\nif [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n`\n : '';\n return `# This script is responsible for uploading debug symbols and source context for Sentry.${includeHomebrew}\nif which sentry-cli >/dev/null; then\n export SENTRY_ORG=${orgSlug}\n export SENTRY_PROJECT=${projectSlug}\n ERROR=$(sentry-cli debug-files upload ${\n uploadSource ? '--include-sources ' : ''\n }\"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null)\n if [ ! $? -eq 0 ]; then\n echo \"warning: sentry-cli - $ERROR\"\n fi\nelse\n echo \"warning: sentry-cli not installed, download from https://github.com/getsentry/sentry-cli/releases\"\nfi\n`;\n}\n\nexport const scriptInputPath =\n '\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}\"';\n\nexport function getSwiftSnippet(dsn: string): string {\n return ` SentrySDK.start { options in\n options.dsn = \"${dsn}\"\n options.debug = true // Enabled debug when first installing is always helpful\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = true\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = {\n $0.sessionSampleRate = 1.0 // We recommend adjusting this value in production.\n $0.lifecycle = .trace\n }\n\n // Uncomment the following lines to add more data to your events\n // options.attachScreenshot = true // This adds a screenshot to the error events\n // options.attachViewHierarchy = true // This adds the view hierarchy to the error events\n }\n // Remove the next line after confirming that your Sentry integration is working.\n SentrySDK.capture(message: \"This app uses Sentry! :)\")\\n`;\n}\n\nexport function getObjcSnippet(dsn: string): string {\n return ` [SentrySDK startWithConfigureOptions:^(SentryOptions * options) {\n options.dsn = @\"${dsn}\";\n options.debug = YES; // Enabled debug when first installing is always helpful\n\n // Adds IP for users.\n // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/\n options.sendDefaultPii = YES;\n\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = @1.0;\n\n // Configure profiling. Visit https://docs.sentry.io/platforms/apple/profiling/ to learn more.\n options.configureProfiling = ^(SentryProfileOptions *profiling) {\n profiling.sessionSampleRate = 1.0; // We recommend adjusting this value in production.\n profiling.lifecycle = SentryProfilingLifecycleTrace;\n };\n\n //Uncomment the following lines to add more data to your events\n //options.attachScreenshot = YES; //This will add a screenshot to the error events\n //options.attachViewHierarchy = YES; //This will add the view hierarchy to the error events\n }];\n //Remove the next line after confirming that your Sentry integration is working.\n [SentrySDK captureMessage:@\"This app uses Sentry!\"];\\n`;\n}\n\nexport function getFastlaneSnippet(org: string, project: string): string {\n return ` sentry_cli(\n org_slug: '${org}',\n project_slug: '${project}',\n include_sources: true\n )`;\n}\n"]}
@@ -54,6 +54,24 @@ export declare class XcodeProject {
54
54
  * @returns The source build phase, or undefined if the target is not found or has no source build phase
55
55
  */
56
56
  findSourceBuildPhaseInTarget(target: PBXNativeTarget): XcodeProjectObjectWithId<PBXSourcesBuildPhase> | undefined;
57
+ /**
58
+ * Adds a new script build phase to the specified target.
59
+ *
60
+ * @param targetKey - The key of the target to add the build phase to
61
+ * @param name - The name of the build phase
62
+ * @param script - The shell script content
63
+ * @param inputPaths - Array of input paths for the script
64
+ * @returns The UUID of the created build phase
65
+ */
66
+ addScriptBuildPhase(targetKey: string, name: string, script: string, inputPaths?: string[]): string;
67
+ /**
68
+ * Updates an existing script build phase.
69
+ *
70
+ * @param buildPhaseId - The UUID of the build phase to update
71
+ * @param script - The new shell script content
72
+ * @param inputPaths - Array of input paths for the script
73
+ */
74
+ updateScriptBuildPhase(buildPhaseId: string, script: string, inputPaths?: string[]): void;
57
75
  /**
58
76
  * Finds all files in the source build phase of a target.
59
77
  *
@@ -240,33 +240,71 @@ class XcodeProject {
240
240
  typeof value !== 'string' &&
241
241
  value?.name === targetName);
242
242
  })[0];
243
+ const target = xcObjects.PBXNativeTarget[targetKey];
244
+ if (!target) {
245
+ (0, debug_1.debug)(`Target not found: ${targetName}`);
246
+ return;
247
+ }
248
+ // Generate the new script content
249
+ const isHomebrewInstalled = fs.existsSync('/opt/homebrew/bin/sentry-cli');
250
+ const shellScript = templates.getRunScriptTemplate(sentryProject.organization.slug, sentryProject.slug, uploadSource, isHomebrewInstalled);
243
251
  if (!xcObjects.PBXShellScriptBuildPhase) {
244
252
  xcObjects.PBXShellScriptBuildPhase = {};
245
253
  }
246
- for (const key in xcObjects.PBXShellScriptBuildPhase) {
247
- const value = xcObjects.PBXShellScriptBuildPhase[key] ?? {};
248
- if (typeof value === 'string') {
249
- // Ignore comments
250
- continue;
254
+ // Look for existing Sentry build phase in the current target
255
+ let existingSentryBuildPhaseId;
256
+ let existingSentryBuildPhase;
257
+ // Check target's build phases for existing Sentry script by searching for a build phase that contains "sentry-cli" in the shell script
258
+ if (target.buildPhases) {
259
+ for (const phase of target.buildPhases) {
260
+ const buildPhase = xcObjects.PBXShellScriptBuildPhase[phase.value];
261
+ if (typeof buildPhase === 'object' &&
262
+ buildPhase.shellScript?.includes('sentry-cli')) {
263
+ existingSentryBuildPhaseId = phase.value;
264
+ existingSentryBuildPhase = buildPhase;
265
+ break;
266
+ }
251
267
  }
252
- // Sentry script already exists, update it
253
- if (value.shellScript?.includes('sentry-cli')) {
254
- delete xcObjects.PBXShellScriptBuildPhase?.[key];
255
- delete xcObjects.PBXShellScriptBuildPhase?.[`${key}_comment`];
256
- break;
268
+ }
269
+ // Clean up orphaned build phase references that may exist from previous runs
270
+ // Find all build phase IDs that are referenced in targets but don't exist in PBXShellScriptBuildPhase
271
+ const orphanedBuildPhaseIds = [];
272
+ for (const targetKey in xcObjects.PBXNativeTarget) {
273
+ const targetValue = xcObjects.PBXNativeTarget[targetKey];
274
+ if (typeof targetValue === 'object' && targetValue.buildPhases) {
275
+ for (const phase of targetValue.buildPhases) {
276
+ // Check if this is a shell script build phase that doesn't exist
277
+ if (!xcObjects.PBXShellScriptBuildPhase?.[phase.value] &&
278
+ phase.comment?.includes('Upload Debug Symbols to Sentry')) {
279
+ orphanedBuildPhaseIds.push(phase.value);
280
+ }
281
+ }
257
282
  }
258
- xcObjects.PBXShellScriptBuildPhase[key] = value;
259
283
  }
260
- // Add the build phase to the target
261
- const isHomebrewInstalled = fs.existsSync('/opt/homebrew/bin/sentry-cli');
262
- this.project.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Upload Debug Symbols to Sentry', targetKey, {
263
- inputFileListPaths: [],
264
- outputFileListPaths: [],
265
- inputPaths: [templates.scriptInputPath],
266
- shellPath: '/bin/sh',
267
- shellScript: templates.getRunScriptTemplate(sentryProject.organization.slug, sentryProject.slug, uploadSource, isHomebrewInstalled),
268
- });
269
- clack.log.step(`Added Sentry upload script to "${targetName}" build phase`);
284
+ // Remove orphaned build phase references from all targets
285
+ if (orphanedBuildPhaseIds.length > 0) {
286
+ for (const targetKey in xcObjects.PBXNativeTarget) {
287
+ const targetValue = xcObjects.PBXNativeTarget[targetKey];
288
+ if (typeof targetValue === 'object' && targetValue.buildPhases) {
289
+ targetValue.buildPhases = targetValue.buildPhases.filter((phase) => {
290
+ return !orphanedBuildPhaseIds.includes(phase.value);
291
+ });
292
+ }
293
+ }
294
+ }
295
+ if (existingSentryBuildPhaseId && existingSentryBuildPhase) {
296
+ // Update existing build phase instead of adding a new one
297
+ // This call is idempotent, so it will not add a new build phase if it already exists
298
+ this.updateScriptBuildPhase(existingSentryBuildPhaseId, shellScript, [
299
+ templates.scriptInputPath,
300
+ ]);
301
+ clack.log.step(`Updated existing Sentry upload script for "${targetName}" build phase`);
302
+ }
303
+ else {
304
+ // Add new build phase to the target
305
+ this.addScriptBuildPhase(targetKey, 'Upload Debug Symbols to Sentry', shellScript, [templates.scriptInputPath]);
306
+ clack.log.step(`Added Sentry upload script to "${targetName}" build phase`);
307
+ }
270
308
  }
271
309
  /**
272
310
  * Retrieves all source files associated with a specific target in the Xcode project.
@@ -366,6 +404,64 @@ class XcodeProject {
366
404
  (0, debug_1.debug)(`No source build phase found for target: ${target.name}`);
367
405
  return undefined;
368
406
  }
407
+ /**
408
+ * Adds a new script build phase to the specified target.
409
+ *
410
+ * @param targetKey - The key of the target to add the build phase to
411
+ * @param name - The name of the build phase
412
+ * @param script - The shell script content
413
+ * @param inputPaths - Array of input paths for the script
414
+ * @returns The UUID of the created build phase
415
+ */
416
+ addScriptBuildPhase(targetKey, name, script, inputPaths = []) {
417
+ const buildPhaseUuid = this.project.generateUuid();
418
+ const escapedScript = script.replace(/"/g, '\\"');
419
+ // Create the shell script build phase object
420
+ const buildPhase = {
421
+ isa: 'PBXShellScriptBuildPhase',
422
+ buildActionMask: 2147483647,
423
+ files: [],
424
+ inputPaths,
425
+ outputPaths: [],
426
+ runOnlyForDeploymentPostprocessing: 0,
427
+ shellPath: '/bin/sh',
428
+ shellScript: `"${escapedScript}"`,
429
+ name: `"${name}"`,
430
+ };
431
+ // Add to PBXShellScriptBuildPhase section
432
+ if (!this.objects.PBXShellScriptBuildPhase) {
433
+ this.objects.PBXShellScriptBuildPhase = {};
434
+ }
435
+ this.objects.PBXShellScriptBuildPhase[buildPhaseUuid] = buildPhase;
436
+ this.objects.PBXShellScriptBuildPhase[`${buildPhaseUuid}_comment`] = name;
437
+ // Add to target's build phases
438
+ const target = this.objects.PBXNativeTarget?.[targetKey];
439
+ if (target?.buildPhases) {
440
+ target.buildPhases.push({
441
+ value: buildPhaseUuid,
442
+ comment: name,
443
+ });
444
+ }
445
+ return buildPhaseUuid;
446
+ }
447
+ /**
448
+ * Updates an existing script build phase.
449
+ *
450
+ * @param buildPhaseId - The UUID of the build phase to update
451
+ * @param script - The new shell script content
452
+ * @param inputPaths - Array of input paths for the script
453
+ */
454
+ updateScriptBuildPhase(buildPhaseId, script, inputPaths = []) {
455
+ const buildPhase = this.objects.PBXShellScriptBuildPhase?.[buildPhaseId];
456
+ if (!buildPhase || typeof buildPhase === 'string') {
457
+ (0, debug_1.debug)(`Build phase not found: ${buildPhaseId}`);
458
+ return;
459
+ }
460
+ const escapedScript = script.replace(/"/g, '\\"');
461
+ buildPhase.shellScript = `"${escapedScript}"`;
462
+ buildPhase.inputPaths = inputPaths;
463
+ buildPhase.shellPath = '/bin/sh';
464
+ }
369
465
  // ================================ FILE HELPERS ================================
370
466
  /**
371
467
  * Finds all files in the source build phase of a target.