0.0.3 • Published 6 years ago

rn-component-generator v0.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

rn-component-generator

Simple, customizable utility for adding new React components to your project.

This project is a globally-installable CLI for adding new React native components. It's dead simple to use, and requires no configuration, although it's easy to customize it to fit your project's coding style.

Features

  • Simple CLI interface for adding Component, PureComponent, or Stateless Functional 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 rn-component-generator
$ npm link rn-component-generator

Configuration

Configuration can be done through 3 different ways:

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

Type

Control the type of component created:

  • class for a traditional Component class (default),
  • pure-class for a PureComponent class,
  • functional for a stateless functional component.

Legacy createClass components are not supported, although support would be easy to add. Feel free to open an issue (or a PR!).

Usage:

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

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

Directory

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

Legacy createClass components are not supported, although support would be easy to add. Feel free to open an issue (or a PR!).

Usage:

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

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

File Extension

Controls the file extension for the created components. Can be either js (default) or jsx.

Usage:

Command line: --extension <value> or -x <value>

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