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

cli(prompts): Add autocomplete support for config props #502

Merged
merged 4 commits into from
Jun 13, 2018

Conversation

dhruvdutt
Copy link
Member

@dhruvdutt dhruvdutt commented Jun 12, 2018

What kind of change does this PR introduce?
Feature

Did you add tests for your changes?

If relevant, did you update the documentation?

Summary
peek 2018-06-12 20-07

Does this PR introduce a breaking change?

Other information

const Confirm = require("@webpack-cli/webpack-scaffold").Confirm;
const List = require("@webpack-cli/webpack-scaffold").List;
const Input = require("@webpack-cli/webpack-scaffold").Input;
const AutoComplete = require("@webpack-cli/webpack-scaffold").AutoComplete;
Copy link
Contributor

Choose a reason for hiding this comment

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

Trivial: at this point we could refactor with destructoring

const { Confirm, List, Input, AutoComplete }= require("@webpack-cli/webpack-scaffold")

@@ -14,6 +16,8 @@ const getPackageManager = require("@webpack-cli/utils/package-manager")
const npmExists = require("@webpack-cli/utils/npm-exists");
const entryQuestions = require("./utils/entry");

const PROPS = Array.from(PROP_TYPES.keys());
Copy link
Contributor

Choose a reason for hiding this comment

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

.keys already returns an array. Why did you use Array.from?

Copy link
Member Author

@dhruvdutt dhruvdutt Jun 12, 2018

Choose a reason for hiding this comment

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

When using a Set, it returns an Iterator instead of array. Hence, we have to use Array.from method.

In case of object, .keys returns an array.

Copy link
Contributor

Choose a reason for hiding this comment

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

Aaah it was a Set! Fair enough, thanks!

*/
const searchProps = (answers, input) => {
input = input || "";
return new Promise(resolve => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a suggestion:

return Promise.resolve(
  PROPS.filter(food =>
    food.toLowerCase().includes(input.toLowerCase())
  )
)

Copy link
Contributor

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Just few enhancements but it looks good!

@webpack-bot

This comment has been minimized.

)
);
});
return new Promise.resolve(
Copy link
Contributor

Choose a reason for hiding this comment

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

Without new

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. Thanks!

Copy link
Member

@evenstensberg evenstensberg left a comment

Choose a reason for hiding this comment

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

Sweet jelly beans 😍 LGTM. I'm not on slack today, but could you start with ts?

@evenstensberg evenstensberg changed the title Add autocomplete support for config props cli(prompts): Add autocomplete support for config props Jun 13, 2018
@dhruvdutt
Copy link
Member Author

Yes. I'll start with TS. 🎉

@ematipico ematipico merged commit 4238ec7 into master Jun 13, 2018
@dhruvdutt dhruvdutt deleted the add-autocomplete branch June 13, 2018 16:55
@evenstensberg
Copy link
Member

🎉 This PR is included in version 3.0.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants