npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@melmacaluso/react-kymera

v0.0.13-beta-1

Published

React tsx component scaffolder along with types, styles and sub-components.

Downloads

10

Readme

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.