From a32ee869f3be5055b2c51b4c3211a2030feb2573 Mon Sep 17 00:00:00 2001 From: Radoslaw Krzemien Date: Fri, 1 Dec 2023 11:49:21 +0100 Subject: [PATCH] [eas-cli] Fix flags and args Fixed flags and args in `update` commands See: https://linear.app/expo/issue/ENG-9175/update-oclif-in-eas-cli --- packages/eas-cli/src/commands/update/configure.ts | 6 ++++-- packages/eas-cli/src/commands/update/delete.ts | 10 +++++----- packages/eas-cli/src/commands/update/index.ts | 14 ++++++++------ packages/eas-cli/src/commands/update/republish.ts | 6 ++++-- .../src/commands/update/roll-back-to-embedded.ts | 14 ++++++++------ packages/eas-cli/src/commands/update/view.ts | 10 +++++----- 6 files changed, 34 insertions(+), 26 deletions(-) diff --git a/packages/eas-cli/src/commands/update/configure.ts b/packages/eas-cli/src/commands/update/configure.ts index 5f153e432d..6fbc4a7956 100644 --- a/packages/eas-cli/src/commands/update/configure.ts +++ b/packages/eas-cli/src/commands/update/configure.ts @@ -11,14 +11,16 @@ import { ensureEASUpdateIsConfiguredInEasJsonAsync, } from '../../update/configure'; +const PLATFORM_FLAG_OPTIONS = ['android', 'ios', 'all']; + export default class UpdateConfigure extends EasCommand { static override description = 'configure the project to support EAS Update'; static override flags = { - platform: Flags.enum({ + platform: Flags.string({ description: 'Platform to configure', char: 'p', - options: ['android', 'ios', 'all'], + options: PLATFORM_FLAG_OPTIONS, default: 'all', }), ...EASNonInteractiveFlag, diff --git a/packages/eas-cli/src/commands/update/delete.ts b/packages/eas-cli/src/commands/update/delete.ts index 1182fc1b2e..6887ecf5af 100644 --- a/packages/eas-cli/src/commands/update/delete.ts +++ b/packages/eas-cli/src/commands/update/delete.ts @@ -1,3 +1,4 @@ +import { Args } from '@oclif/core'; import chalk from 'chalk'; import gql from 'graphql-tag'; @@ -42,13 +43,12 @@ async function deleteUpdateGroupAsync( export default class UpdateDelete extends EasCommand { static override description = 'delete all the updates in an update group'; - static override args = [ - { - name: 'groupId', + static override args = { + groupId: Args.string({ required: true, description: 'The ID of an update group to delete.', - }, - ]; + }), + }; static override flags = { ...EasNonInteractiveAndJsonFlags, diff --git a/packages/eas-cli/src/commands/update/index.ts b/packages/eas-cli/src/commands/update/index.ts index 780f24f141..9cc6fa6ba0 100644 --- a/packages/eas-cli/src/commands/update/index.ts +++ b/packages/eas-cli/src/commands/update/index.ts @@ -87,6 +87,12 @@ type UpdateFlags = { nonInteractive: boolean; }; +const PLATFORM_FLAG_OPTIONS = [ + // TODO: Add web when it's fully supported + ...defaultPublishPlatforms, + 'all', +]; + export default class UpdatePublish extends EasCommand { static override description = 'publish an update group'; @@ -125,13 +131,9 @@ export default class UpdatePublish extends EasCommand { description: `Clear the bundler cache before publishing`, default: false, }), - platform: Flags.enum({ + platform: Flags.string({ char: 'p', - options: [ - // TODO: Add web when it's fully supported - ...defaultPublishPlatforms, - 'all', - ], + options: PLATFORM_FLAG_OPTIONS, default: 'all', required: false, }), diff --git a/packages/eas-cli/src/commands/update/republish.ts b/packages/eas-cli/src/commands/update/republish.ts index 8ee6b29d2a..7af37bce22 100644 --- a/packages/eas-cli/src/commands/update/republish.ts +++ b/packages/eas-cli/src/commands/update/republish.ts @@ -41,6 +41,8 @@ type UpdateRepublishFlags = { json: boolean; }; +const PLATFORM_FLAG_OPTIONS = [...defaultRepublishPlatforms, 'all']; + export default class UpdateRepublish extends EasCommand { static override description = 'roll back to an existing update'; @@ -62,9 +64,9 @@ export default class UpdateRepublish extends EasCommand { description: 'Short message describing the republished update group', required: false, }), - platform: Flags.enum({ + platform: Flags.string({ char: 'p', - options: [...defaultRepublishPlatforms, 'all'], + options: PLATFORM_FLAG_OPTIONS, default: 'all', required: false, }), diff --git a/packages/eas-cli/src/commands/update/roll-back-to-embedded.ts b/packages/eas-cli/src/commands/update/roll-back-to-embedded.ts index 811cbe6955..2ce9356a14 100644 --- a/packages/eas-cli/src/commands/update/roll-back-to-embedded.ts +++ b/packages/eas-cli/src/commands/update/roll-back-to-embedded.ts @@ -69,6 +69,12 @@ type UpdateFlags = { nonInteractive: boolean; }; +const PLATFORM_FLAG_OPTIONS = [ + // TODO: Add web when it's fully supported + ...defaultPublishPlatforms, + 'all', +]; + export default class UpdateRollBackToEmbedded extends EasCommand { static override description = 'roll back to the embedded update'; @@ -85,13 +91,9 @@ export default class UpdateRollBackToEmbedded extends EasCommand { description: 'A short message describing the rollback to embedded update', required: false, }), - platform: Flags.enum({ + platform: Flags.string({ char: 'p', - options: [ - // TODO: Add web when it's fully supported - ...defaultPublishPlatforms, - 'all', - ], + options: PLATFORM_FLAG_OPTIONS, default: 'all', required: false, }), diff --git a/packages/eas-cli/src/commands/update/view.ts b/packages/eas-cli/src/commands/update/view.ts index f6f92a921b..4464fc029b 100644 --- a/packages/eas-cli/src/commands/update/view.ts +++ b/packages/eas-cli/src/commands/update/view.ts @@ -1,3 +1,4 @@ +import { Args } from '@oclif/core'; import chalk from 'chalk'; import EasCommand from '../../commandUtils/EasCommand'; @@ -14,13 +15,12 @@ import { enableJsonOutput, printJsonOnlyOutput } from '../../utils/json'; export default class UpdateView extends EasCommand { static override description = 'update group details'; - static override args = [ - { - name: 'groupId', + static override args = { + groupId: Args.string({ required: true, description: 'The ID of an update group.', - }, - ]; + }), + }; static override flags = { ...EasJsonOnlyFlag,