@sentry/wizard
Version:
Sentry wizard helping you to configure your project
92 lines • 4.07 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.runAppleWizard = void 0;
// @ts-expect-error - 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 telemetry_1 = require("../telemetry");
const clack_1 = require("../utils/clack");
const mcp_config_1 = require("../utils/clack/mcp-config");
const check_installed_cli_1 = require("./check-installed-cli");
const configure_fastlane_1 = require("./configure-fastlane");
const configure_package_manager_1 = require("./configure-package-manager");
const configure_sentry_cli_1 = require("./configure-sentry-cli");
const configure_xcode_project_1 = require("./configure-xcode-project");
const inject_code_snippet_1 = require("./inject-code-snippet");
const lookup_xcode_project_1 = require("./lookup-xcode-project");
async function runAppleWizard(options) {
return (0, telemetry_1.withTelemetry)({
enabled: options.telemetryEnabled,
integration: 'ios',
wizardOptions: options,
}, () => runAppleWizardWithTelementry(options));
}
exports.runAppleWizard = runAppleWizard;
async function runAppleWizardWithTelementry(options) {
// Define options with defaults
const projectDir = options.projectDir ?? process.cwd();
// Step - Welcome Message
(0, clack_1.printWelcome)({
wizardName: 'Sentry Apple Wizard',
promoCode: options.promoCode,
});
// Step - Git Status Check
await (0, clack_1.confirmContinueIfNoOrDirtyGitRepo)({
ignoreGitChanges: options.ignoreGitChanges,
cwd: projectDir,
});
// Step - Sentry CLI Check
await (0, check_installed_cli_1.checkInstalledCLI)();
// Step - Xcode Project Lookup
// This step should be run before the Sentry Project and API Key step
// because it can abort the wizard if no Xcode project is found.
const { xcProject, target } = await (0, lookup_xcode_project_1.lookupXcodeProject)({
projectDir,
});
// Step - Sentry Project and API Key
const { selectedProject, authToken } = await (0, clack_1.getOrAskForProjectData)(options, 'apple-ios');
// Step - Sentry CLI Configuration Setup
(0, configure_sentry_cli_1.configureSentryCLI)({
projectDir,
authToken: authToken,
});
// Step - Set up Package Manager
const { shouldUseSPM } = await (0, configure_package_manager_1.configurePackageManager)({
projectDir,
});
// Step - Configure Xcode Project
(0, configure_xcode_project_1.configureXcodeProject)({
xcProject,
project: selectedProject,
target,
shouldUseSPM,
});
// Step - Feature Selection
const selectedFeatures = await (0, clack_1.featureSelectionPrompt)([
{
id: 'logs',
prompt: `Do you want to enable ${chalk_1.default.bold('Logs')} to send your application logs to Sentry?`,
enabledHint: 'optional',
},
]);
// Step - Add Code Snippet
(0, inject_code_snippet_1.injectCodeSnippet)({
project: xcProject,
target,
dsn: selectedProject.keys[0].dsn.public,
enableLogs: selectedFeatures.logs ?? false,
});
// Step - Fastlane Configuration
await (0, configure_fastlane_1.configureFastlane)({
projectDir,
orgSlug: selectedProject.organization.slug,
projectSlug: selectedProject.slug,
});
// Offer optional project-scoped MCP config for Sentry with org and project scope
await (0, mcp_config_1.offerProjectScopedMcpConfig)(selectedProject.organization.slug, selectedProject.slug);
prompts_1.default.log.success('Sentry was successfully added to your project! Run your project to send your first event to Sentry. Go to Sentry.io to see whether everything is working fine.');
}
//# sourceMappingURL=apple-wizard.js.map
;