@sentry/wizard 2.4.2 → 2.6.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 (30) hide show
  1. package/CHANGELOG.md +16 -4
  2. package/dist/NextJs/configs/next.config.template.js +12 -0
  3. package/dist/lib/Helper/MergeConfig.d.ts +1 -0
  4. package/dist/lib/Helper/MergeConfig.js +20 -0
  5. package/dist/lib/Helper/MergeConfig.js.map +1 -0
  6. package/dist/lib/Helper/__tests__/MergeConfig.d.ts +1 -0
  7. package/dist/lib/Helper/__tests__/MergeConfig.js +46 -0
  8. package/dist/lib/Helper/__tests__/MergeConfig.js.map +1 -0
  9. package/dist/lib/Steps/Integrations/NextJs.d.ts +1 -0
  10. package/dist/lib/Steps/Integrations/NextJs.js +134 -51
  11. package/dist/lib/Steps/Integrations/NextJs.js.map +1 -1
  12. package/dist/lib/Steps/Integrations/ReactNative.d.ts +4 -0
  13. package/dist/lib/Steps/Integrations/ReactNative.js +6 -2
  14. package/dist/lib/Steps/Integrations/ReactNative.js.map +1 -1
  15. package/dist/lib/Steps/Integrations/__tests__/ReactNative.js +34 -3
  16. package/dist/lib/Steps/Integrations/__tests__/ReactNative.js.map +1 -1
  17. package/lib/Helper/MergeConfig.ts +18 -0
  18. package/lib/Helper/__tests__/MergeConfig.ts +77 -0
  19. package/lib/Helper/test-fixtures/next.config.1-merged.js +18 -0
  20. package/lib/Helper/test-fixtures/next.config.1.js +6 -0
  21. package/lib/Helper/test-fixtures/next.config.2.js +8 -0
  22. package/lib/Helper/test-fixtures/next.config.3-merged.js +21 -0
  23. package/lib/Helper/test-fixtures/next.config.3.js +9 -0
  24. package/lib/Helper/test-fixtures/next.config.4-merged.js +21 -0
  25. package/lib/Helper/test-fixtures/next.config.4.js +9 -0
  26. package/lib/Steps/Integrations/NextJs.ts +99 -22
  27. package/lib/Steps/Integrations/ReactNative.ts +9 -2
  28. package/lib/Steps/Integrations/__tests__/ReactNative.ts +28 -3
  29. package/package.json +1 -1
  30. package/scripts/NextJs/configs/next.config.template.js +12 -0
@@ -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.4.2",
3
+ "version": "2.6.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",
@@ -0,0 +1,12 @@
1
+ // This file sets a custom webpack configuration to use your Next.js app
2
+ // with Sentry.
3
+ // https://nextjs.org/docs/api-reference/next.config.js/introduction
4
+ // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
5
+ const { withSentryConfig } = require('@sentry/nextjs');
6
+
7
+ // ORIGINAL CONFIG
8
+ module.exports = withSentryConfig(
9
+ module.exports,
10
+ { silent: true },
11
+ { hideSourcemaps: true },
12
+ );