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

override prompts with command line arguments #6117

Closed
wants to merge 3 commits into from
Closed

override prompts with command line arguments #6117

wants to merge 3 commits into from

Conversation

navtoj
Copy link

@navtoj navtoj commented Aug 20, 2022

This adds support for automatically answering the interactive prompts in environments where manual entry is not possible; e.g. scripts, batch runs, etc.

Before

npm create svelte@latest project_directory

After

npm create svelte@latest project_directory --template=skeleton --types=typescript --eslint=true --prettier=true --playwright=true --overwrite=true

All arguments are optional.

  • --template= default, libskeleton, or skeleton

Screen Shot 2022-08-20 at 5 39 39 AM

  • --types= checkjs or typescript

Screen Shot 2022-08-20 at 5 39 42 AM

  • --eslint= true or false

Screen Shot 2022-08-20 at 5 39 45 AM

  • --prettier= true or false

Screen Shot 2022-08-20 at 5 39 48 AM

  • --playwright= true or false

Screen Shot 2022-08-20 at 5 39 51 AM

  • --overwrite= true or false

Screen Shot 2022-08-20 at 5 44 22 AM

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Aug 20, 2022

⚠️ No Changeset found

Latest commit: 9b0dfd3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Conduitry
Copy link
Member

Thank you for the PR. This has come up several times before, though, and is something we're not comfortable with for a couple reasons. If someone is running the CLI, they're likely going to always be pulling down the latest version, and we may occasionally add additional questions to the script. If they don't specify an option for one of them, what happens? Does the script suddenly become interactive again? If the user specifies at least one option, do we make assumptions about all of the other ones based on some default? If we reorganize some of the prompts, what do we do with CLI args that are now invalid? Any path we take here seems suboptimal.

As a compromise, the create-svelte package also exposes a programmatic API, which will respect semver (once SvelteKit is in general release). Any new prompts that must be answered will be a major version bump. Anything that changes the output in a way that's not a clear backwards-compatible improvement will also be a major version bump. If you need automated access to bootstrapping new projects, you can write a tiny script that calls this API and depends on create-svelte like it would any other dependency, with all the benefits of semver. And the majority of people - those just calling the CLI - will continue to get the latest one (no matter what its semver major version number is) and can just response to the prompts.

@JReinhold
Copy link

For anyone landing here, the Storybook team has released a community solution to this called create-svelte-with-args. It is a small CLI wrapper around create-svelte that allows you to create SvelteKit projects without the interactive prompts.

@Conduitry I've tried to be very explicit in the documentation stating that create-svelte-with-args is not supported nor endorsed by the Svelte core team. The last thing we want is for this to become a burden for you as maintainers because you've stated some very valid arguments above as to why you don't want to support this officially. Let me know if you have any thoughts on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants