Skip to content
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

chore(run-android): deprecate --deviceId in favour of --device #2377

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/cli-platform-android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string>`

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`

Expand Down
24 changes: 20 additions & 4 deletions packages/cli-platform-android/src/commands/runAndroid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface Flags extends BuildFlags {
port: number;
terminal?: string;
packager?: boolean;
device?: string;
deviceId?: string;
listDevices?: boolean;
binaryPath?: string;
Expand Down Expand Up @@ -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.',
szymonrybczak marked this conversation as resolved.
Show resolved Hide resolved
);
args.device = args.deviceId;
}

process.chdir(androidProject.sourceDir);
const cmd = process.platform.startsWith('win') ? 'gradlew.bat' : './gradlew';

Expand All @@ -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`,
);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -326,10 +336,16 @@ export default {
name: '--main-activity <string>',
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 <string>',
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).',
},
{
Expand Down