You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-create-helper

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-create-helper - npm Package Compare versions

Comparing version

to
1.0.0

17

index.js

@@ -53,8 +53,19 @@ #! /usr/bin/env node

let jsContent = require("./templates/component")({basename});
let actionContent = require("./templates/action")({basename});
let reducerContent = require("./templates/reducer")();
let reducerContent = require("./templates/reducer")({basename});
if(typeof config !== "undefined" && typeof config.template !== "undefined"){
if(config.template.component){
jsContent = require( path.resolve(process.cwd(), config.template.component) )({basename});
}
if(config.template.action){
actionContent = require( path.resolve(process.cwd(), config.template.action) )({basename});
}
if(config.template.reducer){
reducerContent = require( path.resolve(process.cwd(), config.template.reducer) )({basename});
}
}
let indexContent = `import ${basename} from "./${basename}";

@@ -132,3 +143,3 @@ export default ${basename};

program
.version('0.1.6')
.version('1.0.0')
.on('--help', function(){

@@ -135,0 +146,0 @@ console.log(' Examples:');

9

package.json
{
"name": "react-create-helper",
"version": "0.1.6",
"description": "create components, reducers and actions easier",
"version": "1.0.0",
"description": "create components, reducers and actions, does not overwrite, make your own templates",
"keywords": [

@@ -12,6 +12,9 @@ "react",

"react redux action",
"create react redux action",
"redux reducer",
"react redux reducer",
"create redux reducer",
"cli",
"rch"
"rch",
"create-react"
],

@@ -18,0 +21,0 @@ "main": "index.js",

@@ -1,3 +0,13 @@

# react-create-helper
react-create-helper
===============
CLI tool to help with creating components, reducers and actions.
Features
--------
#####Create react-* with predefined templates
- Components
- Redux actions
- Redux reducers
### Install

@@ -8,11 +18,23 @@

```
Options
-------
Add new string to `package.json` with name `"react-create-helper"` <br>
- `base` (string) - Base dir for components, actions, and reducers. Default - project root (`./`)
- `actionsDir` (string) - Base dir for actions, extends `base`. Default - project root (`./`)
- `reducersDir` (string) - Base dir for reducers, extends `base`. Default - project root (`./`)
- `styleExtension` (string) - Extensions for generated style file. Default - `css`
- `componentName.prepend` (string) - Prefix for generated component. Default - `undefined`
- `componentName.append` (string) - Suffix for generated component. Default - `undefined`
- `template.component` (string) - Path for your own component template. Default - `undefined`
- `template.reducer` (string) - Path for your own reducer template. Default - `undefined`
- `template.action` (string) - Path for your own action template. Default - `undefined`
## Options
You can provide options in your package json like that
## Example options
```$js
"react-create-helper": {
"base": "./src",
"actionsDir": "actions",
"reducersDir": "reducers",
"actionsDir": "Actions",
"reducersDir": "Reducers",
"componentName": {

@@ -22,20 +44,14 @@ "prepend": "My",

},
"styleExtension": "css"
"styleExtension": "scss"
}
```
**base**: *base dir for components from your project root*
**actionsDir**: *base dir of actions from base*
### Basic usage
**Cli options**
- `-c` generate component (default)
- `-r` generate reducer
- `-a` generate action
- `-h` help (options and usage examples)
**reducersDir**: *base dir of reducers from base*
**componentName**: *also you can configure prefix and suffix of component name.*
**styleExtension**: *style extension)))*
######Does not overwrite files
### Generate component
```$bash

@@ -53,20 +69,7 @@ rch Header

```
Also you can specify path like `rch my/path/Header`
### Generate action & reducers
#### `package.json`
```$js
"react-create-helper": {
"base": "./src",
"actionsDir": "Actions",
"reducersDir": "Reducers",
"componentName": {
"prepend": "My",
"append": "Component"
},
"styleExtension": "css"
}
```
##### Generate action & reducers
```bash
$ rch -c Example
$ rch -a ExampleAction

@@ -79,6 +82,2 @@ $ rch -r ExampleReducer

src
├── MyExampleComponent
│ ├── MyExampleComponent.js
│ ├── MyExampleComponent.css
│ └── index.js
├── Actions

@@ -90,2 +89,53 @@ │ └── ExampleAction.js

Also you can use `rch -h`. To see all options and usage examples;
## Define own templates
```$js
"react-create-helper": {
"template": {
"component": "rch_templates/component.js",
"reducer": "rch_templates/reducer.js",
"action": "rch_templates/action.js",
},
}
```
######Base template
`{basename}` is the name you provided with `rch -c {basename}`
`./rch_templates/component.js`
```js
module.exports = ({basename}) =>
`import React, { Component } from 'react';
import { connect } from 'react-redux';
class ${basename} extends Component {
render() {
return (
<div></div>
)
}
}
const mapStateToProps = (state) => {
return {
}
};
const mapDispatchToProps = (dispatch) => {
return {
exampleName: (exampleProps) => {
dispatch(exampleActionName)
}
}
};
export default connect(mapStateToProps, mapDispatchToProps)(${basename});
`;
```
The same for action, and reducer.
######Have fun