generate-cli-react

A simple React CLI for generating components.

Usage no npm install needed!

<script type="module">
  import generateCliReact from 'https://cdn.skypack.dev/generate-cli-react';
</script>

README

Generate React CLI

This tool provides fast creating React components and gets rid of copying, pasting and renaming files.

Installation

  npm install generate-cli-react --save-dev

Usage

This command create a folder with your component within default directory.

  npx generate-react component Box

You can also generate a few components at once.

  npx generate-react component Box Card Button

Example of the component files structure by default:

|-- /src
    |-- /components
        |-- /Box
            |-- Box.js
            |-- index.js

Options

You can also overwrite default options.

  npx generate-react component Box --withStyle --usePreprocessor scss

Example of the component files structure with options above:

|-- /src
    |-- /components
        |-- /Box
            |-- Box.js
            |-- Box.scss
            |-- index.js
Options Description Value Type Default Value
--path The path where you want the component to be generated. String ./src/components
--withStyle Creates a stylesheet file with this component. Boolean false
--useTypescript Creates the typescript component. Boolean false
--usePreprocessor Creates a stylesheet file used a preprocessor such as scss with this component. String ""
--useTest Creates test file with library enzyme or testingLibrary with this component. String ""