1.0.0 • Published 5 years ago

create-react-components-script v1.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

Create React Components Script

A node script to easily create both Functional and Class React components.

About

While building up my React projects I found myself creating the same directory structure for all the new components I would create. Each component consisted of a folder named the same as the component with two files, the index.js and the actual component with the name of the component as the name of the file. So this node script when run, will use inquirer to prompt and create said files for you.

project
│   README.md
│   ...  
│
└───src
│   │   App.js
│   │   ...
│   │
│   └───components
│       │____Button
|       |   |__ Button.js
|       |   |__ index.js
│       │____NavBar
|       |   |____NavBar.js
|       |   |____index.js
│       │   
│   └───pages
│       │   Landing.js
|       |   |____Landing.js
|       |   |____index.js
│       │   Search.js
|       |   |____Search.js
|       |   |____index.js
│       │   ...

Instructions

  1. Clone this project and cd into it

git clone git@github.com:jtung23/create-react-components-script.git

cd create-react-components-script

  1. With Ubuntu 16.04+ to set up executable (this works for my computer)

    • Move react-component (not the .js file) to /usr/bin/
      • (example) sudo mv react-component /usr/bin/
      • Mac: /usr/local/bin
    • Restart terminal and test with command, react-component
    • Will prompt for class/function component and name
  2. To set up executable for other systems

    • pkg
    • npm install -g pkg
      • This package allows you to create the exectuable file for linux, macos, and windows