@sentry/wizard 3.22.3 → 3.23.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.
@@ -1 +1 @@
1
- {"version":3,"file":"react-native-wizard.js","sourceRoot":"","sources":["../../../src/react-native/react-native-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,yEAAyE;AACzE,2DAAmC;AACnC,gDAA0B;AAC1B,qCAAyB;AACzB,yCAA6B;AAC7B,+CAAmC;AACnC,oDAa8B;AAC9B,sDAA+E;AAC/E,8CAA+C;AAC/C,yBAA8B;AAC9B,iCAUiB;AACjB,mCAIkB;AAClB,yCAAsD;AACtD,+BAA8E;AAE9E,2CAIsB;AACtB,0CAAwD;AACxD,mDAAuC;AACvC,0CAAuD;AACvD,oCAAiD;AACjD,iCAA2C;AAE3C,mEAAmE;AACnE,IAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAElB,QAAA,cAAc,GAAG,sBAAsB,CAAC;AAExC,QAAA,UAAU,GAAG,cAAc,CAAC;AAC5B,QAAA,aAAa,GAAG,cAAc,CAAC;AAE/B,QAAA,kBAAkB,GAAG,UAAU,CAAC;AAE7C,4DAA4D;AAC5D,iDAAiD;AACpC,QAAA,qCAAqC,GAAG,UAAU,CAAC;AAEhE,0DAA0D;AAC7C,QAAA,2CAA2C,GAAG,UAAU,CAAC;AAOtE,SAAsB,oBAAoB,CACxC,MAAgC;;;YAEhC,sBAAO,IAAA,yBAAa,EAClB;oBACE,OAAO,EAAE,MAAM,CAAC,gBAAgB;oBAChC,WAAW,EAAE,cAAc;iBAC5B,EACD,cAAM,OAAA,iCAAiC,CAAC,MAAM,CAAC,EAAzC,CAAyC,CAChD,EAAC;;;CACH;AAVD,oDAUC;AAED,SAAsB,iCAAiC,CACrD,OAAiC;;;;;;o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BACR;oBAED,MAAM,CAAC,MAAM,CAAC,yBAAyB,EAAE,+BAA+B,CAAC,CAAC;oBAC1E,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,2CAAoC,eAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,MAAG,CACtE,CAAC;oBAEF,IAAA,qBAAS,EAAC,wBAAwB,EAAE;wBAClC,OAAA,IAAA,4BAAmB,EAAC,kBAAkB,EAAE,qBAAqB,CAAC;oBAA9D,CAA8D,CAC/D,CAAC;oBACF,iBAAK,CAAC,GAAG,CAAC,OAAO,CACf,eAAK,CAAC,KAAK,CAAC,kBAAW,eAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,YAAS,CAAC,CAChE,CAAC;;;;;CACH;AAED,SAAe,iBAAiB;;;;YAC9B,sBAAO,IAAA,qBAAS,EAAC,qBAAqB,EAAE;;;;oCACP,qBAAM,IAAA,8BAAgB,EACnD,iBAAK,CAAC,MAAM,CAAC;oCACX,OAAO,EAAE,uCAAuC;oCAChD,OAAO,EAAE;wCACP;4CACE,KAAK,EAAE,IAAI;4CACX,KAAK,EAAE,KAAK;4CACZ,IAAI,EAAE,mEAAmE;yCAC1E;wCACD,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,sBAAsB,EAAE;qCAChD;oCACD,YAAY,EAAE,IAAI;iCACnB,CAAC,CACH,EAAA;;gCAbK,sBAAsB,GAAG,SAa9B;gCACD,MAAM,CAAC,MAAM,CAAC,2BAA2B,EAAE,sBAAsB,CAAC,CAAC;gCACnE,sBAAO,sBAAsB,EAAC;;;qBAC/B,CAAC,EAAC;;;CACJ","sourcesContent":["/* eslint-disable max-lines */\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as process from 'process';\nimport {\n CliSetupConfigContent,\n abortIfCancelled,\n addSentryCliConfig,\n confirmContinueIfNoOrDirtyGitRepo,\n confirmContinueIfPackageVersionNotSupported,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n printWelcome,\n propertiesCliSetupConfig,\n showCopyPasteInstructions,\n} from '../utils/clack-utils';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { podInstall } from '../apple/cocoapod';\nimport { platform } from 'os';\nimport {\n getValidExistingBuildPhases,\n findBundlePhase,\n patchBundlePhase,\n findDebugFilesUploadPhase,\n addDebugFilesUploadPhaseWithCli,\n writeXcodeProject,\n addSentryWithCliToBundleShellScript,\n addSentryWithBundledScriptsToBundleShellScript,\n addDebugFilesUploadPhaseWithBundledScripts,\n} from './xcode';\nimport {\n doesAppBuildGradleIncludeRNSentryGradlePlugin,\n addRNSentryGradlePlugin,\n writeAppBuildGradle,\n} from './gradle';\nimport { runReactNativeUninstall } from './uninstall';\nimport { APP_BUILD_GRADLE, XCODE_PROJECT, getFirstMatchedPath } from './glob';\nimport { ReactNativeWizardOptions } from './options';\nimport {\n addSentryInitWithSdkImport,\n doesJsCodeIncludeSdkSentryImport,\n getSentryInitColoredCodeSnippet,\n} from './javascript';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport * as Sentry from '@sentry/node';\nimport { fulfillsVersionRange } from '../utils/semver';\nimport { getIssueStreamUrl } from '../utils/url';\nimport { patchMetroConfig } from './metro';\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\nconst xcode = require('xcode');\n\nexport const RN_SDK_PACKAGE = '@sentry/react-native';\n\nexport const RN_PACKAGE = 'react-native';\nexport const RN_HUMAN_NAME = 'React Native';\n\nexport const SUPPORTED_RN_RANGE = '>=0.69.0';\n\n// The following SDK version ship with bundled Xcode scripts\n// which simplifies the Xcode Build Phases setup.\nexport const SDK_XCODE_SCRIPTS_SUPPORTED_SDK_RANGE = '>=5.11.0';\n\n// The following SDK version ship with Sentry Metro plugin\nexport const SDK_SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE = '>=5.11.0';\n\nexport type RNCliSetupConfigContent = Pick<\n Required<CliSetupConfigContent>,\n 'authToken' | 'org' | 'project' | 'url'\n>;\n\nexport async function runReactNativeWizard(\n params: ReactNativeWizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: params.telemetryEnabled,\n integration: 'react-native',\n },\n () => runReactNativeWizardWithTelemetry(params),\n );\n}\n\nexport async function runReactNativeWizardWithTelemetry(\n options: ReactNativeWizardOptions,\n): Promise<void> {\n if (options.uninstall) {\n Sentry.setTag('uninstall', true);\n return runReactNativeUninstall(options);\n }\n\n printWelcome({\n wizardName: 'Sentry React Native Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n const packageJson = await getPackageDotJson();\n\n await ensurePackageIsInstalled(packageJson, RN_PACKAGE, RN_HUMAN_NAME);\n\n const rnVersion = getPackageVersion(RN_PACKAGE, packageJson);\n if (rnVersion) {\n await confirmContinueIfPackageVersionNotSupported({\n packageName: RN_HUMAN_NAME,\n packageVersion: rnVersion,\n packageId: RN_PACKAGE,\n acceptableVersions: SUPPORTED_RN_RANGE,\n });\n }\n\n const { selectedProject, authToken, sentryUrl } =\n await getOrAskForProjectData(options, 'react-native');\n const orgSlug = selectedProject.organization.slug;\n const projectSlug = selectedProject.slug;\n const projectId = selectedProject.id;\n const cliConfig: RNCliSetupConfigContent = {\n authToken,\n org: orgSlug,\n project: projectSlug,\n url: sentryUrl,\n };\n\n await installPackage({\n packageName: RN_SDK_PACKAGE,\n alreadyInstalled: hasPackageInstalled(RN_SDK_PACKAGE, packageJson),\n });\n const sdkVersion = getPackageVersion(\n RN_SDK_PACKAGE,\n await getPackageDotJson(),\n );\n\n await traceStep('patch-js', () =>\n addSentryInit({ dsn: selectedProject.keys[0].dsn.public }),\n );\n\n await traceStep('patch-metro-config', () =>\n addSentryToMetroConfig({ sdkVersion }),\n );\n\n if (fs.existsSync('ios')) {\n Sentry.setTag('patch-ios', true);\n await traceStep('patch-xcode-files', () =>\n patchXcodeFiles(cliConfig, { sdkVersion }),\n );\n }\n\n if (fs.existsSync('android')) {\n Sentry.setTag('patch-android', true);\n await traceStep('patch-android-files', () => patchAndroidFiles(cliConfig));\n }\n\n const confirmedFirstException = await confirmFirstSentryException(\n sentryUrl,\n orgSlug,\n projectId,\n );\n Sentry.setTag('user-confirmed-first-error', confirmedFirstException);\n\n if (confirmedFirstException) {\n clack.outro(\n `${chalk.green('Everything is set up!')}\n\n ${chalk.dim(\n 'If you encounter any issues, let us know here: https://github.com/getsentry/sentry-react-native/issues',\n )}`,\n );\n } else {\n clack.outro(\n `${chalk.dim(\n 'Let us know here: https://github.com/getsentry/sentry-react-native/issues',\n )}`,\n );\n }\n}\n\nasync function addSentryToMetroConfig({\n sdkVersion,\n}: {\n sdkVersion: string | undefined;\n}) {\n if (\n !sdkVersion ||\n !fulfillsVersionRange({\n version: sdkVersion,\n acceptableVersions: SDK_SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE,\n canBeLatest: true,\n })\n ) {\n return;\n }\n\n await patchMetroConfig();\n}\n\nasync function addSentryInit({ dsn }: { dsn: string }) {\n const prefixGlob = '{.,./src}';\n const suffixGlob = '@(j|t|cj|mj)s?(x)';\n const universalGlob = `App.${suffixGlob}`;\n const jsFileGlob = `${prefixGlob}/+(${universalGlob})`;\n const jsPath = traceStep('find-app-js-file', () =>\n getFirstMatchedPath(jsFileGlob),\n );\n Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');\n if (!jsPath) {\n clack.log.warn(\n `Could not find main App file using ${chalk.cyan(jsFileGlob)}.`,\n );\n await showCopyPasteInstructions(\n 'App.js',\n getSentryInitColoredCodeSnippet(dsn),\n 'This ensures the Sentry SDK is ready to capture errors.',\n );\n return;\n }\n const jsRelativePath = path.relative(process.cwd(), jsPath);\n\n const js = fs.readFileSync(jsPath, 'utf-8');\n const includesSentry = doesJsCodeIncludeSdkSentryImport(js, {\n sdkPackageName: RN_SDK_PACKAGE,\n });\n if (includesSentry) {\n Sentry.setTag('app-js-file-status', 'already-includes-sentry');\n clack.log.warn(\n `${chalk.cyan(\n jsRelativePath,\n )} already includes Sentry. We wont't add it again.`,\n );\n return;\n }\n\n traceStep('add-sentry-init', () => {\n const newContent = addSentryInitWithSdkImport(js, { dsn });\n\n clack.log.success(\n `Added ${chalk.cyan('Sentry.init')} to ${chalk.cyan(jsRelativePath)}.`,\n );\n\n fs.writeFileSync(jsPath, newContent, 'utf-8');\n });\n\n Sentry.setTag('app-js-file-status', 'added-sentry-init');\n clack.log.success(\n chalk.green(`${chalk.cyan(jsRelativePath)} changes saved.`),\n );\n}\n\nasync function confirmFirstSentryException(\n url: string,\n orgSlug: string,\n projectId: string,\n) {\n const issuesStreamUrl = getIssueStreamUrl({ url, orgSlug, projectId });\n\n clack.log\n .step(`To make sure everything is set up correctly, put the following code snippet into your application.\nThe snippet will create a button that, when tapped, sends a test event to Sentry.\n\nAfter that check your project issues:\n\n${chalk.cyan(issuesStreamUrl)}`);\n\n // We want the code snippet to be easily copy-pasteable, without any clack artifacts\n // eslint-disable-next-line no-console\n console.log(\n chalk.greenBright(`\n<Button title='Try!' onPress={ () => { Sentry.captureException(new Error('First error')) }}/>\n`),\n );\n\n const firstErrorConfirmed = clack.confirm({\n message: `Have you successfully sent a test event?`,\n });\n\n return firstErrorConfirmed;\n}\n\nasync function patchXcodeFiles(\n config: RNCliSetupConfigContent,\n context: {\n sdkVersion: string | undefined;\n },\n) {\n await addSentryCliConfig(config, {\n ...propertiesCliSetupConfig,\n name: 'source maps and iOS debug files',\n filename: 'ios/sentry.properties',\n gitignore: false,\n });\n\n if (platform() === 'darwin' && (await confirmPodInstall())) {\n await traceStep('pod-install', () => podInstall('ios'));\n }\n\n const xcodeProjectPath = traceStep('find-xcode-project', () =>\n getFirstMatchedPath(XCODE_PROJECT),\n );\n Sentry.setTag(\n 'xcode-project-status',\n xcodeProjectPath ? 'found' : 'not-found',\n );\n if (!xcodeProjectPath) {\n clack.log.warn(\n `Could not find Xcode project file using ${chalk.cyan(XCODE_PROJECT)}.`,\n );\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const [xcodeProject, buildPhasesMap] = traceStep(\n 'parse-xcode-project',\n () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n const project = xcode.project(xcodeProjectPath);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n project.parseSync();\n\n const map = getValidExistingBuildPhases(project);\n return [project, map];\n },\n );\n Sentry.setTag('xcode-project-status', 'parsed');\n\n traceStep('patch-bundle-phase', () => {\n const bundlePhase = findBundlePhase(buildPhasesMap);\n Sentry.setTag(\n 'xcode-bundle-phase-status',\n bundlePhase ? 'found' : 'not-found',\n );\n if (\n context.sdkVersion &&\n fulfillsVersionRange({\n version: context.sdkVersion,\n acceptableVersions: SDK_XCODE_SCRIPTS_SUPPORTED_SDK_RANGE,\n canBeLatest: true,\n })\n ) {\n patchBundlePhase(\n bundlePhase,\n addSentryWithBundledScriptsToBundleShellScript,\n );\n } else {\n patchBundlePhase(bundlePhase, addSentryWithCliToBundleShellScript);\n }\n Sentry.setTag('xcode-bundle-phase-status', 'patched');\n });\n\n traceStep('add-debug-files-upload-phase', () => {\n const debugFilesUploadPhaseExists =\n !!findDebugFilesUploadPhase(buildPhasesMap);\n Sentry.setTag(\n 'xcode-debug-files-upload-phase-status',\n debugFilesUploadPhaseExists ? 'already-exists' : undefined,\n );\n if (\n context.sdkVersion &&\n fulfillsVersionRange({\n version: context.sdkVersion,\n acceptableVersions: SDK_XCODE_SCRIPTS_SUPPORTED_SDK_RANGE,\n canBeLatest: true,\n })\n ) {\n addDebugFilesUploadPhaseWithBundledScripts(xcodeProject, {\n debugFilesUploadPhaseExists,\n });\n } else {\n addDebugFilesUploadPhaseWithCli(xcodeProject, {\n debugFilesUploadPhaseExists,\n });\n }\n Sentry.setTag('xcode-debug-files-upload-phase-status', 'added');\n });\n\n traceStep('write-xcode-project', () => {\n writeXcodeProject(xcodeProjectPath, xcodeProject);\n });\n Sentry.setTag('xcode-project-status', 'patched');\n}\n\nasync function patchAndroidFiles(config: RNCliSetupConfigContent) {\n await addSentryCliConfig(config, {\n ...propertiesCliSetupConfig,\n name: 'source maps and iOS debug files',\n filename: 'android/sentry.properties',\n gitignore: false,\n });\n\n const appBuildGradlePath = traceStep('find-app-build-gradle', () =>\n getFirstMatchedPath(APP_BUILD_GRADLE),\n );\n Sentry.setTag(\n 'app-build-gradle-status',\n appBuildGradlePath ? 'found' : 'not-found',\n );\n if (!appBuildGradlePath) {\n clack.log.warn(\n `Could not find Android ${chalk.cyan(\n 'app/build.gradle',\n )} file using ${chalk.cyan(APP_BUILD_GRADLE)}.`,\n );\n return;\n }\n\n const appBuildGradle = traceStep('read-app-build-gradle', () =>\n fs.readFileSync(appBuildGradlePath, 'utf-8'),\n );\n const includesSentry =\n doesAppBuildGradleIncludeRNSentryGradlePlugin(appBuildGradle);\n if (includesSentry) {\n Sentry.setTag('app-build-gradle-status', 'already-includes-sentry');\n clack.log.warn(\n `Android ${chalk.cyan('app/build.gradle')} file already includes Sentry.`,\n );\n return;\n }\n\n const patchedAppBuildGradle = traceStep('add-rn-sentry-gradle-plugin', () =>\n addRNSentryGradlePlugin(appBuildGradle),\n );\n if (!doesAppBuildGradleIncludeRNSentryGradlePlugin(patchedAppBuildGradle)) {\n Sentry.setTag(\n 'app-build-gradle-status',\n 'failed-to-add-rn-sentry-gradle-plugin',\n );\n clack.log.warn(\n `Could not add Sentry RN Gradle Plugin to ${chalk.cyan(\n 'app/build.gradle',\n )}.`,\n );\n return;\n }\n\n Sentry.setTag('app-build-gradle-status', 'added-rn-sentry-gradle-plugin');\n clack.log.success(\n `Added Sentry RN Gradle Plugin to ${chalk.bold('app/build.gradle')}.`,\n );\n\n traceStep('write-app-build-gradle', () =>\n writeAppBuildGradle(appBuildGradlePath, patchedAppBuildGradle),\n );\n clack.log.success(\n chalk.green(`Android ${chalk.cyan('app/build.gradle')} saved.`),\n );\n}\n\nasync function confirmPodInstall(): Promise<boolean> {\n return traceStep('confirm-pod-install', async () => {\n const continueWithPodInstall = await abortIfCancelled(\n clack.select({\n message: 'Do you want to run `pod install` now?',\n options: [\n {\n value: true,\n label: 'Yes',\n hint: 'Recommended for smaller projects, this might take several minutes',\n },\n { value: false, label: `No, I'll do it later` },\n ],\n initialValue: true,\n }),\n );\n Sentry.setTag('continue-with-pod-install', continueWithPodInstall);\n return continueWithPodInstall;\n });\n}\n"]}
1
+ {"version":3,"file":"react-native-wizard.js","sourceRoot":"","sources":["../../../src/react-native/react-native-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,yEAAyE;AACzE,2DAAmC;AACnC,gDAA0B;AAC1B,qCAAyB;AACzB,yCAA6B;AAC7B,+CAAmC;AACnC,oDAa8B;AAC9B,sDAA+E;AAC/E,8CAA+C;AAC/C,yBAA8B;AAC9B,iCAUiB;AACjB,mCAIkB;AAClB,yCAAsD;AACtD,+BAA8E;AAE9E,2CAIsB;AACtB,0CAAwD;AACxD,mDAAuC;AACvC,0CAAuD;AACvD,oCAAiD;AACjD,iCAGiB;AAEjB,mEAAmE;AACnE,IAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAElB,QAAA,cAAc,GAAG,sBAAsB,CAAC;AAExC,QAAA,UAAU,GAAG,cAAc,CAAC;AAC5B,QAAA,aAAa,GAAG,cAAc,CAAC;AAE/B,QAAA,kBAAkB,GAAG,UAAU,CAAC;AAE7C,4DAA4D;AAC5D,iDAAiD;AACpC,QAAA,qCAAqC,GAAG,UAAU,CAAC;AAEhE,0DAA0D;AAC7C,QAAA,2CAA2C,GAAG,UAAU,CAAC;AAEtE,uDAAuD;AAC1C,QAAA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IAAI;iCACnB,CAAC,CACH,EAAA;;gCAbK,sBAAsB,GAAG,SAa9B;gCACD,MAAM,CAAC,MAAM,CAAC,2BAA2B,EAAE,sBAAsB,CAAC,CAAC;gCACnE,sBAAO,sBAAsB,EAAC;;;qBAC/B,CAAC,EAAC;;;CACJ","sourcesContent":["/* eslint-disable max-lines */\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as process from 'process';\nimport {\n CliSetupConfigContent,\n abortIfCancelled,\n addSentryCliConfig,\n confirmContinueIfNoOrDirtyGitRepo,\n confirmContinueIfPackageVersionNotSupported,\n ensurePackageIsInstalled,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n printWelcome,\n propertiesCliSetupConfig,\n showCopyPasteInstructions,\n} from '../utils/clack-utils';\nimport { getPackageVersion, hasPackageInstalled } from '../utils/package-json';\nimport { podInstall } from '../apple/cocoapod';\nimport { platform } from 'os';\nimport {\n getValidExistingBuildPhases,\n findBundlePhase,\n patchBundlePhase,\n findDebugFilesUploadPhase,\n addDebugFilesUploadPhaseWithCli,\n writeXcodeProject,\n addSentryWithCliToBundleShellScript,\n addSentryWithBundledScriptsToBundleShellScript,\n addDebugFilesUploadPhaseWithBundledScripts,\n} from './xcode';\nimport {\n doesAppBuildGradleIncludeRNSentryGradlePlugin,\n addRNSentryGradlePlugin,\n writeAppBuildGradle,\n} from './gradle';\nimport { runReactNativeUninstall } from './uninstall';\nimport { APP_BUILD_GRADLE, XCODE_PROJECT, getFirstMatchedPath } from './glob';\nimport { ReactNativeWizardOptions } from './options';\nimport {\n addSentryInitWithSdkImport,\n doesJsCodeIncludeSdkSentryImport,\n getSentryInitColoredCodeSnippet,\n} from './javascript';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport * as Sentry from '@sentry/node';\nimport { fulfillsVersionRange } from '../utils/semver';\nimport { getIssueStreamUrl } from '../utils/url';\nimport {\n patchMetroConfigWithSentrySerializer,\n patchMetroWithSentryConfig,\n} from './metro';\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\nconst xcode = require('xcode');\n\nexport const RN_SDK_PACKAGE = '@sentry/react-native';\n\nexport const RN_PACKAGE = 'react-native';\nexport const RN_HUMAN_NAME = 'React Native';\n\nexport const SUPPORTED_RN_RANGE = '>=0.69.0';\n\n// The following SDK version ship with bundled Xcode scripts\n// which simplifies the Xcode Build Phases setup.\nexport const SDK_XCODE_SCRIPTS_SUPPORTED_SDK_RANGE = '>=5.11.0';\n\n// The following SDK version ship with Sentry Metro plugin\nexport const SDK_SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE = '>=5.11.0';\n\n// The following SDK version shipped `withSentryConfig`\nexport const SDK_SENTRY_METRO_WITH_SENTRY_CONFIG_SUPPORTED_SDK_RANGE =\n '>=5.17.0';\n\nexport type RNCliSetupConfigContent = Pick<\n Required<CliSetupConfigContent>,\n 'authToken' | 'org' | 'project' | 'url'\n>;\n\nexport async function runReactNativeWizard(\n params: ReactNativeWizardOptions,\n): Promise<void> {\n return withTelemetry(\n {\n enabled: params.telemetryEnabled,\n integration: 'react-native',\n },\n () => runReactNativeWizardWithTelemetry(params),\n );\n}\n\nexport async function runReactNativeWizardWithTelemetry(\n options: ReactNativeWizardOptions,\n): Promise<void> {\n if (options.uninstall) {\n Sentry.setTag('uninstall', true);\n return runReactNativeUninstall(options);\n }\n\n printWelcome({\n wizardName: 'Sentry React Native Wizard',\n promoCode: options.promoCode,\n telemetryEnabled: options.telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo();\n\n const packageJson = await getPackageDotJson();\n\n await ensurePackageIsInstalled(packageJson, RN_PACKAGE, RN_HUMAN_NAME);\n\n const rnVersion = getPackageVersion(RN_PACKAGE, packageJson);\n if (rnVersion) {\n await confirmContinueIfPackageVersionNotSupported({\n packageName: RN_HUMAN_NAME,\n packageVersion: rnVersion,\n packageId: RN_PACKAGE,\n acceptableVersions: SUPPORTED_RN_RANGE,\n });\n }\n\n const { selectedProject, authToken, sentryUrl } =\n await getOrAskForProjectData(options, 'react-native');\n const orgSlug = selectedProject.organization.slug;\n const projectSlug = selectedProject.slug;\n const projectId = selectedProject.id;\n const cliConfig: RNCliSetupConfigContent = {\n authToken,\n org: orgSlug,\n project: projectSlug,\n url: sentryUrl,\n };\n\n await installPackage({\n packageName: RN_SDK_PACKAGE,\n alreadyInstalled: hasPackageInstalled(RN_SDK_PACKAGE, packageJson),\n });\n const sdkVersion = getPackageVersion(\n RN_SDK_PACKAGE,\n await getPackageDotJson(),\n );\n\n await traceStep('patch-js', () =>\n addSentryInit({ dsn: selectedProject.keys[0].dsn.public }),\n );\n\n await traceStep('patch-metro-config', () =>\n addSentryToMetroConfig({ sdkVersion }),\n );\n\n if (fs.existsSync('ios')) {\n Sentry.setTag('patch-ios', true);\n await traceStep('patch-xcode-files', () =>\n patchXcodeFiles(cliConfig, { sdkVersion }),\n );\n }\n\n if (fs.existsSync('android')) {\n Sentry.setTag('patch-android', true);\n await traceStep('patch-android-files', () => patchAndroidFiles(cliConfig));\n }\n\n const confirmedFirstException = await confirmFirstSentryException(\n sentryUrl,\n orgSlug,\n projectId,\n );\n Sentry.setTag('user-confirmed-first-error', confirmedFirstException);\n\n if (confirmedFirstException) {\n clack.outro(\n `${chalk.green('Everything is set up!')}\n\n ${chalk.dim(\n 'If you encounter any issues, let us know here: https://github.com/getsentry/sentry-react-native/issues',\n )}`,\n );\n } else {\n clack.outro(\n `${chalk.dim(\n 'Let us know here: https://github.com/getsentry/sentry-react-native/issues',\n )}`,\n );\n }\n}\n\nfunction addSentryToMetroConfig({\n sdkVersion,\n}: {\n sdkVersion: string | undefined;\n}) {\n if (\n sdkVersion &&\n fulfillsVersionRange({\n version: sdkVersion,\n acceptableVersions:\n SDK_SENTRY_METRO_WITH_SENTRY_CONFIG_SUPPORTED_SDK_RANGE,\n canBeLatest: true,\n })\n ) {\n return patchMetroWithSentryConfig();\n }\n\n if (\n sdkVersion &&\n fulfillsVersionRange({\n version: sdkVersion,\n acceptableVersions: SDK_SENTRY_METRO_PLUGIN_SUPPORTED_SDK_RANGE,\n canBeLatest: true,\n })\n ) {\n return patchMetroConfigWithSentrySerializer();\n }\n}\n\nasync function addSentryInit({ dsn }: { dsn: string }) {\n const prefixGlob = '{.,./src}';\n const suffixGlob = '@(j|t|cj|mj)s?(x)';\n const universalGlob = `App.${suffixGlob}`;\n const jsFileGlob = `${prefixGlob}/+(${universalGlob})`;\n const jsPath = traceStep('find-app-js-file', () =>\n getFirstMatchedPath(jsFileGlob),\n );\n Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');\n if (!jsPath) {\n clack.log.warn(\n `Could not find main App file using ${chalk.cyan(jsFileGlob)}.`,\n );\n await showCopyPasteInstructions(\n 'App.js',\n getSentryInitColoredCodeSnippet(dsn),\n 'This ensures the Sentry SDK is ready to capture errors.',\n );\n return;\n }\n const jsRelativePath = path.relative(process.cwd(), jsPath);\n\n const js = fs.readFileSync(jsPath, 'utf-8');\n const includesSentry = doesJsCodeIncludeSdkSentryImport(js, {\n sdkPackageName: RN_SDK_PACKAGE,\n });\n if (includesSentry) {\n Sentry.setTag('app-js-file-status', 'already-includes-sentry');\n clack.log.warn(\n `${chalk.cyan(\n jsRelativePath,\n )} already includes Sentry. We wont't add it again.`,\n );\n return;\n }\n\n traceStep('add-sentry-init', () => {\n const newContent = addSentryInitWithSdkImport(js, { dsn });\n\n clack.log.success(\n `Added ${chalk.cyan('Sentry.init')} to ${chalk.cyan(jsRelativePath)}.`,\n );\n\n fs.writeFileSync(jsPath, newContent, 'utf-8');\n });\n\n Sentry.setTag('app-js-file-status', 'added-sentry-init');\n clack.log.success(\n chalk.green(`${chalk.cyan(jsRelativePath)} changes saved.`),\n );\n}\n\nasync function confirmFirstSentryException(\n url: string,\n orgSlug: string,\n projectId: string,\n) {\n const issuesStreamUrl = getIssueStreamUrl({ url, orgSlug, projectId });\n\n clack.log\n .step(`To make sure everything is set up correctly, put the following code snippet into your application.\nThe snippet will create a button that, when tapped, sends a test event to Sentry.\n\nAfter that check your project issues:\n\n${chalk.cyan(issuesStreamUrl)}`);\n\n // We want the code snippet to be easily copy-pasteable, without any clack artifacts\n // eslint-disable-next-line no-console\n console.log(\n chalk.greenBright(`\n<Button title='Try!' onPress={ () => { Sentry.captureException(new Error('First error')) }}/>\n`),\n );\n\n const firstErrorConfirmed = clack.confirm({\n message: `Have you successfully sent a test event?`,\n });\n\n return firstErrorConfirmed;\n}\n\nasync function patchXcodeFiles(\n config: RNCliSetupConfigContent,\n context: {\n sdkVersion: string | undefined;\n },\n) {\n await addSentryCliConfig(config, {\n ...propertiesCliSetupConfig,\n name: 'source maps and iOS debug files',\n filename: 'ios/sentry.properties',\n gitignore: false,\n });\n\n if (platform() === 'darwin' && (await confirmPodInstall())) {\n await traceStep('pod-install', () => podInstall('ios'));\n }\n\n const xcodeProjectPath = traceStep('find-xcode-project', () =>\n getFirstMatchedPath(XCODE_PROJECT),\n );\n Sentry.setTag(\n 'xcode-project-status',\n xcodeProjectPath ? 'found' : 'not-found',\n );\n if (!xcodeProjectPath) {\n clack.log.warn(\n `Could not find Xcode project file using ${chalk.cyan(XCODE_PROJECT)}.`,\n );\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const [xcodeProject, buildPhasesMap] = traceStep(\n 'parse-xcode-project',\n () => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n const project = xcode.project(xcodeProjectPath);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n project.parseSync();\n\n const map = getValidExistingBuildPhases(project);\n return [project, map];\n },\n );\n Sentry.setTag('xcode-project-status', 'parsed');\n\n traceStep('patch-bundle-phase', () => {\n const bundlePhase = findBundlePhase(buildPhasesMap);\n Sentry.setTag(\n 'xcode-bundle-phase-status',\n bundlePhase ? 'found' : 'not-found',\n );\n if (\n context.sdkVersion &&\n fulfillsVersionRange({\n version: context.sdkVersion,\n acceptableVersions: SDK_XCODE_SCRIPTS_SUPPORTED_SDK_RANGE,\n canBeLatest: true,\n })\n ) {\n patchBundlePhase(\n bundlePhase,\n addSentryWithBundledScriptsToBundleShellScript,\n );\n } else {\n patchBundlePhase(bundlePhase, addSentryWithCliToBundleShellScript);\n }\n Sentry.setTag('xcode-bundle-phase-status', 'patched');\n });\n\n traceStep('add-debug-files-upload-phase', () => {\n const debugFilesUploadPhaseExists =\n !!findDebugFilesUploadPhase(buildPhasesMap);\n Sentry.setTag(\n 'xcode-debug-files-upload-phase-status',\n debugFilesUploadPhaseExists ? 'already-exists' : undefined,\n );\n if (\n context.sdkVersion &&\n fulfillsVersionRange({\n version: context.sdkVersion,\n acceptableVersions: SDK_XCODE_SCRIPTS_SUPPORTED_SDK_RANGE,\n canBeLatest: true,\n })\n ) {\n addDebugFilesUploadPhaseWithBundledScripts(xcodeProject, {\n debugFilesUploadPhaseExists,\n });\n } else {\n addDebugFilesUploadPhaseWithCli(xcodeProject, {\n debugFilesUploadPhaseExists,\n });\n }\n Sentry.setTag('xcode-debug-files-upload-phase-status', 'added');\n });\n\n traceStep('write-xcode-project', () => {\n writeXcodeProject(xcodeProjectPath, xcodeProject);\n });\n Sentry.setTag('xcode-project-status', 'patched');\n}\n\nasync function patchAndroidFiles(config: RNCliSetupConfigContent) {\n await addSentryCliConfig(config, {\n ...propertiesCliSetupConfig,\n name: 'source maps and iOS debug files',\n filename: 'android/sentry.properties',\n gitignore: false,\n });\n\n const appBuildGradlePath = traceStep('find-app-build-gradle', () =>\n getFirstMatchedPath(APP_BUILD_GRADLE),\n );\n Sentry.setTag(\n 'app-build-gradle-status',\n appBuildGradlePath ? 'found' : 'not-found',\n );\n if (!appBuildGradlePath) {\n clack.log.warn(\n `Could not find Android ${chalk.cyan(\n 'app/build.gradle',\n )} file using ${chalk.cyan(APP_BUILD_GRADLE)}.`,\n );\n return;\n }\n\n const appBuildGradle = traceStep('read-app-build-gradle', () =>\n fs.readFileSync(appBuildGradlePath, 'utf-8'),\n );\n const includesSentry =\n doesAppBuildGradleIncludeRNSentryGradlePlugin(appBuildGradle);\n if (includesSentry) {\n Sentry.setTag('app-build-gradle-status', 'already-includes-sentry');\n clack.log.warn(\n `Android ${chalk.cyan('app/build.gradle')} file already includes Sentry.`,\n );\n return;\n }\n\n const patchedAppBuildGradle = traceStep('add-rn-sentry-gradle-plugin', () =>\n addRNSentryGradlePlugin(appBuildGradle),\n );\n if (!doesAppBuildGradleIncludeRNSentryGradlePlugin(patchedAppBuildGradle)) {\n Sentry.setTag(\n 'app-build-gradle-status',\n 'failed-to-add-rn-sentry-gradle-plugin',\n );\n clack.log.warn(\n `Could not add Sentry RN Gradle Plugin to ${chalk.cyan(\n 'app/build.gradle',\n )}.`,\n );\n return;\n }\n\n Sentry.setTag('app-build-gradle-status', 'added-rn-sentry-gradle-plugin');\n clack.log.success(\n `Added Sentry RN Gradle Plugin to ${chalk.bold('app/build.gradle')}.`,\n );\n\n traceStep('write-app-build-gradle', () =>\n writeAppBuildGradle(appBuildGradlePath, patchedAppBuildGradle),\n );\n clack.log.success(\n chalk.green(`Android ${chalk.cyan('app/build.gradle')} saved.`),\n );\n}\n\nasync function confirmPodInstall(): Promise<boolean> {\n return traceStep('confirm-pod-install', async () => {\n const continueWithPodInstall = await abortIfCancelled(\n clack.select({\n message: 'Do you want to run `pod install` now?',\n options: [\n {\n value: true,\n label: 'Yes',\n hint: 'Recommended for smaller projects, this might take several minutes',\n },\n { value: false, label: `No, I'll do it later` },\n ],\n initialValue: true,\n }),\n );\n Sentry.setTag('continue-with-pod-install', continueWithPodInstall);\n return continueWithPodInstall;\n });\n}\n"]}
@@ -83,7 +83,7 @@ export declare function printJsonC(ast: t.Program): string;
83
83
  * Walks the program body and returns index of the last variable assignment initialized by require statement.
84
84
  * Only counts top level require statements.
85
85
  *
86
- * @returns index of the last `const foo = require('bar');` statement
86
+ * @returns index of the last `const foo = require('bar');` statement or -1 if none was found.
87
87
  */
88
88
  export declare function getLastRequireIndex(program: t.Program): number;
89
89
  /**
@@ -212,10 +212,10 @@ exports.printJsonC = printJsonC;
212
212
  * Walks the program body and returns index of the last variable assignment initialized by require statement.
213
213
  * Only counts top level require statements.
214
214
  *
215
- * @returns index of the last `const foo = require('bar');` statement
215
+ * @returns index of the last `const foo = require('bar');` statement or -1 if none was found.
216
216
  */
217
217
  function getLastRequireIndex(program) {
218
- var lastRequireIdex = 0;
218
+ var lastRequireIdex = -1;
219
219
  program.body.forEach(function (s, i) {
220
220
  if (s.type === 'VariableDeclaration' &&
221
221
  s.declarations[0].type === 'VariableDeclarator' &&
@@ -1 +1 @@
1
- {"version":3,"file":"ast-utils.js","sourceRoot":"","sources":["../../../src/utils/ast-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AAEzB,6CAAiC;AAIjC,IAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;AAEhC;;;GAGG;AACH,SAAgB,QAAQ,CACtB,QAAgB,EAChB,SAAoD;IAApD,0BAAA,EAAA,aAAuB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC;IAEpD,OAAO,SAAS;SACb,GAAG,CAAC,UAAC,IAAI,IAAK,OAAA,UAAG,QAAQ,SAAG,IAAI,CAAE,EAApB,CAAoB,CAAC;SACnC,IAAI,CAAC,UAAC,IAAI,IAAK,OAAA,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAnB,CAAmB,CAAC,CAAC;AACzC,CAAC;AAPD,4BAOC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,OAAkB;IACjD,IAAI,WAAW,GAAwB,KAAK,CAAC;IAC7C,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE;QACpB,kBAAkB,YAAC,IAAI;YACrB,WAAW,GAAG,W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AAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS;YAChD,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe;YAC5D,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EAC7D;YACA,iBAAiB,GAAG,IAAI,CAAC;YACzB,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AApBD,sCAoBC","sourcesContent":["import * as fs from 'fs';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nconst b = recast.types.builders;\n\n/**\n * Checks if a file where we don't know its concrete file type yet exists\n * and returns the full path to the file with the correct file type.\n */\nexport function findFile(\n filePath: string,\n fileTypes: string[] = ['.js', '.ts', '.mjs', '.cjs'],\n): string | undefined {\n return fileTypes\n .map((type) => `${filePath}${type}`)\n .find((file) => fs.existsSync(file));\n}\n\n/**\n * checks for require('@sentry/*') syntax\n */\nexport function hasSentryContent(program: t.Program): boolean {\n let foundSentry: boolean | undefined = false;\n recast.visit(program, {\n visitStringLiteral(path) {\n foundSentry = foundSentry || path.node.value.startsWith('@sentry/');\n this.traverse(path);\n },\n visitLiteral(path) {\n foundSentry =\n foundSentry || path.node.value?.toString().startsWith('@sentry/');\n this.traverse(path);\n },\n });\n\n return !!foundSentry;\n}\n\n/**\n * Searches for a property of an ObjectExpression by name\n *\n * @param object the ObjectExpression to search in\n * @param name the name of the property to search for\n *\n * @returns the property if it exists\n */\nexport function getObjectProperty(\n object: t.ObjectExpression,\n name: string,\n): t.Property | undefined {\n return object.properties.find((p): p is t.Property => {\n const isObjectProp = p.type === 'Property' || p.type === 'ObjectProperty';\n\n if (!isObjectProp) {\n return false;\n }\n\n const hasMatchingLiteralKey =\n isObjectProp &&\n (p.key.type === 'Literal' || p.key.type === 'StringLiteral') &&\n p.key.value === name;\n\n if (hasMatchingLiteralKey) {\n return true;\n }\n\n // has matching identifier key\n return isObjectProp && p.key.type === 'Identifier' && p.key.name === name;\n });\n}\n\n/**\n * Attempts to find a property of an ObjectExpression by name. If it doesn't exist,\n * the property will be added to the ObjectExpression with the provided default value.\n *\n * @param object the parent object expression to search in\n * @param name the name of the property to search for\n * @param defaultValue the default value to set if the property doesn't exist\n *\n * @returns the\n */\nexport function getOrSetObjectProperty(\n object: t.ObjectExpression,\n name: string,\n defaultValue:\n | t.Literal\n | t.BooleanLiteral\n | t.StringLiteral\n | t.ObjectExpression,\n): t.Property {\n const existingProperty = getObjectProperty(object, name);\n\n if (existingProperty) {\n return existingProperty;\n }\n\n const newProperty = b.property.from({\n kind: 'init',\n key: b.stringLiteral(name),\n value: defaultValue,\n });\n\n object.properties.push(newProperty);\n\n return newProperty;\n}\n\n/**\n * Sets a property of an ObjectExpression if it exists, otherwise adds it\n * to the ObjectExpression. Optionally, a comment can be added to the\n * property.\n *\n * @param object the ObjectExpression to set the property on\n * @param name the name of the property to set\n * @param value the value of the property to set\n * @param comment (optional) a comment to add to the property\n */\nexport function setOrUpdateObjectProperty(\n object: t.ObjectExpression,\n name: string,\n value: t.Literal | t.BooleanLiteral | t.StringLiteral | t.ObjectExpression,\n comment?: string,\n) {\n const newComments =\n comment &&\n comment.split('\\n').map((c) => b.commentLine(` ${c}`, true, false));\n\n const existingProperty = getObjectProperty(object, name);\n\n if (existingProperty) {\n existingProperty.value = value;\n if (newComments) {\n existingProperty.comments = [\n ...(existingProperty?.comments || []),\n ...newComments,\n ];\n }\n } else {\n object.properties.push(\n b.objectProperty.from({\n key: b.stringLiteral(name),\n value,\n ...(newComments && {\n comments: newComments,\n }),\n }),\n );\n }\n}\n\ntype JsonCParseResult =\n | {\n jsonObject: t.ObjectExpression;\n ast: t.Program;\n }\n | {\n jsonObject: undefined;\n ast: undefined;\n };\n\n/**\n * Parses a JSON string with (potential) comments (JSON-C) and returns the JS AST\n * that can be walked and modified with recast like a normal JS AST.\n *\n * This is done by wrapping the JSON-C string in parentheses, thereby making it\n * a JS `Program` with an `ExpressionStatement` as its body. The expression is then\n * extracted from the AST and returned alongside the AST.\n *\n * To preserve as much original formatting as possible, the returned `ast`\n * property should be passed to {@link `printJsonC`} to get the JSON-C string back.\n *\n * If the input is not valid JSON-C, the result will be undefined.\n *\n * @see {@link JsonCParseResult}\n *\n * @param jsonString a JSON-C string\n *\n * @returns a {@link JsonCParseResult}, containing either the JSON-C object and the AST or undefined in both cases\n */\nexport function parseJsonC(jsonString: string): JsonCParseResult {\n try {\n const jsTsConfig = `(${jsonString})`;\n // no idea why recast returns any here, this is dumb :/\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const ast = recast.parse(jsTsConfig.toString()).program as t.Program;\n\n const jsonObject =\n (ast.body[0].type === 'ExpressionStatement' &&\n ast.body[0].expression.type === 'ObjectExpression' &&\n ast.body[0].expression) ||\n undefined;\n\n if (jsonObject) {\n return { jsonObject, ast };\n }\n } catch {\n /* empty */\n }\n return { jsonObject: undefined, ast: undefined };\n}\n\n/**\n * Takes the AST of a parsed JSON-C \"program\" and returns the JSON-C string without\n * any of the temporary JS wrapper code that was previously applied.\n *\n * Only use this in conjunction with {@link `parseJsonC`}\n *\n * @param ast the `ast` returned from {@link `parseJsonC`}\n *\n * @returns the JSON-C string\n */\nexport function printJsonC(ast: t.Program): string {\n const js = recast.print(ast).code;\n return js.substring(1, js.length - 1);\n}\n\n/**\n * Walks the program body and returns index of the last variable assignment initialized by require statement.\n * Only counts top level require statements.\n *\n * @returns index of the last `const foo = require('bar');` statement\n */\nexport function getLastRequireIndex(program: t.Program): number {\n let lastRequireIdex = 0;\n program.body.forEach((s, i) => {\n if (\n s.type === 'VariableDeclaration' &&\n s.declarations[0].type === 'VariableDeclarator' &&\n s.declarations[0].init !== null &&\n typeof s.declarations[0].init !== 'undefined' &&\n s.declarations[0].init.type === 'CallExpression' &&\n s.declarations[0].init.callee.type === 'Identifier' &&\n s.declarations[0].init.callee.name === 'require'\n ) {\n lastRequireIdex = i;\n }\n });\n return lastRequireIdex;\n}\n\n/**\n * Walks the statements and removes require statements which first argument includes the predicate.\n * Only removes top level require statements like `const foo = require('bar');`\n *\n * @returns True if any require statement was removed.\n */\nexport function removeRequire(program: t.Program, predicate: string): boolean {\n let removedAtLeastOne = false;\n program.body = program.body.filter((s) => {\n if (\n s.type === 'VariableDeclaration' &&\n s.declarations[0].type === 'VariableDeclarator' &&\n s.declarations[0].init !== null &&\n typeof s.declarations[0].init !== 'undefined' &&\n s.declarations[0].init.type === 'CallExpression' &&\n s.declarations[0].init.callee.type === 'Identifier' &&\n s.declarations[0].init.callee.name === 'require' &&\n s.declarations[0].init.arguments[0].type === 'StringLiteral' &&\n s.declarations[0].init.arguments[0].value.includes(predicate)\n ) {\n removedAtLeastOne = true;\n return false;\n }\n return true;\n });\n return removedAtLeastOne;\n}\n"]}
1
+ {"version":3,"file":"ast-utils.js","sourceRoot":"","sources":["../../../src/utils/ast-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AAEzB,6CAAiC;AAIjC,IAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;AAEhC;;;GAGG;AACH,SAAgB,QAAQ,CACtB,QAAgB,EAChB,SAAoD;IAApD,0BAAA,EAAA,aAAuB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC;IAEpD,OAAO,SAAS;SACb,GAAG,CAAC,UAAC,IAAI,IAAK,OAAA,UAAG,QAAQ,SAAG,IAAI,CAAE,EAApB,CAAoB,CAAC;SACnC,IAAI,CAAC,UAAC,IAAI,IAAK,OAAA,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAnB,CAAmB,CAAC,C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AC7C,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,gBAAgB;YAChD,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,YAAY;YACnD,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS;YAChD,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe;YAC5D,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EAC7D;YACA,iBAAiB,GAAG,IAAI,CAAC;YACzB,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AApBD,sCAoBC","sourcesContent":["import * as fs from 'fs';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nconst b = recast.types.builders;\n\n/**\n * Checks if a file where we don't know its concrete file type yet exists\n * and returns the full path to the file with the correct file type.\n */\nexport function findFile(\n filePath: string,\n fileTypes: string[] = ['.js', '.ts', '.mjs', '.cjs'],\n): string | undefined {\n return fileTypes\n .map((type) => `${filePath}${type}`)\n .find((file) => fs.existsSync(file));\n}\n\n/**\n * checks for require('@sentry/*') syntax\n */\nexport function hasSentryContent(program: t.Program): boolean {\n let foundSentry: boolean | undefined = false;\n recast.visit(program, {\n visitStringLiteral(path) {\n foundSentry = foundSentry || path.node.value.startsWith('@sentry/');\n this.traverse(path);\n },\n visitLiteral(path) {\n foundSentry =\n foundSentry || path.node.value?.toString().startsWith('@sentry/');\n this.traverse(path);\n },\n });\n\n return !!foundSentry;\n}\n\n/**\n * Searches for a property of an ObjectExpression by name\n *\n * @param object the ObjectExpression to search in\n * @param name the name of the property to search for\n *\n * @returns the property if it exists\n */\nexport function getObjectProperty(\n object: t.ObjectExpression,\n name: string,\n): t.Property | undefined {\n return object.properties.find((p): p is t.Property => {\n const isObjectProp = p.type === 'Property' || p.type === 'ObjectProperty';\n\n if (!isObjectProp) {\n return false;\n }\n\n const hasMatchingLiteralKey =\n isObjectProp &&\n (p.key.type === 'Literal' || p.key.type === 'StringLiteral') &&\n p.key.value === name;\n\n if (hasMatchingLiteralKey) {\n return true;\n }\n\n // has matching identifier key\n return isObjectProp && p.key.type === 'Identifier' && p.key.name === name;\n });\n}\n\n/**\n * Attempts to find a property of an ObjectExpression by name. If it doesn't exist,\n * the property will be added to the ObjectExpression with the provided default value.\n *\n * @param object the parent object expression to search in\n * @param name the name of the property to search for\n * @param defaultValue the default value to set if the property doesn't exist\n *\n * @returns the\n */\nexport function getOrSetObjectProperty(\n object: t.ObjectExpression,\n name: string,\n defaultValue:\n | t.Literal\n | t.BooleanLiteral\n | t.StringLiteral\n | t.ObjectExpression,\n): t.Property {\n const existingProperty = getObjectProperty(object, name);\n\n if (existingProperty) {\n return existingProperty;\n }\n\n const newProperty = b.property.from({\n kind: 'init',\n key: b.stringLiteral(name),\n value: defaultValue,\n });\n\n object.properties.push(newProperty);\n\n return newProperty;\n}\n\n/**\n * Sets a property of an ObjectExpression if it exists, otherwise adds it\n * to the ObjectExpression. Optionally, a comment can be added to the\n * property.\n *\n * @param object the ObjectExpression to set the property on\n * @param name the name of the property to set\n * @param value the value of the property to set\n * @param comment (optional) a comment to add to the property\n */\nexport function setOrUpdateObjectProperty(\n object: t.ObjectExpression,\n name: string,\n value: t.Literal | t.BooleanLiteral | t.StringLiteral | t.ObjectExpression,\n comment?: string,\n) {\n const newComments =\n comment &&\n comment.split('\\n').map((c) => b.commentLine(` ${c}`, true, false));\n\n const existingProperty = getObjectProperty(object, name);\n\n if (existingProperty) {\n existingProperty.value = value;\n if (newComments) {\n existingProperty.comments = [\n ...(existingProperty?.comments || []),\n ...newComments,\n ];\n }\n } else {\n object.properties.push(\n b.objectProperty.from({\n key: b.stringLiteral(name),\n value,\n ...(newComments && {\n comments: newComments,\n }),\n }),\n );\n }\n}\n\ntype JsonCParseResult =\n | {\n jsonObject: t.ObjectExpression;\n ast: t.Program;\n }\n | {\n jsonObject: undefined;\n ast: undefined;\n };\n\n/**\n * Parses a JSON string with (potential) comments (JSON-C) and returns the JS AST\n * that can be walked and modified with recast like a normal JS AST.\n *\n * This is done by wrapping the JSON-C string in parentheses, thereby making it\n * a JS `Program` with an `ExpressionStatement` as its body. The expression is then\n * extracted from the AST and returned alongside the AST.\n *\n * To preserve as much original formatting as possible, the returned `ast`\n * property should be passed to {@link `printJsonC`} to get the JSON-C string back.\n *\n * If the input is not valid JSON-C, the result will be undefined.\n *\n * @see {@link JsonCParseResult}\n *\n * @param jsonString a JSON-C string\n *\n * @returns a {@link JsonCParseResult}, containing either the JSON-C object and the AST or undefined in both cases\n */\nexport function parseJsonC(jsonString: string): JsonCParseResult {\n try {\n const jsTsConfig = `(${jsonString})`;\n // no idea why recast returns any here, this is dumb :/\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const ast = recast.parse(jsTsConfig.toString()).program as t.Program;\n\n const jsonObject =\n (ast.body[0].type === 'ExpressionStatement' &&\n ast.body[0].expression.type === 'ObjectExpression' &&\n ast.body[0].expression) ||\n undefined;\n\n if (jsonObject) {\n return { jsonObject, ast };\n }\n } catch {\n /* empty */\n }\n return { jsonObject: undefined, ast: undefined };\n}\n\n/**\n * Takes the AST of a parsed JSON-C \"program\" and returns the JSON-C string without\n * any of the temporary JS wrapper code that was previously applied.\n *\n * Only use this in conjunction with {@link `parseJsonC`}\n *\n * @param ast the `ast` returned from {@link `parseJsonC`}\n *\n * @returns the JSON-C string\n */\nexport function printJsonC(ast: t.Program): string {\n const js = recast.print(ast).code;\n return js.substring(1, js.length - 1);\n}\n\n/**\n * Walks the program body and returns index of the last variable assignment initialized by require statement.\n * Only counts top level require statements.\n *\n * @returns index of the last `const foo = require('bar');` statement or -1 if none was found.\n */\nexport function getLastRequireIndex(program: t.Program): number {\n let lastRequireIdex = -1;\n program.body.forEach((s, i) => {\n if (\n s.type === 'VariableDeclaration' &&\n s.declarations[0].type === 'VariableDeclarator' &&\n s.declarations[0].init !== null &&\n typeof s.declarations[0].init !== 'undefined' &&\n s.declarations[0].init.type === 'CallExpression' &&\n s.declarations[0].init.callee.type === 'Identifier' &&\n s.declarations[0].init.callee.name === 'require'\n ) {\n lastRequireIdex = i;\n }\n });\n return lastRequireIdex;\n}\n\n/**\n * Walks the statements and removes require statements which first argument includes the predicate.\n * Only removes top level require statements like `const foo = require('bar');`\n *\n * @returns True if any require statement was removed.\n */\nexport function removeRequire(program: t.Program, predicate: string): boolean {\n let removedAtLeastOne = false;\n program.body = program.body.filter((s) => {\n if (\n s.type === 'VariableDeclaration' &&\n s.declarations[0].type === 'VariableDeclarator' &&\n s.declarations[0].init !== null &&\n typeof s.declarations[0].init !== 'undefined' &&\n s.declarations[0].init.type === 'CallExpression' &&\n s.declarations[0].init.callee.type === 'Identifier' &&\n s.declarations[0].init.callee.name === 'require' &&\n s.declarations[0].init.arguments[0].type === 'StringLiteral' &&\n s.declarations[0].init.arguments[0].value.includes(predicate)\n ) {\n removedAtLeastOne = true;\n return false;\n }\n return true;\n });\n return removedAtLeastOne;\n}\n"]}
@@ -5,7 +5,7 @@ describe('react-native javascript', function () {
5
5
  describe('addSentryInitWithSdkImport', function () {
6
6
  it('adds sdk import and sentry init under last import in the file', function () {
7
7
  var input = "import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;";
8
- var expectedOutput = "import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nimport * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: 'dsn',\n});\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;";
8
+ var expectedOutput = "import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nimport * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: 'dsn',\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // enableSpotlight: __DEV__,\n});\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;";
9
9
  expect((0, javascript_1.addSentryInitWithSdkImport)(input, { dsn: 'dsn' })).toBe(expectedOutput);
10
10
  });
11
11
  it('does not add sdk import and sentry init in the file without imports', function () {
@@ -1 +1 @@
1
- {"version":3,"file":"javascript.test.js","sourceRoot":"","sources":["../../../test/react-native/javascript.test.ts"],"names":[],"mappings":";;AAAA,gEAG2C;AAE3C,QAAQ,CAAC,yBAAyB,EAAE;IAClC,QAAQ,CAAC,4BAA4B,EAAE;QACrC,EAAE,CAAC,+DAA+D,EAAE;YAClE,IAAM,KAAK,GAAG,8MAcA,CAAC;YAEf,IAAM,cAAc,GAAG,oSAmBT,CAAC;YAEf,MAAM,CAAC,IAAA,uCAA0B,EAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAC5D,cAAc,CACf,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,qEAAqE,EAAE;YACxE,IAAM,KAAK,GAAG,6BAA6B,CAAC;YAC5C,MAAM,CAAC,IAAA,uCAA0B,EAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,2DAA2D,EAAE;YAC9D,IAAM,KAAK,GAAG,EAAE,CAAC;YACjB,MAAM,CAAC,IAAA,uCAA0B,EAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kCAAkC,EAAE;QAC3C,EAAE,CAAC,qCAAqC,EAAE;YACxC,IAAM,KAAK,GAAG,+PAeA,CAAC;YAEf,MAAM,CACJ,IAAA,6CAAgC,EAAC,KAAK,EAAE;gBACtC,cAAc,EAAE,sBAAsB;aACvC,CAAC,CACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sCAAsC,EAAE;YACzC,IAAM,KAAK,GAAG,+PAeA,CAAC;YAEf,MAAM,CACJ,IAAA,6CAAgC,EAAC,KAAK,EAAE;gBACtC,cAAc,EAAE,sBAAsB;aACvC,CAAC,CACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,gDAAgD,EAAE;YACnD,IAAM,KAAK,GAAG,6BAA6B,CAAC;YAC5C,MAAM,CACJ,IAAA,6CAAgC,EAAC,KAAK,EAAE;gBACtC,cAAc,EAAE,sBAAsB;aACvC,CAAC,CACH,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8BAA8B,EAAE;YACjC,IAAM,KAAK,GAAG,EAAE,CAAC;YACjB,MAAM,CACJ,IAAA,6CAAgC,EAAC,KAAK,EAAE;gBACtC,cAAc,EAAE,sBAAsB;aACvC,CAAC,CACH,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n addSentryInitWithSdkImport,\n doesJsCodeIncludeSdkSentryImport,\n} from '../../src/react-native/javascript';\n\ndescribe('react-native javascript', () => {\n describe('addSentryInitWithSdkImport', () => {\n it('adds sdk import and sentry init under last import in the file', () => {\n const input = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n const expectedOutput = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nimport * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: 'dsn',\n});\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(\n expectedOutput,\n );\n });\n\n it('does not add sdk import and sentry init in the file without imports', () => {\n const input = `export const test = 'test';`;\n expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(input);\n });\n\n it('does not add sdk import and sentry init in the empty file', () => {\n const input = '';\n expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(input);\n });\n });\n\n describe('doesJsCodeIncludeSdkSentryImport', () => {\n it('returns true if code has sdk import', () => {\n const input = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nimport * as Sentry from '@sentry/react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(true);\n });\n\n it('returns true if code has sdk require', () => {\n const input = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nconst Sentry = require('@sentry/react-native');\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(true);\n });\n\n it('returns false if code does not have sdk import', () => {\n const input = `export const test = 'test';`;\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(false);\n });\n\n it('returns false for empty file', () => {\n const input = '';\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(false);\n });\n });\n});\n"]}
1
+ {"version":3,"file":"javascript.test.js","sourceRoot":"","sources":["../../../test/react-native/javascript.test.ts"],"names":[],"mappings":";;AAAA,gEAG2C;AAE3C,QAAQ,CAAC,yBAAyB,EAAE;IAClC,QAAQ,CAAC,4BAA4B,EAAE;QACrC,EAAE,CAAC,+DAA+D,EAAE;YAClE,IAAM,KAAK,GAAG,8MAcA,CAAC;YAEf,IAAM,cAAc,GAAG,mZAsBT,CAAC;YAEf,MAAM,CAAC,IAAA,uCAA0B,EAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAC5D,cAAc,CACf,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,qEAAqE,EAAE;YACxE,IAAM,KAAK,GAAG,6BAA6B,CAAC;YAC5C,MAAM,CAAC,IAAA,uCAA0B,EAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,2DAA2D,EAAE;YAC9D,IAAM,KAAK,GAAG,EAAE,CAAC;YACjB,MAAM,CAAC,IAAA,uCAA0B,EAAC,KAAK,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,kCAAkC,EAAE;QAC3C,EAAE,CAAC,qCAAqC,EAAE;YACxC,IAAM,KAAK,GAAG,+PAeA,CAAC;YAEf,MAAM,CACJ,IAAA,6CAAgC,EAAC,KAAK,EAAE;gBACtC,cAAc,EAAE,sBAAsB;aACvC,CAAC,CACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sCAAsC,EAAE;YACzC,IAAM,KAAK,GAAG,+PAeA,CAAC;YAEf,MAAM,CACJ,IAAA,6CAAgC,EAAC,KAAK,EAAE;gBACtC,cAAc,EAAE,sBAAsB;aACvC,CAAC,CACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,gDAAgD,EAAE;YACnD,IAAM,KAAK,GAAG,6BAA6B,CAAC;YAC5C,MAAM,CACJ,IAAA,6CAAgC,EAAC,KAAK,EAAE;gBACtC,cAAc,EAAE,sBAAsB;aACvC,CAAC,CACH,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8BAA8B,EAAE;YACjC,IAAM,KAAK,GAAG,EAAE,CAAC;YACjB,MAAM,CACJ,IAAA,6CAAgC,EAAC,KAAK,EAAE;gBACtC,cAAc,EAAE,sBAAsB;aACvC,CAAC,CACH,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n addSentryInitWithSdkImport,\n doesJsCodeIncludeSdkSentryImport,\n} from '../../src/react-native/javascript';\n\ndescribe('react-native javascript', () => {\n describe('addSentryInitWithSdkImport', () => {\n it('adds sdk import and sentry init under last import in the file', () => {\n const input = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n const expectedOutput = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nimport * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: 'dsn',\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // enableSpotlight: __DEV__,\n});\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(\n expectedOutput,\n );\n });\n\n it('does not add sdk import and sentry init in the file without imports', () => {\n const input = `export const test = 'test';`;\n expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(input);\n });\n\n it('does not add sdk import and sentry init in the empty file', () => {\n const input = '';\n expect(addSentryInitWithSdkImport(input, { dsn: 'dsn' })).toBe(input);\n });\n });\n\n describe('doesJsCodeIncludeSdkSentryImport', () => {\n it('returns true if code has sdk import', () => {\n const input = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nimport * as Sentry from '@sentry/react-native';\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(true);\n });\n\n it('returns true if code has sdk require', () => {\n const input = `import * as React from 'react';\n\nconst test = 'test';\n\nimport { View } from 'react-native';\nconst Sentry = require('@sentry/react-native');\n\nconst App = () => {\n return (\n <View>\n Test App\n </View>\n );\n};\n\nexport default App;`;\n\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(true);\n });\n\n it('returns false if code does not have sdk import', () => {\n const input = `export const test = 'test';`;\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(false);\n });\n\n it('returns false for empty file', () => {\n const input = '';\n expect(\n doesJsCodeIncludeSdkSentryImport(input, {\n sdkPackageName: '@sentry/react-native',\n }),\n ).toBe(false);\n });\n });\n});\n"]}
@@ -1,9 +1,124 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  // @ts-ignore - magicast is ESM and TS complains about that. It works though
4
40
  var magicast_1 = require("magicast");
5
41
  var metro_1 = require("../../src/react-native/metro");
6
42
  describe('patch metro config - sentry serializer', function () {
43
+ describe('patchMetroWithSentryConfigInMemory', function () {
44
+ it('patches react native 0.72 default metro config', function () { return __awaiter(void 0, void 0, void 0, function () {
45
+ var mod, result;
46
+ return __generator(this, function (_a) {
47
+ switch (_a.label) {
48
+ case 0:
49
+ mod = (0, magicast_1.parseModule)("const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\n\n/**\n * Metro configuration\n * https://reactnative.dev/docs/metro\n *\n * @type {import('metro-config').MetroConfig}\n */\nconst config = {};\n\nmodule.exports = mergeConfig(getDefaultConfig(__dirname), config);");
50
+ return [4 /*yield*/, (0, metro_1.patchMetroWithSentryConfigInMemory)(mod, function () { return __awaiter(void 0, void 0, void 0, function () {
51
+ return __generator(this, function (_a) {
52
+ return [2 /*return*/];
53
+ });
54
+ }); })];
55
+ case 1:
56
+ result = _a.sent();
57
+ expect(result).toBe(true);
58
+ expect((0, magicast_1.generateCode)(mod.$ast).code)
59
+ .toBe("const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\n\nconst {\n withSentryConfig\n} = require(\"@sentry/react-native/metro\");\n\n/**\n * Metro configuration\n * https://reactnative.dev/docs/metro\n *\n * @type {import('metro-config').MetroConfig}\n */\nconst config = {};\n\nmodule.exports = withSentryConfig(mergeConfig(getDefaultConfig(__dirname), config));");
60
+ return [2 /*return*/];
61
+ }
62
+ });
63
+ }); });
64
+ it('patches react native 0.65 default metro config', function () { return __awaiter(void 0, void 0, void 0, function () {
65
+ var mod, result;
66
+ return __generator(this, function (_a) {
67
+ switch (_a.label) {
68
+ case 0:
69
+ mod = (0, magicast_1.parseModule)("/**\n* Metro configuration for React Native\n* https://github.com/facebook/react-native\n*\n* @format\n*/\n\nmodule.exports = {\n transformer: {\n getTransformOptions: async () => ({\n transform: {\n experimentalImportSupport: false,\n inlineRequires: true,\n },\n }),\n },\n};");
70
+ return [4 /*yield*/, (0, metro_1.patchMetroWithSentryConfigInMemory)(mod, function () { return __awaiter(void 0, void 0, void 0, function () {
71
+ return __generator(this, function (_a) {
72
+ return [2 /*return*/];
73
+ });
74
+ }); })];
75
+ case 1:
76
+ result = _a.sent();
77
+ expect(result).toBe(true);
78
+ expect((0, magicast_1.generateCode)(mod.$ast).code).toBe("const {\n withSentryConfig\n} = require(\"@sentry/react-native/metro\");\n\n/**\n* Metro configuration for React Native\n* https://github.com/facebook/react-native\n*\n* @format\n*/\n\nmodule.exports = withSentryConfig({\n transformer: {\n getTransformOptions: async () => ({\n transform: {\n experimentalImportSupport: false,\n inlineRequires: true,\n },\n }),\n },\n});");
79
+ return [2 /*return*/];
80
+ }
81
+ });
82
+ }); });
83
+ it('patches react native metro config exported variable', function () { return __awaiter(void 0, void 0, void 0, function () {
84
+ var mod, result;
85
+ return __generator(this, function (_a) {
86
+ switch (_a.label) {
87
+ case 0:
88
+ mod = (0, magicast_1.parseModule)("const testConfig = {};\n\nmodule.exports = testConfig;");
89
+ return [4 /*yield*/, (0, metro_1.patchMetroWithSentryConfigInMemory)(mod, function () { return __awaiter(void 0, void 0, void 0, function () {
90
+ return __generator(this, function (_a) {
91
+ return [2 /*return*/];
92
+ });
93
+ }); })];
94
+ case 1:
95
+ result = _a.sent();
96
+ expect(result).toBe(true);
97
+ expect((0, magicast_1.generateCode)(mod.$ast).code).toBe("const {\n withSentryConfig\n} = require(\"@sentry/react-native/metro\");\n\nconst testConfig = {};\n\nmodule.exports = withSentryConfig(testConfig);");
98
+ return [2 /*return*/];
99
+ }
100
+ });
101
+ }); });
102
+ it('does not patch react native metro config exported as factory function', function () { return __awaiter(void 0, void 0, void 0, function () {
103
+ var mod, result;
104
+ return __generator(this, function (_a) {
105
+ switch (_a.label) {
106
+ case 0:
107
+ mod = (0, magicast_1.parseModule)("module.exports = () => ({});");
108
+ return [4 /*yield*/, (0, metro_1.patchMetroWithSentryConfigInMemory)(mod, function () { return __awaiter(void 0, void 0, void 0, function () {
109
+ return __generator(this, function (_a) {
110
+ return [2 /*return*/];
111
+ });
112
+ }); })];
113
+ case 1:
114
+ result = _a.sent();
115
+ expect(result).toBe(false);
116
+ expect((0, magicast_1.generateCode)(mod.$ast).code).toBe("module.exports = () => ({});");
117
+ return [2 /*return*/];
118
+ }
119
+ });
120
+ }); });
121
+ });
7
122
  describe('addSentrySerializerToMetroConfig', function () {
8
123
  it('add to empty config', function () {
9
124
  var mod = (0, magicast_1.parseModule)("module.exports = {\n other: 'config'\n }");
@@ -1 +1 @@
1
- {"version":3,"file":"metro.test.js","sourceRoot":"","sources":["../../../test/react-native/metro.test.ts"],"names":[],"mappings":";;AAAA,4EAA4E;AAC5E,qCAA2E;AAM3E,sDAMsC;AAEtC,QAAQ,CAAC,wCAAwC,EAAE;IACjD,QAAQ,CAAC,kCAAkC,EAAE;QAC3C,EAAE,CAAC,qBAAqB,EAAE;YACxB,IAAM,GAAG,GAAG,IAAA,sBAAW,EAAC,sDAEtB,CAAC,CAAC;YACJ,IAAM,YAAY,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC;YACjD,IAAM,MAAM,GAAG,IAAA,wCAAgC,EAAC,YAAY,CAAC,CAAC;YAC9D,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,MAAM,CAAC,IAAA,uBAAY,EAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,wHAM7C,CAAC,CAAC;QACA,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,mCAAmC,EAAE;YACtC,IAAM,GAAG,GAAG,IAAA,sBAAW,EAAC,sFAK5B,CAAC,CAAC;YACE,IAAM,YAAY,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC;YACjD,IAAM,MAAM,GAAG,IAAA,wCAAgC,EAAC,YAAY,CAAC,CAAC;YAC9D,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC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ignore - magicast is ESM and TS complains about that. It works though\nimport { generateCode, type ProxifiedModule, parseModule } from 'magicast';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nimport {\n addSentrySerializerRequireToMetroConfig,\n addSentrySerializerToMetroConfig,\n getMetroConfigObject,\n removeSentryRequire,\n removeSentrySerializerFromMetroConfig,\n} from '../../src/react-native/metro';\n\ndescribe('patch metro config - sentry serializer', () => {\n describe('addSentrySerializerToMetroConfig', () => {\n it('add to empty config', () => {\n const mod = parseModule(`module.exports = {\n other: 'config'\n }`);\n const configObject = getModuleExportsObject(mod);\n const result = addSentrySerializerToMetroConfig(configObject);\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`module.exports = {\n other: 'config',\n\n serializer: {\n customSerializer: createSentryMetroSerializer()\n }\n}`);\n });\n\n it('add to existing serializer config', () => {\n const mod = parseModule(`module.exports = {\n other: 'config',\n serializer: {\n other: 'config'\n }\n}`);\n const configObject = getModuleExportsObject(mod);\n const result = addSentrySerializerToMetroConfig(configObject);\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`module.exports = {\n other: 'config',\n serializer: {\n other: 'config',\n customSerializer: createSentryMetroSerializer()\n }\n}`);\n });\n\n it('not add to existing customSerializer config', () => {\n const mod = parseModule(`module.exports = {\n other: 'config',\n serializer: {\n other: 'config',\n customSerializer: 'existing-serializer'\n }\n}`);\n const configObject = getModuleExportsObject(mod);\n const result = addSentrySerializerToMetroConfig(configObject);\n expect(result).toBe(false);\n expect(generateCode(mod.$ast).code).toBe(`module.exports = {\n other: 'config',\n serializer: {\n other: 'config',\n customSerializer: 'existing-serializer'\n }\n}`);\n });\n });\n\n describe('addSentrySerializerImportToMetroConfig', () => {\n it('add import', () => {\n const mod =\n parseModule(`const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');\n\nmodule.exports = {\n other: 'config'\n}`);\n const result = addSentrySerializerRequireToMetroConfig(\n mod.$ast as t.Program,\n );\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code)\n .toBe(`const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');\n\nconst {\n createSentryMetroSerializer\n} = require(\"@sentry/react-native/dist/js/tools/sentryMetroSerializer\");\n\nmodule.exports = {\n other: 'config'\n}`);\n });\n });\n\n describe('getMetroConfigObject', () => {\n it('get config object from variable called config', () => {\n const mod = parseModule(`var config = { some: 'config' };`);\n const configObject = getMetroConfigObject(mod.$ast as t.Program);\n expect(\n ((configObject?.properties[0] as t.ObjectProperty).key as t.Identifier)\n .name,\n ).toBe('some');\n expect(\n (\n (configObject?.properties[0] as t.ObjectProperty)\n .value as t.StringLiteral\n ).value,\n ).toBe('config');\n });\n\n it('get config object from const called config', () => {\n const mod = parseModule(`const config = { some: 'config' };`);\n const configObject = getMetroConfigObject(mod.$ast as t.Program);\n expect(\n ((configObject?.properties[0] as t.ObjectProperty).key as t.Identifier)\n .name,\n ).toBe('some');\n expect(\n (\n (configObject?.properties[0] as t.ObjectProperty)\n .value as t.StringLiteral\n ).value,\n ).toBe('config');\n });\n\n it('get config oject from let called config', () => {\n const mod = parseModule(`let config = { some: 'config' };`);\n const configObject = getMetroConfigObject(mod.$ast as t.Program);\n expect(\n ((configObject?.properties[0] as t.ObjectProperty).key as t.Identifier)\n .name,\n ).toBe('some');\n expect(\n (\n (configObject?.properties[0] as t.ObjectProperty)\n .value as t.StringLiteral\n ).value,\n ).toBe('config');\n });\n\n it('get config object from module.exports', () => {\n const mod = parseModule(`module.exports = { some: 'config' };`);\n const configObject = getMetroConfigObject(mod.$ast as t.Program);\n expect(\n ((configObject?.properties[0] as t.ObjectProperty).key as t.Identifier)\n .name,\n ).toBe('some');\n expect(\n (\n (configObject?.properties[0] as t.ObjectProperty)\n .value as t.StringLiteral\n ).value,\n ).toBe('config');\n });\n });\n\n describe('remove @sentry require', () => {\n it('nothing to remove', () => {\n const mod = parseModule(`let config = { some: 'config' };`);\n const result = removeSentryRequire(mod.$ast as t.Program);\n expect(result).toBe(false);\n expect(generateCode(mod.$ast).code).toBe(\n `let config = { some: 'config' };`,\n );\n });\n\n it('remove metro serializer import', () => {\n const mod = parseModule(`const {\n createSentryMetroSerializer,\n} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');\nlet config = { some: 'config' };`);\n const result = removeSentryRequire(mod.$ast as t.Program);\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(\n `let config = { some: 'config' };`,\n );\n });\n\n it('remove all sentry imports', () => {\n const mod = parseModule(`const {\n createSentryMetroSerializer,\n} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');\nvar Sentry = require('@sentry/react-native');\nlet SentryIntegrations = require('@sentry/integrations');\n\nlet config = { some: 'config' };`);\n const result = removeSentryRequire(mod.$ast as t.Program);\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(\n `let config = { some: 'config' };`,\n );\n });\n });\n\n describe('remove sentryMetroSerializer', () => {\n it('no custom serializer to remove', () => {\n const mod = parseModule(`let config = { some: 'config' };`);\n const result = removeSentrySerializerFromMetroConfig(\n mod.$ast as t.Program,\n );\n expect(result).toBe(false);\n expect(generateCode(mod.$ast).code).toBe(\n `let config = { some: 'config' };`,\n );\n });\n\n it('no Sentry custom serializer to remove', () => {\n const mod = parseModule(`let config = {\n serializer: {\n customSerializer: 'existing-serializer',\n other: 'config',\n },\n other: 'config',\n};`);\n const result = removeSentrySerializerFromMetroConfig(\n mod.$ast as t.Program,\n );\n expect(result).toBe(false);\n expect(generateCode(mod.$ast).code).toBe(`let config = {\n serializer: {\n customSerializer: 'existing-serializer',\n other: 'config',\n },\n other: 'config',\n};`);\n });\n\n it('Sentry serializer to remove', () => {\n const mod = parseModule(`let config = {\n serializer: {\n customSerializer: createSentryMetroSerializer(),\n other: 'config',\n },\n other: 'config',\n};`);\n const result = removeSentrySerializerFromMetroConfig(\n mod.$ast as t.Program,\n );\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`let config = {\n serializer: {\n other: 'config'\n },\n other: 'config',\n};`);\n });\n\n it('Sentry serializer to remove with wrapped serializer', () => {\n const mod = parseModule(`let config = {\n serializer: {\n customSerializer: createSentryMetroSerializer(wrappedSerializer()),\n other: 'config',\n },\n other: 'config',\n};`);\n const result = removeSentrySerializerFromMetroConfig(\n mod.$ast as t.Program,\n );\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`let config = {\n serializer: {\n customSerializer: wrappedSerializer(),\n other: 'config',\n },\n other: 'config',\n};`);\n });\n });\n});\n\nfunction getModuleExportsObject(\n mod: ProxifiedModule,\n index = 0,\n): t.ObjectExpression {\n return (\n ((mod.$ast as t.Program).body[index] as t.ExpressionStatement)\n .expression as t.AssignmentExpression\n ).right as t.ObjectExpression;\n}\n"]}
1
+ {"version":3,"file":"metro.test.js","sourceRoot":"","sources":["../../../test/react-native/metro.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4EAA4E;AAC5E,qCAA2E;AAM3E,sDAOsC;AAEtC,QAAQ,CAAC,wCAAwC,EAAE;IACjD,QAAQ,CAAC,oCAAoC,EAAE;QAC7C,EAAE,CAAC,gDAAgD,EAAE;;;;;wBAC7C,GAAG,GACP,IAAA,sBAAW,EAAC,wSAU+C,CAAC,CAAC;wBAEhD,qBAAM,IAAA,0CAAkC,EAAC,GAAG,EAAE;;;;iCAE5D,CAAC,EAAA;;wBAFI,MAAM,GAAG,SAEb;wBACF,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;wBAC1B,MAAM,CAAC,IAAA,uBAAY,EAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;6BAChC,IAAI,CAAC,sYAcuE,CAAC,CAAC;;;;aAClF,CAAC,CAAC;QAEH,EAAE,CAAC,gDAAgD,EAAE;;;;;wBAC7C,GAAG,GAAG,IAAA,sBAAW,EAAC,uTAgB3B,CAAC,CAAC;wBAEgB,qBAAM,IAAA,0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;QAEH,EAAE,CAAC,qDAAqD,EAAE;YACxD,IAAM,GAAG,GAAG,IAAA,sBAAW,EAAC,8JAM3B,CAAC,CAAC;YACC,IAAM,MAAM,GAAG,IAAA,6CAAqC,EAClD,GAAG,CAAC,IAAiB,CACtB,CAAC;YACF,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,MAAM,CAAC,IAAA,uBAAY,EAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,iIAM5C,CAAC,CAAC;QACD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,SAAS,sBAAsB,CAC7B,GAAoB,EACpB,KAAS;IAAT,sBAAA,EAAA,SAAS;IAET,OACI,GAAG,CAAC,IAAkB,CAAC,IAAI,CAAC,KAAK,CAA2B;SAC3D,UACJ,CAAC,KAA2B,CAAC;AAChC,CAAC","sourcesContent":["// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { generateCode, type ProxifiedModule, parseModule } from 'magicast';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nimport {\n addSentrySerializerRequireToMetroConfig,\n addSentrySerializerToMetroConfig,\n getMetroConfigObject,\n patchMetroWithSentryConfigInMemory,\n removeSentryRequire,\n removeSentrySerializerFromMetroConfig,\n} from '../../src/react-native/metro';\n\ndescribe('patch metro config - sentry serializer', () => {\n describe('patchMetroWithSentryConfigInMemory', () => {\n it('patches react native 0.72 default metro config', async () => {\n const mod =\n parseModule(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\n\n/**\n * Metro configuration\n * https://reactnative.dev/docs/metro\n *\n * @type {import('metro-config').MetroConfig}\n */\nconst config = {};\n\nmodule.exports = mergeConfig(getDefaultConfig(__dirname), config);`);\n\n const result = await patchMetroWithSentryConfigInMemory(mod, async () => {\n /* noop */\n });\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code)\n .toBe(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\n\nconst {\n withSentryConfig\n} = require(\"@sentry/react-native/metro\");\n\n/**\n * Metro configuration\n * https://reactnative.dev/docs/metro\n *\n * @type {import('metro-config').MetroConfig}\n */\nconst config = {};\n\nmodule.exports = withSentryConfig(mergeConfig(getDefaultConfig(__dirname), config));`);\n });\n\n it('patches react native 0.65 default metro config', async () => {\n const mod = parseModule(`/**\n* Metro configuration for React Native\n* https://github.com/facebook/react-native\n*\n* @format\n*/\n\nmodule.exports = {\n transformer: {\n getTransformOptions: async () => ({\n transform: {\n experimentalImportSupport: false,\n inlineRequires: true,\n },\n }),\n },\n};`);\n\n const result = await patchMetroWithSentryConfigInMemory(mod, async () => {\n /* noop */\n });\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`const {\n withSentryConfig\n} = require(\"@sentry/react-native/metro\");\n\n/**\n* Metro configuration for React Native\n* https://github.com/facebook/react-native\n*\n* @format\n*/\n\nmodule.exports = withSentryConfig({\n transformer: {\n getTransformOptions: async () => ({\n transform: {\n experimentalImportSupport: false,\n inlineRequires: true,\n },\n }),\n },\n});`);\n });\n\n it('patches react native metro config exported variable', async () => {\n const mod = parseModule(`const testConfig = {};\n\nmodule.exports = testConfig;`);\n\n const result = await patchMetroWithSentryConfigInMemory(mod, async () => {\n /* noop */\n });\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`const {\n withSentryConfig\n} = require(\"@sentry/react-native/metro\");\n\nconst testConfig = {};\n\nmodule.exports = withSentryConfig(testConfig);`);\n });\n\n it('does not patch react native metro config exported as factory function', async () => {\n const mod = parseModule(`module.exports = () => ({});`);\n\n const result = await patchMetroWithSentryConfigInMemory(mod, async () => {\n /* noop */\n });\n expect(result).toBe(false);\n expect(generateCode(mod.$ast).code).toBe(`module.exports = () => ({});`);\n });\n });\n\n describe('addSentrySerializerToMetroConfig', () => {\n it('add to empty config', () => {\n const mod = parseModule(`module.exports = {\n other: 'config'\n }`);\n const configObject = getModuleExportsObject(mod);\n const result = addSentrySerializerToMetroConfig(configObject);\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`module.exports = {\n other: 'config',\n\n serializer: {\n customSerializer: createSentryMetroSerializer()\n }\n}`);\n });\n\n it('add to existing serializer config', () => {\n const mod = parseModule(`module.exports = {\n other: 'config',\n serializer: {\n other: 'config'\n }\n}`);\n const configObject = getModuleExportsObject(mod);\n const result = addSentrySerializerToMetroConfig(configObject);\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`module.exports = {\n other: 'config',\n serializer: {\n other: 'config',\n customSerializer: createSentryMetroSerializer()\n }\n}`);\n });\n\n it('not add to existing customSerializer config', () => {\n const mod = parseModule(`module.exports = {\n other: 'config',\n serializer: {\n other: 'config',\n customSerializer: 'existing-serializer'\n }\n}`);\n const configObject = getModuleExportsObject(mod);\n const result = addSentrySerializerToMetroConfig(configObject);\n expect(result).toBe(false);\n expect(generateCode(mod.$ast).code).toBe(`module.exports = {\n other: 'config',\n serializer: {\n other: 'config',\n customSerializer: 'existing-serializer'\n }\n}`);\n });\n });\n\n describe('addSentrySerializerImportToMetroConfig', () => {\n it('add import', () => {\n const mod =\n parseModule(`const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');\n\nmodule.exports = {\n other: 'config'\n}`);\n const result = addSentrySerializerRequireToMetroConfig(\n mod.$ast as t.Program,\n );\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code)\n .toBe(`const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');\n\nconst {\n createSentryMetroSerializer\n} = require(\"@sentry/react-native/dist/js/tools/sentryMetroSerializer\");\n\nmodule.exports = {\n other: 'config'\n}`);\n });\n });\n\n describe('getMetroConfigObject', () => {\n it('get config object from variable called config', () => {\n const mod = parseModule(`var config = { some: 'config' };`);\n const configObject = getMetroConfigObject(mod.$ast as t.Program);\n expect(\n ((configObject?.properties[0] as t.ObjectProperty).key as t.Identifier)\n .name,\n ).toBe('some');\n expect(\n (\n (configObject?.properties[0] as t.ObjectProperty)\n .value as t.StringLiteral\n ).value,\n ).toBe('config');\n });\n\n it('get config object from const called config', () => {\n const mod = parseModule(`const config = { some: 'config' };`);\n const configObject = getMetroConfigObject(mod.$ast as t.Program);\n expect(\n ((configObject?.properties[0] as t.ObjectProperty).key as t.Identifier)\n .name,\n ).toBe('some');\n expect(\n (\n (configObject?.properties[0] as t.ObjectProperty)\n .value as t.StringLiteral\n ).value,\n ).toBe('config');\n });\n\n it('get config oject from let called config', () => {\n const mod = parseModule(`let config = { some: 'config' };`);\n const configObject = getMetroConfigObject(mod.$ast as t.Program);\n expect(\n ((configObject?.properties[0] as t.ObjectProperty).key as t.Identifier)\n .name,\n ).toBe('some');\n expect(\n (\n (configObject?.properties[0] as t.ObjectProperty)\n .value as t.StringLiteral\n ).value,\n ).toBe('config');\n });\n\n it('get config object from module.exports', () => {\n const mod = parseModule(`module.exports = { some: 'config' };`);\n const configObject = getMetroConfigObject(mod.$ast as t.Program);\n expect(\n ((configObject?.properties[0] as t.ObjectProperty).key as t.Identifier)\n .name,\n ).toBe('some');\n expect(\n (\n (configObject?.properties[0] as t.ObjectProperty)\n .value as t.StringLiteral\n ).value,\n ).toBe('config');\n });\n });\n\n describe('remove @sentry require', () => {\n it('nothing to remove', () => {\n const mod = parseModule(`let config = { some: 'config' };`);\n const result = removeSentryRequire(mod.$ast as t.Program);\n expect(result).toBe(false);\n expect(generateCode(mod.$ast).code).toBe(\n `let config = { some: 'config' };`,\n );\n });\n\n it('remove metro serializer import', () => {\n const mod = parseModule(`const {\n createSentryMetroSerializer,\n} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');\nlet config = { some: 'config' };`);\n const result = removeSentryRequire(mod.$ast as t.Program);\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(\n `let config = { some: 'config' };`,\n );\n });\n\n it('remove all sentry imports', () => {\n const mod = parseModule(`const {\n createSentryMetroSerializer,\n} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');\nvar Sentry = require('@sentry/react-native');\nlet SentryIntegrations = require('@sentry/integrations');\n\nlet config = { some: 'config' };`);\n const result = removeSentryRequire(mod.$ast as t.Program);\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(\n `let config = { some: 'config' };`,\n );\n });\n });\n\n describe('remove sentryMetroSerializer', () => {\n it('no custom serializer to remove', () => {\n const mod = parseModule(`let config = { some: 'config' };`);\n const result = removeSentrySerializerFromMetroConfig(\n mod.$ast as t.Program,\n );\n expect(result).toBe(false);\n expect(generateCode(mod.$ast).code).toBe(\n `let config = { some: 'config' };`,\n );\n });\n\n it('no Sentry custom serializer to remove', () => {\n const mod = parseModule(`let config = {\n serializer: {\n customSerializer: 'existing-serializer',\n other: 'config',\n },\n other: 'config',\n};`);\n const result = removeSentrySerializerFromMetroConfig(\n mod.$ast as t.Program,\n );\n expect(result).toBe(false);\n expect(generateCode(mod.$ast).code).toBe(`let config = {\n serializer: {\n customSerializer: 'existing-serializer',\n other: 'config',\n },\n other: 'config',\n};`);\n });\n\n it('Sentry serializer to remove', () => {\n const mod = parseModule(`let config = {\n serializer: {\n customSerializer: createSentryMetroSerializer(),\n other: 'config',\n },\n other: 'config',\n};`);\n const result = removeSentrySerializerFromMetroConfig(\n mod.$ast as t.Program,\n );\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`let config = {\n serializer: {\n other: 'config'\n },\n other: 'config',\n};`);\n });\n\n it('Sentry serializer to remove with wrapped serializer', () => {\n const mod = parseModule(`let config = {\n serializer: {\n customSerializer: createSentryMetroSerializer(wrappedSerializer()),\n other: 'config',\n },\n other: 'config',\n};`);\n const result = removeSentrySerializerFromMetroConfig(\n mod.$ast as t.Program,\n );\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`let config = {\n serializer: {\n customSerializer: wrappedSerializer(),\n other: 'config',\n },\n other: 'config',\n};`);\n });\n });\n});\n\nfunction getModuleExportsObject(\n mod: ProxifiedModule,\n index = 0,\n): t.ObjectExpression {\n return (\n ((mod.$ast as t.Program).body[index] as t.ExpressionStatement)\n .expression as t.AssignmentExpression\n ).right as t.ObjectExpression;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/wizard",
3
- "version": "3.22.3",
3
+ "version": "3.23.0",
4
4
  "homepage": "https://github.com/getsentry/sentry-wizard",
5
5
  "repository": "https://github.com/getsentry/sentry-wizard",
6
6
  "description": "Sentry wizard helping you to configure your project",
@@ -29,5 +29,8 @@ export function getSentryInitPlainTextSnippet(dsn: string) {
29
29
 
30
30
  Sentry.init({
31
31
  dsn: '${dsn}',
32
+
33
+ // uncomment the line below to enable Spotlight (https://spotlightjs.com)
34
+ // enableSpotlight: __DEV__,
32
35
  });`;
33
36
  }