@sentry/wizard 6.2.0 → 6.3.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 (68) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/e2e-tests/tests/angular-17.test.js +5 -0
  3. package/dist/e2e-tests/tests/angular-17.test.js.map +1 -1
  4. package/dist/e2e-tests/tests/angular-19.test.js +5 -0
  5. package/dist/e2e-tests/tests/angular-19.test.js.map +1 -1
  6. package/dist/e2e-tests/tests/expo.test.js +9 -2
  7. package/dist/e2e-tests/tests/expo.test.js.map +1 -1
  8. package/dist/e2e-tests/tests/flutter.test.js +18 -4
  9. package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
  10. package/dist/e2e-tests/tests/nextjs-14.test.js +4 -3
  11. package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
  12. package/dist/e2e-tests/tests/nextjs-15.test.js +17 -4
  13. package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
  14. package/dist/e2e-tests/tests/nuxt-3.test.js +9 -2
  15. package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
  16. package/dist/e2e-tests/tests/nuxt-4.test.js +9 -2
  17. package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
  18. package/dist/e2e-tests/tests/react-native.test.js +8 -1
  19. package/dist/e2e-tests/tests/react-native.test.js.map +1 -1
  20. package/dist/e2e-tests/tests/remix.test.js +16 -2
  21. package/dist/e2e-tests/tests/remix.test.js.map +1 -1
  22. package/dist/e2e-tests/tests/sveltekit.test.js +16 -2
  23. package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
  24. package/dist/src/android/android-wizard.js +3 -0
  25. package/dist/src/android/android-wizard.js.map +1 -1
  26. package/dist/src/angular/angular-wizard.js +3 -0
  27. package/dist/src/angular/angular-wizard.js.map +1 -1
  28. package/dist/src/apple/apple-wizard.js +3 -0
  29. package/dist/src/apple/apple-wizard.js.map +1 -1
  30. package/dist/src/flutter/flutter-wizard.js +3 -0
  31. package/dist/src/flutter/flutter-wizard.js.map +1 -1
  32. package/dist/src/nextjs/nextjs-wizard.js +3 -0
  33. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  34. package/dist/src/nuxt/nuxt-wizard.js +3 -0
  35. package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
  36. package/dist/src/react-native/react-native-wizard.js +3 -0
  37. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  38. package/dist/src/remix/remix-wizard.d.ts +4 -0
  39. package/dist/src/remix/remix-wizard.js +7 -0
  40. package/dist/src/remix/remix-wizard.js.map +1 -1
  41. package/dist/src/sveltekit/sveltekit-wizard.js +3 -0
  42. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  43. package/dist/src/utils/clack/mcp-config.d.ts +7 -0
  44. package/dist/src/utils/clack/mcp-config.js +427 -0
  45. package/dist/src/utils/clack/mcp-config.js.map +1 -0
  46. package/dist/src/version.d.ts +1 -1
  47. package/dist/src/version.js +1 -1
  48. package/dist/src/version.js.map +1 -1
  49. package/dist/test/angular/angular-wizard.test.js +3 -0
  50. package/dist/test/angular/angular-wizard.test.js.map +1 -1
  51. package/dist/test/apple/templates.test.js +3 -0
  52. package/dist/test/apple/templates.test.js.map +1 -1
  53. package/dist/test/flutter/templates.test.js +3 -0
  54. package/dist/test/flutter/templates.test.js.map +1 -1
  55. package/dist/test/nextjs/wizard-double-wrap-prevention.test.js +3 -0
  56. package/dist/test/nextjs/wizard-double-wrap-prevention.test.js.map +1 -1
  57. package/dist/test/nuxt/templates.test.js +3 -0
  58. package/dist/test/nuxt/templates.test.js.map +1 -1
  59. package/dist/test/react-native/metro.test.js +3 -0
  60. package/dist/test/react-native/metro.test.js.map +1 -1
  61. package/dist/test/remix/root.test.js +3 -0
  62. package/dist/test/remix/root.test.js.map +1 -1
  63. package/dist/test/sveltekit/templates.test.js +3 -0
  64. package/dist/test/sveltekit/templates.test.js.map +1 -1
  65. package/dist/test/utils/clack/mcp-config.test.d.ts +1 -0
  66. package/dist/test/utils/clack/mcp-config.test.js +520 -0
  67. package/dist/test/utils/clack/mcp-config.test.js.map +1 -0
  68. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"templates.test.js","sourceRoot":"","sources":["../../../test/flutter/templates.test.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAC9C,2DAIqC;AAErC,IAAA,iBAAQ,EAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,IAAA,iBAAQ,EAAC,SAAS,EAAE,GAAG,EAAE;QACvB,IAAA,WAAE,EAAC,wCAAwC,EAAE,GAAG,EAAE;YAChD,MAAM,QAAQ,GAAG,IAAA,0BAAc,EAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;YAClE,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC;;;;;;;aAOhC,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,IAAA,iBAAQ,EAAC,mBAAmB,EAAE,GAAG,EAAE;QACjC,IAAA,WAAE,EAAC,wCAAwC,EAAE,GAAG,EAAE;YAChD,MAAM,QAAQ,GAAG,IAAA,4BAAgB,EAAC,eAAe,CAAC,CAAC;YACnD,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC,4BAA4B,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,IAAA,iBAAQ,EAAC,MAAM,EAAE,GAAG,EAAE;QACpB,IAAA,WAAE,EAAC,mDAAmD,EAAE,GAAG,EAAE;YAC3D,MAAM,QAAQ,GAAG,IAAA,uBAAW,EAC1B,QAAQ,EACR;gBACE,OAAO,EAAE,IAAI;gBACb,SAAS,EAAE,IAAI;gBACf,MAAM,EAAE,IAAI;gBACZ,IAAI,EAAE,IAAI;aACX,EACD,eAAe,CAChB,CAAC;YACF,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAC,qBAAqB,CAA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from '../../src/flutter/templates';\n\ndescribe('Flutter code templates', () => {\n describe('pubspec', () => {\n it('generates pubspec with project and org', () => {\n const template = pubspecOptions('fixture-project', 'fixture-org');\n expect(template).toMatchInlineSnapshot(`\n \"sentry:\n upload_debug_symbols: true\n upload_source_maps: true\n project: fixture-project\n org: fixture-org\n \"\n `);\n });\n });\n describe('sentry.properties', () => {\n it('generates sentry.properties with token', () => {\n const template = sentryProperties('fixture-token');\n expect(template).toMatchInlineSnapshot(`\"auth_token=fixture-token\"`);\n });\n });\n describe('init', () => {\n it('generates Sentry config with all features enabled', () => {\n const template = initSnippet(\n 'my-dsn',\n {\n tracing: true,\n profiling: true,\n replay: true,\n logs: true,\n },\n 'const MyApp()',\n );\n expect(template).toMatchInlineSnapshot(`\n \"await SentryFlutter.init(\n (options) {\n options.dsn = 'my-dsn';\n // Adds request headers and IP for users, for more info visit:\n // https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/\n options.sendDefaultPii = true;\n options.enableLogs = true;\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0;\n // The sampling rate for profiling is relative to tracesSampleRate\n // Setting to 1.0 will profile 100% of sampled transactions:\n options.profilesSampleRate = 1.0;\n // Configure Session Replay\n options.replay.sessionSampleRate = 0.1;\n options.replay.onErrorSampleRate = 1.0;\n },\n appRunner: () => runApp(SentryWidget(child: const MyApp())),\n );\n // TODO: Remove this line after sending the first sample event to sentry.\n await Sentry.captureException(StateError('This is a sample exception.'));\"\n `);\n });\n\n it('generates Sentry config with profiling & replay disabled', () => {\n const template = initSnippet(\n 'my-dsn',\n {\n tracing: true,\n profiling: false,\n replay: false,\n logs: true,\n },\n 'const MyApp()',\n );\n expect(template).toMatchInlineSnapshot(`\n \"await SentryFlutter.init(\n (options) {\n options.dsn = 'my-dsn';\n // Adds request headers and IP for users, for more info visit:\n // https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/\n options.sendDefaultPii = true;\n options.enableLogs = true;\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0;\n },\n appRunner: () => runApp(SentryWidget(child: const MyApp())),\n );\n // TODO: Remove this line after sending the first sample event to sentry.\n await Sentry.captureException(StateError('This is a sample exception.'));\"\n `);\n });\n\n it('generates Sentry config with tracing, profiling, replay and logs disabled', () => {\n const template = initSnippet(\n 'my-dsn',\n {\n tracing: false,\n profiling: false,\n replay: false,\n logs: false,\n },\n 'const MyApp()',\n );\n expect(template).toMatchInlineSnapshot(`\n \"await SentryFlutter.init(\n (options) {\n options.dsn = 'my-dsn';\n // Adds request headers and IP for users, for more info visit:\n // https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/\n options.sendDefaultPii = true;\n },\n appRunner: () => runApp(SentryWidget(child: const MyApp())),\n );\n // TODO: Remove this line after sending the first sample event to sentry.\n await Sentry.captureException(StateError('This is a sample exception.'));\"\n `);\n });\n\n it('generates Sentry config with only structured logs enabled', () => {\n const template = initSnippet(\n 'my-dsn',\n {\n tracing: false,\n profiling: false,\n replay: false,\n logs: true,\n },\n 'const MyApp()',\n );\n expect(template).toMatchInlineSnapshot(`\n \"await SentryFlutter.init(\n (options) {\n options.dsn = 'my-dsn';\n // Adds request headers and IP for users, for more info visit:\n // https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/\n options.sendDefaultPii = true;\n options.enableLogs = true;\n },\n appRunner: () => runApp(SentryWidget(child: const MyApp())),\n );\n // TODO: Remove this line after sending the first sample event to sentry.\n await Sentry.captureException(StateError('This is a sample exception.'));\"\n `);\n });\n });\n});\n"]}
1
+ {"version":3,"file":"templates.test.js","sourceRoot":"","sources":["../../../test/flutter/templates.test.ts"],"names":[],"mappings":";;AAAA,mCAAkD;AAClD,2DAIqC;AAErC,WAAE,CAAC,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,CAAC;IACjD,2BAA2B,EAAE,WAA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1B,QAAQ,EACR;gBACE,OAAO,EAAE,IAAI;gBACb,SAAS,EAAE,KAAK;gBAChB,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,IAAI;aACX,EACD,eAAe,CAChB,CAAC;YACF,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;OAgBtC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAA,WAAE,EAAC,2EAA2E,EAAE,GAAG,EAAE;YACnF,MAAM,QAAQ,GAAG,IAAA,uBAAW,EAC1B,QAAQ,EACR;gBACE,OAAO,EAAE,KAAK;gBACd,SAAS,EAAE,KAAK;gBAChB,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,KAAK;aACZ,EACD,eAAe,CAChB,CAAC;YACF,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;OAYtC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,IAAA,WAAE,EAAC,2DAA2D,EAAE,GAAG,EAAE;YACnE,MAAM,QAAQ,GAAG,IAAA,uBAAW,EAC1B,QAAQ,EACR;gBACE,OAAO,EAAE,KAAK;gBACd,SAAS,EAAE,KAAK;gBAChB,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,IAAI;aACX,EACD,eAAe,CAChB,CAAC;YACF,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;OAatC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it, vi } from 'vitest';\nimport {\n pubspecOptions,\n sentryProperties,\n initSnippet,\n} from '../../src/flutter/templates';\n\nvi.mock('../../src/utils/clack/mcp-config', () => ({\n offerProjectScopedMcpConfig: vi.fn().mockResolvedValue(undefined),\n}));\n\ndescribe('Flutter code templates', () => {\n describe('pubspec', () => {\n it('generates pubspec with project and org', () => {\n const template = pubspecOptions('fixture-project', 'fixture-org');\n expect(template).toMatchInlineSnapshot(`\n \"sentry:\n upload_debug_symbols: true\n upload_source_maps: true\n project: fixture-project\n org: fixture-org\n \"\n `);\n });\n });\n describe('sentry.properties', () => {\n it('generates sentry.properties with token', () => {\n const template = sentryProperties('fixture-token');\n expect(template).toMatchInlineSnapshot(`\"auth_token=fixture-token\"`);\n });\n });\n describe('init', () => {\n it('generates Sentry config with all features enabled', () => {\n const template = initSnippet(\n 'my-dsn',\n {\n tracing: true,\n profiling: true,\n replay: true,\n logs: true,\n },\n 'const MyApp()',\n );\n expect(template).toMatchInlineSnapshot(`\n \"await SentryFlutter.init(\n (options) {\n options.dsn = 'my-dsn';\n // Adds request headers and IP for users, for more info visit:\n // https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/\n options.sendDefaultPii = true;\n options.enableLogs = true;\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0;\n // The sampling rate for profiling is relative to tracesSampleRate\n // Setting to 1.0 will profile 100% of sampled transactions:\n options.profilesSampleRate = 1.0;\n // Configure Session Replay\n options.replay.sessionSampleRate = 0.1;\n options.replay.onErrorSampleRate = 1.0;\n },\n appRunner: () => runApp(SentryWidget(child: const MyApp())),\n );\n // TODO: Remove this line after sending the first sample event to sentry.\n await Sentry.captureException(StateError('This is a sample exception.'));\"\n `);\n });\n\n it('generates Sentry config with profiling & replay disabled', () => {\n const template = initSnippet(\n 'my-dsn',\n {\n tracing: true,\n profiling: false,\n replay: false,\n logs: true,\n },\n 'const MyApp()',\n );\n expect(template).toMatchInlineSnapshot(`\n \"await SentryFlutter.init(\n (options) {\n options.dsn = 'my-dsn';\n // Adds request headers and IP for users, for more info visit:\n // https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/\n options.sendDefaultPii = true;\n options.enableLogs = true;\n // Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing.\n // We recommend adjusting this value in production.\n options.tracesSampleRate = 1.0;\n },\n appRunner: () => runApp(SentryWidget(child: const MyApp())),\n );\n // TODO: Remove this line after sending the first sample event to sentry.\n await Sentry.captureException(StateError('This is a sample exception.'));\"\n `);\n });\n\n it('generates Sentry config with tracing, profiling, replay and logs disabled', () => {\n const template = initSnippet(\n 'my-dsn',\n {\n tracing: false,\n profiling: false,\n replay: false,\n logs: false,\n },\n 'const MyApp()',\n );\n expect(template).toMatchInlineSnapshot(`\n \"await SentryFlutter.init(\n (options) {\n options.dsn = 'my-dsn';\n // Adds request headers and IP for users, for more info visit:\n // https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/\n options.sendDefaultPii = true;\n },\n appRunner: () => runApp(SentryWidget(child: const MyApp())),\n );\n // TODO: Remove this line after sending the first sample event to sentry.\n await Sentry.captureException(StateError('This is a sample exception.'));\"\n `);\n });\n\n it('generates Sentry config with only structured logs enabled', () => {\n const template = initSnippet(\n 'my-dsn',\n {\n tracing: false,\n profiling: false,\n replay: false,\n logs: true,\n },\n 'const MyApp()',\n );\n expect(template).toMatchInlineSnapshot(`\n \"await SentryFlutter.init(\n (options) {\n options.dsn = 'my-dsn';\n // Adds request headers and IP for users, for more info visit:\n // https://docs.sentry.io/platforms/dart/guides/flutter/data-management/data-collected/\n options.sendDefaultPii = true;\n options.enableLogs = true;\n },\n appRunner: () => runApp(SentryWidget(child: const MyApp())),\n );\n // TODO: Remove this line after sending the first sample event to sentry.\n await Sentry.captureException(StateError('This is a sample exception.'));\"\n `);\n });\n });\n});\n"]}
@@ -5,6 +5,9 @@ const vitest_1 = require("vitest");
5
5
  const magicast_1 = require("magicast");
6
6
  const templates_1 = require("../../src/nextjs/templates");
7
7
  const utils_1 = require("../../src/nextjs/utils");
8
+ vitest_1.vi.mock('../../src/utils/clack/mcp-config', () => ({
9
+ offerProjectScopedMcpConfig: vitest_1.vi.fn().mockResolvedValue(undefined),
10
+ }));
8
11
  (0, vitest_1.describe)('Next.js wizard double wrap prevention', () => {
9
12
  const mockWithSentryConfigOptionsTemplate = (0, templates_1.getWithSentryConfigOptionsTemplate)({
10
13
  orgSlug: 'test-org',
@@ -1 +1 @@
1
- {"version":3,"file":"wizard-double-wrap-prevention.test.js","sourceRoot":"","sources":["../../../test/nextjs/wizard-double-wrap-prevention.test.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAC9C,kFAAkF;AAClF,uCAAqD;AACrD,0DAAgF;AAChF,kDAGgC;AAEhC,IAAA,iBAAQ,EAAC,uCAAuC,EAAE,GAAG,EAAE;IACrD,MAAM,mCAAmC,GACvC,IAAA,8CAAkC,EAAC;QACjC,OAAO,EAAE,UAAU;QACnB,WAAW,EAAE,cAAc;QAC3B,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,mBAAmB;QAC9B,WAAW,EAAE,KAAK;KACnB,CAAC,CAAC;IAEL,IAAA,iBAAQ,EAAC,wCAAwC,EAAE,GAAG,EAAE;QACtD,IAAA,iBAAQ,EAAC,iCAAiC,EAAE,GAAG,EAAE;YAC/C,IAAA,WAAE,EAAC,qCAAqC,EAAE,GAAG,EAAE;gBAC7C,MAAM,GAAG,GAAG,IAAA,sBAAW,EAAC,2BAA2B,CAAC,CAAC;gBACrD,8GAA8G;gBAC9G,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC;gBAC7C,mEAAmE;gBACnE,MAAM,SAAS,GAAG,IAAA,6BAAqB,EAAC,WAAW,CAAC,CAAC;gBACrD,IAAA,eAAM,EAAC,SAAS,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBAEpC,mEAAmE;gBACnE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,IAAA,uBAAY,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;gBACtE,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC;YAClE,CAAC,CAAC,CAAC;YAEH,I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GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+B5B,CAAC","sourcesContent":["import { describe, it, expect } from 'vitest';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode, parseModule } from 'magicast';\nimport { getWithSentryConfigOptionsTemplate } from '../../src/nextjs/templates';\nimport {\n unwrapSentryConfigAst,\n wrapWithSentryConfig,\n} from '../../src/nextjs/utils';\n\ndescribe('Next.js wizard double wrap prevention', () => {\n const mockWithSentryConfigOptionsTemplate =\n getWithSentryConfigOptionsTemplate({\n orgSlug: 'test-org',\n projectSlug: 'test-project',\n selfHosted: false,\n sentryUrl: 'https://sentry.io',\n tunnelRoute: false,\n });\n\n describe('unwrapSentryConfigAst utility function', () => {\n describe('AST-based expression unwrapping', () => {\n it('keeps code without withSentryConfig', () => {\n const mod = parseModule('export default nextConfig');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const originalAST = mod.exports.default.$ast;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const resultAST = unwrapSentryConfigAst(originalAST);\n expect(resultAST).toBe(originalAST);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const { code: exportDefaultCode } = generateCode({ $ast: resultAST });\n expect(exportDefaultCode).toMatchInlineSnapshot(`\"nextConfig\"`);\n });\n\n it('should handle plain object literal exports', () => {\n const mod = parseModule(\n `export default { nextConfig: { randomValue: true } }`,\n );\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const originalAST = mod.exports.default.$ast;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const resultAST = unwrapSentryConfigAst(originalAST);\n\n expect(resultAST).toBe(originalAST);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(resultAST.type).toBe('ObjectExpression');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(resultAST.properties).toHaveLength(1);\n });\n\n it('should unwrap withSentryConfig with options', () => {\n const mod = parseModule(\n 'export default withSentryConfig(nextConfig, { org: \"test\" })',\n );\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const wrappedAst = mod.exports.default.$ast;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const resultAST = unwrapSentryConfigAst(wrappedAst);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const { code: exportDefaultCode } = generateCode({ $ast: resultAST });\n\n expect(exportDefaultCode).toMatchInlineSnapshot(`\"nextConfig\"`);\n });\n\n it('should unwrap withSentryConfig without options', () => {\n const mod = parseModule('export default withSentryConfig(nextConfig)');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const wrappedAst = mod.exports.default.$ast;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const resultAST = unwrapSentryConfigAst(wrappedAst);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const { code: exportDefaultCode } = generateCode({ $ast: resultAST });\n\n expect(exportDefaultCode).toMatchInlineSnapshot(`\"nextConfig\"`);\n });\n\n it('should handle nested withSentryConfig calls', () => {\n const mod = parseModule(\n 'export default withSentryConfig(withSentryConfig(nextConfig, { org: \"inner\" }), { org: \"outer\" })',\n );\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const wrappedAst = mod.exports.default.$ast;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const resultAST = unwrapSentryConfigAst(wrappedAst);\n\n // Should unwrap one level and return the inner withSentryConfig call\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(resultAST.type).toBe('CallExpression');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(resultAST.callee.name).toBe('withSentryConfig');\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const { code: exportDefaultCode } = generateCode({ $ast: resultAST });\n\n expect(exportDefaultCode).toMatchInlineSnapshot(\n `\"withSentryConfig(nextConfig, { org: \"inner\" })\"`,\n );\n });\n\n it('should handle complex expressions', () => {\n const mod = parseModule(\n 'export default withSentryConfig(someComplexExpression.withMethods())',\n );\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const wrappedAst = mod.exports.default.$ast;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const resultAST = unwrapSentryConfigAst(wrappedAst);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const { code: exportDefaultCode } = generateCode({ $ast: resultAST });\n\n expect(exportDefaultCode).toMatchInlineSnapshot(\n `\"someComplexExpression.withMethods()\"`,\n );\n });\n\n it('should handle object literals', () => {\n const mod = parseModule(\n 'export default withSentryConfig({ next: \"config\", obj: { next: \"nested\" } }, { org: \"test\" })',\n );\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const wrappedAst = mod.exports.default.$ast;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const resultAST = unwrapSentryConfigAst(wrappedAst);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const { code: exportDefaultCode } = generateCode({ $ast: resultAST });\n\n expect(exportDefaultCode).toMatchInlineSnapshot(\n `\"{ next: \"config\", obj: { next: \"nested\" } }\"`,\n );\n });\n\n it('should return unchanged if not a withSentryConfig call', () => {\n const mod = parseModule('export default someOtherFunction(nextConfig)');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const originalAST = mod.exports.default.$ast;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const resultAST = unwrapSentryConfigAst(originalAST);\n\n expect(resultAST).toBe(originalAST);\n });\n });\n });\n\n describe('MJS/TS files', () => {\n it('should unwrap existing withSentryConfig and re-wrap with new config using AST', () => {\n const existingMjsContent = `import { withSentryConfig } from \"@sentry/nextjs\";\n\nconst nextConfig = {};\n\nexport default withSentryConfig(nextConfig, {\n org: \"old-org\",\n project: \"old-project\",\n});`;\n\n const mod = parseModule(existingMjsContent);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const originalAST = mod.exports.default.$ast;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const unwrappedAst = unwrapSentryConfigAst(originalAST);\n // Verify it returns the first argument (nextConfig identifier)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(unwrappedAst.type).toBe('Identifier');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(unwrappedAst.name).toBe('nextConfig');\n\n // Create a fresh module to simulate the re-wrapping process\n const freshMod =\n parseModule(`import { withSentryConfig } from \"@sentry/nextjs\";\n\nconst nextConfig = {};\n\nexport default nextConfig;`);\n\n // Apply wrapping\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n freshMod.exports.default = wrapWithSentryConfig(\n freshMod.exports.default,\n mockWithSentryConfigOptionsTemplate,\n );\n\n const newCode = freshMod.generate().code;\n\n // Verify only one withSentryConfig call exists\n const withSentryConfigMatches = newCode.match(/withSentryConfig\\s*\\(/g);\n expect(withSentryConfigMatches).toHaveLength(1);\n\n expect(newCode).toContain('test-org');\n expect(newCode).toContain('test-project');\n expect(newCode).not.toContain('old-org');\n expect(newCode).not.toContain('old-project');\n });\n\n it('should handle complex nested configurations using AST', () => {\n const existingMjsContent = `import { withSentryConfig } from \"@sentry/nextjs\";\n\nconst nextConfig = { experimental: { appDir: true } };\n\nexport default withSentryConfig(\n withSentryConfig(nextConfig, { org: \"nested-org\" }),\n { org: \"outer-org\" }\n);`;\n\n const mod = parseModule(existingMjsContent);\n\n // First unwrap ----\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const firstUnwrapAST = unwrapSentryConfigAst(mod.exports.default.$ast);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(firstUnwrapAST.type).toBe('CallExpression');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(firstUnwrapAST.callee.name).toBe('withSentryConfig');\n\n const { code: exportDefaultCode1 } = generateCode({\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n $ast: firstUnwrapAST,\n });\n expect(exportDefaultCode1).toMatchInlineSnapshot(\n `\"withSentryConfig(nextConfig, { org: \"nested-org\" })\"`,\n );\n\n // Second unwrap ----\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const secondUnwrapAST = unwrapSentryConfigAst(firstUnwrapAST);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(secondUnwrapAST.type).toBe('Identifier');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(secondUnwrapAST.name).toBe('nextConfig');\n\n const { code: exportDefaultCode2 } = generateCode({\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n $ast: secondUnwrapAST,\n });\n\n expect(exportDefaultCode2).toMatchInlineSnapshot(`\"nextConfig\"`);\n });\n\n it('should handle simple export without existing withSentryConfig using AST', () => {\n const simpleMjsContent = `const nextConfig = {};\n\nexport default nextConfig;`;\n\n const mod = parseModule(simpleMjsContent);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const originalAST = mod.exports.default.$ast;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const unwrappedAst = unwrapSentryConfigAst(originalAST);\n expect(unwrappedAst).toBe(originalAST);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n mod.exports.default = wrapWithSentryConfig(\n mod.exports.default,\n mockWithSentryConfigOptionsTemplate,\n );\n\n const newCode = mod.generate().code;\n\n // Should have exactly one withSentryConfig call\n const withSentryConfigMatches = newCode.match(/withSentryConfig\\s*\\(/g);\n expect(withSentryConfigMatches).toHaveLength(1);\n\n expect(newCode).toMatchInlineSnapshot(`\n \"const nextConfig = {};\n\n export default withSentryConfig(nextConfig, ${sentryOptionsSnapshot});\"\n `);\n });\n\n it('should handle withSentryConfig(nextConfig) without options using AST', () => {\n const existingMjsContent = `import { withSentryConfig } from \"@sentry/nextjs\";\n\nconst nextConfig = {};\n\nexport default withSentryConfig(nextConfig);`;\n\n const mod = parseModule(existingMjsContent);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const originalAST = mod.exports.default.$ast;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const unwrappedAst = unwrapSentryConfigAst(originalAST);\n // Verify it returns the first argument (nextConfig identifier)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(unwrappedAst.type).toBe('Identifier');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(unwrappedAst.name).toBe('nextConfig');\n\n // Simulate the re-wrapping process\n const freshMod =\n parseModule(`import { withSentryConfig } from \"@sentry/nextjs\";\n\nconst nextConfig = {};\n\nexport default nextConfig;`);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n freshMod.exports.default = wrapWithSentryConfig(\n freshMod.exports.default,\n mockWithSentryConfigOptionsTemplate,\n );\n\n const newCode = freshMod.generate().code;\n\n // Should have exactly one withSentryConfig call\n const withSentryConfigMatches = newCode.match(/withSentryConfig\\s*\\(/g);\n expect(withSentryConfigMatches).toHaveLength(1);\n\n expect(newCode).not.toContain('withSentryConfig(withSentryConfig(');\n expect(newCode).toMatch(/withSentryConfig\\s*\\(\\s*nextConfig\\s*,/);\n });\n });\n});\n\nconst sentryOptionsSnapshot = `{\n // For all available options, see:\n // https://www.npmjs.com/package/@sentry/webpack-plugin#options\n\n org: \"test-org\",\n\n project: \"test-project\",\n\n // Only print logs for uploading source maps in CI\n silent: !process.env.CI,\n\n // For all available options, see:\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\n\n // Upload a larger set of source maps for prettier stack traces (increases build time)\n widenClientFileUpload: true,\n\n // Uncomment to route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.\n // This can increase your server load as well as your hosting bill.\n // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-\n // side errors will fail.\n // tunnelRoute: \"/monitoring\",\n\n // Automatically tree-shake Sentry logger statements to reduce bundle size\n disableLogger: true,\n\n // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)\n // See the following for more information:\n // https://docs.sentry.io/product/crons/\n // https://vercel.com/docs/cron-jobs\n automaticVercelMonitors: true\n}`;\n"]}
1
+ {"version":3,"file":"wizard-double-wrap-prevention.test.js","sourceRoot":"","sources":["../../../test/nextjs/wizard-double-wrap-prevention.test.ts"],"names":[],"mappings":";;AAAA,mCAAkD;AAClD,kFAAkF;AAClF,uCAAqD;AACrD,0DAAgF;AAChF,kDAGgC;AAEhC,WAAE,CAAC,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,CAAC;IACjD,2BAA2B,EAAE,WAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC;CAClE,CAAC,CAAC,CAAC;AAEJ,IAAA,iBAAQ,EAAC,uCAAuC,EAAE,GAAG,EAAE;IACrD,MAAM,mCAAmC,GACvC,IAAA,8CAAkC,EAAC;QACjC,OAAO,EAAE,UAAU;QACnB,WAAW,EAAE,cAAc;QAC3B,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,mBAAmB;QAC9B,WAAW,EAAE,KAAK;KACnB,CAAC,CAAC;IAEL,IAAA,iBAAQ,EAAC,wCAAwC,EAAE,GAAG,EAAE;QACtD,IAAA,iBAAQ,EAAC,iCAAiC,EAAE,GAAG,EAAE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nE,QAAQ,CAAC,OAAO,CAAC,OAAO,GAAG,IAAA,4BAAoB,EAC7C,QAAQ,CAAC,OAAO,CAAC,OAAO,EACxB,mCAAmC,CACpC,CAAC;YAEF,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC;YAEzC,gDAAgD;YAChD,MAAM,uBAAuB,GAAG,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;YACxE,IAAA,eAAM,EAAC,uBAAuB,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAEhD,IAAA,eAAM,EAAC,OAAO,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,oCAAoC,CAAC,CAAC;YACpE,IAAA,eAAM,EAAC,OAAO,CAAC,CAAC,OAAO,CAAC,wCAAwC,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+B5B,CAAC","sourcesContent":["import { describe, it, expect, vi } from 'vitest';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode, parseModule } from 'magicast';\nimport { getWithSentryConfigOptionsTemplate } from '../../src/nextjs/templates';\nimport {\n unwrapSentryConfigAst,\n wrapWithSentryConfig,\n} from '../../src/nextjs/utils';\n\nvi.mock('../../src/utils/clack/mcp-config', () => ({\n offerProjectScopedMcpConfig: vi.fn().mockResolvedValue(undefined),\n}));\n\ndescribe('Next.js wizard double wrap prevention', () => {\n const mockWithSentryConfigOptionsTemplate =\n getWithSentryConfigOptionsTemplate({\n orgSlug: 'test-org',\n projectSlug: 'test-project',\n selfHosted: false,\n sentryUrl: 'https://sentry.io',\n tunnelRoute: false,\n });\n\n describe('unwrapSentryConfigAst utility function', () => {\n describe('AST-based expression unwrapping', () => {\n it('keeps code without withSentryConfig', () => {\n const mod = parseModule('export default nextConfig');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const originalAST = mod.exports.default.$ast;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const resultAST = unwrapSentryConfigAst(originalAST);\n expect(resultAST).toBe(originalAST);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const { code: exportDefaultCode } = generateCode({ $ast: resultAST });\n expect(exportDefaultCode).toMatchInlineSnapshot(`\"nextConfig\"`);\n });\n\n it('should handle plain object literal exports', () => {\n const mod = parseModule(\n `export default { nextConfig: { randomValue: true } }`,\n );\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const originalAST = mod.exports.default.$ast;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const resultAST = unwrapSentryConfigAst(originalAST);\n\n expect(resultAST).toBe(originalAST);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(resultAST.type).toBe('ObjectExpression');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(resultAST.properties).toHaveLength(1);\n });\n\n it('should unwrap withSentryConfig with options', () => {\n const mod = parseModule(\n 'export default withSentryConfig(nextConfig, { org: \"test\" })',\n );\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const wrappedAst = mod.exports.default.$ast;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const resultAST = unwrapSentryConfigAst(wrappedAst);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const { code: exportDefaultCode } = generateCode({ $ast: resultAST });\n\n expect(exportDefaultCode).toMatchInlineSnapshot(`\"nextConfig\"`);\n });\n\n it('should unwrap withSentryConfig without options', () => {\n const mod = parseModule('export default withSentryConfig(nextConfig)');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const wrappedAst = mod.exports.default.$ast;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const resultAST = unwrapSentryConfigAst(wrappedAst);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const { code: exportDefaultCode } = generateCode({ $ast: resultAST });\n\n expect(exportDefaultCode).toMatchInlineSnapshot(`\"nextConfig\"`);\n });\n\n it('should handle nested withSentryConfig calls', () => {\n const mod = parseModule(\n 'export default withSentryConfig(withSentryConfig(nextConfig, { org: \"inner\" }), { org: \"outer\" })',\n );\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const wrappedAst = mod.exports.default.$ast;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const resultAST = unwrapSentryConfigAst(wrappedAst);\n\n // Should unwrap one level and return the inner withSentryConfig call\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(resultAST.type).toBe('CallExpression');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(resultAST.callee.name).toBe('withSentryConfig');\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const { code: exportDefaultCode } = generateCode({ $ast: resultAST });\n\n expect(exportDefaultCode).toMatchInlineSnapshot(\n `\"withSentryConfig(nextConfig, { org: \"inner\" })\"`,\n );\n });\n\n it('should handle complex expressions', () => {\n const mod = parseModule(\n 'export default withSentryConfig(someComplexExpression.withMethods())',\n );\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const wrappedAst = mod.exports.default.$ast;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const resultAST = unwrapSentryConfigAst(wrappedAst);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const { code: exportDefaultCode } = generateCode({ $ast: resultAST });\n\n expect(exportDefaultCode).toMatchInlineSnapshot(\n `\"someComplexExpression.withMethods()\"`,\n );\n });\n\n it('should handle object literals', () => {\n const mod = parseModule(\n 'export default withSentryConfig({ next: \"config\", obj: { next: \"nested\" } }, { org: \"test\" })',\n );\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const wrappedAst = mod.exports.default.$ast;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const resultAST = unwrapSentryConfigAst(wrappedAst);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const { code: exportDefaultCode } = generateCode({ $ast: resultAST });\n\n expect(exportDefaultCode).toMatchInlineSnapshot(\n `\"{ next: \"config\", obj: { next: \"nested\" } }\"`,\n );\n });\n\n it('should return unchanged if not a withSentryConfig call', () => {\n const mod = parseModule('export default someOtherFunction(nextConfig)');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const originalAST = mod.exports.default.$ast;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const resultAST = unwrapSentryConfigAst(originalAST);\n\n expect(resultAST).toBe(originalAST);\n });\n });\n });\n\n describe('MJS/TS files', () => {\n it('should unwrap existing withSentryConfig and re-wrap with new config using AST', () => {\n const existingMjsContent = `import { withSentryConfig } from \"@sentry/nextjs\";\n\nconst nextConfig = {};\n\nexport default withSentryConfig(nextConfig, {\n org: \"old-org\",\n project: \"old-project\",\n});`;\n\n const mod = parseModule(existingMjsContent);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const originalAST = mod.exports.default.$ast;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const unwrappedAst = unwrapSentryConfigAst(originalAST);\n // Verify it returns the first argument (nextConfig identifier)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(unwrappedAst.type).toBe('Identifier');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(unwrappedAst.name).toBe('nextConfig');\n\n // Create a fresh module to simulate the re-wrapping process\n const freshMod =\n parseModule(`import { withSentryConfig } from \"@sentry/nextjs\";\n\nconst nextConfig = {};\n\nexport default nextConfig;`);\n\n // Apply wrapping\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n freshMod.exports.default = wrapWithSentryConfig(\n freshMod.exports.default,\n mockWithSentryConfigOptionsTemplate,\n );\n\n const newCode = freshMod.generate().code;\n\n // Verify only one withSentryConfig call exists\n const withSentryConfigMatches = newCode.match(/withSentryConfig\\s*\\(/g);\n expect(withSentryConfigMatches).toHaveLength(1);\n\n expect(newCode).toContain('test-org');\n expect(newCode).toContain('test-project');\n expect(newCode).not.toContain('old-org');\n expect(newCode).not.toContain('old-project');\n });\n\n it('should handle complex nested configurations using AST', () => {\n const existingMjsContent = `import { withSentryConfig } from \"@sentry/nextjs\";\n\nconst nextConfig = { experimental: { appDir: true } };\n\nexport default withSentryConfig(\n withSentryConfig(nextConfig, { org: \"nested-org\" }),\n { org: \"outer-org\" }\n);`;\n\n const mod = parseModule(existingMjsContent);\n\n // First unwrap ----\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const firstUnwrapAST = unwrapSentryConfigAst(mod.exports.default.$ast);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(firstUnwrapAST.type).toBe('CallExpression');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(firstUnwrapAST.callee.name).toBe('withSentryConfig');\n\n const { code: exportDefaultCode1 } = generateCode({\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n $ast: firstUnwrapAST,\n });\n expect(exportDefaultCode1).toMatchInlineSnapshot(\n `\"withSentryConfig(nextConfig, { org: \"nested-org\" })\"`,\n );\n\n // Second unwrap ----\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const secondUnwrapAST = unwrapSentryConfigAst(firstUnwrapAST);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(secondUnwrapAST.type).toBe('Identifier');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(secondUnwrapAST.name).toBe('nextConfig');\n\n const { code: exportDefaultCode2 } = generateCode({\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n $ast: secondUnwrapAST,\n });\n\n expect(exportDefaultCode2).toMatchInlineSnapshot(`\"nextConfig\"`);\n });\n\n it('should handle simple export without existing withSentryConfig using AST', () => {\n const simpleMjsContent = `const nextConfig = {};\n\nexport default nextConfig;`;\n\n const mod = parseModule(simpleMjsContent);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const originalAST = mod.exports.default.$ast;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const unwrappedAst = unwrapSentryConfigAst(originalAST);\n expect(unwrappedAst).toBe(originalAST);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n mod.exports.default = wrapWithSentryConfig(\n mod.exports.default,\n mockWithSentryConfigOptionsTemplate,\n );\n\n const newCode = mod.generate().code;\n\n // Should have exactly one withSentryConfig call\n const withSentryConfigMatches = newCode.match(/withSentryConfig\\s*\\(/g);\n expect(withSentryConfigMatches).toHaveLength(1);\n\n expect(newCode).toMatchInlineSnapshot(`\n \"const nextConfig = {};\n\n export default withSentryConfig(nextConfig, ${sentryOptionsSnapshot});\"\n `);\n });\n\n it('should handle withSentryConfig(nextConfig) without options using AST', () => {\n const existingMjsContent = `import { withSentryConfig } from \"@sentry/nextjs\";\n\nconst nextConfig = {};\n\nexport default withSentryConfig(nextConfig);`;\n\n const mod = parseModule(existingMjsContent);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access\n const originalAST = mod.exports.default.$ast;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const unwrappedAst = unwrapSentryConfigAst(originalAST);\n // Verify it returns the first argument (nextConfig identifier)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(unwrappedAst.type).toBe('Identifier');\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n expect(unwrappedAst.name).toBe('nextConfig');\n\n // Simulate the re-wrapping process\n const freshMod =\n parseModule(`import { withSentryConfig } from \"@sentry/nextjs\";\n\nconst nextConfig = {};\n\nexport default nextConfig;`);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n freshMod.exports.default = wrapWithSentryConfig(\n freshMod.exports.default,\n mockWithSentryConfigOptionsTemplate,\n );\n\n const newCode = freshMod.generate().code;\n\n // Should have exactly one withSentryConfig call\n const withSentryConfigMatches = newCode.match(/withSentryConfig\\s*\\(/g);\n expect(withSentryConfigMatches).toHaveLength(1);\n\n expect(newCode).not.toContain('withSentryConfig(withSentryConfig(');\n expect(newCode).toMatch(/withSentryConfig\\s*\\(\\s*nextConfig\\s*,/);\n });\n });\n});\n\nconst sentryOptionsSnapshot = `{\n // For all available options, see:\n // https://www.npmjs.com/package/@sentry/webpack-plugin#options\n\n org: \"test-org\",\n\n project: \"test-project\",\n\n // Only print logs for uploading source maps in CI\n silent: !process.env.CI,\n\n // For all available options, see:\n // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/\n\n // Upload a larger set of source maps for prettier stack traces (increases build time)\n widenClientFileUpload: true,\n\n // Uncomment to route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.\n // This can increase your server load as well as your hosting bill.\n // Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-\n // side errors will fail.\n // tunnelRoute: \"/monitoring\",\n\n // Automatically tree-shake Sentry logger statements to reduce bundle size\n disableLogger: true,\n\n // Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)\n // See the following for more information:\n // https://docs.sentry.io/product/crons/\n // https://vercel.com/docs/cron-jobs\n automaticVercelMonitors: true\n}`;\n"]}
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const vitest_1 = require("vitest");
4
4
  const templates_1 = require("../../src/nuxt/templates");
5
+ vitest_1.vi.mock('../../src/utils/clack/mcp-config', () => ({
6
+ offerProjectScopedMcpConfig: vitest_1.vi.fn().mockResolvedValue(undefined),
7
+ }));
5
8
  (0, vitest_1.describe)('Nuxt code templates', () => {
6
9
  (0, vitest_1.describe)('getDefaultNuxtConfig', () => {
7
10
  (0, vitest_1.it)('returns a default nuxt config', () => {
@@ -1 +1 @@
1
- {"version":3,"file":"templates.test.js","sourceRoot":"","sources":["../../../test/nuxt/templates.test.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAC9C,wDAIkC;AAElC,IAAA,iBAAQ,EAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,IAAA,iBAAQ,EAAC,sBAAsB,EAAE,GAAG,EAAE;QACpC,IAAA,WAAE,EAAC,+BAA+B,EAAE,GAAG,EAAE;YACvC,IAAA,eAAM,EAAC,IAAA,gCAAoB,GAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;;;CAO1D,CAAC,CAAC;QACC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAA,iBAAQ,EAAC,yBAAyB,EAAE,GAAG,EAAE;QACvC,IAAA,iBAAQ,EAAC,eAAe,EAAE,GAAG,EAAE;YAC7B,IAAA,WAAE,EAAC,mDAAmD,EAAE,GAAG,EAAE;gBAC3D,MAAM,QAAQ,GAAG,IAAA,mCAAuB,EACtC,uBAAuB,EACvB,QAAQ,EACR;oBACE,WAAW,EAAE,IAAI;oBACjB,MAAM,EAAE,IAAI;oBACZ,IAAI,EAAE,IAAI;iBACX,CACF,CAAC;gBAEF,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BxC,CAAC,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,IAAA,WAAE,EAAC,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B,UAAU,EAAE,KAAK;aAClB,EACD,IAAI,CACL,CAAC;YAEF,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;OAUtC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it } from 'vitest';\nimport {\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 logs: 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 // Enable logs to be sent to Sentry\n enableLogs: true,\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 logs: 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 // Enable logs to be sent to Sentry\n enableLogs: true,\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 logs: 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 // Enable logs to be sent to Sentry\n enableLogs: true,\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 logs disabled', () => {\n const template = getSentryConfigContents(\n 'https://sentry.io/123',\n 'client',\n {\n performance: true,\n replay: true,\n logs: 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 // 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 and session replay disabled', () => {\n const template = getSentryConfigContents(\n 'https://sentry.io/123',\n 'client',\n {\n performance: false,\n replay: false,\n logs: 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 // Enable logs to be sent to Sentry\n enableLogs: true,\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 all features disabled', () => {\n const template = getSentryConfigContents(\n 'https://sentry.io/123',\n 'client',\n {\n performance: false,\n replay: false,\n logs: 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 logs: 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 // Enable logs to be sent to Sentry\n enableLogs: true,\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 logs: 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 // Enable logs to be sent to Sentry\n enableLogs: true,\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 logs disabled', () => {\n const template = getSentryConfigContents(\n 'https://sentry.io/123',\n 'server',\n {\n performance: true,\n replay: true,\n logs: false,\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 all features disabled', () => {\n const template = getSentryConfigContents(\n 'https://sentry.io/123',\n 'server',\n {\n performance: false,\n replay: false,\n logs: false,\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 {\n org: 'my-org',\n project: 'my-project',\n url: 'https://sentry.io',\n selfHosted: false,\n },\n 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 it('generates configuration options for the nuxt config with top level import', () => {\n const template = getNuxtModuleFallbackTemplate(\n {\n org: 'my-org',\n project: 'my-project',\n url: 'https://sentry.io',\n selfHosted: false,\n },\n true,\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 autoInjectServerSentry: \"top-level-import\",\n },\n sourcemap: { client: \"hidden\" },\"\n `);\n });\n });\n});\n"]}
1
+ {"version":3,"file":"templates.test.js","sourceRoot":"","sources":["../../../test/nuxt/templates.test.ts"],"names":[],"mappings":";;AAAA,mCAAkD;AAClD,wDAIkC;AAElC,WAAE,CAAC,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,CAAC;IACjD,2BAA2B,EAAE,WAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC;CAClE,CAAC,CAAC,CAAC;AAEJ,IAAA,iBAAQ,EAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,IAAA,iBAAQ,EAAC,sBAAsB,EAAE,GAAG,EAAE;QACpC,IAAA,WAAE,EAAC,+BAA+B,EAAE,GAAG,EAAE;YACvC,IAAA,eAAM,EAAC,IAAA,gCAAoB,GAAE,CAAC,CAAC,qBAAqB,CAAC;;;;;;;CAO1D,CAAC,CAAC;QACC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAA,iBAAQ,EAAC,yBAAyB,EAAE,GAAG,EAAE;QACvC,IAAA,iBAAQ,EAAC,eAAe,EAAE,GAAG,EAAE;YAC7B,IAAA,WAAE,EAAC,mDAAmD,EAAE,GAAG,EAAE;gBAC3D,MAAM,QAAQ,GAAG,IAAA,mCAAuB,EACtC,uBAAuB,EACvB,QAAQ,EACR;oBACE,WAAW,EAAE,IAAI;oBACjB,MAAM,EAAE,IAAI;oBACZ,IAAI,EA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C,CAAC;QAEH,IAAA,WAAE,EAAC,2EAA2E,EAAE,GAAG,EAAE;YACnF,MAAM,QAAQ,GAAG,IAAA,yCAA6B,EAC5C;gBACE,GAAG,EAAE,QAAQ;gBACb,OAAO,EAAE,YAAY;gBACrB,GAAG,EAAE,mBAAmB;gBACxB,UAAU,EAAE,KAAK;aAClB,EACD,IAAI,CACL,CAAC;YAEF,IAAA,eAAM,EAAC,QAAQ,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;OAUtC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it, vi } from 'vitest';\nimport {\n getDefaultNuxtConfig,\n getNuxtModuleFallbackTemplate,\n getSentryConfigContents,\n} from '../../src/nuxt/templates';\n\nvi.mock('../../src/utils/clack/mcp-config', () => ({\n offerProjectScopedMcpConfig: vi.fn().mockResolvedValue(undefined),\n}));\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 logs: 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 // Enable logs to be sent to Sentry\n enableLogs: true,\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 logs: 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 // Enable logs to be sent to Sentry\n enableLogs: true,\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 logs: 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 // Enable logs to be sent to Sentry\n enableLogs: true,\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 logs disabled', () => {\n const template = getSentryConfigContents(\n 'https://sentry.io/123',\n 'client',\n {\n performance: true,\n replay: true,\n logs: 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 // 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 and session replay disabled', () => {\n const template = getSentryConfigContents(\n 'https://sentry.io/123',\n 'client',\n {\n performance: false,\n replay: false,\n logs: 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 // Enable logs to be sent to Sentry\n enableLogs: true,\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 all features disabled', () => {\n const template = getSentryConfigContents(\n 'https://sentry.io/123',\n 'client',\n {\n performance: false,\n replay: false,\n logs: 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 logs: 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 // Enable logs to be sent to Sentry\n enableLogs: true,\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 logs: 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 // Enable logs to be sent to Sentry\n enableLogs: true,\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 logs disabled', () => {\n const template = getSentryConfigContents(\n 'https://sentry.io/123',\n 'server',\n {\n performance: true,\n replay: true,\n logs: false,\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 all features disabled', () => {\n const template = getSentryConfigContents(\n 'https://sentry.io/123',\n 'server',\n {\n performance: false,\n replay: false,\n logs: false,\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 {\n org: 'my-org',\n project: 'my-project',\n url: 'https://sentry.io',\n selfHosted: false,\n },\n 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 it('generates configuration options for the nuxt config with top level import', () => {\n const template = getNuxtModuleFallbackTemplate(\n {\n org: 'my-org',\n project: 'my-project',\n url: 'https://sentry.io',\n selfHosted: false,\n },\n true,\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 autoInjectServerSentry: \"top-level-import\",\n },\n sourcemap: { client: \"hidden\" },\"\n `);\n });\n });\n});\n"]}
@@ -28,6 +28,9 @@ const magicast_1 = require("magicast");
28
28
  const metro_1 = require("../../src/react-native/metro");
29
29
  const vitest_1 = require("vitest");
30
30
  const fs = __importStar(require("fs"));
31
+ vitest_1.vi.mock('../../src/utils/clack/mcp-config', () => ({
32
+ offerProjectScopedMcpConfig: vitest_1.vi.fn().mockResolvedValue(undefined),
33
+ }));
31
34
  vitest_1.vi.mock('fs', async () => {
32
35
  const actual = await vitest_1.vi.importActual('fs');
33
36
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"metro.test.js","sourceRoot":"","sources":["../../../test/react-native/metro.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kFAAkF;AAClF,uCAA2E;AAM3E,wDAMsC;AACtC,mCAA8D;AAC9D,uCAAyB;AAEzB,WAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,IAAI,EAAE;IACvB,MAAM,MAAM,GAAG,MAAM,WAAE,CAAC,YAA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AAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,SAAS,sBAAsB,CAC7B,GAAoB,EACpB,KAAK,GAAG,CAAC;IAET,OACI,GAAG,CAAC,IAAkB,CAAC,IAAI,CAAC,KAAK,CAA2B;SAC3D,UACJ,CAAC,KAA2B,CAAC;AAChC,CAAC","sourcesContent":["// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode, type ProxifiedModule, parseModule } from 'magicast';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nimport {\n addSentrySerializerRequireToMetroConfig,\n addSentrySerializerToMetroConfig,\n findMetroConfigPath,\n getMetroConfigObject,\n patchMetroWithSentryConfigInMemory,\n} from '../../src/react-native/metro';\nimport { beforeEach, describe, expect, it, vi } from 'vitest';\nimport * as fs from 'fs';\n\nvi.mock('fs', async () => {\n const actual = await vi.importActual('fs');\n return {\n ...actual,\n existsSync: vi.fn(),\n };\n});\n\ndescribe('patch metro config - sentry serializer', () => {\n describe('patchMetroWithSentryConfigInMemory', () => {\n it('patches react native 0.72 default metro config', async () => {\n const mod =\n parseModule(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\n\n/**\n * Metro configuration\n * https://reactnative.dev/docs/metro\n *\n * @type {import('metro-config').MetroConfig}\n */\nconst config = {};\n\nmodule.exports = mergeConfig(getDefaultConfig(__dirname), config);`);\n\n const result = await patchMetroWithSentryConfigInMemory(\n mod,\n 'metro.config.js',\n true,\n );\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code)\n .toBe(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\n\nconst {\n withSentryConfig\n} = require(\"@sentry/react-native/metro\");\n\n/**\n * Metro configuration\n * https://reactnative.dev/docs/metro\n *\n * @type {import('metro-config').MetroConfig}\n */\nconst config = {};\n\nmodule.exports = withSentryConfig(mergeConfig(getDefaultConfig(__dirname), config));`);\n });\n\n it('patches react native 0.65 default metro config', async () => {\n const mod = parseModule(`/**\n* Metro configuration for React Native\n* https://github.com/facebook/react-native\n*\n* @format\n*/\n\nmodule.exports = {\n transformer: {\n getTransformOptions: async () => ({\n transform: {\n experimentalImportSupport: false,\n inlineRequires: true,\n },\n }),\n },\n};`);\n\n const result = await patchMetroWithSentryConfigInMemory(\n mod,\n 'metro.config.js',\n true,\n );\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`const {\n withSentryConfig\n} = require(\"@sentry/react-native/metro\");\n\n/**\n* Metro configuration for React Native\n* https://github.com/facebook/react-native\n*\n* @format\n*/\n\nmodule.exports = withSentryConfig({\n transformer: {\n getTransformOptions: async () => ({\n transform: {\n experimentalImportSupport: false,\n inlineRequires: true,\n },\n }),\n },\n});`);\n });\n\n it('patches react native metro config exported variable', async () => {\n const mod = parseModule(`const testConfig = {};\n\nmodule.exports = testConfig;`);\n\n const result = await patchMetroWithSentryConfigInMemory(\n mod,\n 'metro.config.js',\n true,\n );\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`const {\n withSentryConfig\n} = require(\"@sentry/react-native/metro\");\n\nconst testConfig = {};\n\nmodule.exports = withSentryConfig(testConfig);`);\n });\n\n it('patches custom react native metro config', async () => {\n const mod =\n parseModule(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\n\nconst defaultConfig = getDefaultConfig(__dirname);\nconst {assetExts, sourceExts} = defaultConfig.resolver;\n/**\n * Metro configuration\n * https://facebook.github.io/metro/docs/configuration\n *\n * @type {import('metro-config').MetroConfig}\n */\n\nconst jsoMetroPlugin = require('obfuscator-io-metro-plugin')(\n {\n // for these option look javascript-obfuscator library options from above url\n compact: false,\n sourceMap: false,\n controlFlowFlattening: true,\n controlFlowFlatteningThreshold: 1,\n numbersToExpressions: true,\n simplify: true,\n stringArrayShuffle: true,\n splitStrings: true,\n stringArrayThreshold: 1,\n },\n {\n runInDev: false /* optional */,\n logObfuscatedFiles: true /* optional generated files will be located at ./.jso */,\n // source Map generated after obfuscation is not useful right now\n sourceMapLocation:\n './index.android.bundle.map' /* optional only works if sourceMap: true in obfuscation option */,\n },\n);\n\nconst config = {\n transformer: {\n babelTransformerPath: require.resolve('react-native-svg-transformer'),\n getTransformOptions: async () => ({\n transform: {\n experimentalImportSupport: false,\n inlineRequires: true,\n },\n }),\n },\n resolver: {\n assetExts: assetExts.filter(ext => ext !== 'svg'),\n sourceExts: [...sourceExts, 'svg'],\n },\n ...jsoMetroPlugin,\n};\n\nmodule.exports = mergeConfig(getDefaultConfig(__dirname), config);`);\n\n const result = await patchMetroWithSentryConfigInMemory(\n mod,\n 'metro.config.js',\n true,\n );\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code)\n .toBe(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\n\nconst {\n withSentryConfig\n} = require(\"@sentry/react-native/metro\");\n\nconst defaultConfig = getDefaultConfig(__dirname);\nconst {assetExts, sourceExts} = defaultConfig.resolver;\n/**\n * Metro configuration\n * https://facebook.github.io/metro/docs/configuration\n *\n * @type {import('metro-config').MetroConfig}\n */\n\nconst jsoMetroPlugin = require('obfuscator-io-metro-plugin')(\n {\n // for these option look javascript-obfuscator library options from above url\n compact: false,\n sourceMap: false,\n controlFlowFlattening: true,\n controlFlowFlatteningThreshold: 1,\n numbersToExpressions: true,\n simplify: true,\n stringArrayShuffle: true,\n splitStrings: true,\n stringArrayThreshold: 1,\n },\n {\n runInDev: false /* optional */,\n logObfuscatedFiles: true /* optional generated files will be located at ./.jso */,\n // source Map generated after obfuscation is not useful right now\n sourceMapLocation:\n './index.android.bundle.map' /* optional only works if sourceMap: true in obfuscation option */,\n },\n);\n\nconst config = {\n transformer: {\n babelTransformerPath: require.resolve('react-native-svg-transformer'),\n getTransformOptions: async () => ({\n transform: {\n experimentalImportSupport: false,\n inlineRequires: true,\n },\n }),\n },\n resolver: {\n assetExts: assetExts.filter(ext => ext !== 'svg'),\n sourceExts: [...sourceExts, 'svg'],\n },\n ...jsoMetroPlugin,\n};\n\nmodule.exports = withSentryConfig(mergeConfig(getDefaultConfig(__dirname), config));`);\n });\n\n it('patches CJS style metro config', async () => {\n const mod =\n parseModule(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\n\nconst config = {};\n\nmodule.exports = mergeConfig(getDefaultConfig(__dirname), config);`);\n\n const result = await patchMetroWithSentryConfigInMemory(\n mod,\n 'metro.config.cjs',\n true,\n );\n expect(result).toBe(true);\n\n const code = generateCode(mod.$ast).code;\n expect(code).toContain('require(\"@sentry/react-native/metro\")');\n expect(code).toContain('withSentryConfig');\n });\n\n it('does not patch react native metro config exported as factory function', async () => {\n const mod = parseModule(`module.exports = () => ({});`);\n\n const result = await patchMetroWithSentryConfigInMemory(\n mod,\n 'metro.config.js',\n true,\n );\n expect(result).toBe(false);\n expect(generateCode(mod.$ast).code).toBe(`module.exports = () => ({});`);\n });\n });\n\n describe('addSentrySerializerToMetroConfig', () => {\n it('add to empty config', () => {\n const mod = parseModule(`module.exports = {\n other: 'config'\n }`);\n const configObject = getModuleExportsObject(mod);\n const result = addSentrySerializerToMetroConfig(configObject);\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`module.exports = {\n other: 'config',\n\n serializer: {\n customSerializer: createSentryMetroSerializer()\n }\n}`);\n });\n\n it('add to existing serializer config', () => {\n const mod = parseModule(`module.exports = {\n other: 'config',\n serializer: {\n other: 'config'\n }\n}`);\n const configObject = getModuleExportsObject(mod);\n const result = addSentrySerializerToMetroConfig(configObject);\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`module.exports = {\n other: 'config',\n serializer: {\n other: 'config',\n customSerializer: createSentryMetroSerializer()\n }\n}`);\n });\n\n it('not add to existing customSerializer config', () => {\n const mod = parseModule(`module.exports = {\n other: 'config',\n serializer: {\n other: 'config',\n customSerializer: 'existing-serializer'\n }\n}`);\n const configObject = getModuleExportsObject(mod);\n const result = addSentrySerializerToMetroConfig(configObject);\n expect(result).toBe(false);\n expect(generateCode(mod.$ast).code).toBe(`module.exports = {\n other: 'config',\n serializer: {\n other: 'config',\n customSerializer: 'existing-serializer'\n }\n}`);\n });\n });\n\n describe('addSentrySerializerImportToMetroConfig', () => {\n it('add import', () => {\n const mod =\n parseModule(`const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');\n\nmodule.exports = {\n other: 'config'\n}`);\n const result = addSentrySerializerRequireToMetroConfig(\n mod.$ast as t.Program,\n );\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code)\n .toBe(`const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');\n\nconst {\n createSentryMetroSerializer\n} = require(\"@sentry/react-native/dist/js/tools/sentryMetroSerializer\");\n\nmodule.exports = {\n other: 'config'\n}`);\n });\n });\n\n describe('getMetroConfigObject', () => {\n it('get config object from variable called config', () => {\n const mod = parseModule(`var config = { some: 'config' };`);\n const configObject = getMetroConfigObject(mod.$ast as t.Program);\n expect(\n ((configObject?.properties[0] as t.ObjectProperty).key as t.Identifier)\n .name,\n ).toBe('some');\n expect(\n (\n (configObject?.properties[0] as t.ObjectProperty)\n .value as t.StringLiteral\n ).value,\n ).toBe('config');\n });\n\n it('get config object from const called config', () => {\n const mod = parseModule(`const config = { some: 'config' };`);\n const configObject = getMetroConfigObject(mod.$ast as t.Program);\n expect(\n ((configObject?.properties[0] as t.ObjectProperty).key as t.Identifier)\n .name,\n ).toBe('some');\n expect(\n (\n (configObject?.properties[0] as t.ObjectProperty)\n .value as t.StringLiteral\n ).value,\n ).toBe('config');\n });\n\n it('get config oject from let called config', () => {\n const mod = parseModule(`let config = { some: 'config' };`);\n const configObject = getMetroConfigObject(mod.$ast as t.Program);\n expect(\n ((configObject?.properties[0] as t.ObjectProperty).key as t.Identifier)\n .name,\n ).toBe('some');\n expect(\n (\n (configObject?.properties[0] as t.ObjectProperty)\n .value as t.StringLiteral\n ).value,\n ).toBe('config');\n });\n\n it('get config object from module.exports', () => {\n const mod = parseModule(`module.exports = { some: 'config' };`);\n const configObject = getMetroConfigObject(mod.$ast as t.Program);\n expect(\n ((configObject?.properties[0] as t.ObjectProperty).key as t.Identifier)\n .name,\n ).toBe('some');\n expect(\n (\n (configObject?.properties[0] as t.ObjectProperty)\n .value as t.StringLiteral\n ).value,\n ).toBe('config');\n });\n });\n});\n\ndescribe('Dynamic Metro Config path', () => {\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n it('finds metro.config.js when it exists', () => {\n vi.mocked(fs.existsSync).mockImplementation(\n (path: string) => path === 'metro.config.js',\n );\n\n const result = findMetroConfigPath();\n expect(result).toBe('metro.config.js');\n });\n\n it('finds metro.config.cjs when it exists', () => {\n vi.mocked(fs.existsSync).mockImplementation(\n (path: string) => path === 'metro.config.cjs',\n );\n\n const result = findMetroConfigPath();\n expect(result).toBe('metro.config.cjs');\n });\n\n it('prefers metro.config.js over metro.config.cjs when both exist', () => {\n vi.mocked(fs.existsSync).mockImplementation(() => true);\n\n const result = findMetroConfigPath();\n expect(result).toBe('metro.config.js');\n });\n\n it('returns undefined when no metro config exists', () => {\n vi.mocked(fs.existsSync).mockImplementation(() => false);\n\n const result = findMetroConfigPath();\n expect(result).toBeUndefined();\n });\n});\n\nfunction getModuleExportsObject(\n mod: ProxifiedModule,\n index = 0,\n): t.ObjectExpression {\n return (\n ((mod.$ast as t.Program).body[index] as t.ExpressionStatement)\n .expression as t.AssignmentExpression\n ).right as t.ObjectExpression;\n}\n"]}
1
+ {"version":3,"file":"metro.test.js","sourceRoot":"","sources":["../../../test/react-native/metro.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kFAAkF;AAClF,uCAA2E;AAM3E,wDAMsC;AACtC,mCAA8D;AAC9D,uCAAyB;AAEzB,WAAE,CAAC,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,CAAC;IACjD,2BAA2B,EAAE,WAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC;CAClE,CAAC,CAAC,CAAC;AAEJ,WAAE,CAAC,IAA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G,IAAA,2BAAmB,GAAE,CAAC;QACrC,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,aAAa,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,SAAS,sBAAsB,CAC7B,GAAoB,EACpB,KAAK,GAAG,CAAC;IAET,OACI,GAAG,CAAC,IAAkB,CAAC,IAAI,CAAC,KAAK,CAA2B;SAC3D,UACJ,CAAC,KAA2B,CAAC;AAChC,CAAC","sourcesContent":["// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode, type ProxifiedModule, parseModule } from 'magicast';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nimport {\n addSentrySerializerRequireToMetroConfig,\n addSentrySerializerToMetroConfig,\n findMetroConfigPath,\n getMetroConfigObject,\n patchMetroWithSentryConfigInMemory,\n} from '../../src/react-native/metro';\nimport { beforeEach, describe, expect, it, vi } from 'vitest';\nimport * as fs from 'fs';\n\nvi.mock('../../src/utils/clack/mcp-config', () => ({\n offerProjectScopedMcpConfig: vi.fn().mockResolvedValue(undefined),\n}));\n\nvi.mock('fs', async () => {\n const actual = await vi.importActual('fs');\n return {\n ...actual,\n existsSync: vi.fn(),\n };\n});\n\ndescribe('patch metro config - sentry serializer', () => {\n describe('patchMetroWithSentryConfigInMemory', () => {\n it('patches react native 0.72 default metro config', async () => {\n const mod =\n parseModule(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\n\n/**\n * Metro configuration\n * https://reactnative.dev/docs/metro\n *\n * @type {import('metro-config').MetroConfig}\n */\nconst config = {};\n\nmodule.exports = mergeConfig(getDefaultConfig(__dirname), config);`);\n\n const result = await patchMetroWithSentryConfigInMemory(\n mod,\n 'metro.config.js',\n true,\n );\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code)\n .toBe(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\n\nconst {\n withSentryConfig\n} = require(\"@sentry/react-native/metro\");\n\n/**\n * Metro configuration\n * https://reactnative.dev/docs/metro\n *\n * @type {import('metro-config').MetroConfig}\n */\nconst config = {};\n\nmodule.exports = withSentryConfig(mergeConfig(getDefaultConfig(__dirname), config));`);\n });\n\n it('patches react native 0.65 default metro config', async () => {\n const mod = parseModule(`/**\n* Metro configuration for React Native\n* https://github.com/facebook/react-native\n*\n* @format\n*/\n\nmodule.exports = {\n transformer: {\n getTransformOptions: async () => ({\n transform: {\n experimentalImportSupport: false,\n inlineRequires: true,\n },\n }),\n },\n};`);\n\n const result = await patchMetroWithSentryConfigInMemory(\n mod,\n 'metro.config.js',\n true,\n );\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`const {\n withSentryConfig\n} = require(\"@sentry/react-native/metro\");\n\n/**\n* Metro configuration for React Native\n* https://github.com/facebook/react-native\n*\n* @format\n*/\n\nmodule.exports = withSentryConfig({\n transformer: {\n getTransformOptions: async () => ({\n transform: {\n experimentalImportSupport: false,\n inlineRequires: true,\n },\n }),\n },\n});`);\n });\n\n it('patches react native metro config exported variable', async () => {\n const mod = parseModule(`const testConfig = {};\n\nmodule.exports = testConfig;`);\n\n const result = await patchMetroWithSentryConfigInMemory(\n mod,\n 'metro.config.js',\n true,\n );\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`const {\n withSentryConfig\n} = require(\"@sentry/react-native/metro\");\n\nconst testConfig = {};\n\nmodule.exports = withSentryConfig(testConfig);`);\n });\n\n it('patches custom react native metro config', async () => {\n const mod =\n parseModule(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\n\nconst defaultConfig = getDefaultConfig(__dirname);\nconst {assetExts, sourceExts} = defaultConfig.resolver;\n/**\n * Metro configuration\n * https://facebook.github.io/metro/docs/configuration\n *\n * @type {import('metro-config').MetroConfig}\n */\n\nconst jsoMetroPlugin = require('obfuscator-io-metro-plugin')(\n {\n // for these option look javascript-obfuscator library options from above url\n compact: false,\n sourceMap: false,\n controlFlowFlattening: true,\n controlFlowFlatteningThreshold: 1,\n numbersToExpressions: true,\n simplify: true,\n stringArrayShuffle: true,\n splitStrings: true,\n stringArrayThreshold: 1,\n },\n {\n runInDev: false /* optional */,\n logObfuscatedFiles: true /* optional generated files will be located at ./.jso */,\n // source Map generated after obfuscation is not useful right now\n sourceMapLocation:\n './index.android.bundle.map' /* optional only works if sourceMap: true in obfuscation option */,\n },\n);\n\nconst config = {\n transformer: {\n babelTransformerPath: require.resolve('react-native-svg-transformer'),\n getTransformOptions: async () => ({\n transform: {\n experimentalImportSupport: false,\n inlineRequires: true,\n },\n }),\n },\n resolver: {\n assetExts: assetExts.filter(ext => ext !== 'svg'),\n sourceExts: [...sourceExts, 'svg'],\n },\n ...jsoMetroPlugin,\n};\n\nmodule.exports = mergeConfig(getDefaultConfig(__dirname), config);`);\n\n const result = await patchMetroWithSentryConfigInMemory(\n mod,\n 'metro.config.js',\n true,\n );\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code)\n .toBe(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\n\nconst {\n withSentryConfig\n} = require(\"@sentry/react-native/metro\");\n\nconst defaultConfig = getDefaultConfig(__dirname);\nconst {assetExts, sourceExts} = defaultConfig.resolver;\n/**\n * Metro configuration\n * https://facebook.github.io/metro/docs/configuration\n *\n * @type {import('metro-config').MetroConfig}\n */\n\nconst jsoMetroPlugin = require('obfuscator-io-metro-plugin')(\n {\n // for these option look javascript-obfuscator library options from above url\n compact: false,\n sourceMap: false,\n controlFlowFlattening: true,\n controlFlowFlatteningThreshold: 1,\n numbersToExpressions: true,\n simplify: true,\n stringArrayShuffle: true,\n splitStrings: true,\n stringArrayThreshold: 1,\n },\n {\n runInDev: false /* optional */,\n logObfuscatedFiles: true /* optional generated files will be located at ./.jso */,\n // source Map generated after obfuscation is not useful right now\n sourceMapLocation:\n './index.android.bundle.map' /* optional only works if sourceMap: true in obfuscation option */,\n },\n);\n\nconst config = {\n transformer: {\n babelTransformerPath: require.resolve('react-native-svg-transformer'),\n getTransformOptions: async () => ({\n transform: {\n experimentalImportSupport: false,\n inlineRequires: true,\n },\n }),\n },\n resolver: {\n assetExts: assetExts.filter(ext => ext !== 'svg'),\n sourceExts: [...sourceExts, 'svg'],\n },\n ...jsoMetroPlugin,\n};\n\nmodule.exports = withSentryConfig(mergeConfig(getDefaultConfig(__dirname), config));`);\n });\n\n it('patches CJS style metro config', async () => {\n const mod =\n parseModule(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');\n\nconst config = {};\n\nmodule.exports = mergeConfig(getDefaultConfig(__dirname), config);`);\n\n const result = await patchMetroWithSentryConfigInMemory(\n mod,\n 'metro.config.cjs',\n true,\n );\n expect(result).toBe(true);\n\n const code = generateCode(mod.$ast).code;\n expect(code).toContain('require(\"@sentry/react-native/metro\")');\n expect(code).toContain('withSentryConfig');\n });\n\n it('does not patch react native metro config exported as factory function', async () => {\n const mod = parseModule(`module.exports = () => ({});`);\n\n const result = await patchMetroWithSentryConfigInMemory(\n mod,\n 'metro.config.js',\n true,\n );\n expect(result).toBe(false);\n expect(generateCode(mod.$ast).code).toBe(`module.exports = () => ({});`);\n });\n });\n\n describe('addSentrySerializerToMetroConfig', () => {\n it('add to empty config', () => {\n const mod = parseModule(`module.exports = {\n other: 'config'\n }`);\n const configObject = getModuleExportsObject(mod);\n const result = addSentrySerializerToMetroConfig(configObject);\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`module.exports = {\n other: 'config',\n\n serializer: {\n customSerializer: createSentryMetroSerializer()\n }\n}`);\n });\n\n it('add to existing serializer config', () => {\n const mod = parseModule(`module.exports = {\n other: 'config',\n serializer: {\n other: 'config'\n }\n}`);\n const configObject = getModuleExportsObject(mod);\n const result = addSentrySerializerToMetroConfig(configObject);\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code).toBe(`module.exports = {\n other: 'config',\n serializer: {\n other: 'config',\n customSerializer: createSentryMetroSerializer()\n }\n}`);\n });\n\n it('not add to existing customSerializer config', () => {\n const mod = parseModule(`module.exports = {\n other: 'config',\n serializer: {\n other: 'config',\n customSerializer: 'existing-serializer'\n }\n}`);\n const configObject = getModuleExportsObject(mod);\n const result = addSentrySerializerToMetroConfig(configObject);\n expect(result).toBe(false);\n expect(generateCode(mod.$ast).code).toBe(`module.exports = {\n other: 'config',\n serializer: {\n other: 'config',\n customSerializer: 'existing-serializer'\n }\n}`);\n });\n });\n\n describe('addSentrySerializerImportToMetroConfig', () => {\n it('add import', () => {\n const mod =\n parseModule(`const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');\n\nmodule.exports = {\n other: 'config'\n}`);\n const result = addSentrySerializerRequireToMetroConfig(\n mod.$ast as t.Program,\n );\n expect(result).toBe(true);\n expect(generateCode(mod.$ast).code)\n .toBe(`const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');\n\nconst {\n createSentryMetroSerializer\n} = require(\"@sentry/react-native/dist/js/tools/sentryMetroSerializer\");\n\nmodule.exports = {\n other: 'config'\n}`);\n });\n });\n\n describe('getMetroConfigObject', () => {\n it('get config object from variable called config', () => {\n const mod = parseModule(`var config = { some: 'config' };`);\n const configObject = getMetroConfigObject(mod.$ast as t.Program);\n expect(\n ((configObject?.properties[0] as t.ObjectProperty).key as t.Identifier)\n .name,\n ).toBe('some');\n expect(\n (\n (configObject?.properties[0] as t.ObjectProperty)\n .value as t.StringLiteral\n ).value,\n ).toBe('config');\n });\n\n it('get config object from const called config', () => {\n const mod = parseModule(`const config = { some: 'config' };`);\n const configObject = getMetroConfigObject(mod.$ast as t.Program);\n expect(\n ((configObject?.properties[0] as t.ObjectProperty).key as t.Identifier)\n .name,\n ).toBe('some');\n expect(\n (\n (configObject?.properties[0] as t.ObjectProperty)\n .value as t.StringLiteral\n ).value,\n ).toBe('config');\n });\n\n it('get config oject from let called config', () => {\n const mod = parseModule(`let config = { some: 'config' };`);\n const configObject = getMetroConfigObject(mod.$ast as t.Program);\n expect(\n ((configObject?.properties[0] as t.ObjectProperty).key as t.Identifier)\n .name,\n ).toBe('some');\n expect(\n (\n (configObject?.properties[0] as t.ObjectProperty)\n .value as t.StringLiteral\n ).value,\n ).toBe('config');\n });\n\n it('get config object from module.exports', () => {\n const mod = parseModule(`module.exports = { some: 'config' };`);\n const configObject = getMetroConfigObject(mod.$ast as t.Program);\n expect(\n ((configObject?.properties[0] as t.ObjectProperty).key as t.Identifier)\n .name,\n ).toBe('some');\n expect(\n (\n (configObject?.properties[0] as t.ObjectProperty)\n .value as t.StringLiteral\n ).value,\n ).toBe('config');\n });\n });\n});\n\ndescribe('Dynamic Metro Config path', () => {\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n it('finds metro.config.js when it exists', () => {\n vi.mocked(fs.existsSync).mockImplementation(\n (path: string) => path === 'metro.config.js',\n );\n\n const result = findMetroConfigPath();\n expect(result).toBe('metro.config.js');\n });\n\n it('finds metro.config.cjs when it exists', () => {\n vi.mocked(fs.existsSync).mockImplementation(\n (path: string) => path === 'metro.config.cjs',\n );\n\n const result = findMetroConfigPath();\n expect(result).toBe('metro.config.cjs');\n });\n\n it('prefers metro.config.js over metro.config.cjs when both exist', () => {\n vi.mocked(fs.existsSync).mockImplementation(() => true);\n\n const result = findMetroConfigPath();\n expect(result).toBe('metro.config.js');\n });\n\n it('returns undefined when no metro config exists', () => {\n vi.mocked(fs.existsSync).mockImplementation(() => false);\n\n const result = findMetroConfigPath();\n expect(result).toBeUndefined();\n });\n});\n\nfunction getModuleExportsObject(\n mod: ProxifiedModule,\n index = 0,\n): t.ObjectExpression {\n return (\n ((mod.$ast as t.Program).body[index] as t.ExpressionStatement)\n .expression as t.AssignmentExpression\n ).right as t.ObjectExpression;\n}\n"]}
@@ -42,6 +42,9 @@ vitest_1.vi.mock('@clack/prompts', () => {
42
42
  ...mock,
43
43
  };
44
44
  });
45
+ vitest_1.vi.mock('../../src/utils/clack/mcp-config', () => ({
46
+ offerProjectScopedMcpConfig: vitest_1.vi.fn().mockResolvedValue(undefined),
47
+ }));
45
48
  (0, vitest_1.describe)('wrapAppWithSentry', () => {
46
49
  (0, vitest_1.it)('should wrap the app with Sentry', () => {
47
50
  // Empty root.tsx file for testing
@@ -1 +1 @@
1
- {"version":3,"file":"root.test.js","sourceRoot":"","sources":["../../../test/remix/root.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kFAAkF;AAClF,uCAAuC;AACvC,mCAAyE;AACzE,uCAAyB;AACzB,2CAA6B;AAC7B,wDAIuC;AAEvC,WAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC7B,MAAM,IAAI,GAAG;QACX,GAAG,EAAE;YACH,IAAI,EAAE,WAAE,CAAC,EAAE,EAAE;YACb,IAAI,EAAE,WAAE,CAAC,EAAE,EAAE;YACb,OAAO,EAAE,WAAE,CAAC,EAAE,EAAE;SACjB;KACF,CAAC;IACF,OAAO;QACL,OAAO,EAAE,IAAI;QACb,GAAG,IAAI;KACR,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAA,iBAAQ,EAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,IAAA,WAAE,EAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,kCAAkC;QAClC,MAAM,eAAe,GAAG,IAAA,sBAAW,EAAC;;;;;;KAMnC,CAAC,CAAC;QAEH,IAAA,wBAAiB,EAAC,eAAe,EAAE,UAAU,CAAC,CAAC;QAE/C,MAAM,MAAM,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC;QAE/C,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;KASpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAA,iBAAQ,EAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,IAAA,WAAE,EAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,OAAO,GAAG,IAAA,sBAAW,EAAC;;;;;;KAM3B,CAAC,CAAC;QAEH,I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C,CAAC,SAAS,CAC/B,6EAA6E,CAC9E,CAAC;QACF,IAAA,eAAM,EAAC,eAAe,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { parseModule } from 'magicast';\nimport { describe, expect, it, vi, beforeEach, afterEach } from 'vitest';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport {\n wrapAppWithSentry,\n isWithSentryAlreadyUsed,\n instrumentRoot,\n} from '../../src/remix/codemods/root';\n\nvi.mock('@clack/prompts', () => {\n const mock = {\n log: {\n warn: vi.fn(),\n info: vi.fn(),\n success: vi.fn(),\n },\n };\n return {\n default: mock,\n ...mock,\n };\n});\n\ndescribe('wrapAppWithSentry', () => {\n it('should wrap the app with Sentry', () => {\n // Empty root.tsx file for testing\n const originalRootAst = parseModule(`\n import { Outlet } from '@remix-run/react';\n\n export default function App() {\n return <Outlet />;\n }\n `);\n\n wrapAppWithSentry(originalRootAst, 'root.tsx');\n\n const result = originalRootAst.generate().code;\n\n expect(result).toMatchInlineSnapshot(`\n \"import {withSentry} from '@sentry/remix';\n import { Outlet } from '@remix-run/react';\n\n function App() {\n return <Outlet />;\n }\n\n export default withSentry(App);\"\n `);\n });\n});\n\ndescribe('isWithSentryAlreadyUsed', () => {\n it('should return false when withSentry is not used', () => {\n const rootAst = parseModule(`\n import { Outlet } from '@remix-run/react';\n\n export default function App() {\n return <Outlet />;\n }\n `);\n\n expect(isWithSentryAlreadyUsed(rootAst)).toBe(false);\n });\n\n it('should return true when withSentry is used in default export', () => {\n const rootAst = parseModule(`\n import { withSentry } from '@sentry/remix';\n import { Outlet } from '@remix-run/react';\n\n function App() {\n return <Outlet />;\n }\n\n export default withSentry(App);\n `);\n\n expect(isWithSentryAlreadyUsed(rootAst)).toBe(true);\n });\n\n it('should return true when withSentry is used in a variable assignment', () => {\n const rootAst = parseModule(`\n import { withSentry } from '@sentry/remix';\n import { Outlet } from '@remix-run/react';\n\n function App() {\n return <Outlet />;\n }\n\n const WrappedApp = withSentry(App);\n export default WrappedApp;\n `);\n\n expect(isWithSentryAlreadyUsed(rootAst)).toBe(true);\n });\n\n it('should return true when withSentry is used inside a function', () => {\n const rootAst = parseModule(`\n import { withSentry } from '@sentry/remix';\n import { Outlet } from '@remix-run/react';\n\n function App() {\n return <Outlet />;\n }\n\n function createApp() {\n return withSentry(App);\n }\n\n export default createApp();\n `);\n\n expect(isWithSentryAlreadyUsed(rootAst)).toBe(true);\n });\n\n it('should return false when withSentry is imported but not used', () => {\n const rootAst = parseModule(`\n import { withSentry } from '@sentry/remix';\n import { Outlet } from '@remix-run/react';\n\n export default function App() {\n return <Outlet />;\n }\n `);\n\n expect(isWithSentryAlreadyUsed(rootAst)).toBe(false);\n });\n\n it('should return false when a different function with similar name is used', () => {\n const rootAst = parseModule(`\n import { Outlet } from '@remix-run/react';\n\n function withSentryLike() {\n return null;\n }\n\n export default function App() {\n withSentryLike();\n return <Outlet />;\n }\n `);\n\n expect(isWithSentryAlreadyUsed(rootAst)).toBe(false);\n });\n});\n\ndescribe('instrumentRoot', () => {\n const fixturesDir = path.join(__dirname, 'fixtures');\n const tmpDir = path.join(fixturesDir, 'tmp');\n\n beforeEach(() => {\n vi.clearAllMocks();\n // Mock process.cwd() to return the fixtures directory\n vi.spyOn(process, 'cwd').mockReturnValue(fixturesDir);\n });\n\n afterEach(() => {\n // Clean up any temporary files\n if (fs.existsSync(tmpDir)) {\n try {\n // Remove files first, then directory\n const appDir = path.join(tmpDir, 'app');\n if (fs.existsSync(appDir)) {\n const files = fs.readdirSync(appDir);\n files.forEach((file) => {\n fs.unlinkSync(path.join(appDir, file));\n });\n fs.rmdirSync(appDir);\n }\n\n const files = fs.readdirSync(tmpDir);\n files.forEach((file) => {\n const filePath = path.join(tmpDir, file);\n const stat = fs.statSync(filePath);\n if (stat.isDirectory()) {\n fs.rmdirSync(filePath);\n } else {\n fs.unlinkSync(filePath);\n }\n });\n } catch (error) {\n // Ignore cleanup errors in tests\n }\n }\n });\n\n it('should add ErrorBoundary and wrap app with Sentry when no ErrorBoundary exists and withSentry is not used', async () => {\n // Copy fixture to tmp directory for testing\n const srcFile = path.join(fixturesDir, 'root-no-error-boundary.tsx');\n const appDir = path.join(tmpDir, 'app');\n\n // Create app directory and copy file\n fs.mkdirSync(appDir, { recursive: true });\n fs.copyFileSync(srcFile, path.join(appDir, 'root.tsx'));\n\n // Mock process.cwd() to return tmpDir\n vi.spyOn(process, 'cwd').mockReturnValue(tmpDir);\n\n await instrumentRoot('root.tsx');\n\n // Check that the file was modified correctly\n const modifiedContent = fs.readFileSync(\n path.join(appDir, 'root.tsx'),\n 'utf8',\n );\n\n expect(modifiedContent).toContain(\n 'import { captureRemixErrorBoundaryError, withSentry } from \"@sentry/remix\";',\n );\n expect(modifiedContent).toContain(\n \"import { Outlet, useRouteError } from '@remix-run/react';\",\n );\n expect(modifiedContent).toContain('withSentry(App)');\n expect(modifiedContent).toContain('const ErrorBoundary = () => {');\n });\n\n it('should wrap app with Sentry when ErrorBoundary exists but no Sentry content', async () => {\n const srcFile = path.join(fixturesDir, 'root-with-error-boundary.tsx');\n const appDir = path.join(tmpDir, 'app');\n\n fs.mkdirSync(appDir, { recursive: true });\n fs.copyFileSync(srcFile, path.join(appDir, 'root.tsx'));\n\n vi.spyOn(process, 'cwd').mockReturnValue(tmpDir);\n\n await instrumentRoot('root.tsx');\n\n const modifiedContent = fs.readFileSync(\n path.join(appDir, 'root.tsx'),\n 'utf8',\n );\n\n expect(modifiedContent).toContain(\n 'import { captureRemixErrorBoundaryError, withSentry } from \"@sentry/remix\";',\n );\n expect(modifiedContent).toContain('withSentry(App)');\n });\n\n it('should wrap app with Sentry when ErrorBoundary exists with Sentry content but withSentry is not used', async () => {\n const srcFile = path.join(\n fixturesDir,\n 'root-with-sentry-error-boundary.tsx',\n );\n const appDir = path.join(tmpDir, 'app');\n\n fs.mkdirSync(appDir, { recursive: true });\n fs.copyFileSync(srcFile, path.join(appDir, 'root.tsx'));\n\n vi.spyOn(process, 'cwd').mockReturnValue(tmpDir);\n\n await instrumentRoot('root.tsx');\n\n const modifiedContent = fs.readFileSync(\n path.join(appDir, 'root.tsx'),\n 'utf8',\n );\n\n expect(modifiedContent).toContain(\n \"import { captureRemixErrorBoundaryError, withSentry } from '@sentry/remix';\",\n );\n expect(modifiedContent).toContain('withSentry(App)');\n });\n\n it('should not wrap app when withSentry is already used', async () => {\n const srcFile = path.join(fixturesDir, 'root-already-wrapped.tsx');\n const appDir = path.join(tmpDir, 'app');\n\n fs.mkdirSync(appDir, { recursive: true });\n fs.copyFileSync(srcFile, path.join(appDir, 'root.tsx'));\n\n vi.spyOn(process, 'cwd').mockReturnValue(tmpDir);\n\n await instrumentRoot('root.tsx');\n\n const modifiedContent = fs.readFileSync(\n path.join(appDir, 'root.tsx'),\n 'utf8',\n );\n\n // Should not add withSentry import or wrap again\n expect(modifiedContent).toContain('withSentry(App)');\n\n // Count occurrences of withSentry to ensure it's not duplicated\n const withSentryOccurrences = (modifiedContent.match(/withSentry/g) || [])\n .length;\n expect(withSentryOccurrences).toBe(2); // One import, one usage\n\n // The content should remain largely the same since withSentry is already used\n expect(modifiedContent).toContain('export default withSentry(App)');\n });\n\n it('should handle ErrorBoundary as variable declaration', async () => {\n const srcFile = path.join(fixturesDir, 'root-variable-error-boundary.tsx');\n const appDir = path.join(tmpDir, 'app');\n\n fs.mkdirSync(appDir, { recursive: true });\n fs.copyFileSync(srcFile, path.join(appDir, 'root.tsx'));\n\n vi.spyOn(process, 'cwd').mockReturnValue(tmpDir);\n\n await instrumentRoot('root.tsx');\n\n const modifiedContent = fs.readFileSync(\n path.join(appDir, 'root.tsx'),\n 'utf8',\n );\n\n expect(modifiedContent).toContain(\n 'import { captureRemixErrorBoundaryError, withSentry } from \"@sentry/remix\";',\n );\n expect(modifiedContent).toContain('withSentry(App)');\n });\n});\n"]}
1
+ {"version":3,"file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C,EAC7B,MAAM,CACP,CAAC;QAEF,IAAA,eAAM,EAAC,eAAe,CAAC,CAAC,SAAS,CAC/B,6EAA6E,CAC9E,CAAC;QACF,IAAA,eAAM,EAAC,eAAe,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { parseModule } from 'magicast';\nimport { describe, expect, it, vi, beforeEach, afterEach } from 'vitest';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport {\n wrapAppWithSentry,\n isWithSentryAlreadyUsed,\n instrumentRoot,\n} from '../../src/remix/codemods/root';\n\nvi.mock('@clack/prompts', () => {\n const mock = {\n log: {\n warn: vi.fn(),\n info: vi.fn(),\n success: vi.fn(),\n },\n };\n return {\n default: mock,\n ...mock,\n };\n});\n\nvi.mock('../../src/utils/clack/mcp-config', () => ({\n offerProjectScopedMcpConfig: vi.fn().mockResolvedValue(undefined),\n}));\n\ndescribe('wrapAppWithSentry', () => {\n it('should wrap the app with Sentry', () => {\n // Empty root.tsx file for testing\n const originalRootAst = parseModule(`\n import { Outlet } from '@remix-run/react';\n\n export default function App() {\n return <Outlet />;\n }\n `);\n\n wrapAppWithSentry(originalRootAst, 'root.tsx');\n\n const result = originalRootAst.generate().code;\n\n expect(result).toMatchInlineSnapshot(`\n \"import {withSentry} from '@sentry/remix';\n import { Outlet } from '@remix-run/react';\n\n function App() {\n return <Outlet />;\n }\n\n export default withSentry(App);\"\n `);\n });\n});\n\ndescribe('isWithSentryAlreadyUsed', () => {\n it('should return false when withSentry is not used', () => {\n const rootAst = parseModule(`\n import { Outlet } from '@remix-run/react';\n\n export default function App() {\n return <Outlet />;\n }\n `);\n\n expect(isWithSentryAlreadyUsed(rootAst)).toBe(false);\n });\n\n it('should return true when withSentry is used in default export', () => {\n const rootAst = parseModule(`\n import { withSentry } from '@sentry/remix';\n import { Outlet } from '@remix-run/react';\n\n function App() {\n return <Outlet />;\n }\n\n export default withSentry(App);\n `);\n\n expect(isWithSentryAlreadyUsed(rootAst)).toBe(true);\n });\n\n it('should return true when withSentry is used in a variable assignment', () => {\n const rootAst = parseModule(`\n import { withSentry } from '@sentry/remix';\n import { Outlet } from '@remix-run/react';\n\n function App() {\n return <Outlet />;\n }\n\n const WrappedApp = withSentry(App);\n export default WrappedApp;\n `);\n\n expect(isWithSentryAlreadyUsed(rootAst)).toBe(true);\n });\n\n it('should return true when withSentry is used inside a function', () => {\n const rootAst = parseModule(`\n import { withSentry } from '@sentry/remix';\n import { Outlet } from '@remix-run/react';\n\n function App() {\n return <Outlet />;\n }\n\n function createApp() {\n return withSentry(App);\n }\n\n export default createApp();\n `);\n\n expect(isWithSentryAlreadyUsed(rootAst)).toBe(true);\n });\n\n it('should return false when withSentry is imported but not used', () => {\n const rootAst = parseModule(`\n import { withSentry } from '@sentry/remix';\n import { Outlet } from '@remix-run/react';\n\n export default function App() {\n return <Outlet />;\n }\n `);\n\n expect(isWithSentryAlreadyUsed(rootAst)).toBe(false);\n });\n\n it('should return false when a different function with similar name is used', () => {\n const rootAst = parseModule(`\n import { Outlet } from '@remix-run/react';\n\n function withSentryLike() {\n return null;\n }\n\n export default function App() {\n withSentryLike();\n return <Outlet />;\n }\n `);\n\n expect(isWithSentryAlreadyUsed(rootAst)).toBe(false);\n });\n});\n\ndescribe('instrumentRoot', () => {\n const fixturesDir = path.join(__dirname, 'fixtures');\n const tmpDir = path.join(fixturesDir, 'tmp');\n\n beforeEach(() => {\n vi.clearAllMocks();\n // Mock process.cwd() to return the fixtures directory\n vi.spyOn(process, 'cwd').mockReturnValue(fixturesDir);\n });\n\n afterEach(() => {\n // Clean up any temporary files\n if (fs.existsSync(tmpDir)) {\n try {\n // Remove files first, then directory\n const appDir = path.join(tmpDir, 'app');\n if (fs.existsSync(appDir)) {\n const files = fs.readdirSync(appDir);\n files.forEach((file) => {\n fs.unlinkSync(path.join(appDir, file));\n });\n fs.rmdirSync(appDir);\n }\n\n const files = fs.readdirSync(tmpDir);\n files.forEach((file) => {\n const filePath = path.join(tmpDir, file);\n const stat = fs.statSync(filePath);\n if (stat.isDirectory()) {\n fs.rmdirSync(filePath);\n } else {\n fs.unlinkSync(filePath);\n }\n });\n } catch (error) {\n // Ignore cleanup errors in tests\n }\n }\n });\n\n it('should add ErrorBoundary and wrap app with Sentry when no ErrorBoundary exists and withSentry is not used', async () => {\n // Copy fixture to tmp directory for testing\n const srcFile = path.join(fixturesDir, 'root-no-error-boundary.tsx');\n const appDir = path.join(tmpDir, 'app');\n\n // Create app directory and copy file\n fs.mkdirSync(appDir, { recursive: true });\n fs.copyFileSync(srcFile, path.join(appDir, 'root.tsx'));\n\n // Mock process.cwd() to return tmpDir\n vi.spyOn(process, 'cwd').mockReturnValue(tmpDir);\n\n await instrumentRoot('root.tsx');\n\n // Check that the file was modified correctly\n const modifiedContent = fs.readFileSync(\n path.join(appDir, 'root.tsx'),\n 'utf8',\n );\n\n expect(modifiedContent).toContain(\n 'import { captureRemixErrorBoundaryError, withSentry } from \"@sentry/remix\";',\n );\n expect(modifiedContent).toContain(\n \"import { Outlet, useRouteError } from '@remix-run/react';\",\n );\n expect(modifiedContent).toContain('withSentry(App)');\n expect(modifiedContent).toContain('const ErrorBoundary = () => {');\n });\n\n it('should wrap app with Sentry when ErrorBoundary exists but no Sentry content', async () => {\n const srcFile = path.join(fixturesDir, 'root-with-error-boundary.tsx');\n const appDir = path.join(tmpDir, 'app');\n\n fs.mkdirSync(appDir, { recursive: true });\n fs.copyFileSync(srcFile, path.join(appDir, 'root.tsx'));\n\n vi.spyOn(process, 'cwd').mockReturnValue(tmpDir);\n\n await instrumentRoot('root.tsx');\n\n const modifiedContent = fs.readFileSync(\n path.join(appDir, 'root.tsx'),\n 'utf8',\n );\n\n expect(modifiedContent).toContain(\n 'import { captureRemixErrorBoundaryError, withSentry } from \"@sentry/remix\";',\n );\n expect(modifiedContent).toContain('withSentry(App)');\n });\n\n it('should wrap app with Sentry when ErrorBoundary exists with Sentry content but withSentry is not used', async () => {\n const srcFile = path.join(\n fixturesDir,\n 'root-with-sentry-error-boundary.tsx',\n );\n const appDir = path.join(tmpDir, 'app');\n\n fs.mkdirSync(appDir, { recursive: true });\n fs.copyFileSync(srcFile, path.join(appDir, 'root.tsx'));\n\n vi.spyOn(process, 'cwd').mockReturnValue(tmpDir);\n\n await instrumentRoot('root.tsx');\n\n const modifiedContent = fs.readFileSync(\n path.join(appDir, 'root.tsx'),\n 'utf8',\n );\n\n expect(modifiedContent).toContain(\n \"import { captureRemixErrorBoundaryError, withSentry } from '@sentry/remix';\",\n );\n expect(modifiedContent).toContain('withSentry(App)');\n });\n\n it('should not wrap app when withSentry is already used', async () => {\n const srcFile = path.join(fixturesDir, 'root-already-wrapped.tsx');\n const appDir = path.join(tmpDir, 'app');\n\n fs.mkdirSync(appDir, { recursive: true });\n fs.copyFileSync(srcFile, path.join(appDir, 'root.tsx'));\n\n vi.spyOn(process, 'cwd').mockReturnValue(tmpDir);\n\n await instrumentRoot('root.tsx');\n\n const modifiedContent = fs.readFileSync(\n path.join(appDir, 'root.tsx'),\n 'utf8',\n );\n\n // Should not add withSentry import or wrap again\n expect(modifiedContent).toContain('withSentry(App)');\n\n // Count occurrences of withSentry to ensure it's not duplicated\n const withSentryOccurrences = (modifiedContent.match(/withSentry/g) || [])\n .length;\n expect(withSentryOccurrences).toBe(2); // One import, one usage\n\n // The content should remain largely the same since withSentry is already used\n expect(modifiedContent).toContain('export default withSentry(App)');\n });\n\n it('should handle ErrorBoundary as variable declaration', async () => {\n const srcFile = path.join(fixturesDir, 'root-variable-error-boundary.tsx');\n const appDir = path.join(tmpDir, 'app');\n\n fs.mkdirSync(appDir, { recursive: true });\n fs.copyFileSync(srcFile, path.join(appDir, 'root.tsx'));\n\n vi.spyOn(process, 'cwd').mockReturnValue(tmpDir);\n\n await instrumentRoot('root.tsx');\n\n const modifiedContent = fs.readFileSync(\n path.join(appDir, 'root.tsx'),\n 'utf8',\n );\n\n expect(modifiedContent).toContain(\n 'import { captureRemixErrorBoundaryError, withSentry } from \"@sentry/remix\";',\n );\n expect(modifiedContent).toContain('withSentry(App)');\n });\n});\n"]}
@@ -2,6 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const vitest_1 = require("vitest");
4
4
  const templates_1 = require("../../src/sveltekit/templates");
5
+ vitest_1.vi.mock('../../src/utils/clack/mcp-config', () => ({
6
+ offerProjectScopedMcpConfig: vitest_1.vi.fn().mockResolvedValue(undefined),
7
+ }));
5
8
  (0, vitest_1.describe)('getClientHooksTemplate', () => {
6
9
  (0, vitest_1.it)('should generate client hooks template with all features enabled', () => {
7
10
  const result = (0, templates_1.getClientHooksTemplate)('https://sentry.io/123', {
@@ -1 +1 @@
1
- {"version":3,"file":"templates.test.js","sourceRoot":"","sources":["../../../test/sveltekit/templates.test.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAC9C,6DAGuC;AAEvC,IAAA,iBAAQ,EAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,IAAA,WAAE,EAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,MAAM,GAAG,IAAA,kCAAsB,EAAC,uBAAuB,EAAE;YAC7D,WAAW,EAAE,IAAI;YACjB,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;QAEH,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2BpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,MAAM,GAAG,IAAA,kCAAsB,EAAC,uBAAuB,EAAE;YAC7D,WAAW,EAAE,KAAK;YAClB,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;QAEH,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,q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7D,WAAW,EAAE,KAAK;YAClB,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;QAEH,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;KAmBpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,8DAA8D,EAAE,GAAG,EAAE;QACtE,MAAM,MAAM,GAAG,IAAA,kCAAsB,EAAC,uBAAuB,EAAE;YAC7D,WAAW,EAAE,KAAK;YAClB,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;QAEH,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;KAqBpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it } from 'vitest';\nimport {\n getClientHooksTemplate,\n getServerHooksTemplate,\n} from '../../src/sveltekit/templates';\n\ndescribe('getClientHooksTemplate', () => {\n it('should generate client hooks template with all features enabled', () => {\n const result = getClientHooksTemplate('https://sentry.io/123', {\n performance: true,\n replay: true,\n logs: true,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\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: [replayIntegration()],\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n\n it('should generate client hooks template when performance disabled', () => {\n const result = getClientHooksTemplate('https://sentry.io/123', {\n performance: false,\n replay: true,\n logs: false,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\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: [replayIntegration()],\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n\n it('should generate client hooks template when replay disabled', () => {\n const result = getClientHooksTemplate('https://sentry.io/123', {\n performance: true,\n replay: false,\n logs: false,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n tracesSampleRate: 1.0,\n\n\n\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n\n it('should generate client hooks template with only logs enabled', () => {\n const result = getClientHooksTemplate('https://sentry.io/123', {\n performance: false,\n replay: false,\n logs: true,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n});\n\ndescribe('getServerHooksTemplate', () => {\n it('should generate server hooks template with all features enabled', () => {\n const result = getServerHooksTemplate('https://sentry.io/123', {\n performance: true,\n replay: true,\n logs: true,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { sequence } from \"@sveltejs/kit/hooks\";\n import { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n });\n\n // If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\n export const handle = sequence(sentryHandle());\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n\n it('should generate server hooks template when performance disabled', () => {\n const result = getServerHooksTemplate('https://sentry.io/123', {\n performance: false,\n replay: true,\n logs: false,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { sequence } from \"@sveltejs/kit/hooks\";\n import { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n });\n\n // If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\n export const handle = sequence(sentryHandle());\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n\n it('should generate server hooks template with only logs enabled', () => {\n const result = getServerHooksTemplate('https://sentry.io/123', {\n performance: false,\n replay: false,\n logs: true,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { sequence } from \"@sveltejs/kit/hooks\";\n import { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n });\n\n // If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\n export const handle = sequence(sentryHandle());\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n});\n"]}
1
+ {"version":3,"file":"templates.test.js","sourceRoot":"","sources":["../../../test/sveltekit/templates.test.ts"],"names":[],"mappings":";;AAAA,mCAAkD;AAClD,6DAGuC;AAEvC,WAAE,CAAC,IAAI,CAAC,kCAAkC,EAAE,GAAG,EAAE,CAAC,CAAC;IACjD,2BAA2B,EAAE,WAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC;CAClE,CAAC,CAAC,CAAC;AAEJ,IAAA,iBAAQ,EAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,IAAA,WAAE,EAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,MAAM,GAAG,IAAA,kCAAsB,EAAC,uBAAuB,EAAE;YAC7D,WAAW,EAAE,IAAI;YACjB,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;QAEH,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2BpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,MAAM,GAAG,IAAA,kCAAsB,EAAC,uBAAuB,EAAE;YAC7D,WAAW,EAAE,KAAK;YAClB,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;QAEH,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;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ClB,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,KAAK;SACZ,CAAC,CAAC;QAEH,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;KAmBpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,8DAA8D,EAAE,GAAG,EAAE;QACtE,MAAM,MAAM,GAAG,IAAA,kCAAsB,EAAC,uBAAuB,EAAE;YAC7D,WAAW,EAAE,KAAK;YAClB,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;QAEH,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;KAqBpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it, vi } from 'vitest';\nimport {\n getClientHooksTemplate,\n getServerHooksTemplate,\n} from '../../src/sveltekit/templates';\n\nvi.mock('../../src/utils/clack/mcp-config', () => ({\n offerProjectScopedMcpConfig: vi.fn().mockResolvedValue(undefined),\n}));\n\ndescribe('getClientHooksTemplate', () => {\n it('should generate client hooks template with all features enabled', () => {\n const result = getClientHooksTemplate('https://sentry.io/123', {\n performance: true,\n replay: true,\n logs: true,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\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: [replayIntegration()],\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n\n it('should generate client hooks template when performance disabled', () => {\n const result = getClientHooksTemplate('https://sentry.io/123', {\n performance: false,\n replay: true,\n logs: false,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\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: [replayIntegration()],\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n\n it('should generate client hooks template when replay disabled', () => {\n const result = getClientHooksTemplate('https://sentry.io/123', {\n performance: true,\n replay: false,\n logs: false,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n tracesSampleRate: 1.0,\n\n\n\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n\n it('should generate client hooks template with only logs enabled', () => {\n const result = getClientHooksTemplate('https://sentry.io/123', {\n performance: false,\n replay: false,\n logs: true,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n});\n\ndescribe('getServerHooksTemplate', () => {\n it('should generate server hooks template with all features enabled', () => {\n const result = getServerHooksTemplate('https://sentry.io/123', {\n performance: true,\n replay: true,\n logs: true,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { sequence } from \"@sveltejs/kit/hooks\";\n import { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n tracesSampleRate: 1.0,\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n });\n\n // If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\n export const handle = sequence(sentryHandle());\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n\n it('should generate server hooks template when performance disabled', () => {\n const result = getServerHooksTemplate('https://sentry.io/123', {\n performance: false,\n replay: true,\n logs: false,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { sequence } from \"@sveltejs/kit/hooks\";\n import { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n });\n\n // If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\n export const handle = sequence(sentryHandle());\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n\n it('should generate server hooks template with only logs enabled', () => {\n const result = getServerHooksTemplate('https://sentry.io/123', {\n performance: false,\n replay: false,\n logs: true,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { sequence } from \"@sveltejs/kit/hooks\";\n import { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n // Enable logs to be sent to Sentry\n enableLogs: true,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n });\n\n // If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\n export const handle = sequence(sentryHandle());\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n});\n"]}
@@ -0,0 +1 @@
1
+ export {};