-
Notifications
You must be signed in to change notification settings - Fork 935
feat: list available apple devices with run-ios --list-devices
#1676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
adamTrz
merged 10 commits into
react-native-community:main
from
esthor:list-available-apple-devices
Jan 25, 2023
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3565c87
get basic listing of device names working
esthor 46e9e27
get a nice selector prompt going
esthor 968ea14
tidy up the selector
esthor 5e6ce9f
connect list-devices to run-ios command
adamTrz 8b44d0c
Merge remote-tracking branch 'origin/main' into list-available-apple-…
adamTrz 1178446
fix TS error
adamTrz a8d3e97
Update packages/cli-platform-ios/src/commands/runIOS/index.ts
adamTrz 2e97b19
code review fixes
adamTrz b600c03
Merge branch 'list-available-apple-devices' of github.com:esthor/cli …
adamTrz a6d8c42
Merge remote-tracking branch 'origin/main' into list-available-apple-…
adamTrz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/cli-platform-ios/src/commands/runIOS/listIOSDevices.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import {Device} from '../../types'; | ||
| import parseIOSDevicesList from './parseIOSDevicesList'; | ||
| import parseXctraceIOSDevicesList from './parseXctraceIOSDevicesList'; | ||
| import execa from 'execa'; | ||
| import {logger} from '@react-native-community/cli-tools'; | ||
| import prompts from 'prompts'; | ||
| import chalk from 'chalk'; | ||
|
|
||
| export async function promptForDeviceSelection( | ||
| availableDevices: Device[], | ||
| ): Promise<Device | undefined> { | ||
| const {device} = await prompts({ | ||
| type: 'select', | ||
| name: 'device', | ||
| message: 'Select the device you want to use', | ||
| choices: availableDevices | ||
| .filter((d) => d.type === 'device' || d.type === 'simulator') | ||
| .map((d) => ({ | ||
| title: `${chalk.bold(d.name)}`, | ||
| value: d, | ||
| })), | ||
| min: 1, | ||
| }); | ||
| return device; | ||
| } | ||
|
|
||
| async function listIOSDevices(): Promise<Device[]> { | ||
| let devices; | ||
| try { | ||
| const out = execa.sync('xcrun', ['xctrace', 'list', 'devices']); | ||
| devices = parseXctraceIOSDevicesList( | ||
| // Xcode 12.5 introduced a change to output the list to stdout instead of stderr | ||
| out.stderr === '' ? out.stdout : out.stderr, | ||
| ); | ||
| } catch (e) { | ||
| logger.warn( | ||
| 'Support for Xcode 11 and older is deprecated. Please upgrade to Xcode 12.', | ||
| ); | ||
| devices = parseIOSDevicesList( | ||
| execa.sync('xcrun', ['instruments', '-s']).stdout, | ||
| ); | ||
| } | ||
| return devices; | ||
| } | ||
|
|
||
| export default listIOSDevices; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.