0.0.13-beta-1 • Published 1 year ago

@melmacaluso/react-kymera v0.0.13-beta-1

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

React-Kymera


React-Kymera is a command line tool for scaffolding React components and subcomponents, including base styles and folder structures. It uses yargs for CLI functionality and fs/promises, lodash, and path for file system operations.

Installation

You can install React-Kymera globally using npm:

npm install -g @melmacaluso/react-kymera

Usage

React-Kymera provides a command-line interface with the following commands:

Create Component

To create a new component or subcomponent, run the c command followed by the name of the component and, optionally, the name of its parent component. If a parent component is specified, the new component will be created as a subcomponent of the parent component.

$ rkm c <name> [parentComponent]

Arguments

  • <name>: The name of the component to create. This can be all lowercase and will be prefixed by the parent component name (if present).

  • [parentComponent]: The name of the parent component. If present, the new component will be created as a subcomponent of the parent component.

Behavior

  • React-Kymera will create a folder structure in the src/components directory based on the component and parent component names.

  • If the parent component is specified, React-Kymera will create an index file for the parent component if one doesn't already exist.

  • React-Kymera will create an index file and a types file for the new component.

  • If a parent component is specified, React-Kymera will create a base style file for the new component with the name <parentComponent>-<componentName>.scss and add an import statement for the base style file to the parent component's style index file.

  • If a base style file already exists for the new component or its parent component, React-Kymera will move the existing file to the new component's folder and rename it to index.scss.

  • If the style folder for the parent component doesn't exist, React-Kymera will create it.

Single Component creation

To create a new component called MyComponent, run:

$ rkm c MyComponent

When you run the create component command to create a new component, the library creates a folder structure in the src/components directory based on the component and parent component names. It also creates an index file and a types file for the new component.:

src/
├── components/
│ ├── MyComponent/
│ └──index.tsx
│ └── types.ts
├── styles/
│ └── components/
│ └── my-component.scss

Sub Component creation

To create a new subcomponent called MySubcomponent of a parent component called MyComponent, run:

$ rkm c MySubcomponent MyComponent

This will create a folder called MyComponentMySubcomponent (automatically prefixed with the parent component) inside the MyComponent folder, along with an index file (index.tsx) and a types file (types.ts). It will also create a base style file (my-component-my-subcomponent.scss) in the src/styles/components/my-component directory, and add an import statement for the base style file to the newly created src/styles/components/my-component/index.scss which will be populated with whatever content the parent's style file had in src/styles/components/my-component.scss (if that file exists).

src/
├── components/
│ ├── MyComponent/
│ └── index.tsx
│ └── types.ts
│ ├──── MyComponentMySubComponent/
│ └──── index.tsx
│ └── types.ts
├── styles/
│   └── components/
│       └── my-component/
│           ├── index.scss
│           └── my-component-my-subcomponent.scss

Help

To display help information and a list of available commands, run the --help command:

$ rkm --help

Version

To display the current version of React-Kymera, run the --version command:

$ rkm --version

Initialization

You can use the init command to create a new .kymera.config.js file in the root of your project. This file can be used to specify options for the Kymera CLI tool, such as whether or not to generate styles for new components.

To use the init command, run the following in your terminal:

rmk init

If the .kymera.config.js file already exists in the root of your project, the init command will not create a new file and will instead display a warning message.

The init command will generate a base configuration file with the following options:

module.exports = {
  outputStyles: true,
  kymeraChatter: false,
}

You can modify these options as needed to customize the behavior of the Kymera CLI tool.

Configuration

Kymera provides a simple configuration file .kymera.config.js which allows you to customize some of its behavior.

Available options

  • outputStyles (default: true): If set to false, Kymera will create components without associated SCSS files. If set to true, Kymera will create components with SCSS files containing a default class for the component.
  • kymeraChatter (default: false): If set to true, Kymera will output cheerful messages during component creation.

How to use the config file

To use the config file, simply create a .kymera.config.js file in the root of your project and export an object containing the options you want to customize. For example, to turn off SCSS file generation, you can create a .kymera.config.js file with the following content:

const config = {
  outputStyles: false,
}

export default config

If no config file is found, Kymera will assume the default values for all options.

Contributing

Contributions are welcome! If you find a bug or have an idea for a new feature, please open an issue or submit a pull request.

License

React-Kymera is released under the MIT License. See LICENSE.md for more information.

0.0.13-beta-1

1 year ago

0.0.12-beta-1

1 year ago

0.0.11-beta-1

1 year ago

0.0.10-beta-1

1 year ago

0.0.9-beta-1

1 year ago

0.0.8-beta-1

1 year ago

0.0.7-beta-1

1 year ago

0.0.6-beta-1

1 year ago

0.0.5-beta-1

1 year ago

0.0.4-beta-1

1 year ago

0.0.3-beta-1

1 year ago

0.0.2-beta-1

1 year ago

0.0.1-beta-1

1 year ago