run-android-on-specific-device#9568
Conversation
ab5ff96 to
36f98ea
Compare
|
@LearningDave updated the pull request - view changes |
|
@LearningDave updated the pull request - view changes |
|
Nice! This is useful. Looks like there is a lot of code in e.g.: Would it be possible to refactor the code? It looks like this PR adds some logic that's already in that file. nit: Instead of |
local-cli/runAndroid/runAndroid.js
Outdated
There was a problem hiding this comment.
Why Promise? Is the buildApk function async?
There was a problem hiding this comment.
Hi, thanks for the feedback.
i called it '--deviceIdFromList' because its not the actually device id. It is just the id created by adb. -> https://developer.android.com/studio/command-line/adb.html#commandsummary
However '--deviceId' might still be better, since it is easier to use.
I will do some refactoring and remove the promise on buildApk.
|
@LearningDave updated the pull request - view changes |
|
@mkonicek I've done some refactoring, changed the flag to '--deviceId' and removed the misplaced promise. |
local-cli/runAndroid/runAndroid.js
Outdated
There was a problem hiding this comment.
nit (wording): given device id (listed by running "adb devices" on the command line).
(no space after the last .)
|
Thanks for refactoring this @LearningDave. It's a useful feature, it'll take me a while to review since it's quite a bit of code. Have you run the test plan again after refactoring? |
local-cli/runAndroid/runAndroid.js
Outdated
local-cli/runAndroid/runAndroid.js
Outdated
There was a problem hiding this comment.
Could you call adb.getDevices rather than reimplement it here?
react-native/local-cli/runAndroid/adb.js
Line 38 in b9396cd
|
OK I did a basic review :) |
|
@LearningDave could you please rebase your branch against current master? thanks! |
|
@LearningDave are you still planning to ship this? |
Summary: New flag for the command 'run-android': --deviceIdFromList <deviceIdFromList> in order to install and launch apps on a specific device/simulator from the command line. <deviceIdFromList> is the id listed on the output of the command 'adb devices'
adc2301 to
1879a1c
Compare
| const fs = require('fs'); | ||
| const isPackagerRunning = require('../util/isPackagerRunning'); | ||
| const path = require('path'); | ||
| const isPackagerRunning = require('../util/isPackagerRunning'); |
| const path = require('path'); | ||
| const isPackagerRunning = require('../util/isPackagerRunning'); | ||
| const Promise = require('promise'); | ||
| const adb = require('./adb'); |
| adb.getDevices().map((device) => tryRunAdbReverse(device)); | ||
| console.log(chalk.bold( | ||
| 'Building the app...' | ||
| )); |
There was a problem hiding this comment.
This can be on single line.
| }); | ||
| } catch (e) { | ||
| console.log(chalk.red( | ||
| 'Could not build the app on the device, read the error above for details.\n' |
There was a problem hiding this comment.
We are not building the app on the device. We are either building the app, or installing it on device.
|
Just small nits, we can fix these as a followup. Thanks for working on this! @facebook-github-bot shipit |
|
@mkonicek has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
|
@LearningDave are you up for sending a small followup PR for fixing the small nits above? |
|
@LearningDave if you want I can take over the improvements PR - will ping you on mail too |
| command: '--flavor [string]', | ||
| description: '--flavor has been deprecated. Use --variant instead', | ||
| }, { | ||
| command: '--configuration [string]', |
There was a problem hiding this comment.
Why did you removed the configuration flag? This is a breaking change.
Summary: As mkonicek suggested in [#9568](#9568 (comment)) I did some cleanup **Test plan (required)** Only one functional change: > Run `react-native run-android --deviceId` Before it was beginning to build the app and then failing because of the missing device "true" :-) Now it's showing a message and stopping the build: ``` ❯ react-native run-android --deviceId Starting JS server... Parameter missing (device id) ``` Closes #11703 Differential Revision: D4376615 Pulled By: ericvicenti fbshipit-source-id: 3c6e0f12220ab22539c7bc3d390367e02c96728a
Summary: At the moment the run-android command from the react-native cli does run all available devices at once. However it would be extreme useful to have the option to choose only one specific device/simulator. Therefore i've created a new flag for the command 'run-android': --deviceIdFromList 'deviceIdFromList' in order to install and launch apps on a specific device/simulator from the command line. 'deviceIdFromList' is the id listed on the output of the command 'adb devices'. I've tested my code with the following commands: react-native run-android --deviceIdFromList "Not existing id" react-native run-android --deviceIdFromList react-native run-android --deviceIdFromList "id of a simulator" react-native run-android --deviceIdFromList "id of a device" Output:  ) I did some cleanup **Test plan (required)** Only one functional change: > Run `react-native run-android --deviceId` Before it was beginning to build the app and then failing because of the missing device "true" :-) Now it's showing a message and stopping the build: ``` ❯ react-native run-android --deviceId Starting JS server... Parameter missing (device id) ``` Closes facebook/react-native#11703 Differential Revision: D4376615 Pulled By: ericvicenti fbshipit-source-id: 3c6e0f12220ab22539c7bc3d390367e02c96728a

Summary
At the moment the run-android command from the react-native cli does run all available devices at once. However it would be extreme useful to have the option to choose only one specific device/simulator.
Therefore i've created a new flag for the command 'run-android': --deviceIdFromList 'deviceIdFromList' in order
to install and launch apps on a specific device/simulator from the command line.
'deviceIdFromList' is the id listed on the output of the command 'adb devices'.
Tests:
I've tested my code with the following commands:
react-native run-android --deviceIdFromList "Not existing id"
react-native run-android --deviceIdFromList
react-native run-android --deviceIdFromList "id of a simulator"
react-native run-android --deviceIdFromList "id of a device"
Output:





