(opts: {
existingSimulatorId?: string;
existingSimulatorName?: string;
platformFilter: SetupPlatform[];
executor: CommandExecutor;
prompter: Prompter;
isTTY: boolean;
quietOutput: boolean;
})
| 557 | } |
| 558 | |
| 559 | async function selectSimulator(opts: { |
| 560 | existingSimulatorId?: string; |
| 561 | existingSimulatorName?: string; |
| 562 | platformFilter: SetupPlatform[]; |
| 563 | executor: CommandExecutor; |
| 564 | prompter: Prompter; |
| 565 | isTTY: boolean; |
| 566 | quietOutput: boolean; |
| 567 | }): Promise<ListedSimulator | null> { |
| 568 | const allSimulators = await withSpinner({ |
| 569 | isTTY: opts.isTTY, |
| 570 | quietOutput: opts.quietOutput, |
| 571 | startMessage: 'Loading simulators...', |
| 572 | stopMessage: 'Simulators loaded.', |
| 573 | task: async () => { |
| 574 | try { |
| 575 | return await listSimulators(opts.executor); |
| 576 | } catch { |
| 577 | return []; |
| 578 | } |
| 579 | }, |
| 580 | }); |
| 581 | const simulators = filterSimulatorsByPlatforms(allSimulators, opts.platformFilter); |
| 582 | |
| 583 | const defaultIndex = |
| 584 | simulators.length > 0 |
| 585 | ? getDefaultSimulatorIndex(simulators, opts.existingSimulatorId, opts.existingSimulatorName) |
| 586 | : 0; |
| 587 | |
| 588 | showPromptHelp( |
| 589 | 'Select a simulator to set the default device target used by simulator commands.', |
| 590 | opts.quietOutput, |
| 591 | ); |
| 592 | return opts.prompter.selectOne({ |
| 593 | message: 'Select a simulator', |
| 594 | options: [ |
| 595 | { |
| 596 | value: null, |
| 597 | label: 'No default simulator', |
| 598 | description: 'Leave simulator commands unpinned during setup.', |
| 599 | }, |
| 600 | ...simulators.map((simulator) => ({ |
| 601 | value: simulator, |
| 602 | label: `${simulator.runtime} — ${simulator.name} (${simulator.udid})`, |
| 603 | description: simulator.state, |
| 604 | })), |
| 605 | ], |
| 606 | initialIndex: |
| 607 | simulators.length > 0 && (opts.existingSimulatorId ?? opts.existingSimulatorName) != null |
| 608 | ? defaultIndex + 1 |
| 609 | : 0, |
| 610 | }); |
| 611 | } |
| 612 | |
| 613 | function requiresSimulatorDefault(enabledWorkflows: string[]): boolean { |
| 614 | return enabledWorkflows.some((workflowId) => SIMULATOR_DEFAULT_WORKFLOWS.has(workflowId)); |
no test coverage detected