@sentry/wizard 5.3.0 → 6.0.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 (39) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/e2e-tests/tests/angular-17.test.js +7 -1
  3. package/dist/e2e-tests/tests/angular-17.test.js.map +1 -1
  4. package/dist/e2e-tests/tests/angular-19.test.js +7 -1
  5. package/dist/e2e-tests/tests/angular-19.test.js.map +1 -1
  6. package/dist/src/remix/codemods/handle-error.js +3 -6
  7. package/dist/src/remix/codemods/handle-error.js.map +1 -1
  8. package/dist/src/remix/codemods/{root-common.d.ts → root.d.ts} +1 -0
  9. package/dist/src/remix/codemods/{root-v2.js → root.js} +47 -12
  10. package/dist/src/remix/codemods/root.js.map +1 -0
  11. package/dist/src/remix/remix-wizard.js +7 -5
  12. package/dist/src/remix/remix-wizard.js.map +1 -1
  13. package/dist/src/remix/sdk-setup.d.ts +3 -11
  14. package/dist/src/remix/sdk-setup.js +9 -18
  15. package/dist/src/remix/sdk-setup.js.map +1 -1
  16. package/dist/src/remix/templates.d.ts +2 -2
  17. package/dist/src/remix/templates.js +3 -3
  18. package/dist/src/remix/templates.js.map +1 -1
  19. package/dist/src/sourcemaps/sourcemaps-wizard.js +1 -1
  20. package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
  21. package/dist/src/sourcemaps/tools/sentry-cli.js +15 -17
  22. package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
  23. package/dist/src/utils/clack/index.d.ts +7 -0
  24. package/dist/src/utils/clack/index.js +127 -4
  25. package/dist/src/utils/clack/index.js.map +1 -1
  26. package/dist/src/version.d.ts +1 -1
  27. package/dist/src/version.js +1 -1
  28. package/dist/src/version.js.map +1 -1
  29. package/dist/test/remix/root.test.d.ts +1 -0
  30. package/dist/test/remix/root.test.js +31 -0
  31. package/dist/test/remix/root.test.js.map +1 -0
  32. package/package.json +1 -1
  33. package/dist/src/remix/codemods/root-common.js +0 -70
  34. package/dist/src/remix/codemods/root-common.js.map +0 -1
  35. package/dist/src/remix/codemods/root-v1.d.ts +0 -1
  36. package/dist/src/remix/codemods/root-v1.js +0 -52
  37. package/dist/src/remix/codemods/root-v1.js.map +0 -1
  38. package/dist/src/remix/codemods/root-v2.d.ts +0 -1
  39. package/dist/src/remix/codemods/root-v2.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.0.0
4
+
5
+ ### Breaking Changes
6
+
7
+ - remove(remix)!: Drop Remix v1 support ([#1013](https://github.com/getsentry/sentry-wizard/pull/1013))
8
+
9
+ ## 5.4.0
10
+
11
+ - feat: Introduce run build command and prompts in sourcemaps wizard ([#1024](https://github.com/getsentry/sentry-wizard/pull/1024))
12
+ - feat: Add a default build path for create-react-app in soucemaps wizard ([#1025](https://github.com/getsentry/sentry-wizard/pull/1025))
13
+
3
14
  ## 5.3.0
4
15
 
5
16
  - fix(react-native): Avoid importing `isPlainObject` from `@sentry/utils` ([#1023](https://github.com/getsentry/sentry-wizard/pull/1023))
@@ -96,7 +96,7 @@ async function runWizardOnAngularProject(projectDir, integration, fileModificati
96
96
  });
97
97
  const sourcemapsConfiguredPromise = wizardInstance.waitForOutput('Added a sentry:sourcemaps script to your package.json');
98
98
  const buildScriptPromptedPromise = wizardInstance.waitForOutput('Do you want to automatically run the sentry:sourcemaps script after each production build?');
99
- const optionalArtifactsNotFoundPromise = wizardInstance.waitForOutput("We couldn't find artifacts", {
99
+ const optionalArtifactsNotFoundPromise = wizardInstance.waitForOutput("We couldn't find build artifacts at", {
100
100
  optional: true,
101
101
  timeout: 5000,
102
102
  });
@@ -104,6 +104,12 @@ async function runWizardOnAngularProject(projectDir, integration, fileModificati
104
104
  wizardInstance.sendStdin(utils_1.KEYS.ENTER);
105
105
  const optionalArtifactsNotFoundPrompted = await optionalArtifactsNotFoundPromise;
106
106
  if (optionalArtifactsNotFoundPrompted) {
107
+ // The wizard now presents options when artifacts aren't found:
108
+ // - "Let the wizard run the build command"
109
+ // - "Enter a different path manually"
110
+ // - "Proceed anyway — I believe the path is correct"
111
+ // We want to select "Proceed anyway" (third option)
112
+ wizardInstance.sendStdin(utils_1.KEYS.DOWN);
107
113
  wizardInstance.sendStdin(utils_1.KEYS.DOWN);
108
114
  wizardInstance.sendStdin(utils_1.KEYS.ENTER);
109
115
  }
@@ -1 +1 @@
1
- {"version":3,"file":"angular-17.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/angular-17.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAkD;AAClD,oCAakB;AAClB,2CAA6B;AAC7B,oCAAqC;AACrC,mCAAqE;AAErE,iBAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,GAAG,EAAE;IACrC,IAAA,iBAAQ,EAAC,oBAAoB,EAAE,GAAG,EAAE;QAClC,MAAM,WAAW,GAAG,uBAAW,CAAC,OAAO,CAAC;QACxC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAC7B,SAAS,EACT,0CAA0C,CAC3C,CAAC;QAEF,IAAA,kBAAS,EAAC,KAAK,IAAI,EAAE;YACnB,IAAA,0BAAkB,EAAC,UAAU,CAAC,CAAC;YAC/B,MAAM,yBAAyB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;QAEH,IAAA,iBAAQ,EAAC,GAAG,EAAE;YACZ,IAAA,0BAAkB,EAAC,UAAU,CAAC,CAAC;YAC/B,IAAA,kBAAU,EAAC,UAAU,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,mBAAmB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,IAAA,iBAAQ,EAAC,+BAA+B,EAAE,GAAG,EAAE;QAC7C,MAAM,WAAW,GAAG,uBAAW,CAAC,OAAO,CAAC;QACxC,MAAM,UAAU,GAAG,IAAI,CAA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MAAM,IAAA,qBAAa,EAAC,UAAU,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC7C,MAAM,IAAA,6BAAqB,EACzB,UAAU,EACV,yCAAyC,CAC1C,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,IAAA,4BAAoB,EACxB,UAAU,EACV,yCAAyC,CAC1C,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Integration } from '../../lib/Constants';\nimport {\n checkFileContents,\n checkFileDoesNotContain,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n KEYS,\n modifyFile,\n revertLocalChanges,\n startWizardInstance,\n} from '../utils';\nimport * as path from 'path';\nimport { TEST_ARGS } from '../utils';\nimport { test, expect, describe, beforeAll, afterAll } from 'vitest';\n\ndescribe.sequential('Angular-17', () => {\n describe('with empty project', () => {\n const integration = Integration.angular;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/angular-17-test-app',\n );\n\n beforeAll(async () => {\n revertLocalChanges(projectDir);\n await runWizardOnAngularProject(projectDir, integration);\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkAngularProject(projectDir, integration);\n });\n\n describe('with pre-defined ErrorHandler', () => {\n const integration = Integration.angular;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/angular-17-test-app',\n );\n\n beforeAll(async () => {\n revertLocalChanges(projectDir);\n await runWizardOnAngularProject(projectDir, integration, (projectDir) => {\n modifyFile(`${projectDir}/src/app/app.config.ts`, {\n 'providers: [': `providers: [{\n provide: ErrorHandler,\n useValue: null\n },\n `,\n });\n });\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkAngularProject(projectDir, integration, {\n preExistingErrorHandler: true,\n });\n });\n});\n\nasync function runWizardOnAngularProject(\n projectDir: string,\n integration: Integration,\n fileModificationFn?: (projectDir: string) => unknown,\n) {\n const wizardInstance = startWizardInstance(integration, projectDir, true);\n\n if (fileModificationFn) {\n fileModificationFn(projectDir);\n\n await wizardInstance.waitForOutput('Do you want to continue anyway?');\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Please select your package manager.',\n );\n } else {\n await wizardInstance.waitForOutput('Please select your package manager.');\n }\n\n await wizardInstance.sendStdinAndWaitForOutput(\n // Selecting `yarn v1` as the package manager\n [KEYS.DOWN, KEYS.ENTER],\n // \"Do you want to enable Tracing\", sometimes doesn't work as `Tracing` can be printed in bold.\n 'to track the performance of your application?',\n {\n timeout: 240_000, // installing the sdk can take a while\n optional: true,\n },\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n // select \"Yes\" for tracing\n [KEYS.ENTER],\n // \"Do you want to enable Sentry Session Replay\", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.\n 'to get a video-like reproduction of errors during a user session?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n // select \"Yes\" for replay\n [KEYS.ENTER],\n 'Where are your build artifacts located?',\n {\n timeout: 240_000, // installing Sentry CLI can take a while\n },\n );\n\n const sourcemapsConfiguredPromise = wizardInstance.waitForOutput(\n 'Added a sentry:sourcemaps script to your package.json',\n );\n\n const buildScriptPromptedPromise = wizardInstance.waitForOutput(\n 'Do you want to automatically run the sentry:sourcemaps script after each production build?',\n );\n\n const optionalArtifactsNotFoundPromise = wizardInstance.waitForOutput(\n \"We couldn't find artifacts\",\n {\n optional: true,\n timeout: 5000,\n },\n );\n\n // ./dist is the default value, no need to change it\n wizardInstance.sendStdin(KEYS.ENTER);\n\n const optionalArtifactsNotFoundPrompted =\n await optionalArtifactsNotFoundPromise;\n\n if (optionalArtifactsNotFoundPrompted) {\n wizardInstance.sendStdin(KEYS.DOWN);\n wizardInstance.sendStdin(KEYS.ENTER);\n }\n\n await sourcemapsConfiguredPromise;\n\n await buildScriptPromptedPromise;\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, automatically add sentry:sourcemaps script\n 'Is yarn build your production build command?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, yarn build is the production build command\n 'Are you using a CI/CD tool to build and deploy your application?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.DOWN, KEYS.ENTER], // no CI/CD tool\n 'Do you want to create an example component to test your Sentry setup?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, create example component\n 'Did you apply the snippet above?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, applied the snippet\n 'Looks like you have Prettier in your project. Do you want to run it on your files?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, run prettier\n 'Successfully installed the Sentry Angular SDK!',\n );\n\n wizardInstance.kill();\n}\n\nfunction checkAngularProject(\n projectDir: string,\n integration: Integration,\n options?: {\n preExistingErrorHandler?: boolean;\n },\n) {\n test('package.json is updated correctly', () => {\n checkPackageJson(projectDir, integration);\n\n const packageJsonFile = path.resolve(projectDir, 'package.json');\n checkFileContents(packageJsonFile, [\n `\"sentry:sourcemaps\": \"sentry-cli sourcemaps inject --org ${TEST_ARGS.ORG_SLUG} --project ${TEST_ARGS.PROJECT_SLUG} ./dist && sentry-cli sourcemaps upload --org ${TEST_ARGS.ORG_SLUG} --project ${TEST_ARGS.PROJECT_SLUG} ./dist\"`,\n `\"build\": \"ng build && yarn sentry:sourcemaps\"`,\n ]);\n });\n\n test('Sentry is correctly injected into Angular app config', () => {\n const appConfigFile = path.resolve(projectDir, 'src/main.ts');\n checkFileExists(appConfigFile);\n\n checkFileContents(appConfigFile, [\n `import * as Sentry from '@sentry/angular'`,\n 'Sentry.init({',\n TEST_ARGS.PROJECT_DSN,\n 'Sentry.browserTracingIntegration()',\n 'Sentry.replayIntegration()',\n 'tracesSampleRate: 1',\n 'replaysSessionSampleRate: 0.1',\n 'replaysOnErrorSampleRate: 1',\n ]);\n });\n\n test('Sentry is correctly injected into Angular app module', () => {\n const appModuleFile = path.resolve(projectDir, 'src/app/app.config.ts');\n checkFileExists(appModuleFile);\n\n // Checking if the ErrorHandler is already present in the providers array,\n // and if it is, we skip adding it\n if (options?.preExistingErrorHandler) {\n checkFileDoesNotContain(appModuleFile, 'Sentry.createErrorHandler()');\n }\n\n checkFileContents(appModuleFile, [\n `import * as Sentry from '@sentry/angular'`,\n options?.preExistingErrorHandler\n ? `provide: ErrorHandler,\n useValue: null`\n : `provide: ErrorHandler,\n useValue: Sentry.createErrorHandler()`,\n `provide: Sentry.TraceService,\n deps: [Router]`,\n `provide: APP_INITIALIZER,\n useFactory: () => () => {},\n deps: [Sentry.TraceService],\n multi: true`,\n ]);\n });\n\n test('angular.json is updated correctly', async () => {\n const angularJsonFile = path.resolve(projectDir, 'angular.json');\n checkFileExists(angularJsonFile);\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const angularJson = (await import(angularJsonFile)) as Record<string, any>;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n for (const [, project] of Object.entries(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n angularJson.projects as Record<string, any>,\n )) {\n expect(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n project?.architect?.build?.configurations?.production?.sourceMap,\n ).toBe(true);\n }\n });\n\n test('builds successfully', async () => {\n await checkIfBuilds(projectDir);\n });\n\n test('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(\n projectDir,\n 'Application bundle generation complete.',\n );\n });\n\n test('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(\n projectDir,\n 'Application bundle generation complete.',\n );\n });\n}\n"]}
1
+ {"version":3,"file":"angular-17.test.js","sourceRoot":"","sources":["../../../e2e-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C;IACJ,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,IAAA,4BAAoB,EACxB,UAAU,EACV,yCAAyC,CAC1C,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Integration } from '../../lib/Constants';\nimport {\n checkFileContents,\n checkFileDoesNotContain,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n KEYS,\n modifyFile,\n revertLocalChanges,\n startWizardInstance,\n} from '../utils';\nimport * as path from 'path';\nimport { TEST_ARGS } from '../utils';\nimport { test, expect, describe, beforeAll, afterAll } from 'vitest';\n\ndescribe.sequential('Angular-17', () => {\n describe('with empty project', () => {\n const integration = Integration.angular;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/angular-17-test-app',\n );\n\n beforeAll(async () => {\n revertLocalChanges(projectDir);\n await runWizardOnAngularProject(projectDir, integration);\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkAngularProject(projectDir, integration);\n });\n\n describe('with pre-defined ErrorHandler', () => {\n const integration = Integration.angular;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/angular-17-test-app',\n );\n\n beforeAll(async () => {\n revertLocalChanges(projectDir);\n await runWizardOnAngularProject(projectDir, integration, (projectDir) => {\n modifyFile(`${projectDir}/src/app/app.config.ts`, {\n 'providers: [': `providers: [{\n provide: ErrorHandler,\n useValue: null\n },\n `,\n });\n });\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkAngularProject(projectDir, integration, {\n preExistingErrorHandler: true,\n });\n });\n});\n\nasync function runWizardOnAngularProject(\n projectDir: string,\n integration: Integration,\n fileModificationFn?: (projectDir: string) => unknown,\n) {\n const wizardInstance = startWizardInstance(integration, projectDir, true);\n\n if (fileModificationFn) {\n fileModificationFn(projectDir);\n\n await wizardInstance.waitForOutput('Do you want to continue anyway?');\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Please select your package manager.',\n );\n } else {\n await wizardInstance.waitForOutput('Please select your package manager.');\n }\n\n await wizardInstance.sendStdinAndWaitForOutput(\n // Selecting `yarn v1` as the package manager\n [KEYS.DOWN, KEYS.ENTER],\n // \"Do you want to enable Tracing\", sometimes doesn't work as `Tracing` can be printed in bold.\n 'to track the performance of your application?',\n {\n timeout: 240_000, // installing the sdk can take a while\n optional: true,\n },\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n // select \"Yes\" for tracing\n [KEYS.ENTER],\n // \"Do you want to enable Sentry Session Replay\", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.\n 'to get a video-like reproduction of errors during a user session?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n // select \"Yes\" for replay\n [KEYS.ENTER],\n 'Where are your build artifacts located?',\n {\n timeout: 240_000, // installing Sentry CLI can take a while\n },\n );\n\n const sourcemapsConfiguredPromise = wizardInstance.waitForOutput(\n 'Added a sentry:sourcemaps script to your package.json',\n );\n\n const buildScriptPromptedPromise = wizardInstance.waitForOutput(\n 'Do you want to automatically run the sentry:sourcemaps script after each production build?',\n );\n\n const optionalArtifactsNotFoundPromise = wizardInstance.waitForOutput(\n \"We couldn't find build artifacts at\",\n {\n optional: true,\n timeout: 5000,\n },\n );\n\n // ./dist is the default value, no need to change it\n wizardInstance.sendStdin(KEYS.ENTER);\n\n const optionalArtifactsNotFoundPrompted =\n await optionalArtifactsNotFoundPromise;\n\n if (optionalArtifactsNotFoundPrompted) {\n // The wizard now presents options when artifacts aren't found:\n // - \"Let the wizard run the build command\"\n // - \"Enter a different path manually\"\n // - \"Proceed anyway — I believe the path is correct\"\n // We want to select \"Proceed anyway\" (third option)\n wizardInstance.sendStdin(KEYS.DOWN);\n wizardInstance.sendStdin(KEYS.DOWN);\n wizardInstance.sendStdin(KEYS.ENTER);\n }\n\n await sourcemapsConfiguredPromise;\n\n await buildScriptPromptedPromise;\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, automatically add sentry:sourcemaps script\n 'Is yarn build your production build command?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, yarn build is the production build command\n 'Are you using a CI/CD tool to build and deploy your application?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.DOWN, KEYS.ENTER], // no CI/CD tool\n 'Do you want to create an example component to test your Sentry setup?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, create example component\n 'Did you apply the snippet above?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, applied the snippet\n 'Looks like you have Prettier in your project. Do you want to run it on your files?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, run prettier\n 'Successfully installed the Sentry Angular SDK!',\n );\n\n wizardInstance.kill();\n}\n\nfunction checkAngularProject(\n projectDir: string,\n integration: Integration,\n options?: {\n preExistingErrorHandler?: boolean;\n },\n) {\n test('package.json is updated correctly', () => {\n checkPackageJson(projectDir, integration);\n\n const packageJsonFile = path.resolve(projectDir, 'package.json');\n checkFileContents(packageJsonFile, [\n `\"sentry:sourcemaps\": \"sentry-cli sourcemaps inject --org ${TEST_ARGS.ORG_SLUG} --project ${TEST_ARGS.PROJECT_SLUG} ./dist && sentry-cli sourcemaps upload --org ${TEST_ARGS.ORG_SLUG} --project ${TEST_ARGS.PROJECT_SLUG} ./dist\"`,\n `\"build\": \"ng build && yarn sentry:sourcemaps\"`,\n ]);\n });\n\n test('Sentry is correctly injected into Angular app config', () => {\n const appConfigFile = path.resolve(projectDir, 'src/main.ts');\n checkFileExists(appConfigFile);\n\n checkFileContents(appConfigFile, [\n `import * as Sentry from '@sentry/angular'`,\n 'Sentry.init({',\n TEST_ARGS.PROJECT_DSN,\n 'Sentry.browserTracingIntegration()',\n 'Sentry.replayIntegration()',\n 'tracesSampleRate: 1',\n 'replaysSessionSampleRate: 0.1',\n 'replaysOnErrorSampleRate: 1',\n ]);\n });\n\n test('Sentry is correctly injected into Angular app module', () => {\n const appModuleFile = path.resolve(projectDir, 'src/app/app.config.ts');\n checkFileExists(appModuleFile);\n\n // Checking if the ErrorHandler is already present in the providers array,\n // and if it is, we skip adding it\n if (options?.preExistingErrorHandler) {\n checkFileDoesNotContain(appModuleFile, 'Sentry.createErrorHandler()');\n }\n\n checkFileContents(appModuleFile, [\n `import * as Sentry from '@sentry/angular'`,\n options?.preExistingErrorHandler\n ? `provide: ErrorHandler,\n useValue: null`\n : `provide: ErrorHandler,\n useValue: Sentry.createErrorHandler()`,\n `provide: Sentry.TraceService,\n deps: [Router]`,\n `provide: APP_INITIALIZER,\n useFactory: () => () => {},\n deps: [Sentry.TraceService],\n multi: true`,\n ]);\n });\n\n test('angular.json is updated correctly', async () => {\n const angularJsonFile = path.resolve(projectDir, 'angular.json');\n checkFileExists(angularJsonFile);\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const angularJson = (await import(angularJsonFile)) as Record<string, any>;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n for (const [, project] of Object.entries(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n angularJson.projects as Record<string, any>,\n )) {\n expect(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n project?.architect?.build?.configurations?.production?.sourceMap,\n ).toBe(true);\n }\n });\n\n test('builds successfully', async () => {\n await checkIfBuilds(projectDir);\n });\n\n test('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(\n projectDir,\n 'Application bundle generation complete.',\n );\n });\n\n test('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(\n projectDir,\n 'Application bundle generation complete.',\n );\n });\n}\n"]}
@@ -95,7 +95,7 @@ async function runWizardOnAngularProject(projectDir, integration, fileModificati
95
95
  });
96
96
  const sourcemapsConfiguredPromise = wizardInstance.waitForOutput('Added a sentry:sourcemaps script to your package.json');
97
97
  const buildScriptPromptedPromise = wizardInstance.waitForOutput('Do you want to automatically run the sentry:sourcemaps script after each production build?');
98
- const optionalArtifactsNotFoundPromise = wizardInstance.waitForOutput("We couldn't find artifacts", {
98
+ const optionalArtifactsNotFoundPromise = wizardInstance.waitForOutput("We couldn't find build artifacts at", {
99
99
  optional: true,
100
100
  timeout: 5000,
101
101
  });
@@ -103,6 +103,12 @@ async function runWizardOnAngularProject(projectDir, integration, fileModificati
103
103
  wizardInstance.sendStdin(utils_1.KEYS.ENTER);
104
104
  const optionalArtifactsNotFoundPrompted = await optionalArtifactsNotFoundPromise;
105
105
  if (optionalArtifactsNotFoundPrompted) {
106
+ // The wizard now presents options when artifacts aren't found:
107
+ // - "Let the wizard run the build command"
108
+ // - "Enter a different path manually"
109
+ // - "Proceed anyway — I believe the path is correct"
110
+ // We want to select "Proceed anyway" (third option)
111
+ wizardInstance.sendStdin(utils_1.KEYS.DOWN);
106
112
  wizardInstance.sendStdin(utils_1.KEYS.DOWN);
107
113
  wizardInstance.sendStdin(utils_1.KEYS.ENTER);
108
114
  }
@@ -1 +1 @@
1
- {"version":3,"file":"angular-19.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/angular-19.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAkD;AAClD,oCAakB;AAClB,2CAA6B;AAC7B,oCAAqC;AACrC,mCAAqE;AAErE,iBAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,GAAG,EAAE;IACrC,IAAA,iBAAQ,EAAC,oBAAoB,EAAE,GAAG,EAAE;QAClC,MAAM,WAAW,GAAG,uBAAW,CAAC,OAAO,CAAC;QACxC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAC7B,SAAS,EACT,0CAA0C,CAC3C,CAAC;QAEF,IAAA,kBAAS,EAAC,KAAK,IAAI,EAAE;YACnB,IAAA,0BAAkB,EAAC,UAAU,CAA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D,MAAM,WAAW,GAAG,CAAC,MAAM,MAAM,CAAC,eAAe,CAAC,CAAwB,CAAC;QAE3E,8DAA8D;QAC9D,KAAK,MAAM,CAAC,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO;QACtC,8DAA8D;QAC9D,WAAW,CAAC,QAA+B,CAC5C,EAAE;YACD,IAAA,eAAM;YACJ,sEAAsE;YACtE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,CACjE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACd;IACH,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACrC,MAAM,IAAA,qBAAa,EAAC,UAAU,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC7C,MAAM,IAAA,6BAAqB,EACzB,UAAU,EACV,yCAAyC,CAC1C,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,IAAA,4BAAoB,EACxB,UAAU,EACV,yCAAyC,CAC1C,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Integration } from '../../lib/Constants';\nimport {\n checkFileContents,\n checkFileDoesNotContain,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n KEYS,\n modifyFile,\n revertLocalChanges,\n startWizardInstance,\n} from '../utils';\nimport * as path from 'path';\nimport { TEST_ARGS } from '../utils';\nimport { test, expect, describe, beforeAll, afterAll } from 'vitest';\n\ndescribe.sequential('Angular-19', () => {\n describe('with empty project', () => {\n const integration = Integration.angular;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/angular-19-test-app',\n );\n\n beforeAll(async () => {\n revertLocalChanges(projectDir);\n await runWizardOnAngularProject(projectDir, integration);\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkAngularProject(projectDir, integration);\n });\n describe('with pre-defined ErrorHandler', () => {\n const integration = Integration.angular;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/angular-19-test-app',\n );\n\n beforeAll(async () => {\n revertLocalChanges(projectDir);\n await runWizardOnAngularProject(projectDir, integration, (projectDir) => {\n modifyFile(`${projectDir}/src/app/app.config.ts`, {\n 'providers: [': `providers: [{\n provide: ErrorHandler,\n useValue: null\n },\n `,\n });\n });\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkAngularProject(projectDir, integration, {\n preExistingErrorHandler: true,\n });\n });\n});\n\nasync function runWizardOnAngularProject(\n projectDir: string,\n integration: Integration,\n fileModificationFn?: (projectDir: string) => unknown,\n) {\n const wizardInstance = startWizardInstance(integration, projectDir, true);\n\n if (fileModificationFn) {\n fileModificationFn(projectDir);\n\n await wizardInstance.waitForOutput('Do you want to continue anyway?');\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Please select your package manager.',\n );\n } else {\n await wizardInstance.waitForOutput('Please select your package manager.');\n }\n\n await wizardInstance.sendStdinAndWaitForOutput(\n // Selecting `yarn` as the package manager\n [KEYS.DOWN, KEYS.ENTER],\n // \"Do you want to enable Tracing\", sometimes doesn't work as `Tracing` can be printed in bold.\n 'to track the performance of your application?',\n {\n timeout: 240_000,\n optional: true,\n },\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n // \"Do you want to enable Sentry Session Replay\", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.\n 'to get a video-like reproduction of errors during a user session?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n // The first choice here is Angular\n [KEYS.ENTER],\n 'Where are your build artifacts located?',\n {\n optional: true,\n timeout: 5000,\n },\n );\n\n const sourcemapsConfiguredPromise = wizardInstance.waitForOutput(\n 'Added a sentry:sourcemaps script to your package.json',\n );\n\n const buildScriptPromptedPromise = wizardInstance.waitForOutput(\n 'Do you want to automatically run the sentry:sourcemaps script after each production build?',\n );\n\n const optionalArtifactsNotFoundPromise = wizardInstance.waitForOutput(\n \"We couldn't find artifacts\",\n {\n optional: true,\n timeout: 5000,\n },\n );\n\n // ./dist is the default value, no need to change it\n wizardInstance.sendStdin(KEYS.ENTER);\n\n const optionalArtifactsNotFoundPrompted =\n await optionalArtifactsNotFoundPromise;\n\n if (optionalArtifactsNotFoundPrompted) {\n wizardInstance.sendStdin(KEYS.DOWN);\n wizardInstance.sendStdin(KEYS.ENTER);\n }\n\n await sourcemapsConfiguredPromise;\n await buildScriptPromptedPromise;\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, automatically add sentry:sourcemaps script\n 'Is yarn build your production build command?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, yarn build is the production build command\n 'Are you using a CI/CD tool to build and deploy your application?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.DOWN, KEYS.ENTER], // no CI/CD tool\n 'Do you want to create an example component to test your Sentry setup?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, create example component\n 'Did you apply the snippet above?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, applied the snippet\n 'Looks like you have Prettier in your project. Do you want to run it on your files?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, run prettier\n 'Successfully installed the Sentry Angular SDK!',\n );\n\n wizardInstance.kill();\n}\n\nfunction checkAngularProject(\n projectDir: string,\n integration: Integration,\n options?: {\n preExistingErrorHandler?: boolean;\n },\n) {\n test('package.json is updated correctly', () => {\n checkPackageJson(projectDir, integration);\n\n const packageJsonFile = path.resolve(projectDir, 'package.json');\n checkFileContents(packageJsonFile, [\n `\"sentry:sourcemaps\": \"sentry-cli sourcemaps inject --org ${TEST_ARGS.ORG_SLUG} --project ${TEST_ARGS.PROJECT_SLUG} ./dist && sentry-cli sourcemaps upload --org ${TEST_ARGS.ORG_SLUG} --project ${TEST_ARGS.PROJECT_SLUG} ./dist\"`,\n `\"build\": \"ng build && yarn sentry:sourcemaps\"`,\n ]);\n });\n\n test('Sentry is correctly injected into Angular app config', () => {\n const appConfigFile = path.resolve(projectDir, 'src/main.ts');\n checkFileExists(appConfigFile);\n\n checkFileContents(appConfigFile, [\n `import * as Sentry from '@sentry/angular'`,\n 'Sentry.init({',\n TEST_ARGS.PROJECT_DSN,\n 'Sentry.browserTracingIntegration()',\n 'Sentry.replayIntegration()',\n 'tracesSampleRate: 1',\n 'replaysSessionSampleRate: 0.1',\n 'replaysOnErrorSampleRate: 1',\n ]);\n });\n\n test('Sentry is correctly injected into Angular app module', () => {\n const appModuleFile = path.resolve(projectDir, 'src/app/app.config.ts');\n checkFileExists(appModuleFile);\n\n // Checking if the ErrorHandler is already present in the providers array,\n // and if it is, we skip adding it\n if (options?.preExistingErrorHandler) {\n checkFileDoesNotContain(appModuleFile, 'Sentry.createErrorHandler()');\n }\n\n checkFileContents(appModuleFile, [\n `import * as Sentry from '@sentry/angular'`,\n options?.preExistingErrorHandler\n ? `provide: ErrorHandler,\n useValue: null`\n : `provide: ErrorHandler,\n useValue: Sentry.createErrorHandler()`,\n `provide: Sentry.TraceService,\n deps: [Router]`,\n `provideAppInitializer(() => {\n inject(Sentry.TraceService);\n })`,\n ]);\n });\n\n test('angular.json is updated correctly', async () => {\n const angularJsonFile = path.resolve(projectDir, 'angular.json');\n checkFileExists(angularJsonFile);\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const angularJson = (await import(angularJsonFile)) as Record<string, any>;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n for (const [, project] of Object.entries(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n angularJson.projects as Record<string, any>,\n )) {\n expect(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n project?.architect?.build?.configurations?.production?.sourceMap,\n ).toBe(true);\n }\n });\n\n test('builds successfully', async () => {\n await checkIfBuilds(projectDir);\n });\n\n test('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(\n projectDir,\n 'Application bundle generation complete.',\n );\n });\n\n test('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(\n projectDir,\n 'Application bundle generation complete.',\n );\n });\n}\n"]}
1
+ {"version":3,"file":"angular-19.test.js","sourceRoot":"","sources":["../../../e2e-tests/tests/angular-19.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAkD;AAClD,oCAakB;AAClB,2CAA6B;AAC7B,oCAAqC;AACrC,mCAAqE;AAErE,iBAAQ,CAAC,UAAU,CAAC,YAAY,EAAE,GAAG,EAAE;IACrC,IAAA,iBAAQ,EAAC,oBAAoB,EAAE,GAAG,EAAE;QAClC,MAAM,WAAW,GAAG,uBAAW,CAAC,OAAO,CAAC;QACxC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAC7B,SAAS,EACT,0CAA0C,CAC3C,CAAC;QAEF,IAAA,kBAAS,EAAC,KAAK,IAAI,EAAE;YACnB,IAAA,0BAAkB,EAAC,UAAU,CAAC,CAAC;YAC/B,MAAM,yBAAyB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;QAEH,IAAA,iBAAQ,EAAC,GAAG,EAAE;YACZ,IAAA,0BAAkB,EAAC,UAAU,CAAC,CAAC;YAC/B,IAAA,kBAAU,EAAC,UAAU,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,mBAAmB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IACH,IAAA,iBAAQ,EAAC,+BAA+B,EAAE,GAAG,EAAE;QAC7C,MAAM,WAAW,GAAG,uBAAW,CAAC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EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,CACjE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACd;IACH,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;QACrC,MAAM,IAAA,qBAAa,EAAC,UAAU,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC7C,MAAM,IAAA,6BAAqB,EACzB,UAAU,EACV,yCAAyC,CAC1C,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAA,aAAI,EAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;QAC5C,MAAM,IAAA,4BAAoB,EACxB,UAAU,EACV,yCAAyC,CAC1C,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Integration } from '../../lib/Constants';\nimport {\n checkFileContents,\n checkFileDoesNotContain,\n checkFileExists,\n checkIfBuilds,\n checkIfRunsOnDevMode,\n checkIfRunsOnProdMode,\n checkPackageJson,\n cleanupGit,\n KEYS,\n modifyFile,\n revertLocalChanges,\n startWizardInstance,\n} from '../utils';\nimport * as path from 'path';\nimport { TEST_ARGS } from '../utils';\nimport { test, expect, describe, beforeAll, afterAll } from 'vitest';\n\ndescribe.sequential('Angular-19', () => {\n describe('with empty project', () => {\n const integration = Integration.angular;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/angular-19-test-app',\n );\n\n beforeAll(async () => {\n revertLocalChanges(projectDir);\n await runWizardOnAngularProject(projectDir, integration);\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkAngularProject(projectDir, integration);\n });\n describe('with pre-defined ErrorHandler', () => {\n const integration = Integration.angular;\n const projectDir = path.resolve(\n __dirname,\n '../test-applications/angular-19-test-app',\n );\n\n beforeAll(async () => {\n revertLocalChanges(projectDir);\n await runWizardOnAngularProject(projectDir, integration, (projectDir) => {\n modifyFile(`${projectDir}/src/app/app.config.ts`, {\n 'providers: [': `providers: [{\n provide: ErrorHandler,\n useValue: null\n },\n `,\n });\n });\n });\n\n afterAll(() => {\n revertLocalChanges(projectDir);\n cleanupGit(projectDir);\n });\n\n checkAngularProject(projectDir, integration, {\n preExistingErrorHandler: true,\n });\n });\n});\n\nasync function runWizardOnAngularProject(\n projectDir: string,\n integration: Integration,\n fileModificationFn?: (projectDir: string) => unknown,\n) {\n const wizardInstance = startWizardInstance(integration, projectDir, true);\n\n if (fileModificationFn) {\n fileModificationFn(projectDir);\n\n await wizardInstance.waitForOutput('Do you want to continue anyway?');\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n 'Please select your package manager.',\n );\n } else {\n await wizardInstance.waitForOutput('Please select your package manager.');\n }\n\n await wizardInstance.sendStdinAndWaitForOutput(\n // Selecting `yarn` as the package manager\n [KEYS.DOWN, KEYS.ENTER],\n // \"Do you want to enable Tracing\", sometimes doesn't work as `Tracing` can be printed in bold.\n 'to track the performance of your application?',\n {\n timeout: 240_000,\n optional: true,\n },\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER],\n // \"Do you want to enable Sentry Session Replay\", sometimes doesn't work as `Sentry Session Replay` can be printed in bold.\n 'to get a video-like reproduction of errors during a user session?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n // The first choice here is Angular\n [KEYS.ENTER],\n 'Where are your build artifacts located?',\n {\n optional: true,\n timeout: 5000,\n },\n );\n\n const sourcemapsConfiguredPromise = wizardInstance.waitForOutput(\n 'Added a sentry:sourcemaps script to your package.json',\n );\n\n const buildScriptPromptedPromise = wizardInstance.waitForOutput(\n 'Do you want to automatically run the sentry:sourcemaps script after each production build?',\n );\n\n const optionalArtifactsNotFoundPromise = wizardInstance.waitForOutput(\n \"We couldn't find build artifacts at\",\n {\n optional: true,\n timeout: 5000,\n },\n );\n\n // ./dist is the default value, no need to change it\n wizardInstance.sendStdin(KEYS.ENTER);\n\n const optionalArtifactsNotFoundPrompted =\n await optionalArtifactsNotFoundPromise;\n\n if (optionalArtifactsNotFoundPrompted) {\n // The wizard now presents options when artifacts aren't found:\n // - \"Let the wizard run the build command\"\n // - \"Enter a different path manually\"\n // - \"Proceed anyway — I believe the path is correct\"\n // We want to select \"Proceed anyway\" (third option)\n wizardInstance.sendStdin(KEYS.DOWN);\n wizardInstance.sendStdin(KEYS.DOWN);\n wizardInstance.sendStdin(KEYS.ENTER);\n }\n\n await sourcemapsConfiguredPromise;\n await buildScriptPromptedPromise;\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, automatically add sentry:sourcemaps script\n 'Is yarn build your production build command?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, yarn build is the production build command\n 'Are you using a CI/CD tool to build and deploy your application?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.DOWN, KEYS.ENTER], // no CI/CD tool\n 'Do you want to create an example component to test your Sentry setup?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, create example component\n 'Did you apply the snippet above?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, applied the snippet\n 'Looks like you have Prettier in your project. Do you want to run it on your files?',\n );\n\n await wizardInstance.sendStdinAndWaitForOutput(\n [KEYS.ENTER], // yes, run prettier\n 'Successfully installed the Sentry Angular SDK!',\n );\n\n wizardInstance.kill();\n}\n\nfunction checkAngularProject(\n projectDir: string,\n integration: Integration,\n options?: {\n preExistingErrorHandler?: boolean;\n },\n) {\n test('package.json is updated correctly', () => {\n checkPackageJson(projectDir, integration);\n\n const packageJsonFile = path.resolve(projectDir, 'package.json');\n checkFileContents(packageJsonFile, [\n `\"sentry:sourcemaps\": \"sentry-cli sourcemaps inject --org ${TEST_ARGS.ORG_SLUG} --project ${TEST_ARGS.PROJECT_SLUG} ./dist && sentry-cli sourcemaps upload --org ${TEST_ARGS.ORG_SLUG} --project ${TEST_ARGS.PROJECT_SLUG} ./dist\"`,\n `\"build\": \"ng build && yarn sentry:sourcemaps\"`,\n ]);\n });\n\n test('Sentry is correctly injected into Angular app config', () => {\n const appConfigFile = path.resolve(projectDir, 'src/main.ts');\n checkFileExists(appConfigFile);\n\n checkFileContents(appConfigFile, [\n `import * as Sentry from '@sentry/angular'`,\n 'Sentry.init({',\n TEST_ARGS.PROJECT_DSN,\n 'Sentry.browserTracingIntegration()',\n 'Sentry.replayIntegration()',\n 'tracesSampleRate: 1',\n 'replaysSessionSampleRate: 0.1',\n 'replaysOnErrorSampleRate: 1',\n ]);\n });\n\n test('Sentry is correctly injected into Angular app module', () => {\n const appModuleFile = path.resolve(projectDir, 'src/app/app.config.ts');\n checkFileExists(appModuleFile);\n\n // Checking if the ErrorHandler is already present in the providers array,\n // and if it is, we skip adding it\n if (options?.preExistingErrorHandler) {\n checkFileDoesNotContain(appModuleFile, 'Sentry.createErrorHandler()');\n }\n\n checkFileContents(appModuleFile, [\n `import * as Sentry from '@sentry/angular'`,\n options?.preExistingErrorHandler\n ? `provide: ErrorHandler,\n useValue: null`\n : `provide: ErrorHandler,\n useValue: Sentry.createErrorHandler()`,\n `provide: Sentry.TraceService,\n deps: [Router]`,\n `provideAppInitializer(() => {\n inject(Sentry.TraceService);\n })`,\n ]);\n });\n\n test('angular.json is updated correctly', async () => {\n const angularJsonFile = path.resolve(projectDir, 'angular.json');\n checkFileExists(angularJsonFile);\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const angularJson = (await import(angularJsonFile)) as Record<string, any>;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n for (const [, project] of Object.entries(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n angularJson.projects as Record<string, any>,\n )) {\n expect(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n project?.architect?.build?.configurations?.production?.sourceMap,\n ).toBe(true);\n }\n });\n\n test('builds successfully', async () => {\n await checkIfBuilds(projectDir);\n });\n\n test('runs on prod mode correctly', async () => {\n await checkIfRunsOnProdMode(\n projectDir,\n 'Application bundle generation complete.',\n );\n });\n\n test('runs on dev mode correctly', async () => {\n await checkIfRunsOnDevMode(\n projectDir,\n 'Application bundle generation complete.',\n );\n });\n}\n"]}
@@ -54,8 +54,7 @@ originalEntryServerMod, serverEntryFilename) {
54
54
  !handleErrorFunctionVariableDeclarationExport) {
55
55
  prompts_1.default.log.warn(`Could not find function ${chalk_1.default.cyan('handleError')} in ${chalk_1.default.cyan(serverEntryFilename)}. Creating one for you.`);
56
56
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
57
- const implementation = recast.parse(templates_1.HANDLE_ERROR_TEMPLATE_V2).program
58
- .body[0];
57
+ const implementation = recast.parse(templates_1.HANDLE_ERROR_TEMPLATE).program.body[0];
59
58
  originalEntryServerModAST.body.splice((0, utils_1.getAfterImportsInsertionIndex)(originalEntryServerModAST), 0,
60
59
  // @ts-expect-error - string works here because the AST is proxified by magicast
61
60
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
@@ -69,8 +68,7 @@ originalEntryServerMod, serverEntryFilename) {
69
68
  }
70
69
  else if (handleErrorFunctionExport) {
71
70
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
72
- const implementation = recast.parse(templates_1.HANDLE_ERROR_TEMPLATE_V2).program
73
- .body[0];
71
+ const implementation = recast.parse(templates_1.HANDLE_ERROR_TEMPLATE).program.body[0];
74
72
  // If the current handleError function has a body, we need to merge the new implementation with the existing one
75
73
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
76
74
  implementation.declarations[0].init.arguments[0].body.body.unshift(
@@ -82,8 +80,7 @@ originalEntryServerMod, serverEntryFilename) {
82
80
  }
83
81
  else if (handleErrorFunctionVariableDeclarationExport) {
84
82
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
85
- const implementation = recast.parse(templates_1.HANDLE_ERROR_TEMPLATE_V2).program
86
- .body[0];
83
+ const implementation = recast.parse(templates_1.HANDLE_ERROR_TEMPLATE).program.body[0];
87
84
  // If the current handleError function has a body, we need to merge the new implementation with the existing one
88
85
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
89
86
  implementation.declarations[0].init.arguments[0].body.body.unshift(
@@ -1 +1 @@
1
- {"version":3,"file":"handle-error.js","sourceRoot":"","sources":["../../../../src/remix/codemods/handle-error.ts"],"names":[],"mappings":";AAAA,4DAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAM5D,+CAAiC;AAEjC,4CAAwD;AACxD,oCAA2E;AAE3E,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAE1B,kFAAkF;AAClF,uCAAwC;AAExC,SAAgB,qBAAqB;AACnC,iFAAiF;AACjF,8DAA8D;AAC9D,sBAA4C,EAC5C,mBAA2B;IAE3B,MAAM,yBAAyB,GAAG,sBAAsB,CAAC,IAAe,CAAC;IAEzE,MAAM,yBAAyB,GAAG,yBAAyB,CAAC,IAAI,CAAC,IAAI,CACnE,CAAC,IAAI,EAAE,EAAE;QACP,OAAO,CACL,IAAI,CAAC,IAAI,KAAK,wBAAwB;YACtC,IAAI,CAAC,WAAW,EAAE,IAAI,KAAK,qBAAqB;YAChD,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,IAAI,KAAK,aAAa,CAC5C,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,MAAM,4CAA4C,GAChD,yBAAyB,CAAC,IAAI,CAAC,IAAI,CACjC,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,CAAC,IAAI,KAAK,wBAAwB;QACtC,IAAI,CAAC,WAAW,EAAE,IAAI,KAAK,qBAAqB;QAChD,+DAA+D;QAC/D,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,KAAK,aAAa,CAC7D,CAAC;IAEJ,IACE,CAAC,yBAAy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AAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO;QAChE,qFAAqF;QACrF,sEAAsE;QACtE,GAAG,yBAAyB,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CACnD,CAAC;QAEF,qFAAqF;QACrF,yBAAyB,CAAC,WAAW,GAAG,cAAc,CAAC;KACxD;SAAM,IAAI,4CAA4C,EAAE;QACvD,sEAAsE;QACtE,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,oCAAwB,CAAC,CAAC,OAAO;aAClE,IAAI,CAAC,CAAC,CAAC,CAAC;QAEX,gHAAgH;QAChH,yGAAyG;QACzG,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO;QAChE,qFAAqF;QACrF,sEAAsE;QACtE,GAAG,4CAA4C,CAAC,WAAW;aACxD,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAClC,CAAC;QAEF,qFAAqF;QACrF,4CAA4C,CAAC,WAAW,GAAG,cAAc,CAAC;KAC3E;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AArGD,sDAqGC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport type { ProxifiedModule } from 'magicast';\nimport type { Program } from '@babel/types';\n\nimport * as recast from 'recast';\n\nimport { HANDLE_ERROR_TEMPLATE_V2 } from '../templates';\nimport { getAfterImportsInsertionIndex, hasSentryContent } from '../utils';\n\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode } from 'magicast';\n\nexport function instrumentHandleError(\n // MagicAst returns `ProxifiedModule<any>` so therefore we have to use `any` here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalEntryServerMod: ProxifiedModule<any>,\n serverEntryFilename: string,\n): boolean {\n const originalEntryServerModAST = originalEntryServerMod.$ast as Program;\n\n const handleErrorFunctionExport = originalEntryServerModAST.body.find(\n (node) => {\n return (\n node.type === 'ExportNamedDeclaration' &&\n node.declaration?.type === 'FunctionDeclaration' &&\n node.declaration.id?.name === 'handleError'\n );\n },\n );\n\n const handleErrorFunctionVariableDeclarationExport =\n originalEntryServerModAST.body.find(\n (node) =>\n node.type === 'ExportNamedDeclaration' &&\n node.declaration?.type === 'VariableDeclaration' &&\n // @ts-expect-error - id should always have a name in this case\n node.declaration.declarations[0].id.name === 'handleError',\n );\n\n if (\n !handleErrorFunctionExport &&\n !handleErrorFunctionVariableDeclarationExport\n ) {\n clack.log.warn(\n `Could not find function ${chalk.cyan('handleError')} in ${chalk.cyan(\n serverEntryFilename,\n )}. Creating one for you.`,\n );\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const implementation = recast.parse(HANDLE_ERROR_TEMPLATE_V2).program\n .body[0];\n\n originalEntryServerModAST.body.splice(\n getAfterImportsInsertionIndex(originalEntryServerModAST),\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n recast.types.builders.exportNamedDeclaration(implementation),\n );\n } else if (\n (handleErrorFunctionExport &&\n ['wrapHandleErrorWithSentry', 'sentryHandleError'].some((util) =>\n hasSentryContent(\n generateCode(handleErrorFunctionExport).code,\n originalEntryServerMod.$code,\n util,\n ),\n )) ||\n (handleErrorFunctionVariableDeclarationExport &&\n ['wrapHandleErrorWithSentry', 'sentryHandleError'].some((util) =>\n hasSentryContent(\n generateCode(handleErrorFunctionVariableDeclarationExport).code,\n originalEntryServerMod.$code,\n util,\n ),\n ))\n ) {\n return false;\n } else if (handleErrorFunctionExport) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const implementation = recast.parse(HANDLE_ERROR_TEMPLATE_V2).program\n .body[0];\n\n // If the current handleError function has a body, we need to merge the new implementation with the existing one\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n implementation.declarations[0].init.arguments[0].body.body.unshift(\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ...handleErrorFunctionExport.declaration.body.body,\n );\n\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n handleErrorFunctionExport.declaration = implementation;\n } else if (handleErrorFunctionVariableDeclarationExport) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const implementation = recast.parse(HANDLE_ERROR_TEMPLATE_V2).program\n .body[0];\n\n // If the current handleError function has a body, we need to merge the new implementation with the existing one\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n implementation.declarations[0].init.arguments[0].body.body.unshift(\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ...handleErrorFunctionVariableDeclarationExport.declaration\n .declarations[0].init.body.body,\n );\n\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n handleErrorFunctionVariableDeclarationExport.declaration = implementation;\n }\n\n return true;\n}\n"]}
1
+ {"version":3,"file":"handle-error.js","sourceRoot":"","sources":["../../../../src/remix/codemods/handle-error.ts"],"names":[],"mappings":";AAAA,4DAA4D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAM5D,+CAAiC;AAEjC,4CAAqD;AACrD,oCAA2E;AAE3E,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAE1B,kFAAkF;AAClF,uCAAwC;AAExC,SAAgB,qBAAqB;AACnC,iFAAiF;AACjF,8DAA8D;AAC9D,sBAA4C,EAC5C,mBAA2B;IAE3B,MAAM,yBAAyB,GAAG,sBAAsB,CAAC,IAAe,CAAC;IAEzE,MAAM,yBAAyB,GAAG,yBAAyB,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C,IAAI,CAAC,IAAI,CAClC,CAAC;QAEF,qFAAqF;QACrF,4CAA4C,CAAC,WAAW,GAAG,cAAc,CAAC;KAC3E;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAlGD,sDAkGC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport type { ProxifiedModule } from 'magicast';\nimport type { Program } from '@babel/types';\n\nimport * as recast from 'recast';\n\nimport { HANDLE_ERROR_TEMPLATE } from '../templates';\nimport { getAfterImportsInsertionIndex, hasSentryContent } from '../utils';\n\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode } from 'magicast';\n\nexport function instrumentHandleError(\n // MagicAst returns `ProxifiedModule<any>` so therefore we have to use `any` here\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n originalEntryServerMod: ProxifiedModule<any>,\n serverEntryFilename: string,\n): boolean {\n const originalEntryServerModAST = originalEntryServerMod.$ast as Program;\n\n const handleErrorFunctionExport = originalEntryServerModAST.body.find(\n (node) => {\n return (\n node.type === 'ExportNamedDeclaration' &&\n node.declaration?.type === 'FunctionDeclaration' &&\n node.declaration.id?.name === 'handleError'\n );\n },\n );\n\n const handleErrorFunctionVariableDeclarationExport =\n originalEntryServerModAST.body.find(\n (node) =>\n node.type === 'ExportNamedDeclaration' &&\n node.declaration?.type === 'VariableDeclaration' &&\n // @ts-expect-error - id should always have a name in this case\n node.declaration.declarations[0].id.name === 'handleError',\n );\n\n if (\n !handleErrorFunctionExport &&\n !handleErrorFunctionVariableDeclarationExport\n ) {\n clack.log.warn(\n `Could not find function ${chalk.cyan('handleError')} in ${chalk.cyan(\n serverEntryFilename,\n )}. Creating one for you.`,\n );\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const implementation = recast.parse(HANDLE_ERROR_TEMPLATE).program.body[0];\n\n originalEntryServerModAST.body.splice(\n getAfterImportsInsertionIndex(originalEntryServerModAST),\n 0,\n // @ts-expect-error - string works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n recast.types.builders.exportNamedDeclaration(implementation),\n );\n } else if (\n (handleErrorFunctionExport &&\n ['wrapHandleErrorWithSentry', 'sentryHandleError'].some((util) =>\n hasSentryContent(\n generateCode(handleErrorFunctionExport).code,\n originalEntryServerMod.$code,\n util,\n ),\n )) ||\n (handleErrorFunctionVariableDeclarationExport &&\n ['wrapHandleErrorWithSentry', 'sentryHandleError'].some((util) =>\n hasSentryContent(\n generateCode(handleErrorFunctionVariableDeclarationExport).code,\n originalEntryServerMod.$code,\n util,\n ),\n ))\n ) {\n return false;\n } else if (handleErrorFunctionExport) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const implementation = recast.parse(HANDLE_ERROR_TEMPLATE).program.body[0];\n\n // If the current handleError function has a body, we need to merge the new implementation with the existing one\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n implementation.declarations[0].init.arguments[0].body.body.unshift(\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ...handleErrorFunctionExport.declaration.body.body,\n );\n\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n handleErrorFunctionExport.declaration = implementation;\n } else if (handleErrorFunctionVariableDeclarationExport) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const implementation = recast.parse(HANDLE_ERROR_TEMPLATE).program.body[0];\n\n // If the current handleError function has a body, we need to merge the new implementation with the existing one\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call\n implementation.declarations[0].init.arguments[0].body.body.unshift(\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n ...handleErrorFunctionVariableDeclarationExport.declaration\n .declarations[0].init.body.body,\n );\n\n // @ts-expect-error - declaration works here because the AST is proxified by magicast\n handleErrorFunctionVariableDeclarationExport.declaration = implementation;\n }\n\n return true;\n}\n"]}
@@ -1,2 +1,3 @@
1
1
  import { ProxifiedModule } from 'magicast';
2
2
  export declare function wrapAppWithSentry(rootRouteAst: ProxifiedModule, rootFileName: string): void;
3
+ export declare function instrumentRoot(rootFileName: string): Promise<void>;
@@ -1,8 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
3
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
4
- /* eslint-disable @typescript-eslint/no-unsafe-call */
5
- /* eslint-disable @typescript-eslint/no-unsafe-argument */
6
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
3
  if (k2 === undefined) k2 = k;
8
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -26,16 +22,55 @@ var __importStar = (this && this.__importStar) || function (mod) {
26
22
  __setModuleDefault(result, mod);
27
23
  return result;
28
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
29
28
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.instrumentRootRouteV2 = void 0;
29
+ exports.instrumentRoot = exports.wrapAppWithSentry = void 0;
30
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
31
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
32
+ /* eslint-disable @typescript-eslint/no-unsafe-call */
33
+ /* eslint-disable @typescript-eslint/no-unsafe-argument */
31
34
  const recast = __importStar(require("recast"));
32
35
  const path = __importStar(require("path"));
33
- // @ts-expect-error - magicast is ESM and TS complains about that. It works though
34
36
  const magicast_1 = require("magicast");
35
37
  const templates_1 = require("../templates");
36
38
  const utils_1 = require("../utils");
37
- const root_common_1 = require("./root-common");
38
- async function instrumentRootRouteV2(rootFileName) {
39
+ const chalk_1 = __importDefault(require("chalk"));
40
+ // @ts-expect-error - clack is ESM and TS complains about that. It works though
41
+ const clack = __importStar(require("@clack/prompts"));
42
+ function wrapAppWithSentry(rootRouteAst, rootFileName) {
43
+ rootRouteAst.imports.$add({
44
+ from: '@sentry/remix',
45
+ imported: 'withSentry',
46
+ local: 'withSentry',
47
+ });
48
+ recast.visit(rootRouteAst.$ast, {
49
+ visitExportDefaultDeclaration(path) {
50
+ if (path.value.declaration.type === 'FunctionDeclaration') {
51
+ // Move the function declaration just before the default export
52
+ path.insertBefore(path.value.declaration);
53
+ // Get the name of the function to be wrapped
54
+ const functionName = path.value.declaration.id.name;
55
+ // Create the wrapped function call
56
+ const functionCall = recast.types.builders.callExpression(recast.types.builders.identifier('withSentry'), [recast.types.builders.identifier(functionName)]);
57
+ // Replace the default export with the wrapped function call
58
+ path.value.declaration = functionCall;
59
+ }
60
+ else if (path.value.declaration.type === 'Identifier') {
61
+ const rootRouteExport = rootRouteAst.exports.default;
62
+ const expressionToWrap = (0, magicast_1.generateCode)(rootRouteExport.$ast).code;
63
+ rootRouteAst.exports.default = magicast_1.builders.raw(`withSentry(${expressionToWrap})`);
64
+ }
65
+ else {
66
+ clack.log.warn(chalk_1.default.yellow(`Couldn't instrument ${chalk_1.default.bold(rootFileName)} automatically. Wrap your default export with: ${chalk_1.default.dim('withSentry()')}\n`));
67
+ }
68
+ this.traverse(path);
69
+ },
70
+ });
71
+ }
72
+ exports.wrapAppWithSentry = wrapAppWithSentry;
73
+ async function instrumentRoot(rootFileName) {
39
74
  const rootRouteAst = await (0, magicast_1.loadFile)(path.join(process.cwd(), 'app', rootFileName));
40
75
  const exportsAst = rootRouteAst.exports.$ast;
41
76
  const namedExports = exportsAst.body.filter((node) => node.type === 'ExportNamedDeclaration');
@@ -73,7 +108,7 @@ async function instrumentRootRouteV2(rootFileName) {
73
108
  });
74
109
  recast.visit(rootRouteAst.$ast, {
75
110
  visitExportDefaultDeclaration(path) {
76
- const implementation = recast.parse(templates_1.ERROR_BOUNDARY_TEMPLATE_V2).program
111
+ const implementation = recast.parse(templates_1.ERROR_BOUNDARY_TEMPLATE).program
77
112
  .body[0];
78
113
  path.insertBefore(recast.types.builders.exportDeclaration(false, implementation));
79
114
  this.traverse(path);
@@ -87,7 +122,7 @@ async function instrumentRootRouteV2(rootFileName) {
87
122
  imported: 'captureRemixErrorBoundaryError',
88
123
  local: 'captureRemixErrorBoundaryError',
89
124
  });
90
- (0, root_common_1.wrapAppWithSentry)(rootRouteAst, rootFileName);
125
+ wrapAppWithSentry(rootRouteAst, rootFileName);
91
126
  recast.visit(rootRouteAst.$ast, {
92
127
  visitExportNamedDeclaration(path) {
93
128
  // Find ErrorBoundary export
@@ -128,5 +163,5 @@ async function instrumentRootRouteV2(rootFileName) {
128
163
  }
129
164
  await (0, magicast_1.writeFile)(rootRouteAst.$ast, path.join(process.cwd(), 'app', rootFileName));
130
165
  }
131
- exports.instrumentRootRouteV2 = instrumentRootRouteV2;
132
- //# sourceMappingURL=root-v2.js.map
166
+ exports.instrumentRoot = instrumentRoot;
167
+ //# sourceMappingURL=root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root.js","sourceRoot":"","sources":["../../../../src/remix/codemods/root.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAA+D;AAC/D,4DAA4D;AAC5D,sDAAsD;AACtD,0DAA0D;AAC1D,+CAAiC;AACjC,2CAA6B;AAI7B,uCAOkB;AAElB,4CAAuD;AACvD,oCAA4C;AAC5C,kDAA0B;AAE1B,+EAA+E;AAC/E,sDAAwC;AAExC,SAAgB,iBAAiB,CAC/B,YAA6B,EAC7B,YAAoB;IAEpB,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC;QACxB,IAAI,EAAE,eAAe;QACrB,QAAQ,EAAE,YAAY;QACtB,KAAK,EAAE,YAAY;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE;QAC9B,6BAA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C,GAAG,EAAE,EAAE,KAAK,EAAE,YAAY,CAAC,CAC9C,CAAC;AACJ,CAAC;AArID,wCAqIC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-member-access */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\n/* eslint-disable @typescript-eslint/no-unsafe-argument */\nimport * as recast from 'recast';\nimport * as path from 'path';\n\nimport type { ExportNamedDeclaration, Program } from '@babel/types';\n\nimport {\n builders,\n generateCode,\n loadFile,\n ProxifiedModule,\n writeFile,\n // @ts-expect-error - magicast is ESM and TS complains about that. It works though\n} from 'magicast';\n\nimport { ERROR_BOUNDARY_TEMPLATE } from '../templates';\nimport { hasSentryContent } from '../utils';\nimport chalk from 'chalk';\n\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\n\nexport function wrapAppWithSentry(\n rootRouteAst: ProxifiedModule,\n rootFileName: string,\n) {\n rootRouteAst.imports.$add({\n from: '@sentry/remix',\n imported: 'withSentry',\n local: 'withSentry',\n });\n\n recast.visit(rootRouteAst.$ast, {\n visitExportDefaultDeclaration(path) {\n if (path.value.declaration.type === 'FunctionDeclaration') {\n // Move the function declaration just before the default export\n path.insertBefore(path.value.declaration);\n\n // Get the name of the function to be wrapped\n const functionName: string = path.value.declaration.id.name as string;\n\n // Create the wrapped function call\n const functionCall = recast.types.builders.callExpression(\n recast.types.builders.identifier('withSentry'),\n [recast.types.builders.identifier(functionName)],\n );\n\n // Replace the default export with the wrapped function call\n path.value.declaration = functionCall;\n } else if (path.value.declaration.type === 'Identifier') {\n const rootRouteExport = rootRouteAst.exports.default;\n\n const expressionToWrap = generateCode(rootRouteExport.$ast).code;\n\n rootRouteAst.exports.default = builders.raw(\n `withSentry(${expressionToWrap})`,\n );\n } else {\n clack.log.warn(\n chalk.yellow(\n `Couldn't instrument ${chalk.bold(\n rootFileName,\n )} automatically. Wrap your default export with: ${chalk.dim(\n 'withSentry()',\n )}\\n`,\n ),\n );\n }\n\n this.traverse(path);\n },\n });\n}\n\nexport async function instrumentRoot(rootFileName: string): Promise<void> {\n const rootRouteAst = await loadFile(\n path.join(process.cwd(), 'app', rootFileName),\n );\n\n const exportsAst = rootRouteAst.exports.$ast as Program;\n\n const namedExports = exportsAst.body.filter(\n (node) => node.type === 'ExportNamedDeclaration',\n ) as ExportNamedDeclaration[];\n\n let foundErrorBoundary = false;\n\n namedExports.forEach((namedExport) => {\n const declaration = namedExport.declaration;\n\n if (!declaration) {\n return;\n }\n\n if (declaration.type === 'FunctionDeclaration') {\n if (declaration.id?.name === 'ErrorBoundary') {\n foundErrorBoundary = true;\n }\n } else if (declaration.type === 'VariableDeclaration') {\n const declarations = declaration.declarations;\n\n declarations.forEach((declaration) => {\n // @ts-expect-error - id should always have a name in this case\n if (declaration.id?.name === 'ErrorBoundary') {\n foundErrorBoundary = true;\n }\n });\n }\n });\n\n if (!foundErrorBoundary) {\n rootRouteAst.imports.$add({\n from: '@sentry/remix',\n imported: 'captureRemixErrorBoundaryError',\n local: 'captureRemixErrorBoundaryError',\n });\n\n rootRouteAst.imports.$add({\n from: '@remix-run/react',\n imported: 'useRouteError',\n local: 'useRouteError',\n });\n\n recast.visit(rootRouteAst.$ast, {\n visitExportDefaultDeclaration(path) {\n const implementation = recast.parse(ERROR_BOUNDARY_TEMPLATE).program\n .body[0];\n\n path.insertBefore(\n recast.types.builders.exportDeclaration(false, implementation),\n );\n\n this.traverse(path);\n },\n });\n // If there is already a ErrorBoundary export, and it doesn't have Sentry content\n } else if (!hasSentryContent(rootFileName, rootRouteAst.$code)) {\n rootRouteAst.imports.$add({\n from: '@sentry/remix',\n imported: 'captureRemixErrorBoundaryError',\n local: 'captureRemixErrorBoundaryError',\n });\n\n wrapAppWithSentry(rootRouteAst, rootFileName);\n\n recast.visit(rootRouteAst.$ast, {\n visitExportNamedDeclaration(path) {\n // Find ErrorBoundary export\n if (path.value.declaration?.id?.name === 'ErrorBoundary') {\n const errorBoundaryExport = path.value.declaration;\n\n let errorIdentifier;\n\n // check if useRouteError is called\n recast.visit(errorBoundaryExport, {\n visitVariableDeclaration(path) {\n const variableDeclaration = path.value.declarations[0];\n const initializer = variableDeclaration.init;\n\n if (\n initializer.type === 'CallExpression' &&\n initializer.callee.name === 'useRouteError'\n ) {\n errorIdentifier = variableDeclaration.id.name;\n }\n\n this.traverse(path);\n },\n });\n\n // We don't have an errorIdentifier, which means useRouteError is not called / imported\n // We need to add it and capture the error\n if (!errorIdentifier) {\n rootRouteAst.imports.$add({\n from: '@remix-run/react',\n imported: 'useRouteError',\n local: 'useRouteError',\n });\n\n const useRouteErrorCall = recast.parse(\n `const error = useRouteError();`,\n ).program.body[0];\n\n // Insert at the top of ErrorBoundary body\n errorBoundaryExport.body.body.splice(0, 0, useRouteErrorCall);\n }\n\n const captureErrorCall = recast.parse(\n `captureRemixErrorBoundaryError(error);`,\n ).program.body[0];\n\n // Insert just before the the fallback page is returned\n errorBoundaryExport.body.body.splice(\n errorBoundaryExport.body.body.length - 1,\n 0,\n captureErrorCall,\n );\n }\n this.traverse(path);\n },\n });\n }\n\n await writeFile(\n rootRouteAst.$ast,\n path.join(process.cwd(), 'app', rootFileName),\n );\n}\n"]}
@@ -32,12 +32,15 @@ async function runRemixWizardWithTelemetry(options) {
32
32
  promoCode,
33
33
  telemetryEnabled,
34
34
  });
35
+ const packageJson = await (0, clack_1.getPackageDotJson)();
36
+ if (!(0, sdk_setup_1.isRemixV2)(packageJson)) {
37
+ prompts_1.default.log.error(`Sentry only supports Remix v2 and above. Please upgrade your Remix version to use Sentry.`);
38
+ return;
39
+ }
35
40
  await (0, clack_1.confirmContinueIfNoOrDirtyGitRepo)({
36
41
  ignoreGitChanges: options.ignoreGitChanges,
37
42
  cwd: undefined,
38
43
  });
39
- const remixConfig = await (0, sdk_setup_1.loadRemixConfig)();
40
- const packageJson = await (0, clack_1.getPackageDotJson)();
41
44
  // We expect `@remix-run/dev` to be installed for every Remix project
42
45
  await (0, clack_1.ensurePackageIsInstalled)(packageJson, '@remix-run/dev', 'Remix');
43
46
  const { selectedProject, authToken, sentryUrl, selfHosted } = await (0, clack_1.getOrAskForProjectData)(options, 'javascript-remix');
@@ -49,7 +52,6 @@ async function runRemixWizardWithTelemetry(options) {
49
52
  });
50
53
  const dsn = selectedProject.keys[0].dsn.public;
51
54
  const isTS = (0, clack_1.isUsingTypeScript)();
52
- const isV2 = (0, sdk_setup_1.isRemixV2)(remixConfig, packageJson);
53
55
  const viteConfig = (0, ast_utils_1.findFile)('vite.config');
54
56
  const selectedFeatures = await (0, clack_1.featureSelectionPrompt)([
55
57
  {
@@ -103,7 +105,7 @@ async function runRemixWizardWithTelemetry(options) {
103
105
  }
104
106
  await (0, telemetry_1.traceStep)('Instrument root route', async () => {
105
107
  try {
106
- await (0, sdk_setup_1.instrumentRootRoute)(isV2, isTS);
108
+ await (0, sdk_setup_1.instrumentRootRoute)(isTS);
107
109
  }
108
110
  catch (e) {
109
111
  prompts_1.default.log.warn(`Could not instrument root route.
@@ -166,7 +168,7 @@ async function runRemixWizardWithTelemetry(options) {
166
168
  }
167
169
  await (0, telemetry_1.traceStep)('Instrument server `handleError`', async () => {
168
170
  try {
169
- await (0, sdk_setup_1.instrumentSentryOnEntryServer)(isV2, isTS);
171
+ await (0, sdk_setup_1.instrumentSentryOnEntryServer)(isTS);
170
172
  }
171
173
  catch (e) {
172
174
  prompts_1.default.log.warn(`Could not initialize Sentry on server entry.
@@ -1 +1 @@
1
- {"version":3,"file":"remix-wizard.js","sourceRoot":"","sources":["../../../src/remix/remix-wizard.ts"],"names":[],"mappings":";;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAE1B,mDAAkD;AAClD,mDAA+D;AAC/D,4CAAwD;AACxD,kDAA8C;AAC9C,0CAawB;AACxB,0CAAuC;AACvC,wDAA4D;AAE5D,+CAAkD;AAClD,2CAWqB;AACrB,mCAAwC;AAEjC,KAAK,UAAU,cAAc,CAAC,OAA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;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,uBAAuB,GAAG,MAAM,IAAA,kCAA0B,GAAE,CAAC;IAEnE,IAAI,uBAAuB,EAAE;QAC3B,MAAM,IAAA,qBAAS,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;YAChD,MAAM,IAAA,+BAAiB,EAAC;gBACtB,IAAI;gBACJ,UAAU;gBACV,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,IAAI;gBAC1C,SAAS,EAAE,eAAe,CAAC,EAAE;gBAC7B,GAAG,EAAE,SAAS;aACf,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;KACJ;IAED,MAAM,IAAA,8BAAsB,EAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAEjD,iBAAK,CAAC,KAAK,CAAC;EACZ,eAAK,CAAC,KAAK,CACX,iEAAiE,CAClE;;EAEC,eAAK,CAAC,IAAI,CAAC,0DAA0D,CAAC;;EAEtE,eAAK,CAAC,IAAI,CACV;0DACwD,CACzD,EAAE,CAAC,CAAC;AACL,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport { DEFAULT_URL } from '../../lib/Constants';\nimport { configureVitePlugin } from '../sourcemaps/tools/vite';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { findFile } from '../utils/ast-utils';\nimport {\n addSentryCliConfig,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n featureSelectionPrompt,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n isUsingTypeScript,\n printWelcome,\n rcCliSetupConfig,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { debug } from '../utils/debug';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { createExamplePage } from './sdk-example';\nimport {\n createServerInstrumentationFile,\n initializeSentryOnEntryClient,\n insertServerInstrumentationFile,\n instrumentRootRoute,\n instrumentSentryOnEntryServer,\n isRemixV2,\n loadRemixConfig,\n runRemixReveal,\n updateBuildScript,\n updateStartScript,\n} from './sdk-setup';\nimport { isHydrogenApp } from './utils';\n\nexport async function runRemixWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'remix',\n wizardOptions: options,\n },\n () => runRemixWizardWithTelemetry(options),\n );\n}\n\nasync function runRemixWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry Remix Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n const remixConfig = await loadRemixConfig();\n const packageJson = await getPackageDotJson();\n\n // We expect `@remix-run/dev` to be installed for every Remix project\n await ensurePackageIsInstalled(packageJson, '@remix-run/dev', 'Remix');\n\n const { selectedProject, authToken, sentryUrl, selfHosted } =\n await getOrAskForProjectData(options, 'javascript-remix');\n\n await installPackage({\n packageName: '@sentry/remix@^9',\n packageNameDisplayLabel: '@sentry/remix',\n alreadyInstalled: hasPackageInstalled('@sentry/remix', packageJson),\n forceInstall,\n });\n\n const dsn = selectedProject.keys[0].dsn.public;\n\n const isTS = isUsingTypeScript();\n const isV2 = isRemixV2(remixConfig, packageJson);\n const viteConfig = findFile('vite.config');\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Session Replay',\n )} to get a video-like reproduction of errors during a user session?`,\n enabledHint: 'recommended, but increases bundle size',\n },\n ] as const);\n\n if (viteConfig) {\n await traceStep(\n 'Update vite configuration for sourcemap uploads',\n async () => {\n try {\n await configureVitePlugin({\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n url: sentryUrl,\n selfHosted,\n authToken,\n });\n } catch (e) {\n clack.log\n .warn(`Could not update vite configuration to generate and upload sourcemaps.\n Please update your vite configuration manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps/`);\n debug(e);\n }\n },\n );\n } else {\n await traceStep('Update build script for sourcemap uploads', async () => {\n try {\n await updateBuildScript({\n org: selectedProject.organization.slug,\n project: selectedProject.slug,\n url: sentryUrl === DEFAULT_URL ? undefined : sentryUrl,\n isHydrogen: isHydrogenApp(packageJson),\n });\n\n await addSentryCliConfig({ authToken }, rcCliSetupConfig);\n } catch (e) {\n clack.log\n .warn(`Could not update build script to generate and upload sourcemaps.\n Please update your build script manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps/`);\n debug(e);\n }\n });\n }\n\n await traceStep('Instrument root route', async () => {\n try {\n await instrumentRootRoute(isV2, isTS);\n } catch (e) {\n clack.log.warn(`Could not instrument root route.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n traceStep('Reveal missing entry files', () => {\n try {\n runRemixReveal(isTS);\n } catch (e) {\n clack.log.warn(`Could not run 'npx remix reveal'.\n Please create your entry files manually`);\n debug(e);\n }\n });\n\n await traceStep('Initialize Sentry on client entry', async () => {\n try {\n await initializeSentryOnEntryClient(dsn, isTS, selectedFeatures);\n } catch (e) {\n clack.log.warn(`Could not initialize Sentry on client entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n let instrumentationFile = '';\n\n await traceStep('Create server instrumentation file', async () => {\n try {\n instrumentationFile = await createServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n } catch (e) {\n clack.log.warn(\n 'Could not create a server instrumentation file. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/',\n );\n debug(e);\n }\n });\n\n let serverFileInstrumented = false;\n\n await traceStep(\n 'Create server instrumentation file and import it',\n async () => {\n try {\n serverFileInstrumented = await insertServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n } catch (e) {\n clack.log.warn(\n 'Could not create a server instrumentation file. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/',\n );\n debug(e);\n }\n },\n );\n\n if (!serverFileInstrumented && instrumentationFile) {\n await traceStep(\n 'Update `start` script to import instrumentation file.',\n async () => {\n try {\n await updateStartScript(instrumentationFile);\n } catch (e) {\n clack.log\n .warn(`Could not automatically add Sentry initialization to server entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n },\n );\n }\n\n await traceStep('Instrument server `handleError`', async () => {\n try {\n await instrumentSentryOnEntryServer(isV2, isTS);\n } catch (e) {\n clack.log.warn(`Could not initialize Sentry on server entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n const shouldCreateExamplePage = await askShouldCreateExamplePage();\n\n if (shouldCreateExamplePage) {\n await traceStep('Create example page', async () => {\n await createExamplePage({\n isTS,\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n });\n });\n }\n\n await runPrettierIfInstalled({ cwd: undefined });\n\n clack.outro(`\n${chalk.green(\n 'Sentry has been successfully configured for your Remix project.',\n)}\n\n${chalk.cyan('You can now deploy your project to see Sentry in action.')}\n\n${chalk.cyan(\n `To learn more about how to use Sentry with Remix, visit our documentation:\nhttps://docs.sentry.io/platforms/javascript/guides/remix/`,\n)}`);\n}\n"]}
1
+ {"version":3,"file":"remix-wizard.js","sourceRoot":"","sources":["../../../src/remix/remix-wizard.ts"],"names":[],"mappings":";;;;;;AAAA,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAE1B,mDAAkD;AAClD,mDAA+D;AAC/D,4CAAwD;AACxD,kDAA8C;AAC9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AAK,CAAC,GAAG,CAAC,IAAI,CAAC;uHACkG,CAAC,CAAC;YACnH,IAAA,aAAK,EAAC,CAAC,CAAC,CAAC;SACV;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,uBAAuB,GAAG,MAAM,IAAA,kCAA0B,GAAE,CAAC;IAEnE,IAAI,uBAAuB,EAAE;QAC3B,MAAM,IAAA,qBAAS,EAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;YAChD,MAAM,IAAA,+BAAiB,EAAC;gBACtB,IAAI;gBACJ,UAAU;gBACV,OAAO,EAAE,eAAe,CAAC,YAAY,CAAC,IAAI;gBAC1C,SAAS,EAAE,eAAe,CAAC,EAAE;gBAC7B,GAAG,EAAE,SAAS;aACf,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;KACJ;IAED,MAAM,IAAA,8BAAsB,EAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC;IAEjD,iBAAK,CAAC,KAAK,CAAC;EACZ,eAAK,CAAC,KAAK,CACX,iEAAiE,CAClE;;EAEC,eAAK,CAAC,IAAI,CAAC,0DAA0D,CAAC;;EAEtE,eAAK,CAAC,IAAI,CACV;0DACwD,CACzD,EAAE,CAAC,CAAC;AACL,CAAC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\n\nimport { DEFAULT_URL } from '../../lib/Constants';\nimport { configureVitePlugin } from '../sourcemaps/tools/vite';\nimport { traceStep, withTelemetry } from '../telemetry';\nimport { findFile } from '../utils/ast-utils';\nimport {\n addSentryCliConfig,\n askShouldCreateExamplePage,\n confirmContinueIfNoOrDirtyGitRepo,\n ensurePackageIsInstalled,\n featureSelectionPrompt,\n getOrAskForProjectData,\n getPackageDotJson,\n installPackage,\n isUsingTypeScript,\n printWelcome,\n rcCliSetupConfig,\n runPrettierIfInstalled,\n} from '../utils/clack';\nimport { debug } from '../utils/debug';\nimport { hasPackageInstalled } from '../utils/package-json';\nimport type { WizardOptions } from '../utils/types';\nimport { createExamplePage } from './sdk-example';\nimport {\n createServerInstrumentationFile,\n initializeSentryOnEntryClient,\n insertServerInstrumentationFile,\n instrumentRootRoute,\n instrumentSentryOnEntryServer,\n isRemixV2,\n runRemixReveal,\n updateBuildScript,\n updateStartScript,\n} from './sdk-setup';\nimport { isHydrogenApp } from './utils';\n\nexport async function runRemixWizard(options: WizardOptions): Promise<void> {\n return withTelemetry(\n {\n enabled: options.telemetryEnabled,\n integration: 'remix',\n wizardOptions: options,\n },\n () => runRemixWizardWithTelemetry(options),\n );\n}\n\nasync function runRemixWizardWithTelemetry(\n options: WizardOptions,\n): Promise<void> {\n const { promoCode, telemetryEnabled, forceInstall } = options;\n\n printWelcome({\n wizardName: 'Sentry Remix Wizard',\n promoCode,\n telemetryEnabled,\n });\n\n const packageJson = await getPackageDotJson();\n\n if (!isRemixV2(packageJson)) {\n clack.log.error(\n `Sentry only supports Remix v2 and above. Please upgrade your Remix version to use Sentry.`,\n );\n return;\n }\n\n await confirmContinueIfNoOrDirtyGitRepo({\n ignoreGitChanges: options.ignoreGitChanges,\n cwd: undefined,\n });\n\n // We expect `@remix-run/dev` to be installed for every Remix project\n await ensurePackageIsInstalled(packageJson, '@remix-run/dev', 'Remix');\n\n const { selectedProject, authToken, sentryUrl, selfHosted } =\n await getOrAskForProjectData(options, 'javascript-remix');\n\n await installPackage({\n packageName: '@sentry/remix@^9',\n packageNameDisplayLabel: '@sentry/remix',\n alreadyInstalled: hasPackageInstalled('@sentry/remix', packageJson),\n forceInstall,\n });\n\n const dsn = selectedProject.keys[0].dsn.public;\n\n const isTS = isUsingTypeScript();\n const viteConfig = findFile('vite.config');\n const selectedFeatures = await featureSelectionPrompt([\n {\n id: 'performance',\n prompt: `Do you want to enable ${chalk.bold(\n 'Tracing',\n )} to track the performance of your application?`,\n enabledHint: 'recommended',\n },\n {\n id: 'replay',\n prompt: `Do you want to enable ${chalk.bold(\n 'Session Replay',\n )} to get a video-like reproduction of errors during a user session?`,\n enabledHint: 'recommended, but increases bundle size',\n },\n ] as const);\n\n if (viteConfig) {\n await traceStep(\n 'Update vite configuration for sourcemap uploads',\n async () => {\n try {\n await configureVitePlugin({\n orgSlug: selectedProject.organization.slug,\n projectSlug: selectedProject.slug,\n url: sentryUrl,\n selfHosted,\n authToken,\n });\n } catch (e) {\n clack.log\n .warn(`Could not update vite configuration to generate and upload sourcemaps.\n Please update your vite configuration manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps/`);\n debug(e);\n }\n },\n );\n } else {\n await traceStep('Update build script for sourcemap uploads', async () => {\n try {\n await updateBuildScript({\n org: selectedProject.organization.slug,\n project: selectedProject.slug,\n url: sentryUrl === DEFAULT_URL ? undefined : sentryUrl,\n isHydrogen: isHydrogenApp(packageJson),\n });\n\n await addSentryCliConfig({ authToken }, rcCliSetupConfig);\n } catch (e) {\n clack.log\n .warn(`Could not update build script to generate and upload sourcemaps.\n Please update your build script manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/sourcemaps/`);\n debug(e);\n }\n });\n }\n\n await traceStep('Instrument root route', async () => {\n try {\n await instrumentRootRoute(isTS);\n } catch (e) {\n clack.log.warn(`Could not instrument root route.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n traceStep('Reveal missing entry files', () => {\n try {\n runRemixReveal(isTS);\n } catch (e) {\n clack.log.warn(`Could not run 'npx remix reveal'.\n Please create your entry files manually`);\n debug(e);\n }\n });\n\n await traceStep('Initialize Sentry on client entry', async () => {\n try {\n await initializeSentryOnEntryClient(dsn, isTS, selectedFeatures);\n } catch (e) {\n clack.log.warn(`Could not initialize Sentry on client entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n let instrumentationFile = '';\n\n await traceStep('Create server instrumentation file', async () => {\n try {\n instrumentationFile = await createServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n } catch (e) {\n clack.log.warn(\n 'Could not create a server instrumentation file. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/',\n );\n debug(e);\n }\n });\n\n let serverFileInstrumented = false;\n\n await traceStep(\n 'Create server instrumentation file and import it',\n async () => {\n try {\n serverFileInstrumented = await insertServerInstrumentationFile(\n dsn,\n selectedFeatures,\n );\n } catch (e) {\n clack.log.warn(\n 'Could not create a server instrumentation file. Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/',\n );\n debug(e);\n }\n },\n );\n\n if (!serverFileInstrumented && instrumentationFile) {\n await traceStep(\n 'Update `start` script to import instrumentation file.',\n async () => {\n try {\n await updateStartScript(instrumentationFile);\n } catch (e) {\n clack.log\n .warn(`Could not automatically add Sentry initialization to server entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n },\n );\n }\n\n await traceStep('Instrument server `handleError`', async () => {\n try {\n await instrumentSentryOnEntryServer(isTS);\n } catch (e) {\n clack.log.warn(`Could not initialize Sentry on server entry.\n Please do it manually using instructions from https://docs.sentry.io/platforms/javascript/guides/remix/manual-setup/`);\n debug(e);\n }\n });\n\n const shouldCreateExamplePage = await askShouldCreateExamplePage();\n\n if (shouldCreateExamplePage) {\n await traceStep('Create example page', async () => {\n await createExamplePage({\n isTS,\n selfHosted,\n orgSlug: selectedProject.organization.slug,\n projectId: selectedProject.id,\n url: sentryUrl,\n });\n });\n }\n\n await runPrettierIfInstalled({ cwd: undefined });\n\n clack.outro(`\n${chalk.green(\n 'Sentry has been successfully configured for your Remix project.',\n)}\n\n${chalk.cyan('You can now deploy your project to see Sentry in action.')}\n\n${chalk.cyan(\n `To learn more about how to use Sentry with Remix, visit our documentation:\nhttps://docs.sentry.io/platforms/javascript/guides/remix/`,\n)}`);\n}\n"]}
@@ -2,14 +2,6 @@ import type { ProxifiedModule } from 'magicast';
2
2
  import type { PackageDotJson } from '../utils/package-json';
3
3
  export type PartialRemixConfig = {
4
4
  unstable_dev?: boolean;
5
- future?: {
6
- v2_dev?: boolean;
7
- v2_errorBoundary?: boolean;
8
- v2_headers?: boolean;
9
- v2_meta?: boolean;
10
- v2_normalizeFormMethod?: boolean;
11
- v2_routeConvention?: boolean;
12
- };
13
5
  };
14
6
  export declare function runRemixReveal(isTS: boolean): void;
15
7
  export declare function generateServerInstrumentationFile(dsn: string, selectedFeatures: {
@@ -27,9 +19,9 @@ export declare function insertServerInstrumentationFile(dsn: string, selectedFea
27
19
  performance: boolean;
28
20
  replay: boolean;
29
21
  }): Promise<boolean>;
30
- export declare function isRemixV2(remixConfig: PartialRemixConfig, packageJson: PackageDotJson): boolean;
22
+ export declare function isRemixV2(packageJson: PackageDotJson): boolean;
31
23
  export declare function loadRemixConfig(): Promise<PartialRemixConfig>;
32
- export declare function instrumentRootRoute(isV2?: boolean, isTS?: boolean): Promise<void>;
24
+ export declare function instrumentRootRoute(isTS?: boolean): Promise<void>;
33
25
  export declare function updateBuildScript(args: {
34
26
  org: string;
35
27
  project: string;
@@ -45,4 +37,4 @@ export declare function initializeSentryOnEntryClient(dsn: string, isTS: boolean
45
37
  replay: boolean;
46
38
  }): Promise<void>;
47
39
  export declare function updateStartScript(instrumentationFile: string): Promise<void>;
48
- export declare function instrumentSentryOnEntryServer(isV2: boolean, isTS: boolean): Promise<void>;
40
+ export declare function instrumentSentryOnEntryServer(isTS: boolean): Promise<void>;