@sentry/wizard 3.42.0 → 4.0.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/.node-cache/node-v22.14.0-darwin-arm64 +0 -0
- package/.node-cache/node-v22.14.0-darwin-x64 +0 -0
- package/.node-cache/node-v22.14.0-linux-arm64 +0 -0
- package/.node-cache/node-v22.14.0-linux-x64 +0 -0
- package/.node-cache/node-v22.14.0-win-x64.exe +0 -0
- package/CHANGELOG.md +30 -0
- package/COPYING +3575 -0
- package/bin.ts +85 -80
- package/dist/bin.js +44 -35
- package/dist/bin.js.map +1 -1
- package/dist/e2e-tests/jest.config.js +1 -1
- package/dist/e2e-tests/jest.config.js.map +1 -1
- package/dist/e2e-tests/tests/flutter.test.js +62 -147
- package/dist/e2e-tests/tests/flutter.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs.test.js +77 -175
- package/dist/e2e-tests/tests/nextjs.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-3.test.js +61 -162
- package/dist/e2e-tests/tests/nuxt-3.test.js.map +1 -1
- package/dist/e2e-tests/tests/nuxt-4.test.js +62 -163
- package/dist/e2e-tests/tests/nuxt-4.test.js.map +1 -1
- package/dist/e2e-tests/tests/remix.test.js +147 -189
- package/dist/e2e-tests/tests/remix.test.js.map +1 -1
- package/dist/e2e-tests/tests/sveltekit.test.js +133 -187
- 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 +113 -195
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/lib/Constants.js +5 -5
- package/dist/lib/Constants.js.map +1 -1
- package/dist/lib/Helper/BottomBar.d.ts +1 -1
- package/dist/lib/Helper/BottomBar.js +14 -15
- package/dist/lib/Helper/BottomBar.js.map +1 -1
- package/dist/lib/Helper/Env.js +5 -2
- package/dist/lib/Helper/Env.js.map +1 -1
- package/dist/lib/Helper/File.js +14 -27
- package/dist/lib/Helper/File.js.map +1 -1
- package/dist/lib/Helper/Git.js +24 -59
- package/dist/lib/Helper/Git.js.map +1 -1
- package/dist/lib/Helper/Logging.js +2 -2
- package/dist/lib/Helper/Logging.js.map +1 -1
- package/dist/lib/Helper/MergeConfig.js +4 -4
- package/dist/lib/Helper/MergeConfig.js.map +1 -1
- package/dist/lib/Helper/Package.d.ts +4 -1
- package/dist/lib/Helper/Package.js +12 -38
- package/dist/lib/Helper/Package.js.map +1 -1
- package/dist/lib/Helper/SentryCli.js +77 -149
- package/dist/lib/Helper/SentryCli.js.map +1 -1
- package/dist/lib/Helper/Wizard.js +29 -124
- package/dist/lib/Helper/Wizard.js.map +1 -1
- package/dist/lib/Helper/__tests__/File.js +4 -4
- package/dist/lib/Helper/__tests__/File.js.map +1 -1
- package/dist/lib/Helper/__tests__/MergeConfig.js +24 -24
- package/dist/lib/Helper/__tests__/MergeConfig.js.map +1 -1
- package/dist/lib/Helper/__tests__/SentryCli.js +33 -23
- package/dist/lib/Helper/__tests__/SentryCli.js.map +1 -1
- package/dist/lib/Setup.js +23 -85
- package/dist/lib/Setup.js.map +1 -1
- package/dist/lib/Steps/BaseStep.js +8 -8
- package/dist/lib/Steps/BaseStep.js.map +1 -1
- package/dist/lib/Steps/ChooseIntegration.js +80 -125
- package/dist/lib/Steps/ChooseIntegration.js.map +1 -1
- package/dist/lib/Steps/ConfigureProject.js +6 -66
- package/dist/lib/Steps/ConfigureProject.js.map +1 -1
- package/dist/lib/Steps/Initial.js +16 -104
- package/dist/lib/Steps/Initial.js.map +1 -1
- package/dist/lib/Steps/Integrations/BaseIntegration.js +24 -118
- package/dist/lib/Steps/Integrations/BaseIntegration.js.map +1 -1
- package/dist/lib/Steps/Integrations/Cordova.js +95 -183
- package/dist/lib/Steps/Integrations/Cordova.js.map +1 -1
- package/dist/lib/Steps/Integrations/Electron.js +87 -145
- package/dist/lib/Steps/Integrations/Electron.js.map +1 -1
- package/dist/lib/Steps/Integrations/MobileProject.js +40 -148
- package/dist/lib/Steps/Integrations/MobileProject.js.map +1 -1
- package/dist/lib/Steps/OpenSentry.js +63 -126
- package/dist/lib/Steps/OpenSentry.js.map +1 -1
- package/dist/lib/Steps/PromptForParameters.js +110 -206
- package/dist/lib/Steps/PromptForParameters.js.map +1 -1
- package/dist/lib/Steps/Result.js +19 -79
- package/dist/lib/Steps/Result.js.map +1 -1
- package/dist/lib/Steps/SentryProjectSelector.js +57 -148
- package/dist/lib/Steps/SentryProjectSelector.js.map +1 -1
- package/dist/lib/Steps/ShouldConfigure.js +6 -66
- package/dist/lib/Steps/ShouldConfigure.js.map +1 -1
- package/dist/lib/Steps/WaitForSentry.js +43 -120
- package/dist/lib/Steps/WaitForSentry.js.map +1 -1
- package/dist/lib/Steps/Welcome.js +17 -76
- package/dist/lib/Steps/Welcome.js.map +1 -1
- package/dist/lib/__tests__/Env.js +3 -3
- package/dist/lib/__tests__/Env.js.map +1 -1
- package/dist/src/android/android-wizard.js +100 -176
- package/dist/src/android/android-wizard.js.map +1 -1
- package/dist/src/android/code-tools.js +24 -33
- package/dist/src/android/code-tools.js.map +1 -1
- package/dist/src/android/gradle.js +106 -165
- package/dist/src/android/gradle.js.map +1 -1
- package/dist/src/android/manifest.js +26 -27
- package/dist/src/android/manifest.js.map +1 -1
- package/dist/src/android/templates.js +76 -23
- package/dist/src/android/templates.js.map +1 -1
- package/dist/src/apple/apple-wizard.js +129 -225
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/cocoapod.js +47 -109
- package/dist/src/apple/cocoapod.js.map +1 -1
- package/dist/src/apple/code-tools.js +32 -35
- package/dist/src/apple/code-tools.js.map +1 -1
- package/dist/src/apple/fastlane.js +51 -97
- package/dist/src/apple/fastlane.js.map +1 -1
- package/dist/src/apple/templates.js +41 -5
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/apple/xcode-manager.d.ts +2 -2
- package/dist/src/apple/xcode-manager.js +93 -108
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/flutter/code-tools.js +79 -127
- package/dist/src/flutter/code-tools.js.map +1 -1
- package/dist/src/flutter/flutter-wizard.js +75 -136
- package/dist/src/flutter/flutter-wizard.js.map +1 -1
- package/dist/src/flutter/templates.js +48 -12
- package/dist/src/flutter/templates.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +527 -805
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nextjs/templates.js +380 -40
- package/dist/src/nextjs/templates.js.map +1 -1
- package/dist/src/nextjs/utils.js +5 -5
- package/dist/src/nextjs/utils.js.map +1 -1
- package/dist/src/nuxt/nuxt-wizard.js +91 -188
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
- package/dist/src/nuxt/sdk-example.js +68 -137
- package/dist/src/nuxt/sdk-example.js.map +1 -1
- package/dist/src/nuxt/sdk-setup.d.ts +4 -4
- package/dist/src/nuxt/sdk-setup.js +180 -336
- package/dist/src/nuxt/sdk-setup.js.map +1 -1
- package/dist/src/nuxt/templates.js +195 -18
- package/dist/src/nuxt/templates.js.map +1 -1
- package/dist/src/nuxt/utils.js +29 -76
- package/dist/src/nuxt/utils.js.map +1 -1
- package/dist/src/react-native/expo-env-file.js +41 -94
- package/dist/src/react-native/expo-env-file.js.map +1 -1
- package/dist/src/react-native/expo-metro.d.ts +1 -1
- package/dist/src/react-native/expo-metro.js +75 -130
- package/dist/src/react-native/expo-metro.js.map +1 -1
- package/dist/src/react-native/expo.js +61 -114
- package/dist/src/react-native/expo.js.map +1 -1
- package/dist/src/react-native/git.js +23 -56
- package/dist/src/react-native/git.js.map +1 -1
- package/dist/src/react-native/glob.js +3 -3
- package/dist/src/react-native/glob.js.map +1 -1
- package/dist/src/react-native/gradle.js +4 -4
- package/dist/src/react-native/gradle.js.map +1 -1
- package/dist/src/react-native/javascript.js +51 -95
- package/dist/src/react-native/javascript.js.map +1 -1
- package/dist/src/react-native/metro.js +176 -296
- package/dist/src/react-native/metro.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.js +267 -418
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/react-native/uninstall.js +37 -80
- package/dist/src/react-native/uninstall.js.map +1 -1
- package/dist/src/react-native/xcode.js +57 -55
- package/dist/src/react-native/xcode.js.map +1 -1
- package/dist/src/remix/codemods/express-server.js +27 -82
- package/dist/src/remix/codemods/express-server.js.map +1 -1
- package/dist/src/remix/codemods/handle-error.js +28 -31
- package/dist/src/remix/codemods/handle-error.js.map +1 -1
- package/dist/src/remix/codemods/root-common.js +11 -11
- package/dist/src/remix/codemods/root-common.js.map +1 -1
- package/dist/src/remix/codemods/root-v1.js +17 -67
- package/dist/src/remix/codemods/root-v1.js.map +1 -1
- package/dist/src/remix/codemods/root-v2.js +89 -140
- package/dist/src/remix/codemods/root-v2.js.map +1 -1
- package/dist/src/remix/remix-wizard.js +181 -343
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/remix/sdk-example.js +84 -66
- package/dist/src/remix/sdk-example.js.map +1 -1
- package/dist/src/remix/sdk-setup.js +161 -293
- package/dist/src/remix/sdk-setup.js.map +1 -1
- package/dist/src/remix/templates.js +10 -2
- package/dist/src/remix/templates.js.map +1 -1
- package/dist/src/remix/utils.js +13 -14
- package/dist/src/remix/utils.js.map +1 -1
- package/dist/src/run.js +106 -178
- package/dist/src/run.js.map +1 -1
- package/dist/src/sourcemaps/sourcemaps-wizard.js +248 -372
- package/dist/src/sourcemaps/sourcemaps-wizard.js.map +1 -1
- package/dist/src/sourcemaps/tools/angular.js +32 -66
- package/dist/src/sourcemaps/tools/angular.js.map +1 -1
- package/dist/src/sourcemaps/tools/create-react-app.js +14 -59
- package/dist/src/sourcemaps/tools/create-react-app.js.map +1 -1
- package/dist/src/sourcemaps/tools/esbuild.js +34 -77
- package/dist/src/sourcemaps/tools/esbuild.js.map +1 -1
- package/dist/src/sourcemaps/tools/nextjs.d.ts +2 -2
- package/dist/src/sourcemaps/tools/nextjs.js +75 -102
- package/dist/src/sourcemaps/tools/nextjs.js.map +1 -1
- package/dist/src/sourcemaps/tools/remix.js +53 -93
- package/dist/src/sourcemaps/tools/remix.js.map +1 -1
- package/dist/src/sourcemaps/tools/rollup.js +35 -76
- package/dist/src/sourcemaps/tools/rollup.js.map +1 -1
- package/dist/src/sourcemaps/tools/sentry-cli.js +157 -289
- package/dist/src/sourcemaps/tools/sentry-cli.js.map +1 -1
- package/dist/src/sourcemaps/tools/tsc.js +68 -134
- package/dist/src/sourcemaps/tools/tsc.js.map +1 -1
- package/dist/src/sourcemaps/tools/vite.js +111 -196
- package/dist/src/sourcemaps/tools/vite.js.map +1 -1
- package/dist/src/sourcemaps/tools/webpack.d.ts +1 -1
- package/dist/src/sourcemaps/tools/webpack.js +158 -260
- package/dist/src/sourcemaps/tools/webpack.js.map +1 -1
- package/dist/src/sourcemaps/utils/detect-tool.js +9 -54
- package/dist/src/sourcemaps/utils/detect-tool.js.map +1 -1
- package/dist/src/sourcemaps/utils/other-wizards.js +77 -144
- package/dist/src/sourcemaps/utils/other-wizards.js.map +1 -1
- package/dist/src/sourcemaps/utils/sdk-version.js +112 -191
- package/dist/src/sourcemaps/utils/sdk-version.js.map +1 -1
- package/dist/src/sveltekit/sdk-example.js +20 -70
- package/dist/src/sveltekit/sdk-example.js.map +1 -1
- package/dist/src/sveltekit/sdk-setup.js +250 -411
- package/dist/src/sveltekit/sdk-setup.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +107 -191
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/sveltekit/templates.js +147 -13
- package/dist/src/sveltekit/templates.js.map +1 -1
- package/dist/src/sveltekit/utils.js +3 -3
- package/dist/src/sveltekit/utils.js.map +1 -1
- package/dist/src/telemetry.d.ts +2 -2
- package/dist/src/telemetry.js +58 -108
- package/dist/src/telemetry.js.map +1 -1
- package/dist/src/utils/ast-utils.js +39 -54
- package/dist/src/utils/ast-utils.js.map +1 -1
- package/dist/src/utils/bash.js +28 -75
- package/dist/src/utils/bash.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +3 -7
- package/dist/src/utils/clack-utils.js +688 -1083
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/utils/debug.js +6 -10
- package/dist/src/utils/debug.js.map +1 -1
- package/dist/src/utils/package-json.js +5 -6
- package/dist/src/utils/package-json.js.map +1 -1
- package/dist/src/utils/package-manager.js +65 -139
- package/dist/src/utils/package-manager.js.map +1 -1
- package/dist/src/utils/release-registry.js +12 -59
- package/dist/src/utils/release-registry.js.map +1 -1
- package/dist/src/utils/semver.js +3 -4
- package/dist/src/utils/semver.js.map +1 -1
- package/dist/src/utils/sentrycli-utils.js +4 -4
- package/dist/src/utils/sentrycli-utils.js.map +1 -1
- package/dist/src/utils/url.js +5 -6
- package/dist/src/utils/url.js.map +1 -1
- package/dist/test/android/code-tools.test.js +18 -18
- package/dist/test/android/code-tools.test.js.map +1 -1
- package/dist/test/apple/cocoapod.test.js +154 -299
- package/dist/test/apple/cocoapod.test.js.map +1 -1
- package/dist/test/apple/code-tools.test.js +375 -263
- package/dist/test/apple/code-tools.test.js.map +1 -1
- package/dist/test/apple/fastfile.test.js +319 -271
- package/dist/test/apple/fastfile.test.js.map +1 -1
- package/dist/test/apple/templates.test.js +114 -30
- package/dist/test/apple/templates.test.js.map +1 -1
- package/dist/test/apple/xcode-manager.test.js +230 -234
- package/dist/test/apple/xcode-manager.test.js.map +1 -1
- package/dist/test/flutter/code-tools.test.js +119 -48
- package/dist/test/flutter/code-tools.test.js.map +1 -1
- package/dist/test/flutter/templates.test.js +63 -20
- package/dist/test/flutter/templates.test.js.map +1 -1
- package/dist/test/nextjs/templates.test.js +332 -43
- package/dist/test/nextjs/templates.test.js.map +1 -1
- package/dist/test/nuxt/templates.test.js +161 -33
- package/dist/test/nuxt/templates.test.js.map +1 -1
- package/dist/test/react-native/expo-metro.test.js +61 -15
- package/dist/test/react-native/expo-metro.test.js.map +1 -1
- package/dist/test/react-native/expo.test.js +37 -17
- package/dist/test/react-native/expo.test.js.map +1 -1
- package/dist/test/react-native/gradle.test.js +260 -28
- package/dist/test/react-native/gradle.test.js.map +1 -1
- package/dist/test/react-native/javascript.test.js +85 -19
- package/dist/test/react-native/javascript.test.js.map +1 -1
- package/dist/test/react-native/metro.test.js +261 -187
- package/dist/test/react-native/metro.test.js.map +1 -1
- package/dist/test/react-native/xcode.test.js +243 -62
- package/dist/test/react-native/xcode.test.js.map +1 -1
- package/dist/test/remix/client-entry.test.js +81 -21
- package/dist/test/remix/client-entry.test.js.map +1 -1
- package/dist/test/remix/server-instrumentation.test.js +21 -8
- package/dist/test/remix/server-instrumentation.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/sentry-cli.test.js +20 -72
- package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/tsc.test.js +142 -68
- package/dist/test/sourcemaps/tools/tsc.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/vite.test.js +106 -75
- package/dist/test/sourcemaps/tools/vite.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/webpack.test.js +226 -102
- package/dist/test/sourcemaps/tools/webpack.test.js.map +1 -1
- package/dist/test/sveltekit/templates.test.js +117 -18
- package/dist/test/sveltekit/templates.test.js.map +1 -1
- package/dist/test/utils/ast-utils.test.js +99 -58
- package/dist/test/utils/ast-utils.test.js.map +1 -1
- package/dist/test/utils/clack-utils.test.js +142 -247
- package/dist/test/utils/clack-utils.test.js.map +1 -1
- package/e2e-tests/package.json +1 -1
- package/e2e-tests/tests/flutter.test.ts +20 -20
- package/e2e-tests/tests/nextjs.test.ts +2 -2
- package/e2e-tests/tests/nuxt-3.test.ts +4 -4
- package/e2e-tests/tests/nuxt-4.test.ts +3 -3
- package/e2e-tests/tests/remix.test.ts +3 -3
- package/e2e-tests/tests/sveltekit.test.ts +3 -3
- package/e2e-tests/utils/index.ts +33 -15
- package/lib/Helper/BottomBar.ts +1 -1
- package/lib/Helper/Env.ts +1 -1
- package/lib/Helper/Package.ts +12 -10
- package/lib/Helper/SentryCli.ts +18 -27
- package/lib/Helper/Wizard.ts +1 -2
- package/lib/Setup.ts +4 -5
- package/lib/Steps/ChooseIntegration.ts +40 -8
- package/lib/Steps/Initial.ts +17 -26
- package/lib/Steps/Integrations/BaseIntegration.ts +2 -8
- package/lib/Steps/Integrations/Cordova.ts +9 -15
- package/lib/Steps/Integrations/Electron.ts +23 -20
- package/lib/Steps/Integrations/MobileProject.ts +18 -15
- package/lib/Steps/OpenSentry.ts +12 -7
- package/lib/Steps/PromptForParameters.ts +12 -19
- package/lib/Steps/SentryProjectSelector.ts +30 -29
- package/lib/Steps/WaitForSentry.ts +29 -23
- package/package.json +12 -8
- package/src/apple/xcode-manager.ts +10 -10
- package/src/nextjs/templates.ts +2 -6
- package/src/nuxt/sdk-setup.ts +21 -18
- package/src/react-native/expo-metro.ts +2 -2
- package/src/react-native/react-native-wizard.ts +1 -2
- package/src/react-native/uninstall.ts +1 -2
- package/src/react-native/xcode.ts +1 -1
- package/src/run.ts +12 -5
- package/src/sourcemaps/tools/nextjs.ts +2 -5
- package/src/sourcemaps/tools/webpack.ts +3 -3
- package/src/telemetry.ts +27 -7
- package/src/utils/clack-utils.ts +50 -47
- package/test/apple/cocoapod.test.ts +4 -0
- package/test/apple/fastfile.test.ts +12 -7
- package/test/apple/xcode-manager.test.ts +13 -11
- package/test/nextjs/templates.test.ts +0 -12
- package/test/utils/clack-utils.test.ts +40 -50
- package/types/read-env.d.ts +3 -0
- package/types/xcode.d.ts +1 -0
- package/dist/package.json +0 -128
|
@@ -54,8 +54,7 @@ import { patchExpoAppConfig, printSentryExpoMigrationOutro } from './expo';
|
|
|
54
54
|
import { addSentryToExpoMetroConfig } from './expo-metro';
|
|
55
55
|
import { addExpoEnvLocal } from './expo-env-file';
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
const xcode = require('xcode');
|
|
57
|
+
import xcode from 'xcode';
|
|
59
58
|
|
|
60
59
|
export const RN_SDK_PACKAGE = '@sentry/react-native';
|
|
61
60
|
export const RN_SDK_SUPPORTED_RANGE = '>=5.0.0';
|
|
@@ -23,8 +23,7 @@ import {
|
|
|
23
23
|
import { ReactNativeWizardOptions } from './options';
|
|
24
24
|
import { unPatchMetroConfig } from './metro';
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
const xcode = require('xcode');
|
|
26
|
+
import xcode from 'xcode';
|
|
28
27
|
|
|
29
28
|
export async function runReactNativeUninstall(
|
|
30
29
|
options: ReactNativeWizardOptions,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
4
|
-
import * as fs from 'fs';
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
5
|
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
6
6
|
import clack from '@clack/prompts';
|
|
7
7
|
import chalk from 'chalk';
|
package/src/run.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { runSourcemapsWizard } from './sourcemaps/sourcemaps-wizard';
|
|
|
16
16
|
import { readEnvironment } from '../lib/Helper/Env';
|
|
17
17
|
import type { Platform } from '../lib/Constants';
|
|
18
18
|
import type { PackageDotJson } from './utils/package-json';
|
|
19
|
+
import { readFileSync } from 'node:fs';
|
|
19
20
|
|
|
20
21
|
type WizardIntegration =
|
|
21
22
|
| 'reactNative'
|
|
@@ -195,10 +196,16 @@ export async function run(argv: Args) {
|
|
|
195
196
|
* TODO: replace with rollup replace whenever we switch to rollup
|
|
196
197
|
*/
|
|
197
198
|
function tryGetWizardVersion(): string {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
199
|
+
let version = process.env.npm_package_version;
|
|
200
|
+
if (!version) {
|
|
201
|
+
try {
|
|
202
|
+
const wizardPkgJson = JSON.parse(
|
|
203
|
+
readFileSync('../package.json', 'utf-8'),
|
|
204
|
+
) as PackageDotJson;
|
|
205
|
+
version = wizardPkgJson.version;
|
|
206
|
+
} catch {
|
|
207
|
+
// ignore
|
|
208
|
+
}
|
|
203
209
|
}
|
|
210
|
+
return version ?? '';
|
|
204
211
|
}
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
abortIfCancelled,
|
|
8
8
|
addDotEnvSentryBuildPluginFile,
|
|
9
9
|
} from '../../utils/clack-utils';
|
|
10
|
-
import { WizardOptions } from '../../utils/types';
|
|
10
|
+
import type { WizardOptions } from '../../utils/types';
|
|
11
11
|
|
|
12
|
-
import { SourceMapUploadToolConfigurationOptions } from './types';
|
|
12
|
+
import type { SourceMapUploadToolConfigurationOptions } from './types';
|
|
13
13
|
|
|
14
14
|
import * as Sentry from '@sentry/node';
|
|
15
15
|
|
|
@@ -33,9 +33,6 @@ const getCodeSnippet = (options: SourceMapUploadToolConfigurationOptions) =>
|
|
|
33
33
|
${chalk.greenBright(`const sentryOptions = {
|
|
34
34
|
// Upload additional client files (increases upload size)
|
|
35
35
|
widenClientFileUpload: true,
|
|
36
|
-
|
|
37
|
-
// Hides source maps from generated client bundles
|
|
38
|
-
hideSourceMaps: true,
|
|
39
36
|
};`)}
|
|
40
37
|
|
|
41
38
|
${chalk.greenBright(`module.exports = withSentryConfig(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
|
-
import * as fs from 'fs';
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
3
|
|
|
4
4
|
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
5
5
|
import * as clack from '@clack/prompts';
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from '../../utils/clack-utils';
|
|
24
24
|
import { hasPackageInstalled } from '../../utils/package-json';
|
|
25
25
|
|
|
26
|
-
import {
|
|
26
|
+
import type {
|
|
27
27
|
SourceMapUploadToolConfigurationFunction,
|
|
28
28
|
SourceMapUploadToolConfigurationOptions,
|
|
29
29
|
} from './types';
|
package/src/telemetry.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
-
defaultStackParser,
|
|
3
2
|
Hub,
|
|
4
3
|
Integrations,
|
|
4
|
+
NodeClient,
|
|
5
|
+
type Span,
|
|
6
|
+
defaultStackParser,
|
|
7
|
+
flush,
|
|
5
8
|
makeMain,
|
|
6
9
|
makeNodeTransport,
|
|
7
|
-
NodeClient,
|
|
8
10
|
runWithAsyncContext,
|
|
9
11
|
setTag,
|
|
10
12
|
startSpan,
|
|
11
|
-
flush,
|
|
12
|
-
Span,
|
|
13
13
|
} from '@sentry/node';
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
14
|
+
import { readFileSync } from 'node:fs';
|
|
15
|
+
import { dirname, join } from 'node:path';
|
|
16
|
+
import type { WizardOptions } from './utils/types';
|
|
16
17
|
|
|
17
18
|
export async function withTelemetry<F>(
|
|
18
19
|
options: {
|
|
@@ -68,6 +69,25 @@ export async function withTelemetry<F>(
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
function createSentryInstance(enabled: boolean, integration: string) {
|
|
72
|
+
let version: string | undefined = process.env.npm_package_version;
|
|
73
|
+
if (!version) {
|
|
74
|
+
try {
|
|
75
|
+
const pathToPackageJson = join(
|
|
76
|
+
dirname(require.resolve('@sentry/wizard')),
|
|
77
|
+
'..',
|
|
78
|
+
'package.json',
|
|
79
|
+
);
|
|
80
|
+
const packageJsonData = readFileSync(pathToPackageJson, 'utf-8');
|
|
81
|
+
const parsedPackageJson = JSON.parse(packageJsonData) as {
|
|
82
|
+
version?: string;
|
|
83
|
+
};
|
|
84
|
+
version = parsedPackageJson.version;
|
|
85
|
+
} catch {
|
|
86
|
+
// If we fail to read the package.json file, we don't want to crash the wizard
|
|
87
|
+
// so we just don't set the version
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
71
91
|
const client = new NodeClient({
|
|
72
92
|
dsn: 'https://8871d3ff64814ed8960c96d1fcc98a27@o1.ingest.sentry.io/4505425820712960',
|
|
73
93
|
enabled: enabled,
|
|
@@ -77,7 +97,7 @@ function createSentryInstance(enabled: boolean, integration: string) {
|
|
|
77
97
|
tracesSampleRate: 1,
|
|
78
98
|
sampleRate: 1,
|
|
79
99
|
|
|
80
|
-
release:
|
|
100
|
+
release: version,
|
|
81
101
|
integrations: [new Integrations.Http()],
|
|
82
102
|
tracePropagationTargets: [/^https:\/\/sentry.io\//],
|
|
83
103
|
|
package/src/utils/clack-utils.ts
CHANGED
|
@@ -1,31 +1,25 @@
|
|
|
1
|
+
import * as childProcess from 'node:child_process';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import * as os from 'node:os';
|
|
4
|
+
import { basename, dirname, isAbsolute, join, relative } from 'node:path';
|
|
5
|
+
import { setInterval } from 'node:timers';
|
|
6
|
+
import { URL } from 'node:url';
|
|
1
7
|
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
2
8
|
import * as clack from '@clack/prompts';
|
|
9
|
+
import * as Sentry from '@sentry/node';
|
|
3
10
|
import axios from 'axios';
|
|
4
11
|
import chalk from 'chalk';
|
|
5
|
-
import
|
|
6
|
-
import * as fs from 'fs';
|
|
7
|
-
import * as path from 'path';
|
|
8
|
-
import * as os from 'os';
|
|
9
|
-
import { setInterval } from 'timers';
|
|
10
|
-
import { URL } from 'url';
|
|
11
|
-
import * as Sentry from '@sentry/node';
|
|
12
|
-
import { hasPackageInstalled, PackageDotJson } from './package-json';
|
|
13
|
-
import { Feature, SentryProjectData, WizardOptions } from './types';
|
|
12
|
+
import opn from 'opn';
|
|
14
13
|
import { traceStep } from '../telemetry';
|
|
14
|
+
import { debug } from './debug';
|
|
15
|
+
import { type PackageDotJson, hasPackageInstalled } from './package-json';
|
|
15
16
|
import {
|
|
17
|
+
type PackageManager,
|
|
16
18
|
detectPackageManger,
|
|
17
|
-
PackageManager,
|
|
18
19
|
packageManagers,
|
|
19
20
|
} from './package-manager';
|
|
20
|
-
import { debug } from './debug';
|
|
21
21
|
import { fulfillsVersionRange } from './semver';
|
|
22
|
-
|
|
23
|
-
export const opn = require('opn') as (
|
|
24
|
-
url: string,
|
|
25
|
-
options?: {
|
|
26
|
-
wait?: boolean;
|
|
27
|
-
},
|
|
28
|
-
) => Promise<childProcess.ChildProcess>;
|
|
22
|
+
import type { Feature, SentryProjectData, WizardOptions } from './types';
|
|
29
23
|
|
|
30
24
|
export const SENTRY_DOT_ENV_FILE = '.env.sentry-build-plugin';
|
|
31
25
|
export const SENTRY_CLI_RC_FILE = '.sentryclirc';
|
|
@@ -145,23 +139,32 @@ export async function abortIfCancelled<T>(
|
|
|
145
139
|
}
|
|
146
140
|
}
|
|
147
141
|
|
|
142
|
+
type PackageJSON = { version?: string };
|
|
143
|
+
|
|
148
144
|
export function printWelcome(options: {
|
|
149
145
|
wizardName: string;
|
|
150
146
|
promoCode?: string;
|
|
151
147
|
message?: string;
|
|
152
148
|
telemetryEnabled?: boolean;
|
|
153
149
|
}): void {
|
|
154
|
-
let
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
150
|
+
let wizardVersion = process.env.npm_package_version;
|
|
151
|
+
if (!wizardVersion) {
|
|
152
|
+
try {
|
|
153
|
+
wizardVersion = (
|
|
154
|
+
JSON.parse(
|
|
155
|
+
fs.readFileSync(
|
|
156
|
+
join(
|
|
157
|
+
dirname(require.resolve('@sentry/wizard')),
|
|
158
|
+
'..',
|
|
159
|
+
'package.json',
|
|
160
|
+
),
|
|
161
|
+
'utf-8',
|
|
162
|
+
),
|
|
163
|
+
) as PackageJSON
|
|
164
|
+
).version;
|
|
165
|
+
} catch {
|
|
166
|
+
// We don't need to have this
|
|
167
|
+
}
|
|
165
168
|
}
|
|
166
169
|
|
|
167
170
|
// eslint-disable-next-line no-console
|
|
@@ -176,8 +179,8 @@ export function printWelcome(options: {
|
|
|
176
179
|
welcomeText = `${welcomeText}\n\nUsing promo-code: ${options.promoCode}`;
|
|
177
180
|
}
|
|
178
181
|
|
|
179
|
-
if (
|
|
180
|
-
welcomeText = `${welcomeText}\n\nVersion: ${
|
|
182
|
+
if (wizardVersion) {
|
|
183
|
+
welcomeText = `${welcomeText}\n\nVersion: ${wizardVersion}`;
|
|
181
184
|
}
|
|
182
185
|
|
|
183
186
|
if (options.telemetryEnabled) {
|
|
@@ -408,7 +411,7 @@ export async function installPackage({
|
|
|
408
411
|
if (err) {
|
|
409
412
|
// Write a log file so we can better troubleshoot issues
|
|
410
413
|
fs.writeFileSync(
|
|
411
|
-
|
|
414
|
+
join(
|
|
412
415
|
process.cwd(),
|
|
413
416
|
`sentry-wizard-installation-error-${Date.now()}.log`,
|
|
414
417
|
),
|
|
@@ -454,7 +457,7 @@ export async function addSentryCliConfig(
|
|
|
454
457
|
setupConfig: CliSetupConfig = rcCliSetupConfig,
|
|
455
458
|
): Promise<void> {
|
|
456
459
|
return traceStep('add-sentry-cli-config', async () => {
|
|
457
|
-
const configPath =
|
|
460
|
+
const configPath = join(process.cwd(), setupConfig.filename);
|
|
458
461
|
const configExists = fs.existsSync(configPath);
|
|
459
462
|
|
|
460
463
|
let configContents =
|
|
@@ -597,7 +600,7 @@ export async function addDotEnvSentryBuildPluginFile(
|
|
|
597
600
|
SENTRY_AUTH_TOKEN=${authToken}
|
|
598
601
|
`;
|
|
599
602
|
|
|
600
|
-
const dotEnvFilePath =
|
|
603
|
+
const dotEnvFilePath = join(process.cwd(), SENTRY_DOT_ENV_FILE);
|
|
601
604
|
const dotEnvFileExists = fs.existsSync(dotEnvFilePath);
|
|
602
605
|
|
|
603
606
|
if (dotEnvFileExists) {
|
|
@@ -658,7 +661,7 @@ SENTRY_AUTH_TOKEN=${authToken}
|
|
|
658
661
|
}
|
|
659
662
|
|
|
660
663
|
async function addCliConfigFileToGitIgnore(filename: string): Promise<void> {
|
|
661
|
-
const gitignorePath =
|
|
664
|
+
const gitignorePath = join(process.cwd(), '.gitignore');
|
|
662
665
|
|
|
663
666
|
try {
|
|
664
667
|
const gitignoreContent = await fs.promises.readFile(gitignorePath, 'utf8');
|
|
@@ -794,7 +797,7 @@ export async function ensurePackageIsInstalled(
|
|
|
794
797
|
|
|
795
798
|
export async function getPackageDotJson(): Promise<PackageDotJson> {
|
|
796
799
|
const packageJsonFileContents = await fs.promises
|
|
797
|
-
.readFile(
|
|
800
|
+
.readFile(join(process.cwd(), 'package.json'), 'utf8')
|
|
798
801
|
.catch(() => {
|
|
799
802
|
clack.log.error(
|
|
800
803
|
'Could not find package.json. Make sure to run the wizard in the root of your app!',
|
|
@@ -825,7 +828,7 @@ export async function updatePackageDotJson(
|
|
|
825
828
|
): Promise<void> {
|
|
826
829
|
try {
|
|
827
830
|
await fs.promises.writeFile(
|
|
828
|
-
|
|
831
|
+
join(process.cwd(), 'package.json'),
|
|
829
832
|
// TODO: maybe figure out the original indentation
|
|
830
833
|
JSON.stringify(packageDotJson, null, 2),
|
|
831
834
|
{
|
|
@@ -865,7 +868,7 @@ export async function getPackageManager(): Promise<PackageManager> {
|
|
|
865
868
|
|
|
866
869
|
export function isUsingTypeScript() {
|
|
867
870
|
try {
|
|
868
|
-
return fs.existsSync(
|
|
871
|
+
return fs.existsSync(join(process.cwd(), 'tsconfig.json'));
|
|
869
872
|
} catch {
|
|
870
873
|
return false;
|
|
871
874
|
}
|
|
@@ -1127,9 +1130,9 @@ async function askForWizardLogin(options: {
|
|
|
1127
1130
|
)}\n\n${chalk.cyan(urlToOpen)}`,
|
|
1128
1131
|
);
|
|
1129
1132
|
|
|
1130
|
-
opn
|
|
1131
|
-
|
|
1132
|
-
});
|
|
1133
|
+
// opn throws in environments that don't have a browser (e.g. remote shells) so we just noop here
|
|
1134
|
+
const noop = () => {}; // eslint-disable-line @typescript-eslint/no-empty-function
|
|
1135
|
+
opn(urlToOpen, { wait: false }).then((cp) => cp.on('error', noop), noop);
|
|
1133
1136
|
|
|
1134
1137
|
const loginSpinner = clack.spinner();
|
|
1135
1138
|
|
|
@@ -1276,7 +1279,7 @@ export async function askForToolConfigPath(
|
|
|
1276
1279
|
return await abortIfCancelled(
|
|
1277
1280
|
clack.text({
|
|
1278
1281
|
message: `Please enter the path to your ${toolName} config file:`,
|
|
1279
|
-
placeholder:
|
|
1282
|
+
placeholder: join('.', configFileName),
|
|
1280
1283
|
validate: (value) => {
|
|
1281
1284
|
if (!value) {
|
|
1282
1285
|
return 'Please enter a path.';
|
|
@@ -1323,9 +1326,9 @@ export async function showCopyPasteInstructions(
|
|
|
1323
1326
|
hint?: string,
|
|
1324
1327
|
): Promise<void> {
|
|
1325
1328
|
clack.log.step(
|
|
1326
|
-
`Add the following code to your ${chalk.cyan(
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
+
`Add the following code to your ${chalk.cyan(basename(filename))} file:${
|
|
1330
|
+
hint ? chalk.dim(` (${chalk.dim(hint)})`) : ''
|
|
1331
|
+
}`,
|
|
1329
1332
|
);
|
|
1330
1333
|
|
|
1331
1334
|
// Padding the code snippet to be printed with a \n at the beginning and end
|
|
@@ -1406,12 +1409,12 @@ export async function createNewConfigFile(
|
|
|
1406
1409
|
codeSnippet: string,
|
|
1407
1410
|
moreInformation?: string,
|
|
1408
1411
|
): Promise<boolean> {
|
|
1409
|
-
if (!
|
|
1412
|
+
if (!isAbsolute(filepath)) {
|
|
1410
1413
|
debug(`createNewConfigFile: filepath is not absolute: ${filepath}`);
|
|
1411
1414
|
return false;
|
|
1412
1415
|
}
|
|
1413
1416
|
|
|
1414
|
-
const prettyFilename = chalk.cyan(
|
|
1417
|
+
const prettyFilename = chalk.cyan(relative(process.cwd(), filepath));
|
|
1415
1418
|
|
|
1416
1419
|
try {
|
|
1417
1420
|
await fs.promises.writeFile(filepath, codeSnippet);
|
|
@@ -10,6 +10,10 @@ import {
|
|
|
10
10
|
import * as bash from '../../src/utils/bash';
|
|
11
11
|
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
12
12
|
import * as clack from '@clack/prompts';
|
|
13
|
+
jest.mock('@clack/prompts', () => ({
|
|
14
|
+
__esModule: true,
|
|
15
|
+
...jest.requireActual('@clack/prompts'),
|
|
16
|
+
}));
|
|
13
17
|
|
|
14
18
|
jest.mock('../../src/utils/bash');
|
|
15
19
|
jest.spyOn(Sentry, 'setTag').mockImplementation();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as os from 'os';
|
|
3
|
-
import * as path from 'path';
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as os from 'node:os';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
4
|
import {
|
|
5
5
|
addSentryToFastlane,
|
|
6
6
|
exportForTesting,
|
|
@@ -9,6 +9,11 @@ import {
|
|
|
9
9
|
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
10
10
|
import * as clack from '@clack/prompts';
|
|
11
11
|
|
|
12
|
+
jest.mock('@clack/prompts', () => ({
|
|
13
|
+
__esModule: true,
|
|
14
|
+
...jest.requireActual('@clack/prompts'),
|
|
15
|
+
}));
|
|
16
|
+
|
|
12
17
|
describe('fastlane', () => {
|
|
13
18
|
beforeEach(() => {
|
|
14
19
|
jest.spyOn(clack.log, 'warn').mockImplementation();
|
|
@@ -422,7 +427,7 @@ end
|
|
|
422
427
|
platform :ios do
|
|
423
428
|
lane :test do
|
|
424
429
|
puts 'Hello, world!'
|
|
425
|
-
end
|
|
430
|
+
end
|
|
426
431
|
end
|
|
427
432
|
`,
|
|
428
433
|
);
|
|
@@ -443,7 +448,7 @@ platform :ios do
|
|
|
443
448
|
project_slug: 'test-project',
|
|
444
449
|
include_sources: true
|
|
445
450
|
)
|
|
446
|
-
end
|
|
451
|
+
end
|
|
447
452
|
end
|
|
448
453
|
`,
|
|
449
454
|
);
|
|
@@ -463,7 +468,7 @@ end
|
|
|
463
468
|
`platform :ios do
|
|
464
469
|
lane :test do
|
|
465
470
|
puts 'Hello, world!'
|
|
466
|
-
end
|
|
471
|
+
end
|
|
467
472
|
|
|
468
473
|
lane :beta do
|
|
469
474
|
puts 'Beta lane'
|
|
@@ -505,7 +510,7 @@ end
|
|
|
505
510
|
`platform :ios do
|
|
506
511
|
lane :test do
|
|
507
512
|
puts 'Hello, world!'
|
|
508
|
-
end
|
|
513
|
+
end
|
|
509
514
|
|
|
510
515
|
lane :beta do
|
|
511
516
|
puts 'Beta lane'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as os from 'os';
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
import {
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as os from 'node:os';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import type {
|
|
5
5
|
PBXFileReference,
|
|
6
6
|
PBXGroup,
|
|
7
7
|
PBXNativeTarget,
|
|
@@ -11,15 +11,17 @@ import {
|
|
|
11
11
|
} from 'xcode';
|
|
12
12
|
import { getRunScriptTemplate } from '../../src/apple/templates';
|
|
13
13
|
import { XcodeProject } from '../../src/apple/xcode-manager';
|
|
14
|
-
import { SentryProjectData } from '../../src/utils/types';
|
|
14
|
+
import type { SentryProjectData } from '../../src/utils/types';
|
|
15
15
|
|
|
16
|
+
jest.mock('node:fs', () => ({
|
|
17
|
+
__esModule: true,
|
|
18
|
+
...jest.requireActual('node:fs'),
|
|
19
|
+
}));
|
|
16
20
|
jest.mock('@clack/prompts', () => ({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
step: jest.fn(),
|
|
22
|
-
},
|
|
21
|
+
log: {
|
|
22
|
+
info: jest.fn(),
|
|
23
|
+
success: jest.fn(),
|
|
24
|
+
step: jest.fn(),
|
|
23
25
|
},
|
|
24
26
|
}));
|
|
25
27
|
|
|
@@ -273,9 +273,6 @@ describe('Next.js code templates', () => {
|
|
|
273
273
|
// side errors will fail.
|
|
274
274
|
tunnelRoute: "/monitoring",
|
|
275
275
|
|
|
276
|
-
// Hides source maps from generated client bundles
|
|
277
|
-
hideSourceMaps: true,
|
|
278
|
-
|
|
279
276
|
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
|
280
277
|
disableLogger: true,
|
|
281
278
|
|
|
@@ -322,9 +319,6 @@ describe('Next.js code templates', () => {
|
|
|
322
319
|
// side errors will fail.
|
|
323
320
|
tunnelRoute: "/monitoring",
|
|
324
321
|
|
|
325
|
-
// Hides source maps from generated client bundles
|
|
326
|
-
hideSourceMaps: true,
|
|
327
|
-
|
|
328
322
|
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
|
329
323
|
disableLogger: true,
|
|
330
324
|
|
|
@@ -370,9 +364,6 @@ describe('Next.js code templates', () => {
|
|
|
370
364
|
// side errors will fail.
|
|
371
365
|
// tunnelRoute: "/monitoring",
|
|
372
366
|
|
|
373
|
-
// Hides source maps from generated client bundles
|
|
374
|
-
hideSourceMaps: true,
|
|
375
|
-
|
|
376
367
|
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
|
377
368
|
disableLogger: true,
|
|
378
369
|
|
|
@@ -423,9 +414,6 @@ describe('Next.js code templates', () => {
|
|
|
423
414
|
// side errors will fail.
|
|
424
415
|
tunnelRoute: "/monitoring",
|
|
425
416
|
|
|
426
|
-
// Hides source maps from generated client bundles
|
|
427
|
-
hideSourceMaps: true,
|
|
428
|
-
|
|
429
417
|
// Automatically tree-shake Sentry logger statements to reduce bundle size
|
|
430
418
|
disableLogger: true,
|
|
431
419
|
|
|
@@ -4,43 +4,33 @@ import {
|
|
|
4
4
|
installPackage,
|
|
5
5
|
} from '../../src/utils/clack-utils';
|
|
6
6
|
|
|
7
|
-
import * as fs from 'fs';
|
|
8
|
-
import * as ChildProcess from 'child_process';
|
|
9
|
-
import { PackageManager } from '../../src/utils/package-manager';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
import * as fs from 'node:fs';
|
|
8
|
+
import * as ChildProcess from 'node:child_process';
|
|
9
|
+
import type { PackageManager } from '../../src/utils/package-manager';
|
|
10
|
+
|
|
11
|
+
// @ts-ignore - clack is ESM and TS complains about that. It works though
|
|
12
|
+
import * as clack from '@clack/prompts';
|
|
13
|
+
|
|
14
|
+
jest.mock('node:child_process', () => ({
|
|
15
|
+
__esModule: true,
|
|
16
|
+
...jest.requireActual('node:child_process'),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
jest.mock('@clack/prompts', () => ({
|
|
16
20
|
log: {
|
|
17
|
-
info: jest.
|
|
18
|
-
success: jest.
|
|
19
|
-
warn: jest.
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
jest
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
success: jest.fn(),
|
|
31
|
-
warn: jest.fn(),
|
|
32
|
-
},
|
|
33
|
-
text: jest.fn(),
|
|
34
|
-
confirm: jest.fn(),
|
|
35
|
-
cancel: jest.fn(),
|
|
36
|
-
// passthrough for abortIfCancelled
|
|
37
|
-
isCancel: jest.fn().mockReturnValue(false),
|
|
38
|
-
spinner: jest
|
|
39
|
-
.fn()
|
|
40
|
-
.mockImplementation(() => ({ start: jest.fn(), stop: jest.fn() })),
|
|
41
|
-
};
|
|
42
|
-
return clackMock;
|
|
43
|
-
});
|
|
21
|
+
info: jest.fn(),
|
|
22
|
+
success: jest.fn(),
|
|
23
|
+
warn: jest.fn(),
|
|
24
|
+
},
|
|
25
|
+
text: jest.fn(),
|
|
26
|
+
confirm: jest.fn(),
|
|
27
|
+
cancel: jest.fn(),
|
|
28
|
+
// passthrough for abortIfCancelled
|
|
29
|
+
isCancel: jest.fn().mockReturnValue(false),
|
|
30
|
+
spinner: jest
|
|
31
|
+
.fn()
|
|
32
|
+
.mockImplementation(() => ({ start: jest.fn(), stop: jest.fn() })),
|
|
33
|
+
}));
|
|
44
34
|
|
|
45
35
|
function mockUserResponse(fn: jest.Mock, response: any) {
|
|
46
36
|
fn.mockReturnValueOnce(response);
|
|
@@ -52,11 +42,11 @@ describe('askForToolConfigPath', () => {
|
|
|
52
42
|
});
|
|
53
43
|
|
|
54
44
|
it('returns undefined if users have no config file', async () => {
|
|
55
|
-
mockUserResponse(
|
|
45
|
+
mockUserResponse(clack.confirm as jest.Mock, false);
|
|
56
46
|
|
|
57
47
|
const result = await askForToolConfigPath('Webpack', 'webpack.config.js');
|
|
58
48
|
|
|
59
|
-
expect(
|
|
49
|
+
expect(clack.confirm).toHaveBeenCalledWith(
|
|
60
50
|
expect.objectContaining({
|
|
61
51
|
message: expect.stringContaining('have a Webpack config file'),
|
|
62
52
|
}),
|
|
@@ -66,18 +56,18 @@ describe('askForToolConfigPath', () => {
|
|
|
66
56
|
});
|
|
67
57
|
|
|
68
58
|
it('returns the path if users have a config file and the entered path is valid', async () => {
|
|
69
|
-
mockUserResponse(
|
|
70
|
-
mockUserResponse(
|
|
59
|
+
mockUserResponse(clack.confirm as jest.Mock, true);
|
|
60
|
+
mockUserResponse(clack.text as jest.Mock, 'my.webpack.config.js');
|
|
71
61
|
|
|
72
62
|
const result = await askForToolConfigPath('Webpack', 'webpack.config.js');
|
|
73
63
|
|
|
74
|
-
expect(
|
|
64
|
+
expect(clack.confirm).toHaveBeenCalledWith(
|
|
75
65
|
expect.objectContaining({
|
|
76
66
|
message: expect.stringContaining('have a Webpack config file'),
|
|
77
67
|
}),
|
|
78
68
|
);
|
|
79
69
|
|
|
80
|
-
expect(
|
|
70
|
+
expect(clack.text).toHaveBeenCalledWith(
|
|
81
71
|
expect.objectContaining({
|
|
82
72
|
message: expect.stringContaining(
|
|
83
73
|
'enter the path to your Webpack config file',
|
|
@@ -99,8 +89,8 @@ describe('createNewConfigFile', () => {
|
|
|
99
89
|
.spyOn(fs.promises, 'writeFile')
|
|
100
90
|
.mockImplementation(jest.fn());
|
|
101
91
|
|
|
102
|
-
const filename = '/
|
|
103
|
-
const code =
|
|
92
|
+
const filename = '/webpack.config.js';
|
|
93
|
+
const code = 'module.exports = {/*config...*/}';
|
|
104
94
|
|
|
105
95
|
const result = await createNewConfigFile(filename, code);
|
|
106
96
|
|
|
@@ -111,14 +101,14 @@ describe('createNewConfigFile', () => {
|
|
|
111
101
|
it('logs more information if provided as an argument', async () => {
|
|
112
102
|
jest.spyOn(fs.promises, 'writeFile').mockImplementation(jest.fn());
|
|
113
103
|
|
|
114
|
-
const filename = '/
|
|
115
|
-
const code =
|
|
104
|
+
const filename = '/webpack.config.js';
|
|
105
|
+
const code = 'module.exports = {/*config...*/}';
|
|
116
106
|
const moreInfo = 'More information...';
|
|
117
107
|
|
|
118
108
|
await createNewConfigFile(filename, code, moreInfo);
|
|
119
109
|
|
|
120
|
-
expect(
|
|
121
|
-
expect(
|
|
110
|
+
expect(clack.log.info).toHaveBeenCalledTimes(1);
|
|
111
|
+
expect(clack.log.info).toHaveBeenCalledWith(
|
|
122
112
|
expect.stringContaining(moreInfo),
|
|
123
113
|
);
|
|
124
114
|
});
|
|
@@ -129,13 +119,13 @@ describe('createNewConfigFile', () => {
|
|
|
129
119
|
.mockImplementation(() => Promise.reject(new Error('Could not write')));
|
|
130
120
|
|
|
131
121
|
const filename = '/webpack.config.js';
|
|
132
|
-
const code =
|
|
122
|
+
const code = 'module.exports = {/*config...*/}';
|
|
133
123
|
|
|
134
124
|
const result = await createNewConfigFile(filename, code);
|
|
135
125
|
|
|
136
126
|
expect(result).toBe(false);
|
|
137
127
|
expect(writeFileSpy).toHaveBeenCalledWith(filename, code);
|
|
138
|
-
expect(
|
|
128
|
+
expect(clack.log.warn).toHaveBeenCalledTimes(1);
|
|
139
129
|
});
|
|
140
130
|
|
|
141
131
|
it('returns false if the passed path is not absolute', async () => {
|