https://github.com/dhilman/compogen
A CLI tool for creating new React components with custom templates
https://github.com/dhilman/compogen
cli generator react react-component-generator react-template storybook
Last synced: about 2 months ago
JSON representation
A CLI tool for creating new React components with custom templates
- Host: GitHub
- URL: https://github.com/dhilman/compogen
- Owner: dhilman
- License: mit
- Created: 2023-04-04T00:04:11.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-04T10:45:33.000Z (about 3 years ago)
- Last Synced: 2024-04-26T12:04:19.800Z (about 2 years ago)
- Topics: cli, generator, react, react-component-generator, react-template, storybook
- Language: JavaScript
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Create Component CLI
A CLI tool for creating new React components with custom templates.
## Features
- Creates functional components with or without refs
- Allows custom templates via `template.js` file
- Optional storybook and index files (from template)
## Setup
### Installation
```bash
npm install --save-dev compogen
```
### Configuration
Add the following to your `package.json`:
```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:
```typescript
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;
}
}
```
### Usage
```bash
# help
npm run compogen -- --help
```
```bash
npm run compogen -- [options] componentName
```
---
### Global Installation
You can install the CLI globally, so that you can use it for any project.
```bash
npm install -g compogen
```
#### Usage
```bash
compgen [options] componentName
```