Skip to content

feat(create-app): two-level prompt for framework and variants#2941

Merged
patak-cat merged 3 commits intomainfrom
feat/create-app-prompts
Apr 14, 2021
Merged

feat(create-app): two-level prompt for framework and variants#2941
patak-cat merged 3 commits intomainfrom
feat/create-app-prompts

Conversation

@antfu
Copy link
Copy Markdown
Member

@antfu antfu commented Apr 10, 2021

Description

As we are growing rapidly, we are now having 12 templates for users to choose from. As half of them are TypeScript variants and we might have more in the future. This PR introduces two-level prompts to make it simpler and future-proofing - one for frameworks, and one for variants.

From

Screen Shot 2021-04-11 at 6 00 11 AM

To:

Screen Shot 2021-04-11 at 6 00 44 AM

Screen Shot 2021-04-11 at 6 00 52 AM

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@patak-cat
Copy link
Copy Markdown
Member

Nice! Do you think there will be other variants in the future? I was thinking we could use a yes/no question for TypeScript if not. Maybe interesting to think about JSX for vue. In that case we would have four variants if we want to include that option, or two yes/no questions. Typescript? Yes/no, JSX? Yes/no

@antfu
Copy link
Copy Markdown
Member Author

antfu commented Apr 11, 2021

Frankly, I don't know 😅. Just think variants could be more general. With JSX/TSX, we will have 4 variants, I guess maybe it's still ok. We can think about it when we have like 10 items-ish?

message: 'Select a variant:',
choices: frameworkInfo.variants.map((v) => ({
name: v.name,
value: v.name,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we should display JavaScript or TypeScript (the variant display) instead of the template name once the user selects the option. I think it would be more clear as feedback:
image

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well, I actually noticed and tried, but haven't found a way to make enquirer work that way. Might need to hack it a bit?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I thought it was a simple change, your call then. This was just a small DX improvement.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Found the way.
image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🎉

@Shinigami92 Shinigami92 added enhancement New feature or request p2-nice-to-have Not breaking anything but nice to have (priority) labels Apr 11, 2021
Comment thread packages/create-app/index.js Outdated
Comment thread packages/create-app/index.js
Co-authored-by: Shinigami <chrissi92@hotmail.de>
@Shinigami92
Copy link
Copy Markdown
Member

Just an idea I want to raise here 🙂
Is it possible to pick colors of each framework and use these color values for them?
And if the used terminal doesn't support true colors, then fallback to the nearest color?

This would be a new PR 🙂

patak-cat
patak-cat previously approved these changes Apr 14, 2021
@patak-cat patak-cat merged commit 176e55d into main Apr 14, 2021
TobiasMelen pushed a commit to TobiasMelen/vite that referenced this pull request May 3, 2021
@antfu antfu deleted the feat/create-app-prompts branch September 17, 2021 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request p2-nice-to-have Not breaking anything but nice to have (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants