@sentry/wizard 4.6.0 → 4.8.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 +19 -0
- package/README.md +19 -19
- package/dist/bin.js +9 -0
- package/dist/bin.js.map +1 -1
- package/dist/e2e-tests/tests/angular-17.test.d.ts +1 -0
- package/dist/e2e-tests/tests/angular-17.test.js +196 -0
- package/dist/e2e-tests/tests/angular-17.test.js.map +1 -0
- package/dist/e2e-tests/tests/angular-19.test.d.ts +1 -0
- package/dist/e2e-tests/tests/angular-19.test.js +194 -0
- package/dist/e2e-tests/tests/angular-19.test.js.map +1 -0
- package/dist/e2e-tests/tests/expo.test.d.ts +1 -0
- package/dist/e2e-tests/tests/expo.test.js +95 -0
- package/dist/e2e-tests/tests/expo.test.js.map +1 -0
- package/dist/e2e-tests/tests/flutter.test.js +16 -16
- package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
- package/dist/e2e-tests/tests/help-message.test.d.ts +1 -0
- package/dist/e2e-tests/tests/help-message.test.js +56 -0
- package/dist/e2e-tests/tests/help-message.test.js.map +1 -0
- package/dist/e2e-tests/tests/nextjs-14.test.js +15 -15
- package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-15.test.js +15 -15
- package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-3.test.js +13 -12
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js +13 -12
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
- package/dist/e2e-tests/tests/react-native.test.d.ts +1 -0
- package/dist/e2e-tests/tests/react-native.test.js +97 -0
- package/dist/e2e-tests/tests/react-native.test.js.map +1 -0
- package/dist/e2e-tests/tests/remix.test.js +24 -24
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit.test.js +22 -22
- package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.d.ts +7 -0
- package/dist/e2e-tests/utils/index.js +33 -12
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/lib/Constants.d.ts +6 -1
- package/dist/lib/Constants.js +3 -0
- package/dist/lib/Constants.js.map +1 -1
- package/dist/lib/Helper/Logging.d.ts +1 -1
- package/dist/lib/Helper/Logging.js.map +1 -1
- package/dist/lib/Helper/__tests__/File.js +9 -9
- package/dist/lib/Helper/__tests__/File.js.map +1 -1
- package/dist/lib/Helper/__tests__/MergeConfig.js +17 -17
- package/dist/lib/Helper/__tests__/MergeConfig.js.map +1 -1
- package/dist/lib/Helper/__tests__/SentryCli.js +23 -22
- package/dist/lib/Helper/__tests__/SentryCli.js.map +1 -1
- package/dist/lib/Setup.d.ts +2 -1
- package/dist/lib/Setup.js +12 -2
- package/dist/lib/Setup.js.map +1 -1
- package/dist/lib/Steps/BaseStep.d.ts +1 -1
- package/dist/lib/Steps/BaseStep.js.map +1 -1
- package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
- package/dist/lib/Steps/Welcome.js +5 -0
- package/dist/lib/Steps/Welcome.js.map +1 -1
- package/dist/lib/__tests__/Env.js +4 -3
- package/dist/lib/__tests__/Env.js.map +1 -1
- package/dist/src/angular/angular-wizard.d.ts +3 -0
- package/dist/src/angular/angular-wizard.js +186 -0
- package/dist/src/angular/angular-wizard.js.map +1 -0
- package/dist/src/angular/codemods/app-config.d.ts +3 -0
- package/dist/src/angular/codemods/app-config.js +211 -0
- package/dist/src/angular/codemods/app-config.js.map +1 -0
- package/dist/src/angular/codemods/main.d.ts +20 -0
- package/dist/src/angular/codemods/main.js +62 -0
- package/dist/src/angular/codemods/main.js.map +1 -0
- package/dist/src/angular/codemods/sourcemaps.d.ts +21 -0
- package/dist/src/angular/codemods/sourcemaps.js +94 -0
- package/dist/src/angular/codemods/sourcemaps.js.map +1 -0
- package/dist/src/angular/example-component.d.ts +8 -0
- package/dist/src/angular/example-component.js +286 -0
- package/dist/src/angular/example-component.js.map +1 -0
- package/dist/src/angular/sdk-setup.d.ts +6 -0
- package/dist/src/angular/sdk-setup.js +99 -0
- package/dist/src/angular/sdk-setup.js.map +1 -0
- package/dist/src/apple/apple-wizard.js +24 -64
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/configure-package-manager.d.ts +5 -0
- package/dist/src/apple/configure-package-manager.js +68 -0
- package/dist/src/apple/configure-package-manager.js.map +1 -0
- package/dist/src/apple/configure-sentry-cli.d.ts +4 -0
- package/dist/src/apple/configure-sentry-cli.js +47 -0
- package/dist/src/apple/configure-sentry-cli.js.map +1 -0
- package/dist/src/apple/configure-xcode-project.d.ts +8 -0
- package/dist/src/apple/configure-xcode-project.js +11 -0
- package/dist/src/apple/configure-xcode-project.js.map +1 -0
- package/dist/src/apple/inject-code-snippet.d.ts +6 -0
- package/dist/src/apple/inject-code-snippet.js +54 -0
- package/dist/src/apple/inject-code-snippet.js.map +1 -0
- package/dist/src/apple/templates.js +11 -7
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/apple/xcode-manager.js +3 -6
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/flutter/flutter-wizard.js +10 -2
- package/dist/src/flutter/flutter-wizard.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +26 -12
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.js +59 -8
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/nuxt/templates.js +30 -0
- package/dist/src/nuxt/templates.js.map +1 -1
- package/dist/src/react-native/expo-metro.js +4 -1
- package/dist/src/react-native/expo-metro.js.map +1 -1
- package/dist/src/react-native/expo.js +5 -1
- package/dist/src/react-native/expo.js.map +1 -1
- package/dist/src/react-native/javascript.d.ts +6 -4
- package/dist/src/react-native/javascript.js +33 -10
- package/dist/src/react-native/javascript.js.map +1 -1
- package/dist/src/react-native/metro.js +8 -2
- package/dist/src/react-native/metro.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.d.ts +4 -0
- package/dist/src/react-native/react-native-wizard.js +30 -5
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/react-native/xcode.d.ts +7 -3
- package/dist/src/react-native/xcode.js +68 -20
- package/dist/src/react-native/xcode.js.map +1 -1
- package/dist/src/remix/sdk-example.js +30 -1
- package/dist/src/remix/sdk-example.js.map +1 -1
- package/dist/src/remix/sdk-setup.js +11 -5
- package/dist/src/remix/sdk-setup.js.map +1 -1
- package/dist/src/run.d.ts +1 -1
- package/dist/src/run.js +7 -2
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.d.ts +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js +35 -20
- 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 +7 -7
- package/dist/src/sourcemaps/tools/angular.js.map +1 -1
- package/dist/src/sourcemaps/tools/sentry-cli.d.ts +5 -1
- package/dist/src/sourcemaps/tools/sentry-cli.js +6 -3
- package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
- package/dist/src/sourcemaps/tools/tsc.js +5 -1
- package/dist/src/sourcemaps/tools/tsc.js.map +1 -1
- package/dist/src/sourcemaps/tools/vite.js +4 -1
- package/dist/src/sourcemaps/tools/vite.js.map +1 -1
- package/dist/src/sourcemaps/tools/webpack.js +4 -1
- package/dist/src/sourcemaps/tools/webpack.js.map +1 -1
- package/dist/src/sveltekit/sdk-example.js +1 -1
- package/dist/src/sveltekit/sdk-example.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +2 -2
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/sveltekit/templates.js +28 -1
- package/dist/src/sveltekit/templates.js.map +1 -1
- package/dist/src/utils/clack/index.d.ts +11 -3
- package/dist/src/utils/clack/index.js +12 -4
- package/dist/src/utils/clack/index.js.map +1 -1
- package/dist/src/utils/package-manager.d.ts +2 -0
- package/dist/src/utils/package-manager.js +55 -5
- package/dist/src/utils/package-manager.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/test/android/code-tools.test.js +13 -12
- package/dist/test/android/code-tools.test.js.map +1 -1
- package/dist/test/angular/angular-wizard.test.d.ts +1 -0
- package/dist/test/angular/angular-wizard.test.js +27 -0
- package/dist/test/angular/angular-wizard.test.js.map +1 -0
- package/dist/test/angular/codemods/sourcemaps.test.d.ts +1 -0
- package/dist/test/angular/codemods/sourcemaps.test.js +237 -0
- package/dist/test/angular/codemods/sourcemaps.test.js.map +1 -0
- package/dist/test/angular/example-component.test.d.ts +1 -0
- package/dist/test/angular/example-component.test.js +105 -0
- package/dist/test/angular/example-component.test.js.map +1 -0
- package/dist/test/apple/cocoapod.test.js +77 -72
- package/dist/test/apple/cocoapod.test.js.map +1 -1
- package/dist/test/apple/code-tools.test.js +173 -166
- package/dist/test/apple/code-tools.test.js.map +1 -1
- package/dist/test/apple/fastfile.test.js +86 -83
- package/dist/test/apple/fastfile.test.js.map +1 -1
- package/dist/test/apple/templates.test.js +32 -27
- package/dist/test/apple/templates.test.js.map +1 -1
- package/dist/test/apple/xcode-manager.test.js +182 -183
- package/dist/test/apple/xcode-manager.test.js.map +1 -1
- package/dist/test/flutter/code-tools.test.js +29 -28
- package/dist/test/flutter/code-tools.test.js.map +1 -1
- package/dist/test/flutter/templates.test.js +15 -14
- package/dist/test/flutter/templates.test.js.map +1 -1
- package/dist/test/nextjs/templates.test.js +43 -36
- package/dist/test/nextjs/templates.test.js.map +1 -1
- package/dist/test/nuxt/templates.test.js +25 -24
- package/dist/test/nuxt/templates.test.js.map +1 -1
- package/dist/test/react-native/expo-metro.test.js +11 -10
- package/dist/test/react-native/expo-metro.test.js.map +1 -1
- package/dist/test/react-native/expo.test.js +11 -10
- package/dist/test/react-native/expo.test.js.map +1 -1
- package/dist/test/react-native/gradle.test.js +27 -26
- package/dist/test/react-native/gradle.test.js.map +1 -1
- package/dist/test/react-native/javascript.test.js +108 -58
- package/dist/test/react-native/javascript.test.js.map +1 -1
- package/dist/test/react-native/metro.test.js +178 -64
- package/dist/test/react-native/metro.test.js.map +1 -1
- package/dist/test/react-native/xcode.test.js +138 -37
- package/dist/test/react-native/xcode.test.js.map +1 -1
- package/dist/test/remix/client-entry.test.js +18 -17
- package/dist/test/remix/client-entry.test.js.map +1 -1
- package/dist/test/remix/server-instrumentation.test.js +6 -5
- package/dist/test/remix/server-instrumentation.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/sentry-cli.test.js +20 -20
- package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/tsc.test.js +13 -14
- package/dist/test/sourcemaps/tools/tsc.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/vite.test.js +13 -14
- package/dist/test/sourcemaps/tools/vite.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/webpack.test.js +19 -20
- package/dist/test/sourcemaps/tools/webpack.test.js.map +1 -1
- package/dist/test/sveltekit/templates.test.js +13 -12
- package/dist/test/sveltekit/templates.test.js.map +1 -1
- package/dist/test/utils/ast-utils.test.js +45 -44
- package/dist/test/utils/ast-utils.test.js.map +1 -1
- package/dist/test/utils/clack/index.test.js +140 -144
- package/dist/test/utils/clack/index.test.js.map +1 -1
- package/dist/test/utils/package-manager.test.js +8 -7
- package/dist/test/utils/package-manager.test.js.map +1 -1
- package/package.json +10 -38
- package/dist/e2e-tests/jest.config.d.ts +0 -17
- package/dist/e2e-tests/jest.config.js +0 -23
- package/dist/e2e-tests/jest.config.js.map +0 -1
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
|
|
4
4
|
const magicast_1 = require("magicast");
|
|
5
5
|
const sdk_setup_1 = require("../../src/remix/sdk-setup");
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const vitest_1 = require("vitest");
|
|
7
|
+
(0, vitest_1.describe)('initializeSentryOnEntryClient', () => {
|
|
8
|
+
(0, vitest_1.it)('should initialize Sentry on client entry with all features enabled', () => {
|
|
8
9
|
// Empty entry.client.tsx file for testing
|
|
9
10
|
const originalEntryClientMod = (0, magicast_1.parseModule)('');
|
|
10
11
|
const dsn = 'https://sentry.io/123';
|
|
@@ -13,7 +14,7 @@ describe('initializeSentryOnEntryClient', () => {
|
|
|
13
14
|
replay: true,
|
|
14
15
|
};
|
|
15
16
|
const result = (0, sdk_setup_1.updateEntryClientMod)(originalEntryClientMod, dsn, selectedFeatures);
|
|
16
|
-
expect(result.generate().code).toMatchInlineSnapshot(`
|
|
17
|
+
(0, vitest_1.expect)(result.generate().code).toMatchInlineSnapshot(`
|
|
17
18
|
"import { useEffect,} from "react";
|
|
18
19
|
|
|
19
20
|
import {
|
|
@@ -21,17 +22,17 @@ describe('initializeSentryOnEntryClient', () => {
|
|
|
21
22
|
useMatches,
|
|
22
23
|
} from "@remix-run/react";
|
|
23
24
|
|
|
24
|
-
import
|
|
25
|
+
import { init, replayIntegration, browserTracingIntegration,} from "@sentry/remix";
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
init({
|
|
27
28
|
dsn: "https://sentry.io/123",
|
|
28
29
|
tracesSampleRate: 1,
|
|
29
30
|
|
|
30
|
-
integrations: [
|
|
31
|
+
integrations: [browserTracingIntegration({
|
|
31
32
|
useEffect,
|
|
32
33
|
useLocation,
|
|
33
34
|
useMatches
|
|
34
|
-
}),
|
|
35
|
+
}), replayIntegration({
|
|
35
36
|
maskAllText: true,
|
|
36
37
|
blockAllMedia: true
|
|
37
38
|
})],
|
|
@@ -41,7 +42,7 @@ describe('initializeSentryOnEntryClient', () => {
|
|
|
41
42
|
})"
|
|
42
43
|
`);
|
|
43
44
|
});
|
|
44
|
-
it('should initialize Sentry on client entry when performance disabled', () => {
|
|
45
|
+
(0, vitest_1.it)('should initialize Sentry on client entry when performance disabled', () => {
|
|
45
46
|
// Empty entry.client.tsx file for testing
|
|
46
47
|
const originalEntryClientMod = (0, magicast_1.parseModule)('');
|
|
47
48
|
const dsn = 'https://sentry.io/123';
|
|
@@ -50,13 +51,13 @@ describe('initializeSentryOnEntryClient', () => {
|
|
|
50
51
|
replay: true,
|
|
51
52
|
};
|
|
52
53
|
const result = (0, sdk_setup_1.updateEntryClientMod)(originalEntryClientMod, dsn, selectedFeatures);
|
|
53
|
-
expect(result.generate().code).toMatchInlineSnapshot(`
|
|
54
|
-
"import
|
|
54
|
+
(0, vitest_1.expect)(result.generate().code).toMatchInlineSnapshot(`
|
|
55
|
+
"import { init, replayIntegration,} from "@sentry/remix";
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
init({
|
|
57
58
|
dsn: "https://sentry.io/123",
|
|
58
59
|
|
|
59
|
-
integrations: [
|
|
60
|
+
integrations: [replayIntegration({
|
|
60
61
|
maskAllText: true,
|
|
61
62
|
blockAllMedia: true
|
|
62
63
|
})],
|
|
@@ -66,7 +67,7 @@ describe('initializeSentryOnEntryClient', () => {
|
|
|
66
67
|
})"
|
|
67
68
|
`);
|
|
68
69
|
});
|
|
69
|
-
it('should initialize Sentry on client entry when replay disabled', () => {
|
|
70
|
+
(0, vitest_1.it)('should initialize Sentry on client entry when replay disabled', () => {
|
|
70
71
|
// Empty entry.client.tsx file for testing
|
|
71
72
|
const originalEntryClientMod = (0, magicast_1.parseModule)('');
|
|
72
73
|
const dsn = 'https://sentry.io/123';
|
|
@@ -75,7 +76,7 @@ describe('initializeSentryOnEntryClient', () => {
|
|
|
75
76
|
replay: false,
|
|
76
77
|
};
|
|
77
78
|
const result = (0, sdk_setup_1.updateEntryClientMod)(originalEntryClientMod, dsn, selectedFeatures);
|
|
78
|
-
expect(result.generate().code).toMatchInlineSnapshot(`
|
|
79
|
+
(0, vitest_1.expect)(result.generate().code).toMatchInlineSnapshot(`
|
|
79
80
|
"import { useEffect,} from "react";
|
|
80
81
|
|
|
81
82
|
import {
|
|
@@ -83,13 +84,13 @@ describe('initializeSentryOnEntryClient', () => {
|
|
|
83
84
|
useMatches,
|
|
84
85
|
} from "@remix-run/react";
|
|
85
86
|
|
|
86
|
-
import
|
|
87
|
+
import { init, browserTracingIntegration,} from "@sentry/remix";
|
|
87
88
|
|
|
88
|
-
|
|
89
|
+
init({
|
|
89
90
|
dsn: "https://sentry.io/123",
|
|
90
91
|
tracesSampleRate: 1,
|
|
91
92
|
|
|
92
|
-
integrations: [
|
|
93
|
+
integrations: [browserTracingIntegration({
|
|
93
94
|
useEffect,
|
|
94
95
|
useLocation,
|
|
95
96
|
useMatches
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-entry.test.js","sourceRoot":"","sources":["../../../test/remix/client-entry.test.ts"],"names":[],"mappings":";;AAAA,kFAAkF;AAClF,uCAAuC;AACvC,yDAAiE;
|
|
1
|
+
{"version":3,"file":"client-entry.test.js","sourceRoot":"","sources":["../../../test/remix/client-entry.test.ts"],"names":[],"mappings":";;AAAA,kFAAkF;AAClF,uCAAuC;AACvC,yDAAiE;AACjE,mCAA8C;AAE9C,IAAA,iBAAQ,EAAC,+BAA+B,EAAE,GAAG,EAAE;IAC7C,IAAA,WAAE,EAAC,oEAAoE,EAAE,GAAG,EAAE;QAC5E,0CAA0C;QAC1C,MAAM,sBAAsB,GAAG,IAAA,sBAAW,EAAC,EAAE,CAAC,CAAC;QAE/C,MAAM,GAAG,GAAG,uBAAuB,CAAC;QACpC,MAAM,gBAAgB,GAAG;YACvB,WAAW,EAAE,IAAI;YACjB,MAAM,EAAE,IAAI;SACb,CAAC;QAEF,MAAM,MAAM,GAAG,IAAA,gCAAoB,EACjC,sBAAsB,EACtB,GAAG,EACH,gBAAgB,CACjB,CAAC;QAEF,IAAA,eAAM,EAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;KA0BpD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,oEAAoE,EAAE,GAAG,EAAE;QAC5E,0CAA0C;QAC1C,MAAM,sBAAsB,GAAG,IAAA,sBAAW,EAAC,EAAE,CAAC,CAAC;QAE/C,MAAM,GAAG,GAAG,uBAAuB,CAAC;QACpC,MAAM,gBAAgB,GAAG;YACvB,WAAW,EAAE,KAAK;YAClB,MAAM,EAAE,IAAI;SACb,CAAC;QAEF,MAAM,MAAM,GAAG,IAAA,gCAAoB,EACjC,sBAAsB,EACtB,GAAG,EACH,gBAAgB,CACjB,CAAC;QAEF,IAAA,eAAM,EAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;KAcpD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,+DAA+D,EAAE,GAAG,EAAE;QACvE,0CAA0C;QAC1C,MAAM,sBAAsB,GAAG,IAAA,sBAAW,EAAC,EAAE,CAAC,CAAC;QAE/C,MAAM,GAAG,GAAG,uBAAuB,CAAC;QACpC,MAAM,gBAAgB,GAAG;YACvB,WAAW,EAAE,IAAI;YACjB,MAAM,EAAE,KAAK;SACd,CAAC;QAEF,MAAM,MAAM,GAAG,IAAA,gCAAoB,EACjC,sBAAsB,EACtB,GAAG,EACH,gBAAgB,CACjB,CAAC;QAEF,IAAA,eAAM,EAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;KAoBpD,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { parseModule } from 'magicast';\nimport { updateEntryClientMod } from '../../src/remix/sdk-setup';\nimport { describe, expect, it } from 'vitest';\n\ndescribe('initializeSentryOnEntryClient', () => {\n it('should initialize Sentry on client entry with all features enabled', () => {\n // Empty entry.client.tsx file for testing\n const originalEntryClientMod = parseModule('');\n\n const dsn = 'https://sentry.io/123';\n const selectedFeatures = {\n performance: true,\n replay: true,\n };\n\n const result = updateEntryClientMod(\n originalEntryClientMod,\n dsn,\n selectedFeatures,\n );\n\n expect(result.generate().code).toMatchInlineSnapshot(`\n \"import { useEffect,} from \"react\";\n\n import {\n useLocation,\n useMatches,\n } from \"@remix-run/react\";\n\n import { init, replayIntegration, browserTracingIntegration,} from \"@sentry/remix\";\n\n init({\n dsn: \"https://sentry.io/123\",\n tracesSampleRate: 1,\n\n integrations: [browserTracingIntegration({\n useEffect,\n useLocation,\n useMatches\n }), replayIntegration({\n maskAllText: true,\n blockAllMedia: true\n })],\n\n replaysSessionSampleRate: 0.1,\n replaysOnErrorSampleRate: 1\n })\"\n `);\n });\n\n it('should initialize Sentry on client entry when performance disabled', () => {\n // Empty entry.client.tsx file for testing\n const originalEntryClientMod = parseModule('');\n\n const dsn = 'https://sentry.io/123';\n const selectedFeatures = {\n performance: false,\n replay: true,\n };\n\n const result = updateEntryClientMod(\n originalEntryClientMod,\n dsn,\n selectedFeatures,\n );\n\n expect(result.generate().code).toMatchInlineSnapshot(`\n \"import { init, replayIntegration,} from \"@sentry/remix\";\n\n init({\n dsn: \"https://sentry.io/123\",\n\n integrations: [replayIntegration({\n maskAllText: true,\n blockAllMedia: true\n })],\n\n replaysSessionSampleRate: 0.1,\n replaysOnErrorSampleRate: 1\n })\"\n `);\n });\n\n it('should initialize Sentry on client entry when replay disabled', () => {\n // Empty entry.client.tsx file for testing\n const originalEntryClientMod = parseModule('');\n\n const dsn = 'https://sentry.io/123';\n const selectedFeatures = {\n performance: true,\n replay: false,\n };\n\n const result = updateEntryClientMod(\n originalEntryClientMod,\n dsn,\n selectedFeatures,\n );\n\n expect(result.generate().code).toMatchInlineSnapshot(`\n \"import { useEffect,} from \"react\";\n\n import {\n useLocation,\n useMatches,\n } from \"@remix-run/react\";\n\n import { init, browserTracingIntegration,} from \"@sentry/remix\";\n\n init({\n dsn: \"https://sentry.io/123\",\n tracesSampleRate: 1,\n\n integrations: [browserTracingIntegration({\n useEffect,\n useLocation,\n useMatches\n })]\n })\"\n `);\n });\n});\n"]}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
3
4
|
const sdk_setup_1 = require("../../src/remix/sdk-setup");
|
|
4
|
-
describe('generateServerInstrumentationFile', () => {
|
|
5
|
-
it('should generate server instrumentation file', () => {
|
|
5
|
+
(0, vitest_1.describe)('generateServerInstrumentationFile', () => {
|
|
6
|
+
(0, vitest_1.it)('should generate server instrumentation file', () => {
|
|
6
7
|
const result = (0, sdk_setup_1.generateServerInstrumentationFile)('https://sentry.io/123', {
|
|
7
8
|
performance: true,
|
|
8
9
|
replay: true,
|
|
9
10
|
});
|
|
10
|
-
expect(result.instrumentationFileMod.generate().code)
|
|
11
|
+
(0, vitest_1.expect)(result.instrumentationFileMod.generate().code)
|
|
11
12
|
.toMatchInlineSnapshot(`
|
|
12
13
|
"import * as Sentry from "@sentry/remix";
|
|
13
14
|
|
|
@@ -17,12 +18,12 @@ describe('generateServerInstrumentationFile', () => {
|
|
|
17
18
|
})"
|
|
18
19
|
`);
|
|
19
20
|
});
|
|
20
|
-
it('should generate server instrumentation file when performance is disabled', () => {
|
|
21
|
+
(0, vitest_1.it)('should generate server instrumentation file when performance is disabled', () => {
|
|
21
22
|
const result = (0, sdk_setup_1.generateServerInstrumentationFile)('https://sentry.io/123', {
|
|
22
23
|
performance: false,
|
|
23
24
|
replay: true,
|
|
24
25
|
});
|
|
25
|
-
expect(result.instrumentationFileMod.generate().code)
|
|
26
|
+
(0, vitest_1.expect)(result.instrumentationFileMod.generate().code)
|
|
26
27
|
.toMatchInlineSnapshot(`
|
|
27
28
|
"import * as Sentry from "@sentry/remix";
|
|
28
29
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-instrumentation.test.js","sourceRoot":"","sources":["../../../test/remix/server-instrumentation.test.ts"],"names":[],"mappings":";;AAAA,yDAA8E;AAE9E,
|
|
1
|
+
{"version":3,"file":"server-instrumentation.test.js","sourceRoot":"","sources":["../../../test/remix/server-instrumentation.test.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAC9C,yDAA8E;AAE9E,IAAA,iBAAQ,EAAC,mCAAmC,EAAE,GAAG,EAAE;IACjD,IAAA,WAAE,EAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,MAAM,GAAG,IAAA,6CAAiC,EAAC,uBAAuB,EAAE;YACxE,WAAW,EAAE,IAAI;YACjB,MAAM,EAAE,IAAI;SACb,CAAC,CAAC;QAEH,IAAA,eAAM,EAAC,MAAM,CAAC,sBAAsB,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC;aAClD,qBAAqB,CAAC;;;;;;;KAOxB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,0EAA0E,EAAE,GAAG,EAAE;QAClF,MAAM,MAAM,GAAG,IAAA,6CAAiC,EAAC,uBAAuB,EAAE;YACxE,WAAW,EAAE,KAAK;YAClB,MAAM,EAAE,IAAI;SACb,CAAC,CAAC;QAEH,IAAA,eAAM,EAAC,MAAM,CAAC,sBAAsB,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC;aAClD,qBAAqB,CAAC;;;;;;KAMxB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it } from 'vitest';\nimport { generateServerInstrumentationFile } from '../../src/remix/sdk-setup';\n\ndescribe('generateServerInstrumentationFile', () => {\n it('should generate server instrumentation file', () => {\n const result = generateServerInstrumentationFile('https://sentry.io/123', {\n performance: true,\n replay: true,\n });\n\n expect(result.instrumentationFileMod.generate().code)\n .toMatchInlineSnapshot(`\n \"import * as Sentry from \"@sentry/remix\";\n\n Sentry.init({\n dsn: \"https://sentry.io/123\",\n tracesSampleRate: 1\n })\"\n `);\n });\n\n it('should generate server instrumentation file when performance is disabled', () => {\n const result = generateServerInstrumentationFile('https://sentry.io/123', {\n performance: false,\n replay: true,\n });\n\n expect(result.instrumentationFileMod.generate().code)\n .toMatchInlineSnapshot(`\n \"import * as Sentry from \"@sentry/remix\";\n\n Sentry.init({\n dsn: \"https://sentry.io/123\"\n })\"\n `);\n });\n});\n"]}
|
|
@@ -27,57 +27,57 @@ const fs = __importStar(require("fs"));
|
|
|
27
27
|
const sentry_cli_1 = require("../../../src/sourcemaps/tools/sentry-cli");
|
|
28
28
|
const packageManagerHelpers = __importStar(require("../../../src/utils/package-manager"));
|
|
29
29
|
const clack_1 = require("../../../src/utils/clack");
|
|
30
|
-
const
|
|
30
|
+
const vitest_1 = require("vitest");
|
|
31
|
+
const writeFileSpy = vitest_1.vi
|
|
31
32
|
.spyOn(fs.promises, 'writeFile')
|
|
32
33
|
.mockImplementation(() => Promise.resolve());
|
|
33
|
-
|
|
34
|
+
vitest_1.vi.mock('@clack/prompts', () => {
|
|
34
35
|
return {
|
|
35
36
|
log: {
|
|
36
|
-
info:
|
|
37
|
-
success:
|
|
37
|
+
info: vitest_1.vi.fn(),
|
|
38
|
+
success: vitest_1.vi.fn(),
|
|
38
39
|
},
|
|
39
|
-
confirm:
|
|
40
|
-
isCancel:
|
|
40
|
+
confirm: vitest_1.vi.fn().mockResolvedValue(true),
|
|
41
|
+
isCancel: vitest_1.vi.fn().mockReturnValue(false),
|
|
41
42
|
};
|
|
42
43
|
});
|
|
43
44
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
44
|
-
|
|
45
|
-
...
|
|
46
|
-
getPackageDotJson:
|
|
45
|
+
vitest_1.vi.mock('../../../src/utils/clack', async () => ({
|
|
46
|
+
...(await vitest_1.vi.importActual('../../../src/utils/clack')),
|
|
47
|
+
getPackageDotJson: vitest_1.vi.fn().mockResolvedValue({
|
|
47
48
|
scripts: {
|
|
48
49
|
build: 'tsc',
|
|
49
50
|
},
|
|
50
51
|
version: '1.0.0',
|
|
51
52
|
}),
|
|
52
53
|
}));
|
|
53
|
-
describe('addSentryCommandToBuildCommand', () => {
|
|
54
|
-
afterEach(() => {
|
|
55
|
-
|
|
54
|
+
(0, vitest_1.describe)('addSentryCommandToBuildCommand', () => {
|
|
55
|
+
(0, vitest_1.afterEach)(() => {
|
|
56
|
+
vitest_1.vi.clearAllMocks();
|
|
56
57
|
});
|
|
57
|
-
it.each([
|
|
58
|
+
vitest_1.it.each([
|
|
58
59
|
[
|
|
59
60
|
packageManagerHelpers.NPM,
|
|
60
61
|
packageManagerHelpers.PNPM,
|
|
61
62
|
packageManagerHelpers.YARN_V1,
|
|
62
63
|
packageManagerHelpers.YARN_V2,
|
|
63
64
|
packageManagerHelpers.BUN,
|
|
65
|
+
packageManagerHelpers.DENO,
|
|
64
66
|
],
|
|
65
67
|
])('adds the cli command to the script command (%s)', async (_, pacMan) => {
|
|
66
|
-
|
|
67
|
-
.spyOn(packageManagerHelpers, '_detectPackageManger')
|
|
68
|
-
.mockReturnValue(pacMan);
|
|
68
|
+
vitest_1.vi.spyOn(packageManagerHelpers, '_detectPackageManger').mockReturnValue(pacMan);
|
|
69
69
|
await (0, sentry_cli_1.addSentryCommandToBuildCommand)();
|
|
70
|
-
expect(writeFileSpy).toHaveBeenCalledWith(expect.stringContaining('package.json'), expect.stringContaining(`tsc && ${pacMan.runScriptCommand} sentry:sourcemaps`));
|
|
70
|
+
(0, vitest_1.expect)(writeFileSpy).toHaveBeenCalledWith(vitest_1.expect.stringContaining('package.json'), vitest_1.expect.stringContaining(`tsc && ${pacMan.runScriptCommand} sentry:sourcemaps`));
|
|
71
71
|
});
|
|
72
|
-
it('does not add the cli command to the script command if it is already in there', async () => {
|
|
73
|
-
|
|
72
|
+
(0, vitest_1.it)('does not add the cli command to the script command if it is already in there', async () => {
|
|
73
|
+
vitest_1.vi.mocked(clack_1.getPackageDotJson).mockResolvedValue({
|
|
74
74
|
scripts: {
|
|
75
75
|
build: 'tsc && sentry:sourcemaps',
|
|
76
76
|
},
|
|
77
77
|
version: '1.0.0',
|
|
78
78
|
});
|
|
79
79
|
await (0, sentry_cli_1.addSentryCommandToBuildCommand)();
|
|
80
|
-
expect(writeFileSpy).not.toHaveBeenCalled();
|
|
80
|
+
(0, vitest_1.expect)(writeFileSpy).not.toHaveBeenCalled();
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
83
|
//# sourceMappingURL=sentry-cli.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sentry-cli.test.js","sourceRoot":"","sources":["../../../../test/sourcemaps/tools/sentry-cli.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,yEAA0F;AAE1F,0FAA4E;AAC5E,oDAA6D;
|
|
1
|
+
{"version":3,"file":"sentry-cli.test.js","sourceRoot":"","sources":["../../../../test/sourcemaps/tools/sentry-cli.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,yEAA0F;AAE1F,0FAA4E;AAC5E,oDAA6D;AAE7D,mCAA6D;AAE7D,MAAM,YAAY,GAAG,WAAE;KACpB,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC;KAC/B,kBAAkB,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;AAE/C,WAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC7B,OAAO;QACL,GAAG,EAAE;YACH,IAAI,EAAE,WAAE,CAAC,EAAE,EAAE;YACb,OAAO,EAAE,WAAE,CAAC,EAAE,EAAE;SACjB;QACD,OAAO,EAAE,WAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC;QACxC,Q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KAAK,IAAI,EAAE;QAC5F,WAAE,CAAC,MAAM,CAAC,yBAAiB,CAAC,CAAC,iBAAiB,CAAC;YAC7C,OAAO,EAAE;gBACP,KAAK,EAAE,0BAA0B;aAClC;YACD,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;QAEH,MAAM,IAAA,2CAA8B,GAAE,CAAC;QAEvC,IAAA,eAAM,EAAC,YAAY,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as fs from 'fs';\n\nimport { addSentryCommandToBuildCommand } from '../../../src/sourcemaps/tools/sentry-cli';\n\nimport * as packageManagerHelpers from '../../../src/utils/package-manager';\nimport { getPackageDotJson } from '../../../src/utils/clack';\n\nimport { vi, it, describe, expect, afterEach } from 'vitest';\n\nconst writeFileSpy = vi\n .spyOn(fs.promises, 'writeFile')\n .mockImplementation(() => Promise.resolve());\n\nvi.mock('@clack/prompts', () => {\n return {\n log: {\n info: vi.fn(),\n success: vi.fn(),\n },\n confirm: vi.fn().mockResolvedValue(true),\n isCancel: vi.fn().mockReturnValue(false),\n };\n});\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-return\nvi.mock('../../../src/utils/clack', async () => ({\n ...(await vi.importActual('../../../src/utils/clack')),\n getPackageDotJson: vi.fn().mockResolvedValue({\n scripts: {\n build: 'tsc',\n },\n version: '1.0.0',\n }),\n}));\n\ndescribe('addSentryCommandToBuildCommand', () => {\n afterEach(() => {\n vi.clearAllMocks();\n });\n it.each([\n [\n packageManagerHelpers.NPM,\n packageManagerHelpers.PNPM,\n packageManagerHelpers.YARN_V1,\n packageManagerHelpers.YARN_V2,\n packageManagerHelpers.BUN,\n packageManagerHelpers.DENO,\n ],\n ])('adds the cli command to the script command (%s)', async (_, pacMan) => {\n vi.spyOn(packageManagerHelpers, '_detectPackageManger').mockReturnValue(\n pacMan,\n );\n await addSentryCommandToBuildCommand();\n expect(writeFileSpy).toHaveBeenCalledWith(\n expect.stringContaining('package.json'),\n expect.stringContaining(\n `tsc && ${pacMan.runScriptCommand} sentry:sourcemaps`,\n ),\n );\n });\n\n it('does not add the cli command to the script command if it is already in there', async () => {\n vi.mocked(getPackageDotJson).mockResolvedValue({\n scripts: {\n build: 'tsc && sentry:sourcemaps',\n },\n version: '1.0.0',\n });\n\n await addSentryCommandToBuildCommand();\n\n expect(writeFileSpy).not.toHaveBeenCalled();\n });\n});\n"]}
|
|
@@ -25,30 +25,29 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const fs = __importStar(require("fs"));
|
|
27
27
|
const tsc_1 = require("../../../src/sourcemaps/tools/tsc");
|
|
28
|
+
const vitest_1 = require("vitest");
|
|
28
29
|
function updateFileContent(content) {
|
|
29
30
|
fileContent = content;
|
|
30
31
|
}
|
|
31
32
|
let fileContent = '';
|
|
32
|
-
|
|
33
|
+
vitest_1.vi.mock('@clack/prompts', () => {
|
|
33
34
|
return {
|
|
34
35
|
log: {
|
|
35
|
-
info:
|
|
36
|
-
success:
|
|
36
|
+
info: vitest_1.vi.fn(),
|
|
37
|
+
success: vitest_1.vi.fn(),
|
|
37
38
|
},
|
|
38
39
|
};
|
|
39
40
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
.mockImplementation(() => Promise.resolve(fileContent));
|
|
43
|
-
const writeFileSpy = jest
|
|
41
|
+
vitest_1.vi.spyOn(fs.promises, 'readFile').mockImplementation(() => Promise.resolve(fileContent));
|
|
42
|
+
const writeFileSpy = vitest_1.vi
|
|
44
43
|
.spyOn(fs.promises, 'writeFile')
|
|
45
44
|
.mockImplementation(() => Promise.resolve(void 0));
|
|
46
|
-
describe('enableSourcemaps', () => {
|
|
47
|
-
afterEach(() => {
|
|
45
|
+
(0, vitest_1.describe)('enableSourcemaps', () => {
|
|
46
|
+
(0, vitest_1.afterEach)(() => {
|
|
48
47
|
fileContent = '';
|
|
49
|
-
|
|
48
|
+
vitest_1.vi.clearAllMocks();
|
|
50
49
|
});
|
|
51
|
-
it.each([
|
|
50
|
+
vitest_1.it.each([
|
|
52
51
|
[
|
|
53
52
|
'no sourcemaps options',
|
|
54
53
|
`
|
|
@@ -186,10 +185,10 @@ describe('enableSourcemaps', () => {
|
|
|
186
185
|
])('adds the plugin and enables source maps generation (%s)', async (_, originalCode, expectedCode) => {
|
|
187
186
|
updateFileContent(originalCode);
|
|
188
187
|
const addedCode = await (0, tsc_1.enableSourcemaps)('');
|
|
189
|
-
expect(writeFileSpy).toHaveBeenCalledTimes(1);
|
|
188
|
+
(0, vitest_1.expect)(writeFileSpy).toHaveBeenCalledTimes(1);
|
|
190
189
|
const [[, fileContent]] = writeFileSpy.mock.calls;
|
|
191
|
-
expect(fileContent).toBe(expectedCode);
|
|
192
|
-
expect(addedCode).toBe(true);
|
|
190
|
+
(0, vitest_1.expect)(fileContent).toBe(expectedCode);
|
|
191
|
+
(0, vitest_1.expect)(addedCode).toBe(true);
|
|
193
192
|
});
|
|
194
193
|
});
|
|
195
194
|
//# sourceMappingURL=tsc.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsc.test.js","sourceRoot":"","sources":["../../../../test/sourcemaps/tools/tsc.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2DAAqE;AAErE,SAAS,iBAAiB,CAAC,OAAe;IACxC,WAAW,GAAG,OAAO,CAAC;AACxB,CAAC;AAED,IAAI,WAAW,GAAG,EAAE,CAAC;AAErB,
|
|
1
|
+
{"version":3,"file":"tsc.test.js","sourceRoot":"","sources":["../../../../test/sourcemaps/tools/tsc.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2DAAqE;AAErE,mCAA6D;AAE7D,SAAS,iBAAiB,CAAC,OAAe;IACxC,WAAW,GAAG,OAAO,CAAC;AACxB,C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,sBAAgB,EAAC,EAAE,CAAC,CAAC;QAE7C,IAAA,eAAM,EAAC,YAAY,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAC9C,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;QAClD,IAAA,eAAM,EAAC,WAAW,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvC,IAAA,eAAM,EAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CACF,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import * as fs from 'fs';\nimport { enableSourcemaps } from '../../../src/sourcemaps/tools/tsc';\n\nimport { vi, it, describe, expect, afterEach } from 'vitest';\n\nfunction updateFileContent(content: string): void {\n fileContent = content;\n}\n\nlet fileContent = '';\n\nvi.mock('@clack/prompts', () => {\n return {\n log: {\n info: vi.fn(),\n success: vi.fn(),\n },\n };\n});\n\nvi.spyOn(fs.promises, 'readFile').mockImplementation(() =>\n Promise.resolve(fileContent),\n);\n\nconst writeFileSpy = vi\n .spyOn(fs.promises, 'writeFile')\n .mockImplementation(() => Promise.resolve(void 0));\n\ndescribe('enableSourcemaps', () => {\n afterEach(() => {\n fileContent = '';\n vi.clearAllMocks();\n });\n\n it.each([\n [\n 'no sourcemaps options',\n `\n/**\n * My TS config with comments\n */\n{\n \"extends\": \"./tsconfig.build.json\",\n\n \"compilerOptions\": {\n // line comment which should stay\n \"moduleResolution\": \"node16\",\n \"outDir\": \"dist\" // another inline comment\n },\n\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ]\n}\n`,\n `\n/**\n * My TS config with comments\n */\n{\n \"extends\": \"./tsconfig.build.json\",\n\n \"compilerOptions\": {\n // line comment which should stay\n \"moduleResolution\": \"node16\",\n\n // another inline comment\n \"outDir\": \"dist\",\n\n \"sourceMap\": true,\n \"inlineSources\": true,\n\n // Set \\`sourceRoot\\` to \"/\" to strip the build path prefix\n // from generated source code references.\n // This improves issue grouping in Sentry.\n \"sourceRoot\": \"/\"\n },\n\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ]\n}\n`,\n ],\n [\n 'a few sourcemaps options',\n `\n/**\n * My TS config with comments\n */\n{\n \"extends\": \"./tsconfig.build.json\",\n\n \"compilerOptions\": {\n // line comment which should stay\n \"moduleResolution\": \"node16\",\n \"outDir\": \"dist\", // another inline comment\n \"sourceMap\": false,\n \"sourceRoot\": \"/src\"\n },\n\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ]\n}\n`,\n `\n/**\n * My TS config with comments\n */\n{\n \"extends\": \"./tsconfig.build.json\",\n\n \"compilerOptions\": {\n // line comment which should stay\n \"moduleResolution\": \"node16\",\n\n // another inline comment\n \"outDir\": \"dist\",\n\n \"sourceMap\": true,\n\n // Set \\`sourceRoot\\` to \"/\" to strip the build path prefix\n // from generated source code references.\n // This improves issue grouping in Sentry.\n \"sourceRoot\": \"/\",\n\n \"inlineSources\": true\n },\n\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ]\n}\n`,\n ],\n [\n 'no compiler options',\n `\n{\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ]\n}\n`,\n `\n{\n \"include\": [\n \"src/**/*\",\n \"test/**/*\"\n ],\n\n \"compilerOptions\": {\n \"sourceMap\": true,\n \"inlineSources\": true,\n\n // Set \\`sourceRoot\\` to \"/\" to strip the build path prefix\n // from generated source code references.\n // This improves issue grouping in Sentry.\n \"sourceRoot\": \"/\"\n }\n}\n`,\n ],\n ])(\n 'adds the plugin and enables source maps generation (%s)',\n async (_, originalCode, expectedCode) => {\n updateFileContent(originalCode);\n\n const addedCode = await enableSourcemaps('');\n\n expect(writeFileSpy).toHaveBeenCalledTimes(1);\n const [[, fileContent]] = writeFileSpy.mock.calls;\n expect(fileContent).toBe(expectedCode);\n expect(addedCode).toBe(true);\n },\n );\n});\n"]}
|
|
@@ -25,30 +25,29 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const fs = __importStar(require("fs"));
|
|
27
27
|
const vite_1 = require("../../../src/sourcemaps/tools/vite");
|
|
28
|
+
const vitest_1 = require("vitest");
|
|
28
29
|
function updateFileContent(content) {
|
|
29
30
|
fileContent = content;
|
|
30
31
|
}
|
|
31
32
|
let fileContent = '';
|
|
32
|
-
|
|
33
|
+
vitest_1.vi.mock('@clack/prompts', () => {
|
|
33
34
|
return {
|
|
34
35
|
log: {
|
|
35
|
-
info:
|
|
36
|
-
success:
|
|
36
|
+
info: vitest_1.vi.fn(),
|
|
37
|
+
success: vitest_1.vi.fn(),
|
|
37
38
|
},
|
|
38
39
|
};
|
|
39
40
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
.mockImplementation(() => Promise.resolve(fileContent));
|
|
43
|
-
const writeFileSpy = jest
|
|
41
|
+
vitest_1.vi.spyOn(fs.promises, 'readFile').mockImplementation(() => Promise.resolve(fileContent));
|
|
42
|
+
const writeFileSpy = vitest_1.vi
|
|
44
43
|
.spyOn(fs.promises, 'writeFile')
|
|
45
44
|
.mockImplementation(() => Promise.resolve(void 0));
|
|
46
|
-
describe('addVitePluginToConfig', () => {
|
|
47
|
-
afterEach(() => {
|
|
45
|
+
(0, vitest_1.describe)('addVitePluginToConfig', () => {
|
|
46
|
+
(0, vitest_1.afterEach)(() => {
|
|
48
47
|
fileContent = '';
|
|
49
|
-
|
|
48
|
+
vitest_1.vi.clearAllMocks();
|
|
50
49
|
});
|
|
51
|
-
it.each([
|
|
50
|
+
vitest_1.it.each([
|
|
52
51
|
[
|
|
53
52
|
'no build options',
|
|
54
53
|
`
|
|
@@ -154,10 +153,10 @@ export default cfg;`,
|
|
|
154
153
|
selfHosted: false,
|
|
155
154
|
url: 'https://sentry.io/',
|
|
156
155
|
});
|
|
157
|
-
expect(writeFileSpy).toHaveBeenCalledTimes(1);
|
|
156
|
+
(0, vitest_1.expect)(writeFileSpy).toHaveBeenCalledTimes(1);
|
|
158
157
|
const [[, fileContent]] = writeFileSpy.mock.calls;
|
|
159
|
-
expect(fileContent).toBe(expectedCode);
|
|
160
|
-
expect(addedCode).toBe(true);
|
|
158
|
+
(0, vitest_1.expect)(fileContent).toBe(expectedCode);
|
|
159
|
+
(0, vitest_1.expect)(addedCode).toBe(true);
|
|
161
160
|
});
|
|
162
161
|
});
|
|
163
162
|
//# sourceMappingURL=vite.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.test.js","sourceRoot":"","sources":["../../../../test/sourcemaps/tools/vite.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,6DAA2E;AAE3E,SAAS,iBAAiB,CAAC,OAAe;IACxC,WAAW,GAAG,OAAO,CAAC;AACxB,CAAC;AAED,IAAI,WAAW,GAAG,EAAE,CAAC;AAErB,
|
|
1
|
+
{"version":3,"file":"vite.test.js","sourceRoot":"","sources":["../../../../test/sourcemaps/tools/vite.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,6DAA2E;AAE3E,mCAA6D;AAE7D,SAAS,iBAAiB,CAAC,OAAe;IACxC,WAAW,GAAG,OAAO,CAAC;AACxB,CAAC;AAED,IAAI,WAAW,GAAG,EAAE,CAAC;AAErB,WAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC7B,OAAO;QACL,GAAG,EAAE;YACH,IAAI,EAAE,WAAE,CAAC,EAAE,EAAE;YACb,OAAO,EAAE,WAAE,CAAC,EAAE,EAAE;SACjB;KACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,WAAE,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,CACxD,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAC7B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,IAAA,eAAM,EAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CACF,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import * as fs from 'fs';\nimport { addVitePluginToConfig } from '../../../src/sourcemaps/tools/vite';\n\nimport { vi, it, describe, expect, afterEach } from 'vitest';\n\nfunction updateFileContent(content: string): void {\n fileContent = content;\n}\n\nlet fileContent = '';\n\nvi.mock('@clack/prompts', () => {\n return {\n log: {\n info: vi.fn(),\n success: vi.fn(),\n },\n };\n});\n\nvi.spyOn(fs.promises, 'readFile').mockImplementation(() =>\n Promise.resolve(fileContent),\n);\n\nconst writeFileSpy = vi\n .spyOn(fs.promises, 'writeFile')\n .mockImplementation(() => Promise.resolve(void 0));\n\ndescribe('addVitePluginToConfig', () => {\n afterEach(() => {\n fileContent = '';\n vi.clearAllMocks();\n });\n\n it.each([\n [\n 'no build options',\n `\nexport default defineConfig({\n plugins: [\n vue(),\n ],\n})\n`,\n `import { sentryVitePlugin } from \"@sentry/vite-plugin\";\nexport default defineConfig({\n plugins: [vue(), sentryVitePlugin({\n org: \"my-org\",\n project: \"my-project\"\n })],\n\n build: {\n sourcemap: true\n }\n})`,\n ],\n [\n 'no build.sourcemap options',\n `\nexport default defineConfig({\n plugins: [\n vue(),\n ],\n build: {\n test: 1, \n }\n})\n `,\n `import { sentryVitePlugin } from \"@sentry/vite-plugin\";\nexport default defineConfig({\n plugins: [vue(), sentryVitePlugin({\n org: \"my-org\",\n project: \"my-project\"\n })],\n build: {\n test: 1,\n sourcemap: true\n }\n})`,\n ],\n [\n 'keep sourcemap: \"hidden\"',\n `\nexport default {\n plugins: [\n vue(),\n ],\n build: {\n sourcemap: \"hidden\",\n }\n}\n `,\n `import { sentryVitePlugin } from \"@sentry/vite-plugin\";\nexport default {\n plugins: [vue(), sentryVitePlugin({\n org: \"my-org\",\n project: \"my-project\"\n })],\n build: {\n sourcemap: \"hidden\",\n }\n}`,\n ],\n [\n 'rewrite sourcemap: false to true',\n `\nconst cfg = {\n plugins: [\n vue(),\n ],\n build: {\n sourcemap: false,\n }\n}\n\nexport default cfg;\n `,\n `import { sentryVitePlugin } from \"@sentry/vite-plugin\";\nconst cfg = {\n plugins: [vue(), sentryVitePlugin({\n org: \"my-org\",\n project: \"my-project\"\n })],\n\n build: {\n sourcemap: true,\n }\n}\n\nexport default cfg;`,\n ],\n ])(\n 'adds the plugin and enables source maps generation (%s)',\n async (_, originalCode, expectedCode) => {\n updateFileContent(originalCode);\n\n const addedCode = await addVitePluginToConfig('', {\n authToken: '',\n orgSlug: 'my-org',\n projectSlug: 'my-project',\n selfHosted: false,\n url: 'https://sentry.io/',\n });\n\n expect(writeFileSpy).toHaveBeenCalledTimes(1);\n const [[, fileContent]] = writeFileSpy.mock.calls;\n expect(fileContent).toBe(expectedCode);\n expect(addedCode).toBe(true);\n },\n );\n});\n"]}
|
|
@@ -25,24 +25,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const fs = __importStar(require("fs"));
|
|
27
27
|
const webpack_1 = require("../../../src/sourcemaps/tools/webpack");
|
|
28
|
+
const vitest_1 = require("vitest");
|
|
28
29
|
function updateFileContent(content) {
|
|
29
30
|
fileContent = content;
|
|
30
31
|
}
|
|
31
32
|
let fileContent = '';
|
|
32
|
-
|
|
33
|
+
vitest_1.vi.mock('@clack/prompts', () => {
|
|
33
34
|
return {
|
|
34
35
|
log: {
|
|
35
|
-
info:
|
|
36
|
-
success:
|
|
36
|
+
info: vitest_1.vi.fn(),
|
|
37
|
+
success: vitest_1.vi.fn(),
|
|
37
38
|
},
|
|
38
|
-
select:
|
|
39
|
-
isCancel:
|
|
39
|
+
select: vitest_1.vi.fn().mockImplementation(() => Promise.resolve(true)),
|
|
40
|
+
isCancel: vitest_1.vi.fn().mockReturnValue(false),
|
|
40
41
|
};
|
|
41
42
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.mockImplementation(() => Promise.resolve(fileContent));
|
|
45
|
-
const writeFileSpy = jest
|
|
43
|
+
vitest_1.vi.spyOn(fs.promises, 'readFile').mockImplementation(() => Promise.resolve(fileContent));
|
|
44
|
+
const writeFileSpy = vitest_1.vi
|
|
46
45
|
.spyOn(fs.promises, 'writeFile')
|
|
47
46
|
.mockImplementation(() => Promise.resolve(void 0));
|
|
48
47
|
const noSourcemapNoPluginsPojo = `module.exports = {
|
|
@@ -234,12 +233,12 @@ module.exports = {
|
|
|
234
233
|
|
|
235
234
|
devtool: "source-map"
|
|
236
235
|
};`;
|
|
237
|
-
describe('modifyWebpackConfig', () => {
|
|
238
|
-
afterEach(() => {
|
|
236
|
+
(0, vitest_1.describe)('modifyWebpackConfig', () => {
|
|
237
|
+
(0, vitest_1.afterEach)(() => {
|
|
239
238
|
fileContent = '';
|
|
240
|
-
|
|
239
|
+
vitest_1.vi.clearAllMocks();
|
|
241
240
|
});
|
|
242
|
-
it.each([
|
|
241
|
+
vitest_1.it.each([
|
|
243
242
|
[
|
|
244
243
|
'no sourcemap option, no plugins, object',
|
|
245
244
|
noSourcemapNoPluginsPojo,
|
|
@@ -280,12 +279,12 @@ describe('modifyWebpackConfig', () => {
|
|
|
280
279
|
selfHosted: false,
|
|
281
280
|
url: 'https://sentry.io/',
|
|
282
281
|
});
|
|
283
|
-
expect(writeFileSpy).toHaveBeenCalledTimes(1);
|
|
282
|
+
(0, vitest_1.expect)(writeFileSpy).toHaveBeenCalledTimes(1);
|
|
284
283
|
const [[, fileContent]] = writeFileSpy.mock.calls;
|
|
285
|
-
expect(fileContent).toBe(expectedCode);
|
|
286
|
-
expect(addedCode).toBe(true);
|
|
284
|
+
(0, vitest_1.expect)(fileContent).toBe(expectedCode);
|
|
285
|
+
(0, vitest_1.expect)(addedCode).toBe(true);
|
|
287
286
|
});
|
|
288
|
-
it('adds the url parameter to the webpack plugin options if self-hosted', async () => {
|
|
287
|
+
(0, vitest_1.it)('adds the url parameter to the webpack plugin options if self-hosted', async () => {
|
|
289
288
|
updateFileContent(noSourcemapNoPluginsPojo);
|
|
290
289
|
const addedCode = await (0, webpack_1.modifyWebpackConfig)('', {
|
|
291
290
|
authToken: '',
|
|
@@ -294,10 +293,10 @@ describe('modifyWebpackConfig', () => {
|
|
|
294
293
|
selfHosted: true,
|
|
295
294
|
url: 'https://santry.io/',
|
|
296
295
|
});
|
|
297
|
-
expect(writeFileSpy).toHaveBeenCalledTimes(1);
|
|
296
|
+
(0, vitest_1.expect)(writeFileSpy).toHaveBeenCalledTimes(1);
|
|
298
297
|
const [[, fileContent]] = writeFileSpy.mock.calls;
|
|
299
|
-
expect(fileContent).toContain('url: "https://santry.io/"');
|
|
300
|
-
expect(addedCode).toBe(true);
|
|
298
|
+
(0, vitest_1.expect)(fileContent).toContain('url: "https://santry.io/"');
|
|
299
|
+
(0, vitest_1.expect)(addedCode).toBe(true);
|
|
301
300
|
});
|
|
302
301
|
});
|
|
303
302
|
//# sourceMappingURL=webpack.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.test.js","sourceRoot":"","sources":["../../../../test/sourcemaps/tools/webpack.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,mEAA4E;AAE5E,SAAS,iBAAiB,CAAC,OAAe;IACxC,WAAW,GAAG,OAAO,CAAC;AACxB,CAAC;AAED,IAAI,WAAW,GAAG,EAAE,CAAC;AAErB,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC/B,OAAO;QACL,GAAG,EAAE;YACH,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;YACf,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;SACnB;QACD,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjE,QAAQ,EAAE,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AS,EAAE,EAAE;YACb,OAAO,EAAE,QAAQ;YACjB,WAAW,EAAE,YAAY;YACzB,UAAU,EAAE,IAAI;YAChB,GAAG,EAAE,oBAAoB;SAC1B,CAAC,CAAC;QAEH,MAAM,CAAC,YAAY,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAC9C,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;QAClD,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;QAC3D,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as fs from 'fs';\n\nimport { modifyWebpackConfig } from '../../../src/sourcemaps/tools/webpack';\n\nfunction updateFileContent(content: string): void {\n fileContent = content;\n}\n\nlet fileContent = '';\n\njest.mock('@clack/prompts', () => {\n return {\n log: {\n info: jest.fn(),\n success: jest.fn(),\n },\n select: jest.fn().mockImplementation(() => Promise.resolve(true)),\n isCancel: jest.fn().mockReturnValue(false),\n };\n});\n\njest\n .spyOn(fs.promises, 'readFile')\n .mockImplementation(() => Promise.resolve(fileContent));\n\nconst writeFileSpy = jest\n .spyOn(fs.promises, 'writeFile')\n .mockImplementation(() => Promise.resolve(void 0));\n\nconst noSourcemapNoPluginsPojo = `module.exports = {\n entry: \"./src/index.js\",\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n};`;\n\nconst noSourcemapNoPluginsPojoResult = `const {\n sentryWebpackPlugin\n} = require(\"@sentry/webpack-plugin\");\n\nmodule.exports = {\n entry: \"./src/index.js\",\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n\n devtool: \"source-map\",\n\n plugins: [sentryWebpackPlugin({\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: \"my-org\",\n project: \"my-project\"\n })]\n};`;\n\nconst noSourcemapsNoPluginsId = `const config = {\n entry: \"./src/index.js\",\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n};\n\nmodule.exports = config;`;\n\nconst noSourcemapsNoPluginsIdResult = `const {\n sentryWebpackPlugin\n} = require(\"@sentry/webpack-plugin\");\n\nconst config = {\n entry: \"./src/index.js\",\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n\n devtool: \"source-map\",\n\n plugins: [sentryWebpackPlugin({\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: \"my-org\",\n project: \"my-project\"\n })]\n};\n\nmodule.exports = config;`;\n\nconst hiddenSourcemapNoPluginsId = `const config = {\n entry: \"./src/index.js\",\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n\n devtool: \"hidden-cheap-source-map\",\n};\n\nmodule.exports = config;\n `;\nconst hiddenSourcemapNoPluginsIdResult = `const {\n sentryWebpackPlugin\n} = require(\"@sentry/webpack-plugin\");\n\nconst config = {\n entry: \"./src/index.js\",\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n\n devtool: \"hidden-source-map\",\n\n plugins: [sentryWebpackPlugin({\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: \"my-org\",\n project: \"my-project\"\n })]\n};\n\nmodule.exports = config;`;\n\nconst arbitrarySourcemapNoPluginsId = `\nconst config = {\n entry: \"./src/index.js\",\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n\n devtool: getSourcemapSetting(),\n};\n\nmodule.exports = config;\n `;\nconst arbitrarySourcemapNoPluginsIdResult = `const {\n sentryWebpackPlugin\n} = require(\"@sentry/webpack-plugin\");\n\nconst config = {\n entry: \"./src/index.js\",\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n\n devtool: \"source-map\",\n\n plugins: [sentryWebpackPlugin({\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: \"my-org\",\n project: \"my-project\"\n })]\n};\n\nmodule.exports = config;`;\n\nconst noSourcemapUndefinedPluginsPojo = `module.exports = {\n entry: \"./src/index.js\",\n plugins: undefined,\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n};`;\n\nconst noSourcemapUndefinedPluginsPojoResult = `const {\n sentryWebpackPlugin\n} = require(\"@sentry/webpack-plugin\");\n\nmodule.exports = {\n entry: \"./src/index.js\",\n\n plugins: [sentryWebpackPlugin({\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: \"my-org\",\n project: \"my-project\"\n })],\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n\n devtool: \"source-map\"\n};`;\n\nconst noSourcemapPluginsPojo = `module.exports = {\n entry: \"./src/index.js\",\n plugins: [\n new HtmlWebpackPlugin(),\n new MiniCssExtractPlugin(),\n ],\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n};`;\n\nconst noSourcemapPluginsPojoResult = `const {\n sentryWebpackPlugin\n} = require(\"@sentry/webpack-plugin\");\n\nmodule.exports = {\n entry: \"./src/index.js\",\n\n plugins: [new HtmlWebpackPlugin(), new MiniCssExtractPlugin(), sentryWebpackPlugin({\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: \"my-org\",\n project: \"my-project\"\n })],\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n\n devtool: \"source-map\"\n};`;\n\ndescribe('modifyWebpackConfig', () => {\n afterEach(() => {\n fileContent = '';\n jest.clearAllMocks();\n });\n\n it.each([\n [\n 'no sourcemap option, no plugins, object',\n noSourcemapNoPluginsPojo,\n noSourcemapNoPluginsPojoResult,\n ],\n [\n 'no sourcemap option, no plugins, identifier',\n noSourcemapsNoPluginsId,\n noSourcemapsNoPluginsIdResult,\n ],\n [\n 'hidden sourcemap option, no plugins, identifier',\n hiddenSourcemapNoPluginsId,\n hiddenSourcemapNoPluginsIdResult,\n ],\n [\n 'arbitrary sourcemap option, no plugins, identifier',\n arbitrarySourcemapNoPluginsId,\n arbitrarySourcemapNoPluginsIdResult,\n ],\n [\n 'no sourcemap option, plugins, object',\n noSourcemapUndefinedPluginsPojo,\n noSourcemapUndefinedPluginsPojoResult,\n ],\n [\n 'no sourcemap option, plugins, object',\n noSourcemapPluginsPojo,\n noSourcemapPluginsPojoResult,\n ],\n ])(\n 'adds plugin and source maps emission to the webpack config (%s)',\n async (_, originalCode, expectedCode) => {\n updateFileContent(originalCode);\n\n // updateFileContent(originalCode);\n const addedCode = await modifyWebpackConfig('', {\n authToken: '',\n orgSlug: 'my-org',\n projectSlug: 'my-project',\n selfHosted: false,\n url: 'https://sentry.io/',\n });\n\n expect(writeFileSpy).toHaveBeenCalledTimes(1);\n const [[, fileContent]] = writeFileSpy.mock.calls;\n expect(fileContent).toBe(expectedCode);\n expect(addedCode).toBe(true);\n },\n );\n\n it('adds the url parameter to the webpack plugin options if self-hosted', async () => {\n updateFileContent(noSourcemapNoPluginsPojo);\n\n const addedCode = await modifyWebpackConfig('', {\n authToken: '',\n orgSlug: 'my-org',\n projectSlug: 'my-project',\n selfHosted: true,\n url: 'https://santry.io/',\n });\n\n expect(writeFileSpy).toHaveBeenCalledTimes(1);\n const [[, fileContent]] = writeFileSpy.mock.calls;\n expect(fileContent).toContain('url: \"https://santry.io/\"');\n expect(addedCode).toBe(true);\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"webpack.test.js","sourceRoot":"","sources":["../../../../test/sourcemaps/tools/webpack.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,mEAA4E;AAE5E,mCAA6D;AAE7D,SAAS,iBAAiB,CAAC,OAAe;IACxC,WAAW,GAAG,OAAO,CAAC;AACxB,CAAC;AAED,IAAI,WAAW,GAAG,EAAE,CAAC;AAErB,WAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,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CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACvC,IAAA,eAAM,EAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CACF,CAAC;IAEF,IAAA,WAAE,EAAC,qEAAqE,EAAE,KAAK,IAAI,EAAE;QACnF,iBAAiB,CAAC,wBAAwB,CAAC,CAAC;QAE5C,MAAM,SAAS,GAAG,MAAM,IAAA,6BAAmB,EAAC,EAAE,EAAE;YAC9C,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,QAAQ;YACjB,WAAW,EAAE,YAAY;YACzB,UAAU,EAAE,IAAI;YAChB,GAAG,EAAE,oBAAoB;SAC1B,CAAC,CAAC;QAEH,IAAA,eAAM,EAAC,YAAY,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAC9C,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;QAClD,IAAA,eAAM,EAAC,WAAW,CAAC,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;QAC3D,IAAA,eAAM,EAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import * as fs from 'fs';\n\nimport { modifyWebpackConfig } from '../../../src/sourcemaps/tools/webpack';\n\nimport { vi, it, expect, describe, afterEach } from 'vitest';\n\nfunction updateFileContent(content: string): void {\n fileContent = content;\n}\n\nlet fileContent = '';\n\nvi.mock('@clack/prompts', () => {\n return {\n log: {\n info: vi.fn(),\n success: vi.fn(),\n },\n select: vi.fn().mockImplementation(() => Promise.resolve(true)),\n isCancel: vi.fn().mockReturnValue(false),\n };\n});\n\nvi.spyOn(fs.promises, 'readFile').mockImplementation(() =>\n Promise.resolve(fileContent),\n);\n\nconst writeFileSpy = vi\n .spyOn(fs.promises, 'writeFile')\n .mockImplementation(() => Promise.resolve(void 0));\n\nconst noSourcemapNoPluginsPojo = `module.exports = {\n entry: \"./src/index.js\",\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n};`;\n\nconst noSourcemapNoPluginsPojoResult = `const {\n sentryWebpackPlugin\n} = require(\"@sentry/webpack-plugin\");\n\nmodule.exports = {\n entry: \"./src/index.js\",\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n\n devtool: \"source-map\",\n\n plugins: [sentryWebpackPlugin({\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: \"my-org\",\n project: \"my-project\"\n })]\n};`;\n\nconst noSourcemapsNoPluginsId = `const config = {\n entry: \"./src/index.js\",\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n};\n\nmodule.exports = config;`;\n\nconst noSourcemapsNoPluginsIdResult = `const {\n sentryWebpackPlugin\n} = require(\"@sentry/webpack-plugin\");\n\nconst config = {\n entry: \"./src/index.js\",\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n\n devtool: \"source-map\",\n\n plugins: [sentryWebpackPlugin({\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: \"my-org\",\n project: \"my-project\"\n })]\n};\n\nmodule.exports = config;`;\n\nconst hiddenSourcemapNoPluginsId = `const config = {\n entry: \"./src/index.js\",\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n\n devtool: \"hidden-cheap-source-map\",\n};\n\nmodule.exports = config;\n `;\nconst hiddenSourcemapNoPluginsIdResult = `const {\n sentryWebpackPlugin\n} = require(\"@sentry/webpack-plugin\");\n\nconst config = {\n entry: \"./src/index.js\",\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n\n devtool: \"hidden-source-map\",\n\n plugins: [sentryWebpackPlugin({\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: \"my-org\",\n project: \"my-project\"\n })]\n};\n\nmodule.exports = config;`;\n\nconst arbitrarySourcemapNoPluginsId = `\nconst config = {\n entry: \"./src/index.js\",\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n\n devtool: getSourcemapSetting(),\n};\n\nmodule.exports = config;\n `;\nconst arbitrarySourcemapNoPluginsIdResult = `const {\n sentryWebpackPlugin\n} = require(\"@sentry/webpack-plugin\");\n\nconst config = {\n entry: \"./src/index.js\",\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n\n devtool: \"source-map\",\n\n plugins: [sentryWebpackPlugin({\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: \"my-org\",\n project: \"my-project\"\n })]\n};\n\nmodule.exports = config;`;\n\nconst noSourcemapUndefinedPluginsPojo = `module.exports = {\n entry: \"./src/index.js\",\n plugins: undefined,\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n};`;\n\nconst noSourcemapUndefinedPluginsPojoResult = `const {\n sentryWebpackPlugin\n} = require(\"@sentry/webpack-plugin\");\n\nmodule.exports = {\n entry: \"./src/index.js\",\n\n plugins: [sentryWebpackPlugin({\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: \"my-org\",\n project: \"my-project\"\n })],\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n\n devtool: \"source-map\"\n};`;\n\nconst noSourcemapPluginsPojo = `module.exports = {\n entry: \"./src/index.js\",\n plugins: [\n new HtmlWebpackPlugin(),\n new MiniCssExtractPlugin(),\n ],\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n};`;\n\nconst noSourcemapPluginsPojoResult = `const {\n sentryWebpackPlugin\n} = require(\"@sentry/webpack-plugin\");\n\nmodule.exports = {\n entry: \"./src/index.js\",\n\n plugins: [new HtmlWebpackPlugin(), new MiniCssExtractPlugin(), sentryWebpackPlugin({\n authToken: process.env.SENTRY_AUTH_TOKEN,\n org: \"my-org\",\n project: \"my-project\"\n })],\n\n output: {\n filename: \"main.js\",\n path: path.resolve(__dirname, \"build\"),\n },\n\n devtool: \"source-map\"\n};`;\n\ndescribe('modifyWebpackConfig', () => {\n afterEach(() => {\n fileContent = '';\n vi.clearAllMocks();\n });\n\n it.each([\n [\n 'no sourcemap option, no plugins, object',\n noSourcemapNoPluginsPojo,\n noSourcemapNoPluginsPojoResult,\n ],\n [\n 'no sourcemap option, no plugins, identifier',\n noSourcemapsNoPluginsId,\n noSourcemapsNoPluginsIdResult,\n ],\n [\n 'hidden sourcemap option, no plugins, identifier',\n hiddenSourcemapNoPluginsId,\n hiddenSourcemapNoPluginsIdResult,\n ],\n [\n 'arbitrary sourcemap option, no plugins, identifier',\n arbitrarySourcemapNoPluginsId,\n arbitrarySourcemapNoPluginsIdResult,\n ],\n [\n 'no sourcemap option, plugins, object',\n noSourcemapUndefinedPluginsPojo,\n noSourcemapUndefinedPluginsPojoResult,\n ],\n [\n 'no sourcemap option, plugins, object',\n noSourcemapPluginsPojo,\n noSourcemapPluginsPojoResult,\n ],\n ])(\n 'adds plugin and source maps emission to the webpack config (%s)',\n async (_, originalCode, expectedCode) => {\n updateFileContent(originalCode);\n\n // updateFileContent(originalCode);\n const addedCode = await modifyWebpackConfig('', {\n authToken: '',\n orgSlug: 'my-org',\n projectSlug: 'my-project',\n selfHosted: false,\n url: 'https://sentry.io/',\n });\n\n expect(writeFileSpy).toHaveBeenCalledTimes(1);\n const [[, fileContent]] = writeFileSpy.mock.calls;\n expect(fileContent).toBe(expectedCode);\n expect(addedCode).toBe(true);\n },\n );\n\n it('adds the url parameter to the webpack plugin options if self-hosted', async () => {\n updateFileContent(noSourcemapNoPluginsPojo);\n\n const addedCode = await modifyWebpackConfig('', {\n authToken: '',\n orgSlug: 'my-org',\n projectSlug: 'my-project',\n selfHosted: true,\n url: 'https://santry.io/',\n });\n\n expect(writeFileSpy).toHaveBeenCalledTimes(1);\n const [[, fileContent]] = writeFileSpy.mock.calls;\n expect(fileContent).toContain('url: \"https://santry.io/\"');\n expect(addedCode).toBe(true);\n });\n});\n"]}
|