@sentry/wizard 3.34.4 → 3.36.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 (88) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/dist/e2e-tests/tests/nuxt-3.test.d.ts +1 -0
  3. package/dist/e2e-tests/tests/nuxt-3.test.js +257 -0
  4. package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -0
  5. package/dist/e2e-tests/tests/nuxt-4.test.d.ts +1 -0
  6. package/dist/e2e-tests/tests/nuxt-4.test.js +258 -0
  7. package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -0
  8. package/dist/e2e-tests/tests/remix.test.js +92 -27
  9. package/dist/e2e-tests/tests/remix.test.js.map +1 -1
  10. package/dist/e2e-tests/tests/sveltekit.test.js +102 -42
  11. package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
  12. package/dist/e2e-tests/utils/index.d.ts +18 -1
  13. package/dist/e2e-tests/utils/index.js +31 -2
  14. package/dist/e2e-tests/utils/index.js.map +1 -1
  15. package/dist/lib/Constants.d.ts +1 -0
  16. package/dist/lib/Constants.js +1 -0
  17. package/dist/lib/Constants.js.map +1 -1
  18. package/dist/package.json +1 -1
  19. package/dist/src/android/templates.js +1 -1
  20. package/dist/src/android/templates.js.map +1 -1
  21. package/dist/src/apple/templates.js +2 -2
  22. package/dist/src/apple/templates.js.map +1 -1
  23. package/dist/src/nextjs/nextjs-wizard.js +1 -0
  24. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  25. package/dist/src/nuxt/nuxt-wizard.d.ts +3 -0
  26. package/dist/src/nuxt/nuxt-wizard.js +227 -0
  27. package/dist/src/nuxt/nuxt-wizard.js.map +1 -0
  28. package/dist/src/nuxt/sdk-example.d.ts +8 -0
  29. package/dist/src/nuxt/sdk-example.js +179 -0
  30. package/dist/src/nuxt/sdk-example.js.map +1 -0
  31. package/dist/src/nuxt/sdk-setup.d.ts +11 -0
  32. package/dist/src/nuxt/sdk-setup.js +326 -0
  33. package/dist/src/nuxt/sdk-setup.js.map +1 -0
  34. package/dist/src/nuxt/templates.d.ts +22 -0
  35. package/dist/src/nuxt/templates.js +84 -0
  36. package/dist/src/nuxt/templates.js.map +1 -0
  37. package/dist/src/nuxt/utils.d.ts +1 -0
  38. package/dist/src/nuxt/utils.js +71 -0
  39. package/dist/src/nuxt/utils.js.map +1 -0
  40. package/dist/src/remix/remix-wizard.js +2 -1
  41. package/dist/src/remix/remix-wizard.js.map +1 -1
  42. package/dist/src/run.d.ts +1 -1
  43. package/dist/src/run.js +30 -23
  44. package/dist/src/run.js.map +1 -1
  45. package/dist/src/sourcemaps/tools/rollup.js +1 -1
  46. package/dist/src/sourcemaps/tools/rollup.js.map +1 -1
  47. package/dist/src/sveltekit/sveltekit-wizard.js +2 -1
  48. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  49. package/dist/src/utils/clack-utils.d.ts +9 -2
  50. package/dist/src/utils/clack-utils.js +93 -27
  51. package/dist/src/utils/clack-utils.js.map +1 -1
  52. package/dist/src/utils/package-json.d.ts +5 -0
  53. package/dist/src/utils/package-json.js.map +1 -1
  54. package/dist/src/utils/package-manager.d.ts +1 -0
  55. package/dist/src/utils/package-manager.js +129 -0
  56. package/dist/src/utils/package-manager.js.map +1 -1
  57. package/dist/test/nuxt/templates.test.d.ts +1 -0
  58. package/dist/test/nuxt/templates.test.js +70 -0
  59. package/dist/test/nuxt/templates.test.js.map +1 -0
  60. package/e2e-tests/README.md +59 -0
  61. package/e2e-tests/test-applications/nuxt-3-test-app/README.md +75 -0
  62. package/e2e-tests/test-applications/nuxt-3-test-app/nuxt.config.ts +5 -0
  63. package/e2e-tests/test-applications/nuxt-3-test-app/package.json +18 -0
  64. package/e2e-tests/test-applications/nuxt-3-test-app/public/favicon.ico +0 -0
  65. package/e2e-tests/test-applications/nuxt-3-test-app/public/robots.txt +1 -0
  66. package/e2e-tests/tests/nuxt-3.test.ts +192 -0
  67. package/e2e-tests/tests/nuxt-4.test.ts +191 -0
  68. package/e2e-tests/tests/remix.test.ts +163 -50
  69. package/e2e-tests/tests/sveltekit.test.ts +180 -79
  70. package/e2e-tests/utils/index.ts +34 -1
  71. package/lib/Constants.ts +1 -0
  72. package/package.json +1 -1
  73. package/src/android/templates.ts +0 -2
  74. package/src/apple/templates.ts +14 -2
  75. package/src/nextjs/nextjs-wizard.ts +1 -0
  76. package/src/nuxt/nuxt-wizard.ts +177 -0
  77. package/src/nuxt/sdk-example.ts +135 -0
  78. package/src/nuxt/sdk-setup.ts +248 -0
  79. package/src/nuxt/templates.ts +296 -0
  80. package/src/nuxt/utils.ts +32 -0
  81. package/src/remix/remix-wizard.ts +2 -1
  82. package/src/run.ts +7 -0
  83. package/src/sourcemaps/tools/rollup.ts +1 -1
  84. package/src/sveltekit/sveltekit-wizard.ts +2 -1
  85. package/src/utils/clack-utils.ts +74 -13
  86. package/src/utils/package-json.ts +5 -0
  87. package/src/utils/package-manager.ts +66 -0
  88. package/test/nuxt/templates.test.ts +228 -0
@@ -4,6 +4,7 @@ import * as path from 'path';
4
4
 
5
5
  import * as Sentry from '@sentry/node';
6
6
  import { traceStep } from '../telemetry';
7
+ import { getPackageDotJson, updatePackageDotJson } from './clack-utils';
7
8
 
8
9
  export interface PackageManager {
9
10
  name: string;
@@ -15,6 +16,7 @@ export interface PackageManager {
15
16
  runScriptCommand: string;
16
17
  flags: string;
17
18
  detect: () => boolean;
19
+ addOverride: (pkgName: string, pkgVersion: string) => Promise<void>;
18
20
  }
19
21
 
20
22
  export const BUN: PackageManager = {
@@ -26,6 +28,18 @@ export const BUN: PackageManager = {
26
28
  runScriptCommand: 'bun run',
27
29
  flags: '',
28
30
  detect: () => fs.existsSync(path.join(process.cwd(), BUN.lockFile)),
31
+ addOverride: async (pkgName, pkgVersion): Promise<void> => {
32
+ const packageDotJson = await getPackageDotJson();
33
+ const overrides = packageDotJson.overrides || {};
34
+
35
+ await updatePackageDotJson({
36
+ ...packageDotJson,
37
+ overrides: {
38
+ ...overrides,
39
+ [pkgName]: pkgVersion,
40
+ },
41
+ });
42
+ },
29
43
  };
30
44
  export const YARN_V1: PackageManager = {
31
45
  name: 'yarn',
@@ -45,6 +59,18 @@ export const YARN_V1: PackageManager = {
45
59
  return false;
46
60
  }
47
61
  },
62
+ addOverride: async (pkgName, pkgVersion): Promise<void> => {
63
+ const packageDotJson = await getPackageDotJson();
64
+ const resolutions = packageDotJson.resolutions || {};
65
+
66
+ await updatePackageDotJson({
67
+ ...packageDotJson,
68
+ resolutions: {
69
+ ...resolutions,
70
+ [pkgName]: pkgVersion,
71
+ },
72
+ });
73
+ },
48
74
  };
49
75
  /** YARN V2/3/4 */
50
76
  export const YARN_V2: PackageManager = {
@@ -65,6 +91,18 @@ export const YARN_V2: PackageManager = {
65
91
  return false;
66
92
  }
67
93
  },
94
+ addOverride: async (pkgName, pkgVersion): Promise<void> => {
95
+ const packageDotJson = await getPackageDotJson();
96
+ const resolutions = packageDotJson.resolutions || {};
97
+
98
+ await updatePackageDotJson({
99
+ ...packageDotJson,
100
+ resolutions: {
101
+ ...resolutions,
102
+ [pkgName]: pkgVersion,
103
+ },
104
+ });
105
+ },
68
106
  };
69
107
  export const PNPM: PackageManager = {
70
108
  name: 'pnpm',
@@ -75,6 +113,22 @@ export const PNPM: PackageManager = {
75
113
  runScriptCommand: 'pnpm',
76
114
  flags: '--ignore-workspace-root-check',
77
115
  detect: () => fs.existsSync(path.join(process.cwd(), PNPM.lockFile)),
116
+ addOverride: async (pkgName, pkgVersion): Promise<void> => {
117
+ const packageDotJson = await getPackageDotJson();
118
+ const pnpm = packageDotJson.pnpm || {};
119
+ const overrides = pnpm.overrides || {};
120
+
121
+ await updatePackageDotJson({
122
+ ...packageDotJson,
123
+ pnpm: {
124
+ ...pnpm,
125
+ overrides: {
126
+ ...overrides,
127
+ [pkgName]: pkgVersion,
128
+ },
129
+ },
130
+ });
131
+ },
78
132
  };
79
133
  export const NPM: PackageManager = {
80
134
  name: 'npm',
@@ -85,6 +139,18 @@ export const NPM: PackageManager = {
85
139
  runScriptCommand: 'npm run',
86
140
  flags: '',
87
141
  detect: () => fs.existsSync(path.join(process.cwd(), NPM.lockFile)),
142
+ addOverride: async (pkgName, pkgVersion): Promise<void> => {
143
+ const packageDotJson = await getPackageDotJson();
144
+ const overrides = packageDotJson.overrides || {};
145
+
146
+ await updatePackageDotJson({
147
+ ...packageDotJson,
148
+ overrides: {
149
+ ...overrides,
150
+ [pkgName]: pkgVersion,
151
+ },
152
+ });
153
+ },
88
154
  };
89
155
 
90
156
  export const packageManagers = [BUN, YARN_V1, YARN_V2, PNPM, NPM];
@@ -0,0 +1,228 @@
1
+ import {
2
+ getDefaultNuxtConfig,
3
+ getNuxtModuleFallbackTemplate,
4
+ getSentryConfigContents,
5
+ } from '../../src/nuxt/templates';
6
+
7
+ describe('Nuxt code templates', () => {
8
+ describe('getDefaultNuxtConfig', () => {
9
+ it('returns a default nuxt config', () => {
10
+ expect(getDefaultNuxtConfig()).toMatchInlineSnapshot(`
11
+ "// https://nuxt.com/docs/api/configuration/nuxt-config
12
+ export default defineNuxtConfig({
13
+ compatibilityDate: '2024-04-03',
14
+ devtools: { enabled: true }
15
+ })
16
+ "
17
+ `);
18
+ });
19
+ });
20
+
21
+ describe('getSentryConfigContents', () => {
22
+ describe('client config', () => {
23
+ it('generates Sentry config with all features enabled', () => {
24
+ const template = getSentryConfigContents(
25
+ 'https://sentry.io/123',
26
+ 'client',
27
+ {
28
+ performance: true,
29
+ replay: true,
30
+ },
31
+ );
32
+
33
+ expect(template).toMatchInlineSnapshot(`
34
+ "import * as Sentry from "@sentry/nuxt";
35
+
36
+ Sentry.init({
37
+ // If set up, you can use your runtime config here
38
+ // dsn: useRuntimeConfig().public.sentry.dsn,
39
+ dsn: "https://sentry.io/123",
40
+
41
+ // We recommend adjusting this value in production, or using tracesSampler
42
+ // for finer control
43
+ tracesSampleRate: 1.0,
44
+
45
+ // This sets the sample rate to be 10%. You may want this to be 100% while
46
+ // in development and sample at a lower rate in production
47
+ replaysSessionSampleRate: 0.1,
48
+
49
+ // If the entire session is not sampled, use the below sample rate to sample
50
+ // sessions when an error occurs.
51
+ replaysOnErrorSampleRate: 1.0,
52
+
53
+ // If you don't want to use Session Replay, just remove the line below:
54
+ integrations: [Sentry.replayIntegration()],
55
+
56
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
57
+ debug: false,
58
+ });
59
+ "
60
+ `);
61
+ });
62
+
63
+ it('generates Sentry config with performance monitoring disabled', () => {
64
+ const template = getSentryConfigContents(
65
+ 'https://sentry.io/123',
66
+ 'client',
67
+ {
68
+ performance: false,
69
+ replay: true,
70
+ },
71
+ );
72
+
73
+ expect(template).toMatchInlineSnapshot(`
74
+ "import * as Sentry from "@sentry/nuxt";
75
+
76
+ Sentry.init({
77
+ // If set up, you can use your runtime config here
78
+ // dsn: useRuntimeConfig().public.sentry.dsn,
79
+ dsn: "https://sentry.io/123",
80
+
81
+ // This sets the sample rate to be 10%. You may want this to be 100% while
82
+ // in development and sample at a lower rate in production
83
+ replaysSessionSampleRate: 0.1,
84
+
85
+ // If the entire session is not sampled, use the below sample rate to sample
86
+ // sessions when an error occurs.
87
+ replaysOnErrorSampleRate: 1.0,
88
+
89
+ // If you don't want to use Session Replay, just remove the line below:
90
+ integrations: [Sentry.replayIntegration()],
91
+
92
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
93
+ debug: false,
94
+ });
95
+ "
96
+ `);
97
+ });
98
+
99
+ it('generates Sentry config with session replay disabled', () => {
100
+ const template = getSentryConfigContents(
101
+ 'https://sentry.io/123',
102
+ 'client',
103
+ {
104
+ performance: true,
105
+ replay: false,
106
+ },
107
+ );
108
+
109
+ expect(template).toMatchInlineSnapshot(`
110
+ "import * as Sentry from "@sentry/nuxt";
111
+
112
+ Sentry.init({
113
+ // If set up, you can use your runtime config here
114
+ // dsn: useRuntimeConfig().public.sentry.dsn,
115
+ dsn: "https://sentry.io/123",
116
+
117
+ // We recommend adjusting this value in production, or using tracesSampler
118
+ // for finer control
119
+ tracesSampleRate: 1.0,
120
+
121
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
122
+ debug: false,
123
+ });
124
+ "
125
+ `);
126
+ });
127
+
128
+ it('generates Sentry config with performance monitoring and session replay disabled', () => {
129
+ const template = getSentryConfigContents(
130
+ 'https://sentry.io/123',
131
+ 'client',
132
+ {
133
+ performance: false,
134
+ replay: false,
135
+ },
136
+ );
137
+
138
+ expect(template).toMatchInlineSnapshot(`
139
+ "import * as Sentry from "@sentry/nuxt";
140
+
141
+ Sentry.init({
142
+ // If set up, you can use your runtime config here
143
+ // dsn: useRuntimeConfig().public.sentry.dsn,
144
+ dsn: "https://sentry.io/123",
145
+
146
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
147
+ debug: false,
148
+ });
149
+ "
150
+ `);
151
+ });
152
+ });
153
+
154
+ describe('server config', () => {
155
+ it('generates Sentry config with all features enabled', () => {
156
+ const template = getSentryConfigContents(
157
+ 'https://sentry.io/123',
158
+ 'server',
159
+ {
160
+ performance: true,
161
+ replay: true,
162
+ },
163
+ );
164
+
165
+ expect(template).toMatchInlineSnapshot(`
166
+ "import * as Sentry from "@sentry/nuxt";
167
+
168
+ Sentry.init({
169
+ dsn: "https://sentry.io/123",
170
+
171
+ // We recommend adjusting this value in production, or using tracesSampler
172
+ // for finer control
173
+ tracesSampleRate: 1.0,
174
+
175
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
176
+ debug: false,
177
+ });
178
+ "
179
+ `);
180
+ });
181
+
182
+ it('generates Sentry config with performance monitoring disabled', () => {
183
+ const template = getSentryConfigContents(
184
+ 'https://sentry.io/123',
185
+ 'server',
186
+ {
187
+ performance: false,
188
+ replay: true,
189
+ },
190
+ );
191
+
192
+ expect(template).toMatchInlineSnapshot(`
193
+ "import * as Sentry from "@sentry/nuxt";
194
+
195
+ Sentry.init({
196
+ dsn: "https://sentry.io/123",
197
+
198
+ // Setting this option to true will print useful information to the console while you're setting up Sentry.
199
+ debug: false,
200
+ });
201
+ "
202
+ `);
203
+ });
204
+ });
205
+ });
206
+
207
+ describe('getNuxtModuleFallbackTemplate', () => {
208
+ it('generates configuration options for the nuxt config', () => {
209
+ const template = getNuxtModuleFallbackTemplate({
210
+ org: 'my-org',
211
+ project: 'my-project',
212
+ url: 'https://sentry.io',
213
+ selfHosted: false,
214
+ });
215
+
216
+ expect(template).toMatchInlineSnapshot(`
217
+ " modules: ["@sentry/nuxt/module"],
218
+ sentry: {
219
+ sourceMapsUploadOptions: {
220
+ org: "my-org",
221
+ project: "my-project",
222
+ },
223
+ },
224
+ sourcemap: { client: "hidden" },"
225
+ `);
226
+ });
227
+ });
228
+ });