@sentry/wizard 2.6.0 → 2.7.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.
- package/CHANGELOG.md +12 -0
- package/dist/lib/Helper/Package.d.ts +1 -0
- package/dist/lib/Helper/Package.js +46 -0
- package/dist/lib/Helper/Package.js.map +1 -0
- package/dist/lib/Helper/PackageManager.d.ts +22 -0
- package/dist/lib/Helper/PackageManager.js +135 -0
- package/dist/lib/Helper/PackageManager.js.map +1 -0
- package/dist/lib/Helper/Wizard.js +2 -1
- package/dist/lib/Helper/Wizard.js.map +1 -1
- package/dist/lib/Helper/__tests__/MergeConfig.js +25 -14
- package/dist/lib/Helper/__tests__/MergeConfig.js.map +1 -1
- package/dist/lib/Steps/Integrations/NextJs.d.ts +0 -5
- package/dist/lib/Steps/Integrations/NextJs.js +6 -85
- package/dist/lib/Steps/Integrations/NextJs.js.map +1 -1
- package/dist/lib/Steps/Integrations/ReactNative.d.ts +7 -0
- package/dist/lib/Steps/Integrations/ReactNative.js +120 -51
- package/dist/lib/Steps/Integrations/ReactNative.js.map +1 -1
- package/dist/lib/Steps/Integrations/__tests__/ReactNative.js +42 -0
- package/dist/lib/Steps/Integrations/__tests__/ReactNative.js.map +1 -1
- package/dist/lib/__tests__/Setup.js +15 -0
- package/dist/lib/__tests__/Setup.js.map +1 -1
- package/lib/Helper/Package.ts +61 -0
- package/lib/Helper/PackageManager.ts +64 -0
- package/lib/Helper/Wizard.ts +1 -1
- package/lib/Helper/__tests__/MergeConfig.ts +36 -20
- package/lib/Steps/Integrations/NextJs.ts +8 -108
- package/lib/Steps/Integrations/ReactNative.ts +108 -37
- package/lib/Steps/Integrations/__tests__/ReactNative.ts +34 -0
- package/lib/__tests__/Setup.ts +23 -0
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
jest.mock('../../../Helper/Logging.ts'); // We mock logging to not pollute the output
|
|
2
|
+
jest.mock('child_process');
|
|
3
|
+
import * as child_process from 'child_process';
|
|
2
4
|
import * as fs from 'fs';
|
|
3
5
|
import { Answers } from 'inquirer';
|
|
4
6
|
import * as path from 'path';
|
|
@@ -12,6 +14,7 @@ const testDir = 'rn-test';
|
|
|
12
14
|
const iosIndexJs = 'index.ios.js';
|
|
13
15
|
const appTsx = 'src/App.tsx';
|
|
14
16
|
const appBuildGradle = 'android/app/build.gradle';
|
|
17
|
+
const yarnLock = 'yarn.lock';
|
|
15
18
|
|
|
16
19
|
const dummyJsContent = 'import React from "react";\n';
|
|
17
20
|
const dummyAppBuildGradleContent = 'apply plugin: "com.facebook.react"\n\nandroid {\n}\n';
|
|
@@ -44,6 +47,17 @@ const mockAndroidAnswers: Answers = {
|
|
|
44
47
|
},
|
|
45
48
|
};
|
|
46
49
|
|
|
50
|
+
const originalExec = child_process.exec;
|
|
51
|
+
|
|
52
|
+
const restoreExec = (): void => {
|
|
53
|
+
(child_process as any).exec = originalExec;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const mockExec = (): void => {
|
|
57
|
+
(child_process.exec as unknown as jest.Mock)
|
|
58
|
+
.mockImplementation((_command, callback) => callback(null, { stdout: '' }));
|
|
59
|
+
}
|
|
60
|
+
|
|
47
61
|
describe('ReactNative', () => {
|
|
48
62
|
|
|
49
63
|
const defaultCwd = process.cwd();
|
|
@@ -57,9 +71,12 @@ describe('ReactNative', () => {
|
|
|
57
71
|
fs.writeFileSync(appTsx, dummyJsContent);
|
|
58
72
|
fs.mkdirSync(path.dirname(appBuildGradle), { recursive: true });
|
|
59
73
|
fs.writeFileSync(appBuildGradle, dummyAppBuildGradleContent);
|
|
74
|
+
fs.writeFileSync(yarnLock, '');
|
|
75
|
+
mockExec();
|
|
60
76
|
});
|
|
61
77
|
|
|
62
78
|
afterEach(() => {
|
|
79
|
+
restoreExec();
|
|
63
80
|
process.chdir(defaultCwd);
|
|
64
81
|
rimraf.sync(testDir);
|
|
65
82
|
});
|
|
@@ -81,6 +98,7 @@ describe('ReactNative', () => {
|
|
|
81
98
|
|
|
82
99
|
test('patches android app build gradle file', async () => {
|
|
83
100
|
const project = new ReactNative(testArgs as Args);
|
|
101
|
+
|
|
84
102
|
await project.emit(mockAndroidAnswers);
|
|
85
103
|
|
|
86
104
|
const patchedAppBuildGradle = fs.readFileSync(appBuildGradle, 'utf8');
|
|
@@ -89,4 +107,20 @@ describe('ReactNative', () => {
|
|
|
89
107
|
'android {\n}\n';
|
|
90
108
|
expect(patchedAppBuildGradle).toEqual(expectedPatch);
|
|
91
109
|
});
|
|
110
|
+
|
|
111
|
+
test('does install sentry sdk', async () => {
|
|
112
|
+
const project = new ReactNative(testArgs as Args);
|
|
113
|
+
|
|
114
|
+
await project.emit(mockIosAnswers);
|
|
115
|
+
|
|
116
|
+
expect(child_process.exec).toHaveBeenCalledWith('yarn add @sentry/react-native', expect.anything());
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('executes pod install', async () => {
|
|
120
|
+
const project = new ReactNative(testArgs as Args);
|
|
121
|
+
|
|
122
|
+
await project.emit(mockIosAnswers);
|
|
123
|
+
|
|
124
|
+
expect(child_process.exec).toHaveBeenCalledWith('npx --yes pod-install --non-interactive --quiet', expect.anything());
|
|
125
|
+
});
|
|
92
126
|
});
|
package/lib/__tests__/Setup.ts
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
1
|
jest.mock('../Helper/Logging'); // We mock logging to not pollute the output
|
|
2
|
+
jest.mock('child_process');
|
|
3
|
+
import * as child_process from 'child_process';
|
|
4
|
+
|
|
2
5
|
import { Integration, Platform } from '../Constants';
|
|
3
6
|
import { run } from '../Setup';
|
|
4
7
|
|
|
8
|
+
const originalExec = child_process.exec;
|
|
9
|
+
|
|
10
|
+
const restoreExec = (): void => {
|
|
11
|
+
(child_process as any).exec = originalExec;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const mockExec = (): void => {
|
|
15
|
+
((child_process.exec as unknown) as jest.Mock).mockImplementation(
|
|
16
|
+
(_command, callback) => callback(null, { stdout: '' }),
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
5
20
|
describe('Wizard', () => {
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
mockExec();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
restoreExec();
|
|
27
|
+
});
|
|
28
|
+
|
|
6
29
|
describe('React Native', () => {
|
|
7
30
|
test('run', () => {
|
|
8
31
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
package/package.json
CHANGED