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

cli-rjs

v1.0.2

Published

A CLI that uses create-react-app to init a new React app and can generate components

Downloads

5

Readme

License

❯ Why ?

To help speed up productivity in React projects and stop copying, pasting, and renaming files each time you want to create a new component.


❯ Getting started


Install with npm:

$ npm install -g cli-rjs

Install with yarn:

$ yarn global add cli-rjs

Init

$ rjs init <appName> [options]

Once installed, creating a new React project is simple. You can simply run:

$ rjs init yourAppName

Or if you don't want to install you can run:

$ npx rjs init yourAppName

(npx is a package runner tool that comes with npm 5.2+)

Or just simply :

$ rjs init

If you don't specify a name for your app it will trigger the interactive mode.

Options

You can configure your app by adding some options

|-- /node_modules
|-- /public
|-- /src
    |-- /App
        |-- App.css
        |-- App.js
        |-- App.test.js
    |-- assets
        |-- /css
            |-- index.css
            |-- reset.css
        |-- /images
    |-- index.js
    |-- logo.svg
    |-- reportWebVitals.js
    |-- setupTests.js
|-- .gitignore
|-- package.json
|-- README.md
|-- yarn.lock

Example commands with different option

with typescript, redux and sass

$ rjs init -tRS

What you'll get

|-- /node_modules
|-- /public
|-- /src
    |-- /App
        |-- App.scss
        |-- App.tsx
        |-- App.test.tsx
    |-- assets
        |-- /images
        |-- /scss
            |-- _reset.scss
            |-- _variables.scss
            |-- index.scss
    |-- /containers
        |-- /App
            |-- App.ts
    |-- /store
        |-- / actions
            |-- index.ts
            |-- actions.template.ts
        |-- / middlewares
            |-- index.ts
            |-- middleware.template.ts
        |-- / reducers
            |-- index.ts
            |-- reducer.template.ts
        |-- / selectors
        |-- index.ts
    |-- index.js
    |-- logo.svg
    |-- react-app-env.d.ts
    |-- reportWebVitals.js
    |-- setupTests.js
|-- .gitignore
|-- package.json
|-- README.md
|-- yarn.lock

with typescript, sass and css modules

$ rjs init -tmS

What you'll get

|-- /node_modules
|-- /public
|-- /src
    |-- /App
        |-- App.module.scss
        |-- App.tsx
        |-- App.test.tsx
    |-- assets
        |-- /images
        |-- /scss
            |-- _reset.scss
            |-- _variables.scss
            |-- index.scss
    |-- index.js
    |-- logo.svg
    |-- react-app-env.d.ts
    |-- reportWebVitals.js
    |-- setupTests.js
|-- .gitignore
|-- package.json
|-- README.md
|-- yarn.lock
$ rjs generate-component | gc <name> [directory] [options]

This command will create a folder with your component name within your default (e.g. src/components) directory, and its corresponding file.

To create a component just run:

$ rjs generate-component Header

Or you can use an alias

$ rjs gc Header

This will generate a folder and a .js file with your component name.

|-- /src
    |-- /components
        |-- /Header
            |-- Header.js

Example of the javascript generated component

import React from 'react';
import PropTypes from 'prop-types';

const Header = () => {
  return <div>Header Component</div>;
};

Header.propTypes = {};

export default Header;

You can also attach a style file with you component:

$ rjs generate-component Header -s css

This will generate a folder with a .js file and a css file with your component name.

|-- /src
    |-- /components
        |-- /Header
            |-- Header.js
            |-- Header.css

You can also use typescript and css modules:

$ rjs gc Header -tms css

or

$ rjs generate-component Header --use-typescript --use-modules -with-styles scss

This will generate a folder with a .tsx file and a scss module file with your component name.

|-- /src
    |-- /components
        |-- /Header
            |-- Header.tsx
            |-- Header.module.scss

Example of the typescript generated component

import React, { FC } from 'react';
import styles from './Header.module.scss';

interface HeaderProps {}

const Header: FC<HeaderProps> = () => {
  return <div className={styles.Header}>Header Component</div>;
};

export default Header;

Directory

You can also specify a directory name or path for your component, it will create a path from where you currently are

if you're in src directory and want to create a Nav component in the components/Header/Nav

# path : src

$ rjs gc Nav components/Header/Nav -tms scss

Result

|-- /src
    |-- /components
        |-- /Header
            |-- Header.tsx
            |-- Header.module.scss
        |-- /Nav
            |-- Nav.tsx
            |-- Nav.module.scss

You can also create a component in the folder where you currently are by using . as a directory name.

Let's say you want to create a Layout component with typescript in your components directory

# path : src/components
$ rjs gc Layout . -t

Result

|-- /src
    |-- /components
        |-- /Header
            |-- Header.tsx
            |-- Header.module.scss
        |-- Layout.tsx

Options

Here are all the available options

License

rjs-cli is open source software licensed as MIT.