RCG
A Node.js library and CLI for generating React components.
Features
- Generates a React component based on a given name
- Creates the component and accompanying files and folders
- Takes time out of generating files and folders for React components
Install
npm i @anephenix/rcg
Usage
There are 2 ways that you can use RCG - via CLI, or as an NPM module in your Node.js code.
via CLI
After you have installed rcg, cd into your React app, and run this:
npx rcg MyComponent
This will do the following:
- Create a folder called 'my-component' in the src/components folder
- Inside that folder, it will create these files:
- A React component file called MyComponent.js
- A styling file called MyComponent.scss
- A test file called MyComponent.test.js
via NPM
You can load it this way:
const path = require('path');
const rcg = require('@anephenix/rcg');
const componentName = 'MyComponent';
const srcFolderPath = path.join(process.cwd(), 'src', 'components');
(async () => {
await rcg(componentName, srcFolderPath);
})();
Running Tests
npm t
License and Credits
© 2019 Anephenix OÜ. RCG is licensed under the MIT License.