Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions packages/eas-cli/src/credentials/manager/SelectPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ManageIos } from './ManageIos';
import { Analytics } from '../../analytics/AnalyticsManager';
import { DynamicConfigContextFn } from '../../commandUtils/context/DynamicProjectConfigContextField';
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
import { selectPlatformAsync } from '../../platform';
import { selectPlatformWithExitOptionAsync } from '../../platform';
import { Actor } from '../../user/User';
import { Client } from '../../vcs/vcs';
import { CredentialsContextProjectInfo } from '../context';
Expand All @@ -20,7 +20,7 @@ export class SelectPlatform {
) {}

async runAsync(): Promise<void> {
const platform = await selectPlatformAsync(this.flagPlatform);
const platform = await selectPlatformWithExitOptionAsync(this.flagPlatform);

if (platform === 'ios') {
await new ManageIos(this, process.cwd()).runAsync();
Expand Down
34 changes: 28 additions & 6 deletions packages/eas-cli/src/platform.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Platform } from '@expo/eas-build-job';

import { AppPlatform } from './graphql/generated';
import Log from './log';
import { promptAsync } from './prompts';

export const appPlatformDisplayNames: Record<AppPlatform, string> = {
Expand Down Expand Up @@ -47,21 +48,42 @@ export async function selectRequestedPlatformAsync(platform?: string): Promise<R
return requestedPlatform;
}

export async function selectPlatformWithExitOptionAsync(platform?: string): Promise<Platform> {
return await selectPlatformInternalAsync(platform, true);
}
export async function selectPlatformAsync(platform?: string): Promise<Platform> {
return await selectPlatformInternalAsync(platform, false);
}

async function selectPlatformInternalAsync(
platform?: string,
allowExit?: boolean
): Promise<Platform> {
if (platform && Object.values(Platform).includes(platform.toLowerCase() as Platform)) {
return platform.toLowerCase() as Platform;
}

const { resolvedPlatform } = await promptAsync({
const platformChoices: { title: string; value: Platform | 'Exit' }[] = [
{ title: 'Android', value: Platform.ANDROID },
{ title: 'iOS', value: Platform.IOS },
];

if (allowExit) {
platformChoices.push({ title: 'Exit', value: 'Exit' });
}

const result: any = await promptAsync({
type: 'select',
message: 'Select platform',
name: 'resolvedPlatform',
choices: [
{ title: 'Android', value: Platform.ANDROID },
{ title: 'iOS', value: Platform.IOS },
],
choices: platformChoices,
});
return resolvedPlatform;
if (result.resolvedPlatform === 'Exit') {
Log.addNewLineIfNone();
Log.log('Exiting');
process.exit(0);
}
return result.resolvedPlatform;
}

export function toPlatforms(requestedPlatform: RequestedPlatform): Platform[] {
Expand Down