1.0.0 • Published 3 years ago

@sasa_djuric/react-cli v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
3 years ago

React Cli Header

code style: prettier License

Short description

Motivation

Examples

react create component button
rct c c text-input
react-cli c c container header
npx react-cli c h useInput

Installation

For NPM

npm install -g react-cli

For Yarn

yarn global add -g react-cli

Usage

react init

Generates a configuration file based on the prompt

react create component

Arguments

ArgumentDescription
typeType of component defined in the configuration file
\Name for the component. If you want to make a sub-component for an existing component, you can input a name like this: existing-component-name/new-component-name

Options

OptionAliasDescription
--class-cCreate a class component
--typescript-tpUse typescript
--style-sCreate a style file
--storyN/ACreate a story file
--proptypes-pInclude proptypes
--redux-rInclude redux
--test-tCreate a test file
--index-iCreate an index file with default export
--file-name \-fnSpecify the file name. If this argument is provided, the file naming config will be ignored
--path \N/ASpecify the path for the file relative to the project source path defined in the project configuration entry
--no-typescript-notpDon't use typescript
--no-style-nosDon't create a style file
--no-storyN/ADon't create story book file
--no-proptypes-nopDon't include proptypes
--no-redux-norDon't include redux
--no-test-notDon't create a test file
--no-index-noiDon't create an index file

react create hook

Arguments

ArgumentDescription
\Name for hook

Options

OptionAliasDescription
--typescript-tUse typescript
--no-typescript-notpDon't use typescript
--path \N/ASpecify the path for the file relative to the project source path defined in the project configuration entry

Configuration

ScopeType
projectProjectConfig
componentComponentConfig
styleStyleConfig
storybookStorybookConfig
testTestConfig
hookHookConfig

ProjectConfig

OptionTypeDescription
pathstringProject source path
typescriptbooleanUses typescript
fileNamingFileNamingDefine file naming

ComponentConfig

OptionTypeDescription
classbooleanCreate a class component
stylebooleanCreate a style file
storybooleanCreate a story file
proptypesbooleanInclude proptypes
reduxbooleanInclude redux
testbooleanCreate a test file
testIdbooleanAdds data-testid attribute on the element
indexbooleanCreate an index file
openbooleanOpen file in default editor after creating
pathstringSpecify the path for the file relative to the project source path defined in the project configuration entry
typescriptbooleanUse typescript
inFolderbooleanSave the file in its own folder
fileNamingFileNamingDefine file naming
overrideComponentOverrideConfigOverride configuration of style, storybook, or test

ComponentOverrideConfig

OptionType
styleStyleConfig
storybookStorybookConfig
testTestConfig

StyleConfig

OptionTypeDescription
typecss | scss | sass | less | styled-componentsType of styling technology
modulesbooleanUse css modules
pathstringSpecify the path for the file relative to the project source path defined in the project configuration entry
typescriptbooleanUse typescript (for css in js solutions)
inFolderbooleanSave the file in its own folder
fileNamingFileNamingDefine file naming

StorybookConfig

OptionTypeDescription
pathstringSpecify the path for the file relative to the project source path defined in the project configuration entry
typescriptbooleanUse typescript
inFolderbooleanSave the file in its own folder
fileNamingFileNamingDefine file naming

TestConfig

OptionTypeDescription
pathstringSpecify the path for the file relative to the project source path defined in the project configuration entry
typescriptbooleanUse typescript
inFolderbooleanSave the file in its own folder
fileNamingFileNamingDefine file naming

HookConfig

OptionTypeDescription
openbooleanOpen file in default editor after creating
pathstringSpecify the path for the file relative to the project source path defined in the project configuration entry
typescriptbooleanUse typescript
inFolderbooleanSave the file in its own folder
fileNamingFileNamingDefine file naming

FileNaming

OptionTypeDescription
namestringSpecify name or naming type
postfixstringDefine postfix or postfix type for file name
postfixDeviderstringDefine postfix devider
casingcamel | pascal | kebab | snakeSpecify casing type

Name types

Component

TypeDescription
{name}Provided component name

Style

TypeDescription
{name}Provided name

Story

TypeDescription
{name}Provided name

Test

TypeDescription
{name}Provided name

Postfix types

Component

TypeDescription
{type}Value is compnent
{componentType}Specified type argument

Style

TypeDescription
{type}Value is style
{componentType}Specified component type argument

Example

{
    "project": {
        "path": "./src",
        "typescript": true,
        "fileNaming": {
            "casing": "kebab",
            "postfix": "",
            "postfixDevider": "."
        }
    },
    "component": {
        "default": {
            "style": true,
            "story": true,
            "test": true,
            "proptypes": true,
            "index": true,
            "inFolder": true,
            "open": true,
            "fileNaming": {
                "casing": "camel"
            },
            "path": "/components",
            "class": false,
            "redux": false,
            "override": {
                "style": {
                    "type": "scss"
                }
            }
        },
        "container": {
            "style": true,
            "story": false,
            "test": true,
            "proptypes": true,
            "index": true,
            "inFolder": true,
            "open": true,
            "path": "/containers"
        }
    },
    "style": {
        "type": "styled-components",
        "modules": false,
        "path": "{componentPath}"
    },
    "storybook": {
        "path": "{componentPath}",
        "fileNaming": {
            "postfix": "story"
        }
    },
    "test": {
        "path": "../test",
        "fileNaming": {
            "postfix": "test"
        }
    },
    "hook": {
        "open": true,
        "path": "/hooks"
    }
}

License

MIT

1.0.0

3 years ago