@sentry/wizard 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -1
- package/README.md +23 -19
- package/dist/bin.js +13 -0
- package/dist/bin.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-14.test.js +3 -2
- package/dist/e2e-tests/tests/nextjs-14.test.js.map +1 -1
- package/dist/e2e-tests/tests/nextjs-15.test.js +2 -2
- package/dist/e2e-tests/tests/nextjs-15.test.js.map +1 -1
- package/dist/e2e-tests/utils/index.d.ts +1 -1
- package/dist/e2e-tests/utils/index.js +20 -2
- package/dist/e2e-tests/utils/index.js.map +1 -1
- package/dist/lib/Constants.d.ts +2 -0
- 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 +3 -0
- 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__/SentryCli.js +21 -4
- package/dist/lib/Helper/__tests__/SentryCli.js.map +1 -1
- package/dist/lib/Setup.d.ts +3 -1
- package/dist/lib/Setup.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/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 +6 -13
- 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 +37 -118
- 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/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/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/xcode-manager.js +1 -1
- 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 +191 -63
- 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.js +7 -7
- 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 +1 -1
- package/dist/src/react-native/react-native-wizard.js +36 -31
- 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 +2 -1
- package/dist/src/react-native/xcode.js +1 -2
- 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} +72 -19
- 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 +6 -1
- package/dist/src/utils/package-manager.js +25 -19
- 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 +0 -1
- package/dist/test/android/code-tools.test.js.map +1 -1
- package/dist/test/apple/cocoapod.test.js +1 -1
- package/dist/test/apple/cocoapod.test.js.map +1 -1
- package/dist/test/apple/code-tools.test.js +1 -1
- package/dist/test/apple/code-tools.test.js.map +1 -1
- package/dist/test/apple/fastfile.test.js +1 -1
- package/dist/test/apple/fastfile.test.js.map +1 -1
- package/dist/test/apple/xcode-manager.test.js +26 -2
- package/dist/test/apple/xcode-manager.test.js.map +1 -1
- package/dist/test/flutter/code-tools.test.js +0 -2
- package/dist/test/flutter/code-tools.test.js.map +1 -1
- package/dist/test/flutter/templates.test.js +23 -23
- package/dist/test/flutter/templates.test.js.map +1 -1
- package/dist/test/nextjs/templates.test.js +128 -83
- package/dist/test/nextjs/templates.test.js.map +1 -1
- package/dist/test/react-native/expo-metro.test.js +1 -1
- package/dist/test/react-native/expo-metro.test.js.map +1 -1
- package/dist/test/react-native/javascript.test.js +1 -1
- package/dist/test/react-native/javascript.test.js.map +1 -1
- package/dist/test/react-native/metro.test.js +1 -1
- package/dist/test/react-native/metro.test.js.map +1 -1
- package/dist/test/sourcemaps/tools/sentry-cli.test.js +5 -5
- package/dist/test/sourcemaps/tools/sentry-cli.test.js.map +1 -1
- package/dist/test/utils/{clack-utils.test.js → clack/index.test.js} +91 -18
- 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 +29 -0
- package/dist/test/utils/package-manager.test.js.map +1 -0
- package/package.json +1 -1
- package/dist/src/utils/clack-utils.js.map +0 -1
- package/dist/test/utils/clack-utils.test.js.map +0 -1
- /package/dist/test/utils/{clack-utils.test.d.ts → clack/index.test.d.ts} +0 -0
package/dist/src/nuxt/utils.js
CHANGED
|
@@ -24,12 +24,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.isNuxtV4 = void 0;
|
|
27
|
-
// @ts-
|
|
27
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
28
28
|
const clack = __importStar(require("@clack/prompts"));
|
|
29
29
|
const semver_1 = require("semver");
|
|
30
30
|
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
|
|
31
31
|
const magicast_1 = require("magicast");
|
|
32
|
-
const
|
|
32
|
+
const clack_1 = require("../utils/clack");
|
|
33
33
|
async function isNuxtV4(nuxtConfig, packageVersion) {
|
|
34
34
|
if (!packageVersion) {
|
|
35
35
|
return false;
|
|
@@ -42,6 +42,8 @@ async function isNuxtV4(nuxtConfig, packageVersion) {
|
|
|
42
42
|
// major yet. We must read the `compatibilityVersion`
|
|
43
43
|
// from the nuxt config.
|
|
44
44
|
try {
|
|
45
|
+
// Magicast is hard to type correctly so we disable these rules
|
|
46
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */
|
|
45
47
|
const mod = await (0, magicast_1.loadFile)(nuxtConfig);
|
|
46
48
|
const config = mod.exports.default.$type === 'function-call'
|
|
47
49
|
? mod.exports.default.$args[0]
|
|
@@ -49,10 +51,11 @@ async function isNuxtV4(nuxtConfig, packageVersion) {
|
|
|
49
51
|
if (config && config.future && config.future.compatibilityVersion === 4) {
|
|
50
52
|
return true;
|
|
51
53
|
}
|
|
54
|
+
/* eslint-enable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */
|
|
52
55
|
}
|
|
53
56
|
catch {
|
|
54
57
|
// If we cannot parse their config, just ask.
|
|
55
|
-
return await (0,
|
|
58
|
+
return await (0, clack_1.abortIfCancelled)(clack.confirm({ message: 'Are you using Nuxt version 4?' }));
|
|
56
59
|
}
|
|
57
60
|
return false;
|
|
58
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/nuxt/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/nuxt/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,mCAAyC;AACzC,kFAAkF;AAClF,uCAAoC;AACpC,0CAAkD;AAE3C,KAAK,UAAU,QAAQ,CAC5B,UAAkB,EAClB,cAAkC;IAElC,IAAI,CAAC,cAAc,EAAE;QACnB,OAAO,KAAK,CAAC;KACd;IAED,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,cAAc,CAAC,CAAC;IAC1C,IAAI,MAAM,IAAI,IAAA,YAAG,EAAC,MAAM,EAAE,OAAO,CAAC,EAAE;QAClC,OAAO,IAAI,CAAC;KACb;IAED,mDAAmD;IACnD,qDAAqD;IACrD,wBAAwB;IACxB,IAAI;QACF,+DAA+D;QAC/D,wGAAwG;QACxG,MAAM,GAAG,GAAG,MAAM,IAAA,mBAAQ,EAAC,UAAU,CAAC,CAAC;QACvC,MAAM,MAAM,GACV,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,KAAK,eAAe;YAC3C,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;YAC9B,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC;QAE1B,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,oBAAoB,KAAK,CAAC,EAAE;YACvE,OAAO,IAAI,CAAC;SACb;QACD,uGAAuG;KACxG;IAAC,MAAM;QACN,6CAA6C;QAC7C,OAAO,MAAM,IAAA,wBAAgB,EAC3B,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC,CAC5D,CAAC;KACH;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AArCD,4BAqCC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport { gte, minVersion } from 'semver';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { loadFile } from 'magicast';\nimport { abortIfCancelled } from '../utils/clack';\n\nexport async function isNuxtV4(\n nuxtConfig: string,\n packageVersion: string | undefined,\n) {\n if (!packageVersion) {\n return false;\n }\n\n const minVer = minVersion(packageVersion);\n if (minVer && gte(minVer, '4.0.0')) {\n return true;\n }\n\n // At the time of writing, nuxt 4 is not on its own\n // major yet. We must read the `compatibilityVersion`\n // from the nuxt config.\n try {\n // Magicast is hard to type correctly so we disable these rules\n /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */\n const mod = await loadFile(nuxtConfig);\n const config =\n mod.exports.default.$type === 'function-call'\n ? mod.exports.default.$args[0]\n : mod.exports.default;\n\n if (config && config.future && config.future.compatibilityVersion === 4) {\n return true;\n }\n /* eslint-enable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-assignment */\n } catch {\n // If we cannot parse their config, just ask.\n return await abortIfCancelled(\n clack.confirm({ message: 'Are you using Nuxt version 4?' }),\n );\n }\n\n return false;\n}\n"]}
|
|
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.addExpoEnvLocal = void 0;
|
|
30
|
-
// @ts-
|
|
30
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
31
31
|
const clack = __importStar(require("@clack/prompts"));
|
|
32
32
|
const chalk_1 = __importDefault(require("chalk"));
|
|
33
33
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expo-env-file.js","sourceRoot":"","sources":["../../../src/react-native/expo-env-file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"expo-env-file.js","sourceRoot":"","sources":["../../../src/react-native/expo-env-file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAC1B,4CAAoB;AACpB,qDAAuC;AAEvC,+BAAuC;AAEvC,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAElC,KAAK,UAAU,eAAe,CACnC,OAAgC;IAEhC,MAAM,UAAU,GAAG,0CAA0C,OAAO,CAAC,SAAS,IAAI,CAAC;IAEnF,MAAM,KAAK,GAAG,MAAM,IAAA,oBAAc,EAAC,mBAAmB,CAAC,CAAC;IACxD,IAAI,KAAK,EAAE;QACT,KAAK,CAAC,GAAG,CAAC,OAAO,CACf,SAAS,eAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,iBAAiB,CAC1D,CAAC;KACH;SAAM;QACL,KAAK,CAAC,GAAG,CAAC,KAAK,CACb,iBAAiB,eAAK,CAAC,IAAI,CACzB,mBAAmB,CACpB,4DAA4D,CAC9D,CAAC;KACH;IAED,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE;QACvC,IAAI;YACF,MAAM,YAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;YAC7D,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC;YAC3C,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,eAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;YACjE,OAAO,IAAI,CAAC;SACb;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;YAC/C,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,eAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;YACvE,OAAO,KAAK,CAAC;SACd;KACF;IAED,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;IAC1C,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,qBAAqB,eAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;IAExE,IAAI;QACF,MAAM,YAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;QAC9D,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC;QAC3C,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,eAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;QAChD,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,oBAAoB,eAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACxE,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AA5CD,0CA4CC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport * as Sentry from '@sentry/node';\nimport { RNCliSetupConfigContent } from './react-native-wizard';\nimport { addToGitignore } from './git';\n\nconst EXPO_ENV_LOCAL_FILE = '.env.local';\n\nexport async function addExpoEnvLocal(\n options: RNCliSetupConfigContent,\n): Promise<boolean> {\n const newContent = `#DO NOT COMMIT THIS\\nSENTRY_AUTH_TOKEN=${options.authToken}\\n`;\n\n const added = await addToGitignore(EXPO_ENV_LOCAL_FILE);\n if (added) {\n clack.log.success(\n `Added ${chalk.cyan(EXPO_ENV_LOCAL_FILE)} to .gitignore.`,\n );\n } else {\n clack.log.error(\n `Could not add ${chalk.cyan(\n EXPO_ENV_LOCAL_FILE,\n )} to .gitignore, please add it to not commit your auth key.`,\n );\n }\n\n if (!fs.existsSync(EXPO_ENV_LOCAL_FILE)) {\n try {\n await fs.promises.writeFile(EXPO_ENV_LOCAL_FILE, newContent);\n Sentry.setTag('expo-env-local', 'written');\n clack.log.success(`Written ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);\n return true;\n } catch (error) {\n Sentry.setTag('expo-env-local', 'write-error');\n clack.log.error(`Unable to write ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);\n return false;\n }\n }\n\n Sentry.setTag('expo-env-local', 'exists');\n clack.log.info(`Updating existing ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);\n\n try {\n await fs.promises.appendFile(EXPO_ENV_LOCAL_FILE, newContent);\n Sentry.setTag('expo-env-local', 'updated');\n clack.log.success(`Updated ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);\n return true;\n } catch (error) {\n Sentry.setTag('expo-env-local', 'update-error');\n clack.log.error(`Unable to update ${chalk.cyan(EXPO_ENV_LOCAL_FILE)}.`);\n return false;\n }\n}\n"]}
|
|
@@ -28,12 +28,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.addSentryExpoConfigRequire = exports.patchMetroInMemory = exports.addSentryToExpoMetroConfig = void 0;
|
|
30
30
|
const fs = __importStar(require("node:fs"));
|
|
31
|
-
// @ts-
|
|
31
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
32
32
|
const clack = __importStar(require("@clack/prompts"));
|
|
33
33
|
const chalk_1 = __importDefault(require("chalk"));
|
|
34
34
|
const Sentry = __importStar(require("@sentry/node"));
|
|
35
35
|
const ast_utils_1 = require("../utils/ast-utils");
|
|
36
|
-
const
|
|
36
|
+
const clack_1 = require("../utils/clack");
|
|
37
37
|
const metro_1 = require("./metro");
|
|
38
38
|
const recast = __importStar(require("recast"));
|
|
39
39
|
const b = recast.types.builders;
|
|
@@ -167,10 +167,10 @@ module.exports = config;
|
|
|
167
167
|
return true;
|
|
168
168
|
}
|
|
169
169
|
function showInstructions() {
|
|
170
|
-
return (0,
|
|
170
|
+
return (0, clack_1.showCopyPasteInstructions)(metro_1.metroConfigPath, getMetroWithSentryExpoConfigSnippet(true));
|
|
171
171
|
}
|
|
172
172
|
function getMetroWithSentryExpoConfigSnippet(colors) {
|
|
173
|
-
return (0,
|
|
173
|
+
return (0, clack_1.makeCodeSnippet)(colors, (unchanged, plus, minus) => unchanged(`${minus(`// const { getDefaultConfig } = require("expo/metro-config");`)}
|
|
174
174
|
${plus(`const { getSentryExpoConfig } = require("@sentry/react-native/metro");`)}
|
|
175
175
|
|
|
176
176
|
${minus(`// const config = getDefaultConfig(__dirname);`)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expo-metro.js","sourceRoot":"","sources":["../../../src/react-native/expo-metro.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,yEAAyE;AACzE,sDAAwC;AAGxC,kDAA0B;AAC1B,qDAAuC;AAEvC,kDAA2E;AAC3E,sDAG8B;AAE9B,mCAA8E;AAE9E,+CAAiC;AAIjC,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;AAEzB,KAAK,UAAU,0BAA0B;IAC9C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,uBAAe,CAAC,EAAE;QACnC,MAAM,OAAO,GAAG,MAAM,2BAA2B,EAAE,CAAC;QACpD,IAAI,CAAC,OAAO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;IACF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,gBAAgB;IACvB,OAAO,IAAA,uCAAyB,EAC9B,uBAAe,EACf,mCAAmC,CAAC,IAAI,CAAC,CAC1C,CAAC;AACJ,CAAC;AAED,SAAS,mCAAmC,CAAC,MAAe;IAC1D,OAAO,IAAA,6BAAe,EAAC,MAAM,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CACxD,SAAS,CAAC,GAAG,KAAK,CAChB,+DAA+D,CAChE;EACH,IAAI,CACJ,wEAAwE,CACzE;;EAEC,KAAK,CAAC,gDAAgD,CAAC;EACvD,IAAI,CAAC,gDAAgD,CAAC;;yBAE/B,CAAC,CACvB,CAAC;AACJ,CAAC","sourcesContent":["import * as fs from 'node:fs';\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport type { ProxifiedModule } from 'magicast';\nimport chalk from 'chalk';\nimport * as Sentry from '@sentry/node';\n\nimport { getLastRequireIndex, hasSentryContent } from '../utils/ast-utils';\nimport {\n makeCodeSnippet,\n showCopyPasteInstructions,\n} from '../utils/clack-utils';\n\nimport { metroConfigPath, parseMetroConfig, writeMetroConfig } from './metro';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nconst b = recast.types.builders;\n\nexport async function addSentryToExpoMetroConfig() {\n if (!fs.existsSync(metroConfigPath)) {\n const success = await createSentryExpoMetroConfig();\n if (!success) {\n Sentry.setTag('expo-metro-config', 'create-new-error');\n return await showInstructions();\n }\n Sentry.setTag('expo-metro-config', 'created-new');\n return undefined;\n }\n\n const mod = await parseMetroConfig();\n\n let didPatch = false;\n try {\n didPatch = patchMetroInMemory(mod);\n } catch (e) {\n // noop\n }\n if (!didPatch) {\n Sentry.setTag('expo-metro-config', 'patch-error');\n clack.log.error(\n `Could not patch ${chalk.cyan(\n metroConfigPath,\n )} with Sentry configuration.`,\n );\n return await showInstructions();\n }\n\n const saved = await writeMetroConfig(mod);\n if (saved) {\n Sentry.setTag('expo-metro-config', 'patch-saved');\n clack.log.success(\n chalk.green(`${chalk.cyan(metroConfigPath)} changes saved.`),\n );\n } else {\n Sentry.setTag('expo-metro-config', 'patch-save-error');\n clack.log.warn(\n `Could not save changes to ${chalk.cyan(\n metroConfigPath,\n )}, please follow the manual steps.`,\n );\n return await showInstructions();\n }\n}\n\nexport function patchMetroInMemory(mod: ProxifiedModule): boolean {\n const ast = mod.$ast as t.Program;\n\n if (hasSentryContent(ast)) {\n clack.log.warn(\n `The ${chalk.cyan(\n metroConfigPath,\n )} file already has Sentry configuration.`,\n );\n return false;\n }\n\n let didReplaceDefaultConfigCall = false;\n\n recast.visit(ast, {\n visitVariableDeclaration(path) {\n const { node } = path;\n\n if (\n // path is require(\"expo/metro-config\")\n // and only getDefaultConfig is being destructured\n // then remove the entire declaration\n node.declarations.length > 0 &&\n node.declarations[0].type === 'VariableDeclarator' &&\n node.declarations[0].init &&\n node.declarations[0].init.type === 'CallExpression' &&\n node.declarations[0].init.callee &&\n node.declarations[0].init.callee.type === 'Identifier' &&\n node.declarations[0].init.callee.name === 'require' &&\n node.declarations[0].init.arguments[0].type === 'StringLiteral' &&\n node.declarations[0].init.arguments[0].value === 'expo/metro-config' &&\n node.declarations[0].id.type === 'ObjectPattern' &&\n node.declarations[0].id.properties.length === 1 &&\n node.declarations[0].id.properties[0].type === 'ObjectProperty' &&\n node.declarations[0].id.properties[0].key.type === 'Identifier' &&\n node.declarations[0].id.properties[0].key.name === 'getDefaultConfig'\n ) {\n path.prune();\n return false;\n }\n\n this.traverse(path);\n },\n\n visitCallExpression(path) {\n const { node } = path;\n if (\n // path is getDefaultConfig\n // then rename it to getSentryExpoConfig\n node.callee.type === 'Identifier' &&\n node.callee.name === 'getDefaultConfig'\n ) {\n node.callee.name = 'getSentryExpoConfig';\n didReplaceDefaultConfigCall = true;\n return false;\n }\n\n this.traverse(path);\n },\n });\n\n if (!didReplaceDefaultConfigCall) {\n clack.log.warn(\n `Could not find \\`getDefaultConfig\\` in ${chalk.cyan(metroConfigPath)}.`,\n );\n return false;\n }\n\n addSentryExpoConfigRequire(ast);\n\n return true;\n}\n\nexport function addSentryExpoConfigRequire(program: t.Program) {\n const lastRequireIndex = getLastRequireIndex(program);\n const sentryExpoConfigRequire = createSentryExpoConfigRequire();\n program.body.splice(lastRequireIndex + 1, 0, sentryExpoConfigRequire);\n}\n\n/**\n * Creates const { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");\n */\nfunction createSentryExpoConfigRequire() {\n return b.variableDeclaration('const', [\n b.variableDeclarator(\n b.objectPattern([\n b.objectProperty.from({\n key: b.identifier('getSentryExpoConfig'),\n value: b.identifier('getSentryExpoConfig'),\n shorthand: true,\n }),\n ]),\n b.callExpression(b.identifier('require'), [\n b.literal('@sentry/react-native/metro'),\n ]),\n ),\n ]);\n}\n\nasync function createSentryExpoMetroConfig(): Promise<boolean> {\n const snippet = `const { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");\n\nconst config = getSentryExpoConfig(__dirname);\n\nmodule.exports = config;\n`;\n try {\n await fs.promises.writeFile(metroConfigPath, snippet);\n } catch (e) {\n clack.log.error(\n `Could not create ${chalk.cyan(\n metroConfigPath,\n )} with Sentry configuration.`,\n );\n return false;\n }\n clack.log.success(\n `Created ${chalk.cyan(metroConfigPath)} with Sentry configuration.`,\n );\n return true;\n}\n\nfunction showInstructions() {\n return showCopyPasteInstructions(\n metroConfigPath,\n getMetroWithSentryExpoConfigSnippet(true),\n );\n}\n\nfunction getMetroWithSentryExpoConfigSnippet(colors: boolean): string {\n return makeCodeSnippet(colors, (unchanged, plus, minus) =>\n unchanged(`${minus(\n `// const { getDefaultConfig } = require(\"expo/metro-config\");`,\n )}\n${plus(\n `const { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");`,\n)}\n\n${minus(`// const config = getDefaultConfig(__dirname);`)}\n${plus(`const config = getSentryExpoConfig(__dirname);`)}\n\nmodule.exports = config;`),\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"expo-metro.js","sourceRoot":"","sources":["../../../src/react-native/expo-metro.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,+EAA+E;AAC/E,sDAAwC;AAGxC,kDAA0B;AAC1B,qDAAuC;AAEvC,kDAA2E;AAC3E,0CAA4E;AAE5E,mCAA8E;AAE9E,+CAAiC;AAIjC,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;AAEzB,KAAK,UAAU,0BAA0B;IAC9C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,uBAAe,CAAC,EAAE;QACnC,MAAM,OAAO,GAAG,MAAM,2BAA2B,EAAE,CAAC;QACpD,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,CAAC;YACvD,OAAO,MAAM,gBAAgB,EAAE,CAAC;SACjC;QACD,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;QAClD,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,GAAG,GAAG,MAAM,IAAA,wBAAgB,GAAE,CAAC;IAErC,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI;QACF,QAAQ,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;KACpC;IAAC,OAAO,CAAC,EAAE;QACV,OAAO;KACR;IACD,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC;QAClD,KAAK,CAAC,GAAG,CAAC,KAAK,CACb,mBAAmB,eAAK,CAAC,IAAI,CAC3B,uBAAe,CAChB,6BAA6B,CAC/B,CAAC;QACF,OAAO,MAAM,gBAAgB,EAAE,CAAC;KACjC;IAED,MAAM,KAAK,GAAG,MAAM,IAAA,wBAAgB,EAAC,GAAG,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C,EAAE;YACxC,CAAC,CAAC,OAAO,CAAC,4BAA4B,CAAC;SACxC,CAAC,CACH;KACF,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,2BAA2B;IACxC,MAAM,OAAO,GAAG;;;;;CAKjB,CAAC;IACA,IAAI;QACF,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,uBAAe,EAAE,OAAO,CAAC,CAAC;KACvD;IAAC,OAAO,CAAC,EAAE;QACV,KAAK,CAAC,GAAG,CAAC,KAAK,CACb,oBAAoB,eAAK,CAAC,IAAI,CAC5B,uBAAe,CAChB,6BAA6B,CAC/B,CAAC;QACF,OAAO,KAAK,CAAC;KACd;IACD,KAAK,CAAC,GAAG,CAAC,OAAO,CACf,WAAW,eAAK,CAAC,IAAI,CAAC,uBAAe,CAAC,6BAA6B,CACpE,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,gBAAgB;IACvB,OAAO,IAAA,iCAAyB,EAC9B,uBAAe,EACf,mCAAmC,CAAC,IAAI,CAAC,CAC1C,CAAC;AACJ,CAAC;AAED,SAAS,mCAAmC,CAAC,MAAe;IAC1D,OAAO,IAAA,uBAAe,EAAC,MAAM,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CACxD,SAAS,CAAC,GAAG,KAAK,CAChB,+DAA+D,CAChE;EACH,IAAI,CACJ,wEAAwE,CACzE;;EAEC,KAAK,CAAC,gDAAgD,CAAC;EACvD,IAAI,CAAC,gDAAgD,CAAC;;yBAE/B,CAAC,CACvB,CAAC;AACJ,CAAC","sourcesContent":["import * as fs from 'node:fs';\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport type { ProxifiedModule } from 'magicast';\nimport chalk from 'chalk';\nimport * as Sentry from '@sentry/node';\n\nimport { getLastRequireIndex, hasSentryContent } from '../utils/ast-utils';\nimport { makeCodeSnippet, showCopyPasteInstructions } from '../utils/clack';\n\nimport { metroConfigPath, parseMetroConfig, writeMetroConfig } from './metro';\n\nimport * as recast from 'recast';\nimport x = recast.types;\nimport t = x.namedTypes;\n\nconst b = recast.types.builders;\n\nexport async function addSentryToExpoMetroConfig() {\n if (!fs.existsSync(metroConfigPath)) {\n const success = await createSentryExpoMetroConfig();\n if (!success) {\n Sentry.setTag('expo-metro-config', 'create-new-error');\n return await showInstructions();\n }\n Sentry.setTag('expo-metro-config', 'created-new');\n return undefined;\n }\n\n const mod = await parseMetroConfig();\n\n let didPatch = false;\n try {\n didPatch = patchMetroInMemory(mod);\n } catch (e) {\n // noop\n }\n if (!didPatch) {\n Sentry.setTag('expo-metro-config', 'patch-error');\n clack.log.error(\n `Could not patch ${chalk.cyan(\n metroConfigPath,\n )} with Sentry configuration.`,\n );\n return await showInstructions();\n }\n\n const saved = await writeMetroConfig(mod);\n if (saved) {\n Sentry.setTag('expo-metro-config', 'patch-saved');\n clack.log.success(\n chalk.green(`${chalk.cyan(metroConfigPath)} changes saved.`),\n );\n } else {\n Sentry.setTag('expo-metro-config', 'patch-save-error');\n clack.log.warn(\n `Could not save changes to ${chalk.cyan(\n metroConfigPath,\n )}, please follow the manual steps.`,\n );\n return await showInstructions();\n }\n}\n\nexport function patchMetroInMemory(mod: ProxifiedModule): boolean {\n const ast = mod.$ast as t.Program;\n\n if (hasSentryContent(ast)) {\n clack.log.warn(\n `The ${chalk.cyan(\n metroConfigPath,\n )} file already has Sentry configuration.`,\n );\n return false;\n }\n\n let didReplaceDefaultConfigCall = false;\n\n recast.visit(ast, {\n visitVariableDeclaration(path) {\n const { node } = path;\n\n if (\n // path is require(\"expo/metro-config\")\n // and only getDefaultConfig is being destructured\n // then remove the entire declaration\n node.declarations.length > 0 &&\n node.declarations[0].type === 'VariableDeclarator' &&\n node.declarations[0].init &&\n node.declarations[0].init.type === 'CallExpression' &&\n node.declarations[0].init.callee &&\n node.declarations[0].init.callee.type === 'Identifier' &&\n node.declarations[0].init.callee.name === 'require' &&\n node.declarations[0].init.arguments[0].type === 'StringLiteral' &&\n node.declarations[0].init.arguments[0].value === 'expo/metro-config' &&\n node.declarations[0].id.type === 'ObjectPattern' &&\n node.declarations[0].id.properties.length === 1 &&\n node.declarations[0].id.properties[0].type === 'ObjectProperty' &&\n node.declarations[0].id.properties[0].key.type === 'Identifier' &&\n node.declarations[0].id.properties[0].key.name === 'getDefaultConfig'\n ) {\n path.prune();\n return false;\n }\n\n this.traverse(path);\n },\n\n visitCallExpression(path) {\n const { node } = path;\n if (\n // path is getDefaultConfig\n // then rename it to getSentryExpoConfig\n node.callee.type === 'Identifier' &&\n node.callee.name === 'getDefaultConfig'\n ) {\n node.callee.name = 'getSentryExpoConfig';\n didReplaceDefaultConfigCall = true;\n return false;\n }\n\n this.traverse(path);\n },\n });\n\n if (!didReplaceDefaultConfigCall) {\n clack.log.warn(\n `Could not find \\`getDefaultConfig\\` in ${chalk.cyan(metroConfigPath)}.`,\n );\n return false;\n }\n\n addSentryExpoConfigRequire(ast);\n\n return true;\n}\n\nexport function addSentryExpoConfigRequire(program: t.Program) {\n const lastRequireIndex = getLastRequireIndex(program);\n const sentryExpoConfigRequire = createSentryExpoConfigRequire();\n program.body.splice(lastRequireIndex + 1, 0, sentryExpoConfigRequire);\n}\n\n/**\n * Creates const { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");\n */\nfunction createSentryExpoConfigRequire() {\n return b.variableDeclaration('const', [\n b.variableDeclarator(\n b.objectPattern([\n b.objectProperty.from({\n key: b.identifier('getSentryExpoConfig'),\n value: b.identifier('getSentryExpoConfig'),\n shorthand: true,\n }),\n ]),\n b.callExpression(b.identifier('require'), [\n b.literal('@sentry/react-native/metro'),\n ]),\n ),\n ]);\n}\n\nasync function createSentryExpoMetroConfig(): Promise<boolean> {\n const snippet = `const { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");\n\nconst config = getSentryExpoConfig(__dirname);\n\nmodule.exports = config;\n`;\n try {\n await fs.promises.writeFile(metroConfigPath, snippet);\n } catch (e) {\n clack.log.error(\n `Could not create ${chalk.cyan(\n metroConfigPath,\n )} with Sentry configuration.`,\n );\n return false;\n }\n clack.log.success(\n `Created ${chalk.cyan(metroConfigPath)} with Sentry configuration.`,\n );\n return true;\n}\n\nfunction showInstructions() {\n return showCopyPasteInstructions(\n metroConfigPath,\n getMetroWithSentryExpoConfigSnippet(true),\n );\n}\n\nfunction getMetroWithSentryExpoConfigSnippet(colors: boolean): string {\n return makeCodeSnippet(colors, (unchanged, plus, minus) =>\n unchanged(`${minus(\n `// const { getDefaultConfig } = require(\"expo/metro-config\");`,\n )}\n${plus(\n `const { getSentryExpoConfig } = require(\"@sentry/react-native/metro\");`,\n)}\n\n${minus(`// const config = getDefaultConfig(__dirname);`)}\n${plus(`const config = getSentryExpoConfig(__dirname);`)}\n\nmodule.exports = config;`),\n );\n}\n"]}
|
|
@@ -27,14 +27,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.getSentryAppConfigJsonCodeSnippet = exports.addWithSentryToAppConfigJson = exports.patchExpoAppConfig = exports.printSentryExpoMigrationOutro = exports.SENTRY_PLUGIN_FUNCTION_NAME = exports.DEPRECATED_SENTRY_EXPO_PLUGIN_NAME = exports.SENTRY_EXPO_PLUGIN_NAME = void 0;
|
|
30
|
-
// @ts-
|
|
30
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
31
31
|
const clack = __importStar(require("@clack/prompts"));
|
|
32
32
|
const chalk_1 = __importDefault(require("chalk"));
|
|
33
33
|
const fs = __importStar(require("fs"));
|
|
34
34
|
const os_1 = require("os");
|
|
35
35
|
const utils_1 = require("@sentry/utils");
|
|
36
36
|
const Sentry = __importStar(require("@sentry/node"));
|
|
37
|
-
const
|
|
37
|
+
const clack_1 = require("../utils/clack");
|
|
38
38
|
const telemetry_1 = require("../telemetry");
|
|
39
39
|
exports.SENTRY_EXPO_PLUGIN_NAME = '@sentry/react-native/expo';
|
|
40
40
|
exports.DEPRECATED_SENTRY_EXPO_PLUGIN_NAME = 'sentry-expo';
|
|
@@ -49,7 +49,7 @@ exports.printSentryExpoMigrationOutro = printSentryExpoMigrationOutro;
|
|
|
49
49
|
*/
|
|
50
50
|
async function patchExpoAppConfig(options) {
|
|
51
51
|
function showInstructions() {
|
|
52
|
-
return (0,
|
|
52
|
+
return (0, clack_1.showCopyPasteInstructions)(APP_CONFIG_JSON, getSentryAppConfigJsonCodeSnippet(options), 'This ensures auto upload of source maps during native app build.');
|
|
53
53
|
}
|
|
54
54
|
const appConfigJsonExists = fs.existsSync(APP_CONFIG_JSON);
|
|
55
55
|
Sentry.setTag('app-config-file-status', appConfigJsonExists ? 'found' : 'not-found');
|
|
@@ -122,7 +122,7 @@ function addWithSentryToAppConfigJson(appConfigContent, options) {
|
|
|
122
122
|
}
|
|
123
123
|
exports.addWithSentryToAppConfigJson = addWithSentryToAppConfigJson;
|
|
124
124
|
function getSentryAppConfigJsonCodeSnippet({ url, project, org, }) {
|
|
125
|
-
return (0,
|
|
125
|
+
return (0, clack_1.makeCodeSnippet)(true, (unchanged, plus, _minus) => {
|
|
126
126
|
return unchanged(`{
|
|
127
127
|
"name": "my app",
|
|
128
128
|
"plugins": [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expo.js","sourceRoot":"","sources":["../../../src/react-native/expo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"expo.js","sourceRoot":"","sources":["../../../src/react-native/expo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+EAA+E;AAC/E,sDAAwC;AACxC,kDAA0B;AAC1B,uCAAyB;AACzB,2BAAyB;AAEzB,yCAA8C;AAC9C,qDAAuC;AACvC,0CAA4E;AAE5E,4CAAyC;AAE5B,QAAA,uBAAuB,GA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IAAI,CAAC;;;kBAGO,GAAG;sBACC,OAAO;2BACF,GAAG;;MAExB,CAAC;;EAEL,CAAC,CAAC;IACF,CAAC,CAAC,CAAC;AACL,CAAC;AApBD,8EAoBC","sourcesContent":["// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport * as clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as fs from 'fs';\nimport { EOL } from 'os';\n\nimport { isPlainObject } from '@sentry/utils';\nimport * as Sentry from '@sentry/node';\nimport { makeCodeSnippet, showCopyPasteInstructions } from '../utils/clack';\nimport { RNCliSetupConfigContent } from './react-native-wizard';\nimport { traceStep } from '../telemetry';\n\nexport const SENTRY_EXPO_PLUGIN_NAME = '@sentry/react-native/expo';\nexport const DEPRECATED_SENTRY_EXPO_PLUGIN_NAME = 'sentry-expo';\n\nexport const SENTRY_PLUGIN_FUNCTION_NAME = 'withSentry';\n\nconst APP_CONFIG_JSON = `app.json`;\n\nexport interface AppConfigJson {\n expo?: {\n plugins?: Array<[string, undefined | Record<string, unknown>]>;\n };\n}\n\nexport function printSentryExpoMigrationOutro(): void {\n clack.outro(\n `Deprecated ${chalk.cyan(\n 'sentry-expo',\n )} package installed in your dependencies. Please follow the migration guide at ${chalk.cyan(\n 'https://docs.sentry.io/platforms/react-native/migration/sentry-expo/',\n )}`,\n );\n}\n\n/**\n * Finds app.json in the project root and add Sentry Expo `withSentry` plugin.\n */\nexport async function patchExpoAppConfig(options: RNCliSetupConfigContent) {\n function showInstructions() {\n return showCopyPasteInstructions(\n APP_CONFIG_JSON,\n getSentryAppConfigJsonCodeSnippet(options),\n 'This ensures auto upload of source maps during native app build.',\n );\n }\n\n const appConfigJsonExists = fs.existsSync(APP_CONFIG_JSON);\n\n Sentry.setTag(\n 'app-config-file-status',\n appConfigJsonExists ? 'found' : 'not-found',\n );\n if (!appConfigJsonExists) {\n return await showInstructions();\n }\n\n const patched = await patchAppConfigJson(APP_CONFIG_JSON, options);\n if (!patched) {\n return await showInstructions();\n }\n}\n\nasync function patchAppConfigJson(\n path: string,\n options: RNCliSetupConfigContent,\n): Promise<boolean> {\n const appConfigContent = (\n await fs.promises.readFile(path, { encoding: 'utf-8' })\n ).toString();\n const patchedContent = traceStep('app-config-json-patch', () =>\n addWithSentryToAppConfigJson(appConfigContent, options),\n );\n if (patchedContent === null) {\n return false;\n }\n\n try {\n await fs.promises.writeFile(path, patchedContent);\n } catch (error) {\n Sentry.setTag('app-config-file-status', 'json-write-error');\n clack.log.error(`Unable to write ${chalk.cyan('app.config.json')}.`);\n return false;\n }\n Sentry.setTag('app-config-file-status', 'json-write-success');\n clack.log.success(\n `Added Sentry Expo plugin to ${chalk.cyan('app.config.json')}.`,\n );\n return true;\n}\n\nexport function addWithSentryToAppConfigJson(\n appConfigContent: string,\n options: RNCliSetupConfigContent,\n): string | null {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const parsedAppConfig: AppConfigJson = JSON.parse(appConfigContent);\n const includesWithSentry =\n appConfigContent.includes(SENTRY_EXPO_PLUGIN_NAME) ||\n appConfigContent.includes(DEPRECATED_SENTRY_EXPO_PLUGIN_NAME);\n\n if (includesWithSentry) {\n Sentry.setTag('app-config-file-status', 'already-patched');\n clack.log.warn(\n `Your ${chalk.cyan(\n 'app.config.json',\n )} already includes the Sentry Expo plugin.`,\n );\n return null;\n }\n\n if (\n parsedAppConfig.expo !== undefined &&\n !isPlainObject(parsedAppConfig.expo)\n ) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n return null;\n }\n if (\n parsedAppConfig.expo &&\n parsedAppConfig.expo.plugins !== undefined &&\n !Array.isArray(parsedAppConfig.expo.plugins)\n ) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n return null;\n }\n\n parsedAppConfig.expo = parsedAppConfig.expo ?? {};\n parsedAppConfig.expo.plugins = parsedAppConfig.expo.plugins ?? [];\n parsedAppConfig.expo.plugins.push([\n SENTRY_EXPO_PLUGIN_NAME,\n {\n url: options.url,\n project: options.project,\n organization: options.org,\n },\n ]);\n\n return JSON.stringify(parsedAppConfig, null, 2) + EOL;\n } catch (error) {\n Sentry.setTag('app-config-file-status', 'invalid-json');\n clack.log.error(\n `Unable to parse your ${chalk.cyan(\n 'app.config.json',\n )}. Make sure it has a valid format!`,\n );\n return null;\n }\n}\n\nexport function getSentryAppConfigJsonCodeSnippet({\n url,\n project,\n org,\n}: Omit<RNCliSetupConfigContent, 'authToken'>) {\n return makeCodeSnippet(true, (unchanged, plus, _minus) => {\n return unchanged(`{\n \"name\": \"my app\",\n \"plugins\": [\n ${plus(`[\n \"@sentry/react-native/expo\",\n {\n \"url\": \"${url}\",\n \"project\": \"${project}\",\n \"organization\": \"${org}\"\n }\n ]`)}\n ],\n}`);\n });\n}\n"]}
|
|
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.doesContainSentryWrap = exports.replaceDefaultExport = exports.wrapWithSentry = exports.getDefaultExport = exports.checkAndWrapRootComponent = exports.SentryWrapResult = exports.wrapRootComponent = exports.getSentryInitPlainTextSnippet = exports.getSentryInitColoredCodeSnippet = exports.doesJsCodeIncludeSdkSentryImport = exports.addSentryInitWithSdkImport = exports.addSentryInit = void 0;
|
|
30
30
|
/* eslint-disable max-lines */
|
|
31
|
-
// @ts-
|
|
31
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
32
32
|
const prompts_1 = __importDefault(require("@clack/prompts"));
|
|
33
33
|
const chalk_1 = __importDefault(require("chalk"));
|
|
34
34
|
const path = __importStar(require("path"));
|
|
@@ -36,10 +36,10 @@ const process = __importStar(require("process"));
|
|
|
36
36
|
const fs = __importStar(require("fs"));
|
|
37
37
|
const Sentry = __importStar(require("@sentry/node"));
|
|
38
38
|
const telemetry_1 = require("../telemetry");
|
|
39
|
-
const
|
|
39
|
+
const clack_1 = require("../utils/clack");
|
|
40
40
|
const glob_1 = require("./glob");
|
|
41
41
|
const react_native_wizard_1 = require("./react-native-wizard");
|
|
42
|
-
// @ts-
|
|
42
|
+
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
|
|
43
43
|
const magicast_1 = require("magicast");
|
|
44
44
|
const t = __importStar(require("@babel/types"));
|
|
45
45
|
async function addSentryInit({ dsn }) {
|
|
@@ -47,7 +47,7 @@ async function addSentryInit({ dsn }) {
|
|
|
47
47
|
Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');
|
|
48
48
|
if (!jsPath) {
|
|
49
49
|
prompts_1.default.log.warn(`Could not find main App file. Place the following code snippet close to the Apps Root component.`);
|
|
50
|
-
await (0,
|
|
50
|
+
await (0, clack_1.showCopyPasteInstructions)('App.js or _layout.tsx', getSentryInitColoredCodeSnippet(dsn), 'This ensures the Sentry SDK is ready to capture errors.');
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
const jsRelativePath = path.relative(process.cwd(), jsPath);
|
|
@@ -79,7 +79,7 @@ function doesJsCodeIncludeSdkSentryImport(js, { sdkPackageName }) {
|
|
|
79
79
|
}
|
|
80
80
|
exports.doesJsCodeIncludeSdkSentryImport = doesJsCodeIncludeSdkSentryImport;
|
|
81
81
|
function getSentryInitColoredCodeSnippet(dsn) {
|
|
82
|
-
return (0,
|
|
82
|
+
return (0, clack_1.makeCodeSnippet)(true, (_unchanged, plus, _minus) => {
|
|
83
83
|
return plus(getSentryInitPlainTextSnippet(dsn));
|
|
84
84
|
});
|
|
85
85
|
}
|
|
@@ -107,7 +107,7 @@ function getMainAppFilePath() {
|
|
|
107
107
|
* This step should be executed after `addSentryInit`
|
|
108
108
|
*/
|
|
109
109
|
async function wrapRootComponent() {
|
|
110
|
-
const showInstructions = () => (0,
|
|
110
|
+
const showInstructions = () => (0, clack_1.showCopyPasteInstructions)('App.js or _layout.tsx', getSentryWrapColoredCodeSnippet());
|
|
111
111
|
const jsPath = getMainAppFilePath();
|
|
112
112
|
Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');
|
|
113
113
|
if (!jsPath) {
|
|
@@ -225,7 +225,7 @@ function doesContainSentryWrap(program) {
|
|
|
225
225
|
}
|
|
226
226
|
exports.doesContainSentryWrap = doesContainSentryWrap;
|
|
227
227
|
function getSentryWrapColoredCodeSnippet() {
|
|
228
|
-
return (0,
|
|
228
|
+
return (0, clack_1.makeCodeSnippet)(true, (_unchanged, plus, _minus) => {
|
|
229
229
|
return plus(`import * as Sentry from '@sentry/react-native';
|
|
230
230
|
|
|
231
231
|
export default Sentry.wrap(App);`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../../src/react-native/javascript.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,yEAAyE;AACzE,6DAAmC;AACnC,kDAA0B;AAC1B,2CAA6B;AAC7B,iDAAmC;AACnC,uCAAyB;AACzB,qDAAuC;AAEvC,4CAAyC;AACzC,sDAG8B;AAC9B,iCAA6C;AAC7C,+DAAuD;AAEvD,4EAA4E;AAC5E,uCAAsE;AACtE,gDAAkC;AAE3B,KAAK,UAAU,aAAa,CAAC,EAAE,GAAG,EAAmB;IAC1D,MAAM,MAAM,GAAG,kBAAkB,EAAE,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IACpE,IAAI,CAAC,MAAM,EAAE;QACX,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,kGAAkG,CACnG,CAAC;QACF,MAAM,IAAA,uCAAyB,EAC7B,uBAAuB,EACvB,+BAA+B,CAAC,GAAG,CAAC,EACpC,yDAAyD,CAC1D,CAAC;QACF,OAAO;KACR;IACD,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;IAE5D,MAAM,EAAE,GAAG,EAA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;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AArBD,sDAqBC;AAED,SAAS,+BAA+B;IACtC,OAAO,IAAA,6BAAe,EAAC,IAAI,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QACxD,OAAO,IAAI,CAAC;;iCAEiB,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable max-lines */\n// @ts-ignore - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as path from 'path';\nimport * as process from 'process';\nimport * as fs from 'fs';\nimport * as Sentry from '@sentry/node';\n\nimport { traceStep } from '../telemetry';\nimport {\n makeCodeSnippet,\n showCopyPasteInstructions,\n} from '../utils/clack-utils';\nimport { getFirstMatchedPath } from './glob';\nimport { RN_SDK_PACKAGE } from './react-native-wizard';\n\n// @ts-ignore - magicast is ESM and TS complains about that. It works though\nimport { generateCode, ProxifiedModule, parseModule } from 'magicast';\nimport * as t from '@babel/types';\n\nexport async function addSentryInit({ dsn }: { dsn: string }) {\n const jsPath = getMainAppFilePath();\n Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');\n if (!jsPath) {\n clack.log.warn(\n `Could not find main App file. Place the following code snippet close to the Apps Root component.`,\n );\n await showCopyPasteInstructions(\n 'App.js or _layout.tsx',\n getSentryInitColoredCodeSnippet(dsn),\n 'This ensures the Sentry SDK is ready to capture errors.',\n );\n return;\n }\n const jsRelativePath = path.relative(process.cwd(), jsPath);\n\n const js = fs.readFileSync(jsPath, 'utf-8');\n const includesSentry = doesJsCodeIncludeSdkSentryImport(js, {\n sdkPackageName: RN_SDK_PACKAGE,\n });\n if (includesSentry) {\n Sentry.setTag('app-js-file-status', 'already-includes-sentry');\n clack.log.warn(\n `${chalk.cyan(\n jsRelativePath,\n )} already includes Sentry. We wont't add it again.`,\n );\n return;\n }\n\n traceStep('add-sentry-init', () => {\n const newContent = addSentryInitWithSdkImport(js, { dsn });\n\n clack.log.success(\n `Added ${chalk.cyan('Sentry.init')} to ${chalk.cyan(jsRelativePath)}.`,\n );\n\n fs.writeFileSync(jsPath, newContent, 'utf-8');\n });\n\n Sentry.setTag('app-js-file-status', 'added-sentry-init');\n clack.log.success(\n chalk.green(`${chalk.cyan(jsRelativePath)} changes saved.`),\n );\n}\n\nexport function addSentryInitWithSdkImport(\n js: string,\n { dsn }: { dsn: string },\n): string {\n return js.replace(\n /^([^]*)(import\\s+[^;]*?;$)/m,\n (match: string) => `${match}\n${getSentryInitPlainTextSnippet(dsn)}`,\n );\n}\n\nexport function doesJsCodeIncludeSdkSentryImport(\n js: string,\n { sdkPackageName }: { sdkPackageName: string },\n): boolean {\n return !!js.match(sdkPackageName);\n}\n\nexport function getSentryInitColoredCodeSnippet(dsn: string) {\n return makeCodeSnippet(true, (_unchanged, plus, _minus) => {\n return plus(getSentryInitPlainTextSnippet(dsn));\n });\n}\n\nexport function getSentryInitPlainTextSnippet(dsn: string) {\n return `import * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: '${dsn}',\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: __DEV__,\n});`;\n}\n\nfunction getMainAppFilePath(): string | undefined {\n const prefixGlob = '{.,./src,./app}';\n const suffixGlob = '@(j|t|cj|mj)s?(x)';\n const universalGlob = `@(App|_layout).${suffixGlob}`;\n const jsFileGlob = `${prefixGlob}/+(${universalGlob})`;\n const jsPath = traceStep('find-app-js-file', () =>\n getFirstMatchedPath(jsFileGlob),\n );\n return jsPath;\n}\n\n/**\n * This step should be executed after `addSentryInit`\n */\nexport async function wrapRootComponent() {\n const showInstructions = () =>\n showCopyPasteInstructions(\n 'App.js or _layout.tsx',\n getSentryWrapColoredCodeSnippet(),\n );\n\n const jsPath = getMainAppFilePath();\n Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');\n if (!jsPath) {\n clack.log.warn(\n `Could not find main App file. Please wrap your App's Root component.`,\n );\n await showInstructions();\n return;\n }\n\n const jsRelativePath = path.relative(process.cwd(), jsPath);\n\n const js = fs.readFileSync(jsPath, 'utf-8');\n\n const mod = parseModule(js);\n const result = checkAndWrapRootComponent(mod);\n\n if (result === SentryWrapResult.AlreadyWrapped) {\n Sentry.setTag('app-js-file-status', 'already-includes-sentry-wrap');\n clack.log.warn(\n `${chalk.cyan(\n jsRelativePath,\n )} already includes Sentry.wrap. We wont't add it again.`,\n );\n return;\n }\n\n if (result === SentryWrapResult.NotFound) {\n clack.log.warn(\n `Could not find your App's Root component. Please wrap your App's Root component manually.`,\n );\n await showInstructions();\n return;\n }\n\n traceStep('add-sentry-wrap', () => {\n clack.log.success(\n `Added ${chalk.cyan('Sentry.wrap')} to ${chalk.cyan(jsRelativePath)}.`,\n );\n\n fs.writeFileSync(jsPath, generateCode(mod.$ast).code, 'utf-8');\n });\n\n Sentry.setTag('app-js-file-status', 'added-sentry-wrap');\n clack.log.success(\n chalk.green(`${chalk.cyan(jsRelativePath)} changes saved.`),\n );\n}\n\nexport enum SentryWrapResult {\n NotFound = 'RootComponentNotFound',\n AlreadyWrapped = 'AlreadyWrapped',\n Success = 'Success',\n}\n\nexport function checkAndWrapRootComponent(\n mod: ProxifiedModule,\n): SentryWrapResult {\n if (doesContainSentryWrap(mod.$ast as t.Program)) {\n return SentryWrapResult.AlreadyWrapped;\n }\n\n const defaultExport = getDefaultExport(mod.$ast as t.Program);\n if (!defaultExport) {\n return SentryWrapResult.NotFound;\n }\n\n const wrappedConfig = wrapWithSentry(defaultExport);\n\n const replacedDefaultExport = replaceDefaultExport(\n mod.$ast as t.Program,\n wrappedConfig,\n );\n\n if (!replacedDefaultExport) {\n return SentryWrapResult.NotFound;\n }\n\n return SentryWrapResult.Success;\n}\n\nexport function getDefaultExport(\n program: t.Program,\n):\n | t.Identifier\n | t.CallExpression\n | t.ObjectExpression\n | t.FunctionDeclaration\n | t.ArrowFunctionExpression\n | t.ClassDeclaration\n | undefined {\n for (const node of program.body) {\n if (\n t.isExportDefaultDeclaration(node) &&\n (t.isIdentifier(node.declaration) ||\n t.isCallExpression(node.declaration) ||\n t.isObjectExpression(node.declaration) ||\n t.isFunctionDeclaration(node.declaration) ||\n t.isArrowFunctionExpression(node.declaration) ||\n t.isClassDeclaration(node.declaration))\n ) {\n Sentry.setTag('app-js-file-status', 'default-export');\n return node.declaration;\n }\n }\n\n Sentry.setTag('app-js-file-status', 'default-export-not-found');\n return undefined;\n}\n\nexport function wrapWithSentry(\n configObj:\n | t.Identifier\n | t.CallExpression\n | t.ObjectExpression\n | t.FunctionDeclaration\n | t.ArrowFunctionExpression\n | t.ClassDeclaration,\n): t.CallExpression {\n if (t.isFunctionDeclaration(configObj)) {\n return t.callExpression(\n t.memberExpression(t.identifier('Sentry'), t.identifier('wrap')),\n [\n t.functionExpression(\n configObj.id,\n configObj.params,\n configObj.body,\n configObj.generator,\n configObj.async,\n ),\n ],\n );\n }\n\n if (t.isArrowFunctionExpression(configObj)) {\n return t.callExpression(\n t.memberExpression(t.identifier('Sentry'), t.identifier('wrap')),\n [configObj],\n );\n }\n\n if (t.isClassDeclaration(configObj)) {\n return t.callExpression(\n t.memberExpression(t.identifier('Sentry'), t.identifier('wrap')),\n [\n t.classExpression(\n configObj.id,\n configObj.superClass,\n configObj.body,\n configObj.decorators,\n ),\n ],\n );\n }\n\n return t.callExpression(\n t.memberExpression(t.identifier('Sentry'), t.identifier('wrap')),\n [configObj],\n );\n}\n\nexport function replaceDefaultExport(\n program: t.Program,\n wrappedDefaultExport: t.CallExpression,\n): boolean {\n for (const node of program.body) {\n if (t.isExportDefaultDeclaration(node)) {\n node.declaration = wrappedDefaultExport;\n return true;\n }\n }\n return false;\n}\n\nexport function doesContainSentryWrap(program: t.Program): boolean {\n for (const node of program.body) {\n if (t.isExportDefaultDeclaration(node)) {\n const declaration = node.declaration;\n if (t.isCallExpression(declaration)) {\n const callExpr = declaration;\n if (t.isMemberExpression(callExpr.callee)) {\n const callee = callExpr.callee;\n if (\n t.isIdentifier(callee.object) &&\n callee.object.name === 'Sentry' &&\n t.isIdentifier(callee.property) &&\n callee.property.name === 'wrap'\n ) {\n return true;\n }\n }\n }\n }\n }\n return false;\n}\n\nfunction getSentryWrapColoredCodeSnippet() {\n return makeCodeSnippet(true, (_unchanged, plus, _minus) => {\n return plus(`import * as Sentry from '@sentry/react-native';\n\nexport default Sentry.wrap(App);`);\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"javascript.js","sourceRoot":"","sources":["../../../src/react-native/javascript.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAA8B;AAC9B,+EAA+E;AAC/E,6DAAmC;AACnC,kDAA0B;AAC1B,2CAA6B;AAC7B,iDAAmC;AACnC,uCAAyB;AACzB,qDAAuC;AAEvC,4CAAyC;AACzC,0CAA4E;AAC5E,iCAA6C;AAC7C,+DAAuD;AAEvD,kFAAkF;AAClF,uCAAsE;AACtE,gDAAkC;AAE3B,KAAK,UAAU,aAAa,CAAC,EAAE,GAAG,EAAmB;IAC1D,MAAM,MAAM,GAAG,kBAAkB,EAAE,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IACpE,IAAI,CAAC,MAAM,EAAE;QACX,iBAAK,CAAC,GAAG,CAAC,IAAI,CACZ,kGAAkG,CACnG,CAAC;QACF,MAAM,IAAA,iCAAyB,EAC7B,uBAAuB,EACvB,+BAA+B,CAAC,GAAG,CAAC,EACpC,yDAAyD,CAC1D,CAAC;QACF,OAAO;KACR;IACD,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;IAE5D,MAAM,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,MAAM,cAAc,GAAG,gCAAgC,CAAC,EAAE,EAAE;QA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,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;QACxD,OAAO,IAAI,CAAC;;iCAEiB,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* eslint-disable max-lines */\n// @ts-expect-error - clack is ESM and TS complains about that. It works though\nimport clack from '@clack/prompts';\nimport chalk from 'chalk';\nimport * as path from 'path';\nimport * as process from 'process';\nimport * as fs from 'fs';\nimport * as Sentry from '@sentry/node';\n\nimport { traceStep } from '../telemetry';\nimport { makeCodeSnippet, showCopyPasteInstructions } from '../utils/clack';\nimport { getFirstMatchedPath } from './glob';\nimport { RN_SDK_PACKAGE } from './react-native-wizard';\n\n// @ts-expect-error - magicast is ESM and TS complains about that. It works though\nimport { generateCode, ProxifiedModule, parseModule } from 'magicast';\nimport * as t from '@babel/types';\n\nexport async function addSentryInit({ dsn }: { dsn: string }) {\n const jsPath = getMainAppFilePath();\n Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');\n if (!jsPath) {\n clack.log.warn(\n `Could not find main App file. Place the following code snippet close to the Apps Root component.`,\n );\n await showCopyPasteInstructions(\n 'App.js or _layout.tsx',\n getSentryInitColoredCodeSnippet(dsn),\n 'This ensures the Sentry SDK is ready to capture errors.',\n );\n return;\n }\n const jsRelativePath = path.relative(process.cwd(), jsPath);\n\n const js = fs.readFileSync(jsPath, 'utf-8');\n const includesSentry = doesJsCodeIncludeSdkSentryImport(js, {\n sdkPackageName: RN_SDK_PACKAGE,\n });\n if (includesSentry) {\n Sentry.setTag('app-js-file-status', 'already-includes-sentry');\n clack.log.warn(\n `${chalk.cyan(\n jsRelativePath,\n )} already includes Sentry. We wont't add it again.`,\n );\n return;\n }\n\n traceStep('add-sentry-init', () => {\n const newContent = addSentryInitWithSdkImport(js, { dsn });\n\n clack.log.success(\n `Added ${chalk.cyan('Sentry.init')} to ${chalk.cyan(jsRelativePath)}.`,\n );\n\n fs.writeFileSync(jsPath, newContent, 'utf-8');\n });\n\n Sentry.setTag('app-js-file-status', 'added-sentry-init');\n clack.log.success(\n chalk.green(`${chalk.cyan(jsRelativePath)} changes saved.`),\n );\n}\n\nexport function addSentryInitWithSdkImport(\n js: string,\n { dsn }: { dsn: string },\n): string {\n return js.replace(\n /^([^]*)(import\\s+[^;]*?;$)/m,\n (match: string) => `${match}\n${getSentryInitPlainTextSnippet(dsn)}`,\n );\n}\n\nexport function doesJsCodeIncludeSdkSentryImport(\n js: string,\n { sdkPackageName }: { sdkPackageName: string },\n): boolean {\n return !!js.match(sdkPackageName);\n}\n\nexport function getSentryInitColoredCodeSnippet(dsn: string) {\n return makeCodeSnippet(true, (_unchanged, plus, _minus) => {\n return plus(getSentryInitPlainTextSnippet(dsn));\n });\n}\n\nexport function getSentryInitPlainTextSnippet(dsn: string) {\n return `import * as Sentry from '@sentry/react-native';\n\nSentry.init({\n dsn: '${dsn}',\n\n // uncomment the line below to enable Spotlight (https://spotlightjs.com)\n // spotlight: __DEV__,\n});`;\n}\n\nfunction getMainAppFilePath(): string | undefined {\n const prefixGlob = '{.,./src,./app}';\n const suffixGlob = '@(j|t|cj|mj)s?(x)';\n const universalGlob = `@(App|_layout).${suffixGlob}`;\n const jsFileGlob = `${prefixGlob}/+(${universalGlob})`;\n const jsPath = traceStep('find-app-js-file', () =>\n getFirstMatchedPath(jsFileGlob),\n );\n return jsPath;\n}\n\n/**\n * This step should be executed after `addSentryInit`\n */\nexport async function wrapRootComponent() {\n const showInstructions = () =>\n showCopyPasteInstructions(\n 'App.js or _layout.tsx',\n getSentryWrapColoredCodeSnippet(),\n );\n\n const jsPath = getMainAppFilePath();\n Sentry.setTag('app-js-file-status', jsPath ? 'found' : 'not-found');\n if (!jsPath) {\n clack.log.warn(\n `Could not find main App file. Please wrap your App's Root component.`,\n );\n await showInstructions();\n return;\n }\n\n const jsRelativePath = path.relative(process.cwd(), jsPath);\n\n const js = fs.readFileSync(jsPath, 'utf-8');\n\n const mod = parseModule(js);\n const result = checkAndWrapRootComponent(mod);\n\n if (result === SentryWrapResult.AlreadyWrapped) {\n Sentry.setTag('app-js-file-status', 'already-includes-sentry-wrap');\n clack.log.warn(\n `${chalk.cyan(\n jsRelativePath,\n )} already includes Sentry.wrap. We wont't add it again.`,\n );\n return;\n }\n\n if (result === SentryWrapResult.NotFound) {\n clack.log.warn(\n `Could not find your App's Root component. Please wrap your App's Root component manually.`,\n );\n await showInstructions();\n return;\n }\n\n traceStep('add-sentry-wrap', () => {\n clack.log.success(\n `Added ${chalk.cyan('Sentry.wrap')} to ${chalk.cyan(jsRelativePath)}.`,\n );\n\n fs.writeFileSync(jsPath, generateCode(mod.$ast).code, 'utf-8');\n });\n\n Sentry.setTag('app-js-file-status', 'added-sentry-wrap');\n clack.log.success(\n chalk.green(`${chalk.cyan(jsRelativePath)} changes saved.`),\n );\n}\n\nexport enum SentryWrapResult {\n NotFound = 'RootComponentNotFound',\n AlreadyWrapped = 'AlreadyWrapped',\n Success = 'Success',\n}\n\nexport function checkAndWrapRootComponent(\n mod: ProxifiedModule,\n): SentryWrapResult {\n if (doesContainSentryWrap(mod.$ast as t.Program)) {\n return SentryWrapResult.AlreadyWrapped;\n }\n\n const defaultExport = getDefaultExport(mod.$ast as t.Program);\n if (!defaultExport) {\n return SentryWrapResult.NotFound;\n }\n\n const wrappedConfig = wrapWithSentry(defaultExport);\n\n const replacedDefaultExport = replaceDefaultExport(\n mod.$ast as t.Program,\n wrappedConfig,\n );\n\n if (!replacedDefaultExport) {\n return SentryWrapResult.NotFound;\n }\n\n return SentryWrapResult.Success;\n}\n\nexport function getDefaultExport(\n program: t.Program,\n):\n | t.Identifier\n | t.CallExpression\n | t.ObjectExpression\n | t.FunctionDeclaration\n | t.ArrowFunctionExpression\n | t.ClassDeclaration\n | undefined {\n for (const node of program.body) {\n if (\n t.isExportDefaultDeclaration(node) &&\n (t.isIdentifier(node.declaration) ||\n t.isCallExpression(node.declaration) ||\n t.isObjectExpression(node.declaration) ||\n t.isFunctionDeclaration(node.declaration) ||\n t.isArrowFunctionExpression(node.declaration) ||\n t.isClassDeclaration(node.declaration))\n ) {\n Sentry.setTag('app-js-file-status', 'default-export');\n return node.declaration;\n }\n }\n\n Sentry.setTag('app-js-file-status', 'default-export-not-found');\n return undefined;\n}\n\nexport function wrapWithSentry(\n configObj:\n | t.Identifier\n | t.CallExpression\n | t.ObjectExpression\n | t.FunctionDeclaration\n | t.ArrowFunctionExpression\n | t.ClassDeclaration,\n): t.CallExpression {\n if (t.isFunctionDeclaration(configObj)) {\n return t.callExpression(\n t.memberExpression(t.identifier('Sentry'), t.identifier('wrap')),\n [\n t.functionExpression(\n configObj.id,\n configObj.params,\n configObj.body,\n configObj.generator,\n configObj.async,\n ),\n ],\n );\n }\n\n if (t.isArrowFunctionExpression(configObj)) {\n return t.callExpression(\n t.memberExpression(t.identifier('Sentry'), t.identifier('wrap')),\n [configObj],\n );\n }\n\n if (t.isClassDeclaration(configObj)) {\n return t.callExpression(\n t.memberExpression(t.identifier('Sentry'), t.identifier('wrap')),\n [\n t.classExpression(\n configObj.id,\n configObj.superClass,\n configObj.body,\n configObj.decorators,\n ),\n ],\n );\n }\n\n return t.callExpression(\n t.memberExpression(t.identifier('Sentry'), t.identifier('wrap')),\n [configObj],\n );\n}\n\nexport function replaceDefaultExport(\n program: t.Program,\n wrappedDefaultExport: t.CallExpression,\n): boolean {\n for (const node of program.body) {\n if (t.isExportDefaultDeclaration(node)) {\n node.declaration = wrappedDefaultExport;\n return true;\n }\n }\n return false;\n}\n\nexport function doesContainSentryWrap(program: t.Program): boolean {\n for (const node of program.body) {\n if (t.isExportDefaultDeclaration(node)) {\n const declaration = node.declaration;\n if (t.isCallExpression(declaration)) {\n const callExpr = declaration;\n if (t.isMemberExpression(callExpr.callee)) {\n const callee = callExpr.callee;\n if (\n t.isIdentifier(callee.object) &&\n callee.object.name === 'Sentry' &&\n t.isIdentifier(callee.property) &&\n callee.property.name === 'wrap'\n ) {\n return true;\n }\n }\n }\n }\n }\n return false;\n}\n\nfunction getSentryWrapColoredCodeSnippet() {\n return makeCodeSnippet(true, (_unchanged, plus, _minus) => {\n return plus(`import * as Sentry from '@sentry/react-native';\n\nexport default Sentry.wrap(App);`);\n });\n}\n"]}
|
|
@@ -27,21 +27,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.getModuleExportsAssignmentRight = exports.getMetroConfigObject = exports.addSentryMetroRequireToMetroConfig = exports.addSentrySerializerRequireToMetroConfig = exports.addSentrySerializerToMetroConfig = exports.writeMetroConfig = exports.parseMetroConfig = exports.removeSentryRequire = exports.removeSentrySerializerFromMetroConfig = exports.unPatchMetroConfig = exports.patchMetroConfigWithSentrySerializer = exports.patchMetroWithSentryConfigInMemory = exports.patchMetroWithSentryConfig = exports.metroConfigPath = void 0;
|
|
30
|
-
// @ts-
|
|
30
|
+
// @ts-expect-error - clack is ESM and TS complains about that. It works though
|
|
31
31
|
const clack = __importStar(require("@clack/prompts"));
|
|
32
|
-
// @ts-
|
|
32
|
+
// @ts-expect-error - magicast is ESM and TS complains about that. It works though
|
|
33
33
|
const magicast_1 = require("magicast");
|
|
34
34
|
const fs = __importStar(require("fs"));
|
|
35
35
|
const Sentry = __importStar(require("@sentry/node"));
|
|
36
36
|
const ast_utils_1 = require("../utils/ast-utils");
|
|
37
|
-
const
|
|
37
|
+
const clack_1 = require("../utils/clack");
|
|
38
38
|
const recast = __importStar(require("recast"));
|
|
39
39
|
const chalk_1 = __importDefault(require("chalk"));
|
|
40
40
|
const b = recast.types.builders;
|
|
41
41
|
exports.metroConfigPath = 'metro.config.js';
|
|
42
42
|
async function patchMetroWithSentryConfig() {
|
|
43
43
|
const mod = await parseMetroConfig();
|
|
44
|
-
const showInstructions = () => (0,
|
|
44
|
+
const showInstructions = () => (0, clack_1.showCopyPasteInstructions)(exports.metroConfigPath, getMetroWithSentryConfigSnippet(true));
|
|
45
45
|
const success = await patchMetroWithSentryConfigInMemory(mod, showInstructions);
|
|
46
46
|
if (!success) {
|
|
47
47
|
return;
|
|
@@ -89,7 +89,7 @@ async function patchMetroWithSentryConfigInMemory(mod, showInstructions) {
|
|
|
89
89
|
exports.patchMetroWithSentryConfigInMemory = patchMetroWithSentryConfigInMemory;
|
|
90
90
|
async function patchMetroConfigWithSentrySerializer() {
|
|
91
91
|
const mod = await parseMetroConfig();
|
|
92
|
-
const showInstructions = () => (0,
|
|
92
|
+
const showInstructions = () => (0, clack_1.showCopyPasteInstructions)(exports.metroConfigPath, getMetroSentrySerializerSnippet(true));
|
|
93
93
|
if ((0, ast_utils_1.hasSentryContent)(mod.$ast)) {
|
|
94
94
|
const shouldContinue = await confirmPathMetroConfig();
|
|
95
95
|
if (!shouldContinue) {
|
|
@@ -324,7 +324,7 @@ function createSentryMetroRequire() {
|
|
|
324
324
|
]);
|
|
325
325
|
}
|
|
326
326
|
async function confirmPathMetroConfig() {
|
|
327
|
-
const shouldContinue = await (0,
|
|
327
|
+
const shouldContinue = await (0, clack_1.abortIfCancelled)(clack.select({
|
|
328
328
|
message: `Metro Config already contains Sentry-related code. Should the wizard modify it anyway?`,
|
|
329
329
|
options: [
|
|
330
330
|
{
|
|
@@ -405,7 +405,7 @@ function getModuleExports(program) {
|
|
|
405
405
|
});
|
|
406
406
|
}
|
|
407
407
|
function getMetroSentrySerializerSnippet(colors) {
|
|
408
|
-
return (0,
|
|
408
|
+
return (0, clack_1.makeCodeSnippet)(colors, (unchanged, plus, _) => unchanged(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');";
|
|
409
409
|
${plus("const {createSentryMetroSerializer} = require('@sentry/react-native/dist/js/tools/sentryMetroSerializer');")}
|
|
410
410
|
|
|
411
411
|
const config = {
|
|
@@ -418,7 +418,7 @@ module.exports = mergeConfig(getDefaultConfig(__dirname), config);
|
|
|
418
418
|
`));
|
|
419
419
|
}
|
|
420
420
|
function getMetroWithSentryConfigSnippet(colors) {
|
|
421
|
-
return (0,
|
|
421
|
+
return (0, clack_1.makeCodeSnippet)(colors, (unchanged, plus, _) => unchanged(`const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');";
|
|
422
422
|
${plus("const {withSentryConfig} = require('@sentry/react-native/metro');")}
|
|
423
423
|
|
|
424
424
|
const config = {};
|