@sentry/wizard 3.9.2 → 3.10.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 (60) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/lib/Constants.d.ts +1 -0
  3. package/dist/lib/Constants.js +5 -0
  4. package/dist/lib/Constants.js.map +1 -1
  5. package/dist/lib/Steps/ChooseIntegration.js +7 -0
  6. package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
  7. package/dist/lib/Steps/Integrations/Cordova.js +5 -1
  8. package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
  9. package/dist/lib/Steps/Integrations/Remix.d.ts +12 -0
  10. package/dist/lib/Steps/Integrations/Remix.js +98 -0
  11. package/dist/lib/Steps/Integrations/Remix.js.map +1 -0
  12. package/dist/package.json +1 -1
  13. package/dist/src/remix/codemods/handle-error.d.ts +2 -0
  14. package/dist/src/remix/codemods/handle-error.js +70 -0
  15. package/dist/src/remix/codemods/handle-error.js.map +1 -0
  16. package/dist/src/remix/codemods/root-v1.d.ts +1 -0
  17. package/dist/src/remix/codemods/root-v1.js +133 -0
  18. package/dist/src/remix/codemods/root-v1.js.map +1 -0
  19. package/dist/src/remix/codemods/root-v2.d.ts +1 -0
  20. package/dist/src/remix/codemods/root-v2.js +134 -0
  21. package/dist/src/remix/codemods/root-v2.js.map +1 -0
  22. package/dist/src/remix/remix-wizard.d.ts +2 -0
  23. package/dist/src/remix/remix-wizard.js +206 -0
  24. package/dist/src/remix/remix-wizard.js.map +1 -0
  25. package/dist/src/remix/sdk-setup.d.ts +18 -0
  26. package/dist/src/remix/sdk-setup.js +293 -0
  27. package/dist/src/remix/sdk-setup.js.map +1 -0
  28. package/dist/src/remix/templates.d.ts +2 -0
  29. package/dist/src/remix/templates.js +6 -0
  30. package/dist/src/remix/templates.js.map +1 -0
  31. package/dist/src/remix/utils.d.ts +6 -0
  32. package/dist/src/remix/utils.js +55 -0
  33. package/dist/src/remix/utils.js.map +1 -0
  34. package/dist/src/sourcemaps/sourcemaps-wizard.js +23 -12
  35. package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
  36. package/dist/src/sourcemaps/tools/remix.d.ts +3 -0
  37. package/dist/src/sourcemaps/tools/remix.js +125 -0
  38. package/dist/src/sourcemaps/tools/remix.js.map +1 -0
  39. package/dist/src/sourcemaps/utils/detect-tool.d.ts +1 -1
  40. package/dist/src/sourcemaps/utils/detect-tool.js +1 -0
  41. package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
  42. package/dist/src/utils/clack-utils.d.ts +3 -2
  43. package/dist/src/utils/clack-utils.js +39 -2
  44. package/dist/src/utils/clack-utils.js.map +1 -1
  45. package/lib/Constants.ts +5 -0
  46. package/lib/Steps/ChooseIntegration.ts +7 -0
  47. package/lib/Steps/Integrations/Cordova.ts +5 -1
  48. package/lib/Steps/Integrations/Remix.ts +32 -0
  49. package/package.json +1 -1
  50. package/src/remix/codemods/handle-error.ts +67 -0
  51. package/src/remix/codemods/root-v1.ts +91 -0
  52. package/src/remix/codemods/root-v2.ts +84 -0
  53. package/src/remix/remix-wizard.ts +137 -0
  54. package/src/remix/sdk-setup.ts +300 -0
  55. package/src/remix/templates.ts +15 -0
  56. package/src/remix/utils.ts +41 -0
  57. package/src/sourcemaps/sourcemaps-wizard.ts +9 -0
  58. package/src/sourcemaps/tools/remix.ts +90 -0
  59. package/src/sourcemaps/utils/detect-tool.ts +3 -1
  60. package/src/utils/clack-utils.ts +56 -2
@@ -0,0 +1,90 @@
1
+ // @ts-ignore - clack is ESM and TS complains about that. It works though
2
+ import * as clack from '@clack/prompts';
3
+ import chalk from 'chalk';
4
+ import { runRemixWizard } from '../../remix/remix-wizard';
5
+ import { traceStep } from '../../telemetry';
6
+ import { abortIfCancelled } from '../../utils/clack-utils';
7
+ import { WizardOptions } from '../../utils/types';
8
+ import { SourceMapUploadToolConfigurationOptions } from './types';
9
+
10
+ import * as Sentry from '@sentry/node';
11
+
12
+ export const configureRemixSourceMapsUpload = async (
13
+ options: SourceMapUploadToolConfigurationOptions,
14
+ wizardOptions: WizardOptions,
15
+ ) => {
16
+ clack.log
17
+ .info(`Source Maps upload for Remix is configured automatically by default if you run the Sentry Wizard for Remix.
18
+ But don't worry, we can redirect you to the wizard now!
19
+ In case you already tried the wizard, we can also show you how to configure your ${chalk.cyan(
20
+ 'remix.config.js',
21
+ )} file manually instead.`);
22
+
23
+ const shouldRedirect: boolean = await abortIfCancelled(
24
+ clack.select({
25
+ message: 'Do you want to run the Sentry Wizard for Remix now?',
26
+ options: [
27
+ {
28
+ label: 'Yes, run the wizard!',
29
+ value: true,
30
+ hint: 'The wizard can also configure your SDK setup',
31
+ },
32
+ {
33
+ label: 'No, show me how to configure it manually',
34
+ value: false,
35
+ },
36
+ ],
37
+ }),
38
+ );
39
+
40
+ Sentry.setTag('redirect-remix-wizard', shouldRedirect);
41
+
42
+ if (shouldRedirect) {
43
+ await traceStep('run-remix-wizard', () => runRemixWizard(wizardOptions));
44
+ clack.intro('Sentry Source Maps Upload Configuration Wizard');
45
+ clack.log.info(
46
+ "Welcome back to the Source Maps wizard - we're almost done ;)",
47
+ );
48
+ } else {
49
+ clack.log.step(
50
+ `Build your app with ${chalk.cyan(
51
+ 'remix build --sourcemap',
52
+ )}, then upload your source maps using ${chalk.cyan(
53
+ 'sentry-upload-sourcemaps',
54
+ )} cli tool.`,
55
+ );
56
+
57
+ clack.log.step(
58
+ `You can add ${chalk.cyan(
59
+ 'sentry-upload-sourcemaps',
60
+ )} to your build script in ${chalk.cyan('package.json')} like this:`,
61
+ );
62
+
63
+ // Intentially logging directly to console here so that the code can be copied/pasted directly
64
+ // eslint-disable-next-line no-console
65
+ console.log(codeSnippet);
66
+
67
+ clack.log.step(`or run it manually after building your app.
68
+
69
+ To see all available options for ${chalk.cyan(
70
+ 'sentry-upload-sourcemaps',
71
+ )}, run ${chalk.cyan('sentry-upload-sourcemaps --help')}
72
+ `);
73
+
74
+ await abortIfCancelled(
75
+ clack.select({
76
+ message: 'Did you finish configuring your build and prod scripts?',
77
+ options: [{ label: 'Yes, continue!', value: true }],
78
+ initialValue: true,
79
+ }),
80
+ );
81
+ }
82
+ };
83
+
84
+ const codeSnippet = chalk.gray(`
85
+ "scripts": {
86
+ ${chalk.greenBright(
87
+ '"build": "remix build --sourcemap && sentry-upload-sourcemaps"',
88
+ )};
89
+ }
90
+ `);
@@ -10,7 +10,8 @@ export type SupportedTools =
10
10
  | 'sentry-cli'
11
11
  | 'create-react-app'
12
12
  | 'angular'
13
- | 'nextjs';
13
+ | 'nextjs'
14
+ | 'remix';
14
15
 
15
16
  // A map of package names pointing to the tool slug.
16
17
  // The order is important, because we want to detect the most specific tool first.
@@ -25,6 +26,7 @@ export const TOOL_PACKAGE_MAP: Record<string, SupportedTools> = {
25
26
  esbuild: 'esbuild',
26
27
  rollup: 'rollup',
27
28
  typescript: 'tsc',
29
+ remix: 'remix',
28
30
  };
29
31
 
30
32
  export async function detectUsedTool(): Promise<SupportedTools> {
@@ -66,6 +66,7 @@ export function printWelcome(options: {
66
66
  wizardName: string;
67
67
  promoCode?: string;
68
68
  message?: string;
69
+ telemetryEnabled?: boolean;
69
70
  }): void {
70
71
  let wizardPackage: { version?: string } = {};
71
72
 
@@ -96,6 +97,10 @@ export function printWelcome(options: {
96
97
  welcomeText += `\n\nVersion: ${wizardPackage.version}`;
97
98
  }
98
99
 
100
+ if (options.telemetryEnabled) {
101
+ welcomeText += `\n\nYou are using the Sentry Wizard with telemetry enabled. This helps us improve the Wizard.\nYou can disable it at any time by running \`sentry-wizard --disable-telemetry\`.`;
102
+ }
103
+
99
104
  clack.note(welcomeText);
100
105
  }
101
106
 
@@ -132,7 +137,11 @@ export async function askToInstallSentryCLI(): Promise<boolean> {
132
137
  export async function askForWizardLogin(options: {
133
138
  url: string;
134
139
  promoCode?: string;
135
- platform?: 'javascript-nextjs' | 'javascript-sveltekit' | 'apple-ios';
140
+ platform?:
141
+ | 'javascript-nextjs'
142
+ | 'javascript-remix'
143
+ | 'javascript-sveltekit'
144
+ | 'apple-ios';
136
145
  }): Promise<WizardProjectData> {
137
146
  Sentry.setTag('has-promo-code', !!options.promoCode);
138
147
 
@@ -408,7 +417,48 @@ export async function askForSelfHosted(urlFromArgs?: string): Promise<{
408
417
  return { url: validUrl, selfHosted: true };
409
418
  }
410
419
 
411
- export async function addSentryCliRc(authToken: string): Promise<void> {
420
+ async function addOrgAndProjectToSentryCliRc(
421
+ org: string,
422
+ project: string,
423
+ ): Promise<void> {
424
+ const clircContents = fs.readFileSync(
425
+ path.join(process.cwd(), SENTRY_CLI_RC_FILE),
426
+ 'utf8',
427
+ );
428
+
429
+ const likelyAlreadyHasOrgAndProject = !!(
430
+ clircContents.includes('[defaults]') &&
431
+ clircContents.match(/org=./g) &&
432
+ clircContents.match(/project=./g)
433
+ );
434
+
435
+ if (likelyAlreadyHasOrgAndProject) {
436
+ clack.log.warn(
437
+ `${chalk.bold(
438
+ SENTRY_CLI_RC_FILE,
439
+ )} already has org and project. Will not add them.`,
440
+ );
441
+ } else {
442
+ try {
443
+ await fs.promises.appendFile(
444
+ path.join(process.cwd(), SENTRY_CLI_RC_FILE),
445
+ `\n[defaults]\norg=${org}\nproject=${project}\n`,
446
+ );
447
+ } catch (e) {
448
+ clack.log.warn(
449
+ `${chalk.bold(
450
+ SENTRY_CLI_RC_FILE,
451
+ )} could not be updated with org and project.`,
452
+ );
453
+ }
454
+ }
455
+ }
456
+
457
+ export async function addSentryCliRc(
458
+ authToken: string,
459
+ orgSlug?: string,
460
+ projectSlug?: string,
461
+ ): Promise<void> {
412
462
  const clircExists = fs.existsSync(
413
463
  path.join(process.cwd(), SENTRY_CLI_RC_FILE),
414
464
  );
@@ -469,6 +519,10 @@ export async function addSentryCliRc(authToken: string): Promise<void> {
469
519
  }
470
520
  }
471
521
 
522
+ if (orgSlug && projectSlug) {
523
+ await addOrgAndProjectToSentryCliRc(orgSlug, projectSlug);
524
+ }
525
+
472
526
  await addAuthTokenFileToGitIgnore(SENTRY_CLI_RC_FILE);
473
527
  }
474
528