A CLI tool for creating new React components with custom templates.
- Creates functional components with or without refs
- Allows custom templates via
template.js
file - Optional storybook and index files (from template)
npm install --save-dev compogen
Add the following to your package.json
:
{
"scripts": {
"compogen": "compogen"
}
}
Further configuration is done via a template.js
file in the root directory of your project. This file should export an object with the following properties:
interface Config {
dir: string;
ext: 'ts' | 'js';
i: boolean;
n: boolean;
t: 'functional' | 'functionalWithRef';
componentName: string;
s: boolean;
templates?: {
functional?: string;
functionalWithRef?: string;
storybook?: string;
index?: string;
}
}
# help
npm run compogen -- --help
npm run compogen -- [options] componentName
You can install the CLI globally, so that you can use it for any project.
npm install -g compogen
compgen [options] componentName