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

feat(gatsby-cli): Prompt user for options (no args with gatsby new) #14097

Merged
merged 9 commits into from
Jun 21, 2019

Conversation

gillkyle
Copy link
Contributor

Description

This PR would allow the gatsby new command with empty args to prompt the user for the path and official starter they'd like to use like this:

gtsby-new

I added a 4th option where they could select use another option which just exits the command and logs the url to the starter showcase as well:

gtsby-new-2

Some things worth discussing:

  • should the starter used be the first question? It would allow a short circuit exit if they select option 4 (Use a different starter)
  • is their wording that should change?

Related Issues

Addresses issue #14085

@pieh
Copy link
Contributor

pieh commented May 17, 2019

Nice!

I would add to the discussion:

  • maybe open browser with starter library url when selecting 4th option (f.e. using opn package)
  • maybe show starter selection prompt anytime that starter wasn't specified (so change current behaviour of auto selecting default starter)

As for your question - I would keep default starter as default choice (especially if we would move forward with my 2nd discussion item)

This is minor and not really relevant as this is draft PR, but we already use prompts for ... prompts :P so would be good to not use multiple packages for similar thing (wanted to mentioned before you add more prompts :D)

@gillkyle
Copy link
Contributor Author

I think those are both great ideas, just switched inquirer for prompts 😅 , guess I should've looked through the existing cli commands a little more first.

@gillkyle gillkyle changed the title (cli): Prompt user for options (no args with gatsby new) feat(gatsby-cli): Prompt user for options (no args with gatsby new) May 17, 2019
@gillkyle
Copy link
Contributor Author

This now opens the starter library when an official starter isn't selected.

I do like @pieh's idea of showing a prompt to select a starter when no starter is supplied, though I think having the default starter being used with just a path defined is useful in places like the Quick Start where gatsby new gatsby-site is one less step to be explained. Maybe I'm being nitpicky though.

With the changes in this PR the behavior of entering commands with other combinations of args aren't changed, but resolves the weird error you get when you run gatsby new alone in a folder that isn't empty.

@pieh
Copy link
Contributor

pieh commented May 17, 2019

though I think having the default starter being used with just a path defined is useful in places like the Quick Start where gatsby new gatsby-site is one less step to be explained. Maybe I'm being nitpicky though.

This is very valid point. Selecting one of starters assume user already have some familiarity with Gatsby. Tho even that could be somewhat resolved with adding more context to selection (something like):

  • gatsby-starter-default - good to see what Gatsby is about
  • gatsby-starter-blog - directory structure and configured plugins to quickly jumpstart your markdown blog
  • gatsby-starter-hello-world - minimal, barebones project, no plugins or packages other than gatsby and react

But this isn't hill I want to die on ;)

@gillkyle gillkyle marked this pull request as ready for review May 20, 2019 14:16
@gillkyle gillkyle requested a review from a team as a code owner May 20, 2019 14:16
@gillkyle
Copy link
Contributor Author

The order of selections for starters right now aligns with their popularity of usage. The default starter is the most popular, but maybe because it is just the default when gatsby new is run without a starter given?

@gillkyle gillkyle added status: awaiting reviewer response A pull request that is currently awaiting a reviewer's response topic: cli Related to the Gatsby CLI type: feature or enhancement labels May 20, 2019
@DSchau DSchau self-assigned this May 23, 2019
@wardpeet
Copy link
Contributor

RIP @pieh XD

This is awesome!

wardpeet
wardpeet previously approved these changes Jun 21, 2019
Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

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

I think this one is ready to get merged! Great work @gillkyle 💪.

if change reporter.log in to reporter.info I would be super happy

packages/gatsby-cli/src/init-starter.js Outdated Show resolved Hide resolved
Co-Authored-By: Ward Peeters <ward@coding-tech.com>
Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

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

Awesome! 💪 Woop woop, we're merging this one!

@wardpeet wardpeet added bot: merge on green Gatsbot will merge these PRs automatically when all tests passes and removed status: awaiting reviewer response A pull request that is currently awaiting a reviewer's response labels Jun 21, 2019
@gatsbybot gatsbybot merged commit 99fb7b4 into gatsbyjs:master Jun 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: merge on green Gatsbot will merge these PRs automatically when all tests passes topic: cli Related to the Gatsby CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants