Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add a required input prompt for use in region input #2292

Merged
merged 3 commits into from
Dec 3, 2024
Merged

Conversation

Amplifiyer
Copy link
Contributor

Problem

Currently we accept "Enter" as acceptable input for region while configuring the profile. This results in "" value to be stored as region which later fails validation

Changes

fix: add a required input prompt for use in region input

Corresponding docs PR, if applicable:

Validation

Checklist

  • If this PR includes a functional change to the runtime behavior of the code, I have added or updated automated test coverage for this change.
  • If this PR requires a change to the Project Architecture README, I have included that update in this PR.
  • If this PR requires a docs update, I have linked to that docs PR above.
  • If this PR modifies E2E tests, makes changes to resource provisioning, or makes SDK calls, I have run the PR checks with the run-e2e label set.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Amplifiyer Amplifiyer requested review from a team as code owners December 3, 2024 16:16
Copy link

changeset-bot bot commented Dec 3, 2024

🦋 Changeset detected

Latest commit: 4a57977

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@aws-amplify/cli-core Patch
@aws-amplify/backend-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines 18 to 20
static requiredInput: (options: {
message: string;
}) => Promise<string>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about

    static input: (options: {
        message: string;
        defaultValue?: string;
        required?: boolean
    }) => Promise<string>;

above?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(or some type union for options to make default and required mutually exclusive)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

combining it was making it slightly cryptic without making a break in the API.

e.g.

{
    message: string;
    required: false;
    defaultValue?: string;
  } | {
    message: string;
    required: true;
  }

is a breaking change and

{
    message: string;
    defaultValue?: string;
  } | {
    message: string;
    required: true;
  }

allows both defaultValue and required shows up in the intellisense which is confusing API

await AmplifyPrompter.input({
    message: `Hit [enter] when complete`,
    required: true,
    defaultValue: ''
});

I figured having an explicit API is probably better to not touch the existing uses of input

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did see this pattern in bedrock SDK. might be worth trying.

{
    message: string;
    required?: never;
    defaultValue?: string;
  } | {
    message: string;
    required: true;
    defaultValue?: never;
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohh that's neat. Updated.

sobolk
sobolk previously approved these changes Dec 3, 2024
@Amplifiyer Amplifiyer merged commit 0cf5c26 into main Dec 3, 2024
40 checks passed
@Amplifiyer Amplifiyer deleted the prompt_fix branch December 3, 2024 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants