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

get-component

v0.1.3

Published

CLI for creating new React components

Downloads

26

Readme

npm version npm downloads bundle License

📦 get-component

Simple, customizable utility for adding new React 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.

This project uses an opinionated file structure discussed in this blog post: Delightful React File/Directory Structure.

Note: This project is designed to work with Next.js, but it should work with any React project. This Projekt use NerdFonts for the icons in the terminal. If you don't have them installed, you can find them here: NerdFonts.

🌟 Features

  • Simple CLI interface for adding React components.
  • Designed to work seamlessly with Next.js and its new app router.
  • Offers global config, which can be overridden on a project-by-project basis.
  • Colourful terminal output!
  • Supports only TypeScript.
  • Supports only functional components.
  • Supports components with styled-components.

⏱️ Quickstart

📥 Install:

# pnpm 
pnpm add -g get-component@latest

# yarn
yarn global add get-component@latest

# npm
$ npm i -g get-component@latest

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

📂 With new folder, component, and index file

getc MyNewComponent -n

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

// `MyNewComponent/index.ts`
export * from './MyNewComponent'
export { default } from './MyNewComponent'
// `MyNewComponent/MyNewComponent.tsx`
export default function MyNewComponent() {
   return (
    <>
    </>
   )
}

➕ Only one new component

getc MyNewComponent

creates a new component with selected name directly in app/components folder

🛠️ Only one new component in the desired path

getc MyNewComponent -p Sections

creates a new component with selected name directly in app/components/Sections folder

💅 With styled-components

getc MyNewComponent -s
import styled from 'styled-components'

export default function MyNewComponent() {
   return (
    <Wrapper>
    </Wrapper>
   )
}

const Wrapper = styled.div``

⚙️ Configuration

Configuration can be done through 3 different ways:

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

📝 Template

Controls which template, normal or with styled-components, should be used.

  • -s — creates a component file with styled-components.
  • normal is default and needs no flag.

Note that all components created will be functional components. Class components are not supported.

Usage:

Command line: --sytle or -s

📁 Directory

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

Usage:

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

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

🌐 Platform Support

This has only been tested in macOS. I think it'd work fine in linux, but I haven't tested it in Windows.

📜 License

MIT 💚 License © 2023 Dennis Ollhoff