(opts: {
existingDeviceId?: string;
fs: FileSystemExecutor;
executor: CommandExecutor;
prompter: Prompter;
isTTY: boolean;
quietOutput: boolean;
})
| 798 | } |
| 799 | |
| 800 | async function selectDevice(opts: { |
| 801 | existingDeviceId?: string; |
| 802 | fs: FileSystemExecutor; |
| 803 | executor: CommandExecutor; |
| 804 | prompter: Prompter; |
| 805 | isTTY: boolean; |
| 806 | quietOutput: boolean; |
| 807 | }): Promise<SetupDevice | null> { |
| 808 | const devices = await withSpinner({ |
| 809 | isTTY: opts.isTTY, |
| 810 | quietOutput: opts.quietOutput, |
| 811 | startMessage: 'Loading devices...', |
| 812 | stopMessage: 'Devices loaded.', |
| 813 | task: () => listAvailableDevices(opts.fs, opts.executor), |
| 814 | }); |
| 815 | |
| 816 | const defaultIndex = |
| 817 | devices.length > 0 ? getDefaultDeviceIndex(devices, opts.existingDeviceId) : 0; |
| 818 | |
| 819 | showPromptHelp( |
| 820 | 'Select a device to set the default target used by physical-device commands.', |
| 821 | opts.quietOutput, |
| 822 | ); |
| 823 | return opts.prompter.selectOne({ |
| 824 | message: 'Select a device', |
| 825 | options: [ |
| 826 | { |
| 827 | value: null, |
| 828 | label: 'No default device', |
| 829 | description: 'Leave device commands unpinned during setup.', |
| 830 | }, |
| 831 | ...devices.map((device) => ({ |
| 832 | value: device, |
| 833 | label: `${device.platform} — ${device.name} (${device.udid})`, |
| 834 | })), |
| 835 | ], |
| 836 | initialIndex: devices.length > 0 && opts.existingDeviceId != null ? defaultIndex + 1 : 0, |
| 837 | }); |
| 838 | } |
| 839 | |
| 840 | async function ensureSetupPrerequisites(opts: { |
| 841 | executor: CommandExecutor; |
no test coverage detected