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

n-comp

v0.1.7

Published

CLI for creating new react components

Downloads

20

Readme

Features

  • Create React components.
  • Choose between TypeScript and JavaScript.
  • Components can be function, arrow or class.
  • Even you can use your favorite ui library (personal whim).

Quickstart

From your terminal run:

# install the package with NPM
$ npx n-comp

# or install it with YARN
$ yarn n-comp

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

$ new-component MyNewComponent

Your project will now have a new directory at src/components/MyNewComponent. This directory has two files:

// `MyNewComponent/index.js`
export { default } from './MyNewComponent';
// `MyNewComponent/MyNewComponent.js`
function MyNewComponent() {
  return (
    <div>
      <p>MyNewComponent</p>
    </div>
  );
}

export default MyNewComponent;

These files will be formatted according to your Prettier configuration.

Configuration

Configuration can be done through 3 different ways:

  • Creating a global .nc.config.json in your home directory (~/.nc.config.json).
  • Creating a local .nc.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.

API Reference

Language

Controls which language, JavaScript or TypeScript, should be used.

  • ts — creates a .tsx file (default).
  • js — creates a .js file.

Usage: Command line: --lang <value> or -l <value>

JSON config: { "lang": <value> }

Type

Controls which type of component, function, arrow or class should be used.

  • Function — use function MyNewComponent() {}
  • Arrow — use const MyNewComponent = () => {}
  • Class — use class MyNewComponent extends React.Component {}

Usage: Command line: --type <value> or -t <value>

JSON config: { "type": <value> }

UI Library

Controls which ui library, vanilla, Chakra UI or MUI should be used.

  • Vanilla — use <div> and <p> tags.
  • Chakra UI — use <Box> and <Text> components.
  • Material UI — use <Box> and <Typography> components.

Usage: Command line: --ui <value>

JSON config: { "ui": <value> }

Directory

Controls the desired directory for the created component. Defaults to src/components

Usage: Command line: --dir <value> or -d <value>

JSON config: { "dir": <value> }

License

Licensed under the MIT license