amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

cli skips option to create new column when created nosql storage

Open cityzen opened this issue 8 years ago • 14 comments

Describe the bug While going through the storage setup for dynamo, the cli will seemingly skip questions. It was defaulting to "true" for each "Would you like to add another column" and on a second try it defaulted to "false" after first column and went directly to primary key.

To Reproduce Steps to reproduce the behavior:

  1. cli: amplify storage add
  2. nosql
  3. Enter resource label
  4. enter table name
  5. name first column "name" and set type as String
  6. yes to add new column
  7. name second column "test" and set type as List
  8. at this point mine will skip the next "would you like to add another column" and default to true and ask for the name of the new column

Expected behavior Will be prompted for each column setup

Screenshots screen recording 2018-12-01 at 11 54 am

Desktop (please complete the following information):

  • OS: MacOS 10.14.1

Additional context cli version: 0.1.34

cityzen avatar Dec 01 '18 16:12 cityzen

Same issue with cli version 0.1.35 on macOS.

solshark avatar Dec 03 '18 13:12 solshark

@cityzen what version of node do you have installed?

yuth avatar Dec 03 '18 19:12 yuth

@yuth I have issue with node 10.13.0

solshark avatar Dec 03 '18 20:12 solshark

@yuth I am also experiencing the same issue with both [email protected] and [email protected] on node 8.11.0.

zjullion avatar Dec 03 '18 21:12 zjullion

@yuth I'm on node 10.11.0

cityzen avatar Dec 03 '18 21:12 cityzen

The issue is here:

https://github.com/aws-amplify/amplify-cli/blob/d5401ba3d9ce1fee19a921e3267160f7c57d6966/packages/amplify-category-storage/provider-utils/awscloudformation/service-walkthroughs/dynamoDb-walkthrough.js#L176

I suspect there is an issue with context.prompt.confirm, but I'm having trouble finding where that is defined.

zjullion avatar Dec 03 '18 22:12 zjullion

@zjullion context.prompt.confirm is declared in gluegun.

The funny things is I can reproduce this issue and one of my co-worker has identical setup and everything work on in his machine.

For some reason await doesn't wait for the function call to return. Its using the value from the previous call after first invocation.

yuth avatar Dec 03 '18 23:12 yuth

From our testing, it doesn't always seem to return the value from the previous call - it will sometimes (seemingly randomly) return another value.

A simple work to work around this is the following:

    const continueQuestion = {
      type: 'confirm',
      name: 'continue',
      message: 'Wanna add another column?',
    };
    const continueAnswer = await inquirer.prompt([continueQuestion]);
    continueAttributeQuestion = continueAnswer.continue;

It's a little strange to me that amplify-cli hooks into gluegun's use of enquirer for some prompts, while mostly using inquirer. Should all the calls to context.prompt.confirm maybe be refactored to inquirer calls?

zjullion avatar Dec 03 '18 23:12 zjullion

It's a little strange to me that amplify-cli hooks into gluegun's use of enquirer for some prompts, while mostly using inquirer. Should all the calls to context.prompt.confirm maybe be refactored to inquirer calls?

Using glueguns confirm makes the code lot more readable. But yes we should move all our interaction code to use inquirer which is a little more involved as we have this in bunch of places

yuth avatar Dec 03 '18 23:12 yuth

@yuth I can open a PR for this, if you like. It should be ready to go sometime tomorrow at the latest.

zjullion avatar Dec 03 '18 23:12 zjullion

I already have a fix. PR coming right up in a bit

yuth avatar Dec 03 '18 23:12 yuth

You've updated the prompts in /packages/amplify-category-storage/provider-utils/awscloudformation/service-walkthroughs/dynamoDb-walkthrough.js, but gluegun's context.prompt.confirm is also used in a number of other files - is it worth updating those as well?

zjullion avatar Dec 04 '18 00:12 zjullion

The fix has been released in 0.1.36

yuth avatar Dec 05 '18 22:12 yuth

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

github-actions[bot] avatar May 27 '21 17:05 github-actions[bot]