Skip to content

Commit

Permalink
[eas-cli] Fix flags and args
Browse files Browse the repository at this point in the history
Fixed flags and args in `analytics`, `config`, `credentials` and `submit` commands

See: https://linear.app/expo/issue/ENG-9175/update-oclif-in-eas-cli
  • Loading branch information
radoslawkrzemien committed Dec 1, 2023
1 parent 5d4f380 commit c057738
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
8 changes: 4 additions & 4 deletions packages/eas-cli/src/commands/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Args } from '@oclif/core';

import { getAnalyticsEnabledAsync, setAnalyticsEnabledAsync } from '../analytics/AnalyticsManager';
import EasCommand from '../commandUtils/EasCommand';
import Log from '../log';

export default class AnalyticsView extends EasCommand {
static override description = 'display or change analytics settings';

static override args = [{ name: 'STATUS', options: ['on', 'off'] }];
static override args = { STATUS: Args.string({ options: ['on', 'off'] }) };

async runAsync(): Promise<void> {
const { STATUS: status } = (await this.parse(AnalyticsView)).args;
Expand All @@ -15,9 +17,7 @@ export default class AnalyticsView extends EasCommand {
} else {
const analyticsEnabled = await getAnalyticsEnabledAsync();
Log.log(
`Analytics are ${
analyticsEnabled === false ? 'disabled' : 'enabled'
} on this eas-cli installation.`
`Analytics are ${!analyticsEnabled ? 'disabled' : 'enabled'} on this eas-cli installation.`
);
}
}
Expand Down
37 changes: 35 additions & 2 deletions packages/eas-cli/src/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,36 @@ import { appPlatformEmojis } from '../platform';
import { selectAsync } from '../prompts';
import { enableJsonOutput, printJsonOnlyOutput } from '../utils/json';

interface RawConfigFlags {
platform?: string;
profile?: string;
'eas-json-only'?: boolean;
json?: boolean;
'non-interactive'?: boolean;
}

interface ConfigCommandFlags {
platform?: Platform;
profile?: string;
'eas-json-only'?: boolean;
json?: boolean;
'non-interactive'?: boolean;
}

function maybeGetPlatform(platformString: string | undefined): Platform | undefined {
if (!platformString) {
return undefined;
}
return Object.values(Platform).find(platform => platform === platformString);
}

const PLATFORM_FLAG_OPTIONS = [Platform.ANDROID, Platform.IOS];

export default class Config extends EasCommand {
static override description = 'display project configuration (app.json + eas.json)';

static override flags = {
platform: Flags.enum<Platform>({ char: 'p', options: [Platform.ANDROID, Platform.IOS] }),
platform: Flags.string({ char: 'p', options: PLATFORM_FLAG_OPTIONS }),
profile: Flags.string({
char: 'e',
description:
Expand All @@ -36,7 +61,8 @@ export default class Config extends EasCommand {
};

async runAsync(): Promise<void> {
const { flags } = await this.parse(Config);
const { flags: rawFlags } = await this.parse(Config);
const flags = await this.sanitizeFlagsAsync(rawFlags);
if (flags.json) {
enableJsonOutput();
}
Expand Down Expand Up @@ -103,4 +129,11 @@ export default class Config extends EasCommand {
}
}
}

private async sanitizeFlagsAsync(flags: RawConfigFlags): Promise<ConfigCommandFlags> {
return {
...flags,
platform: maybeGetPlatform(flags.platform),
};
}
}
4 changes: 3 additions & 1 deletion packages/eas-cli/src/commands/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { Flags } from '@oclif/core';
import EasCommand from '../commandUtils/EasCommand';
import { SelectPlatform } from '../credentials/manager/SelectPlatform';

const PLATFORM_FLAG_OPTIONS = ['android', 'ios'];

export default class Credentials extends EasCommand {
static override description = 'manage credentials';

static override flags = {
platform: Flags.enum({ char: 'p', options: ['android', 'ios'] }),
platform: Flags.string({ char: 'p', options: PLATFORM_FLAG_OPTIONS }),
};

static override contextDefinition = {
Expand Down
6 changes: 4 additions & 2 deletions packages/eas-cli/src/commands/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ interface CommandFlags {
nonInteractive: boolean;
}

const PLATFORM_FLAG_OPTIONS = ['android', 'ios', 'all'];

export default class Submit extends EasCommand {
static override description = 'submit app binary to App Store and/or Play Store';
static override aliases = ['build:submit'];

static override flags = {
platform: Flags.enum({
platform: Flags.string({
char: 'p',
options: ['android', 'ios', 'all'],
options: PLATFORM_FLAG_OPTIONS,
}),
profile: Flags.string({
char: 'e',
Expand Down

0 comments on commit c057738

Please sign in to comment.