MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / selectProjectChoice

Function selectProjectChoice

src/cli/commands/setup.ts:453–495  ·  view source on GitHub ↗
(opts: {
  cwd: string;
  existingProjectPath?: string;
  existingWorkspacePath?: string;
  fs: FileSystemExecutor;
  prompter: Prompter;
  isTTY: boolean;
  quietOutput: boolean;
})

Source from the content-addressed store, hash-verified

451type ProjectChoice = { kind: 'workspace' | 'project'; absolutePath: string };
452
453async function selectProjectChoice(opts: {
454 cwd: string;
455 existingProjectPath?: string;
456 existingWorkspacePath?: string;
457 fs: FileSystemExecutor;
458 prompter: Prompter;
459 isTTY: boolean;
460 quietOutput: boolean;
461}): Promise<ProjectChoice> {
462 const discovered = await withSpinner({
463 isTTY: opts.isTTY,
464 quietOutput: opts.quietOutput,
465 startMessage: 'Discovering projects...',
466 stopMessage: 'Projects discovered.',
467 task: () => discoverProjects({ workspaceRoot: opts.cwd }, opts.fs),
468 });
469 const choices: ProjectChoice[] = [
470 ...discovered.workspaces.map((absolutePath) => ({ kind: 'workspace' as const, absolutePath })),
471 ...discovered.projects.map((absolutePath) => ({ kind: 'project' as const, absolutePath })),
472 ];
473
474 if (choices.length === 0) {
475 throw new Error('No Xcode project or workspace files were discovered.');
476 }
477
478 const defaultPath = opts.existingWorkspacePath ?? opts.existingProjectPath;
479 const defaultIndex = choices.findIndex((choice) => choice.absolutePath === defaultPath);
480
481 const projectOptions: SelectOption<ProjectChoice>[] = choices.map((choice) => ({
482 value: choice,
483 label: `${choice.kind === 'workspace' ? 'Workspace' : 'Project'}: ${relativePathOrAbsolute(choice.absolutePath, opts.cwd)}`,
484 }));
485
486 showPromptHelp(
487 'Select a project or workspace to set the default path used by build and run commands.',
488 opts.quietOutput,
489 );
490 return opts.prompter.selectOne({
491 message: 'Select a project or workspace',
492 options: projectOptions,
493 initialIndex: defaultIndex >= 0 ? defaultIndex : 0,
494 });
495}
496
497async function selectScheme(opts: {
498 projectChoice: ProjectChoice;

Callers 1

collectSetupSelectionFunction · 0.85

Calls 5

discoverProjectsFunction · 0.90
withSpinnerFunction · 0.85
relativePathOrAbsoluteFunction · 0.85
showPromptHelpFunction · 0.85
selectOneMethod · 0.80

Tested by

no test coverage detected