@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
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var templates_1 = require("../../src/nuxt/templates");
4
+ describe('Nuxt code templates', function () {
5
+ describe('getDefaultNuxtConfig', function () {
6
+ it('returns a default nuxt config', function () {
7
+ expect((0, templates_1.getDefaultNuxtConfig)()).toMatchInlineSnapshot("\n \"// https://nuxt.com/docs/api/configuration/nuxt-config\n export default defineNuxtConfig({\n compatibilityDate: '2024-04-03',\n devtools: { enabled: true }\n })\n \"\n");
8
+ });
9
+ });
10
+ describe('getSentryConfigContents', function () {
11
+ describe('client config', function () {
12
+ it('generates Sentry config with all features enabled', function () {
13
+ var template = (0, templates_1.getSentryConfigContents)('https://sentry.io/123', 'client', {
14
+ performance: true,
15
+ replay: true,
16
+ });
17
+ expect(template).toMatchInlineSnapshot("\n \"import * as Sentry from \"@sentry/nuxt\";\n\n Sentry.init({\n // If set up, you can use your runtime config here\n // dsn: useRuntimeConfig().public.sentry.dsn,\n dsn: \"https://sentry.io/123\",\n\n // We recommend adjusting this value in production, or using tracesSampler\n // for finer control\n tracesSampleRate: 1.0,\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n \n // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n \n // If you don't want to use Session Replay, just remove the line below:\n integrations: [Sentry.replayIntegration()],\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n });\n \"\n ");
18
+ });
19
+ it('generates Sentry config with performance monitoring disabled', function () {
20
+ var template = (0, templates_1.getSentryConfigContents)('https://sentry.io/123', 'client', {
21
+ performance: false,
22
+ replay: true,
23
+ });
24
+ expect(template).toMatchInlineSnapshot("\n \"import * as Sentry from \"@sentry/nuxt\";\n\n Sentry.init({\n // If set up, you can use your runtime config here\n // dsn: useRuntimeConfig().public.sentry.dsn,\n dsn: \"https://sentry.io/123\",\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n \n // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n \n // If you don't want to use Session Replay, just remove the line below:\n integrations: [Sentry.replayIntegration()],\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n });\n \"\n ");
25
+ });
26
+ it('generates Sentry config with session replay disabled', function () {
27
+ var template = (0, templates_1.getSentryConfigContents)('https://sentry.io/123', 'client', {
28
+ performance: true,
29
+ replay: false,
30
+ });
31
+ expect(template).toMatchInlineSnapshot("\n \"import * as Sentry from \"@sentry/nuxt\";\n\n Sentry.init({\n // If set up, you can use your runtime config here\n // dsn: useRuntimeConfig().public.sentry.dsn,\n dsn: \"https://sentry.io/123\",\n\n // We recommend adjusting this value in production, or using tracesSampler\n // for finer control\n tracesSampleRate: 1.0,\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n });\n \"\n ");
32
+ });
33
+ it('generates Sentry config with performance monitoring and session replay disabled', function () {
34
+ var template = (0, templates_1.getSentryConfigContents)('https://sentry.io/123', 'client', {
35
+ performance: false,
36
+ replay: false,
37
+ });
38
+ expect(template).toMatchInlineSnapshot("\n \"import * as Sentry from \"@sentry/nuxt\";\n\n Sentry.init({\n // If set up, you can use your runtime config here\n // dsn: useRuntimeConfig().public.sentry.dsn,\n dsn: \"https://sentry.io/123\",\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n });\n \"\n ");
39
+ });
40
+ });
41
+ describe('server config', function () {
42
+ it('generates Sentry config with all features enabled', function () {
43
+ var template = (0, templates_1.getSentryConfigContents)('https://sentry.io/123', 'server', {
44
+ performance: true,
45
+ replay: true,
46
+ });
47
+ expect(template).toMatchInlineSnapshot("\n \"import * as Sentry from \"@sentry/nuxt\";\n \n Sentry.init({\n dsn: \"https://sentry.io/123\",\n\n // We recommend adjusting this value in production, or using tracesSampler\n // for finer control\n tracesSampleRate: 1.0,\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n });\n \"\n ");
48
+ });
49
+ it('generates Sentry config with performance monitoring disabled', function () {
50
+ var template = (0, templates_1.getSentryConfigContents)('https://sentry.io/123', 'server', {
51
+ performance: false,
52
+ replay: true,
53
+ });
54
+ expect(template).toMatchInlineSnapshot("\n \"import * as Sentry from \"@sentry/nuxt\";\n \n Sentry.init({\n dsn: \"https://sentry.io/123\",\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n });\n \"\n ");
55
+ });
56
+ });
57
+ });
58
+ describe('getNuxtModuleFallbackTemplate', function () {
59
+ it('generates configuration options for the nuxt config', function () {
60
+ var template = (0, templates_1.getNuxtModuleFallbackTemplate)({
61
+ org: 'my-org',
62
+ project: 'my-project',
63
+ url: 'https://sentry.io',
64
+ selfHosted: false,
65
+ });
66
+ expect(template).toMatchInlineSnapshot("\n \" modules: [\"@sentry/nuxt/module\"],\n sentry: {\n sourceMapsUploadOptions: {\n org: \"my-org\",\n project: \"my-project\",\n },\n },\n sourcemap: { client: \"hidden\" },\"\n ");
67
+ });
68
+ });
69
+ });
70
+ //# sourceMappingURL=templates.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.test.js","sourceRoot":"","sources":["../../../test/nuxt/templates.test.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n getDefaultNuxtConfig,\n getNuxtModuleFallbackTemplate,\n getSentryConfigContents,\n} from '../../src/nuxt/templates';\n\ndescribe('Nuxt code templates', () => {\n describe('getDefaultNuxtConfig', () => {\n it('returns a default nuxt config', () => {\n expect(getDefaultNuxtConfig()).toMatchInlineSnapshot(`\n \"// https://nuxt.com/docs/api/configuration/nuxt-config\n export default defineNuxtConfig({\n compatibilityDate: '2024-04-03',\n devtools: { enabled: true }\n })\n \"\n`);\n });\n });\n\n describe('getSentryConfigContents', () => {\n describe('client config', () => {\n it('generates Sentry config with all features enabled', () => {\n const template = getSentryConfigContents(\n 'https://sentry.io/123',\n 'client',\n {\n performance: true,\n replay: true,\n },\n );\n\n expect(template).toMatchInlineSnapshot(`\n \"import * as Sentry from \"@sentry/nuxt\";\n\n Sentry.init({\n // If set up, you can use your runtime config here\n // dsn: useRuntimeConfig().public.sentry.dsn,\n dsn: \"https://sentry.io/123\",\n\n // We recommend adjusting this value in production, or using tracesSampler\n // for finer control\n tracesSampleRate: 1.0,\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n \n // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n \n // If you don't want to use Session Replay, just remove the line below:\n integrations: [Sentry.replayIntegration()],\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n });\n \"\n `);\n });\n\n it('generates Sentry config with performance monitoring disabled', () => {\n const template = getSentryConfigContents(\n 'https://sentry.io/123',\n 'client',\n {\n performance: false,\n replay: true,\n },\n );\n\n expect(template).toMatchInlineSnapshot(`\n \"import * as Sentry from \"@sentry/nuxt\";\n\n Sentry.init({\n // If set up, you can use your runtime config here\n // dsn: useRuntimeConfig().public.sentry.dsn,\n dsn: \"https://sentry.io/123\",\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n \n // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n \n // If you don't want to use Session Replay, just remove the line below:\n integrations: [Sentry.replayIntegration()],\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n });\n \"\n `);\n });\n\n it('generates Sentry config with session replay disabled', () => {\n const template = getSentryConfigContents(\n 'https://sentry.io/123',\n 'client',\n {\n performance: true,\n replay: false,\n },\n );\n\n expect(template).toMatchInlineSnapshot(`\n \"import * as Sentry from \"@sentry/nuxt\";\n\n Sentry.init({\n // If set up, you can use your runtime config here\n // dsn: useRuntimeConfig().public.sentry.dsn,\n dsn: \"https://sentry.io/123\",\n\n // We recommend adjusting this value in production, or using tracesSampler\n // for finer control\n tracesSampleRate: 1.0,\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n });\n \"\n `);\n });\n\n it('generates Sentry config with performance monitoring and session replay disabled', () => {\n const template = getSentryConfigContents(\n 'https://sentry.io/123',\n 'client',\n {\n performance: false,\n replay: false,\n },\n );\n\n expect(template).toMatchInlineSnapshot(`\n \"import * as Sentry from \"@sentry/nuxt\";\n\n Sentry.init({\n // If set up, you can use your runtime config here\n // dsn: useRuntimeConfig().public.sentry.dsn,\n dsn: \"https://sentry.io/123\",\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n });\n \"\n `);\n });\n });\n\n describe('server config', () => {\n it('generates Sentry config with all features enabled', () => {\n const template = getSentryConfigContents(\n 'https://sentry.io/123',\n 'server',\n {\n performance: true,\n replay: true,\n },\n );\n\n expect(template).toMatchInlineSnapshot(`\n \"import * as Sentry from \"@sentry/nuxt\";\n \n Sentry.init({\n dsn: \"https://sentry.io/123\",\n\n // We recommend adjusting this value in production, or using tracesSampler\n // for finer control\n tracesSampleRate: 1.0,\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n });\n \"\n `);\n });\n\n it('generates Sentry config with performance monitoring disabled', () => {\n const template = getSentryConfigContents(\n 'https://sentry.io/123',\n 'server',\n {\n performance: false,\n replay: true,\n },\n );\n\n expect(template).toMatchInlineSnapshot(`\n \"import * as Sentry from \"@sentry/nuxt\";\n \n Sentry.init({\n dsn: \"https://sentry.io/123\",\n \n // Setting this option to true will print useful information to the console while you're setting up Sentry.\n debug: false,\n });\n \"\n `);\n });\n });\n });\n\n describe('getNuxtModuleFallbackTemplate', () => {\n it('generates configuration options for the nuxt config', () => {\n const template = getNuxtModuleFallbackTemplate({\n org: 'my-org',\n project: 'my-project',\n url: 'https://sentry.io',\n selfHosted: false,\n });\n\n expect(template).toMatchInlineSnapshot(`\n \" modules: [\"@sentry/nuxt/module\"],\n sentry: {\n sourceMapsUploadOptions: {\n org: \"my-org\",\n project: \"my-project\",\n },\n },\n sourcemap: { client: \"hidden\" },\"\n `);\n });\n });\n});\n"]}
@@ -0,0 +1,59 @@
1
+ # End-to-end Tests for Sentry Wizard
2
+
3
+ ## Structure
4
+
5
+ ```
6
+ test-applications/
7
+ |---- nextjs-test-app/
8
+ |---- remix-test-app/
9
+ |---- sveltekit-test-app/
10
+ tests/
11
+ |---- nextjs.test.ts
12
+ |---- remix.test.ts
13
+ |---- sveltekit.test.ts
14
+ ```
15
+
16
+ ### Utilities
17
+
18
+ `utils/` contains helpers such as the wizard runner, assertion tools and file modifiers that can be used in (`*.test.ts`).
19
+
20
+ #### Helpers
21
+
22
+ - `startWizardInstance` - Starts a new instance of `WizardTestEnv`.
23
+
24
+ - `initGit` - Initializes a temporary git repository in the test project.
25
+ - `cleanupGit` - Cleans up the temporary git repository in the test project.
26
+ - `revertLocalChanges` - Reverts local changes (git tracked or untracked) in the test project.
27
+
28
+ - `createFile` - Creates a file (optionally with content) in the test project.
29
+ - `modifyFile` - Modifies a file in the test project.
30
+
31
+ - `checkFileExists` - Checks if a file exists in the test project.
32
+ - `checkPackageJson` - Checks if the `@sentry/[integration]` package exists in the dependencies of the test project's `package.json`.
33
+ - `checkSentryCliConfig` - Checks if the `.sentryclirc` file contains the Sentry auth token.
34
+ - `checkEnvBuildPlugin` - Cheks if `.env.sentry-build-plugin` contains the Sentry auth token.
35
+
36
+ - `checkIfBuilds` - Checks if the test project builds successfully.
37
+ - `checkIfRunsOnDevMode` - Checks if the test project runs on dev mode successfully.
38
+ - `checkIfRunsOnProdMode` - Checks if the test project runs on prod mode successfully.
39
+
40
+
41
+ #### `WizardTestEnv`
42
+
43
+ `WizardTestEnv` is a class that can be used to run the Sentry Wizard in a test environment. It provides methods to run the wizard with specific arguments and stdio.
44
+
45
+ ## Running Tests Locally
46
+
47
+ First, you need to create a `.env` file set the environment variables from the `.env.example` file in the root of the project.
48
+
49
+ Tests can be run locally from the root of the project with:
50
+
51
+ `yarn test:e2e`
52
+
53
+ To run a specific test application
54
+
55
+ `yarn test:e2e [Remix | NextJS | SvelteKit]`
56
+
57
+ ## Writing Tests
58
+
59
+ Each test file should contain a single test suite that tests the Sentry Wizard for a specific framework. The test suite should contain a `beforeAll` and `afterAll` function that starts and stops the test application respectively.
@@ -0,0 +1,75 @@
1
+ # Nuxt Minimal Starter
2
+
3
+ Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
4
+
5
+ ## Setup
6
+
7
+ Make sure to install dependencies:
8
+
9
+ ```bash
10
+ # npm
11
+ npm install
12
+
13
+ # pnpm
14
+ pnpm install
15
+
16
+ # yarn
17
+ yarn install
18
+
19
+ # bun
20
+ bun install
21
+ ```
22
+
23
+ ## Development Server
24
+
25
+ Start the development server on `http://localhost:3000`:
26
+
27
+ ```bash
28
+ # npm
29
+ npm run dev
30
+
31
+ # pnpm
32
+ pnpm dev
33
+
34
+ # yarn
35
+ yarn dev
36
+
37
+ # bun
38
+ bun run dev
39
+ ```
40
+
41
+ ## Production
42
+
43
+ Build the application for production:
44
+
45
+ ```bash
46
+ # npm
47
+ npm run build
48
+
49
+ # pnpm
50
+ pnpm build
51
+
52
+ # yarn
53
+ yarn build
54
+
55
+ # bun
56
+ bun run build
57
+ ```
58
+
59
+ Locally preview production build:
60
+
61
+ ```bash
62
+ # npm
63
+ npm run preview
64
+
65
+ # pnpm
66
+ pnpm preview
67
+
68
+ # yarn
69
+ yarn preview
70
+
71
+ # bun
72
+ bun run preview
73
+ ```
74
+
75
+ Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
@@ -0,0 +1,5 @@
1
+ // https://nuxt.com/docs/api/configuration/nuxt-config
2
+ export default defineNuxtConfig({
3
+ compatibilityDate: '2024-11-01',
4
+ devtools: { enabled: true }
5
+ })
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "nuxt-app",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "build": "nuxt build",
7
+ "dev": "nuxt dev",
8
+ "generate": "nuxt generate",
9
+ "preview": "nuxt preview",
10
+ "postinstall": "nuxt prepare",
11
+ "start": "node .output/server/index.mjs"
12
+ },
13
+ "dependencies": {
14
+ "nuxt": "^3.14.1592",
15
+ "vue": "latest",
16
+ "vue-router": "latest"
17
+ }
18
+ }
@@ -0,0 +1,192 @@
1
+ import * as path from 'path';
2
+ import {
3
+ checkEnvBuildPlugin,
4
+ checkFileContents,
5
+ checkFileExists,
6
+ checkIfBuilds,
7
+ checkIfRunsOnProdMode,
8
+ checkPackageJson,
9
+ cleanupGit,
10
+ KEYS,
11
+ revertLocalChanges,
12
+ startWizardInstance,
13
+ TEST_ARGS,
14
+ } from '../utils';
15
+ import { Integration } from '../../lib/Constants';
16
+
17
+ describe('Nuxt-3', () => {
18
+ const projectDir = path.resolve(
19
+ __dirname,
20
+ '../test-applications/nuxt-3-test-app',
21
+ );
22
+
23
+ beforeAll(async () => {
24
+ await runWizardOnNuxtProject(projectDir);
25
+ });
26
+
27
+ afterAll(() => {
28
+ revertLocalChanges(projectDir);
29
+ cleanupGit(projectDir);
30
+ });
31
+
32
+ testNuxtProjectSetup(projectDir);
33
+
34
+ testNuxtProjectConfigs(projectDir);
35
+
36
+ testNuxtProjectBuildsAndRuns(projectDir);
37
+ });
38
+
39
+ async function runWizardOnNuxtProject(projectDir: string): Promise<void> {
40
+ const integration = Integration.nuxt;
41
+
42
+ const wizardInstance = startWizardInstance(integration, projectDir);
43
+ const packageManagerPrompted = await wizardInstance.waitForOutput(
44
+ 'Please select your package manager.',
45
+ );
46
+
47
+ const nitropackOverridePrompted =
48
+ packageManagerPrompted &&
49
+ (await wizardInstance.sendStdinAndWaitForOutput(
50
+ // Selecting `yarn` as the package manager
51
+ [KEYS.DOWN, KEYS.ENTER],
52
+ // Do you want to install version 2.9.7 of nitropack and add an override to package.json?
53
+ 'Do you want to add an override for nitropack version ~2.9.7?',
54
+ {
55
+ timeout: 240_000,
56
+ },
57
+ ));
58
+
59
+ const nftOverridePrompted =
60
+ nitropackOverridePrompted &&
61
+ (await wizardInstance.sendStdinAndWaitForOutput(
62
+ // Selecting `yes` to downgrade nitropack
63
+ KEYS.ENTER,
64
+ 'Do you want to add an override for @vercel/nft version ^0.27.4?',
65
+ // 'Do you want to install version',
66
+ {
67
+ timeout: 240_000,
68
+ },
69
+ ));
70
+
71
+ const tracingOptionPrompted =
72
+ nftOverridePrompted &&
73
+ (await wizardInstance.sendStdinAndWaitForOutput(
74
+ KEYS.ENTER,
75
+ // "Do you want to enable Tracing", sometimes doesn't work as `Tracing` can be printed in bold.
76
+ 'Do you want to enable',
77
+ {
78
+ timeout: 240_000,
79
+ },
80
+ ));
81
+
82
+ const replayOptionPrompted =
83
+ tracingOptionPrompted &&
84
+ (await wizardInstance.sendStdinAndWaitForOutput(
85
+ KEYS.ENTER,
86
+ // "Do you want to enable Sentry Session Replay", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.
87
+ 'to get a video-like reproduction of errors during a user session?',
88
+ ));
89
+
90
+ replayOptionPrompted &&
91
+ (await wizardInstance.sendStdinAndWaitForOutput(
92
+ [KEYS.ENTER],
93
+ 'Do you want to create an example page',
94
+ {
95
+ optional: true,
96
+ },
97
+ ));
98
+
99
+ await wizardInstance.sendStdinAndWaitForOutput(
100
+ [KEYS.ENTER, KEYS.ENTER],
101
+ 'Successfully installed the Sentry Nuxt SDK!',
102
+ );
103
+
104
+ wizardInstance.kill();
105
+ }
106
+
107
+ function testNuxtProjectSetup(projectDir: string) {
108
+ const integration = Integration.nuxt;
109
+
110
+ test('package.json is updated correctly', () => {
111
+ checkPackageJson(projectDir, integration);
112
+ });
113
+
114
+ test('.env-sentry-build-plugin is created and contains the auth token', () => {
115
+ checkEnvBuildPlugin(projectDir);
116
+ });
117
+
118
+ test('config files created', () => {
119
+ checkFileExists(`${projectDir}/sentry.server.config.ts`);
120
+ checkFileExists(`${projectDir}/sentry.client.config.ts`);
121
+ });
122
+
123
+ test('example page exists', () => {
124
+ checkFileExists(`${projectDir}/pages/sentry-example-page.vue`);
125
+ checkFileExists(`${projectDir}/server/api/sentry-example-api.ts`);
126
+ });
127
+ }
128
+
129
+ function testNuxtProjectConfigs(projectDir: string) {
130
+ test('nuxt config contains sentry module', () => {
131
+ checkFileContents(path.resolve(projectDir, 'nuxt.config.ts'), [
132
+ "modules: ['@sentry/nuxt/module'],",
133
+ 'sentry: {',
134
+ ' sourceMapsUploadOptions: {',
135
+ ` org: '${TEST_ARGS.ORG_SLUG}',`,
136
+ ` project: '${TEST_ARGS.PROJECT_SLUG}'`,
137
+ ' }',
138
+ '},',
139
+ 'sourcemap: {',
140
+ " client: 'hidden'",
141
+ '}',
142
+ ]);
143
+ });
144
+
145
+ test('sentry.client.config.ts contents', () => {
146
+ checkFileContents(path.resolve(projectDir, 'sentry.client.config.ts'), [
147
+ 'import * as Sentry from "@sentry/nuxt";',
148
+ 'Sentry.init({',
149
+ ' // If set up, you can use your runtime config here',
150
+ ' // dsn: useRuntimeConfig().public.sentry.dsn,',
151
+ ` dsn: "${TEST_ARGS.PROJECT_DSN}",`,
152
+ ' // We recommend adjusting this value in production, or using tracesSampler',
153
+ ' // for finer control',
154
+ ' tracesSampleRate: 1.0,',
155
+ ' // This sets the sample rate to be 10%. You may want this to be 100% while',
156
+ ' // in development and sample at a lower rate in production',
157
+ ' replaysSessionSampleRate: 0.1,',
158
+ ' // If the entire session is not sampled, use the below sample rate to sample',
159
+ ' // sessions when an error occurs.',
160
+ ' replaysOnErrorSampleRate: 1.0,',
161
+ " // If you don't want to use Session Replay, just remove the line below:",
162
+ ' integrations: [Sentry.replayIntegration()],',
163
+ " // Setting this option to true will print useful information to the console while you're setting up Sentry.",
164
+ ' debug: false,',
165
+ '});',
166
+ ]);
167
+ });
168
+
169
+ test('sentry.server.config.ts contents', () => {
170
+ checkFileContents(path.resolve(projectDir, 'sentry.server.config.ts'), [
171
+ 'import * as Sentry from "@sentry/nuxt";',
172
+ 'Sentry.init({',
173
+ ` dsn: "${TEST_ARGS.PROJECT_DSN}",`,
174
+ ' // We recommend adjusting this value in production, or using tracesSampler',
175
+ ' // for finer control',
176
+ ' tracesSampleRate: 1.0,',
177
+ " // Setting this option to true will print useful information to the console while you're setting up Sentry.",
178
+ ' debug: false,',
179
+ '});',
180
+ ]);
181
+ });
182
+ }
183
+
184
+ function testNuxtProjectBuildsAndRuns(projectDir: string) {
185
+ test('builds successfully', async () => {
186
+ await checkIfBuilds(projectDir, 'preview this build');
187
+ });
188
+
189
+ test('runs on prod mode correctly', async () => {
190
+ await checkIfRunsOnProdMode(projectDir, 'Listening on');
191
+ });
192
+ }
@@ -0,0 +1,191 @@
1
+ import * as path from 'path';
2
+ import { Integration } from '../../lib/Constants';
3
+ import { cleanupGit, revertLocalChanges } from '../utils';
4
+ import {
5
+ checkEnvBuildPlugin,
6
+ checkFileContents,
7
+ checkFileExists,
8
+ checkIfBuilds,
9
+ checkIfRunsOnProdMode,
10
+ checkPackageJson,
11
+ KEYS,
12
+ startWizardInstance,
13
+ TEST_ARGS,
14
+ } from '../utils';
15
+
16
+ describe('Nuxt-4', () => {
17
+ const projectDir = path.resolve(
18
+ __dirname,
19
+ '../test-applications/nuxt-4-test-app',
20
+ );
21
+
22
+ beforeAll(async () => {
23
+ await runWizardOnNuxtProject(projectDir);
24
+ });
25
+
26
+ afterAll(() => {
27
+ revertLocalChanges(projectDir);
28
+ cleanupGit(projectDir);
29
+ });
30
+
31
+ testNuxtProjectSetup(projectDir);
32
+
33
+ testNuxtProjectConfigs(projectDir);
34
+
35
+ testNuxtProjectBuildsAndRuns(projectDir);
36
+ });
37
+
38
+ async function runWizardOnNuxtProject(projectDir: string): Promise<void> {
39
+ const integration = Integration.nuxt;
40
+
41
+ const wizardInstance = startWizardInstance(integration, projectDir);
42
+ const packageManagerPrompted = await wizardInstance.waitForOutput(
43
+ 'Please select your package manager.',
44
+ );
45
+
46
+ const nitropackOverridePrompted =
47
+ packageManagerPrompted &&
48
+ (await wizardInstance.sendStdinAndWaitForOutput(
49
+ // Selecting `yarn` as the package manager
50
+ [KEYS.DOWN, KEYS.ENTER],
51
+ // Do you want to install version 2.9.7 of nitropack and add an override to package.json?
52
+ 'Do you want to add an override for nitropack version ~2.9.7?',
53
+ {
54
+ timeout: 240_000,
55
+ },
56
+ ));
57
+
58
+ const nftOverridePrompted =
59
+ nitropackOverridePrompted &&
60
+ (await wizardInstance.sendStdinAndWaitForOutput(
61
+ // Selecting `yes` to downgrade nitropack
62
+ KEYS.ENTER,
63
+ 'Do you want to add an override for @vercel/nft version ^0.27.4?',
64
+ // 'Do you want to install version',
65
+ {
66
+ timeout: 240_000,
67
+ },
68
+ ));
69
+
70
+ const tracingOptionPrompted =
71
+ nftOverridePrompted &&
72
+ (await wizardInstance.sendStdinAndWaitForOutput(
73
+ KEYS.ENTER,
74
+ // "Do you want to enable Tracing", sometimes doesn't work as `Tracing` can be printed in bold.
75
+ 'Do you want to enable',
76
+ {
77
+ timeout: 240_000,
78
+ },
79
+ ));
80
+
81
+ const replayOptionPrompted =
82
+ tracingOptionPrompted &&
83
+ (await wizardInstance.sendStdinAndWaitForOutput(
84
+ [KEYS.ENTER],
85
+ // "Do you want to enable Sentry Session Replay", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.
86
+ 'to get a video-like reproduction of errors during a user session?',
87
+ ));
88
+
89
+ replayOptionPrompted &&
90
+ (await wizardInstance.sendStdinAndWaitForOutput(
91
+ [KEYS.ENTER],
92
+ 'Do you want to create an example page',
93
+ {
94
+ optional: true,
95
+ },
96
+ ));
97
+
98
+ await wizardInstance.sendStdinAndWaitForOutput(
99
+ [KEYS.ENTER, KEYS.ENTER],
100
+ 'Successfully installed the Sentry Nuxt SDK!',
101
+ );
102
+
103
+ wizardInstance.kill();
104
+ }
105
+
106
+ function testNuxtProjectSetup(projectDir: string) {
107
+ const integration = Integration.nuxt;
108
+
109
+ test('package.json is updated correctly', () => {
110
+ checkPackageJson(projectDir, integration);
111
+ });
112
+
113
+ test('.env-sentry-build-plugin is created and contains the auth token', () => {
114
+ checkEnvBuildPlugin(projectDir);
115
+ });
116
+
117
+ test('config files created', () => {
118
+ checkFileExists(`${projectDir}/sentry.server.config.ts`);
119
+ checkFileExists(`${projectDir}/sentry.client.config.ts`);
120
+ });
121
+
122
+ test('example page exists', () => {
123
+ checkFileExists(`${projectDir}/app/pages/sentry-example-page.vue`);
124
+ checkFileExists(`${projectDir}/server/api/sentry-example-api.ts`);
125
+ });
126
+ }
127
+
128
+ function testNuxtProjectConfigs(projectDir: string) {
129
+ test('nuxt config contains sentry module', () => {
130
+ checkFileContents(path.resolve(projectDir, 'nuxt.config.ts'), [
131
+ "modules: ['@sentry/nuxt/module'],",
132
+ 'sentry: {',
133
+ ' sourceMapsUploadOptions: {',
134
+ ` org: '${TEST_ARGS.ORG_SLUG}',`,
135
+ ` project: '${TEST_ARGS.PROJECT_SLUG}'`,
136
+ ' }',
137
+ '},',
138
+ 'sourcemap: {',
139
+ " client: 'hidden'",
140
+ '}',
141
+ ]);
142
+ });
143
+
144
+ test('sentry.client.config.ts contents', () => {
145
+ checkFileContents(path.resolve(projectDir, 'sentry.client.config.ts'), [
146
+ 'import * as Sentry from "@sentry/nuxt";',
147
+ 'Sentry.init({',
148
+ ' // If set up, you can use your runtime config here',
149
+ ' // dsn: useRuntimeConfig().public.sentry.dsn,',
150
+ ` dsn: "${TEST_ARGS.PROJECT_DSN}",`,
151
+ ' // We recommend adjusting this value in production, or using tracesSampler',
152
+ ' // for finer control',
153
+ ' tracesSampleRate: 1.0,',
154
+ ' // This sets the sample rate to be 10%. You may want this to be 100% while',
155
+ ' // in development and sample at a lower rate in production',
156
+ ' replaysSessionSampleRate: 0.1,',
157
+ ' // If the entire session is not sampled, use the below sample rate to sample',
158
+ ' // sessions when an error occurs.',
159
+ ' replaysOnErrorSampleRate: 1.0,',
160
+ " // If you don't want to use Session Replay, just remove the line below:",
161
+ ' integrations: [Sentry.replayIntegration()],',
162
+ " // Setting this option to true will print useful information to the console while you're setting up Sentry.",
163
+ ' debug: false,',
164
+ '});',
165
+ ]);
166
+ });
167
+
168
+ test('sentry.server.config.ts contents', () => {
169
+ checkFileContents(path.resolve(projectDir, 'sentry.server.config.ts'), [
170
+ 'import * as Sentry from "@sentry/nuxt";',
171
+ 'Sentry.init({',
172
+ ` dsn: "${TEST_ARGS.PROJECT_DSN}",`,
173
+ ' // We recommend adjusting this value in production, or using tracesSampler',
174
+ ' // for finer control',
175
+ ' tracesSampleRate: 1.0,',
176
+ " // Setting this option to true will print useful information to the console while you're setting up Sentry.",
177
+ ' debug: false,',
178
+ '});',
179
+ ]);
180
+ });
181
+ }
182
+
183
+ function testNuxtProjectBuildsAndRuns(projectDir: string) {
184
+ test('builds successfully', async () => {
185
+ await checkIfBuilds(projectDir, 'preview this build');
186
+ });
187
+
188
+ test('runs on prod mode correctly', async () => {
189
+ await checkIfRunsOnProdMode(projectDir, 'Listening on');
190
+ });
191
+ }