Coder Social home page Coder Social logo

cra-generate's Issues

Improve code quality

I'ld really like to see these things fixed in this project:

  • Add Prettier
  • Enforce formatting per commit
  • Add Flow
  • Add code coverage
  • Type check and run test suit in CI.

semi option from package.json is ignored

When setting semi: false in package.json the false value is ignored.
The reason is twofold:
1 config.js (line 26) always overwrites the value from both defaultOptions and package.json
2 --no-semi means that if you don't specifically include this option when you use cra-generate (in the command line) the value will be set to semi: true

So reason 2 makes sure that the command line sets the option to true if you don't explicitly set it to false and reason 1 makes sure that the defaultOptions and package.json is ignored completely

[RFC] Decouple the CLI and the component templates

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?

Add tests

Need to test the transformers at the very least.

Skipping css file

For js-in-css projects, we don't want a css file for components. Would be nice to have a project setting to skip that, like we can already skip the tests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.