@sentry/wizard
Version:
Sentry wizard helping you to configure your project
91 lines (89 loc) • 4.63 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.runReactNativeUninstall = void 0;
const fs = __importStar(require("fs"));
// @ts-ignore - clack is ESM and TS complains about that. It works though
const prompts_1 = __importDefault(require("@clack/prompts"));
const chalk_1 = __importDefault(require("chalk"));
const clack_utils_1 = require("../utils/clack-utils");
const xcode_1 = require("./xcode");
const glob_1 = require("./glob");
const gradle_1 = require("./gradle");
const metro_1 = require("./metro");
const xcode_2 = __importDefault(require("xcode"));
async function runReactNativeUninstall(options) {
(0, clack_utils_1.printWelcome)({
wizardName: 'Sentry React Native Uninstall Wizard',
message: 'This wizard will remove Sentry from your React Native project.',
telemetryEnabled: options.telemetryEnabled,
});
await (0, clack_utils_1.confirmContinueIfNoOrDirtyGitRepo)();
await (0, metro_1.unPatchMetroConfig)();
unPatchXcodeFiles();
unPatchAndroidFiles();
prompts_1.default.note(`To make sure your project builds after removing Sentry please run:
1. ${chalk_1.default.bold('yarn remove @sentry/react-native')}
2. ${chalk_1.default.bold('cd ios && pod install')}
3. Remove all occurrences of ${chalk_1.default.bold('@sentry/react-native')} from your application code.`);
prompts_1.default.outro(`${chalk_1.default.green('Uninstall is done!')}
${chalk_1.default.dim('If you encounter any issues, let us know here: https://github.com/getsentry/sentry-react-native/issues')}`);
}
exports.runReactNativeUninstall = runReactNativeUninstall;
function unPatchXcodeFiles() {
const xcodeProjectPath = (0, glob_1.getFirstMatchedPath)(glob_1.XCODE_PROJECT);
if (!xcodeProjectPath) {
prompts_1.default.log.warn(`Could not find Xcode project file using ${chalk_1.default.bold(glob_1.XCODE_PROJECT)}.`);
return;
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
const xcodeProject = xcode_2.default.project(xcodeProjectPath);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
xcodeProject.parseSync();
const buildPhases = (0, xcode_1.getValidExistingBuildPhases)(xcodeProject);
const bundlePhase = (0, xcode_1.findBundlePhase)(buildPhases);
(0, xcode_1.unPatchBundlePhase)(bundlePhase);
(0, xcode_1.unPatchDebugFilesUploadPhase)(xcodeProject);
(0, xcode_1.writeXcodeProject)(xcodeProjectPath, xcodeProject);
}
function unPatchAndroidFiles() {
const appBuildGradlePath = (0, glob_1.getFirstMatchedPath)(glob_1.APP_BUILD_GRADLE);
if (!appBuildGradlePath) {
prompts_1.default.log.warn(`Could not find Android app/build.gradle file using ${chalk_1.default.bold(glob_1.APP_BUILD_GRADLE)}.`);
return;
}
const appBuildGradle = fs.readFileSync(appBuildGradlePath, 'utf-8');
const includesSentry = (0, gradle_1.doesAppBuildGradleIncludeRNSentryGradlePlugin)(appBuildGradle);
if (!includesSentry) {
prompts_1.default.log.warn(`Sentry not found in Android app/build.gradle.`);
return;
}
const patchedAppBuildGradle = (0, gradle_1.removeRNSentryGradlePlugin)(appBuildGradle);
(0, gradle_1.writeAppBuildGradle)(appBuildGradlePath, patchedAppBuildGradle);
}
//# sourceMappingURL=uninstall.js.map