From 970403081315af9d38e11a31569db19ed6620f9b Mon Sep 17 00:00:00 2001 From: szymonrybczak Date: Mon, 6 May 2024 19:33:07 +0200 Subject: [PATCH 1/3] chore(run-android): deprecate `--deviceId` in favour of `--device` --- packages/cli-platform-android/README.md | 8 ++++++- .../src/commands/runAndroid/index.ts | 24 +++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/packages/cli-platform-android/README.md b/packages/cli-platform-android/README.md index fa9ec7805..155a5dc89 100644 --- a/packages/cli-platform-android/README.md +++ b/packages/cli-platform-android/README.md @@ -36,9 +36,15 @@ Specify an `applicationIdSuffix` to launch after build. Name of the activity to start. +#### `--device [string]` + +Explicitly set the device to use by name. The value is not required if you have a single device connected. + #### `--deviceId ` -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). +> **DEPRECATED** - use `--device [string]` instead + +Builds your app and starts it on a specific device with the given device id (listed by running "adb devices" on the command line). #### `--no-packager` diff --git a/packages/cli-platform-android/src/commands/runAndroid/index.ts b/packages/cli-platform-android/src/commands/runAndroid/index.ts index 33134a143..160e5cc43 100644 --- a/packages/cli-platform-android/src/commands/runAndroid/index.ts +++ b/packages/cli-platform-android/src/commands/runAndroid/index.ts @@ -38,6 +38,7 @@ export interface Flags extends BuildFlags { port: number; terminal?: string; packager?: boolean; + device?: string | true; deviceId?: string; listDevices?: boolean; binaryPath?: string; @@ -122,6 +123,13 @@ async function getAvailableDevicePort( // Builds the app and runs it on a connected emulator / device. async function buildAndRun(args: Flags, androidProject: AndroidProject) { + if (args.deviceId) { + logger.warn( + 'The `deviceId` parameter is deprecated. Please use `device` instead.', + ); + args.device = args.deviceId; + } + process.chdir(androidProject.sourceDir); const cmd = process.platform.startsWith('win') ? 'gradlew.bat' : './gradlew'; @@ -140,9 +148,11 @@ async function buildAndRun(args: Flags, androidProject: AndroidProject) { } if (args.listDevices || args.interactive) { - if (args.deviceId) { + if (args.device) { logger.warn( - 'Both "deviceId" and "list-devices" parameters were passed to "run" command. We will list available devices and let you choose from one', + `Both ${ + args.deviceId ? 'deviceId' : 'device' + } and "list-devices" parameters were passed to "run" command. We will list available devices and let you choose from one`, ); } @@ -193,7 +203,7 @@ async function buildAndRun(args: Flags, androidProject: AndroidProject) { ); } - if (args.deviceId) { + if (args.device) { return runOnSpecificDevice(args, adbPath, androidProject, selectedTask); } else { return runOnAllDevices(args, cmd, adbPath, androidProject); @@ -326,10 +336,16 @@ export default { name: '--main-activity ', description: 'Name of the activity to start', }, + { + name: '--device [string]', + description: + 'Explicitly set the device to use by name. The value is not required ' + + 'if you have a single device connected.', + }, { name: '--deviceId ', description: - 'builds your app and starts it on a specific device/simulator with the ' + + '**DEPRECATED** 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).', }, { From 4cfe961d6e4bcd7c3619bdcc840660a4ae9f0dd4 Mon Sep 17 00:00:00 2001 From: szymonrybczak Date: Mon, 6 May 2024 19:37:47 +0200 Subject: [PATCH 2/3] fix: option should accept only strings --- packages/cli-platform-android/README.md | 4 ++-- .../cli-platform-android/src/commands/runAndroid/index.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/cli-platform-android/README.md b/packages/cli-platform-android/README.md index 155a5dc89..1a0c168c2 100644 --- a/packages/cli-platform-android/README.md +++ b/packages/cli-platform-android/README.md @@ -36,13 +36,13 @@ Specify an `applicationIdSuffix` to launch after build. Name of the activity to start. -#### `--device [string]` +#### `--device ` Explicitly set the device to use by name. The value is not required if you have a single device connected. #### `--deviceId ` -> **DEPRECATED** - use `--device [string]` instead +> **DEPRECATED** - use `--device ` instead Builds your app and starts it on a specific device with the given device id (listed by running "adb devices" on the command line). diff --git a/packages/cli-platform-android/src/commands/runAndroid/index.ts b/packages/cli-platform-android/src/commands/runAndroid/index.ts index 160e5cc43..58ec06474 100644 --- a/packages/cli-platform-android/src/commands/runAndroid/index.ts +++ b/packages/cli-platform-android/src/commands/runAndroid/index.ts @@ -38,7 +38,7 @@ export interface Flags extends BuildFlags { port: number; terminal?: string; packager?: boolean; - device?: string | true; + device?: string; deviceId?: string; listDevices?: boolean; binaryPath?: string; @@ -337,7 +337,7 @@ export default { description: 'Name of the activity to start', }, { - name: '--device [string]', + name: '--device ', description: 'Explicitly set the device to use by name. The value is not required ' + 'if you have a single device connected.', From 7b8aa96c88b810865707d614e1cd8a4baf749181 Mon Sep 17 00:00:00 2001 From: Szymon Rybczak Date: Tue, 4 Jun 2024 19:17:54 +0200 Subject: [PATCH 3/3] Update packages/cli-platform-android/src/commands/runAndroid/index.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Michał Pierzchała --- packages/cli-platform-android/src/commands/runAndroid/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli-platform-android/src/commands/runAndroid/index.ts b/packages/cli-platform-android/src/commands/runAndroid/index.ts index 58ec06474..e5011a857 100644 --- a/packages/cli-platform-android/src/commands/runAndroid/index.ts +++ b/packages/cli-platform-android/src/commands/runAndroid/index.ts @@ -125,7 +125,7 @@ async function getAvailableDevicePort( async function buildAndRun(args: Flags, androidProject: AndroidProject) { if (args.deviceId) { logger.warn( - 'The `deviceId` parameter is deprecated. Please use `device` instead.', + 'The `deviceId` parameter is renamed to `device`. Please use the new `device` argument next time to avoid this warning.', ); args.device = args.deviceId; }