Skip to content

Commit 88d9627

Browse files
authored
Allow exit from credentials command (#3269)
# Why The command `eas credentials` does not provide a way to exit other than control-C, if no platform flag is passed in. # How Add an "Exit" choice to the platform prompt. # Test Plan Tested locally.
1 parent 59ce6d0 commit 88d9627

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

packages/eas-cli/src/credentials/manager/SelectPlatform.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ManageIos } from './ManageIos';
33
import { Analytics } from '../../analytics/AnalyticsManager';
44
import { DynamicConfigContextFn } from '../../commandUtils/context/DynamicProjectConfigContextField';
55
import { ExpoGraphqlClient } from '../../commandUtils/context/contextUtils/createGraphqlClient';
6-
import { selectPlatformAsync } from '../../platform';
6+
import { selectPlatformWithExitOptionAsync } from '../../platform';
77
import { Actor } from '../../user/User';
88
import { Client } from '../../vcs/vcs';
99
import { CredentialsContextProjectInfo } from '../context';
@@ -20,7 +20,7 @@ export class SelectPlatform {
2020
) {}
2121

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

2525
if (platform === 'ios') {
2626
await new ManageIos(this, process.cwd()).runAsync();

packages/eas-cli/src/platform.ts

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Platform } from '@expo/eas-build-job';
22

33
import { AppPlatform } from './graphql/generated';
4+
import Log from './log';
45
import { promptAsync } from './prompts';
56

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

51+
export async function selectPlatformWithExitOptionAsync(platform?: string): Promise<Platform> {
52+
return await selectPlatformInternalAsync(platform, true);
53+
}
5054
export async function selectPlatformAsync(platform?: string): Promise<Platform> {
55+
return await selectPlatformInternalAsync(platform, false);
56+
}
57+
58+
async function selectPlatformInternalAsync(
59+
platform?: string,
60+
allowExit?: boolean
61+
): Promise<Platform> {
5162
if (platform && Object.values(Platform).includes(platform.toLowerCase() as Platform)) {
5263
return platform.toLowerCase() as Platform;
5364
}
5465

55-
const { resolvedPlatform } = await promptAsync({
66+
const platformChoices: { title: string; value: Platform | 'Exit' }[] = [
67+
{ title: 'Android', value: Platform.ANDROID },
68+
{ title: 'iOS', value: Platform.IOS },
69+
];
70+
71+
if (allowExit) {
72+
platformChoices.push({ title: 'Exit', value: 'Exit' });
73+
}
74+
75+
const result: any = await promptAsync({
5676
type: 'select',
5777
message: 'Select platform',
5878
name: 'resolvedPlatform',
59-
choices: [
60-
{ title: 'Android', value: Platform.ANDROID },
61-
{ title: 'iOS', value: Platform.IOS },
62-
],
79+
choices: platformChoices,
6380
});
64-
return resolvedPlatform;
81+
if (result.resolvedPlatform === 'Exit') {
82+
Log.addNewLineIfNone();
83+
Log.log('Exiting');
84+
process.exit(0);
85+
}
86+
return result.resolvedPlatform;
6587
}
6688

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

0 commit comments

Comments
 (0)