-
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(create-gatsby): Add create-gatsby #27703
Conversation
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 looks fantastic already! 😍
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.
It would also be fantastic if we could already figure out how to automatically test this to ensure it works as expected. How we're going to best do that is honestly a bit of a questionmark in my head, I've never unit tested a CLI...
If we can work out how to do the interactive input we could test it by calling the |
The |
@@ -0,0 +1,8 @@ | |||
{ | |||
"none": "No (or I'll add it later)", |
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.
enquirer
seems to have some internal logic to use the message
if the name
is falsy, so I just added a string to check against.
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.
Haha. I was really confused this morning. I'd done literally the same fix yesterday but forgot to commit it. When I pulled it had already been changed, and I couldn't work out why it was still showing as uncommitted locally! Good solution 😉
I've disabled the tests until we can work out how to reproduce the failures |
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.
Small nits only, let's merge this into master?!
* feat(create-gatsby): Add support for plugin dependencies * Fix extra plugin handling
Co-authored-by: Max Stoiber <contact@mxstbr.com>
…feat/create-gatsby
installTimer.start() | ||
reporter.info(`Installing ${plugin}`) | ||
try { | ||
const result = await NPMPackage.create({ root }, { name: plugin }) |
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.
@ascorbic a bit late to the game but is there a reason this create call is awaited? It makes package installs serial — if you just return the promise, the NPMPackage provider will batch up all calls made at the same time into one npm/yarn install call.
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.
@KyleAMathews Afaict, this should still work, because we're doing the calls to installPluginPackage
in parallel in an async function. It will "await", but the async function will have already returned the promise so they'll still run in parallel
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.
ahhh yeah 😅 async is hard. Carry on!
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.
When it messes with my head, I find it helpful to think of an async function as starting with return new Promise
...
This is a new command
create-gatsby
, which creates and configures a new site, a little likegatsby new
on dexamethasone.To run it:
or
Goals
The command needs to run quickly, and get the user with a working site, configured to their needs, with a minumum number of steps.
The command aims to be as small as possible, because it has to download and install it before running. The target is <100kB, gzipped including dependencies. The current size is
75kB95kB.There should be no need for flags or arguments, because these are not easily discoverable. Instead it should use interactive configuration.
Architecture
To keep the install fast, the
create-gatsby
package does not depend on any gatsby packages except core-utils. When running, it usesenquirer
to ask a number of questions to determine plugins to install. It starts by cloning and installinggatsby-starter-hello-world
. It uses a stripped-down version of theinitStarter
command from gatsby-cli for this.To install plugins it will use the copy of gatsby-cli in the newly-installed site. To do this, it resolves the
gatsby-cli
package relative to the site root, then loadscreate-cli
. It then passes theplugin add
args to that function, which runs it as if it had been invoked directly.[ch17789]
[ch17925]
[ch17779]