Skip to content

Commit

Permalink
update readme for selector generation
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKott committed Jun 6, 2019
1 parent aba06e7 commit 597aaa2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
30 changes: 21 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* [components](docs/component.md)
* [middleware](docs/middleware.md)
* [reducers](docs/reducer.md)
* [selectors](docs/selector.md)

We're also working on generating _selectors_, _SCSS stylesheets_ and an _initial project setup_ for the redux store.
We're also working on generating _SCSS stylesheets_ and an _initial project setup_ for the redux store.

The code generated by *zwen-react* follows our [best practices](docs/introduction.md) at Zweitag and is therefore highly opinionated.

Expand All @@ -21,6 +22,7 @@ The code generated by *zwen-react* follows our [best practices](docs/introductio
- [Components](#components)
- [Middleware](#middleware)
- [Reducers](#reducers)
- [Selectors](#selectors)
1. [Advanced Usage](#advanced-usage)
- [Sorting](#sorting)
1. [Architecture](#architecture)
Expand Down Expand Up @@ -58,27 +60,27 @@ If you prefer tabs or any other kind of indentation you may define it here.
## Usage
### Actions
```
zwen action path/to/actionName
zwen action path/to/myAction
```
This will create or update the action creators (`src/actions/path/to/creators.js`) and tests (`src/actions/path/to/creators.test.js`) with the `actionName`. If you choose to, it will also create or update `src/actions/path/to/types.js` with the type `ACTION_NAME`.
This will create or update the action creators (`src/actions/path/to/creators.js`) and tests (`src/actions/path/to/creators.test.js`) with an action called `myAction`. If you choose to, it will also create or update `src/actions/path/to/types.js` with the type `MY_ACTION`.

It will also wire up exports along the path and create new `index.js` files if they don't exist.

([More about actions](docs/action.md))

### Components
```
zwen component path/to/component
zwen component path/to/myComponent
```
This will create a new component file (`src/components/path/to/Component.js`). You can choose if the component should be connected to the store, or – if not – should be set up with props.
This will create a new component file (`src/components/path/to/MyComponent.js`). You can choose if the component should be connected to the store, or – if not – should be set up with props.

You also have the option to generate a class component by supplying a flag:
```
zwen component path/to/component --classComp
zwen component path/to/myComponent --classComp
```
or
```
zwen component path/to/component -c
zwen component path/to/myComponent -c
```

([More about components](docs/component.md))
Expand All @@ -95,15 +97,25 @@ It will also export the new middleware from the folder's `index.js` file.

### Reducers
```
zwen reducer path/to/reducer
zwen reducer path/to/myReducer
```
This will create a new reducer file (`src/reducers/path/to/reducer.js`) and a test file (`src/reducers/path/to/reducer.test.js`).
This will create a new reducer file (`src/reducers/path/to/myReducer.js`) and a test file (`src/reducers/path/to/myReducer.test.js`).

It will also wire up exports along the path and create new `index.js` files if they don't exist.

([More about reducers](docs/reducer.md))
([More about selectors](docs/selector.md))

### Selectors
```
zwen selector path/to/mySelector
```
This will create or update the file located at `src/selectors/path/to.js` and a test file (`src/selectors/path/to.test.js`). The new selector will be named `mySelector`. It will also wire up the imports and create new `index.js` files if they don't exist.

You will get a list with all selectors defined in reducer files (we're working on adding complex selectors to that list as well), from which you choose the ones to use in your new selector. Type `done!` when your selection is complete.

([More about selectors](docs/selector.md))

## Advanced Usage
### Sorting
When generating exports in `index.js` files *zwen-react* automatically sorts everything alphabetically. This might become a problem as soon as you want to have a certain order to your exports (e.g. middleware).
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zwen-react",
"description": "Code generator CLI for projects using react and redux",
"version": "0.8.2",
"version": "0.8.3",
"author": "Zweitag GmbH @zweitag",
"contributors": [
"Alex Kott <[email protected]>",
Expand Down

0 comments on commit 597aaa2

Please sign in to comment.