ReactJs module/directory/files creator.
This CLI tool will help you to create a file structure and boilerplate for the component.
- Clone the repo
git clone git@github.com:NaveenPantra/create-react-component.git
. - Navigate to
create-react-component
. - Run
npm link
(this will makecrc
as you command). - Now run
crc
at any place to run the repo.
The file index.js
will be created from a file index.ejs
and the template engine ejs
will parse the content based on condition we pass and generate the output.
- Input
lib/fileData/index.ejs
<% if (isTypeSafe) { %>//@flow<% } %>
import React from 'react'
<% if (isTypeSafe) { %>import type { Node } from 'react'<% } %>
import use<%= componentName %>Styles from './index.styles'
<% if (isTypeSafe) { %>import type { <%= componentName %>Props } from './index.types'<% } %>
const <%= componentName %> = (props<% if (isTypeSafe) { %>: <%= componentName %>Props<% } %>)<% if (isTypeSafe) { %>: Node<% } %> => {
const classes = use<%= componentName %>Styles()
return <div className={classes.root}></div>
}
export default <%= componentName %>
- Output
/ComponentName/index.js
//@flow
import React from 'react'
import type { Node } from 'react'
import useComponentNameStyles from './index.styles'
import type { ComponentNameProps } from './index.types'
const ComponentName = (props: ComponentNameProps): Node => {
const classes = useComponentNameStyles()
return <div className={classes.root}></div>
}
export default ComponentName
- Enter component name
- Choose predifined File structure
- Confirm file structure
- Choosing wether custom file are typed or not.
- Choosing files (before selecting)
- Choosing files (after selection selecting)
- Comfirm custom files