@sentry/wizard 3.29.0 → 3.31.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 (41) hide show
  1. package/CHANGELOG.md +18 -4
  2. package/dist/package.json +1 -1
  3. package/dist/src/android/android-wizard.js +1 -0
  4. package/dist/src/android/android-wizard.js.map +1 -1
  5. package/dist/src/apple/apple-wizard.js +1 -0
  6. package/dist/src/apple/apple-wizard.js.map +1 -1
  7. package/dist/src/nextjs/nextjs-wizard.js +1 -0
  8. package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
  9. package/dist/src/react-native/react-native-wizard.js +1 -0
  10. package/dist/src/react-native/react-native-wizard.js.map +1 -1
  11. package/dist/src/remix/remix-wizard.js +1 -0
  12. package/dist/src/remix/remix-wizard.js.map +1 -1
  13. package/dist/src/run.d.ts +2 -0
  14. package/dist/src/run.js +2 -0
  15. package/dist/src/run.js.map +1 -1
  16. package/dist/src/sourcemaps/sourcemaps-wizard.js +1 -0
  17. package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
  18. package/dist/src/sourcemaps/utils/sdk-version.js +9 -0
  19. package/dist/src/sourcemaps/utils/sdk-version.js.map +1 -1
  20. package/dist/src/sveltekit/sveltekit-wizard.js +2 -1
  21. package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
  22. package/dist/src/telemetry.d.ts +2 -0
  23. package/dist/src/telemetry.js +3 -0
  24. package/dist/src/telemetry.js.map +1 -1
  25. package/dist/src/utils/clack-utils.js +27 -13
  26. package/dist/src/utils/clack-utils.js.map +1 -1
  27. package/dist/src/utils/types.d.ts +12 -0
  28. package/dist/src/utils/types.js.map +1 -1
  29. package/package.json +1 -1
  30. package/src/android/android-wizard.ts +1 -0
  31. package/src/apple/apple-wizard.ts +1 -0
  32. package/src/nextjs/nextjs-wizard.ts +1 -0
  33. package/src/react-native/react-native-wizard.ts +1 -0
  34. package/src/remix/remix-wizard.ts +1 -0
  35. package/src/run.ts +4 -0
  36. package/src/sourcemaps/sourcemaps-wizard.ts +1 -0
  37. package/src/sourcemaps/utils/sdk-version.ts +9 -0
  38. package/src/sveltekit/sveltekit-wizard.ts +3 -2
  39. package/src/telemetry.ts +6 -0
  40. package/src/utils/clack-utils.ts +46 -2
  41. package/src/utils/types.ts +14 -0
@@ -869,7 +869,7 @@ export async function getOrAskForProjectData(
869
869
  }
870
870
 
871
871
  const selectedProject = await traceStep('select-project', () =>
872
- askForProjectSelection(projects),
872
+ askForProjectSelection(projects, options.orgSlug, options.projectSlug),
873
873
  );
874
874
 
875
875
  const { token } = apiKeys ?? {};
@@ -1087,14 +1087,38 @@ async function askForWizardLogin(options: {
1087
1087
 
1088
1088
  async function askForProjectSelection(
1089
1089
  projects: SentryProjectData[],
1090
+ orgSlug?: string,
1091
+ projectSlug?: string,
1090
1092
  ): Promise<SentryProjectData> {
1091
1093
  const label = (project: SentryProjectData): string => {
1092
1094
  return `${project.organization.slug}/${project.slug}`;
1093
1095
  };
1094
- const sortedProjects = [...projects];
1096
+
1097
+ const filteredProjects = filterProjectsBySlugs(
1098
+ projects,
1099
+ orgSlug,
1100
+ projectSlug,
1101
+ );
1102
+
1103
+ if (filteredProjects.length === 1) {
1104
+ const selection = filteredProjects[0];
1105
+
1106
+ Sentry.setTag('project', selection.slug);
1107
+ Sentry.setUser({ id: selection.organization.slug });
1108
+ clack.log.step(`Selected project ${label(selection)}`);
1109
+
1110
+ return selection;
1111
+ }
1112
+
1113
+ if (filteredProjects.length === 0) {
1114
+ clack.log.warn('Could not find a project with the provided slugs.');
1115
+ }
1116
+
1117
+ const sortedProjects = filteredProjects.length ? filteredProjects : projects;
1095
1118
  sortedProjects.sort((a: SentryProjectData, b: SentryProjectData) => {
1096
1119
  return label(a).localeCompare(label(b));
1097
1120
  });
1121
+
1098
1122
  const selection: SentryProjectData | symbol = await abortIfCancelled(
1099
1123
  clack.select({
1100
1124
  maxItems: 12,
@@ -1114,6 +1138,26 @@ async function askForProjectSelection(
1114
1138
  return selection;
1115
1139
  }
1116
1140
 
1141
+ function filterProjectsBySlugs(
1142
+ projects: SentryProjectData[],
1143
+ orgSlug?: string,
1144
+ projectSlug?: string,
1145
+ ): SentryProjectData[] {
1146
+ if (!orgSlug && !projectSlug) {
1147
+ return projects;
1148
+ }
1149
+ if (orgSlug && !projectSlug) {
1150
+ return projects.filter((p) => p.organization.slug === orgSlug);
1151
+ }
1152
+ if (!orgSlug && projectSlug) {
1153
+ return projects.filter((p) => p.slug === projectSlug);
1154
+ }
1155
+
1156
+ return projects.filter(
1157
+ (p) => p.organization.slug === orgSlug && p.slug === projectSlug,
1158
+ );
1159
+ }
1160
+
1117
1161
  /**
1118
1162
  * Asks users if they have a config file for @param tool (e.g. Vite).
1119
1163
  * If yes, asks users to specify the path to their config file.
@@ -33,6 +33,20 @@ export type WizardOptions = {
33
33
  */
34
34
  url?: string;
35
35
 
36
+ /**
37
+ * The org to pre-select in the wizard.
38
+ * This can be passed via the `--org` arg.
39
+ * Example: `--org my-org`
40
+ */
41
+ orgSlug?: string;
42
+
43
+ /**
44
+ * Project slug to pre-select in the wizard.
45
+ * This can be passed via the `--project` arg.
46
+ * Example: `--project my-project`
47
+ */
48
+ projectSlug?: string;
49
+
36
50
  /**
37
51
  * If this is set, the wizard will skip the login and project selection step.
38
52
  * (This can not yet be set externally but for example when redirecting from