@sentry/wizard
Version:
Sentry wizard helping you to configure your project
68 lines • 3.89 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.configurePackageManager = void 0;
// @ts-expect-error - clack is ESM and TS complains about that. It works though
const prompts_1 = __importDefault(require("@clack/prompts"));
const Sentry = __importStar(require("@sentry/node"));
const chalk_1 = __importDefault(require("chalk"));
const telemetry_1 = require("../telemetry");
const clack_1 = require("../utils/clack");
const debug_1 = require("../utils/debug");
const cocoapod = __importStar(require("./cocoapod"));
async function configurePackageManager({ projectDir, }) {
(0, debug_1.debug)(`Checking if CocoaPods is installed at path: ${chalk_1.default.cyan(projectDir)}`);
// Xcode ships with the Swift Package Manager and potentially using CocoaPods.
// We need to check if the user has CocoaPods set up.
let shouldUseSPM = true;
const isCocoaPodsAvailable = cocoapod.usesCocoaPod(projectDir);
Sentry.setTag('cocoapod-exists', isCocoaPodsAvailable);
(0, debug_1.debug)(`CocoaPods is ${isCocoaPodsAvailable ? 'installed' : 'not installed'}`);
if (isCocoaPodsAvailable) {
// If the user has CocoaPods installed, we need to ask them which package manager they want to use.
// Otherwise, we can just use the Swift Package Manager.
(0, debug_1.debug)('Asking user to choose a package manager');
const pm = (await (0, telemetry_1.traceStep)('Choose a package manager', () => (0, clack_1.askForItemSelection)(['Swift Package Manager', 'CocoaPods'], 'Which package manager would you like to use to add Sentry?'))).value;
(0, debug_1.debug)(`User chose package manager: ${chalk_1.default.cyan(pm)}`);
shouldUseSPM = pm === 'Swift Package Manager';
if (!shouldUseSPM) {
(0, debug_1.debug)('Adding CocoaPods reference');
const podAdded = await (0, telemetry_1.traceStep)('Add CocoaPods reference', () => cocoapod.addCocoaPods(projectDir));
Sentry.setTag('cocoapod-added', podAdded);
(0, debug_1.debug)(`CocoaPods reference added: ${chalk_1.default.cyan(podAdded.toString())}`);
if (!podAdded) {
prompts_1.default.log.warn("Could not add Sentry pod to your Podfile. You'll have to add it manually.\nPlease follow the instructions at https://docs.sentry.io/platforms/apple/guides/ios/#install");
}
}
}
(0, debug_1.debug)(`Should use SPM: ${chalk_1.default.cyan(shouldUseSPM.toString())}`);
Sentry.setTag('package-manager', shouldUseSPM ? 'SPM' : 'cocoapods');
return { shouldUseSPM };
}
exports.configurePackageManager = configurePackageManager;
//# sourceMappingURL=configure-package-manager.js.map
;