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

[RFC] Decouple the CLI and the component templates #17

Closed
rthor opened this issue Apr 14, 2017 · 0 comments
Closed

[RFC] Decouple the CLI and the component templates #17

rthor opened this issue Apr 14, 2017 · 0 comments

Comments

@rthor
Copy link
Owner

rthor commented Apr 14, 2017

It would be great if we can remove the link between the package version and the templates that the CLI uses to generate new components. Currently, it's really awkward to change a template, say fix a typo, then all users need to update their global cra-generate version, which, tbh, no one does.

The solution

I propose that we move the templates to a different package and have cra-generate install a new version per project (think npm install --save-dev cra-generate-templates@latest). Doing it like this, we get a fresh version of the templates for each project that uses cra-generate and we can utilize npm's caching.

Here's how I imagine the flow:

Use in a new project:

$ cra-generate some-component
  • This adds a dev-dependency to you package.json:
    { 
      "devDependency": {
        "cra-generate-templates": "[some version]"
      } 
    }  
  • Then proceeds to generate the component based on this new template.

Use in a project that already installed the templates:

$ cra-generate some-component
  • Checks if a new version of the templates has been released and prompts you to update to the latest version, or use the current version.
  • Then proceeds to generate the component based on this new template.

Use offline:

  • cra-generate should have a dependency on the templates itself and use in case of network loss.

Drawbacks

  • It adds a devDependency to the project that has nothing to with building, running or testing it.
  • Now we have more packages to maintain, will probably change this to a monorepo.

Other possible solutions

  • Always download new templates:
    • Download directly from GitHub and simply use curl (or similar) to skip the dependency step, update checks and project overhead.
    • This will be harder to cache and more complicated to implement (I think).
    • The same project might start getting a new template for components that don't match existing ones (git tags might solve that though).
    • Is this even realistic?
@rthor rthor closed this as completed Jul 9, 2017
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

No branches or pull requests

1 participant