An easy to use cli-tool that simplifies the process of creation of React components.
$ git clone https://github.com/aleksandryackovlev/crc.git
$ cd crc
$ make install
Create React component
crc create [-f] [-s] [-t <TEMPLATE>] [-d <DIRECTORY>] [ -l <LIFECYCLE_METHODS>]
[-h <HANDLERS>] [-m <METHODS>] <COMPONENT_NAME> [<PROPS>]
If the placeholder for an option is not defined in a template, this option will not appear in the resulting file even if it is set in the command.
-f
Create a file component.
-s
Add styles to a new component. This option is ignored if -f options is set.
-t <TEMPLATE>
Create a component from the template with the name <TEMPLATE>
. By default it is set to the "default" template.
-d <DIRECTORY>
Create a component in the <DIRECTORY>
. By default it is set to the current working directory.
-l <LIFECYCLE_METHODS>
Add a given list of lifecycle methods. Methods should be given as a string that consits of method names separated by colons.
-h <HANDLERS>
Add a given list of arrow functions. Handlers should be given as a string that consits of their names separated by colons.
-m <METHODS>
Add a given list of methods. Methods should be given as a string that consits of their names separated by colons.
<COMPONENT_NAME>
The name of a component that should be created written in camelcase.
<PROPS>
A list of props that should be added to a component. Every prop should be written as a separate parameter and should consist of the name, propType and defaultProp separated by colons. If a defaultProp is not given the prop is considered as a required one.
Create a directory with the SomeComponent component from the default template:
$ crc create SomeComponent
Create a directory with the SomeComponent component from the "some-template" template:
$ crc create -t some-template SomeComponent
Create a file component from the "some-template" template:
$ crc create -t some-template -f SomeComponent
Create a directory with the SomeComponent component from the "some-template" template adding styles:
$ crc create -t some-template -s SomeComponent
Create a directory with the SomeComponent component from the "default" template adding a given list of props:
$ crc create SomeComponent "somePropName:PropType:defalutValue"
Create a directory with the SomeComponent component from the "default" template adding a given list of lifecycle methods:
$ crc create -l "componentDidMount:componentWillUnmount" SomeComponent
Create a directory with the SomeComponent component from the "default" template adding a given list of handlers:
$ crc create -h "handleChange:handleClick" SomeComponent
Create the SomeComponent component with a given list of handlers:
$ crc create -m "handleChange:handleClick" SomeComponent
Create, edit or delete local crc config files for different directories
crc config <COMMAND> [<DIRECTORY>]
The command handles local config files. If there is no config file in PWD, it is going to be looked for in ancestor directories. The first file, that is found in a list of ancestor directories, is considered as the active local config. Config files are going to be edited in the default EDITOR.
create [<DIRECTORY>]
Create a local config file component. By default <DIRECTORY>
is set to PWD
edit
Edit the active local config file component if it exits.
delete
Delete the active local config file component if it exits.
Create a config file in a current directory:
$ crc config create
Edit the active config file if it exists:
$ crc config edit
Delete the active config file if it exists:
$ crc config delete
Create, read, update or delete templates
crc template <COMMAND> [-n] [-j <JS_FILE_EXTENTION>] [-s <CSS_FILE_EXTENTION>] <TEMPLATE>
The command handles template files. Template files are going to be edited in the default EDITOR.
create <TEMPLATE>
Create a new template with the name <TEMPLATE>
.
Options:
-n
Create a template without opening its files in the EDITOR.
-j <JS_FILE_EXTENTION>
Set the extention of a component template. By default it is set to "js".
-s <CSS_FILE_EXTENTION>
Set the extention of a styles template. By default it is set to "css".
copy <OLD_TEMPLATE> <NEW_TEMPLATE>
Copy files from the <OLD_TEMPLATE>
to <NEW_TEMPLATE>
.
edit <TEMPLATE>
Edit files for the <TEMPLATE>
if this template exits.
delete <TEMPLATE>
Delete the <TEMPLATE>
if this template exits.
Create a new template:
$ crc template -j jsx -s sass create some_template
Edit the "some_template":
$ crc template edit some_template
Delete the "some_template":
$ crc config template delete some_template
Show help info
crc help [<COMMAND>]
Show version:
$ crc help version
Show usage info:
$ crc help usage
Show help info on the crc-create command:
$ crc help create