@sentry/wizard 2.5.0 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.6.1
4
+
5
+ - fix(rn): Upload debug files from `$DWARF_DSYM_FOLDER_PATH` during Xcode build ([#240](https://github.com/getsentry/sentry-wizard/pull/240))
6
+
7
+ ## 2.6.0
8
+
9
+ - feat(rn): Support patching app/build.gradle RN 0.71.0 and Expo SDK 43+ bare workflow ([#229](https://github.com/getsentry/sentry-wizard/pull/229))
10
+
3
11
  ## 2.5.0
4
12
 
5
13
  - feat: Merge next.config.js files automatically (#222)
@@ -4,6 +4,10 @@ import { SentryCli } from '../../Helper/SentryCli';
4
4
  import { MobileProject } from './MobileProject';
5
5
  export declare class ReactNative extends MobileProject {
6
6
  protected _argv: Args;
7
+ /**
8
+ * All React Native versions have app/build.gradle with android section.
9
+ */
10
+ private static _buildGradleAndroidSectionBeginning;
7
11
  protected _answers: Answers;
8
12
  protected _sentryCli: SentryCli;
9
13
  constructor(_argv: Args);
@@ -265,9 +265,9 @@ var ReactNative = /** @class */ (function (_super) {
265
265
  if (contents.indexOf(applyFrom) >= 0) {
266
266
  return Promise.resolve(null);
267
267
  }
268
- return Promise.resolve(contents.replace(/^apply from: "..\/..\/node_modules\/react-native\/react.gradle"/m,
268
+ return Promise.resolve(contents.replace(ReactNative._buildGradleAndroidSectionBeginning,
269
269
  // eslint-disable-next-line prefer-template
270
- function (match) { return match + '\n' + applyFrom; }));
270
+ function (match) { return applyFrom + '\n' + match; }));
271
271
  };
272
272
  ReactNative.prototype._unpatchBuildGradle = function (contents) {
273
273
  return Promise.resolve(contents.replace(/^\s*apply from: ["']..\/..\/node_modules\/@sentry\/react-native\/sentry.gradle["'];?\s*?\r?\n/m, ''));
@@ -302,7 +302,7 @@ var ReactNative = /** @class */ (function (_super) {
302
302
  }
303
303
  proj.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Upload Debug Symbols to Sentry', null, {
304
304
  shellPath: '/bin/sh',
305
- 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\"\n",
305
+ 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",
306
306
  });
307
307
  };
308
308
  ReactNative.prototype._patchXcodeProj = function (contents, filename) {
@@ -419,6 +419,10 @@ var ReactNative = /** @class */ (function (_super) {
419
419
  });
420
420
  });
421
421
  };
422
+ /**
423
+ * All React Native versions have app/build.gradle with android section.
424
+ */
425
+ ReactNative._buildGradleAndroidSectionBeginning = /^android {/m;
422
426
  return ReactNative;
423
427
  }(MobileProject_1.MobileProject));
424
428
  exports.ReactNative = ReactNative;
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNative.js","sourceRoot":"","sources":["../../../../lib/Steps/Integrations/ReactNative.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,uBAAyB;AAEzB,0BAA4B;AAC5B,2BAA6B;AAG7B,0CAA0F;AAC1F,gDAA+D;AAC/D,oDAAmD;AACnD,iDAAgD;AAEhD,IAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE/B;IAAiC,+BAAa;IAI5C,qBAAsB,KAAW;QAAjC,YACE,kBAAM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AAgE;gBAChE,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;gBACpB,gEAAgE;gBAChE,OAAO,OAAO,CAAI,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;IACH,kBAAC;AAAD,CAAC,AA5ZD,CAAiC,6BAAa,GA4Z7C;AA5ZY,kCAAW","sourcesContent":["/* eslint-disable max-lines */\nimport * as fs from 'fs';\nimport { Answers } from 'inquirer';\nimport * as _ from 'lodash';\nimport * as path from 'path';\n\nimport { Args } from '../../Constants';\nimport { exists, matchesContent, matchFiles, patchMatchingFile } from '../../Helper/File';\nimport { dim, green, red, yellow } from '../../Helper/Logging';\nimport { SentryCli } from '../../Helper/SentryCli';\nimport { MobileProject } from './MobileProject';\n\nconst xcode = require('xcode');\n\nexport class ReactNative extends MobileProject {\n protected _answers: Answers;\n protected _sentryCli: SentryCli;\n\n constructor(protected _argv: Args) {\n super(_argv);\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\n const sentryCliProperties = this._sentryCli.convertAnswersToProperties(\n answers,\n );\n\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\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 dim(`✅ Patched build script in Xcode project.`);\n } else {\n await patchMatchingFile(\n '**/app/build.gradle',\n this._patchBuildGradle.bind(this),\n );\n dim(`✅ Patched build.gradle file.`);\n }\n await this._patchJsSentryInit(platform, answers);\n await this._addSentryProperties(platform, sentryCliProperties);\n dim(`✅ Added sentry.properties file to ${platform}`);\n\n green(`Successfully set up ${platform} for react-native`);\n } catch (e) {\n red(e);\n }\n },\n );\n Promise.all(promises)\n .then(resolve)\n .catch(reject);\n });\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 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 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 dim(`✅ Patched ${jsFileToPatch.join(', ')} file(s).`);\n } else {\n dim(`🚨 Could not find ${platformGlob} nor ${universalGlob} files.`);\n yellow('❓ 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 return Promise.resolve(\n contents.replace(\n /^apply from: \"..\\/..\\/node_modules\\/react-native\\/react.gradle\"/m,\n // eslint-disable-next-line prefer-template\n match => match + '\\n' + applyFrom,\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(\n /\\/scripts\\/react-native-xcode\\.sh/i,\n ) ||\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\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 (script.shellScript.match(/sentry-cli\\s+(upload-dsym|debug-files upload)/)) {\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\"\n`,\n },\n );\n }\n\n private _patchXcodeProj(contents: string, filename: string): 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 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();\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(/^\\/bin\\/sh ..\\/node_modules\\/@sentry\\/react-native\\/scripts\\/collect-modules.sh\\r?\\n/m, '')\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,uBAAyB;AAEzB,0BAA4B;AAC5B,2BAA6B;AAG7B,0CAA0F;AAC1F,gDAA+D;AAC/D,oDAAmD;AACnD,iDAAgD;AAEhD,IAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE/B;IAAiC,+BAAa;IAU5C,qBAAsB,KAAW;QAAjC,YACE,kBAAM,KAAK,CAAC,SAEb;QAHqB,WAAK,GAAL,KAAK,CAAM;QAE/B,KAAI,CAAC,UAAU,GAAG,IAAI,qBAAS,CAAC,KAAI,CAAC,KAAK,CAAC,CAAC;;IAC9C,CAAC;IAEY,0BAAI,GAAjB,UAAkB,OAAgB;;;;;;;wBAChC,IAAI,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE;4BACxB,sBAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAC;yBAChC;wBACK,qBAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAA;;wBAApC,IAAI,CAAC,CAAC,SAA8B,CAAC,EAAE;4BACrC,s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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;IAhaD;;OAEG;IACY,+CAAmC,GAAW,aAAa,CAAC;IA8Z7E,kBAAC;CAAA,AAnaD,CAAiC,6BAAa,GAma7C;AAnaY,kCAAW","sourcesContent":["/* eslint-disable max-lines */\nimport * as fs from 'fs';\nimport { Answers } from 'inquirer';\nimport * as _ from 'lodash';\nimport * as path from 'path';\n\nimport { Args } from '../../Constants';\nimport { exists, matchesContent, matchFiles, patchMatchingFile } from '../../Helper/File';\nimport { dim, green, red, yellow } from '../../Helper/Logging';\nimport { SentryCli } from '../../Helper/SentryCli';\nimport { MobileProject } from './MobileProject';\n\nconst xcode = require('xcode');\n\nexport class ReactNative extends MobileProject {\n\n /**\n * All React Native versions have app/build.gradle with android section.\n */\n private static _buildGradleAndroidSectionBeginning: RegExp = /^android {/m;\n\n protected _answers: Answers;\n protected _sentryCli: SentryCli;\n\n constructor(protected _argv: Args) {\n super(_argv);\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\n const sentryCliProperties = this._sentryCli.convertAnswersToProperties(\n answers,\n );\n\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\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 dim(`✅ Patched build script in Xcode project.`);\n } else {\n await patchMatchingFile(\n '**/app/build.gradle',\n this._patchBuildGradle.bind(this),\n );\n dim(`✅ Patched build.gradle file.`);\n }\n await this._patchJsSentryInit(platform, answers);\n await this._addSentryProperties(platform, sentryCliProperties);\n dim(`✅ Added sentry.properties file to ${platform}`);\n\n green(`Successfully set up ${platform} for react-native`);\n } catch (e) {\n red(e);\n }\n },\n );\n Promise.all(promises)\n .then(resolve)\n .catch(reject);\n });\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 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 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 dim(`✅ Patched ${jsFileToPatch.join(', ')} file(s).`);\n } else {\n dim(`🚨 Could not find ${platformGlob} nor ${universalGlob} files.`);\n yellow('❓ 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(\n /\\/scripts\\/react-native-xcode\\.sh/i,\n ) ||\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\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 (script.shellScript.match(/sentry-cli\\s+(upload-dsym|debug-files upload)/)) {\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(contents: string, filename: string): 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 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();\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(/^\\/bin\\/sh ..\\/node_modules\\/@sentry\\/react-native\\/scripts\\/collect-modules.sh\\r?\\n/m, '')\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"]}
@@ -38,6 +38,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  jest.mock('../../../Helper/Logging.ts'); // We mock logging to not pollute the output
40
40
  var fs = require("fs");
41
+ var path = require("path");
41
42
  var process = require("process");
42
43
  var rimraf = require("rimraf");
43
44
  var Constants_1 = require("../../../Constants");
@@ -45,7 +46,9 @@ var ReactNative_1 = require("../ReactNative");
45
46
  var testDir = 'rn-test';
46
47
  var iosIndexJs = 'index.ios.js';
47
48
  var appTsx = 'src/App.tsx';
49
+ var appBuildGradle = 'android/app/build.gradle';
48
50
  var dummyJsContent = 'import React from "react";\n';
51
+ var dummyAppBuildGradleContent = 'apply plugin: "com.facebook.react"\n\nandroid {\n}\n';
49
52
  var testArgs = {
50
53
  debug: false,
51
54
  integration: Constants_1.Integration.reactNative,
@@ -55,7 +58,7 @@ var testArgs = {
55
58
  uninstall: false,
56
59
  url: 'https://not.used',
57
60
  };
58
- var testAnswers = {
61
+ var mockIosAnswers = {
59
62
  shouldConfigurePlatforms: { 'ios': true },
60
63
  config: {
61
64
  dsn: {
@@ -63,6 +66,14 @@ var testAnswers = {
63
66
  },
64
67
  },
65
68
  };
69
+ var mockAndroidAnswers = {
70
+ shouldConfigurePlatforms: { 'android': true },
71
+ config: {
72
+ dsn: {
73
+ public: 'dns.public.com',
74
+ },
75
+ },
76
+ };
66
77
  describe('ReactNative', function () {
67
78
  var defaultCwd = process.cwd();
68
79
  beforeEach(function () {
@@ -70,8 +81,10 @@ describe('ReactNative', function () {
70
81
  fs.mkdirSync(testDir);
71
82
  process.chdir(testDir);
72
83
  fs.writeFileSync(iosIndexJs, dummyJsContent);
73
- fs.mkdirSync('src');
84
+ fs.mkdirSync(path.dirname(appTsx), { recursive: true });
74
85
  fs.writeFileSync(appTsx, dummyJsContent);
86
+ fs.mkdirSync(path.dirname(appBuildGradle), { recursive: true });
87
+ fs.writeFileSync(appBuildGradle, dummyAppBuildGradleContent);
75
88
  });
76
89
  afterEach(function () {
77
90
  process.chdir(defaultCwd);
@@ -83,7 +96,7 @@ describe('ReactNative', function () {
83
96
  switch (_a.label) {
84
97
  case 0:
85
98
  project = new ReactNative_1.ReactNative(testArgs);
86
- return [4 /*yield*/, project.emit(testAnswers)];
99
+ return [4 /*yield*/, project.emit(mockIosAnswers)];
87
100
  case 1:
88
101
  _a.sent();
89
102
  patchedIosIndexJs = fs.readFileSync(iosIndexJs, 'utf8');
@@ -99,5 +112,23 @@ describe('ReactNative', function () {
99
112
  }
100
113
  });
101
114
  }); });
115
+ test('patches android app build gradle file', function () { return __awaiter(void 0, void 0, void 0, function () {
116
+ var project, patchedAppBuildGradle, expectedPatch;
117
+ return __generator(this, function (_a) {
118
+ switch (_a.label) {
119
+ case 0:
120
+ project = new ReactNative_1.ReactNative(testArgs);
121
+ return [4 /*yield*/, project.emit(mockAndroidAnswers)];
122
+ case 1:
123
+ _a.sent();
124
+ patchedAppBuildGradle = fs.readFileSync(appBuildGradle, 'utf8');
125
+ expectedPatch = 'apply plugin: "com.facebook.react"\n\n' +
126
+ 'apply from: "../../node_modules/@sentry/react-native/sentry.gradle"\n' +
127
+ 'android {\n}\n';
128
+ expect(patchedAppBuildGradle).toEqual(expectedPatch);
129
+ return [2 /*return*/];
130
+ }
131
+ });
132
+ }); });
102
133
  });
103
134
  //# sourceMappingURL=ReactNative.js.map
@@ -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,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,CAAC,kBAAkB,EAAE;;;;;oBACjB,OAAO,GAAG,IAAI,yBAAW,CAAC,QAAgB,CAAC,CAAC;oBAClD,qBAAM,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,EAAA;;oBAA/B,SAA+B,CAAC;oBAE1B,iBAAiB,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;oBACxD,aAAa,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;oBAChD,aAAa,GAAG,gCAAgC;wBACpD,uDAAuD;wBACvD,kBAAkB;wBAClB,+BAA+B;wBAC/B,SAAS,CAAC;oBACZ,MAAM,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;oBACjD,MAAM,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;;;;SAC9C,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["jest.mock('../../../Helper/Logging.ts'); // We mock logging to not pollute the output\nimport * as fs from 'fs';\nimport { Answers } from 'inquirer';\nimport * as process from 'process';\nimport * as rimraf from 'rimraf';\n\nimport { Args, Integration, Platform } from '../../../Constants';\nimport { ReactNative } from '../ReactNative';\n\nconst testDir = 'rn-test';\nconst iosIndexJs = 'index.ios.js';\nconst appTsx = 'src/App.tsx';\n\nconst dummyJsContent = 'import React from \"react\";\\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 testAnswers: Answers = {\n shouldConfigurePlatforms: { 'ios': true },\n config: {\n dsn: {\n public: 'dns.public.com',\n },\n },\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('src');\n fs.writeFileSync(appTsx, dummyJsContent);\n });\n\n afterEach(() => {\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(testAnswers);\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"]}
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,uBAAyB;AAEzB,2BAA6B;AAC7B,iCAAmC;AACnC,+BAAiC;AAEjC,gDAAiE;AACjE,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;AAElD,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,cA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BAAM,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,EAAA;;oBAAlC,SAAkC,CAAC;oBAE7B,iBAAiB,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;oBACxD,aAAa,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;oBAChD,aAAa,GAAG,gCAAgC;wBACpD,uDAAuD;wBACvD,kBAAkB;wBAClB,+BAA+B;wBAC/B,SAAS,CAAC;oBACZ,MAAM,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;oBACjD,MAAM,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;;;;SAC9C,CAAC,CAAC;IAEH,IAAI,CAAC,uCAAuC,EAAE;;;;;oBACtC,OAAO,GAAG,IAAI,yBAAW,CAAC,QAAgB,CAAC,CAAC;oBAClD,qBAAM,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAA;;oBAAtC,SAAsC,CAAC;oBAEjC,qBAAqB,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;oBAChE,aAAa,GAAG,wCAAwC;wBAC5D,uEAAuE;wBACvE,gBAAgB,CAAC;oBACnB,MAAM,CAAC,qBAAqB,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;;;;SACtD,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["jest.mock('../../../Helper/Logging.ts'); // We mock logging to not pollute the output\nimport * as fs from 'fs';\nimport { Answers } from 'inquirer';\nimport * as path from 'path';\nimport * as process from 'process';\nimport * as rimraf from 'rimraf';\n\nimport { Args, 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';\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\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 });\n\n afterEach(() => {\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 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"]}
@@ -13,6 +13,12 @@ import { MobileProject } from './MobileProject';
13
13
  const xcode = require('xcode');
14
14
 
15
15
  export class ReactNative extends MobileProject {
16
+
17
+ /**
18
+ * All React Native versions have app/build.gradle with android section.
19
+ */
20
+ private static _buildGradleAndroidSectionBeginning: RegExp = /^android {/m;
21
+
16
22
  protected _answers: Answers;
17
23
  protected _sentryCli: SentryCli;
18
24
 
@@ -220,11 +226,12 @@ export class ReactNative extends MobileProject {
220
226
  if (contents.indexOf(applyFrom) >= 0) {
221
227
  return Promise.resolve(null);
222
228
  }
229
+
223
230
  return Promise.resolve(
224
231
  contents.replace(
225
- /^apply from: "..\/..\/node_modules\/react-native\/react.gradle"/m,
232
+ ReactNative._buildGradleAndroidSectionBeginning,
226
233
  // eslint-disable-next-line prefer-template
227
- match => match + '\n' + applyFrom,
234
+ match => applyFrom + '\n' + match,
228
235
  ),
229
236
  );
230
237
  }
@@ -283,7 +290,7 @@ export class ReactNative extends MobileProject {
283
290
  shellScript:`
284
291
  export SENTRY_PROPERTIES=sentry.properties
285
292
  [[ $SENTRY_INCLUDE_NATIVE_SOURCES == "true" ]] && INCLUDE_SOURCES_FLAG="--include-sources" || INCLUDE_SOURCES_FLAG=""
286
- ../node_modules/@sentry/cli/bin/sentry-cli debug-files upload "$INCLUDE_SOURCES_FLAG"
293
+ ../node_modules/@sentry/cli/bin/sentry-cli debug-files upload "$INCLUDE_SOURCES_FLAG" "$DWARF_DSYM_FOLDER_PATH"
287
294
  `,
288
295
  },
289
296
  );
@@ -1,6 +1,7 @@
1
1
  jest.mock('../../../Helper/Logging.ts'); // We mock logging to not pollute the output
2
2
  import * as fs from 'fs';
3
3
  import { Answers } from 'inquirer';
4
+ import * as path from 'path';
4
5
  import * as process from 'process';
5
6
  import * as rimraf from 'rimraf';
6
7
 
@@ -10,8 +11,10 @@ import { ReactNative } from '../ReactNative';
10
11
  const testDir = 'rn-test';
11
12
  const iosIndexJs = 'index.ios.js';
12
13
  const appTsx = 'src/App.tsx';
14
+ const appBuildGradle = 'android/app/build.gradle';
13
15
 
14
16
  const dummyJsContent = 'import React from "react";\n';
17
+ const dummyAppBuildGradleContent = 'apply plugin: "com.facebook.react"\n\nandroid {\n}\n';
15
18
 
16
19
  const testArgs = {
17
20
  debug: false,
@@ -23,7 +26,7 @@ const testArgs = {
23
26
  url: 'https://not.used',
24
27
  };
25
28
 
26
- const testAnswers: Answers = {
29
+ const mockIosAnswers: Answers = {
27
30
  shouldConfigurePlatforms: { 'ios': true },
28
31
  config: {
29
32
  dsn: {
@@ -32,6 +35,15 @@ const testAnswers: Answers = {
32
35
  },
33
36
  };
34
37
 
38
+ const mockAndroidAnswers: Answers = {
39
+ shouldConfigurePlatforms: { 'android': true },
40
+ config: {
41
+ dsn: {
42
+ public: 'dns.public.com',
43
+ },
44
+ },
45
+ };
46
+
35
47
  describe('ReactNative', () => {
36
48
 
37
49
  const defaultCwd = process.cwd();
@@ -41,8 +53,10 @@ describe('ReactNative', () => {
41
53
  fs.mkdirSync(testDir);
42
54
  process.chdir(testDir);
43
55
  fs.writeFileSync(iosIndexJs, dummyJsContent);
44
- fs.mkdirSync('src');
56
+ fs.mkdirSync(path.dirname(appTsx), { recursive: true });
45
57
  fs.writeFileSync(appTsx, dummyJsContent);
58
+ fs.mkdirSync(path.dirname(appBuildGradle), { recursive: true });
59
+ fs.writeFileSync(appBuildGradle, dummyAppBuildGradleContent);
46
60
  });
47
61
 
48
62
  afterEach(() => {
@@ -52,7 +66,7 @@ describe('ReactNative', () => {
52
66
 
53
67
  test('patches js files', async () => {
54
68
  const project = new ReactNative(testArgs as Args);
55
- await project.emit(testAnswers);
69
+ await project.emit(mockIosAnswers);
56
70
 
57
71
  const patchedIosIndexJs = fs.readFileSync(iosIndexJs, 'utf8');
58
72
  const patchedAppTsx = fs.readFileSync(appTsx, 'utf8');
@@ -64,4 +78,15 @@ describe('ReactNative', () => {
64
78
  expect(patchedIosIndexJs).toEqual(expectedPatch);
65
79
  expect(patchedAppTsx).toEqual(expectedPatch);
66
80
  });
81
+
82
+ test('patches android app build gradle file', async () => {
83
+ const project = new ReactNative(testArgs as Args);
84
+ await project.emit(mockAndroidAnswers);
85
+
86
+ const patchedAppBuildGradle = fs.readFileSync(appBuildGradle, 'utf8');
87
+ const expectedPatch = 'apply plugin: "com.facebook.react"\n\n' +
88
+ 'apply from: "../../node_modules/@sentry/react-native/sentry.gradle"\n' +
89
+ 'android {\n}\n';
90
+ expect(patchedAppBuildGradle).toEqual(expectedPatch);
91
+ });
67
92
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/wizard",
3
- "version": "2.5.0",
3
+ "version": "2.6.1",
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",