-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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): Better suggestions #12392
feat(gatsby-cli): Better suggestions #12392
Conversation
Who uses `meant`: This package is used by NPM. Implementation: Used to mimic the same UX of giving command suggestions, upon failure to provide correct command Additional Reasons to use package: - Zero Dependencies attached - Only 30 lines of POJO - very lightweight - Very few issues with current versions Please checkout: https://www.npmjs.com/package/meant
This code has been duplicated from NPM 6.8.0 with minor tweaks. Tweaks: - Style changes of using string template literals over single quotes - newlines - \n added to the end to line 10 and line 13, to make the code more developer friendly
Line 328 - alter demandCommand - message string `Pass --help ...` will not show, because cli.fail method (330 line) is utilise. Thus message string has been moved to function 285. Another reason it has been moved there is organise al suggestions into one place Line 318 - showHelpOnFail could not get access to `yargs` thus cli.fail function was used instead Line 319 - `recommendCommands`, did not recommend commands were not very accurate, thus cli.fail was used configured more specific commands and show multiple command suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, @anthonytranDev 👍
Left a small comment!
|
||
cli.showHelp() | ||
report.log(suggestion) | ||
report.log(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be log the msg
as well?
~/Code/gatsby/www feat/gatsby-cli-suggestions*
❯ ./node_modules/gatsby-cli/lib/index.js ne .
Usage: node_modules/gatsby-cli/lib/index.js <command> [options]
Commands:
develop Start development server. Watches files, rebuilds, and hot reloads if something changes
build Build a Gatsby project.
serve Serve previously built Gatsby site.
info Get environment information for debugging and issue reporting
clean Wipe the local gatsby environment including built assets and cache
repl Get a node repl with context of Gatsby environment, see (add docs link here)
new [rootPath] [starter] Create new Gatsby project.
Options:
--verbose Turn on verbose output [boolean] [default: false]
--no-color Turn off the color in output [boolean] [default: false]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Did you mean this?
new
Unknown arguments: ne, .
In this case, maybe we can do without the Unknown arguments
bit. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this is good to have for future proofing as correctly pointed out by @pieh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to let you know, I decided to log the msg
as Unknown arguments: <args>
as it clearly states the mistakes the user has made.
This will help Newcomers and Junior Developers like myself take up Gatsby faster.
The ethos here is copy a Rust Lang level of stderr, as to makes it so obvious, that it makes Gatsby easier to adopt
Nonetheless I've been thinking of some improvements, that can be made to make the Unknown arguments: <args>
part more readable and aesthically pleasing to Gatsby Community
I've already got some ideas, plus it would be nice to hear back on what you guys think 😄
Holy buckets, @anthonytranDev — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! |
Published in gatsby-cli@2.4.14 |
Description
Gatsby-cli will give more accurate suggestion(s) upon fail.
Related Issues
This is #12078