-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
create-svelte: Skip prompts by passing args to CLI #6982
Conversation
🦋 Changeset detectedLatest commit: 48b1e45 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
const args = await yargs(hideBin(process.argv)).coerce('types', (arg) => | ||
arg === 'none' ? null : arg | ||
).argv; |
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 makes it so that --types=none
ends up as { types: null }
internally.
Alternatively we could make the arg match one-to-one either by making the arg null
instead of "none"
, or changing the internal null
to be "none"
everywhere.
Thank you, but this isn't something we want to add. See, most recently, #6117 (comment) for more information. |
Oh wow sorry for wasting your time. My searching came up empty. |
Note that you can still use |
@dummdidumm the problem is that then you need to install the package and you can not use it through |
@Ni55aN I've created a separate package for this that might suit your needs. I attempt to keep it up-to-date regularly. https://github.com/storybookjs/create-svelte-with-args |
@JReinhold thanks, opted for this package ✔ |
This PR makes it possible to skip some or all prompts when creating a new SvelteKit project with the
create-svelte
package. eg.:The problem
In Storybook we have a system for creating new projects with the different frameworks programmatically, to continuously ensure Storybook works out of the box with all the frameworks. But that's a bit hard for us to do with SvelteKit, because
create-svelte
is an interactive experience and thus not easy to automate.Instead of hacking around it internally in Storybook I thought it would be better to solve it for everyone. This is also useful in tutorial/guide situations where an author wants to simplify the learning path by removing prompts that a beginner might not understand.
The solution
As per the example in the
prompts
docs,yargs
is used to implicitly override any of the prompts if they are passed as named arguments. The implicitness is important here, because it means that if we add or change the prompts later they will automatically be overwritable by args.I have not documented this feature in the official docs because there didn't seem to be a good place to do it. I'm open to add it somewhere though if you think it makes sense.
It is however documented in the package's readme similarly to how the programmatic API is documented.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0