WebstoneHQ / webstone-plugins

Start your next full-stack application with Webstone and configure it as you go.
MIT License
85 stars 6 forks source link

Refactor create-webstone-app #388

Closed Cahllagerfeld closed 1 year ago

Cahllagerfeld commented 1 year ago

closes #377

features:

changeset-bot[bot] commented 1 year ago

🦋 Changeset detected

Latest commit: cdd05cb2d0eaf44479d710828ef1d703378db04c

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

This PR includes changesets to release 1 package | Name | Type | | ------------------- | ----- | | create-webstone-app | Minor |

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

mikenikles commented 1 year ago

I've been thinking about this PR today 🤔. With the new structure you developed, do we still need a template structure when someone creates a new Webstone plugin?

If you haven't see this comment yet,, please have a look – it's essential to what I'm about to say 😄.

I'm under the impression that a Webstone plugin, at a very high level, is nothing else other than a SvelteKit lib project, with a src/cli directory and a few changes as outlined in the linked comment above.

I expected the flow to create a new plugin to be something like this:

  1. npm create webstone-app --type plugin
  2. Script prompts for a few things, including whether the plugin provides CLI commands
  3. Script uses create-svelte (I think that's what it's called) to generate a SvelteKit lib project
  4. If the user said the plugin provides CLI commands, the script creates src/cli, configures tsup, etc.
  5. Script configures whatever is necessary for the plugin (see comment linked above)
  6. Done

My worry with the template structure is that it requires maintenance and may be out of sync with a default SvelteKit library project. Maybe we're ok with this 🤔?! As a con to my scripted approach above, that also requires maintenance so we have to discuss what's more effort.

One more thought: I have a dream where any existing SvelteKit library package can be converted to a Webstone plugin with a single command. If we also use a SvelteKit lib project as our base and script the changes we need, we could more easily apply that to an existing SvelteKit lib project.

I'm curious to hear your thoughts on that 🙏

Cahllagerfeld commented 1 year ago

I took the template approach becaseu Svelte and Vite are doing this. My worry with this codemod approach is, that it gets unmaintainable adjusting all the things in package.json (we could use a template for it though). I also had it in mind though

mikenikles commented 1 year ago

Incredible 🤩! I created a new app and a new plugin, both without any issues. I'll merge it, get it released to NPM and use it to re-create the request-logger plugin.