Skip to content

Commit efd6bd4

Browse files
chore(run-android): deprecate --deviceId in favour of --device (#2377)
* chore(run-android): deprecate `--deviceId` in favour of `--device` * fix: option should accept only strings * Update packages/cli-platform-android/src/commands/runAndroid/index.ts Co-authored-by: Michał Pierzchała <[email protected]> --------- Co-authored-by: Michał Pierzchała <[email protected]>
1 parent 017a62b commit efd6bd4

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

packages/cli-platform-android/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,15 @@ Specify an `applicationIdSuffix` to launch after build.
3636
3737
Name of the activity to start.
3838

39+
#### `--device <string>`
40+
41+
Explicitly set the device to use by name. The value is not required if you have a single device connected.
42+
3943
#### `--deviceId <string>`
4044

41-
builds your app and starts it on a specific device/simulator with the given device id (listed by running "adb devices" on the command line).
45+
> **DEPRECATED** - use `--device <string>` instead
46+
47+
Builds your app and starts it on a specific device with the given device id (listed by running "adb devices" on the command line).
4248

4349
#### `--no-packager`
4450

packages/cli-platform-android/src/commands/runAndroid/index.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export interface Flags extends BuildFlags {
3838
port: number;
3939
terminal?: string;
4040
packager?: boolean;
41+
device?: string;
4142
deviceId?: string;
4243
listDevices?: boolean;
4344
binaryPath?: string;
@@ -122,6 +123,13 @@ async function getAvailableDevicePort(
122123

123124
// Builds the app and runs it on a connected emulator / device.
124125
async function buildAndRun(args: Flags, androidProject: AndroidProject) {
126+
if (args.deviceId) {
127+
logger.warn(
128+
'The `deviceId` parameter is renamed to `device`. Please use the new `device` argument next time to avoid this warning.',
129+
);
130+
args.device = args.deviceId;
131+
}
132+
125133
process.chdir(androidProject.sourceDir);
126134
const cmd = process.platform.startsWith('win') ? 'gradlew.bat' : './gradlew';
127135

@@ -140,9 +148,11 @@ async function buildAndRun(args: Flags, androidProject: AndroidProject) {
140148
}
141149

142150
if (args.listDevices || args.interactive) {
143-
if (args.deviceId) {
151+
if (args.device) {
144152
logger.warn(
145-
'Both "deviceId" and "list-devices" parameters were passed to "run" command. We will list available devices and let you choose from one',
153+
`Both ${
154+
args.deviceId ? 'deviceId' : 'device'
155+
} and "list-devices" parameters were passed to "run" command. We will list available devices and let you choose from one`,
146156
);
147157
}
148158

@@ -193,7 +203,7 @@ async function buildAndRun(args: Flags, androidProject: AndroidProject) {
193203
);
194204
}
195205

196-
if (args.deviceId) {
206+
if (args.device) {
197207
return runOnSpecificDevice(args, adbPath, androidProject, selectedTask);
198208
} else {
199209
return runOnAllDevices(args, cmd, adbPath, androidProject);
@@ -326,10 +336,16 @@ export default {
326336
name: '--main-activity <string>',
327337
description: 'Name of the activity to start',
328338
},
339+
{
340+
name: '--device <string>',
341+
description:
342+
'Explicitly set the device to use by name. The value is not required ' +
343+
'if you have a single device connected.',
344+
},
329345
{
330346
name: '--deviceId <string>',
331347
description:
332-
'builds your app and starts it on a specific device/simulator with the ' +
348+
'**DEPRECATED** Builds your app and starts it on a specific device/simulator with the ' +
333349
'given device id (listed by running "adb devices" on the command line).',
334350
},
335351
{

0 commit comments

Comments
 (0)