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] create-svelte: Add prompt for choosing adapter #2479

Closed
wants to merge 4 commits into from

Conversation

ambarvm
Copy link
Contributor

@ambarvm ambarvm commented Sep 23, 2021

Fixes #2459

Add a new prompt for adapter. The default option is "I'll add it later or use a community-provided adapter".

Updated:
image

image

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 pnpx changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Sep 23, 2021

🦋 Changeset detected

Latest commit: d562724

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-svelte Patch

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 dest = path.join(cwd, file.name);
mkdirp(path.dirname(dest));
fs.writeFileSync(dest, file.contents);
}
});

if (options.adapter) {
pkg.devDependencies[options.adapter.npm] = 'next';
Copy link
Member

Choose a reason for hiding this comment

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

Should the version be the actual value of the latest release instead of the tag?
People installing like this would get left behind once adapters are released as 1.0 which switches to latest tag.

As a workaround for having to pull every adapter version for now we could use "^1.0.0-next.0" which should match all releases of the adapters including "1.x.y". It won't match new majors after 1 eg "2.x.y" or new prereleases after 1.0.0 eg "1.1.2-next.1"

Copy link
Member

Choose a reason for hiding this comment

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

Another, more general thing: right now the logic for modifying the files is different and works by overwriting files using the files in https://github.com/sveltejs/kit/tree/master/packages/create-svelte/shared . So the overwrites should be added there, and there's also likely some other logic in bin.js

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dummdidumm I tried using the shared files for this but would end up making 10 different svelte.config.js and that would make future changes more difficult. Can use it for adding adapter to devDependencies but the current logic will still be needed if we want to include community adapters as discussed here #2459 (comment)

@dummdidumm
Copy link
Member

I approve the change but not its current implementation, at least not yet. It's very different to what is present and having two different styles to add prompts is confusing. Honestly I was never a big fan of the refactoring to use these folders, which now shows as it would result in many more folders needed to be created. I'm okay to merge this after we agree on how to refactor this into a consistent approach.

@benmccann benmccann changed the title create-svelte: Add prompt for choosing adapter [feat] create-svelte: Add prompt for choosing adapter Oct 16, 2021
@bluwy
Copy link
Member

bluwy commented Oct 18, 2021

I think the folder-based approach is great, but the bottleneck now is merging svelte.config.js. To do that, ideally we have some sort of meta file in each folder to show what needs to be added, similar to how package.json merging works. With that we should be able to have one folder for each adapter, which also allows us to recommend platform-specific configs, e.g. netlify.toml.

@ambarvm
Copy link
Contributor Author

ambarvm commented Oct 18, 2021

If we want to provide an option to choose from a list of community adapters fetched from an API, we will still need some runtime logic outside the folders similar to the current implementation.
I guess I can modify the svelte.config.js file without the // insert: placeholders if that is desirable.

@bluwy
Copy link
Member

bluwy commented Oct 19, 2021

I don't think we would provide an option for community adapters from an API in the future, since it implies something that we endorse but we don't have control of it. (Though that's just my opinion)

Nevertheless, I think this is safe to merge as is. Per dummdidumm comment, the refactoring we can do after this IMO is to build a way to merge svelte config files to use to folder based structure instead. But I'll see if the other maintainers have an opinion on this.

@bluwy bluwy mentioned this pull request Nov 15, 2021
@Rich-Harris
Copy link
Member

We ended up going in a different direction — #2867 — so I'm going to close this. Thank you!

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.

Include a default adapter for the demo project
6 participants