@sentry/wizard 3.5.0 → 3.6.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.
- package/CHANGELOG.md +8 -0
- package/bin.ts +8 -9
- package/dist/bin.js +8 -5
- package/dist/bin.js.map +1 -1
- package/dist/lib/Constants.d.ts +2 -0
- package/dist/lib/Constants.js +5 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/lib/Helper/Wizard.js +2 -0
- package/dist/lib/Helper/Wizard.js.map +1 -1
- package/dist/lib/Helper/__tests__/SentryCli.js +1 -0
- package/dist/lib/Helper/__tests__/SentryCli.js.map +1 -1
- package/dist/lib/Steps/ChooseIntegration.js +4 -0
- package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
- package/dist/lib/Steps/Integrations/Apple.d.ts +10 -0
- package/dist/lib/Steps/Integrations/Apple.js +92 -0
- package/dist/lib/Steps/Integrations/Apple.js.map +1 -0
- package/dist/lib/Steps/Integrations/NextJsShim.js +1 -0
- package/dist/lib/Steps/Integrations/NextJsShim.js.map +1 -1
- package/dist/lib/Steps/Integrations/SourceMapsShim.js +1 -0
- package/dist/lib/Steps/Integrations/SourceMapsShim.js.map +1 -1
- package/dist/lib/Steps/Integrations/SvelteKitShim.js +1 -0
- package/dist/lib/Steps/Integrations/SvelteKitShim.js.map +1 -1
- package/dist/package.json +2 -2
- package/dist/src/apple/apple-wizard.d.ts +2 -0
- package/dist/src/apple/apple-wizard.js +197 -0
- package/dist/src/apple/apple-wizard.js.map +1 -0
- package/dist/src/apple/code-tools.d.ts +1 -0
- package/dist/src/apple/code-tools.js +100 -0
- package/dist/src/apple/code-tools.js.map +1 -0
- package/dist/src/apple/templates.d.ts +4 -0
- package/dist/src/apple/templates.js +19 -0
- package/dist/src/apple/templates.js.map +1 -0
- package/dist/src/apple/xcode-manager.d.ts +4 -0
- package/dist/src/apple/xcode-manager.js +145 -0
- package/dist/src/apple/xcode-manager.js.map +1 -0
- package/dist/src/sourcemaps/sourcemaps-wizard.js +143 -71
- package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
- package/dist/src/sourcemaps/tools/angular.d.ts +1 -0
- package/dist/src/sourcemaps/tools/angular.js +76 -0
- package/dist/src/sourcemaps/tools/angular.js.map +1 -0
- package/dist/src/sourcemaps/tools/esbuild.js +2 -1
- package/dist/src/sourcemaps/tools/esbuild.js.map +1 -1
- package/dist/src/sourcemaps/tools/rollup.js +2 -1
- package/dist/src/sourcemaps/tools/rollup.js.map +1 -1
- package/dist/src/sourcemaps/tools/sentry-cli.js +2 -1
- package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
- package/dist/src/sourcemaps/tools/vite.js +2 -1
- package/dist/src/sourcemaps/tools/vite.js.map +1 -1
- package/dist/src/sourcemaps/tools/webpack.js +2 -1
- package/dist/src/sourcemaps/tools/webpack.js.map +1 -1
- package/dist/src/sourcemaps/utils/detect-tool.d.ts +3 -0
- package/dist/src/sourcemaps/utils/detect-tool.js +73 -0
- package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -0
- package/dist/src/sourcemaps/utils/other-wizards.d.ts +4 -0
- package/dist/src/sourcemaps/utils/other-wizards.js +183 -0
- package/dist/src/sourcemaps/utils/other-wizards.js.map +1 -0
- package/dist/src/sourcemaps/utils/sdk-version.js +14 -13
- package/dist/src/sourcemaps/utils/sdk-version.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +2 -1
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/telemetry.d.ts +1 -0
- package/dist/src/telemetry.js +7 -1
- package/dist/src/telemetry.js.map +1 -1
- package/dist/src/utils/bash.d.ts +3 -0
- package/dist/src/utils/bash.js +118 -0
- package/dist/src/utils/bash.js.map +1 -0
- package/dist/src/utils/clack-utils.d.ts +9 -8
- package/dist/src/utils/clack-utils.js +54 -21
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/utils/package-json.d.ts +19 -0
- package/dist/src/utils/package-json.js +29 -0
- package/dist/src/utils/package-json.js.map +1 -0
- package/dist/src/utils/types.d.ts +4 -0
- package/dist/src/utils/types.js.map +1 -1
- package/lib/Constants.ts +6 -0
- package/lib/Helper/Wizard.ts +3 -0
- package/lib/Helper/__tests__/SentryCli.ts +2 -1
- package/lib/Steps/ChooseIntegration.ts +4 -0
- package/lib/Steps/Integrations/Apple.ts +27 -0
- package/lib/Steps/Integrations/NextJsShim.ts +1 -0
- package/lib/Steps/Integrations/SourceMapsShim.ts +1 -0
- package/lib/Steps/Integrations/SvelteKitShim.ts +1 -0
- package/package-lock.json +8910 -0
- package/package.json +2 -2
- package/src/apple/apple-wizard.ts +150 -0
- package/src/apple/code-tools.ts +81 -0
- package/src/apple/templates.ts +39 -0
- package/src/apple/xcode-manager.ts +147 -0
- package/src/sourcemaps/sourcemaps-wizard.ts +156 -91
- package/src/sourcemaps/tools/angular.ts +42 -0
- package/src/sourcemaps/tools/esbuild.ts +1 -1
- package/src/sourcemaps/tools/rollup.ts +2 -4
- package/src/sourcemaps/tools/sentry-cli.ts +1 -1
- package/src/sourcemaps/tools/vite.ts +1 -1
- package/src/sourcemaps/tools/webpack.ts +1 -1
- package/src/sourcemaps/utils/detect-tool.ts +41 -0
- package/src/sourcemaps/utils/other-wizards.ts +148 -0
- package/src/sourcemaps/utils/sdk-version.ts +9 -16
- package/src/sveltekit/sveltekit-wizard.ts +1 -1
- package/src/telemetry.ts +8 -0
- package/src/utils/bash.ts +44 -0
- package/src/utils/clack-utils.ts +44 -37
- package/src/utils/package-json.ts +45 -0
- package/src/utils/types.ts +5 -0
package/src/telemetry.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
makeNodeTransport,
|
|
7
7
|
NodeClient,
|
|
8
8
|
runWithAsyncContext,
|
|
9
|
+
trace,
|
|
9
10
|
} from '@sentry/node';
|
|
10
11
|
import packageJson from '../package.json';
|
|
11
12
|
|
|
@@ -26,6 +27,7 @@ export async function withTelemetry<F>(
|
|
|
26
27
|
const transaction = sentryHub.startTransaction({
|
|
27
28
|
name: 'sentry-wizard-execution',
|
|
28
29
|
status: 'ok',
|
|
30
|
+
op: 'wizard.flow',
|
|
29
31
|
});
|
|
30
32
|
sentryHub.getScope().setSpan(transaction);
|
|
31
33
|
const sentrySession = sentryHub.startSession();
|
|
@@ -74,6 +76,8 @@ function createSentryInstance(enabled: boolean, integration: string) {
|
|
|
74
76
|
},
|
|
75
77
|
|
|
76
78
|
transport: makeNodeTransport,
|
|
79
|
+
|
|
80
|
+
debug: true,
|
|
77
81
|
});
|
|
78
82
|
|
|
79
83
|
const hub = new Hub(client);
|
|
@@ -84,3 +88,7 @@ function createSentryInstance(enabled: boolean, integration: string) {
|
|
|
84
88
|
|
|
85
89
|
return { sentryHub: hub, sentryClient: client };
|
|
86
90
|
}
|
|
91
|
+
|
|
92
|
+
export function traceStep<T>(step: string, callback: () => T): T {
|
|
93
|
+
return trace({ name: step, op: 'wizard.step' }, () => callback());
|
|
94
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as child_process from 'child_process';
|
|
2
|
+
import * as https from 'https';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
|
|
5
|
+
export function hasSentryCLI(): boolean {
|
|
6
|
+
try {
|
|
7
|
+
child_process.execSync('sentry-cli --version');
|
|
8
|
+
return true;
|
|
9
|
+
} catch (e) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export async function installSentryCLI(): Promise<void> {
|
|
15
|
+
const httpAsync = new Promise((resolve, reject) => {
|
|
16
|
+
const file = fs.createWriteStream('installcli.sh');
|
|
17
|
+
https.get('https://sentry.io/get-cli/', (response) => {
|
|
18
|
+
response.pipe(file);
|
|
19
|
+
file.on('finish', () => {
|
|
20
|
+
file.close();
|
|
21
|
+
try {
|
|
22
|
+
child_process.execSync('bash ./installcli.sh');
|
|
23
|
+
} catch (e) {
|
|
24
|
+
reject(e);
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
fs.unlinkSync('installcli.sh');
|
|
28
|
+
resolve(null);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
file.on('error', (err) => {
|
|
32
|
+
fs.unlinkSync('installcli.sh');
|
|
33
|
+
reject(err);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
await httpAsync;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function execute(command: string): string {
|
|
42
|
+
const output = child_process.execSync(command);
|
|
43
|
+
return output.toString();
|
|
44
|
+
}
|
package/src/utils/clack-utils.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { URL } from 'url';
|
|
|
10
10
|
import { promisify } from 'util';
|
|
11
11
|
import * as Sentry from '@sentry/node';
|
|
12
12
|
import { windowedSelect } from './vendor/clack-custom-select';
|
|
13
|
+
import { hasPackageInstalled, PackageDotJson } from './package-json';
|
|
13
14
|
|
|
14
15
|
const opn = require('opn') as (
|
|
15
16
|
url: string,
|
|
@@ -24,16 +25,11 @@ interface WizardProjectData {
|
|
|
24
25
|
projects: SentryProjectData[];
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
export type PackageDotJson = {
|
|
28
|
-
scripts?: Record<string, string>;
|
|
29
|
-
dependencies?: Record<string, string>;
|
|
30
|
-
devDependencies?: Record<string, string>;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
28
|
export interface SentryProjectData {
|
|
34
29
|
id: string;
|
|
35
30
|
slug: string;
|
|
36
31
|
name: string;
|
|
32
|
+
platform: string;
|
|
37
33
|
organization: {
|
|
38
34
|
slug: string;
|
|
39
35
|
};
|
|
@@ -130,10 +126,16 @@ export async function confirmContinueEvenThoughNoGitRepo(): Promise<void> {
|
|
|
130
126
|
}
|
|
131
127
|
}
|
|
132
128
|
|
|
129
|
+
export async function askToInstallSentryCLI(): Promise<boolean> {
|
|
130
|
+
return await abortIfCancelled(clack.confirm({
|
|
131
|
+
message: "You don't have Sentry CLI installed. Do you want to install it?"
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
|
|
133
135
|
export async function askForWizardLogin(options: {
|
|
134
136
|
url: string;
|
|
135
137
|
promoCode?: string;
|
|
136
|
-
platform?: 'javascript-nextjs' | 'javascript-sveltekit';
|
|
138
|
+
platform?: 'javascript-nextjs' | 'javascript-sveltekit' | 'apple-ios';
|
|
137
139
|
}): Promise<WizardProjectData> {
|
|
138
140
|
Sentry.setTag('has-promo-code', !!options.promoCode);
|
|
139
141
|
|
|
@@ -186,8 +188,7 @@ export async function askForWizardLogin(options: {
|
|
|
186
188
|
const urlToOpen = loginUrl.toString();
|
|
187
189
|
clack.log.info(
|
|
188
190
|
`${chalk.bold(
|
|
189
|
-
`If the browser window didn't open automatically, please open the following link to ${
|
|
190
|
-
hasSentryAccount ? 'log' : 'sign'
|
|
191
|
+
`If the browser window didn't open automatically, please open the following link to ${hasSentryAccount ? 'log' : 'sign'
|
|
191
192
|
} into Sentry:`,
|
|
192
193
|
)}\n\n${chalk.cyan(urlToOpen)}`,
|
|
193
194
|
);
|
|
@@ -234,6 +235,23 @@ export async function askForWizardLogin(options: {
|
|
|
234
235
|
return data;
|
|
235
236
|
}
|
|
236
237
|
|
|
238
|
+
export async function askForItemSelection(items: string[], message: string): Promise<{ value: string, index: number }> {
|
|
239
|
+
const selection: { value: string, index: number } | symbol = await abortIfCancelled(
|
|
240
|
+
windowedSelect({
|
|
241
|
+
maxItems: 12,
|
|
242
|
+
message: message,
|
|
243
|
+
options: items.map((item, index) => {
|
|
244
|
+
return {
|
|
245
|
+
value: { value: item, index: index },
|
|
246
|
+
label: item,
|
|
247
|
+
};
|
|
248
|
+
}),
|
|
249
|
+
}),
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
return selection;
|
|
253
|
+
}
|
|
254
|
+
|
|
237
255
|
export async function askForProjectSelection(
|
|
238
256
|
projects: SentryProjectData[],
|
|
239
257
|
): Promise<SentryProjectData> {
|
|
@@ -251,6 +269,7 @@ export async function askForProjectSelection(
|
|
|
251
269
|
);
|
|
252
270
|
|
|
253
271
|
Sentry.setTag('project', selection.slug);
|
|
272
|
+
Sentry.setTag('project-platform', selection.platform);
|
|
254
273
|
Sentry.setUser({ id: selection.organization.slug });
|
|
255
274
|
|
|
256
275
|
return selection;
|
|
@@ -359,9 +378,8 @@ export async function askForSelfHosted(urlFromArgs?: string): Promise<{
|
|
|
359
378
|
tmpUrlFromArgs ||
|
|
360
379
|
(await abortIfCancelled(
|
|
361
380
|
clack.text({
|
|
362
|
-
message: `Please enter the URL of your ${
|
|
363
|
-
|
|
364
|
-
}Sentry instance.`,
|
|
381
|
+
message: `Please enter the URL of your ${urlFromArgs ? '' : 'self-hosted '
|
|
382
|
+
}Sentry instance.`,
|
|
365
383
|
placeholder: 'https://sentry.io/',
|
|
366
384
|
}),
|
|
367
385
|
));
|
|
@@ -584,32 +602,8 @@ export async function getPackageDotJson(): Promise<PackageDotJson> {
|
|
|
584
602
|
return packageJson || {};
|
|
585
603
|
}
|
|
586
604
|
|
|
587
|
-
export function hasPackageInstalled(
|
|
588
|
-
packageName: string,
|
|
589
|
-
packageJson: PackageDotJson,
|
|
590
|
-
): boolean {
|
|
591
|
-
return getPackageVersion(packageName, packageJson) !== undefined;
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
export function getPackageVersion(
|
|
595
|
-
packageName: string,
|
|
596
|
-
packageJson: PackageDotJson,
|
|
597
|
-
): string | undefined {
|
|
598
|
-
return (
|
|
599
|
-
packageJson?.dependencies?.[packageName] ||
|
|
600
|
-
packageJson?.devDependencies?.[packageName]
|
|
601
|
-
);
|
|
602
|
-
}
|
|
603
|
-
|
|
604
605
|
async function getPackageManager(): Promise<string> {
|
|
605
|
-
|
|
606
|
-
if (fs.existsSync(path.join(process.cwd(), 'yarn.lock'))) {
|
|
607
|
-
detectedPackageManager = 'yarn';
|
|
608
|
-
} else if (fs.existsSync(path.join(process.cwd(), 'package-lock.json'))) {
|
|
609
|
-
detectedPackageManager = 'npm';
|
|
610
|
-
} else if (fs.existsSync(path.join(process.cwd(), 'pnpm-lock.yaml'))) {
|
|
611
|
-
detectedPackageManager = 'pnpm';
|
|
612
|
-
}
|
|
606
|
+
const detectedPackageManager = detectPackageManager();
|
|
613
607
|
|
|
614
608
|
if (detectedPackageManager) {
|
|
615
609
|
return detectedPackageManager;
|
|
@@ -630,3 +624,16 @@ async function getPackageManager(): Promise<string> {
|
|
|
630
624
|
|
|
631
625
|
return selectedPackageManager;
|
|
632
626
|
}
|
|
627
|
+
|
|
628
|
+
export function detectPackageManager(): 'yarn' | 'npm' | 'pnpm' | undefined {
|
|
629
|
+
if (fs.existsSync(path.join(process.cwd(), 'yarn.lock'))) {
|
|
630
|
+
return 'yarn';
|
|
631
|
+
}
|
|
632
|
+
if (fs.existsSync(path.join(process.cwd(), 'package-lock.json'))) {
|
|
633
|
+
return 'npm';
|
|
634
|
+
}
|
|
635
|
+
if (fs.existsSync(path.join(process.cwd(), 'pnpm-lock.yaml'))) {
|
|
636
|
+
return 'pnpm';
|
|
637
|
+
}
|
|
638
|
+
return undefined;
|
|
639
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type PackageDotJson = {
|
|
2
|
+
scripts?: Record<string, string>;
|
|
3
|
+
dependencies?: Record<string, string>;
|
|
4
|
+
devDependencies?: Record<string, string>;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
type NpmPackage = {
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Checks if @param packageJson has any of the @param packageNamesList package names
|
|
14
|
+
* listed as a dependency or devDependency.
|
|
15
|
+
* If so, it returns the first package name that is found, including the
|
|
16
|
+
* version (range) specified in the package.json.
|
|
17
|
+
*/
|
|
18
|
+
export function findInstalledPackageFromList(
|
|
19
|
+
packageNamesList: string[],
|
|
20
|
+
packageJson: PackageDotJson,
|
|
21
|
+
): NpmPackage | undefined {
|
|
22
|
+
return packageNamesList
|
|
23
|
+
.map((packageName) => ({
|
|
24
|
+
name: packageName,
|
|
25
|
+
version: getPackageVersion(packageName, packageJson),
|
|
26
|
+
}))
|
|
27
|
+
.find((sdkPackage): sdkPackage is NpmPackage => !!sdkPackage.version);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function hasPackageInstalled(
|
|
31
|
+
packageName: string,
|
|
32
|
+
packageJson: PackageDotJson,
|
|
33
|
+
): boolean {
|
|
34
|
+
return getPackageVersion(packageName, packageJson) !== undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function getPackageVersion(
|
|
38
|
+
packageName: string,
|
|
39
|
+
packageJson: PackageDotJson,
|
|
40
|
+
): string | undefined {
|
|
41
|
+
return (
|
|
42
|
+
packageJson?.dependencies?.[packageName] ||
|
|
43
|
+
packageJson?.devDependencies?.[packageName]
|
|
44
|
+
);
|
|
45
|
+
}
|
package/src/utils/types.ts
CHANGED