@sentry/wizard 4.5.0 → 4.7.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 +25 -1
- package/README.md +23 -19
- package/dist/bin.js +22 -0
- package/dist/bin.js.map +1 -1
- 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.js +56 -0
- package/dist/e2e-tests/tests/help-message.test.js.map +1 -0
- package/dist/e2e-tests/tests/nextjs-14.test.js +17 -16
- package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-15.test.js +16 -16
- 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/remix.test.js +20 -20
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit.test.js +20 -20
- package/dist/e2e-tests/tests/sveltekit.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.d.ts +1 -1
- package/dist/e2e-tests/utils/index.js +35 -13
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/lib/Constants.d.ts +7 -1
- package/dist/lib/Constants.js.map +1 -1
- package/dist/lib/Helper/File.d.ts +1 -1
- package/dist/lib/Helper/File.js +1 -3
- package/dist/lib/Helper/File.js.map +1 -1
- package/dist/lib/Helper/Logging.d.ts +4 -1
- package/dist/lib/Helper/Logging.js +3 -0
- package/dist/lib/Helper/Logging.js.map +1 -1
- package/dist/lib/Helper/Package.d.ts +5 -3
- package/dist/lib/Helper/Package.js +2 -2
- package/dist/lib/Helper/Package.js.map +1 -1
- package/dist/lib/Helper/SentryCli.d.ts +20 -7
- package/dist/lib/Helper/SentryCli.js +21 -13
- package/dist/lib/Helper/SentryCli.js.map +1 -1
- package/dist/lib/Helper/Wizard.js +9 -5
- package/dist/lib/Helper/Wizard.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 +39 -21
- package/dist/lib/Helper/__tests__/SentryCli.js.map +1 -1
- package/dist/lib/Setup.d.ts +4 -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/BaseIntegration.js +1 -2
- package/dist/lib/Steps/Integrations/BaseIntegration.js.map +1 -1
- package/dist/lib/Steps/Integrations/Cordova.js +14 -10
- package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
- package/dist/lib/Steps/Integrations/Electron.d.ts +4 -1
- package/dist/lib/Steps/Integrations/Electron.js +1 -1
- package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
- package/dist/lib/Steps/Integrations/MobileProject.d.ts +3 -1
- package/dist/lib/Steps/Integrations/MobileProject.js +1 -1
- package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
- package/dist/lib/Steps/PromptForParameters.d.ts +4 -1
- package/dist/lib/Steps/PromptForParameters.js.map +1 -1
- package/dist/lib/Steps/SentryProjectSelector.d.ts +42 -1
- package/dist/lib/Steps/SentryProjectSelector.js +1 -1
- package/dist/lib/Steps/SentryProjectSelector.js.map +1 -1
- package/dist/lib/Steps/WaitForSentry.d.ts +3 -1
- package/dist/lib/Steps/WaitForSentry.js +4 -4
- package/dist/lib/Steps/WaitForSentry.js.map +1 -1
- package/dist/lib/Steps/Welcome.js +5 -0
- package/dist/lib/Steps/Welcome.js.map +1 -1
- package/dist/lib/Types.d.ts +14 -0
- package/dist/lib/Types.js +3 -0
- package/dist/lib/Types.js.map +1 -0
- package/dist/lib/__tests__/Env.js +10 -16
- package/dist/lib/__tests__/Env.js.map +1 -1
- package/dist/src/android/android-wizard.js +15 -12
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/android/code-tools.js +1 -1
- package/dist/src/android/code-tools.js.map +1 -1
- package/dist/src/android/gradle.js +4 -4
- package/dist/src/android/gradle.js.map +1 -1
- package/dist/src/android/manifest.js +1 -1
- package/dist/src/android/manifest.js.map +1 -1
- package/dist/src/apple/apple-wizard.d.ts +2 -2
- package/dist/src/apple/apple-wizard.js +54 -175
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/check-installed-cli.d.ts +1 -0
- package/dist/src/apple/check-installed-cli.js +60 -0
- package/dist/src/apple/check-installed-cli.js.map +1 -0
- package/dist/src/apple/cocoapod.js +1 -1
- package/dist/src/apple/cocoapod.js.map +1 -1
- package/dist/src/apple/code-tools.js +1 -1
- package/dist/src/apple/code-tools.js.map +1 -1
- package/dist/src/apple/configure-fastlane.d.ts +5 -0
- package/dist/src/apple/configure-fastlane.js +66 -0
- package/dist/src/apple/configure-fastlane.js.map +1 -0
- 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/fastlane.d.ts +1 -1
- package/dist/src/apple/fastlane.js +5 -5
- package/dist/src/apple/fastlane.js.map +1 -1
- 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/lookup-xcode-project.d.ts +7 -0
- package/dist/src/apple/lookup-xcode-project.js +98 -0
- package/dist/src/apple/lookup-xcode-project.js.map +1 -0
- package/dist/src/apple/options.d.ts +4 -0
- package/dist/src/apple/options.js +3 -0
- package/dist/src/apple/options.js.map +1 -0
- package/dist/src/apple/search-xcode-project-at-path.d.ts +1 -0
- package/dist/src/apple/search-xcode-project-at-path.js +70 -0
- package/dist/src/apple/search-xcode-project-at-path.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 +4 -7
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/flutter/code-tools.js +3 -3
- package/dist/src/flutter/code-tools.js.map +1 -1
- package/dist/src/flutter/flutter-wizard.js +21 -15
- package/dist/src/flutter/flutter-wizard.js.map +1 -1
- package/dist/src/flutter/templates.js +4 -4
- package/dist/src/flutter/templates.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +118 -43
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.d.ts +10 -1
- package/dist/src/nextjs/templates.js +192 -62
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/nuxt/nuxt-wizard.js +21 -16
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
- package/dist/src/nuxt/sdk-example.js +3 -3
- package/dist/src/nuxt/sdk-example.js.map +1 -1
- package/dist/src/nuxt/sdk-setup.js +9 -9
- package/dist/src/nuxt/sdk-setup.js.map +1 -1
- package/dist/src/nuxt/templates.js +173 -58
- package/dist/src/nuxt/templates.js.map +1 -1
- package/dist/src/nuxt/utils.js +6 -3
- package/dist/src/nuxt/utils.js.map +1 -1
- package/dist/src/react-native/expo-env-file.js +1 -1
- package/dist/src/react-native/expo-env-file.js.map +1 -1
- package/dist/src/react-native/expo-metro.js +4 -4
- package/dist/src/react-native/expo-metro.js.map +1 -1
- package/dist/src/react-native/expo.js +4 -4
- 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 +31 -15
- package/dist/src/react-native/javascript.js.map +1 -1
- package/dist/src/react-native/metro.js +8 -8
- package/dist/src/react-native/metro.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.d.ts +5 -1
- package/dist/src/react-native/react-native-wizard.js +66 -36
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/react-native/uninstall.js +8 -5
- package/dist/src/react-native/uninstall.js.map +1 -1
- package/dist/src/react-native/xcode.d.ts +9 -4
- package/dist/src/react-native/xcode.js +65 -22
- package/dist/src/react-native/xcode.js.map +1 -1
- package/dist/src/remix/codemods/handle-error.js +4 -1
- package/dist/src/remix/codemods/handle-error.js.map +1 -1
- package/dist/src/remix/remix-wizard.js +23 -18
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/remix/sdk-example.js +163 -64
- package/dist/src/remix/sdk-example.js.map +1 -1
- package/dist/src/remix/sdk-setup.js +11 -7
- package/dist/src/remix/sdk-setup.js.map +1 -1
- package/dist/src/run.d.ts +3 -1
- package/dist/src/run.js +29 -9
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js +30 -28
- package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
- package/dist/src/sourcemaps/tools/angular.js +3 -3
- package/dist/src/sourcemaps/tools/angular.js.map +1 -1
- package/dist/src/sourcemaps/tools/create-react-app.js +3 -3
- package/dist/src/sourcemaps/tools/create-react-app.js.map +1 -1
- package/dist/src/sourcemaps/tools/esbuild.js +6 -6
- package/dist/src/sourcemaps/tools/esbuild.js.map +1 -1
- package/dist/src/sourcemaps/tools/nextjs.js +5 -5
- package/dist/src/sourcemaps/tools/nextjs.js.map +1 -1
- package/dist/src/sourcemaps/tools/remix.js +4 -4
- package/dist/src/sourcemaps/tools/remix.js.map +1 -1
- package/dist/src/sourcemaps/tools/rollup.js +6 -6
- package/dist/src/sourcemaps/tools/rollup.js.map +1 -1
- package/dist/src/sourcemaps/tools/sentry-cli.js +15 -15
- package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
- package/dist/src/sourcemaps/tools/tsc.js +6 -6
- package/dist/src/sourcemaps/tools/tsc.js.map +1 -1
- package/dist/src/sourcemaps/tools/vite.js +12 -12
- package/dist/src/sourcemaps/tools/vite.js.map +1 -1
- package/dist/src/sourcemaps/tools/webpack.js +10 -10
- package/dist/src/sourcemaps/tools/webpack.js.map +1 -1
- package/dist/src/sourcemaps/utils/detect-tool.js +2 -2
- package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
- package/dist/src/sourcemaps/utils/other-wizards.js +5 -5
- package/dist/src/sourcemaps/utils/other-wizards.js.map +1 -1
- package/dist/src/sourcemaps/utils/sdk-version.js +7 -7
- package/dist/src/sourcemaps/utils/sdk-version.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/sdk-setup.js +15 -14
- package/dist/src/sveltekit/sdk-setup.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +25 -20
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/sveltekit/templates.js +126 -37
- package/dist/src/sveltekit/templates.js.map +1 -1
- package/dist/src/telemetry.js +11 -0
- package/dist/src/telemetry.js.map +1 -1
- package/dist/src/utils/{clack-utils.d.ts → clack/index.d.ts} +45 -7
- package/dist/src/utils/{clack-utils.js → clack/index.js} +75 -20
- package/dist/src/utils/clack/index.js.map +1 -0
- package/dist/src/utils/debug.js +1 -1
- package/dist/src/utils/debug.js.map +1 -1
- package/dist/src/utils/find-files-with-extension.d.ts +1 -0
- package/dist/src/utils/find-files-with-extension.js +39 -0
- package/dist/src/utils/find-files-with-extension.js.map +1 -0
- package/dist/src/utils/package-manager.d.ts +8 -1
- package/dist/src/utils/package-manager.js +79 -23
- package/dist/src/utils/package-manager.js.map +1 -1
- package/dist/src/utils/sentrycli-utils.js +0 -1
- package/dist/src/utils/sentrycli-utils.js.map +1 -1
- package/dist/src/utils/types.d.ts +4 -0
- package/dist/src/utils/types.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 -13
- package/dist/test/android/code-tools.test.js.map +1 -1
- package/dist/test/apple/cocoapod.test.js +78 -73
- package/dist/test/apple/cocoapod.test.js.map +1 -1
- package/dist/test/apple/code-tools.test.js +174 -167
- package/dist/test/apple/code-tools.test.js.map +1 -1
- package/dist/test/apple/fastfile.test.js +87 -84
- 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 +208 -185
- package/dist/test/apple/xcode-manager.test.js.map +1 -1
- package/dist/test/flutter/code-tools.test.js +29 -30
- package/dist/test/flutter/code-tools.test.js.map +1 -1
- package/dist/test/flutter/templates.test.js +38 -37
- package/dist/test/flutter/templates.test.js.map +1 -1
- package/dist/test/nextjs/templates.test.js +155 -103
- 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 +12 -11
- 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 +109 -59
- package/dist/test/react-native/javascript.test.js.map +1 -1
- package/dist/test/react-native/metro.test.js +66 -65
- 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 +8 -7
- 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 +21 -21
- 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.d.ts +1 -0
- package/dist/test/utils/clack/index.test.js +375 -0
- package/dist/test/utils/clack/index.test.js.map +1 -0
- package/dist/test/utils/package-manager.test.d.ts +1 -0
- package/dist/test/utils/package-manager.test.js +30 -0
- package/dist/test/utils/package-manager.test.js.map +1 -0
- 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
- package/dist/src/utils/clack-utils.js.map +0 -1
- package/dist/test/utils/clack-utils.test.js +0 -306
- package/dist/test/utils/clack-utils.test.js.map +0 -1
- /package/dist/{test/utils/clack-utils.test.d.ts → e2e-tests/tests/help-message.test.d.ts} +0 -0
|
@@ -26,58 +26,58 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
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
|
-
const
|
|
30
|
-
const
|
|
29
|
+
const clack_1 = require("../../../src/utils/clack");
|
|
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,
|
|
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,QAAQ,EAAE,WAAE,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC;KACzC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,+DAA+D;AAC/D,WAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;IAC/C,GAAG,CAAC,MAAM,WAAE,CAAC,YAAY,CAAC,0BAA0B,CAAC,CAAC;IACtD,iBAAiB,EAAE,WAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC;QAC3C,OAAO,EAAE;YACP,KAAK,EAAE,KAAK;SACb;QACD,OAAO,EAAE,OAAO;KACjB,CAAC;CACH,CAAC,CAAC,CAAC;AAEJ,IAAA,iBAAQ,EAAC,gCAAgC,EAAE,GAAG,EAAE;IAC9C,IAAA,kBAAS,EAAC,GAAG,EAAE;QACb,WAAE,CAAC,aAAa,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IACH,WAAE,CAAC,IAAI,CAAC;QACN;YACE,qBAAqB,CAAC,GAAG;YACzB,qBAAqB,CAAC,IAAI;YAC1B,qBAAqB,CAAC,OAAO;YAC7B,qBAAqB,CAAC,OAAO;YAC7B,qBAAqB,CAAC,GAAG;YACzB,qBAAqB,CAAC,IAAI;SAC3B;KACF,CAAC,CAAC,iDAAiD,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE;QACxE,WAAE,CAAC,KAAK,CAAC,qBAAqB,EAAE,sBAAsB,CAAC,CAAC,eAAe,CACrE,MAAM,CACP,CAAC;QACF,MAAM,IAAA,2CAA8B,GAAE,CAAC;QACvC,IAAA,eAAM,EAAC,YAAY,CAAC,CAAC,oBAAoB,CACvC,eAAM,CAAC,gBAAgB,CAAC,cAAc,CAAC,EACvC,eAAM,CAAC,gBAAgB,CACrB,UAAU,MAAM,CAAC,gBAAgB,oBAAoB,CACtD,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,8EAA8E,EAAE,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,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,CAAC;AAEF,MAAM,YAAY,GAAG,WAAE;KACpB,KAAK,CAAC,EAAE,CAA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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,uCA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YACE,4BAA4B;YAC5B;;;;;;;;;GASH;YACG;;;;;;;;;;GAUH;SACE;QACD;YACE,0BAA0B;YAC1B;;;;;;;;;KASD;YACC;;;;;;;;;EASJ;SACG;QACD;YACE,kCAAkC;YAClC;;;;;;;;;;;OAWC;YACD;;;;;;;;;;;;oBAYc;SACf;KACF,CAAC,CACA,yDAAyD,EACzD,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,YAAY,EAAE,EAAE;QACtC,iBAAiB,CAAC,YAAY,CAAC,CAAC;QAEhC,MAAM,SAAS,GAAG,MAAM,IAAA,4BAAqB,EAAC,EAAE,EAAE;YAChD,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,QAAQ;YACjB,WAAW,EAAE,YAAY;YACzB,UAAU,EAAE,KAAK;YACjB,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,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 { 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,IAAI,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC;KAC3C,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI;KACD,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC;KAC9B,kBAAkB,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;AAE1D,MAAM,YAAY,GAAG,IAAI;KACtB,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC;KAC/B,kBAAkB,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAErD,MAAM,wBAAwB,GAAG;;;;;;GAM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AC,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,GAAG,EAAE;IAC7B,OAAO;QACL,GAAG,EAAE;YACH,IAAI,EAAE,WAAE,CAAC,EAAE,EAAE;YACb,OAAO,EAAE,WAAE,CAAC,EAAE,EAAE;SACjB;QACD,MAAM,EAAE,WAAE,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/D,QAAQ,EAAE,WAAE,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC;KACzC,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,WAAE,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,kBAAkB,CAAC,GAAG,EAAE,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AAC,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"]}
|
|
@@ -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 templates_1 = require("../../src/sveltekit/templates");
|
|
4
|
-
describe('getClientHooksTemplate', () => {
|
|
5
|
-
it('should generate client hooks template with all features enabled', () => {
|
|
5
|
+
(0, vitest_1.describe)('getClientHooksTemplate', () => {
|
|
6
|
+
(0, vitest_1.it)('should generate client hooks template with all features enabled', () => {
|
|
6
7
|
const result = (0, templates_1.getClientHooksTemplate)('https://sentry.io/123', {
|
|
7
8
|
performance: true,
|
|
8
9
|
replay: true,
|
|
9
10
|
});
|
|
10
|
-
expect(result).toMatchInlineSnapshot(`
|
|
11
|
+
(0, vitest_1.expect)(result).toMatchInlineSnapshot(`
|
|
11
12
|
"import { handleErrorWithSentry, replayIntegration } from "@sentry/sveltekit";
|
|
12
13
|
import * as Sentry from '@sentry/sveltekit';
|
|
13
14
|
|
|
@@ -33,12 +34,12 @@ describe('getClientHooksTemplate', () => {
|
|
|
33
34
|
"
|
|
34
35
|
`);
|
|
35
36
|
});
|
|
36
|
-
it('should generate client hooks template when performance disabled', () => {
|
|
37
|
+
(0, vitest_1.it)('should generate client hooks template when performance disabled', () => {
|
|
37
38
|
const result = (0, templates_1.getClientHooksTemplate)('https://sentry.io/123', {
|
|
38
39
|
performance: false,
|
|
39
40
|
replay: true,
|
|
40
41
|
});
|
|
41
|
-
expect(result).toMatchInlineSnapshot(`
|
|
42
|
+
(0, vitest_1.expect)(result).toMatchInlineSnapshot(`
|
|
42
43
|
"import { handleErrorWithSentry, replayIntegration } from "@sentry/sveltekit";
|
|
43
44
|
import * as Sentry from '@sentry/sveltekit';
|
|
44
45
|
|
|
@@ -62,12 +63,12 @@ describe('getClientHooksTemplate', () => {
|
|
|
62
63
|
"
|
|
63
64
|
`);
|
|
64
65
|
});
|
|
65
|
-
it('should generate client hooks template when replay disabled', () => {
|
|
66
|
+
(0, vitest_1.it)('should generate client hooks template when replay disabled', () => {
|
|
66
67
|
const result = (0, templates_1.getClientHooksTemplate)('https://sentry.io/123', {
|
|
67
68
|
performance: true,
|
|
68
69
|
replay: false,
|
|
69
70
|
});
|
|
70
|
-
expect(result).toMatchInlineSnapshot(`
|
|
71
|
+
(0, vitest_1.expect)(result).toMatchInlineSnapshot(`
|
|
71
72
|
"import { handleErrorWithSentry, replayIntegration } from "@sentry/sveltekit";
|
|
72
73
|
import * as Sentry from '@sentry/sveltekit';
|
|
73
74
|
|
|
@@ -85,13 +86,13 @@ describe('getClientHooksTemplate', () => {
|
|
|
85
86
|
`);
|
|
86
87
|
});
|
|
87
88
|
});
|
|
88
|
-
describe('getServerHooksTemplate', () => {
|
|
89
|
-
it('should generate server hooks template with all features enabled', () => {
|
|
89
|
+
(0, vitest_1.describe)('getServerHooksTemplate', () => {
|
|
90
|
+
(0, vitest_1.it)('should generate server hooks template with all features enabled', () => {
|
|
90
91
|
const result = (0, templates_1.getServerHooksTemplate)('https://sentry.io/123', {
|
|
91
92
|
performance: true,
|
|
92
93
|
replay: true,
|
|
93
94
|
});
|
|
94
|
-
expect(result).toMatchInlineSnapshot(`
|
|
95
|
+
(0, vitest_1.expect)(result).toMatchInlineSnapshot(`
|
|
95
96
|
"import { sequence } from "@sveltejs/kit/hooks";
|
|
96
97
|
import { handleErrorWithSentry, sentryHandle } from "@sentry/sveltekit";
|
|
97
98
|
import * as Sentry from '@sentry/sveltekit';
|
|
@@ -113,12 +114,12 @@ describe('getServerHooksTemplate', () => {
|
|
|
113
114
|
"
|
|
114
115
|
`);
|
|
115
116
|
});
|
|
116
|
-
it('should generate server hooks template when performance disabled', () => {
|
|
117
|
+
(0, vitest_1.it)('should generate server hooks template when performance disabled', () => {
|
|
117
118
|
const result = (0, templates_1.getServerHooksTemplate)('https://sentry.io/123', {
|
|
118
119
|
performance: false,
|
|
119
120
|
replay: true,
|
|
120
121
|
});
|
|
121
|
-
expect(result).toMatchInlineSnapshot(`
|
|
122
|
+
(0, vitest_1.expect)(result).toMatchInlineSnapshot(`
|
|
122
123
|
"import { sequence } from "@sveltejs/kit/hooks";
|
|
123
124
|
import { handleErrorWithSentry, sentryHandle } from "@sentry/sveltekit";
|
|
124
125
|
import * as Sentry from '@sentry/sveltekit';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.test.js","sourceRoot":"","sources":["../../../test/sveltekit/templates.test.ts"],"names":[],"mappings":";;AAAA,6DAGuC;AAEvC,
|
|
1
|
+
{"version":3,"file":"templates.test.js","sourceRoot":"","sources":["../../../test/sveltekit/templates.test.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AA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AAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;;KAoBpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,MAAM,GAAG,IAAA,kCAAsB,EAAC,uBAAuB,EAAE;YAC7D,WAAW,EAAE,KAAK;YAClB,MAAM,EAAE,IAAI;SACb,CAAC,CAAC;QAEH,IAAA,eAAM,EAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;KAkBpC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it } from 'vitest';\nimport {\n getClientHooksTemplate,\n getServerHooksTemplate,\n} from '../../src/sveltekit/templates';\n\ndescribe('getClientHooksTemplate', () => {\n it('should generate client hooks template with all features enabled', () => {\n const result = getClientHooksTemplate('https://sentry.io/123', {\n performance: true,\n replay: true,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n tracesSampleRate: 1.0,\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n\n // If you don't want to use Session Replay, just remove the line below:\n integrations: [replayIntegration()],\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n\n it('should generate client hooks template when performance disabled', () => {\n const result = getClientHooksTemplate('https://sentry.io/123', {\n performance: false,\n replay: true,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n // This sets the sample rate to be 10%. You may want this to be 100% while\n // in development and sample at a lower rate in production\n replaysSessionSampleRate: 0.1,\n\n // If the entire session is not sampled, use the below sample rate to sample\n // sessions when an error occurs.\n replaysOnErrorSampleRate: 1.0,\n\n // If you don't want to use Session Replay, just remove the line below:\n integrations: [replayIntegration()],\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n\n it('should generate client hooks template when replay disabled', () => {\n const result = getClientHooksTemplate('https://sentry.io/123', {\n performance: true,\n replay: false,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { handleErrorWithSentry, replayIntegration } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n tracesSampleRate: 1.0,\n\n\n });\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n});\n\ndescribe('getServerHooksTemplate', () => {\n it('should generate server hooks template with all features enabled', () => {\n const result = getServerHooksTemplate('https://sentry.io/123', {\n performance: true,\n replay: true,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { sequence } from \"@sveltejs/kit/hooks\";\n import { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n tracesSampleRate: 1.0,\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n });\n\n // If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\n export const handle = sequence(sentryHandle());\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n\n it('should generate server hooks template when performance disabled', () => {\n const result = getServerHooksTemplate('https://sentry.io/123', {\n performance: false,\n replay: true,\n });\n\n expect(result).toMatchInlineSnapshot(`\n \"import { sequence } from \"@sveltejs/kit/hooks\";\n import { handleErrorWithSentry, sentryHandle } from \"@sentry/sveltekit\";\n import * as Sentry from '@sentry/sveltekit';\n\n Sentry.init({\n dsn: 'https://sentry.io/123',\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: import.meta.env.DEV,\n });\n\n // If you have custom handlers, make sure to place them after \\`sentryHandle()\\` in the \\`sequence\\` function.\n export const handle = sequence(sentryHandle());\n\n // If you have a custom error handler, pass it to \\`handleErrorWithSentry\\`\n export const handleError = handleErrorWithSentry();\n \"\n `);\n });\n});\n"]}
|