jsbot-cli v1.0.8
JSBOT
A small cli for react that generates a starter boilerplate. You can also generate new components with this package.
Install
Run
npm install -g jsbot-cli
You may need to sudo
it.
Why?
The jsbot cli has no actual structure and I noticed that when I start a project almost everytime I needed a router,state-management (redux, I choose redux to mange state).
And the second reason was that I had to manually copy-paste the code when I wanted to create a component. It is time consuming and redudant.
You can generate two components: Functional and Class Components :
Functional Component:
import React, {Component} from 'react';
const Comp = () => {
return (
<div className="Comp">
</div>
)
}
export default Comp;
Class Component:
import React, {Component} from 'react';
class Comp extends Component {
constructor(props){
super(props);
}
render(){
return (
<div className="Comp">
</div>
)
}
}
export default Comp;
You can generate these files anywhere. If it detects that the project directory has a ./src/components directory it will choose to generate them there.
Initialize project
Run
jsbot create <ProjectName>
This will ask you what project you want to inialize, a new project with the boilerplate in place with following project structure :
project
└─ node_modules
└─ public
└─ src
│ └─ Assets
│ │ │ logo.png
│ │ └─ styles
│ │ └─ images
│ └─ Components
│ │ └─ loader
│ │ │ │ index.js
│ │ └─ home
│ │ │ │ actions.js
│ │ │ │ constants.js
│ │ │ │ index.js
│ │ │ │ reducer.js
│ └─ Containers
│ │ └─ Homepage
│ │ │ │ index.js
│ └─ Reducers
│ │ │ index.js
│ └─ Store
│ │ │ index.js
│ └─ Services
│ │ │ example.service.js
│ │ App.js
│ │ App.css
│ │ App.test.js
│ │ index.js
│ │ index.css
│ │ routes.js
│ .gitignore
│ LICENSE
│ package.json
│ package-lock.json
│ README.md
currently react project in working and soon other project will come too.
Generate Component
Run
jsbot gc <Path/ComponentName || ComponentName>
This will create a folder of your component name, and a class component js file of the same name. You can also give paths to the component name for example :
jsbot gc test/testcomp1
=> will create a testcomp1 component within test folder inside Components folder (and make it if it doesn't exist).Options
Create a functional component
jsbot gc <Path/ComponentName || ComponentName> -f
orjsbot gc <Path/ComponentName || ComponentName> --functional
Create a component without style css file
jsbot gc <Path/ComponentName || ComponentName> -s
orjsbot gc <Path/ComponentName || ComponentName> --nostyle
Create a component with redux and related files
jsbot gc <Path/ComponentName || ComponentName> -r
orjsbot gc <Path/ComponentName || ComponentName> --redux
Create a component with test file
jsbot gc <Path/ComponentName || ComponentName> -t
orjsbot gc <Path/ComponentName || ComponentName> --test
Create a component but don't wrap it in a folder
jsbot gc <Path/ComponentName || ComponentName> -n
orjsbot gc <Path/ComponentName || ComponentName> --nofolder
Generate Service
Run
jsbot gs <Path/ServiceName || ServiceName>
This will create a file with a ServiceName js file. You can also give paths to the service name for example :
jsbot gs test/testservice1
=> will create a testservice1 service within test folder inside Services folder (and make it if it doesn't exist).
Utility Commands
- Use any npm script command from package.json using following cmd
Run
jsbot run <script_name>
This will execute that script for you. You can use above command as follow, for example :
To run application
jsbot run
To run application
jsbot run start
To run application testing
jsbot run test
- intsall you packages using below command
jsbot install [package name(s)]
This command will install all the given packages, Usage:
jsbot install jsbot-cli
ENJOY!