Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cli/src/android/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ export async function runAndroid(
{
target: selectedTarget,
targetName: selectedTargetName,
targetNameSdkVersion: selectedTargetSdkVersion,
flavor: selectedFlavor,
forwardPorts: selectedPorts,
}: RunCommandOptions,
): Promise<void> {
const target = await promptForPlatformTarget(
await getPlatformTargets('android'),
selectedTarget ?? selectedTargetName,
selectedTargetSdkVersion,
selectedTargetName !== undefined,
);

Expand Down
8 changes: 7 additions & 1 deletion cli/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ export interface PlatformTarget {
export async function promptForPlatformTarget(
targets: PlatformTarget[],
selectedTarget?: string,
selectedTargetSdkVersion?: string,
selectByName?: boolean,
): Promise<PlatformTarget> {
const { prompt } = await import('prompts');
Expand Down Expand Up @@ -408,6 +409,10 @@ export async function promptForPlatformTarget(
const targetID = selectedTarget.trim();
const target = targets.find((t) => {
if (selectByName === true) {
if (selectedTargetSdkVersion) {
return t.name === targetID && t.sdkVersion === selectedTargetSdkVersion;
}

return t.name === targetID;
}

Expand All @@ -417,7 +422,8 @@ export async function promptForPlatformTarget(
if (!target) {
if (selectByName) {
fatal(
`Invalid target name: ${c.input(targetID)}.\n` + `Valid targets are: ${targets.map((t) => t.name).join(', ')}`,
`Invalid target name: ${c.input(targetID)}.\n` +
`Valid targets are: ${targets.map((t) => `${t.name} [${t.sdkVersion}]`).join(', ')}`,
);
}
fatal(`Invalid target ID: ${c.input(targetID)}.\n` + `Valid targets are: ${targets.map((t) => t.id).join(', ')}`);
Expand Down
3 changes: 3 additions & 0 deletions cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ export function runProgram(config: Config): void {
.addOption(new Option('--json').hideHelp())
.option('--target <id>', 'use a specific target')
.option('--target-name <name>', 'use a specific target by name')
.option('--target-name-sdk-version <version>', 'use a specific sdk version when using --target-name')
.option('--no-sync', `do not run ${c.input('sync')}`)
.option('--forwardPorts <port:port>', 'Automatically run "adb reverse" for better live-reloading support')
.option('-l, --live-reload', 'Enable Live Reload')
Expand All @@ -254,6 +255,7 @@ export function runProgram(config: Config): void {
json,
target,
targetName,
targetNameSdkVersion,
sync,
forwardPorts,
liveReload,
Expand All @@ -270,6 +272,7 @@ export function runProgram(config: Config): void {
json,
target,
targetName,
targetNameSdkVersion,
sync,
forwardPorts,
liveReload,
Expand Down
2 changes: 2 additions & 0 deletions cli/src/ios/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ export async function runIOS(
{
target: selectedTarget,
targetName: selectedTargetName,
targetNameSdkVersion: selectedTargetSdkVersion,
scheme: selectedScheme,
configuration: selectedConfiguration,
}: RunCommandOptions,
): Promise<void> {
const target = await promptForPlatformTarget(
await getPlatformTargets('ios'),
selectedTarget ?? selectedTargetName,
selectedTargetSdkVersion,
selectedTargetName !== undefined,
);

Expand Down
1 change: 1 addition & 0 deletions cli/src/tasks/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface RunCommandOptions {
json?: boolean;
target?: string;
targetName?: string;
targetNameSdkVersion?: string;
sync?: boolean;
forwardPorts?: string;
liveReload?: boolean;
Expand Down