@sentry/wizard 3.7.1 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/bin.ts +14 -0
  3. package/dist/bin.js +9 -0
  4. package/dist/bin.js.map +1 -1
  5. package/dist/lib/Helper/Logging.d.ts +1 -0
  6. package/dist/lib/Helper/Logging.js +2 -1
  7. package/dist/lib/Helper/Logging.js.map +1 -1
  8. package/dist/lib/Helper/__tests__/MergeConfig.js.map +1 -1
  9. package/dist/lib/Setup.js +4 -0
  10. package/dist/lib/Setup.js.map +1 -1
  11. package/dist/lib/Steps/ChooseIntegration.js +12 -26
  12. package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
  13. package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
  14. package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
  15. package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
  16. package/dist/lib/Steps/Integrations/ReactNative.js +5 -5
  17. package/dist/lib/Steps/Integrations/ReactNative.js.map +1 -1
  18. package/dist/lib/Steps/Integrations/__tests__/ReactNative.js +5 -6
  19. package/dist/lib/Steps/Integrations/__tests__/ReactNative.js.map +1 -1
  20. package/dist/package.json +11 -7
  21. package/dist/src/apple/apple-wizard.js +31 -2
  22. package/dist/src/apple/apple-wizard.js.map +1 -1
  23. package/dist/src/apple/cocoapod.d.ts +2 -0
  24. package/dist/src/apple/cocoapod.js +122 -0
  25. package/dist/src/apple/cocoapod.js.map +1 -0
  26. package/dist/src/apple/code-tools.js +22 -12
  27. package/dist/src/apple/code-tools.js.map +1 -1
  28. package/dist/src/apple/fastlane.d.ts +2 -0
  29. package/dist/src/apple/fastlane.js +179 -0
  30. package/dist/src/apple/fastlane.js.map +1 -0
  31. package/dist/src/apple/templates.d.ts +1 -0
  32. package/dist/src/apple/templates.js +7 -3
  33. package/dist/src/apple/templates.js.map +1 -1
  34. package/dist/src/apple/xcode-manager.d.ts +1 -1
  35. package/dist/src/apple/xcode-manager.js +35 -28
  36. package/dist/src/apple/xcode-manager.js.map +1 -1
  37. package/dist/src/nextjs/nextjs-wizard.js +71 -81
  38. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  39. package/dist/src/sourcemaps/sourcemaps-wizard.js +61 -46
  40. package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
  41. package/dist/src/sourcemaps/tools/nextjs.d.ts +3 -0
  42. package/dist/src/sourcemaps/tools/nextjs.js +135 -0
  43. package/dist/src/sourcemaps/tools/nextjs.js.map +1 -0
  44. package/dist/src/sourcemaps/tools/sentry-cli.js +120 -16
  45. package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
  46. package/dist/src/sourcemaps/tools/vite.js +102 -12
  47. package/dist/src/sourcemaps/tools/vite.js.map +1 -1
  48. package/dist/src/sourcemaps/utils/detect-tool.d.ts +1 -1
  49. package/dist/src/sourcemaps/utils/detect-tool.js +1 -0
  50. package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
  51. package/dist/src/sourcemaps/utils/other-wizards.js +35 -12
  52. package/dist/src/sourcemaps/utils/other-wizards.js.map +1 -1
  53. package/dist/src/sveltekit/sdk-setup.d.ts +9 -1
  54. package/dist/src/sveltekit/sdk-setup.js +73 -29
  55. package/dist/src/sveltekit/sdk-setup.js.map +1 -1
  56. package/dist/src/sveltekit/sveltekit-wizard.js +23 -13
  57. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  58. package/dist/src/utils/ast-utils.d.ts +8 -0
  59. package/dist/src/utils/ast-utils.js +45 -0
  60. package/dist/src/utils/ast-utils.js.map +1 -0
  61. package/dist/src/utils/bash.d.ts +2 -1
  62. package/dist/src/utils/bash.js +14 -2
  63. package/dist/src/utils/bash.js.map +1 -1
  64. package/dist/src/utils/clack-utils.d.ts +7 -14
  65. package/dist/src/utils/clack-utils.js +46 -2
  66. package/dist/src/utils/clack-utils.js.map +1 -1
  67. package/dist/src/utils/debug.d.ts +2 -0
  68. package/dist/src/utils/debug.js +51 -0
  69. package/dist/src/utils/debug.js.map +1 -0
  70. package/dist/src/utils/package-json.d.ts +1 -1
  71. package/dist/src/utils/package-json.js.map +1 -1
  72. package/dist/src/utils/types.d.ts +24 -0
  73. package/dist/src/utils/types.js.map +1 -1
  74. package/dist/test/utils/ast-utils.test.d.ts +1 -0
  75. package/dist/test/utils/ast-utils.test.js +21 -0
  76. package/dist/test/utils/ast-utils.test.js.map +1 -0
  77. package/lib/Helper/Logging.ts +1 -1
  78. package/lib/Helper/__tests__/MergeConfig.ts +9 -4
  79. package/lib/Setup.ts +5 -0
  80. package/lib/Steps/ChooseIntegration.ts +13 -3
  81. package/lib/Steps/Integrations/Cordova.ts +3 -3
  82. package/lib/Steps/Integrations/Electron.ts +1 -2
  83. package/lib/Steps/Integrations/MobileProject.ts +1 -1
  84. package/lib/Steps/Integrations/ReactNative.ts +23 -17
  85. package/lib/Steps/Integrations/__tests__/ReactNative.ts +24 -15
  86. package/package.json +11 -7
  87. package/src/apple/apple-wizard.ts +35 -3
  88. package/src/apple/cocoapod.ts +57 -0
  89. package/src/apple/code-tools.ts +80 -57
  90. package/src/apple/fastlane.ts +160 -0
  91. package/src/apple/templates.ts +26 -10
  92. package/src/apple/xcode-manager.ts +137 -120
  93. package/src/nextjs/nextjs-wizard.ts +4 -13
  94. package/src/sourcemaps/sourcemaps-wizard.ts +40 -28
  95. package/src/sourcemaps/tools/nextjs.ts +114 -0
  96. package/src/sourcemaps/tools/sentry-cli.ts +134 -8
  97. package/src/sourcemaps/tools/vite.ts +101 -12
  98. package/src/sourcemaps/utils/detect-tool.ts +3 -1
  99. package/src/sourcemaps/utils/other-wizards.ts +32 -13
  100. package/src/sveltekit/sdk-setup.ts +122 -43
  101. package/src/sveltekit/sveltekit-wizard.ts +15 -6
  102. package/src/utils/ast-utils.ts +20 -0
  103. package/src/utils/bash.ts +43 -30
  104. package/src/utils/clack-utils.ts +42 -14
  105. package/src/utils/debug.ts +20 -0
  106. package/src/utils/package-json.ts +1 -1
  107. package/src/utils/types.ts +22 -0
  108. package/test/utils/ast-utils.test.ts +44 -0
  109. package/dist/src/sveltekit/sentry-cli-setup.d.ts +0 -2
  110. package/dist/src/sveltekit/sentry-cli-setup.js +0 -71
  111. package/dist/src/sveltekit/sentry-cli-setup.js.map +0 -1
  112. package/package-lock.json +0 -8910
  113. package/src/sveltekit/sentry-cli-setup.ts +0 -27
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNative.js","sourceRoot":"","sources":["../../../../lib/Steps/Integrations/ReactNative.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+CAAqC;AACrC,qCAAyB;AAEzB,qCAAkC;AAClC,wCAA4B;AAC5B,yCAA6B;AAC7B,6BAAiC;AAGjC,0CAK2B;AAC3B,gDAA8D;AAC9D,gDAA2D;AAC3D,8DAAsE;AACtE,oDAAmD;AACnD,iDAAgD;AAChD,oDAAmD;AACnD,2BAA0B;AAE1B,IAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAElB,QAAA,gCAAgC,GAAG,UAAU,CAAC;AAC9C,QAAA,sBAAsB,GAAG,UAAU,CAAC;AAEpC,QAAA,2BAA2B,GAAG,sBAAsB,CAAC;AACrD,QAAA,oBAAoB,GAAG,cAAc,CAAC;AAEtC,QAAA,iBAAiB,GAC5B,0EAA0E,CAAC;AAE7E;IAAiC,+BAAa;IAY5C,qBAA6B,KAAW;QAAxC,YACE,kBAAM,KAAK,CAAC,SAGb;QAJ4B,WAAK,GAAL,KAAK,CAAM;QAEtC,KAAI,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC;QACrB,KAAI,CAAC,UAAU,GAAG,IAAI,qBAAS,CAAC,KAAI,CAAC,KAAK,CAAC,CAAC;;IAC9C,CAAC;IAEY,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KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YACjC,IAAI,CAAC,KAAK,CAAC,UAAC,GAAQ;gBAClB,IAAI,GAAG,EAAE;oBACP,MAAM,CAAC,GAAG,CAAC,CAAC;oBACZ,OAAO;iBACR;gBAED,KAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC;gBACrC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAthBD;;OAEG;IACY,+CAAmC,GAAG,aAAa,CAAC;IAohBrE,kBAAC;CAAA,AAxhBD,CAAiC,6BAAa,GAwhB7C","sourcesContent":["/* eslint-disable max-lines */\nimport { exec } from 'child_process';\nimport * as fs from 'fs';\nimport type { Answers} from 'inquirer';\nimport { prompt } from 'inquirer';\nimport * as _ from 'lodash';\nimport * as path from 'path';\nimport { promisify } from 'util';\n\nimport type { Args } from '../../Constants';\nimport {\n exists,\n matchesContent,\n matchFiles,\n patchMatchingFile,\n} from '../../Helper/File';\nimport { dim, green, l, nl, red } from '../../Helper/Logging';\nimport { checkPackageVersion } from '../../Helper/Package';\nimport { getPackageManagerChoice } from '../../Helper/PackageManager';\nimport { SentryCli } from '../../Helper/SentryCli';\nimport { MobileProject } from './MobileProject';\nimport { BottomBar } from '../../Helper/BottomBar';\nimport { URL } from 'url';\n\nconst xcode = require('xcode');\n\nexport const COMPATIBLE_REACT_NATIVE_VERSIONS = '>=0.69.0';\nexport const COMPATIBLE_SDK_VERSION = '>= 5.0.0';\n\nexport const SENTRY_REACT_NATIVE_PACKAGE = '@sentry/react-native';\nexport const REACT_NATIVE_PACKAGE = 'react-native';\n\nexport const DOCS_MANUAL_STEPS =\n 'https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/';\n\nexport class ReactNative extends MobileProject {\n /**\n * All React Native versions have app/build.gradle with android section.\n */\n private static _buildGradleAndroidSectionBeginning = /^android {/m;\n\n private url: string | undefined;\n\n protected _answers: Answers;\n protected _sentryCli: SentryCli;\n\n\n public constructor(protected _argv: Args) {\n super(_argv);\n this.url = _argv.url;\n this._sentryCli = new SentryCli(this._argv);\n }\n\n public async emit(answers: Answers): Promise<Answers> {\n if (this._argv.uninstall) {\n return this.uninstall(answers);\n }\n if (!(await this.shouldEmit(answers))) {\n return {};\n }\n nl();\n\n let userAnswers: Answers = { continue: true };\n const packageManager = getPackageManagerChoice();\n\n const hasCompatibleReactNativeVersion = checkPackageVersion(\n this._readAppPackage(),\n REACT_NATIVE_PACKAGE,\n COMPATIBLE_REACT_NATIVE_VERSIONS,\n true,\n );\n if (!hasCompatibleReactNativeVersion && !this._argv.quiet) {\n userAnswers = await prompt({\n message: 'Your version of React Native is not compatible with Sentry\\'s React Native SDK. Do you want to continue?',\n name: 'continue',\n default: false,\n type: 'confirm',\n });\n nl();\n }\n if (!userAnswers.continue) {\n throw new Error(\n `Please upgrade to a version that is compatible with ${COMPATIBLE_REACT_NATIVE_VERSIONS}. Or use ${DOCS_MANUAL_STEPS}`,\n );\n }\n\n if (packageManager) {\n BottomBar.show(`Adding ${SENTRY_REACT_NATIVE_PACKAGE}...`);\n await packageManager.installPackage(SENTRY_REACT_NATIVE_PACKAGE);\n BottomBar.hide();\n green(`✓ Added \\`${SENTRY_REACT_NATIVE_PACKAGE}\\``);\n }\n const hasCompatibleSentryReactNativeVersion = checkPackageVersion(\n this._readAppPackage(),\n SENTRY_REACT_NATIVE_PACKAGE,\n COMPATIBLE_SDK_VERSION,\n true,\n );\n if (!hasCompatibleSentryReactNativeVersion && !this._argv.quiet) {\n userAnswers = await prompt({\n message: `Your version of ${SENTRY_REACT_NATIVE_PACKAGE} is not compatible with this wizard. Do you want to continue?`,\n name: 'continue',\n default: false,\n type: 'confirm',\n });\n nl();\n }\n if (!userAnswers.continue) {\n throw new Error(\n `Please upgrade to a version that is compatible with ${COMPATIBLE_SDK_VERSION}.`,\n );\n }\n\n const sentryCliProperties = this._sentryCli.convertAnswersToProperties(\n answers,\n );\n\n const promises = this.getPlatforms(answers).map(\n async (platform: string) => {\n try {\n if (platform === 'ios') {\n await patchMatchingFile(\n 'ios/*.xcodeproj/project.pbxproj',\n this._patchXcodeProj.bind(this),\n );\n green('✓ Patched build script in Xcode project.');\n BottomBar.show('Adding Sentry pods...');\n await this._podInstall();\n BottomBar.hide();\n green('✓ Pods installed.');\n } else {\n await patchMatchingFile(\n '**/app/build.gradle',\n this._patchBuildGradle.bind(this),\n );\n green('✓ Patched build.gradle file.');\n }\n await this._patchJsSentryInit(platform, answers);\n await this._addSentryProperties(platform, sentryCliProperties);\n green(`✓ Added sentry.properties file to ${platform}`);\n } catch (e) {\n red(e);\n }\n },\n );\n\n await Promise.all(promises);\n\n let host: string | null = null\n try {\n host = (new URL(this.url || '')).host;\n } catch (_error) {\n // ignore\n }\n const orgSlug = _.get(answers, 'config.organization.slug', null);\n const projectId = _.get(answers, 'config.project.id', null);\n const projectIssuesUrl = host && orgSlug && projectId\n ? `https://${orgSlug}.${host}/issues/?project=${projectId}`\n : null;\n\n l(`\nTo 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`);\n\n if (projectIssuesUrl) {\n l(`After that check your project issues:`);\n l(projectIssuesUrl);\n nl();\n }\n\n l(`<Button title='Try!' onPress={ () => { Sentry.captureException(new Error('First error')) }}/>`);\n nl();\n\n if (!this._argv.quiet) {\n await prompt({\n message: 'Have you successfully sent a test event?',\n name: 'snippet',\n default: true,\n type: 'confirm',\n });\n }\n\n return answers;\n }\n\n public async uninstall(_answers: Answers): Promise<Answers> {\n await patchMatchingFile(\n '**/*.xcodeproj/project.pbxproj',\n this._unpatchXcodeProj.bind(this),\n );\n await patchMatchingFile(\n '**/app/build.gradle',\n this._unpatchBuildGradle.bind(this),\n );\n return {};\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n protected async _shouldConfigurePlatform(platform: string): Promise<boolean> {\n let result = false;\n\n if (!exists(`${platform}/sentry.properties`)) {\n result = true;\n this.debug(`${platform}/sentry.properties not exists`);\n }\n\n if (!matchesContent('**/*.xcodeproj/project.pbxproj', /sentry-cli/gi)) {\n result = true;\n this.debug('**/*.xcodeproj/project.pbxproj not matched');\n }\n\n if (!matchesContent('**/app/build.gradle', /sentry\\.gradle/gi)) {\n result = true;\n this.debug('**/app/build.gradle not matched');\n }\n\n const regex = /Sentry/gi;\n if (\n exists(`index.${platform}.js`) &&\n !matchesContent(`index.${platform}.js`, regex)\n ) {\n result = true;\n this.debug(`index.${platform}.js not matched`);\n }\n if (exists('App.js') && !matchesContent('App.js', regex)) {\n result = true;\n this.debug('index.js or App.js not matched');\n }\n\n if (this._argv.uninstall) {\n // if we uninstall we need to invert the result so we remove already patched\n // but leave untouched platforms as they are\n return !result;\n }\n\n return result;\n }\n\n private _readAppPackage(): Record<string, unknown> {\n let appPackage: Record<string, unknown> = {};\n\n try {\n appPackage = JSON.parse(\n fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf8'),\n );\n } catch {\n // We don't need to have this\n }\n\n return appPackage;\n }\n\n private async _podInstall(): Promise<void> {\n await promisify(exec)('npx --yes pod-install --non-interactive --quiet');\n }\n\n private async _patchJsSentryInit(\n platform: string,\n answers: Answers,\n ): Promise<void> {\n const prefixGlob = '{.,./src}';\n const suffixGlob = '@(j|t|cj|mj)s?(x)';\n const platformGlob = `index.${platform}.${suffixGlob}`;\n // rm 0.49 introduced an App.js for both platforms\n const universalGlob = `App.${suffixGlob}`;\n const jsFileGlob = `${prefixGlob}/+(${platformGlob}|${universalGlob})`;\n\n const jsFileToPatch = matchFiles(jsFileGlob);\n if (jsFileToPatch.length !== 0) {\n await patchMatchingFile(\n jsFileGlob,\n this._patchJs.bind(this),\n answers,\n platform,\n );\n green(`✓ Patched ${jsFileToPatch.join(', ')} file(s).`);\n } else {\n red(`✗ Could not find ${platformGlob} nor ${universalGlob} files.`);\n red('✗ Please, visit https://docs.sentry.io/platforms/react-native');\n }\n }\n\n private _addSentryProperties(\n platform: string,\n properties: any,\n ): Promise<void> {\n let rv = Promise.resolve();\n\n // This will create the ios/android folder before trying to write\n // sentry.properties in it which would fail otherwise\n if (!fs.existsSync(platform)) {\n dim(`${platform} folder did not exist, creating it.`);\n fs.mkdirSync(platform);\n }\n const fn = path.join(platform, 'sentry.properties');\n\n if (platform === 'android' && properties['cli/executable']) {\n // We don't need to write the sentry-cli path in the properties file\n // since our gradle plugins already pick it up on the correct spot\n delete properties['cli/executable'];\n }\n rv = rv.then(() =>\n fs.writeFileSync(fn, this._sentryCli.dumpProperties(properties)),\n );\n\n return rv;\n }\n\n private _patchJs(\n contents: string,\n _filename: string,\n answers: Answers,\n platform?: string,\n ): Promise<string | null> {\n // since the init call could live in other places too, we really only\n // want to do this if we managed to patch any of the other files as well.\n if (contents.match(/Sentry.config\\(/)) {\n return Promise.resolve(null);\n }\n\n // if we match @sentry\\/react-native somewhere, we already patched the file\n // and no longer need to\n if (contents.match('@sentry/react-native')) {\n return Promise.resolve(contents);\n }\n\n let dsn = '__DSN__';\n this.getPlatforms(answers).forEach((selectedPlatform: string) => {\n if (platform && selectedPlatform === platform) {\n dsn = _.get(answers, 'config.dsn.public', null);\n } else if (platform === undefined) {\n dsn = _.get(answers, 'config.dsn.public', null);\n }\n });\n\n return Promise.resolve(\n contents.replace(\n /^([^]*)(import\\s+[^;]*?;$)/m,\n match =>\n // eslint-disable-next-line prefer-template\n match +\n \"\\n\\nimport * as Sentry from '@sentry/react-native';\\n\\n\" +\n 'Sentry.init({ \\n' +\n ` dsn: '${dsn}', \\n` +\n '});\\n',\n ),\n );\n }\n\n // ANDROID -----------------------------------------\n\n private _patchBuildGradle(contents: string): Promise<string | null> {\n const applyFrom =\n 'apply from: \"../../node_modules/@sentry/react-native/sentry.gradle\"';\n if (contents.indexOf(applyFrom) >= 0) {\n return Promise.resolve(null);\n }\n\n return Promise.resolve(\n contents.replace(\n ReactNative._buildGradleAndroidSectionBeginning,\n // eslint-disable-next-line prefer-template\n match => applyFrom + '\\n' + match,\n ),\n );\n }\n\n private _unpatchBuildGradle(contents: string): Promise<string> {\n return Promise.resolve(\n contents.replace(\n /^\\s*apply from: [\"']..\\/..\\/node_modules\\/@sentry\\/react-native\\/sentry.gradle[\"'];?\\s*?\\r?\\n/m,\n '',\n ),\n );\n }\n\n // IOS -----------------------------------------\n\n private _patchExistingXcodeBuildScripts(buildScripts: any): void {\n for (const script of buildScripts) {\n if (\n !script.shellScript.match(/\\/scripts\\/react-native-xcode\\.sh/i) ||\n script.shellScript.match(/sentry-cli\\s+react-native\\s+xcode/i)\n ) {\n continue;\n }\n let code = JSON.parse(script.shellScript);\n code =\n // eslint-disable-next-line prefer-template, @typescript-eslint/restrict-plus-operands\n 'export SENTRY_PROPERTIES=sentry.properties\\n' +\n 'export EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\\n' +\n code.replace(\n '$REACT_NATIVE_XCODE',\n () =>\n // eslint-disable-next-line no-useless-escape\n '\\\\\"../node_modules/@sentry/cli/bin/sentry-cli react-native xcode $REACT_NATIVE_XCODE\\\\\"',\n ) +\n '\\n/bin/sh ../node_modules/@sentry/react-native/scripts/collect-modules.sh\\n';\n script.shellScript = JSON.stringify(code);\n }\n }\n\n private _addNewXcodeBuildPhaseForSymbols(buildScripts: any, proj: any): void {\n for (const script of buildScripts) {\n if (\n script.shellScript.match(\n /sentry-cli\\s+(upload-dsym|debug-files upload)/,\n )\n ) {\n return;\n }\n }\n\n proj.addBuildPhase(\n [],\n 'PBXShellScriptBuildPhase',\n 'Upload Debug Symbols to Sentry',\n null,\n {\n shellPath: '/bin/sh',\n shellScript: `\nexport SENTRY_PROPERTIES=sentry.properties\n[[ $SENTRY_INCLUDE_NATIVE_SOURCES == \"true\" ]] && INCLUDE_SOURCES_FLAG=\"--include-sources\" || INCLUDE_SOURCES_FLAG=\"\"\n../node_modules/@sentry/cli/bin/sentry-cli debug-files upload \"$INCLUDE_SOURCES_FLAG\" \"$DWARF_DSYM_FOLDER_PATH\"\n`,\n },\n );\n }\n\n private _patchXcodeProj(\n contents: string,\n filename: string,\n ): Promise<string | undefined> {\n const proj = xcode.project(filename);\n return new Promise((resolve, reject) => {\n proj.parse((err: any) => {\n if (err) {\n reject(err);\n return;\n }\n\n const buildScripts = [];\n for (const key in proj.hash.project.objects.PBXShellScriptBuildPhase ||\n {}) {\n if (\n // eslint-disable-next-line no-prototype-builtins\n proj.hash.project.objects.PBXShellScriptBuildPhase.hasOwnProperty(\n key,\n )\n ) {\n const val = proj.hash.project.objects.PBXShellScriptBuildPhase[key];\n if (val.isa) {\n buildScripts.push(val);\n }\n }\n }\n\n try {\n this._patchExistingXcodeBuildScripts(buildScripts);\n } catch (e) {\n red(e);\n }\n try {\n this._addNewXcodeBuildPhaseForSymbols(buildScripts, proj);\n } catch (e) {\n red(e);\n }\n\n // we always modify the xcode file in memory but we only want to save it\n // in case the user wants configuration for ios. This is why we check\n // here first if changes are made before we might prompt the platform\n // continue prompt.\n const newContents = proj.writeSync();\n if (newContents === contents) {\n resolve(undefined);\n } else {\n resolve(newContents);\n }\n });\n });\n }\n\n private _unpatchXcodeBuildScripts(proj: any): void {\n const scripts = proj.hash.project.objects.PBXShellScriptBuildPhase || {};\n const firstTarget = proj.getFirstTarget().uuid;\n const nativeTargets = proj.hash.project.objects.PBXNativeTarget;\n\n // scripts to patch partially. Run this first so that we don't\n // accidentally delete some scripts later entirely that we only want to\n // rewrite.\n for (const key of Object.keys(scripts)) {\n const script = scripts[key];\n\n // ignore comments\n if (typeof script === 'string') {\n continue;\n }\n\n // ignore scripts that do not invoke the react-native-xcode command.\n if (!script.shellScript.match(/sentry-cli\\s+react-native\\s+xcode/i)) {\n continue;\n }\n\n script.shellScript = JSON.stringify(\n JSON.parse(script.shellScript)\n // remove sentry properties export\n .replace(/^export SENTRY_PROPERTIES=sentry.properties\\r?\\n/m, '')\n .replace(\n /^\\/bin\\/sh ..\\/node_modules\\/@sentry\\/react-native\\/scripts\\/collect-modules.sh\\r?\\n/m,\n '',\n )\n // unwrap react-native-xcode.sh command. In case someone replaced it\n // entirely with the sentry-cli command we need to put the original\n // version back in.\n .replace(\n /\\.\\.\\/node_modules\\/@sentry\\/cli\\/bin\\/sentry-cli\\s+react-native\\s+xcode\\s+\\$REACT_NATIVE_XCODE/i,\n '$REACT_NATIVE_XCODE',\n ),\n );\n }\n\n // scripts to kill entirely.\n for (const key of Object.keys(scripts)) {\n const script = scripts[key];\n\n // ignore comments and keys that got deleted\n if (typeof script === 'string' || script === undefined) {\n continue;\n }\n\n if (\n script.shellScript.match(\n /@sentry\\/cli\\/bin\\/sentry-cli\\s+(upload-dsym|debug-files upload)\\b/,\n )\n ) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete scripts[key];\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete scripts[`${key}_comment`];\n const phases = nativeTargets[firstTarget].buildPhases;\n if (phases) {\n for (let i = 0; i < phases.length; i++) {\n if (phases[i].value === key) {\n phases.splice(i, 1);\n break;\n }\n }\n }\n continue;\n }\n }\n }\n\n private _unpatchXcodeProj(\n _contents: string,\n filename: string,\n ): Promise<string> {\n const proj = xcode.project(filename);\n return new Promise((resolve, reject) => {\n proj.parse((err: any) => {\n if (err) {\n reject(err);\n return;\n }\n\n this._unpatchXcodeBuildScripts(proj);\n resolve(proj.writeSync());\n });\n });\n }\n}\n"]}
1
+ {"version":3,"file":"ReactNative.js","sourceRoot":"","sources":["../../../../lib/Steps/Integrations/ReactNative.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+CAAqC;AACrC,qCAAyB;AAEzB,qCAAkC;AAClC,wCAA4B;AAC5B,yCAA6B;AAC7B,6BAAiC;AAGjC,0CAK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K,CACtB,oEAAoE,CACrE,EACD;gBACA,gEAAgE;gBAChE,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;gBACpB,gEAAgE;gBAChE,OAAO,OAAO,CAAC,UAAG,GAAG,aAAU,CAAC,CAAC;gBACjC,IAAM,MAAM,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC;gBACtD,IAAI,MAAM,EAAE;oBACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;wBACtC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,GAAG,EAAE;4BAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;4BACpB,MAAM;yBACP;qBACF;iBACF;gBACD,SAAS;aACV;SACF;IACH,CAAC;IAEO,uCAAiB,GAAzB,UACE,SAAiB,EACjB,QAAgB;QAFlB,iBAgBC;QAZC,IAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YACjC,IAAI,CAAC,KAAK,CAAC,UAAC,GAAQ;gBAClB,IAAI,GAAG,EAAE;oBACP,MAAM,CAAC,GAAG,CAAC,CAAC;oBACZ,OAAO;iBACR;gBAED,KAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC;gBACrC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IA5hBD;;OAEG;IACY,+CAAmC,GAAG,aAAa,CAAC;IA0hBrE,kBAAC;CAAA,AA9hBD,CAAiC,6BAAa,GA8hB7C","sourcesContent":["/* eslint-disable max-lines */\nimport { exec } from 'child_process';\nimport * as fs from 'fs';\nimport type { Answers } from 'inquirer';\nimport { prompt } from 'inquirer';\nimport * as _ from 'lodash';\nimport * as path from 'path';\nimport { promisify } from 'util';\n\nimport type { Args } from '../../Constants';\nimport {\n exists,\n matchesContent,\n matchFiles,\n patchMatchingFile,\n} from '../../Helper/File';\nimport { dim, green, l, nl, red } from '../../Helper/Logging';\nimport { checkPackageVersion } from '../../Helper/Package';\nimport { getPackageManagerChoice } from '../../Helper/PackageManager';\nimport { SentryCli } from '../../Helper/SentryCli';\nimport { MobileProject } from './MobileProject';\nimport { BottomBar } from '../../Helper/BottomBar';\nimport { URL } from 'url';\n\nconst xcode = require('xcode');\n\nexport const COMPATIBLE_REACT_NATIVE_VERSIONS = '>=0.69.0';\nexport const COMPATIBLE_SDK_VERSION = '>= 5.0.0';\n\nexport const SENTRY_REACT_NATIVE_PACKAGE = '@sentry/react-native';\nexport const REACT_NATIVE_PACKAGE = 'react-native';\n\nexport const DOCS_MANUAL_STEPS =\n 'https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/';\n\nexport class ReactNative extends MobileProject {\n /**\n * All React Native versions have app/build.gradle with android section.\n */\n private static _buildGradleAndroidSectionBeginning = /^android {/m;\n\n private url: string | undefined;\n\n protected _answers: Answers;\n protected _sentryCli: SentryCli;\n\n public constructor(protected _argv: Args) {\n super(_argv);\n this.url = _argv.url;\n this._sentryCli = new SentryCli(this._argv);\n }\n\n public async emit(answers: Answers): Promise<Answers> {\n if (this._argv.uninstall) {\n return this.uninstall(answers);\n }\n if (!(await this.shouldEmit(answers))) {\n return {};\n }\n nl();\n\n let userAnswers: Answers = { continue: true };\n const packageManager = getPackageManagerChoice();\n\n const hasCompatibleReactNativeVersion = checkPackageVersion(\n this._readAppPackage(),\n REACT_NATIVE_PACKAGE,\n COMPATIBLE_REACT_NATIVE_VERSIONS,\n true,\n );\n if (!hasCompatibleReactNativeVersion && !this._argv.quiet) {\n userAnswers = await prompt({\n message:\n \"Your version of React Native is not compatible with Sentry's React Native SDK. Do you want to continue?\",\n name: 'continue',\n default: false,\n type: 'confirm',\n });\n nl();\n }\n if (!userAnswers.continue) {\n throw new Error(\n `Please upgrade to a version that is compatible with ${COMPATIBLE_REACT_NATIVE_VERSIONS}. Or use ${DOCS_MANUAL_STEPS}`,\n );\n }\n\n if (packageManager) {\n BottomBar.show(`Adding ${SENTRY_REACT_NATIVE_PACKAGE}...`);\n await packageManager.installPackage(SENTRY_REACT_NATIVE_PACKAGE);\n BottomBar.hide();\n green(`✓ Added \\`${SENTRY_REACT_NATIVE_PACKAGE}\\``);\n }\n const hasCompatibleSentryReactNativeVersion = checkPackageVersion(\n this._readAppPackage(),\n SENTRY_REACT_NATIVE_PACKAGE,\n COMPATIBLE_SDK_VERSION,\n true,\n );\n if (!hasCompatibleSentryReactNativeVersion && !this._argv.quiet) {\n userAnswers = await prompt({\n message: `Your version of ${SENTRY_REACT_NATIVE_PACKAGE} is not compatible with this wizard. Do you want to continue?`,\n name: 'continue',\n default: false,\n type: 'confirm',\n });\n nl();\n }\n if (!userAnswers.continue) {\n throw new Error(\n `Please upgrade to a version that is compatible with ${COMPATIBLE_SDK_VERSION}.`,\n );\n }\n\n const sentryCliProperties =\n this._sentryCli.convertAnswersToProperties(answers);\n\n const promises = this.getPlatforms(answers).map(\n async (platform: string) => {\n try {\n if (platform === 'ios') {\n await patchMatchingFile(\n 'ios/*.xcodeproj/project.pbxproj',\n this._patchXcodeProj.bind(this),\n );\n green('✓ Patched build script in Xcode project.');\n BottomBar.show('Adding Sentry pods...');\n await this._podInstall();\n BottomBar.hide();\n green('✓ Pods installed.');\n } else {\n await patchMatchingFile(\n '**/app/build.gradle',\n this._patchBuildGradle.bind(this),\n );\n green('✓ Patched build.gradle file.');\n }\n await this._patchJsSentryInit(platform, answers);\n await this._addSentryProperties(platform, sentryCliProperties);\n green(`✓ Added sentry.properties file to ${platform}`);\n } catch (e) {\n red(e);\n }\n },\n );\n\n await Promise.all(promises);\n\n let host: string | null = null;\n try {\n host = new URL(this.url || '').host;\n } catch (_error) {\n // ignore\n }\n const orgSlug = _.get(answers, 'config.organization.slug', null);\n const projectId = _.get(answers, 'config.project.id', null);\n const projectIssuesUrl =\n host && orgSlug && projectId\n ? `https://${orgSlug}.${host}/issues/?project=${projectId}`\n : null;\n\n l(`\nTo 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`);\n\n if (projectIssuesUrl) {\n l(`After that check your project issues:`);\n l(projectIssuesUrl);\n nl();\n }\n\n l(\n `<Button title='Try!' onPress={ () => { Sentry.captureException(new Error('First error')) }}/>`,\n );\n nl();\n\n if (!this._argv.quiet) {\n await prompt({\n message: 'Have you successfully sent a test event?',\n name: 'snippet',\n default: true,\n type: 'confirm',\n });\n }\n\n return answers;\n }\n\n public async uninstall(_answers: Answers): Promise<Answers> {\n await patchMatchingFile(\n '**/*.xcodeproj/project.pbxproj',\n this._unpatchXcodeProj.bind(this),\n );\n await patchMatchingFile(\n '**/app/build.gradle',\n this._unpatchBuildGradle.bind(this),\n );\n return {};\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n protected async _shouldConfigurePlatform(platform: string): Promise<boolean> {\n let result = false;\n\n if (!exists(`${platform}/sentry.properties`)) {\n result = true;\n this.debug(`${platform}/sentry.properties not exists`);\n }\n\n if (!matchesContent('**/*.xcodeproj/project.pbxproj', /sentry-cli/gi)) {\n result = true;\n this.debug('**/*.xcodeproj/project.pbxproj not matched');\n }\n\n if (!matchesContent('**/app/build.gradle', /sentry\\.gradle/gi)) {\n result = true;\n this.debug('**/app/build.gradle not matched');\n }\n\n const regex = /Sentry/gi;\n if (\n exists(`index.${platform}.js`) &&\n !matchesContent(`index.${platform}.js`, regex)\n ) {\n result = true;\n this.debug(`index.${platform}.js not matched`);\n }\n if (exists('App.js') && !matchesContent('App.js', regex)) {\n result = true;\n this.debug('index.js or App.js not matched');\n }\n\n if (this._argv.uninstall) {\n // if we uninstall we need to invert the result so we remove already patched\n // but leave untouched platforms as they are\n return !result;\n }\n\n return result;\n }\n\n private _readAppPackage(): Record<string, unknown> {\n let appPackage: Record<string, unknown> = {};\n\n try {\n appPackage = JSON.parse(\n fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf8'),\n );\n } catch {\n // We don't need to have this\n }\n\n return appPackage;\n }\n\n private async _podInstall(): Promise<void> {\n await promisify(exec)('npx --yes pod-install --non-interactive --quiet');\n }\n\n private async _patchJsSentryInit(\n platform: string,\n answers: Answers,\n ): Promise<void> {\n const prefixGlob = '{.,./src}';\n const suffixGlob = '@(j|t|cj|mj)s?(x)';\n const platformGlob = `index.${platform}.${suffixGlob}`;\n // rm 0.49 introduced an App.js for both platforms\n const universalGlob = `App.${suffixGlob}`;\n const jsFileGlob = `${prefixGlob}/+(${platformGlob}|${universalGlob})`;\n\n const jsFileToPatch = matchFiles(jsFileGlob);\n if (jsFileToPatch.length !== 0) {\n await patchMatchingFile(\n jsFileGlob,\n this._patchJs.bind(this),\n answers,\n platform,\n );\n green(`✓ Patched ${jsFileToPatch.join(', ')} file(s).`);\n } else {\n red(`✗ Could not find ${platformGlob} nor ${universalGlob} files.`);\n red('✗ Please, visit https://docs.sentry.io/platforms/react-native');\n }\n }\n\n private _addSentryProperties(\n platform: string,\n properties: any,\n ): Promise<void> {\n let rv = Promise.resolve();\n\n // This will create the ios/android folder before trying to write\n // sentry.properties in it which would fail otherwise\n if (!fs.existsSync(platform)) {\n dim(`${platform} folder did not exist, creating it.`);\n fs.mkdirSync(platform);\n }\n const fn = path.join(platform, 'sentry.properties');\n\n if (platform === 'android' && properties['cli/executable']) {\n // We don't need to write the sentry-cli path in the properties file\n // since our gradle plugins already pick it up on the correct spot\n delete properties['cli/executable'];\n }\n rv = rv.then(() =>\n fs.writeFileSync(fn, this._sentryCli.dumpProperties(properties)),\n );\n\n return rv;\n }\n\n private _patchJs(\n contents: string,\n _filename: string,\n answers: Answers,\n platform?: string,\n ): Promise<string | null> {\n // since the init call could live in other places too, we really only\n // want to do this if we managed to patch any of the other files as well.\n if (contents.match(/Sentry.config\\(/)) {\n return Promise.resolve(null);\n }\n\n // if we match @sentry\\/react-native somewhere, we already patched the file\n // and no longer need to\n if (contents.match('@sentry/react-native')) {\n return Promise.resolve(contents);\n }\n\n let dsn = '__DSN__';\n this.getPlatforms(answers).forEach((selectedPlatform: string) => {\n if (platform && selectedPlatform === platform) {\n dsn = _.get(answers, 'config.dsn.public', null);\n } else if (platform === undefined) {\n dsn = _.get(answers, 'config.dsn.public', null);\n }\n });\n\n return Promise.resolve(\n contents.replace(\n /^([^]*)(import\\s+[^;]*?;$)/m,\n (match) =>\n // eslint-disable-next-line prefer-template\n match +\n \"\\n\\nimport * as Sentry from '@sentry/react-native';\\n\\n\" +\n 'Sentry.init({ \\n' +\n ` dsn: '${dsn}', \\n` +\n '});\\n',\n ),\n );\n }\n\n // ANDROID -----------------------------------------\n\n private _patchBuildGradle(contents: string): Promise<string | null> {\n const applyFrom =\n 'apply from: \"../../node_modules/@sentry/react-native/sentry.gradle\"';\n if (contents.indexOf(applyFrom) >= 0) {\n return Promise.resolve(null);\n }\n\n return Promise.resolve(\n contents.replace(\n ReactNative._buildGradleAndroidSectionBeginning,\n // eslint-disable-next-line prefer-template\n (match) => applyFrom + '\\n' + match,\n ),\n );\n }\n\n private _unpatchBuildGradle(contents: string): Promise<string> {\n return Promise.resolve(\n contents.replace(\n /^\\s*apply from: [\"']..\\/..\\/node_modules\\/@sentry\\/react-native\\/sentry.gradle[\"'];?\\s*?\\r?\\n/m,\n '',\n ),\n );\n }\n\n // IOS -----------------------------------------\n\n private _patchExistingXcodeBuildScripts(buildScripts: any): void {\n for (const script of buildScripts) {\n if (\n !script.shellScript.match(/\\/scripts\\/react-native-xcode\\.sh/i) ||\n script.shellScript.match(/sentry-cli\\s+react-native\\s+xcode/i)\n ) {\n continue;\n }\n let code = JSON.parse(script.shellScript);\n code =\n // eslint-disable-next-line prefer-template, @typescript-eslint/restrict-plus-operands\n 'export SENTRY_PROPERTIES=sentry.properties\\n' +\n 'export EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\\n' +\n code.replace(\n '$REACT_NATIVE_XCODE',\n () =>\n // eslint-disable-next-line no-useless-escape\n '\\\\\"../node_modules/@sentry/cli/bin/sentry-cli react-native xcode $REACT_NATIVE_XCODE\\\\\"',\n ) +\n '\\n/bin/sh -c \"$WITH_ENVIRONMENT ../node_modules/@sentry/react-native/scripts/collect-modules.sh\"\\n';\n script.shellScript = JSON.stringify(code);\n }\n }\n\n private _addNewXcodeBuildPhaseForSymbols(buildScripts: any, proj: any): void {\n for (const script of buildScripts) {\n if (\n script.shellScript.match(\n /sentry-cli\\s+(upload-dsym|debug-files upload)/,\n )\n ) {\n return;\n }\n }\n\n proj.addBuildPhase(\n [],\n 'PBXShellScriptBuildPhase',\n 'Upload Debug Symbols to Sentry',\n null,\n {\n shellPath: '/bin/sh',\n shellScript: `\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nif [ -f \"$WITH_ENVIRONMENT\" ]; then\n . \"$WITH_ENVIRONMENT\"\nfi \nexport SENTRY_PROPERTIES=sentry.properties\n[ \"$SENTRY_INCLUDE_NATIVE_SOURCES\" = \"true\" ] && INCLUDE_SOURCES_FLAG=\"--include-sources\" || INCLUDE_SOURCES_FLAG=\"\"\n../node_modules/@sentry/cli/bin/sentry-cli debug-files upload \"$INCLUDE_SOURCES_FLAG\" \"$DWARF_DSYM_FOLDER_PATH\"\n`,\n },\n );\n }\n\n private _patchXcodeProj(\n contents: string,\n filename: string,\n ): Promise<string | undefined> {\n const proj = xcode.project(filename);\n return new Promise((resolve, reject) => {\n proj.parse((err: any) => {\n if (err) {\n reject(err);\n return;\n }\n\n const buildScripts = [];\n for (const key in proj.hash.project.objects.PBXShellScriptBuildPhase ||\n {}) {\n if (\n // eslint-disable-next-line no-prototype-builtins\n proj.hash.project.objects.PBXShellScriptBuildPhase.hasOwnProperty(\n key,\n )\n ) {\n const val = proj.hash.project.objects.PBXShellScriptBuildPhase[key];\n if (val.isa) {\n buildScripts.push(val);\n }\n }\n }\n\n try {\n this._patchExistingXcodeBuildScripts(buildScripts);\n } catch (e) {\n red(e);\n }\n try {\n this._addNewXcodeBuildPhaseForSymbols(buildScripts, proj);\n } catch (e) {\n red(e);\n }\n\n // we always modify the xcode file in memory but we only want to save it\n // in case the user wants configuration for ios. This is why we check\n // here first if changes are made before we might prompt the platform\n // continue prompt.\n const newContents = proj.writeSync();\n if (newContents === contents) {\n resolve(undefined);\n } else {\n resolve(newContents);\n }\n });\n });\n }\n\n private _unpatchXcodeBuildScripts(proj: any): void {\n const scripts = proj.hash.project.objects.PBXShellScriptBuildPhase || {};\n const firstTarget = proj.getFirstTarget().uuid;\n const nativeTargets = proj.hash.project.objects.PBXNativeTarget;\n\n // scripts to patch partially. Run this first so that we don't\n // accidentally delete some scripts later entirely that we only want to\n // rewrite.\n for (const key of Object.keys(scripts)) {\n const script = scripts[key];\n\n // ignore comments\n if (typeof script === 'string') {\n continue;\n }\n\n // ignore scripts that do not invoke the react-native-xcode command.\n if (!script.shellScript.match(/sentry-cli\\s+react-native\\s+xcode/i)) {\n continue;\n }\n\n script.shellScript = JSON.stringify(\n JSON.parse(script.shellScript)\n // remove sentry properties export\n .replace(/^export SENTRY_PROPERTIES=sentry.properties\\r?\\n/m, '')\n .replace(\n /^\\/bin\\/sh .*?..\\/node_modules\\/@sentry\\/react-native\\/scripts\\/collect-modules.sh\"?\\r?\\n/m,\n '',\n )\n // unwrap react-native-xcode.sh command. In case someone replaced it\n // entirely with the sentry-cli command we need to put the original\n // version back in.\n .replace(\n /\\.\\.\\/node_modules\\/@sentry\\/cli\\/bin\\/sentry-cli\\s+react-native\\s+xcode\\s+\\$REACT_NATIVE_XCODE/i,\n '$REACT_NATIVE_XCODE',\n ),\n );\n }\n\n // scripts to kill entirely.\n for (const key of Object.keys(scripts)) {\n const script = scripts[key];\n\n // ignore comments and keys that got deleted\n if (typeof script === 'string' || script === undefined) {\n continue;\n }\n\n if (\n script.shellScript.match(\n /@sentry\\/cli\\/bin\\/sentry-cli\\s+(upload-dsym|debug-files upload)\\b/,\n )\n ) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete scripts[key];\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete scripts[`${key}_comment`];\n const phases = nativeTargets[firstTarget].buildPhases;\n if (phases) {\n for (let i = 0; i < phases.length; i++) {\n if (phases[i].value === key) {\n phases.splice(i, 1);\n break;\n }\n }\n }\n continue;\n }\n }\n }\n\n private _unpatchXcodeProj(\n _contents: string,\n filename: string,\n ): Promise<string> {\n const proj = xcode.project(filename);\n return new Promise((resolve, reject) => {\n proj.parse((err: any) => {\n if (err) {\n reject(err);\n return;\n }\n\n this._unpatchXcodeBuildScripts(proj);\n resolve(proj.writeSync());\n });\n });\n }\n}\n"]}
@@ -85,7 +85,7 @@ var testArgs = {
85
85
  url: 'https://not.used',
86
86
  };
87
87
  var mockIosAnswers = {
88
- shouldConfigurePlatforms: { 'ios': true },
88
+ shouldConfigurePlatforms: { ios: true },
89
89
  config: {
90
90
  dsn: {
91
91
  public: 'dns.public.com',
@@ -93,7 +93,7 @@ var mockIosAnswers = {
93
93
  },
94
94
  };
95
95
  var mockAndroidAnswers = {
96
- shouldConfigurePlatforms: { 'android': true },
96
+ shouldConfigurePlatforms: { android: true },
97
97
  config: {
98
98
  dsn: {
99
99
  public: 'dns.public.com',
@@ -105,8 +105,7 @@ var restoreExec = function () {
105
105
  child_process.exec = originalExec;
106
106
  };
107
107
  var mockExec = function () {
108
- child_process.exec
109
- .mockImplementation(function (_command, callback) { return callback(null, { stdout: '' }); });
108
+ child_process.exec.mockImplementation(function (_command, callback) { return callback(null, { stdout: '' }); });
110
109
  };
111
110
  describe('ReactNative', function () {
112
111
  var defaultCwd = process.cwd();
@@ -139,9 +138,9 @@ describe('ReactNative', function () {
139
138
  patchedIosIndexJs = fs.readFileSync(iosIndexJs, 'utf8');
140
139
  patchedAppTsx = fs.readFileSync(appTsx, 'utf8');
141
140
  expectedPatch = 'import React from "react";\n\n' +
142
- 'import * as Sentry from \'@sentry/react-native\';\n\n' +
141
+ "import * as Sentry from '@sentry/react-native';\n\n" +
143
142
  'Sentry.init({ \n' +
144
- ' dsn: \'dns.public.com\', \n' +
143
+ " dsn: 'dns.public.com', \n" +
145
144
  '});\n\n';
146
145
  expect(patchedIosIndexJs).toEqual(expectedPatch);
147
146
  expect(patchedAppTsx).toEqual(expectedPatch);
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNative.js","sourceRoot":"","sources":["../../../../../lib/Steps/Integrations/__tests__/ReactNative.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAI,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC,CAAC,4CAA4C;AACrF,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAC3B,2DAA+C;AAC/C,qCAAyB;AAEzB,yCAA6B;AAC7B,+CAAmC;AACnC,6CAAiC;AAGjC,gDAA2D;AAC3D,8CAA6C;AAE7C,IAAM,OAAO,GAAG,SAAS,CAAC;AAC1B,IAAM,UAAU,GAAG,cAAc,CAAC;AAClC,IAAM,MAAM,GAAG,aAAa,CAAC;AAC7B,IAAM,cAAc,GAAG,0BAA0B,CAAC;AAClD,IAAM,QAAQ,GAAG,WAAW,CAAC;AAE7B,IAAM,cAAc,GAAG,8BAA8B,CAAC;AACtD,IAAM,0BAA0B,GAAG,sDAAsD,CAAC;AAE1F,IAAM,QAAQ,GAAG;IACf,KAAK,EAAE,KAAK;IACZ,WAAW,EAAE,uBAAW,CAAC,WAAW;IACpC,QAAQ,EAAE,CAAC,oBAAQ,CAAC,GAAG,CAAC;IACxB,KAAK,EAAE,IAAI;IACX,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,KAAK;IAChB,GAAG,EAAE,kBAAkB;CACxB,CAAC;AAEF,IAAM,cAAc,GAAY;IAC9B,wBAAwB,EAAE,EAAE,KAAK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AAqB,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;;;;SACtD,CAAC,CAAC;IAEH,IAAI,CAAC,yBAAyB,EAAE;;;;;oBACxB,OAAO,GAAG,IAAI,yBAAW,CAAC,QAAgB,CAAC,CAAC;oBAElD,qBAAM,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,EAAA;;oBAAlC,SAAkC,CAAC;oBAEnC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAAC,+BAA+B,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;;;;SACrG,CAAC,CAAC;IAEH,IAAI,CAAC,sBAAsB,EAAE;;;;;oBACrB,OAAO,GAAG,IAAI,yBAAW,CAAC,QAAgB,CAAC,CAAC;oBAElD,qBAAM,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,EAAA;;oBAAlC,SAAkC,CAAC;oBAEnC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAAC,iDAAiD,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;;;;SACvH,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["jest.mock('../../../Helper/Logging.ts'); // We mock logging to not pollute the output\njest.mock('child_process');\nimport * as child_process from 'child_process';\nimport * as fs from 'fs';\nimport type { Answers } from 'inquirer';\nimport * as path from 'path';\nimport * as process from 'process';\nimport * as rimraf from 'rimraf';\n\nimport type { Args} from '../../../Constants';\nimport { Integration, Platform } from '../../../Constants';\nimport { ReactNative } from '../ReactNative';\n\nconst testDir = 'rn-test';\nconst iosIndexJs = 'index.ios.js';\nconst appTsx = 'src/App.tsx';\nconst appBuildGradle = 'android/app/build.gradle';\nconst yarnLock = 'yarn.lock';\n\nconst dummyJsContent = 'import React from \"react\";\\n';\nconst dummyAppBuildGradleContent = 'apply plugin: \"com.facebook.react\"\\n\\nandroid {\\n}\\n';\n\nconst testArgs = {\n debug: false,\n integration: Integration.reactNative,\n platform: [Platform.ios],\n quiet: true,\n skipConnect: true,\n uninstall: false,\n url: 'https://not.used',\n};\n\nconst mockIosAnswers: Answers = {\n shouldConfigurePlatforms: { 'ios': true },\n config: {\n dsn: {\n public: 'dns.public.com',\n },\n },\n};\n\nconst mockAndroidAnswers: Answers = {\n shouldConfigurePlatforms: { 'android': true },\n config: {\n dsn: {\n public: 'dns.public.com',\n },\n },\n};\n\nconst originalExec = child_process.exec;\n\nconst restoreExec = (): void => {\n (child_process as any).exec = originalExec;\n}\n\nconst mockExec = (): void => {\n (child_process.exec as unknown as jest.Mock)\n .mockImplementation((_command, callback) => callback(null, { stdout: '' }));\n}\n\ndescribe('ReactNative', () => {\n\n const defaultCwd = process.cwd();\n\n beforeEach(() => {\n rimraf.sync(testDir);\n fs.mkdirSync(testDir);\n process.chdir(testDir);\n fs.writeFileSync(iosIndexJs, dummyJsContent);\n fs.mkdirSync(path.dirname(appTsx), { recursive: true });\n fs.writeFileSync(appTsx, dummyJsContent);\n fs.mkdirSync(path.dirname(appBuildGradle), { recursive: true });\n fs.writeFileSync(appBuildGradle, dummyAppBuildGradleContent);\n fs.writeFileSync(yarnLock, '');\n mockExec();\n });\n\n afterEach(() => {\n restoreExec();\n process.chdir(defaultCwd);\n rimraf.sync(testDir);\n });\n\n test('patches js files', async () => {\n const project = new ReactNative(testArgs as Args);\n await project.emit(mockIosAnswers);\n\n const patchedIosIndexJs = fs.readFileSync(iosIndexJs, 'utf8');\n const patchedAppTsx = fs.readFileSync(appTsx, 'utf8');\n const expectedPatch = 'import React from \"react\";\\n\\n' +\n 'import * as Sentry from \\'@sentry/react-native\\';\\n\\n' +\n 'Sentry.init({ \\n' +\n ' dsn: \\'dns.public.com\\', \\n' +\n '});\\n\\n';\n expect(patchedIosIndexJs).toEqual(expectedPatch);\n expect(patchedAppTsx).toEqual(expectedPatch);\n });\n\n test('patches android app build gradle file', async () => {\n const project = new ReactNative(testArgs as Args);\n\n await project.emit(mockAndroidAnswers);\n\n const patchedAppBuildGradle = fs.readFileSync(appBuildGradle, 'utf8');\n const expectedPatch = 'apply plugin: \"com.facebook.react\"\\n\\n' +\n 'apply from: \"../../node_modules/@sentry/react-native/sentry.gradle\"\\n' +\n 'android {\\n}\\n';\n expect(patchedAppBuildGradle).toEqual(expectedPatch);\n });\n\n test('does install sentry sdk', async () => {\n const project = new ReactNative(testArgs as Args);\n\n await project.emit(mockIosAnswers);\n\n expect(child_process.exec).toHaveBeenCalledWith('yarn add @sentry/react-native', expect.anything());\n });\n\n test('executes pod install', async () => {\n const project = new ReactNative(testArgs as Args);\n\n await project.emit(mockIosAnswers);\n\n expect(child_process.exec).toHaveBeenCalledWith('npx --yes pod-install --non-interactive --quiet', expect.anything());\n });\n});\n"]}
1
+ {"version":3,"file":"ReactNative.js","sourceRoot":"","sources":["../../../../../lib/Steps/Integrations/__tests__/ReactNative.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAI,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC,CAAC,4CAA4C;AACrF,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAC3B,2DAA+C;AAC/C,qCAAyB;AAEzB,yCAA6B;AAC7B,+CAAmC;AACnC,6CAAiC;AAGjC,gDAA2D;AAC3D,8CAA6C;AAE7C,IAAM,OAAO,GAAG,SAAS,CAAC;AAC1B,IAAM,UAAU,GAAG,cAAc,CAAC;AAClC,IAAM,MAAM,GAAG,aAAa,CAAC;AAC7B,IAAM,cAAc,GAAG,0BAA0B,CAAC;AAClD,IAAM,QAAQ,GAAG,WAAW,CAAC;AAE7B,IAAM,cAAc,GAAG,8BAA8B,CAAC;AACtD,IAAM,0BAA0B,GAC9B,sDAAsD,CAAC;AAEzD,IAAM,QAAQ,GAAG;IACf,KAAK,EAAE,KAAK;IACZ,WAAW,EAAE,uBAAW,CAAC,WAAW;IACpC,QAAQ,EAAE,CAAC,oBAAQ,CAA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AtC,SAAsC,CAAC;oBAEjC,qBAAqB,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;oBAChE,aAAa,GACjB,wCAAwC;wBACxC,uEAAuE;wBACvE,gBAAgB,CAAC;oBACnB,MAAM,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;;;;SACtD,CAAC,CAAC;IAEH,IAAI,CAAC,yBAAyB,EAAE;;;;;oBACxB,OAAO,GAAG,IAAI,yBAAW,CAAC,QAAgB,CAAC,CAAC;oBAElD,qBAAM,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,EAAA;;oBAAlC,SAAkC,CAAC;oBAEnC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAC7C,+BAA+B,EAC/B,MAAM,CAAC,QAAQ,EAAE,CAClB,CAAC;;;;SACH,CAAC,CAAC;IAEH,IAAI,CAAC,sBAAsB,EAAE;;;;;oBACrB,OAAO,GAAG,IAAI,yBAAW,CAAC,QAAgB,CAAC,CAAC;oBAElD,qBAAM,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,EAAA;;oBAAlC,SAAkC,CAAC;oBAEnC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,oBAAoB,CAC7C,iDAAiD,EACjD,MAAM,CAAC,QAAQ,EAAE,CAClB,CAAC;;;;SACH,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["jest.mock('../../../Helper/Logging.ts'); // We mock logging to not pollute the output\njest.mock('child_process');\nimport * as child_process from 'child_process';\nimport * as fs from 'fs';\nimport type { Answers } from 'inquirer';\nimport * as path from 'path';\nimport * as process from 'process';\nimport * as rimraf from 'rimraf';\n\nimport type { Args } from '../../../Constants';\nimport { Integration, Platform } from '../../../Constants';\nimport { ReactNative } from '../ReactNative';\n\nconst testDir = 'rn-test';\nconst iosIndexJs = 'index.ios.js';\nconst appTsx = 'src/App.tsx';\nconst appBuildGradle = 'android/app/build.gradle';\nconst yarnLock = 'yarn.lock';\n\nconst dummyJsContent = 'import React from \"react\";\\n';\nconst dummyAppBuildGradleContent =\n 'apply plugin: \"com.facebook.react\"\\n\\nandroid {\\n}\\n';\n\nconst testArgs = {\n debug: false,\n integration: Integration.reactNative,\n platform: [Platform.ios],\n quiet: true,\n skipConnect: true,\n uninstall: false,\n url: 'https://not.used',\n};\n\nconst mockIosAnswers: Answers = {\n shouldConfigurePlatforms: { ios: true },\n config: {\n dsn: {\n public: 'dns.public.com',\n },\n },\n};\n\nconst mockAndroidAnswers: Answers = {\n shouldConfigurePlatforms: { android: true },\n config: {\n dsn: {\n public: 'dns.public.com',\n },\n },\n};\n\nconst originalExec = child_process.exec;\n\nconst restoreExec = (): void => {\n (child_process as any).exec = originalExec;\n};\n\nconst mockExec = (): void => {\n (child_process.exec as unknown as jest.Mock).mockImplementation(\n (_command, callback) => callback(null, { stdout: '' }),\n );\n};\n\ndescribe('ReactNative', () => {\n const defaultCwd = process.cwd();\n\n beforeEach(() => {\n rimraf.sync(testDir);\n fs.mkdirSync(testDir);\n process.chdir(testDir);\n fs.writeFileSync(iosIndexJs, dummyJsContent);\n fs.mkdirSync(path.dirname(appTsx), { recursive: true });\n fs.writeFileSync(appTsx, dummyJsContent);\n fs.mkdirSync(path.dirname(appBuildGradle), { recursive: true });\n fs.writeFileSync(appBuildGradle, dummyAppBuildGradleContent);\n fs.writeFileSync(yarnLock, '');\n mockExec();\n });\n\n afterEach(() => {\n restoreExec();\n process.chdir(defaultCwd);\n rimraf.sync(testDir);\n });\n\n test('patches js files', async () => {\n const project = new ReactNative(testArgs as Args);\n await project.emit(mockIosAnswers);\n\n const patchedIosIndexJs = fs.readFileSync(iosIndexJs, 'utf8');\n const patchedAppTsx = fs.readFileSync(appTsx, 'utf8');\n const expectedPatch =\n 'import React from \"react\";\\n\\n' +\n \"import * as Sentry from '@sentry/react-native';\\n\\n\" +\n 'Sentry.init({ \\n' +\n \" dsn: 'dns.public.com', \\n\" +\n '});\\n\\n';\n expect(patchedIosIndexJs).toEqual(expectedPatch);\n expect(patchedAppTsx).toEqual(expectedPatch);\n });\n\n test('patches android app build gradle file', async () => {\n const project = new ReactNative(testArgs as Args);\n\n await project.emit(mockAndroidAnswers);\n\n const patchedAppBuildGradle = fs.readFileSync(appBuildGradle, 'utf8');\n const expectedPatch =\n 'apply plugin: \"com.facebook.react\"\\n\\n' +\n 'apply from: \"../../node_modules/@sentry/react-native/sentry.gradle\"\\n' +\n 'android {\\n}\\n';\n expect(patchedAppBuildGradle).toEqual(expectedPatch);\n });\n\n test('does install sentry sdk', async () => {\n const project = new ReactNative(testArgs as Args);\n\n await project.emit(mockIosAnswers);\n\n expect(child_process.exec).toHaveBeenCalledWith(\n 'yarn add @sentry/react-native',\n expect.anything(),\n );\n });\n\n test('executes pod install', async () => {\n const project = new ReactNative(testArgs as Args);\n\n await project.emit(mockIosAnswers);\n\n expect(child_process.exec).toHaveBeenCalledWith(\n 'npx --yes pod-install --non-interactive --quiet',\n expect.anything(),\n );\n });\n});\n"]}
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/wizard",
3
- "version": "3.7.1",
3
+ "version": "3.9.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",
@@ -32,7 +32,7 @@
32
32
  "glob": "^7.1.3",
33
33
  "inquirer": "^6.2.0",
34
34
  "lodash": "^4.17.15",
35
- "magicast": "^0.2.9",
35
+ "magicast": "^0.2.10",
36
36
  "opn": "^5.4.0",
37
37
  "r2": "^2.0.1",
38
38
  "read-env": "^1.3.0",
@@ -65,7 +65,7 @@
65
65
  "**/xmldom": "^0.6.0"
66
66
  },
67
67
  "engines": {
68
- "node": ">=14.0.0",
68
+ "node": ">=14.18.0",
69
69
  "npm": ">=3.10.7",
70
70
  "yarn": ">=1.0.2"
71
71
  },
@@ -76,15 +76,15 @@
76
76
  "build": "yarn tsc",
77
77
  "postbuild": "chmod +x ./dist/bin.js && cp -r scripts/** dist",
78
78
  "lint": "yarn lint:prettier && yarn lint:eslint",
79
- "lint:prettier": "prettier --check lib/**/*.ts",
79
+ "lint:prettier": "prettier --check \"{lib,src,test}/**/*.ts\"",
80
80
  "lint:eslint": "eslint . --cache --format stylish",
81
81
  "fix": "yarn fix:eslint && yarn fix:prettier",
82
- "fix:prettier": "prettier --write lib/**/*.ts",
82
+ "fix:prettier": "prettier --write \"{lib,src,test}/**/*.ts\"",
83
83
  "fix:eslint": "eslint . --format stylish --fix",
84
84
  "test": "yarn build && jest",
85
85
  "try": "ts-node bin.ts",
86
86
  "try:uninstall": "ts-node bin.ts --uninstall",
87
- "test:watch": "jest --watch --notify"
87
+ "test:watch": "jest --watch"
88
88
  },
89
89
  "jest": {
90
90
  "collectCoverage": true,
@@ -114,5 +114,9 @@
114
114
  "testEnvironment": "node"
115
115
  },
116
116
  "author": "Sentry",
117
- "license": "MIT"
117
+ "license": "MIT",
118
+ "volta": {
119
+ "node": "14.18.3",
120
+ "yarn": "1.22.19"
121
+ }
118
122
  }
@@ -77,6 +77,8 @@ var codeTools = __importStar(require("./code-tools"));
77
77
  var bash = __importStar(require("../utils/bash"));
78
78
  var Sentry = __importStar(require("@sentry/node"));
79
79
  var telemetry_1 = require("../telemetry");
80
+ var cocoapod = __importStar(require("./cocoapod"));
81
+ var fastlane = __importStar(require("./fastlane"));
80
82
  var xcode = require('xcode');
81
83
  /* eslint-enable @typescript-eslint/no-unused-vars */
82
84
  var clack_utils_1 = require("../utils/clack-utils");
@@ -93,7 +95,7 @@ function runAppleWizard(options) {
93
95
  exports.runAppleWizard = runAppleWizard;
94
96
  function runAppleWizardWithTelementry(options) {
95
97
  return __awaiter(this, void 0, void 0, function () {
96
- var hasCli, projectDir, xcodeProjFiles, xcodeProjFile, pbxproj, _a, project, apiKey, projSource, codeAdded;
98
+ var hasCli, projectDir, xcodeProjFiles, xcodeProjFile, pbxproj, _a, project, apiKey, hasCocoa, podAdded, projSource, codeAdded, addLane;
97
99
  return __generator(this, function (_b) {
98
100
  switch (_b.label) {
99
101
  case 0:
@@ -148,9 +150,22 @@ function runAppleWizardWithTelementry(options) {
148
150
  case 11: return [4 /*yield*/, getSentryProjectAndApiKey(options.promoCode, options.url)];
149
151
  case 12:
150
152
  _a = _b.sent(), project = _a.project, apiKey = _a.apiKey;
153
+ hasCocoa = cocoapod.usesCocoaPod(projectDir);
154
+ if (!hasCocoa) return [3 /*break*/, 14];
155
+ return [4 /*yield*/, (0, telemetry_1.traceStep)('Add CocoaPods reference', function () {
156
+ return cocoapod.addCocoaPods(projectDir);
157
+ })];
158
+ case 13:
159
+ podAdded = _b.sent();
160
+ if (!podAdded) {
161
+ prompts_1.default.log.warn("Could not add Sentry pod to your Podfile. You'll have to add it manually.\nPlease follow the instructions at https://docs.sentry.io/platforms/apple/guides/ios/#install");
162
+ }
163
+ _b.label = 14;
164
+ case 14:
151
165
  (0, telemetry_1.traceStep)('Update Xcode project', function () {
152
- xcManager.updateXcodeProject(pbxproj, project, apiKey, true, true);
166
+ xcManager.updateXcodeProject(pbxproj, project, apiKey, !hasCocoa, true);
153
167
  });
168
+ Sentry.setTag('package-manager', hasCocoa ? 'cocoapods' : 'SPM');
154
169
  projSource = path.join(projectDir, xcodeProjFile.replace('.xcodeproj', ''));
155
170
  codeAdded = (0, telemetry_1.traceStep)('Add code snippet', function () {
156
171
  return codeTools.addCodeSnippetToProject(projSource, project.keys[0].dsn.public);
@@ -159,6 +174,20 @@ function runAppleWizardWithTelementry(options) {
159
174
  prompts_1.default.log.warn('Added the Sentry dependency to your project but could not add the Sentry code snippet. Please add the code snipped manually by following the docs: https://docs.sentry.io/platforms/apple/guides/ios/#configure');
160
175
  return [2 /*return*/];
161
176
  }
177
+ if (!fastlane.fastFile(projectDir)) return [3 /*break*/, 17];
178
+ return [4 /*yield*/, prompts_1.default.confirm({
179
+ message: 'Found a Fastfile in your project. Do you want to configure a lane to upload debug symbols to Sentry?',
180
+ })];
181
+ case 15:
182
+ addLane = _b.sent();
183
+ if (!addLane) return [3 /*break*/, 17];
184
+ return [4 /*yield*/, (0, telemetry_1.traceStep)('Configure fastlane', function () {
185
+ return fastlane.addSentryToFastlane(projectDir, project.organization.slug, project.slug, apiKey.token);
186
+ })];
187
+ case 16:
188
+ _b.sent();
189
+ _b.label = 17;
190
+ case 17:
162
191
  prompts_1.default.log.success('Sentry was successfully added to your project!');
163
192
  return [2 /*return*/];
164
193
  }
@@ -1 +1 @@
1
- {"version":3,"file":"apple-wizard.js","sourceRoot":"","sources":["../../../src/apple/apple-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+DAA+D;AAC/D,4DAA4D;AAC5D,sDAAsD;AACtD,sDAAsD;AACtD,yEAAyE;AACzE,2DAAmC;AACnC,qCAAyB;AACzB,yCAA6B;AAC7B,yDAA6C;AAC7C,sDAA0C;AAC1C,kDAAsC;AAEtC,mDAAuC;AACvC,0CAAwD;AAExD,IAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC/B,qDAAqD;AAErD,oDAS8B;AAE9B,SAAsB,cAAc,CAAC,OAAsB;;;YACzD,sBAAO,IAAA,yBAAa,EAClB;oBACE,OAAO,EAAE,OAAO,CAAC,gBAAgB;oBACjC,WAAW,EAAE,KAAK;iBACnB,EACD,cAAM,OAAA,4BAA4B,CAAC,OAAO,CAAC,EAArC,CAAqC,CAC5C,EAAC;;;CACH;AARD,wCAQC;AAED,SAAe,4BAA4B,CACzC,OAAsB;;;;;;oBAEtB,IAAA,0BAAY,EAAC;wBACX,UAAU,EAAE,qBAAqB;wBACjC,SAAS,EAAE,OAAO,CAAC,SAAS;qBAC7B,CAAC,CAAC;oBAEG,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;oBACnC,MAA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e,qBAAM,IAAA,8BAAgB,EAAC,GAAG,CAAC,EAAA;;oBAAzC,SAAS,GAAK,CAAA,SAA2B,CAAA,IAAhC;oBAEQ,qBAAM,IAAA,+BAAiB,EAAC;4BACpD,SAAS,EAAE,SAAS;4BACpB,GAAG,EAAE,SAAS;4BACd,QAAQ,EAAE,WAAW;yBACtB,CAAC,EAAA;;oBAJI,KAAwB,SAI5B,EAJM,QAAQ,cAAA,EAAE,OAAO,aAAA;oBAMD,qBAAM,IAAA,oCAAsB,EAAC,QAAQ,CAAC,EAAA;;oBAAxD,eAAe,GAAG,SAAsC;oBAC9D,sBAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,EAAC;;;;CACtD;AAED,qCAAqC;AACrC,SAAS,sBAAsB,CAAC,GAAW,EAAE,SAAiB;IAC5D,IAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,MAAM,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAxB,CAAwB,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unused-vars */\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as xcManager from './xcode-manager';\nimport * as codeTools from './code-tools';\nimport * as bash from '../utils/bash';\nimport { WizardOptions } from '../utils/types';\nimport * as Sentry from '@sentry/node';\nimport { traceStep, withTelemetry } from '../telemetry';\n\nconst xcode = require('xcode');\n/* eslint-enable @typescript-eslint/no-unused-vars */\n\nimport {\n askForProjectSelection,\n askForSelfHosted,\n askForWizardLogin,\n askToInstallSentryCLI,\n SentryProjectData,\n printWelcome,\n abort,\n askForItemSelection,\n} from '../utils/clack-utils';\n\nexport async function runAppleWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'ios',\n },\n () => runAppleWizardWithTelementry(options),\n );\n}\n\nasync function runAppleWizardWithTelementry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Apple Wizard',\n promoCode: options.promoCode,\n });\n\n const hasCli = bash.hasSentryCLI();\n Sentry.setTag('has-cli', hasCli);\n if (!hasCli) {\n if (\n !(await traceStep('Ask for SentryCLI', () => askToInstallSentryCLI()))\n ) {\n clack.log.warn(\n \"Without sentry-cli, you won't be able to upload debug symbols to Sentry. You can install it later by following the instructions at https://docs.sentry.io/cli/\",\n );\n Sentry.setTag('CLI-Installed', false);\n } else {\n await bash.installSentryCLI();\n Sentry.setTag('CLI-Installed', true);\n }\n }\n\n const projectDir = process.cwd();\n const xcodeProjFiles = findFilesWithExtension(projectDir, '.xcodeproj');\n\n if (!xcodeProjFiles || xcodeProjFiles.length === 0) {\n clack.log.error(\n 'No Xcode project found. Please run this command from the root of your project.',\n );\n await abort();\n return;\n }\n\n let xcodeProjFile;\n\n if (xcodeProjFiles.length === 1) {\n xcodeProjFile = xcodeProjFiles[0];\n Sentry.setTag('multiple-projects', false);\n } else {\n Sentry.setTag('multiple-projects', true);\n xcodeProjFile = (\n await traceStep('Choose Xcode project', () =>\n askForItemSelection(\n xcodeProjFiles,\n 'Which project do you want to add Sentry to?',\n ),\n )\n ).value;\n }\n\n const pbxproj = path.join(projectDir, xcodeProjFile, 'project.pbxproj');\n if (!fs.existsSync(pbxproj)) {\n clack.log.error(`No pbxproj found at ${pbxproj}`);\n await abort();\n return;\n }\n\n const { project, apiKey } = await getSentryProjectAndApiKey(\n options.promoCode,\n options.url,\n );\n\n traceStep('Update Xcode project', () => {\n xcManager.updateXcodeProject(pbxproj, project, apiKey, true, true);\n });\n\n const projSource = path.join(\n projectDir,\n xcodeProjFile.replace('.xcodeproj', ''),\n );\n const codeAdded = traceStep('Add code snippet', () => {\n return codeTools.addCodeSnippetToProject(\n projSource,\n project.keys[0].dsn.public,\n );\n });\n if (!codeAdded) {\n clack.log.warn(\n 'Added the Sentry dependency to your project but could not add the Sentry code snippet. Please add the code snipped manually by following the docs: https://docs.sentry.io/platforms/apple/guides/ios/#configure',\n );\n return;\n }\n\n clack.log.success('Sentry was successfully added to your project!');\n}\n\n//Prompt for Sentry project and API key\nasync function getSentryProjectAndApiKey(\n promoCode?: string,\n url?: string,\n): Promise<{ project: SentryProjectData; apiKey: { token: string } }> {\n const { url: sentryUrl } = await askForSelfHosted(url);\n\n const { projects, apiKeys } = await askForWizardLogin({\n promoCode: promoCode,\n url: sentryUrl,\n platform: 'apple-ios',\n });\n\n const selectedProject = await askForProjectSelection(projects);\n return { project: selectedProject, apiKey: apiKeys };\n}\n\n//find files with the given extension\nfunction findFilesWithExtension(dir: string, extension: string): string[] {\n const files = fs.readdirSync(dir);\n return files.filter((file) => file.endsWith(extension));\n}\n"]}
1
+ {"version":3,"file":"apple-wizard.js","sourceRoot":"","sources":["../../../src/apple/apple-wizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+DAA+D;AAC/D,4DAA4D;AAC5D,sDAAsD;AACtD,sDAAsD;AACtD,yEAAyE;AACzE,2DAAmC;AACnC,qCAAyB;AACzB,yCAA6B;AAC7B,yDAA6C;AAC7C,sDAA0C;AAC1C,kDAAsC;AAEtC,mDAAuC;AACvC,0CAAwD;AACxD,mDAAuC;AACvC,mDAAuC;AAEvC,IAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC/B,qDAAqD;AAErD,oDAQ8B;AAE9B,SAAsB,cAAc,CAAC,OAAsB;;;YACzD,sBAAO,IAAA,yBAAa,EAClB;oBACE,OAAO,EAAE,OAA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AClB,GAAY;;;;;wBAEe,qBAAM,IAAA,8BAAgB,EAAC,GAAG,CAAC,EAAA;;oBAAzC,SAAS,GAAK,CAAA,SAA2B,CAAA,IAAhC;oBAEQ,qBAAM,IAAA,+BAAiB,EAAC;4BACpD,SAAS,EAAE,SAAS;4BACpB,GAAG,EAAE,SAAS;4BACd,QAAQ,EAAE,WAAW;yBACtB,CAAC,EAAA;;oBAJI,KAAwB,SAI5B,EAJM,QAAQ,cAAA,EAAE,OAAO,aAAA;oBAMD,qBAAM,IAAA,oCAAsB,EAAC,QAAQ,CAAC,EAAA;;oBAAxD,eAAe,GAAG,SAAsC;oBAC9D,sBAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,EAAC;;;;CACtD;AAED,qCAAqC;AACrC,SAAS,sBAAsB,CAAC,GAAW,EAAE,SAAiB;IAC5D,IAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,MAAM,CAAC,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAxB,CAAwB,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["/* eslint-disable max-lines */\n/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unused-vars */\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as xcManager from './xcode-manager';\nimport * as codeTools from './code-tools';\nimport * as bash from '../utils/bash';\nimport { SentryProjectData, WizardOptions } from '../utils/types';\nimport * as Sentry from '@sentry/node';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport * as cocoapod from './cocoapod';\nimport * as fastlane from './fastlane';\n\nconst xcode = require('xcode');\n/* eslint-enable @typescript-eslint/no-unused-vars */\n\nimport {\n askForProjectSelection,\n askForSelfHosted,\n askForWizardLogin,\n askToInstallSentryCLI,\n printWelcome,\n abort,\n askForItemSelection,\n} from '../utils/clack-utils';\n\nexport async function runAppleWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'ios',\n },\n () => runAppleWizardWithTelementry(options),\n );\n}\n\nasync function runAppleWizardWithTelementry(\n options: WizardOptions,\n): Promise<void> {\n printWelcome({\n wizardName: 'Sentry Apple Wizard',\n promoCode: options.promoCode,\n });\n\n const hasCli = bash.hasSentryCLI();\n Sentry.setTag('has-cli', hasCli);\n if (!hasCli) {\n if (\n !(await traceStep('Ask for SentryCLI', () => askToInstallSentryCLI()))\n ) {\n clack.log.warn(\n \"Without sentry-cli, you won't be able to upload debug symbols to Sentry. You can install it later by following the instructions at https://docs.sentry.io/cli/\",\n );\n Sentry.setTag('CLI-Installed', false);\n } else {\n await bash.installSentryCLI();\n Sentry.setTag('CLI-Installed', true);\n }\n }\n\n const projectDir = process.cwd();\n const xcodeProjFiles = findFilesWithExtension(projectDir, '.xcodeproj');\n\n if (!xcodeProjFiles || xcodeProjFiles.length === 0) {\n clack.log.error(\n 'No Xcode project found. Please run this command from the root of your project.',\n );\n await abort();\n return;\n }\n\n let xcodeProjFile;\n\n if (xcodeProjFiles.length === 1) {\n xcodeProjFile = xcodeProjFiles[0];\n Sentry.setTag('multiple-projects', false);\n } else {\n Sentry.setTag('multiple-projects', true);\n xcodeProjFile = (\n await traceStep('Choose Xcode project', () =>\n askForItemSelection(\n xcodeProjFiles,\n 'Which project do you want to add Sentry to?',\n ),\n )\n ).value;\n }\n\n const pbxproj = path.join(projectDir, xcodeProjFile, 'project.pbxproj');\n if (!fs.existsSync(pbxproj)) {\n clack.log.error(`No pbxproj found at ${pbxproj}`);\n await abort();\n return;\n }\n\n const { project, apiKey } = await getSentryProjectAndApiKey(\n options.promoCode,\n options.url,\n );\n\n const hasCocoa = cocoapod.usesCocoaPod(projectDir);\n\n if (hasCocoa) {\n const podAdded = await traceStep('Add CocoaPods reference', () =>\n cocoapod.addCocoaPods(projectDir),\n );\n if (!podAdded) {\n clack.log.warn(\n \"Could not add Sentry pod to your Podfile. You'll have to add it manually.\\nPlease follow the instructions at https://docs.sentry.io/platforms/apple/guides/ios/#install\",\n );\n }\n }\n\n traceStep('Update Xcode project', () => {\n xcManager.updateXcodeProject(pbxproj, project, apiKey, !hasCocoa, true);\n });\n\n Sentry.setTag('package-manager', hasCocoa ? 'cocoapods' : 'SPM');\n const projSource = path.join(\n projectDir,\n xcodeProjFile.replace('.xcodeproj', ''),\n );\n const codeAdded = traceStep('Add code snippet', () => {\n return codeTools.addCodeSnippetToProject(\n projSource,\n project.keys[0].dsn.public,\n );\n });\n if (!codeAdded) {\n clack.log.warn(\n 'Added the Sentry dependency to your project but could not add the Sentry code snippet. Please add the code snipped manually by following the docs: https://docs.sentry.io/platforms/apple/guides/ios/#configure',\n );\n return;\n }\n\n if (fastlane.fastFile(projectDir)) {\n const addLane = await clack.confirm({\n message:\n 'Found a Fastfile in your project. Do you want to configure a lane to upload debug symbols to Sentry?',\n });\n if (addLane) {\n await traceStep('Configure fastlane', () =>\n fastlane.addSentryToFastlane(\n projectDir,\n project.organization.slug,\n project.slug,\n apiKey.token,\n ),\n );\n }\n }\n\n clack.log.success('Sentry was successfully added to your project!');\n}\n\n//Prompt for Sentry project and API key\nasync function getSentryProjectAndApiKey(\n promoCode?: string,\n url?: string,\n): Promise<{ project: SentryProjectData; apiKey: { token: string } }> {\n const { url: sentryUrl } = await askForSelfHosted(url);\n\n const { projects, apiKeys } = await askForWizardLogin({\n promoCode: promoCode,\n url: sentryUrl,\n platform: 'apple-ios',\n });\n\n const selectedProject = await askForProjectSelection(projects);\n return { project: selectedProject, apiKey: apiKeys };\n}\n\n//find files with the given extension\nfunction findFilesWithExtension(dir: string, extension: string): string[] {\n const files = fs.readdirSync(dir);\n return files.filter((file) => file.endsWith(extension));\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function usesCocoaPod(projPath: string): boolean;
2
+ export declare function addCocoaPods(projPath: string): Promise<boolean>;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __generator = (this && this.__generator) || function (thisArg, body) {
35
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
+ function verb(n) { return function (v) { return step([n, v]); }; }
38
+ function step(op) {
39
+ if (f) throw new TypeError("Generator is already executing.");
40
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
+ 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;
42
+ if (y = 0, t) op = [op[0] & 2, t.value];
43
+ switch (op[0]) {
44
+ case 0: case 1: t = op; break;
45
+ case 4: _.label++; return { value: op[1], done: false };
46
+ case 5: _.label++; y = op[1]; op = [0]; continue;
47
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
+ default:
49
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
+ if (t[2]) _.ops.pop();
54
+ _.trys.pop(); continue;
55
+ }
56
+ op = body.call(thisArg, _);
57
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
+ }
60
+ };
61
+ Object.defineProperty(exports, "__esModule", { value: true });
62
+ exports.addCocoaPods = exports.usesCocoaPod = void 0;
63
+ var fs = __importStar(require("fs"));
64
+ var path = __importStar(require("path"));
65
+ var bash = __importStar(require("../utils/bash"));
66
+ var Sentry = __importStar(require("@sentry/node"));
67
+ // @ts-ignore - clack is ESM and TS complains about that. It works though
68
+ var clack = __importStar(require("@clack/prompts"));
69
+ function usesCocoaPod(projPath) {
70
+ return fs.existsSync(path.join(projPath, 'Podfile'));
71
+ }
72
+ exports.usesCocoaPod = usesCocoaPod;
73
+ function addCocoaPods(projPath) {
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ var podfile, podContent, podMatch, frameworkMatch, insertIndex, newFileContent, loginSpinner, e_1;
76
+ return __generator(this, function (_a) {
77
+ switch (_a.label) {
78
+ case 0:
79
+ podfile = path.join(projPath, 'Podfile');
80
+ podContent = fs.readFileSync(podfile, 'utf8');
81
+ if (/^\s*pod\s+(['"]Sentry['"]|['"]SentrySwiftUI['"])\s*$/im.test(podContent)) {
82
+ // Already have Sentry pod
83
+ return [2 /*return*/, true];
84
+ }
85
+ podMatch = /^( *)pod\s+['"](\w+)['"] *$/im.exec(podContent);
86
+ if (!podMatch) {
87
+ frameworkMatch = /^( *)use_frameworks![^\n]* *$/im.exec(podContent);
88
+ if (!frameworkMatch) {
89
+ return [2 /*return*/, false];
90
+ }
91
+ podMatch = frameworkMatch;
92
+ }
93
+ insertIndex = podMatch.index + podMatch[0].length;
94
+ newFileContent = podContent.slice(0, insertIndex) +
95
+ '\n' +
96
+ podMatch[1] +
97
+ "pod 'Sentry'\n" +
98
+ podContent.slice(insertIndex);
99
+ fs.writeFileSync(podfile, newFileContent, 'utf8');
100
+ loginSpinner = clack.spinner();
101
+ loginSpinner.start("Running 'pod install'. This may take a few minutes...");
102
+ _a.label = 1;
103
+ case 1:
104
+ _a.trys.push([1, 3, , 4]);
105
+ return [4 /*yield*/, bash.execute('pod install --silent')];
106
+ case 2:
107
+ _a.sent();
108
+ loginSpinner.stop('Sentry pod added to the project.');
109
+ return [3 /*break*/, 4];
110
+ case 3:
111
+ e_1 = _a.sent();
112
+ clack.log.error("'pod install' failed. You will need to run it manually.");
113
+ loginSpinner.stop();
114
+ Sentry.captureException('Sentry pod install failed.');
115
+ return [3 /*break*/, 4];
116
+ case 4: return [2 /*return*/, true];
117
+ }
118
+ });
119
+ });
120
+ }
121
+ exports.addCocoaPods = addCocoaPods;
122
+ //# sourceMappingURL=cocoapod.js.map
@@ -0,0 +1 @@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,CAAC,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;oBAE5C,YAAY,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;oBAErC,YAAY,CAAC,KAAK,CAAC,uDAAuD,CAAC,CAAC;;;;oBAG1E,qBAAM,IAAI,CAAC,OAAO,CAAC,sBAAsB,CAAC,EAAA;;oBAA1C,SAA0C,CAAC;oBAC3C,YAAY,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;;;;oBAEtD,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;oBAC3E,YAAY,CAAC,IAAI,EAAE,CAAC;oBACpB,MAAM,CAAC,gBAAgB,CAAC,4BAA4B,CAAC,CAAC;;wBAGxD,sBAAO,IAAI,EAAC;;;;CACb;AA7CD,oCA6CC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport * as bash from '../utils/bash';\nimport * as Sentry from '@sentry/node';\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\n\nexport function usesCocoaPod(projPath: string): boolean {\n return fs.existsSync(path.join(projPath, 'Podfile'));\n}\n\nexport async function addCocoaPods(projPath: string): Promise<boolean> {\n const podfile = path.join(projPath, 'Podfile');\n\n const podContent = fs.readFileSync(podfile, 'utf8');\n\n if (\n /^\\s*pod\\s+(['\"]Sentry['\"]|['\"]SentrySwiftUI['\"])\\s*$/im.test(podContent)\n ) {\n // Already have Sentry pod\n return true;\n }\n\n let podMatch = /^( *)pod\\s+['\"](\\w+)['\"] *$/im.exec(podContent);\n if (!podMatch) {\n // No Podfile is empty, will try to add Sentry pod after \"use_frameworks!\"\n const frameworkMatch = /^( *)use_frameworks![^\\n]* *$/im.exec(podContent);\n if (!frameworkMatch) {\n return false;\n }\n podMatch = frameworkMatch;\n }\n\n const insertIndex = podMatch.index + podMatch[0].length;\n const newFileContent =\n podContent.slice(0, insertIndex) +\n '\\n' +\n podMatch[1] +\n \"pod 'Sentry'\\n\" +\n podContent.slice(insertIndex);\n fs.writeFileSync(podfile, newFileContent, 'utf8');\n\n const loginSpinner = clack.spinner();\n\n loginSpinner.start(\"Running 'pod install'. This may take a few minutes...\");\n\n try {\n await bash.execute('pod install --silent');\n loginSpinner.stop('Sentry pod added to the project.');\n } catch (e) {\n clack.log.error(\"'pod install' failed. You will need to run it manually.\");\n loginSpinner.stop();\n Sentry.captureException('Sentry pod install failed.');\n }\n\n return true;\n}\n"]}
@@ -32,24 +32,31 @@ var swiftAppLaunchRegex = /(func\s+application\s*\(_\sapplication:[^,]+,\s*didFi
32
32
  var objcAppLaunchRegex = /-\s*\(BOOL\)\s*application:\s*\(UIApplication\s*\*\)\s*application\s+didFinishLaunchingWithOptions:\s*\(NSDictionary\s*\*\)\s*launchOptions\s*{/im;
33
33
  var swiftUIRegex = /struct[^:]+:\s*App\s*{/im;
34
34
  function isAppDelegateFile(filePath) {
35
- var appLaunchRegex = filePath.toLowerCase().endsWith(".swift") ? swiftAppLaunchRegex : objcAppLaunchRegex;
35
+ var appLaunchRegex = filePath.toLowerCase().endsWith('.swift')
36
+ ? swiftAppLaunchRegex
37
+ : objcAppLaunchRegex;
36
38
  var fileContent = fs.readFileSync(filePath, 'utf8');
37
39
  return appLaunchRegex.test(fileContent) || swiftUIRegex.test(fileContent);
38
40
  }
39
41
  function findAppDidFinishLaunchingWithOptions(dir) {
40
42
  var files = fs.readdirSync(dir);
41
- //iterate over subdirectories later,
43
+ //iterate over subdirectories later,
42
44
  //the appdelegate usually is in the top level
43
45
  var dirs = [];
44
46
  for (var _i = 0, files_1 = files; _i < files_1.length; _i++) {
45
47
  var file = files_1[_i];
46
48
  var filePath = path.join(dir, file);
47
- if (file.endsWith(".swift") || file.endsWith(".m") || file.endsWith(".mm")) {
49
+ if (file.endsWith('.swift') ||
50
+ file.endsWith('.m') ||
51
+ file.endsWith('.mm')) {
48
52
  if (isAppDelegateFile(filePath)) {
49
53
  return filePath;
50
54
  }
51
55
  }
52
- else if (!file.startsWith(".") && !file.endsWith(".xcodeproj") && !file.endsWith(".xcassets") && fs.lstatSync(filePath).isDirectory()) {
56
+ else if (!file.startsWith('.') &&
57
+ !file.endsWith('.xcodeproj') &&
58
+ !file.endsWith('.xcassets') &&
59
+ fs.lstatSync(filePath).isDirectory()) {
53
60
  dirs.push(file);
54
61
  }
55
62
  }
@@ -67,13 +74,15 @@ function addCodeSnippetToProject(projPath, dsn) {
67
74
  return false;
68
75
  }
69
76
  var fileContent = fs.readFileSync(appDelegate, 'utf8');
70
- var isSwift = appDelegate.toLowerCase().endsWith(".swift");
77
+ var isSwift = appDelegate.toLowerCase().endsWith('.swift');
71
78
  var appLaunchRegex = isSwift ? swiftAppLaunchRegex : objcAppLaunchRegex;
72
- var importStatement = isSwift ? "import Sentry\n" : "@import Sentry;\n";
73
- var checkForSentryInit = isSwift ? "SentrySDK.start" : "[SentrySDK start";
74
- var codeSnippet = isSwift ? templates.getSwiftSnippet(dsn) : templates.getObjcSnippet(dsn);
75
- Sentry.setTag("code-language", isSwift ? "swift" : "objc");
76
- Sentry.setTag("ui-engine", swiftUIRegex.test(fileContent) ? "swiftui" : "uikit");
79
+ var importStatement = isSwift ? 'import Sentry\n' : '@import Sentry;\n';
80
+ var checkForSentryInit = isSwift ? 'SentrySDK.start' : '[SentrySDK start';
81
+ var codeSnippet = isSwift
82
+ ? templates.getSwiftSnippet(dsn)
83
+ : templates.getObjcSnippet(dsn);
84
+ Sentry.setTag('code-language', isSwift ? 'swift' : 'objc');
85
+ Sentry.setTag('ui-engine', swiftUIRegex.test(fileContent) ? 'swiftui' : 'uikit');
77
86
  if (fileContent.includes(checkForSentryInit)) {
78
87
  //already initialized
79
88
  return true;
@@ -89,8 +98,9 @@ function addCodeSnippetToProject(projPath, dsn) {
89
98
  codeSnippet = " init() {\n".concat(codeSnippet, " }");
90
99
  }
91
100
  var insertIndex = match.index + match[0].length;
92
- var newFileContent = (fileContent.indexOf(importStatement) >= 0 ? "" : importStatement) +
93
- fileContent.slice(0, insertIndex) + "\n" +
101
+ var newFileContent = (fileContent.indexOf(importStatement) >= 0 ? '' : importStatement) +
102
+ fileContent.slice(0, insertIndex) +
103
+ '\n' +
94
104
  codeSnippet +
95
105
  fileContent.slice(insertIndex);
96
106
  fs.writeFileSync(appDelegate, newFileContent, 'utf8');