@sentry/wizard 3.11.0 → 3.12.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 +7 -0
- package/dist/package.json +1 -1
- package/dist/src/android/android-wizard.js +8 -0
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/android/code-tools.d.ts +8 -0
- package/dist/src/android/code-tools.js +20 -8
- package/dist/src/android/code-tools.js.map +1 -1
- package/dist/src/android/gradle.js +6 -1
- package/dist/src/android/gradle.js.map +1 -1
- package/dist/src/sourcemaps/tools/vite.js +36 -111
- package/dist/src/sourcemaps/tools/vite.js.map +1 -1
- package/dist/src/sourcemaps/tools/webpack.d.ts +6 -1
- package/dist/src/sourcemaps/tools/webpack.js +290 -25
- package/dist/src/sourcemaps/tools/webpack.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup.js +2 -2
- package/dist/src/sveltekit/sdk-setup.js.map +1 -1
- package/dist/src/utils/ast-utils.d.ts +7 -3
- package/dist/src/utils/ast-utils.js +20 -5
- package/dist/src/utils/ast-utils.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +52 -0
- package/dist/src/utils/clack-utils.js +169 -12
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/test/android/code-tools.test.d.ts +1 -0
- package/dist/test/android/code-tools.test.js +34 -0
- package/dist/test/android/code-tools.test.js.map +1 -0
- package/dist/test/sourcemaps/tools/webpack.test.d.ts +1 -0
- package/dist/test/sourcemaps/tools/webpack.test.js +179 -0
- package/dist/test/sourcemaps/tools/webpack.test.js.map +1 -0
- package/dist/test/utils/ast-utils.test.js +42 -7
- package/dist/test/utils/ast-utils.test.js.map +1 -1
- package/dist/test/utils/clack-utils.test.d.ts +1 -0
- package/dist/test/utils/clack-utils.test.js +200 -0
- package/dist/test/utils/clack-utils.test.js.map +1 -0
- package/package.json +1 -1
- package/src/android/android-wizard.ts +8 -0
- package/src/android/code-tools.ts +21 -7
- package/src/android/gradle.ts +6 -1
- package/src/sourcemaps/tools/vite.ts +22 -88
- package/src/sourcemaps/tools/webpack.ts +369 -30
- package/src/sveltekit/sdk-setup.ts +6 -2
- package/src/utils/ast-utils.ts +23 -7
- package/src/utils/clack-utils.ts +150 -2
- package/test/android/code-tools.test.ts +49 -0
- package/test/sourcemaps/tools/webpack.test.ts +303 -0
- package/test/utils/ast-utils.test.ts +28 -9
- package/test/utils/clack-utils.test.ts +142 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {
|
|
2
|
+
askForToolConfigPath,
|
|
3
|
+
createNewConfigFile,
|
|
4
|
+
} from '../../src/utils/clack-utils';
|
|
5
|
+
|
|
6
|
+
import * as fs from 'fs';
|
|
7
|
+
|
|
8
|
+
type ClackMock = {
|
|
9
|
+
confirm: jest.Mock;
|
|
10
|
+
text: jest.Mock;
|
|
11
|
+
isCancel: jest.Mock;
|
|
12
|
+
cancel: jest.Mock;
|
|
13
|
+
log: {
|
|
14
|
+
info: jest.Mock;
|
|
15
|
+
success: jest.Mock;
|
|
16
|
+
warn: jest.Mock;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
let clackMock: ClackMock;
|
|
21
|
+
|
|
22
|
+
jest.mock('@clack/prompts', () => {
|
|
23
|
+
clackMock = {
|
|
24
|
+
log: {
|
|
25
|
+
info: jest.fn(),
|
|
26
|
+
success: jest.fn(),
|
|
27
|
+
warn: jest.fn(),
|
|
28
|
+
},
|
|
29
|
+
text: jest.fn(),
|
|
30
|
+
confirm: jest.fn(),
|
|
31
|
+
cancel: jest.fn(),
|
|
32
|
+
// passthrough for abortIfCancelled
|
|
33
|
+
isCancel: jest.fn().mockReturnValue(false),
|
|
34
|
+
};
|
|
35
|
+
return clackMock;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
function mockUserResponse(fn: jest.Mock, response: any) {
|
|
39
|
+
fn.mockReturnValueOnce(response);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
describe('askForToolConfigPath', () => {
|
|
43
|
+
afterEach(() => {
|
|
44
|
+
jest.clearAllMocks();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('returns undefined if users have no config file', async () => {
|
|
48
|
+
mockUserResponse(clackMock.confirm, false);
|
|
49
|
+
|
|
50
|
+
const result = await askForToolConfigPath('Webpack', 'webpack.config.js');
|
|
51
|
+
|
|
52
|
+
expect(clackMock.confirm).toHaveBeenCalledWith(
|
|
53
|
+
expect.objectContaining({
|
|
54
|
+
message: expect.stringContaining('have a Webpack config file'),
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
expect(result).toBeUndefined();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('returns the path if users have a config file and the entered path is valid', async () => {
|
|
62
|
+
mockUserResponse(clackMock.confirm, true);
|
|
63
|
+
mockUserResponse(clackMock.text, 'my.webpack.config.js');
|
|
64
|
+
|
|
65
|
+
const result = await askForToolConfigPath('Webpack', 'webpack.config.js');
|
|
66
|
+
|
|
67
|
+
expect(clackMock.confirm).toHaveBeenCalledWith(
|
|
68
|
+
expect.objectContaining({
|
|
69
|
+
message: expect.stringContaining('have a Webpack config file'),
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect(clackMock.text).toHaveBeenCalledWith(
|
|
74
|
+
expect.objectContaining({
|
|
75
|
+
message: expect.stringContaining(
|
|
76
|
+
'enter the path to your Webpack config file',
|
|
77
|
+
),
|
|
78
|
+
}),
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
expect(result).toBe('my.webpack.config.js');
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe('createNewConfigFile', () => {
|
|
86
|
+
afterEach(() => {
|
|
87
|
+
jest.clearAllMocks();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('writes the file to disk and returns true if the file was created successfully', async () => {
|
|
91
|
+
const writeFileSpy = jest
|
|
92
|
+
.spyOn(fs.promises, 'writeFile')
|
|
93
|
+
.mockImplementation(jest.fn());
|
|
94
|
+
|
|
95
|
+
const filename = '/weboack.config.js';
|
|
96
|
+
const code = `module.exports = {/*config...*/}`;
|
|
97
|
+
|
|
98
|
+
const result = await createNewConfigFile(filename, code);
|
|
99
|
+
|
|
100
|
+
expect(result).toBe(true);
|
|
101
|
+
expect(writeFileSpy).toHaveBeenCalledWith(filename, code);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('logs more information if provided as an argument', async () => {
|
|
105
|
+
jest.spyOn(fs.promises, 'writeFile').mockImplementation(jest.fn());
|
|
106
|
+
|
|
107
|
+
const filename = '/weboack.config.js';
|
|
108
|
+
const code = `module.exports = {/*config...*/}`;
|
|
109
|
+
const moreInfo = 'More information...';
|
|
110
|
+
|
|
111
|
+
await createNewConfigFile(filename, code, moreInfo);
|
|
112
|
+
|
|
113
|
+
expect(clackMock.log.info).toHaveBeenCalledTimes(1);
|
|
114
|
+
expect(clackMock.log.info).toHaveBeenCalledWith(
|
|
115
|
+
expect.stringContaining(moreInfo),
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('returns false and logs a warning if the file could not be created', async () => {
|
|
120
|
+
const writeFileSpy = jest
|
|
121
|
+
.spyOn(fs.promises, 'writeFile')
|
|
122
|
+
.mockImplementation(() => Promise.reject(new Error('Could not write')));
|
|
123
|
+
|
|
124
|
+
const filename = '/webpack.config.js';
|
|
125
|
+
const code = `module.exports = {/*config...*/}`;
|
|
126
|
+
|
|
127
|
+
const result = await createNewConfigFile(filename, code);
|
|
128
|
+
|
|
129
|
+
expect(result).toBe(false);
|
|
130
|
+
expect(writeFileSpy).toHaveBeenCalledWith(filename, code);
|
|
131
|
+
expect(clackMock.log.warn).toHaveBeenCalledTimes(1);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('returns false if the passed path is not absolute', async () => {
|
|
135
|
+
const result = await createNewConfigFile(
|
|
136
|
+
'./relative/webpack.config.js',
|
|
137
|
+
'',
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
expect(result).toBe(false);
|
|
141
|
+
});
|
|
142
|
+
});
|