# rg-cli

> A React generator CLI tool for generating React components in Javascript or Typescript

Latest version **3.1.0** (published 2018-12-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install rg-cli
pnpm add rg-cli
yarn add rg-cli
bun add rg-cli
```

Provides the command `rg`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2018-12-22 |
| First published | 2018-10-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | brendanatme |
| Maintainers | brendanatme |
| Keywords | react, typescript, component, generator, cli |

## Links

- npm: https://www.npmjs.com/package/rg-cli
- Repository: https://github.com/brendanatme/rg-cli
- Homepage: https://github.com/brendanatme/rg-cli#readme
- Issues: https://github.com/brendanatme/rg-cli/issues
- npm.io page: https://npm.io/package/rg-cli

## Dependencies (1)

- [minimist](https://npm.io/package/minimist.md) ^1.2.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 3.1.0 (latest) — 2018-12-22
- 3.0.0 — 2018-12-21
- 2.0.1 — 2018-12-17
- 2.0.0 — 2018-12-17
- 1.2.0 — 2018-10-17
- 1.1.6 — 2018-10-17
- 1.1.5 — 2018-10-17
- 1.1.4 — 2018-10-17
- 1.1.1 — 2018-10-15
- 1.1.0 — 2018-10-15
- 1.0.2 — 2018-10-15
- 1.0.1 — 2018-10-15
- 1.0.0 — 2018-10-12

## README

# RG-CLI

A React generator CLI tool

Inspired by `ng-cli` &mdash; but does so much less.

Generates components (just components for now) in JavaScript or TypeScript.

## Why

So we can quickly bang out React components that follow best practices off the bat, and create a clean folder structure &mdash; especially useful in large projects

## Requirements

- tested and working in Node v10+
- probably works in lower versions &mdash; we're really not doing anything fancy here

## Installation

```
npm install -g rg-cli
```

## Usage

From your project root, in terminal, run: `rg g c [component-name]`

For example: `rg g c text-input`

## What It Does

Generates a component folder at ./src/components/[my-component-name], relative to your `cwd`.

## Changing the Output Directory

You can change the output directory by passing it in the `--dir` flag

For example:

```
rg g c --dir="my/favourite/components" text-input
```

The `--dir` flag is evaluated relative to your `cwd`.

## Generating TypeScript

The generator generates JavaScript by default; to generate TypeScript, use the `--type=ts` flag.

```
rg g c --type=ts text-input
```

## Generating Sass

The generator generates CSS stylesheets by default; to generate Scss, use the `--style=scss` flag.

## Generated Folder Structure

The component folder looks contains these files:

- `my-component-name.component.(s)css`
- `my-component-name.component.(js|ts)x`
- `my-component-name.container.(js|ts)x`
- `index.(js|ts)`

## Configuring RG-CLI for your project

RG-CLI will look for an `rg.config.json` file in your current working directory; if it finds it, it will use the options set in their by default. Any command-line arguments passed will take precendence over the config file.

An example `rg.config.json` file:

```json
{
  "dir": "client/src/components",
  "type": "ts",
  "style": "scss"
}
```

## Importing Your Generated Component

After generating a component, you can import it like so:

JavaScript:

```javascript
import MyComponent from '[components-dir]/my-component';
```

TypeScript:

```typescript
import { MyComponent } from '[components-dir]/my-component';
```

---
_Source: https://npm.io/package/rg-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
