@sentry/wizard 6.3.0 → 6.5.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/e2e-tests/tests/expo.test.js +9 -2
- package/dist/e2e-tests/tests/expo.test.js.map +1 -1
- package/dist/e2e-tests/tests/react-native.test.js +9 -2
- package/dist/e2e-tests/tests/react-native.test.js.map +1 -1
- package/dist/e2e-tests/tests/{sveltekit.test.js → sveltekit-hooks.test.js} +10 -6
- package/dist/e2e-tests/tests/sveltekit-hooks.test.js.map +1 -0
- package/dist/e2e-tests/tests/sveltekit-tracing.test.d.ts +1 -0
- package/dist/e2e-tests/tests/sveltekit-tracing.test.js +203 -0
- package/dist/e2e-tests/tests/sveltekit-tracing.test.js.map +1 -0
- package/dist/src/android/android-wizard.js +9 -1
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/android/manifest.d.ts +1 -1
- package/dist/src/android/manifest.js +2 -2
- package/dist/src/android/manifest.js.map +1 -1
- package/dist/src/android/templates.d.ts +1 -1
- package/dist/src/android/templates.js +4 -1
- package/dist/src/android/templates.js.map +1 -1
- package/dist/src/react-native/javascript.d.ts +6 -4
- package/dist/src/react-native/javascript.js +11 -7
- package/dist/src/react-native/javascript.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.js +12 -3
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/react-native/xcode.d.ts +2 -2
- package/dist/src/react-native/xcode.js +11 -4
- package/dist/src/react-native/xcode.js.map +1 -1
- package/dist/src/sveltekit/sdk-example.d.ts +2 -2
- package/dist/src/sveltekit/sdk-example.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup/setup.d.ts +3 -0
- package/dist/src/sveltekit/{sdk-setup.js → sdk-setup/setup.js} +113 -157
- package/dist/src/sveltekit/sdk-setup/setup.js.map +1 -0
- package/dist/src/sveltekit/sdk-setup/svelte-config.d.ts +25 -0
- package/dist/src/sveltekit/sdk-setup/svelte-config.js +291 -0
- package/dist/src/sveltekit/sdk-setup/svelte-config.js.map +1 -0
- package/dist/src/sveltekit/sdk-setup/types.d.ts +7 -0
- package/dist/src/sveltekit/sdk-setup/types.js +3 -0
- package/dist/src/sveltekit/sdk-setup/types.js.map +1 -0
- package/dist/src/sveltekit/sdk-setup/utils.d.ts +6 -0
- package/dist/src/sveltekit/sdk-setup/utils.js +45 -0
- package/dist/src/sveltekit/sdk-setup/utils.js.map +1 -0
- package/dist/src/sveltekit/sdk-setup/vite.d.ts +2 -0
- package/dist/src/sveltekit/sdk-setup/vite.js +120 -0
- package/dist/src/sveltekit/sdk-setup/vite.js.map +1 -0
- package/dist/src/sveltekit/sveltekit-wizard.js +45 -5
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/sveltekit/templates.d.ts +4 -0
- package/dist/src/sveltekit/templates.js +33 -10
- package/dist/src/sveltekit/templates.js.map +1 -1
- package/dist/src/sveltekit/utils.d.ts +2 -1
- package/dist/src/sveltekit/utils.js +7 -2
- package/dist/src/sveltekit/utils.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/test/react-native/javascript.test.js +225 -0
- package/dist/test/react-native/javascript.test.js.map +1 -1
- package/dist/test/react-native/xcode.test.js +21 -4
- package/dist/test/react-native/xcode.test.js.map +1 -1
- package/dist/test/sveltekit/sdk-setup/svelte-config.test.d.ts +1 -0
- package/dist/test/sveltekit/sdk-setup/svelte-config.test.js +529 -0
- package/dist/test/sveltekit/sdk-setup/svelte-config.test.js.map +1 -0
- package/dist/test/sveltekit/templates.test.js +103 -10
- package/dist/test/sveltekit/templates.test.js.map +1 -1
- package/package.json +1 -1
- package/dist/e2e-tests/tests/sveltekit.test.js.map +0 -1
- package/dist/src/sveltekit/sdk-setup.d.ts +0 -21
- package/dist/src/sveltekit/sdk-setup.js.map +0 -1
- /package/dist/e2e-tests/tests/{sveltekit.test.d.ts → sveltekit-hooks.test.d.ts} +0 -0
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const svelte_config_1 = require("../../../src/sveltekit/sdk-setup/svelte-config");
|
|
5
|
+
(0, vitest_1.describe)('_enableTracingAndInstrumentationInConfig', () => {
|
|
6
|
+
(0, vitest_1.it)('leaves already correct config unchanged', () => {
|
|
7
|
+
const originalConfig = `export default {
|
|
8
|
+
preprocess: vitePreprocess(),
|
|
9
|
+
|
|
10
|
+
kit: {
|
|
11
|
+
adapter: adapter(),
|
|
12
|
+
experimental: {
|
|
13
|
+
tracing: {
|
|
14
|
+
server: true,
|
|
15
|
+
},
|
|
16
|
+
instrumentation: {
|
|
17
|
+
server: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};`;
|
|
22
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
23
|
+
(0, vitest_1.expect)(modifiedConfig.result).toBe(originalConfig);
|
|
24
|
+
});
|
|
25
|
+
(0, vitest_1.describe)('successfully handles', () => {
|
|
26
|
+
(0, vitest_1.it)('default config as variable declaration', () => {
|
|
27
|
+
const originalConfig = `/** @type {import('@sveltejs/kit').Config} */
|
|
28
|
+
const config = {
|
|
29
|
+
preprocess: vitePreprocess(),
|
|
30
|
+
|
|
31
|
+
kit: {
|
|
32
|
+
adapter: adapter(),
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default config;
|
|
37
|
+
`;
|
|
38
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
39
|
+
(0, vitest_1.expect)(modifiedConfig.result).toMatchInlineSnapshot(`
|
|
40
|
+
"/** @type {import('@sveltejs/kit').Config} */
|
|
41
|
+
const config = {
|
|
42
|
+
preprocess: vitePreprocess(),
|
|
43
|
+
|
|
44
|
+
kit: {
|
|
45
|
+
adapter: adapter(),
|
|
46
|
+
|
|
47
|
+
experimental: {
|
|
48
|
+
tracing: {
|
|
49
|
+
server: true,
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
instrumentation: {
|
|
53
|
+
server: true,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default config;"
|
|
60
|
+
`);
|
|
61
|
+
});
|
|
62
|
+
(0, vitest_1.it)('default config named declaration object', () => {
|
|
63
|
+
const originalConfig = `
|
|
64
|
+
export default config = {
|
|
65
|
+
preprocess: vitePreprocess(),
|
|
66
|
+
|
|
67
|
+
kit: {
|
|
68
|
+
adapter: adapter(),
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
`;
|
|
72
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
73
|
+
(0, vitest_1.expect)(modifiedConfig.result).toMatchInlineSnapshot(`
|
|
74
|
+
"export default config = {
|
|
75
|
+
preprocess: vitePreprocess(),
|
|
76
|
+
|
|
77
|
+
kit: {
|
|
78
|
+
adapter: adapter(),
|
|
79
|
+
|
|
80
|
+
experimental: {
|
|
81
|
+
tracing: {
|
|
82
|
+
server: true,
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
instrumentation: {
|
|
86
|
+
server: true,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
};"
|
|
91
|
+
`);
|
|
92
|
+
});
|
|
93
|
+
(0, vitest_1.it)('default config as in-place object', () => {
|
|
94
|
+
const originalConfig = `
|
|
95
|
+
export default {
|
|
96
|
+
preprocess: vitePreprocess(),
|
|
97
|
+
|
|
98
|
+
kit: {
|
|
99
|
+
adapter: adapter(),
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
`;
|
|
103
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
104
|
+
(0, vitest_1.expect)(modifiedConfig.result).toMatchInlineSnapshot(`
|
|
105
|
+
"export default {
|
|
106
|
+
preprocess: vitePreprocess(),
|
|
107
|
+
|
|
108
|
+
kit: {
|
|
109
|
+
adapter: adapter(),
|
|
110
|
+
|
|
111
|
+
experimental: {
|
|
112
|
+
tracing: {
|
|
113
|
+
server: true,
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
instrumentation: {
|
|
117
|
+
server: true,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
};"
|
|
122
|
+
`);
|
|
123
|
+
});
|
|
124
|
+
(0, vitest_1.it)('config with tracing disabled', () => {
|
|
125
|
+
const originalConfig = `
|
|
126
|
+
export default {
|
|
127
|
+
preprocess: vitePreprocess(),
|
|
128
|
+
|
|
129
|
+
kit: {
|
|
130
|
+
adapter: adapter(),
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
`;
|
|
134
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, false);
|
|
135
|
+
(0, vitest_1.expect)(modifiedConfig.result).toMatchInlineSnapshot(`
|
|
136
|
+
"export default {
|
|
137
|
+
preprocess: vitePreprocess(),
|
|
138
|
+
|
|
139
|
+
kit: {
|
|
140
|
+
adapter: adapter(),
|
|
141
|
+
|
|
142
|
+
experimental: {
|
|
143
|
+
tracing: {
|
|
144
|
+
server: false,
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
instrumentation: {
|
|
148
|
+
server: true,
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
};"
|
|
153
|
+
`);
|
|
154
|
+
});
|
|
155
|
+
(0, vitest_1.it)('config with pre-existing `kit.experimental` property', () => {
|
|
156
|
+
const originalConfig = `
|
|
157
|
+
export default {
|
|
158
|
+
preprocess: vitePreprocess(),
|
|
159
|
+
|
|
160
|
+
kit: {
|
|
161
|
+
adapter: adapter(),
|
|
162
|
+
experimental: {
|
|
163
|
+
remoteFunctions: true,
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
`;
|
|
168
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
169
|
+
(0, vitest_1.expect)(modifiedConfig.result).toMatchInlineSnapshot(`
|
|
170
|
+
"export default {
|
|
171
|
+
preprocess: vitePreprocess(),
|
|
172
|
+
|
|
173
|
+
kit: {
|
|
174
|
+
adapter: adapter(),
|
|
175
|
+
experimental: {
|
|
176
|
+
remoteFunctions: true,
|
|
177
|
+
|
|
178
|
+
tracing: {
|
|
179
|
+
server: true,
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
instrumentation: {
|
|
183
|
+
server: true,
|
|
184
|
+
},
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
};"
|
|
188
|
+
`);
|
|
189
|
+
});
|
|
190
|
+
(0, vitest_1.it)('config with pre-existing and empty `kit.experimental.tracing` property', () => {
|
|
191
|
+
const originalConfig = `
|
|
192
|
+
export default {
|
|
193
|
+
preprocess: vitePreprocess(),
|
|
194
|
+
|
|
195
|
+
kit: {
|
|
196
|
+
adapter: adapter(),
|
|
197
|
+
experimental: {
|
|
198
|
+
remoteFunctions: true,
|
|
199
|
+
tracing: {
|
|
200
|
+
},
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
`;
|
|
205
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
206
|
+
(0, vitest_1.expect)(modifiedConfig.result).toMatchInlineSnapshot(`
|
|
207
|
+
"export default {
|
|
208
|
+
preprocess: vitePreprocess(),
|
|
209
|
+
|
|
210
|
+
kit: {
|
|
211
|
+
adapter: adapter(),
|
|
212
|
+
experimental: {
|
|
213
|
+
remoteFunctions: true,
|
|
214
|
+
|
|
215
|
+
tracing: {
|
|
216
|
+
server: true,
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
instrumentation: {
|
|
220
|
+
server: true,
|
|
221
|
+
},
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
};"
|
|
225
|
+
`);
|
|
226
|
+
});
|
|
227
|
+
(0, vitest_1.it)('config with pre-existing and empty `kit.experimental.instrumentation` property', () => {
|
|
228
|
+
const originalConfig = `
|
|
229
|
+
export default {
|
|
230
|
+
preprocess: vitePreprocess(),
|
|
231
|
+
|
|
232
|
+
kit: {
|
|
233
|
+
adapter: adapter(),
|
|
234
|
+
experimental: {
|
|
235
|
+
remoteFunctions: true,
|
|
236
|
+
tracing: {
|
|
237
|
+
},
|
|
238
|
+
instrumentation: {
|
|
239
|
+
},
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
`;
|
|
244
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
245
|
+
(0, vitest_1.expect)(modifiedConfig.result).toMatchInlineSnapshot(`
|
|
246
|
+
"export default {
|
|
247
|
+
preprocess: vitePreprocess(),
|
|
248
|
+
|
|
249
|
+
kit: {
|
|
250
|
+
adapter: adapter(),
|
|
251
|
+
experimental: {
|
|
252
|
+
remoteFunctions: true,
|
|
253
|
+
tracing: {
|
|
254
|
+
server: true,
|
|
255
|
+
},
|
|
256
|
+
instrumentation: {
|
|
257
|
+
server: true,
|
|
258
|
+
},
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
};"
|
|
262
|
+
`);
|
|
263
|
+
});
|
|
264
|
+
(0, vitest_1.it)('config with pre-existing and filled `kit.experimental.(instrumentation|tracing).server` properties', () => {
|
|
265
|
+
const originalConfig = `
|
|
266
|
+
export default {
|
|
267
|
+
preprocess: vitePreprocess(),
|
|
268
|
+
|
|
269
|
+
kit: {
|
|
270
|
+
adapter: adapter(),
|
|
271
|
+
experimental: {
|
|
272
|
+
remoteFunctions: true,
|
|
273
|
+
tracing: {
|
|
274
|
+
server: false,
|
|
275
|
+
},
|
|
276
|
+
instrumentation: {
|
|
277
|
+
server: false,
|
|
278
|
+
},
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
`;
|
|
283
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
284
|
+
(0, vitest_1.expect)(modifiedConfig.result).toMatchInlineSnapshot(`
|
|
285
|
+
"export default {
|
|
286
|
+
preprocess: vitePreprocess(),
|
|
287
|
+
|
|
288
|
+
kit: {
|
|
289
|
+
adapter: adapter(),
|
|
290
|
+
experimental: {
|
|
291
|
+
remoteFunctions: true,
|
|
292
|
+
tracing: {
|
|
293
|
+
server: true,
|
|
294
|
+
},
|
|
295
|
+
instrumentation: {
|
|
296
|
+
server: true,
|
|
297
|
+
},
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
};"
|
|
301
|
+
`);
|
|
302
|
+
});
|
|
303
|
+
(0, vitest_1.it)('config with pre-existing and filled `kit.experimental.(instrumentation|tracing).server` properties with instrumentation disabled', () => {
|
|
304
|
+
const originalConfig = `
|
|
305
|
+
export default {
|
|
306
|
+
preprocess: vitePreprocess(),
|
|
307
|
+
|
|
308
|
+
kit: {
|
|
309
|
+
adapter: adapter(),
|
|
310
|
+
experimental: {
|
|
311
|
+
remoteFunctions: true,
|
|
312
|
+
tracing: {
|
|
313
|
+
server: true,
|
|
314
|
+
},
|
|
315
|
+
instrumentation: {
|
|
316
|
+
server: false,
|
|
317
|
+
},
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
};
|
|
321
|
+
`;
|
|
322
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
323
|
+
(0, vitest_1.expect)(modifiedConfig.result).toMatchInlineSnapshot(`
|
|
324
|
+
"export default {
|
|
325
|
+
preprocess: vitePreprocess(),
|
|
326
|
+
|
|
327
|
+
kit: {
|
|
328
|
+
adapter: adapter(),
|
|
329
|
+
experimental: {
|
|
330
|
+
remoteFunctions: true,
|
|
331
|
+
tracing: {
|
|
332
|
+
server: true,
|
|
333
|
+
},
|
|
334
|
+
instrumentation: {
|
|
335
|
+
server: true,
|
|
336
|
+
},
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
};"
|
|
340
|
+
`);
|
|
341
|
+
});
|
|
342
|
+
(0, vitest_1.it)('config with pre-existing and filled `kit.experimental.(instrumentation|tracing).server` properties with tracing disabled', () => {
|
|
343
|
+
const originalConfig = `
|
|
344
|
+
export default {
|
|
345
|
+
preprocess: vitePreprocess(),
|
|
346
|
+
|
|
347
|
+
kit: {
|
|
348
|
+
adapter: adapter(),
|
|
349
|
+
experimental: {
|
|
350
|
+
remoteFunctions: true,
|
|
351
|
+
tracing: {
|
|
352
|
+
server: false,
|
|
353
|
+
},
|
|
354
|
+
instrumentation: {
|
|
355
|
+
server: true,
|
|
356
|
+
},
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
`;
|
|
361
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
362
|
+
(0, vitest_1.expect)(modifiedConfig.result).toMatchInlineSnapshot(`
|
|
363
|
+
"export default {
|
|
364
|
+
preprocess: vitePreprocess(),
|
|
365
|
+
|
|
366
|
+
kit: {
|
|
367
|
+
adapter: adapter(),
|
|
368
|
+
experimental: {
|
|
369
|
+
remoteFunctions: true,
|
|
370
|
+
tracing: {
|
|
371
|
+
server: true,
|
|
372
|
+
},
|
|
373
|
+
instrumentation: {
|
|
374
|
+
server: true,
|
|
375
|
+
},
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
};"
|
|
379
|
+
`);
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
(0, vitest_1.describe)('gracefully errors if', () => {
|
|
383
|
+
(0, vitest_1.it)('config object not found', () => {
|
|
384
|
+
const originalConfig = `console.log('hello')`;
|
|
385
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
386
|
+
(0, vitest_1.expect)(modifiedConfig.error).toBe("Couldn't find the config object");
|
|
387
|
+
});
|
|
388
|
+
(0, vitest_1.it)('config is not an object', () => {
|
|
389
|
+
const originalConfig = `
|
|
390
|
+
export default getSvelteConfig();
|
|
391
|
+
`;
|
|
392
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
393
|
+
(0, vitest_1.expect)(modifiedConfig.error).toBe("Couldn't find the config object");
|
|
394
|
+
});
|
|
395
|
+
(0, vitest_1.it)('`kit` property is missing', () => {
|
|
396
|
+
const originalConfig = `
|
|
397
|
+
export default {
|
|
398
|
+
preprocess: vitePreprocess(),
|
|
399
|
+
};
|
|
400
|
+
`;
|
|
401
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
402
|
+
(0, vitest_1.expect)(modifiedConfig.error).toBe("Couldn't find the `kit` property");
|
|
403
|
+
});
|
|
404
|
+
(0, vitest_1.it)('`kit` property has unexpected type', () => {
|
|
405
|
+
const originalConfig = `
|
|
406
|
+
export default {
|
|
407
|
+
preprocess: vitePreprocess(),
|
|
408
|
+
|
|
409
|
+
kit: getKitConfig(),
|
|
410
|
+
};
|
|
411
|
+
`;
|
|
412
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
413
|
+
(0, vitest_1.expect)(modifiedConfig.error).toBe('`kit` property has unexpected type: CallExpression');
|
|
414
|
+
});
|
|
415
|
+
(0, vitest_1.it)('`kit.experimental` property has unexpected type', () => {
|
|
416
|
+
const originalConfig = `
|
|
417
|
+
export default {
|
|
418
|
+
preprocess: vitePreprocess(),
|
|
419
|
+
|
|
420
|
+
kit: {
|
|
421
|
+
adapter: adapter(),
|
|
422
|
+
experimental: 'hello',
|
|
423
|
+
},
|
|
424
|
+
};
|
|
425
|
+
`;
|
|
426
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
427
|
+
(0, vitest_1.expect)(modifiedConfig.error).toBe('Property `kit.experimental` has unexpected type: StringLiteral');
|
|
428
|
+
});
|
|
429
|
+
(0, vitest_1.it)('`kit.experimental.tracing` property has unexpected type', () => {
|
|
430
|
+
const originalConfig = `
|
|
431
|
+
export default {
|
|
432
|
+
preprocess: vitePreprocess(),
|
|
433
|
+
|
|
434
|
+
kit: {
|
|
435
|
+
adapter: adapter(),
|
|
436
|
+
experimental: {
|
|
437
|
+
tracing: true,
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
};
|
|
441
|
+
`;
|
|
442
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
443
|
+
(0, vitest_1.expect)(modifiedConfig.error).toBe('Property `kit.experimental.tracing` has unexpected type: BooleanLiteral');
|
|
444
|
+
});
|
|
445
|
+
(0, vitest_1.it)('`kit.experimental.instrumentation` property has unexpected type', () => {
|
|
446
|
+
const originalConfig = `
|
|
447
|
+
export default {
|
|
448
|
+
preprocess: vitePreprocess(),
|
|
449
|
+
|
|
450
|
+
kit: {
|
|
451
|
+
adapter: adapter(),
|
|
452
|
+
experimental: {
|
|
453
|
+
tracing: {
|
|
454
|
+
server: true,
|
|
455
|
+
},
|
|
456
|
+
instrumentation: 'server',
|
|
457
|
+
},
|
|
458
|
+
},
|
|
459
|
+
};
|
|
460
|
+
`;
|
|
461
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
462
|
+
(0, vitest_1.expect)(modifiedConfig.error).toBe('Property `kit.experimental.instrumentation` has unexpected type: StringLiteral');
|
|
463
|
+
});
|
|
464
|
+
(0, vitest_1.it)('`kit.experimental.tracing.server` property has unexpected type', () => {
|
|
465
|
+
const originalConfig = `
|
|
466
|
+
export default {
|
|
467
|
+
preprocess: vitePreprocess(),
|
|
468
|
+
|
|
469
|
+
kit: {
|
|
470
|
+
adapter: adapter(),
|
|
471
|
+
experimental: {
|
|
472
|
+
tracing: {
|
|
473
|
+
server: !!process.env['ENABLE_TRACING'],
|
|
474
|
+
},
|
|
475
|
+
instrumentation: {
|
|
476
|
+
server: true,
|
|
477
|
+
},
|
|
478
|
+
},
|
|
479
|
+
},
|
|
480
|
+
};
|
|
481
|
+
`;
|
|
482
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
483
|
+
(0, vitest_1.expect)(modifiedConfig.error).toBe('Property `kit.experimental.tracing.server` has unexpected type: UnaryExpression');
|
|
484
|
+
});
|
|
485
|
+
(0, vitest_1.it)('`kit.experimental.instrumentation.server` property has unexpected type', () => {
|
|
486
|
+
const originalConfig = `
|
|
487
|
+
export default {
|
|
488
|
+
preprocess: vitePreprocess(),
|
|
489
|
+
|
|
490
|
+
kit: {
|
|
491
|
+
adapter: adapter(),
|
|
492
|
+
experimental: {
|
|
493
|
+
tracing: {
|
|
494
|
+
server: true,
|
|
495
|
+
},
|
|
496
|
+
instrumentation: {
|
|
497
|
+
server: 'hello',
|
|
498
|
+
},
|
|
499
|
+
},
|
|
500
|
+
},
|
|
501
|
+
};
|
|
502
|
+
`;
|
|
503
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
504
|
+
(0, vitest_1.expect)(modifiedConfig.error).toBe('Property `kit.experimental.instrumentation.server` has unexpected type: StringLiteral');
|
|
505
|
+
});
|
|
506
|
+
(0, vitest_1.it)('config parsing fails', () => {
|
|
507
|
+
const originalConfig = `
|
|
508
|
+
export default {
|
|
509
|
+
preprocess: vitePreprocess(),
|
|
510
|
+
|
|
511
|
+
kit: {
|
|
512
|
+
adapter: adapter(),
|
|
513
|
+
experimental: {
|
|
514
|
+
tracing: {
|
|
515
|
+
server: true,
|
|
516
|
+
}
|
|
517
|
+
instrumentation: {
|
|
518
|
+
server: 'hello',
|
|
519
|
+
},
|
|
520
|
+
},
|
|
521
|
+
},
|
|
522
|
+
};
|
|
523
|
+
`;
|
|
524
|
+
const modifiedConfig = (0, svelte_config_1._enableTracingAndInstrumentationInConfig)(originalConfig, true);
|
|
525
|
+
(0, vitest_1.expect)(modifiedConfig.error).toBe('Failed to parse Svelte config');
|
|
526
|
+
});
|
|
527
|
+
});
|
|
528
|
+
});
|
|
529
|
+
//# sourceMappingURL=svelte-config.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svelte-config.test.js","sourceRoot":"","sources":["../../../../test/sveltekit/sdk-setup/svelte-config.test.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAC9C,kFAA0G;AAE1G,IAAA,iBAAQ,EAAC,0CAA0C,EAAE,GAAG,EAAE;IACxD,IAAA,WAAE,EAAC,yCAAyC,EAAE,GAAG,EAAE;QACjD,MAAM,cAAc,GAAG;;;;;;;;;;;;;;GAcxB,CAAC;QAEA,MAAM,cAAc,GAAG,IAAA,wDAAwC,EAC7D,cAAc,EACd,IAAI,CACL,CAAC;QAEF,IAAA,eAAM,EAAC,cAAc,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,IAAA,iBAAQ,EAAC,sBAAsB,EAAE,GAAG,EAAE;QACpC,IAAA,WAAE,EAAC,wCAAwC,EAAE,GAAG,EAAE;YAChD,MAAM,cAAc,GAAG;;;;;;;;;;CAU5B,CAAC;YAEI,MAAM,cAAc,GAAG,IAAA,wDAAwC,EAC7D,cAAc,EACd,IAAI,CACL,CAAC;YAEF,IAAA,eAAM,EAAC,cAAc,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;KAqBrD,CAAC,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,IAAA,WAAE,EAAC,yC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,EAC7D,cAAc,EACd,IAAI,CACL,CAAC;YAEF,IAAA,eAAM,EAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAC/B,iFAAiF,CAClF,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,IAAA,WAAE,EAAC,wEAAwE,EAAE,GAAG,EAAE;YAChF,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;OAgBtB,CAAC;YAEF,MAAM,cAAc,GAAG,IAAA,wDAAwC,EAC7D,cAAc,EACd,IAAI,CACL,CAAC;YAEF,IAAA,eAAM,EAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAC/B,uFAAuF,CACxF,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,IAAA,WAAE,EAAC,sBAAsB,EAAE,GAAG,EAAE;YAC9B,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;OAgBtB,CAAC;YAEF,MAAM,cAAc,GAAG,IAAA,wDAAwC,EAC7D,cAAc,EACd,IAAI,CACL,CAAC;YAEF,IAAA,eAAM,EAAC,cAAc,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, it, expect } from 'vitest';\nimport { _enableTracingAndInstrumentationInConfig } from '../../../src/sveltekit/sdk-setup/svelte-config';\n\ndescribe('_enableTracingAndInstrumentationInConfig', () => {\n it('leaves already correct config unchanged', () => {\n const originalConfig = `export default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n tracing: {\n server: true,\n },\n instrumentation: {\n server: true,\n },\n },\n },\n};`;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.result).toBe(originalConfig);\n });\n\n describe('successfully handles', () => {\n it('default config as variable declaration', () => {\n const originalConfig = `/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n },\n};\n\nexport default config;\n`;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.result).toMatchInlineSnapshot(`\n \"/** @type {import('@sveltejs/kit').Config} */\n const config = {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n\n experimental: {\n tracing: {\n server: true,\n },\n\n instrumentation: {\n server: true,\n },\n },\n },\n };\n\n export default config;\"\n `);\n });\n\n it('default config named declaration object', () => {\n const originalConfig = `\nexport default config = {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n },\n};\n`;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.result).toMatchInlineSnapshot(`\n \"export default config = {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n\n experimental: {\n tracing: {\n server: true,\n },\n\n instrumentation: {\n server: true,\n },\n },\n },\n };\"\n `);\n });\n\n it('default config as in-place object', () => {\n const originalConfig = `\nexport default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n },\n};\n`;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.result).toMatchInlineSnapshot(`\n \"export default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n\n experimental: {\n tracing: {\n server: true,\n },\n\n instrumentation: {\n server: true,\n },\n },\n },\n };\"\n `);\n });\n\n it('config with tracing disabled', () => {\n const originalConfig = `\nexport default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n },\n};\n`;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n false,\n );\n\n expect(modifiedConfig.result).toMatchInlineSnapshot(`\n \"export default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n\n experimental: {\n tracing: {\n server: false,\n },\n\n instrumentation: {\n server: true,\n },\n },\n },\n };\"\n `);\n });\n\n it('config with pre-existing `kit.experimental` property', () => {\n const originalConfig = `\nexport default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n remoteFunctions: true,\n }\n },\n};\n`;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.result).toMatchInlineSnapshot(`\n \"export default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n remoteFunctions: true,\n\n tracing: {\n server: true,\n },\n\n instrumentation: {\n server: true,\n },\n }\n },\n };\"\n `);\n });\n\n it('config with pre-existing and empty `kit.experimental.tracing` property', () => {\n const originalConfig = `\nexport default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n remoteFunctions: true,\n tracing: {\n },\n }\n },\n};\n`;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.result).toMatchInlineSnapshot(`\n \"export default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n remoteFunctions: true,\n\n tracing: {\n server: true,\n },\n\n instrumentation: {\n server: true,\n },\n }\n },\n };\"\n `);\n });\n\n it('config with pre-existing and empty `kit.experimental.instrumentation` property', () => {\n const originalConfig = `\nexport default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n remoteFunctions: true,\n tracing: {\n },\n instrumentation: {\n },\n }\n },\n};\n`;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.result).toMatchInlineSnapshot(`\n \"export default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n remoteFunctions: true,\n tracing: {\n server: true,\n },\n instrumentation: {\n server: true,\n },\n }\n },\n };\"\n `);\n });\n\n it('config with pre-existing and filled `kit.experimental.(instrumentation|tracing).server` properties', () => {\n const originalConfig = `\nexport default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n remoteFunctions: true,\n tracing: {\n server: false,\n },\n instrumentation: {\n server: false,\n },\n }\n },\n};\n`;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.result).toMatchInlineSnapshot(`\n \"export default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n remoteFunctions: true,\n tracing: {\n server: true,\n },\n instrumentation: {\n server: true,\n },\n }\n },\n };\"\n `);\n });\n\n it('config with pre-existing and filled `kit.experimental.(instrumentation|tracing).server` properties with instrumentation disabled', () => {\n const originalConfig = `\nexport default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n remoteFunctions: true,\n tracing: {\n server: true,\n },\n instrumentation: {\n server: false,\n },\n }\n },\n};\n`;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.result).toMatchInlineSnapshot(`\n \"export default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n remoteFunctions: true,\n tracing: {\n server: true,\n },\n instrumentation: {\n server: true,\n },\n }\n },\n };\"\n `);\n });\n\n it('config with pre-existing and filled `kit.experimental.(instrumentation|tracing).server` properties with tracing disabled', () => {\n const originalConfig = `\nexport default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n remoteFunctions: true,\n tracing: {\n server: false,\n },\n instrumentation: {\n server: true,\n },\n }\n },\n};\n`;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.result).toMatchInlineSnapshot(`\n \"export default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n remoteFunctions: true,\n tracing: {\n server: true,\n },\n instrumentation: {\n server: true,\n },\n }\n },\n };\"\n `);\n });\n });\n\n describe('gracefully errors if', () => {\n it('config object not found', () => {\n const originalConfig = `console.log('hello')`;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.error).toBe(\"Couldn't find the config object\");\n });\n\n it('config is not an object', () => {\n const originalConfig = `\n export default getSvelteConfig();\n `;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.error).toBe(\"Couldn't find the config object\");\n });\n\n it('`kit` property is missing', () => {\n const originalConfig = `\n export default {\n preprocess: vitePreprocess(),\n };\n `;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.error).toBe(\"Couldn't find the `kit` property\");\n });\n\n it('`kit` property has unexpected type', () => {\n const originalConfig = `\n export default {\n preprocess: vitePreprocess(),\n \n kit: getKitConfig(),\n };\n `;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.error).toBe(\n '`kit` property has unexpected type: CallExpression',\n );\n });\n\n it('`kit.experimental` property has unexpected type', () => {\n const originalConfig = `\n export default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: 'hello',\n },\n };\n `;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.error).toBe(\n 'Property `kit.experimental` has unexpected type: StringLiteral',\n );\n });\n\n it('`kit.experimental.tracing` property has unexpected type', () => {\n const originalConfig = `\n export default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n tracing: true,\n },\n },\n };\n `;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.error).toBe(\n 'Property `kit.experimental.tracing` has unexpected type: BooleanLiteral',\n );\n });\n\n it('`kit.experimental.instrumentation` property has unexpected type', () => {\n const originalConfig = `\n export default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n tracing: {\n server: true,\n },\n instrumentation: 'server',\n },\n },\n };\n `;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.error).toBe(\n 'Property `kit.experimental.instrumentation` has unexpected type: StringLiteral',\n );\n });\n\n it('`kit.experimental.tracing.server` property has unexpected type', () => {\n const originalConfig = `\n export default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n tracing: {\n server: !!process.env['ENABLE_TRACING'],\n },\n instrumentation: {\n server: true,\n },\n },\n },\n };\n `;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.error).toBe(\n 'Property `kit.experimental.tracing.server` has unexpected type: UnaryExpression',\n );\n });\n\n it('`kit.experimental.instrumentation.server` property has unexpected type', () => {\n const originalConfig = `\n export default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n tracing: {\n server: true,\n },\n instrumentation: {\n server: 'hello',\n },\n },\n },\n };\n `;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.error).toBe(\n 'Property `kit.experimental.instrumentation.server` has unexpected type: StringLiteral',\n );\n });\n\n it('config parsing fails', () => {\n const originalConfig = `\n export default {\n preprocess: vitePreprocess(),\n\n kit: {\n adapter: adapter(),\n experimental: {\n tracing: {\n server: true,\n }\n instrumentation: {\n server: 'hello',\n },\n },\n },\n };\n `;\n\n const modifiedConfig = _enableTracingAndInstrumentationInConfig(\n originalConfig,\n true,\n );\n\n expect(modifiedConfig.error).toBe('Failed to parse Svelte config');\n });\n });\n});\n"]}
|