Skip to content

Commit d208167

Browse files
committed
Resolve bug with generation path & Add support for multiple config formats
1 parent cbe24b8 commit d208167

12 files changed

Lines changed: 459 additions & 110 deletions

File tree

.eslintrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ rules:
1414
no-console: off
1515
import/prefer-default-export: off
1616
no-param-reassign: off
17+
import/no-cycle: off

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
.idea
12
src

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# React Codegen CLI
22

33
React Codegen is a development tool to quickly generate React components.
4-
It helps you to speed up productivity in React projects and stop copying, pasting files
4+
It helps you to speed up productivity in React projects and stop copying, pasting files.
55

66
## Installation
77

@@ -22,8 +22,8 @@ Then add the following script to your `packages.json` file:
2222

2323
## Get started
2424

25-
`react-codegen` will look for a [configuration file](#configration-file) in root folder and use it if available.
26-
If no config file is found it will fallback to a default configuration.
25+
`react-codegen` will look for a [configuration file](#configuration-file) in root folder and use it if available.
26+
If no config file found it will fallback to a default configuration.
2727

2828
The following command can be used to generate code:
2929
```sh
@@ -32,14 +32,20 @@ npm run react-codegen
3232

3333
After running the command in the terminal,
3434
you can enter the name of the component and configure the generation of the files.
35-
When creating a react component, you are given the choice to modificate the component parts,
35+
When creating a React component, you are given the choice to modify the component parts,
3636
such as connecting the `useState`, `useEffect`, `propTypes` and so on.
3737

3838
![Demo](https://i.imgur.com/MVFvUq5.png)
3939

40-
## Configration file
40+
## Configuration file
4141

42-
Use `JSON` file to specify configuration information. This should be in the form of `react-codegen.json`.
42+
React codegen uses [cosmiconfig](https://github.com/davidtheclark/cosmiconfig) for configuration file support. This means you can configure it via:
43+
44+
- A `"react-codegen"` key in your `package.json` file.
45+
- A `.react-codegenrc` file, written in JSON or YAML, with optional extensions: `.json/.yaml/.yml` (without extension takes precedence).
46+
- A `.react-codegenrc.js` or `react-codegen.config.js` file that exports an object.
47+
48+
The configuration file will be resolved in the root folder of the project. If no configuration file found the default config will be used.
4349

4450
| Type | Value | Default | Description |
4551
|:------------:|:------------------------------------------------------------:|:--------------:|----------------------------------------------------------------------|

0 commit comments

Comments
 (0)