@sentry/wizard 3.10.0 → 3.11.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 +47 -7
- package/dist/lib/Constants.d.ts +1 -0
- package/dist/lib/Constants.js +5 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/lib/Steps/ChooseIntegration.js +8 -4
- package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
- package/dist/lib/Steps/Integrations/Android.d.ts +9 -0
- package/dist/lib/Steps/Integrations/Android.js +86 -0
- package/dist/lib/Steps/Integrations/Android.js.map +1 -0
- package/dist/lib/Steps/Integrations/ReactNative.js +3 -3
- package/dist/lib/Steps/Integrations/ReactNative.js.map +1 -1
- package/dist/lib/Steps/PromptForParameters.js +36 -3
- package/dist/lib/Steps/PromptForParameters.js.map +1 -1
- package/dist/lib/Steps/SentryProjectSelector.js +1 -1
- package/dist/lib/Steps/SentryProjectSelector.js.map +1 -1
- package/dist/package.json +4 -3
- package/dist/src/android/android-wizard.d.ts +2 -0
- package/dist/src/android/android-wizard.js +217 -0
- package/dist/src/android/android-wizard.js.map +1 -0
- package/dist/src/android/code-tools.d.ts +39 -0
- package/dist/src/android/code-tools.js +161 -0
- package/dist/src/android/code-tools.js.map +1 -0
- package/dist/src/android/gradle.d.ts +62 -0
- package/dist/src/android/gradle.js +281 -0
- package/dist/src/android/gradle.js.map +1 -0
- package/dist/src/android/manifest.d.ts +57 -0
- package/dist/src/android/manifest.js +183 -0
- package/dist/src/android/manifest.js.map +1 -0
- package/dist/src/android/templates.d.ts +11 -0
- package/dist/src/android/templates.js +34 -0
- package/dist/src/android/templates.js.map +1 -0
- package/dist/src/apple/apple-wizard.js +123 -64
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/cocoapod.js +4 -3
- package/dist/src/apple/cocoapod.js.map +1 -1
- package/dist/src/apple/code-tools.d.ts +1 -1
- package/dist/src/apple/code-tools.js +43 -19
- package/dist/src/apple/code-tools.js.map +1 -1
- package/dist/src/apple/fastlane.d.ts +1 -1
- package/dist/src/apple/fastlane.js +12 -6
- package/dist/src/apple/fastlane.js.map +1 -1
- package/dist/src/apple/templates.d.ts +2 -2
- package/dist/src/apple/templates.js +4 -4
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/apple/xcode-manager.d.ts +19 -3
- package/dist/src/apple/xcode-manager.js +126 -24
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +49 -11
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +2 -0
- package/dist/src/nextjs/templates.js +6 -2
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/remix/remix-wizard.js +10 -20
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js +26 -13
- package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
- package/dist/src/sourcemaps/tools/nextjs.js +1 -1
- package/dist/src/sourcemaps/tools/nextjs.js.map +1 -1
- package/dist/src/sourcemaps/tools/sentry-cli.js +19 -16
- package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
- package/dist/src/sourcemaps/tools/vite.d.ts +2 -1
- package/dist/src/sourcemaps/tools/vite.js +99 -12
- package/dist/src/sourcemaps/tools/vite.js.map +1 -1
- package/dist/src/sourcemaps/utils/detect-tool.d.ts +1 -1
- package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup.js +3 -3
- package/dist/src/sveltekit/sdk-setup.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +34 -44
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/telemetry.js +1 -0
- package/dist/src/telemetry.js.map +1 -1
- package/dist/src/utils/ast-utils.d.ts +2 -2
- package/dist/src/utils/ast-utils.js +7 -7
- package/dist/src/utils/ast-utils.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +22 -28
- package/dist/src/utils/clack-utils.js +270 -264
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/utils/package-manager.d.ts +10 -0
- package/dist/{lib/Helper/PackageManager.js → src/utils/package-manager.js} +42 -74
- package/dist/src/utils/package-manager.js.map +1 -0
- package/dist/src/utils/release-registry.d.ts +1 -0
- package/dist/src/utils/release-registry.js +68 -0
- package/dist/src/utils/release-registry.js.map +1 -0
- package/dist/src/utils/sentrycli-utils.d.ts +4 -0
- package/dist/src/utils/sentrycli-utils.js +41 -0
- package/dist/src/utils/sentrycli-utils.js.map +1 -0
- package/dist/test/sourcemaps/tools/vite.test.d.ts +1 -0
- package/dist/test/sourcemaps/tools/vite.test.js +132 -0
- package/dist/test/sourcemaps/tools/vite.test.js.map +1 -0
- package/lib/Constants.ts +5 -0
- package/lib/Steps/ChooseIntegration.ts +7 -3
- package/lib/Steps/Integrations/Android.ts +23 -0
- package/lib/Steps/Integrations/ReactNative.ts +9 -3
- package/lib/Steps/PromptForParameters.ts +48 -3
- package/lib/Steps/SentryProjectSelector.ts +3 -1
- package/package.json +4 -3
- package/src/android/android-wizard.ts +196 -0
- package/src/android/code-tools.ts +156 -0
- package/src/android/gradle.ts +245 -0
- package/src/android/manifest.ts +180 -0
- package/src/android/templates.ts +88 -0
- package/src/apple/apple-wizard.ts +113 -35
- package/src/apple/cocoapod.ts +6 -3
- package/src/apple/code-tools.ts +46 -18
- package/src/apple/fastlane.ts +6 -12
- package/src/apple/templates.ts +2 -8
- package/src/apple/xcode-manager.ts +167 -25
- package/src/nextjs/nextjs-wizard.ts +72 -8
- package/src/nextjs/templates.ts +16 -2
- package/src/remix/remix-wizard.ts +10 -15
- package/src/sourcemaps/sourcemaps-wizard.ts +19 -5
- package/src/sourcemaps/tools/nextjs.ts +2 -2
- package/src/sourcemaps/tools/sentry-cli.ts +8 -7
- package/src/sourcemaps/tools/vite.ts +136 -6
- package/src/sourcemaps/utils/detect-tool.ts +2 -1
- package/src/sveltekit/sdk-setup.ts +4 -4
- package/src/sveltekit/sveltekit-wizard.ts +5 -14
- package/src/telemetry.ts +2 -0
- package/src/utils/ast-utils.ts +7 -5
- package/src/utils/clack-utils.ts +337 -283
- package/src/utils/package-manager.ts +61 -0
- package/src/utils/release-registry.ts +19 -0
- package/src/utils/sentrycli-utils.ts +22 -0
- package/test/sourcemaps/tools/vite.test.ts +149 -0
- package/dist/lib/Helper/PackageManager.d.ts +0 -22
- package/dist/lib/Helper/PackageManager.js.map +0 -1
- package/dist/src/utils/vendor/clack-custom-select.d.ts +0 -21
- package/dist/src/utils/vendor/clack-custom-select.js +0 -137
- package/dist/src/utils/vendor/clack-custom-select.js.map +0 -1
- package/lib/Helper/PackageManager.ts +0 -59
- package/src/utils/vendor/clack-custom-select.ts +0 -160
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
2
|
-
import
|
|
2
|
+
import * as clack from '@clack/prompts';
|
|
3
3
|
// @ts-ignore - magicast is ESM and TS complains about that. It works though
|
|
4
4
|
import { generateCode, parseModule } from 'magicast';
|
|
5
5
|
// @ts-ignore - magicast is ESM and TS complains about that. It works though
|
|
6
6
|
import { addVitePlugin } from 'magicast/helpers';
|
|
7
7
|
|
|
8
|
+
import type { namedTypes as t } from 'ast-types';
|
|
9
|
+
|
|
10
|
+
import * as recast from 'recast';
|
|
11
|
+
|
|
8
12
|
import * as Sentry from '@sentry/node';
|
|
9
13
|
|
|
10
14
|
import chalk from 'chalk';
|
|
@@ -20,7 +24,7 @@ import {
|
|
|
20
24
|
SourceMapUploadToolConfigurationFunction,
|
|
21
25
|
SourceMapUploadToolConfigurationOptions,
|
|
22
26
|
} from './types';
|
|
23
|
-
import {
|
|
27
|
+
import { findFile, hasSentryContent } from '../../utils/ast-utils';
|
|
24
28
|
|
|
25
29
|
import * as path from 'path';
|
|
26
30
|
import * as fs from 'fs';
|
|
@@ -87,7 +91,7 @@ export const configureVitePlugin: SourceMapUploadToolConfigurationFunction =
|
|
|
87
91
|
});
|
|
88
92
|
|
|
89
93
|
const viteConfigPath =
|
|
90
|
-
|
|
94
|
+
findFile(path.resolve(process.cwd(), 'vite.config')) ||
|
|
91
95
|
(await askForViteConfigPath());
|
|
92
96
|
|
|
93
97
|
let successfullyAdded = false;
|
|
@@ -139,7 +143,7 @@ async function createNewViteConfig(
|
|
|
139
143
|
}
|
|
140
144
|
}
|
|
141
145
|
|
|
142
|
-
async function addVitePluginToConfig(
|
|
146
|
+
export async function addVitePluginToConfig(
|
|
143
147
|
viteConfigPath: string,
|
|
144
148
|
options: SourceMapUploadToolConfigurationOptions,
|
|
145
149
|
): Promise<boolean> {
|
|
@@ -176,6 +180,12 @@ async function addVitePluginToConfig(
|
|
|
176
180
|
}
|
|
177
181
|
}
|
|
178
182
|
|
|
183
|
+
const enabledSourcemaps = enableSourcemapGeneration(mod.$ast as t.Program);
|
|
184
|
+
if (!enabledSourcemaps) {
|
|
185
|
+
Sentry.setTag('ast-mod-fail-reason', 'insertion-fail');
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
|
|
179
189
|
const { orgSlug: org, projectSlug: project, selfHosted, url } = options;
|
|
180
190
|
|
|
181
191
|
addVitePlugin(mod, {
|
|
@@ -194,7 +204,7 @@ async function addVitePluginToConfig(
|
|
|
194
204
|
await fs.promises.writeFile(viteConfigPath, code);
|
|
195
205
|
|
|
196
206
|
clack.log.success(
|
|
197
|
-
`Added the Sentry Vite plugin to ${prettyViteConfigFilename}`,
|
|
207
|
+
`Added the Sentry Vite plugin to ${prettyViteConfigFilename} and enabled source maps`,
|
|
198
208
|
);
|
|
199
209
|
|
|
200
210
|
return true;
|
|
@@ -218,7 +228,7 @@ async function showCopyPasteInstructions(
|
|
|
218
228
|
console.log(`\n${getViteConfigSnippet(options, true)}`);
|
|
219
229
|
|
|
220
230
|
await abortIfCancelled(
|
|
221
|
-
select({
|
|
231
|
+
clack.select({
|
|
222
232
|
message: 'Did you copy the snippet above?',
|
|
223
233
|
options: [{ label: 'Yes, continue!', value: true }],
|
|
224
234
|
initialValue: true,
|
|
@@ -258,3 +268,123 @@ async function askForViteConfigPath(): Promise<string | undefined> {
|
|
|
258
268
|
}),
|
|
259
269
|
);
|
|
260
270
|
}
|
|
271
|
+
|
|
272
|
+
function enableSourcemapGeneration(program: t.Program): boolean {
|
|
273
|
+
const configObj = getViteConfigObject(program);
|
|
274
|
+
|
|
275
|
+
if (!configObj) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const b = recast.types.builders;
|
|
280
|
+
|
|
281
|
+
const buildProp = configObj.properties.find(
|
|
282
|
+
(p: t.ObjectProperty) =>
|
|
283
|
+
p.key.type === 'Identifier' && p.key.name === 'build',
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
// case 1: build property doesn't exist yet, so we can just add it
|
|
287
|
+
if (!buildProp) {
|
|
288
|
+
configObj.properties.push(
|
|
289
|
+
b.objectProperty(
|
|
290
|
+
b.identifier('build'),
|
|
291
|
+
b.objectExpression([
|
|
292
|
+
b.objectProperty(b.identifier('sourcemap'), b.booleanLiteral(true)),
|
|
293
|
+
]),
|
|
294
|
+
),
|
|
295
|
+
);
|
|
296
|
+
return true;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const isValidBuildProp =
|
|
300
|
+
buildProp.type === 'ObjectProperty' &&
|
|
301
|
+
buildProp.value.type === 'ObjectExpression';
|
|
302
|
+
|
|
303
|
+
if (!isValidBuildProp) {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const sourceMapsProp =
|
|
308
|
+
buildProp.value.type === 'ObjectExpression' &&
|
|
309
|
+
buildProp.value.properties.find(
|
|
310
|
+
(p: t.ObjectProperty) =>
|
|
311
|
+
p.key.type === 'Identifier' && p.key.name === 'sourcemap',
|
|
312
|
+
);
|
|
313
|
+
|
|
314
|
+
// case 2: build.sourcemap property doesn't exist yet, so we just add it
|
|
315
|
+
if (!sourceMapsProp && buildProp.value.type === 'ObjectExpression') {
|
|
316
|
+
buildProp.value.properties.push(
|
|
317
|
+
b.objectProperty(b.identifier('sourcemap'), b.booleanLiteral(true)),
|
|
318
|
+
);
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (!sourceMapsProp || sourceMapsProp.type !== 'ObjectProperty') {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// case 3: build.sourcemap property exists, and it's set to 'hidden'
|
|
327
|
+
if (
|
|
328
|
+
sourceMapsProp.value.type === 'StringLiteral' &&
|
|
329
|
+
sourceMapsProp.value.value === 'hidden'
|
|
330
|
+
) {
|
|
331
|
+
// nothing to do for us
|
|
332
|
+
return true;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// case 4: build.sourcemap property exists, but it's not enabled, so we set it to true
|
|
336
|
+
// or it is already true in which case this is a noop
|
|
337
|
+
sourceMapsProp.value = b.booleanLiteral(true);
|
|
338
|
+
return true;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function getViteConfigObject(
|
|
342
|
+
program: t.Program,
|
|
343
|
+
): t.ObjectExpression | undefined {
|
|
344
|
+
const defaultExport = program.body.find(
|
|
345
|
+
(s) => s.type === 'ExportDefaultDeclaration',
|
|
346
|
+
) as t.ExportDefaultDeclaration;
|
|
347
|
+
|
|
348
|
+
if (!defaultExport) {
|
|
349
|
+
return undefined;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
if (defaultExport.declaration.type === 'ObjectExpression') {
|
|
353
|
+
return defaultExport.declaration;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if (
|
|
357
|
+
defaultExport.declaration.type === 'CallExpression' &&
|
|
358
|
+
defaultExport.declaration.arguments[0].type === 'ObjectExpression'
|
|
359
|
+
) {
|
|
360
|
+
return defaultExport.declaration.arguments[0];
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
if (defaultExport.declaration.type === 'Identifier') {
|
|
364
|
+
const configId = defaultExport.declaration.name;
|
|
365
|
+
return findConfigNode(configId, program);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
return undefined;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
function findConfigNode(
|
|
372
|
+
configId: string,
|
|
373
|
+
program: t.Program,
|
|
374
|
+
): t.ObjectExpression | undefined {
|
|
375
|
+
for (const node of program.body) {
|
|
376
|
+
if (node.type === 'VariableDeclaration') {
|
|
377
|
+
for (const declaration of node.declarations) {
|
|
378
|
+
if (
|
|
379
|
+
declaration.type === 'VariableDeclarator' &&
|
|
380
|
+
declaration.id.type === 'Identifier' &&
|
|
381
|
+
declaration.id.name === configId &&
|
|
382
|
+
declaration.init?.type === 'ObjectExpression'
|
|
383
|
+
) {
|
|
384
|
+
return declaration.init;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return undefined;
|
|
390
|
+
}
|
|
@@ -11,7 +11,8 @@ export type SupportedTools =
|
|
|
11
11
|
| 'create-react-app'
|
|
12
12
|
| 'angular'
|
|
13
13
|
| 'nextjs'
|
|
14
|
-
| 'remix'
|
|
14
|
+
| 'remix'
|
|
15
|
+
| 'no-tool';
|
|
15
16
|
|
|
16
17
|
// A map of package names pointing to the tool slug.
|
|
17
18
|
// The order is important, because we want to detect the most specific tool first.
|
|
@@ -15,7 +15,7 @@ import { addVitePlugin } from 'magicast/helpers';
|
|
|
15
15
|
import { getClientHooksTemplate, getServerHooksTemplate } from './templates';
|
|
16
16
|
import { abortIfCancelled, isUsingTypeScript } from '../utils/clack-utils';
|
|
17
17
|
import { debug } from '../utils/debug';
|
|
18
|
-
import {
|
|
18
|
+
import { findFile, hasSentryContent } from '../utils/ast-utils';
|
|
19
19
|
|
|
20
20
|
const SVELTE_CONFIG_FILE = 'svelte.config.js';
|
|
21
21
|
|
|
@@ -46,10 +46,10 @@ export async function createOrMergeSvelteKitFiles(
|
|
|
46
46
|
const { clientHooksPath, serverHooksPath } = getHooksConfigDirs(svelteConfig);
|
|
47
47
|
|
|
48
48
|
// full file paths with correct file ending (or undefined if not found)
|
|
49
|
-
const originalClientHooksFile =
|
|
50
|
-
const originalServerHooksFile =
|
|
49
|
+
const originalClientHooksFile = findFile(clientHooksPath);
|
|
50
|
+
const originalServerHooksFile = findFile(serverHooksPath);
|
|
51
51
|
|
|
52
|
-
const viteConfig =
|
|
52
|
+
const viteConfig = findFile(path.resolve(process.cwd(), 'vite.config'));
|
|
53
53
|
|
|
54
54
|
const fileEnding = isUsingTypeScript() ? 'ts' : 'js';
|
|
55
55
|
|
|
@@ -4,12 +4,10 @@ import chalk from 'chalk';
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
abort,
|
|
7
|
-
|
|
8
|
-
askForProjectSelection,
|
|
9
|
-
askForSelfHosted,
|
|
10
|
-
askForWizardLogin,
|
|
7
|
+
addSentryCliConfig,
|
|
11
8
|
confirmContinueEvenThoughNoGitRepo,
|
|
12
9
|
ensurePackageIsInstalled,
|
|
10
|
+
getOrAskForProjectData,
|
|
13
11
|
getPackageDotJson,
|
|
14
12
|
installPackage,
|
|
15
13
|
printWelcome,
|
|
@@ -32,22 +30,15 @@ export async function runSvelteKitWizard(
|
|
|
32
30
|
const packageJson = await getPackageDotJson();
|
|
33
31
|
await ensurePackageIsInstalled(packageJson, '@sveltejs/kit', 'Sveltekit');
|
|
34
32
|
|
|
35
|
-
const {
|
|
36
|
-
|
|
37
|
-
const { projects, apiKeys } = await askForWizardLogin({
|
|
38
|
-
promoCode: options.promoCode,
|
|
39
|
-
url: sentryUrl,
|
|
40
|
-
platform: 'javascript-sveltekit',
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const selectedProject = await askForProjectSelection(projects);
|
|
33
|
+
const { selectedProject, selfHosted, sentryUrl, authToken } =
|
|
34
|
+
await getOrAskForProjectData(options, 'javascript-sveltekit');
|
|
44
35
|
|
|
45
36
|
await installPackage({
|
|
46
37
|
packageName: '@sentry/sveltekit',
|
|
47
38
|
alreadyInstalled: hasPackageInstalled('@sentry/sveltekit', packageJson),
|
|
48
39
|
});
|
|
49
40
|
|
|
50
|
-
await
|
|
41
|
+
await addSentryCliConfig(authToken);
|
|
51
42
|
|
|
52
43
|
const svelteConfig = await loadSvelteConfig();
|
|
53
44
|
|
package/src/telemetry.ts
CHANGED
|
@@ -52,6 +52,8 @@ function createSentryInstance(enabled: boolean, integration: string) {
|
|
|
52
52
|
dsn: 'https://8871d3ff64814ed8960c96d1fcc98a27@o1.ingest.sentry.io/4505425820712960',
|
|
53
53
|
enabled: enabled,
|
|
54
54
|
|
|
55
|
+
environment: `production-${integration}`,
|
|
56
|
+
|
|
55
57
|
tracesSampleRate: 1,
|
|
56
58
|
sampleRate: 1,
|
|
57
59
|
|
package/src/utils/ast-utils.ts
CHANGED
|
@@ -3,13 +3,15 @@ import * as fs from 'fs';
|
|
|
3
3
|
import { ProxifiedModule } from 'magicast';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Checks if a
|
|
6
|
+
* Checks if a file where we don't know its concrete file type yet exists
|
|
7
7
|
* and returns the full path to the file with the correct file type.
|
|
8
8
|
*/
|
|
9
|
-
export function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export function findFile(
|
|
10
|
+
filePath: string,
|
|
11
|
+
fileTypes: string[] = ['.js', '.ts', '.mjs'],
|
|
12
|
+
): string | undefined {
|
|
13
|
+
return fileTypes
|
|
14
|
+
.map((type) => `${filePath}${type}`)
|
|
13
15
|
.find((file) => fs.existsSync(file));
|
|
14
16
|
}
|
|
15
17
|
|