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

react-new-component-cli

v1.3.0

Published

A simple CLI tool to create new React / Next.js components

Downloads

18

Readme

react-new-component-cli

Simple, customizable utility for adding new React / Next components to your project ✨

This project is a CLI tool that allows you to quickly scaffold new components. All of the necessary boilerplate will be generated automatically.

  • ⌨️ Simple CLI interface for adding React components.
  • ✨ Uses Prettier to stylistically match the existing project.
  • 📝 Offers global config, which can be overridden on a project-by-project basis.
  • 🌈 Colourful terminal output!

Quickstart

Install via NPM:

npm i -g react-new-component-cli

cd into your project's directory, and try creating a new component:

rnc MyShinyComponent

Your project will now have a new directory at src/ui/MyShinyComponent containing three files :

  • MyShinyComponent.tsx
  • MyShinyComponent.module.scss
  • index.ts

These files will be formatted according to your Prettier configuration.

Configuration

Configuration can be done through 3 different ways:

  • Creating a global .react-component-config.json in your home directory (~/.react-component-config.json).
  • Creating a local .react-component-config.json in your project's root directory.
  • Command-line arguments.

The resulting values are merged, with command-line values overwriting local values, and local values overwriting global ones.

Example JSON configuration file:

{
  "lang": "ts",
  "style": ".scss",
  "dir": "src/components"
}

API Reference

All components created will be functional components.

| Option | Shorthand | JSON config | Defaults | Description | | ------- | --------- | ---------------------- | -------------- | -------------------------------------------------------------------- | | --lang | -l | { "lang": <value> } | ts | Controls which language, JavaScript or TypeScript, should be used. | | --dir | -d | { "dir": <value> } | src/ui | Controls the desired directory for the created component | | --style | -s | { "style": <value> } | .module.scss | Controls the desired style file extension for the created component. |

More about style extension API

Available values:

  • .module.scss or .module.css for CSS modules
  • .scss or .css for classic styles file
  • none if you don't want any style file included.

Examples

# (defaults)
# Creates Tile.tsx, index.ts and tile.module.scss file in app/ui directory
rnc Tile

# Creates Tile.jsx, index.js and Tile.css file in src/components directory
rnc Tile -s .css -d src/components -l js

# Creates Tile.tsx, index.ts in src/components directory
rnc Tile -s none -d src/components

Platform Support

This utility has only been tested in MacOS environment.

Development

To get started with development:

  • Fork and clone the Git repo
  • cd into the directory and install dependencies (npm install)
  • Set up a symlink by running npm link, while in the react-new-component-cli directory. This will ensure that the rnc command uses this locally-cloned project, rather than the global NPM installation.
  • Spin up a test React project.
  • In that test project, use the rnc command to create components and test that your changes are working.

Special thanks

Special thanks to ✨ Josh W. Comeau ✨, this utility's base is a fork from his repository.