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

react-code-creator

v0.3.3

Published

A lightweight tool to create boilerplate code for common React files

Downloads

31

Readme

React Code Creator

Summary

A lightweight tool to create boilerplate code for common React files.

React Code Creator is a simple implementation of plop.js for common React files.

React Code Creator supports creating the following types of React files:

  • Views (jsx or tsx)
  • Services
  • Contexts
  • Models (when using typescript)
  • Includes css and test spec files
  • Redux reducers
  • Actions
  • Storybook stories

Install

npm install react-code-creator --save-dev

Or

yarn add react-code-creator --dev

Using

Config file

React Code Creator uses a react-code-creator.config.yaml file (which you should place at your project's root directory) to determine how to generate certain files. The config file should automatically be added to your root folder after installation with npm.

The config file has the following properties:

useTypescript: # Default: false
generateCss: # Default: true
generateTests: # Default: true
generateInterfaces: # Default: false
generateStories: # Default: false
generatePropTypes: false # true or false. Default is false
generateTypescriptProps: false # true or false. Default is false
cssExtension: # Default: "css"
testExtension: # Default: "spec"
root: # Default: "./src"
viewPath: # Default "views"
modelPath: # Default "models"
servicePath: # Default "services"
contextPath: # Default "contexts"
fileCase: # Default "camel"
pathCase: # Default "camel"
useSemicolons: # Default true

|Property|Description|Possible Values|Default| |--------|-----------|---------------|-------| |useTypescript|Whether to create typescript files (.tsx, .ts)|true or false|false| |generateCss|Whether to generate css files when creating components|true or false|true| |generateTests|Whether to generate test spec files when creating components and services|true or false|true| |generateInterfaces|Whether to generate interfaces when creating services|true or false|false| |generateStories|Whether to generate Storybook stories when creating components|true or false|false| |generatePropTypes|Whether to generate React.PropTypes when creating components|true or false|false| |generateTypescriptProps|Whether to generate Typescript props when creating components|true or false|false| |cssExtension|Define the type of css file to generate|"css", "scss", "less", "sass"|"css"| |testExtension|The file extension for test spec files|"spec" or "test"|"spec"| |root|The root directory for your source code (where React Code Creator will place the generated files)|any filepath string|"./src"| |viewPath|Where in the root directory to place autogenerated views|any filepath string|"views"| |modelPath|Where in the root directory to place autogenerated models|any filepath string|"models"| |servicePath|Where in the root directory to place autogenerated services|any filepath string|"services"| |contextPath|Where in the root directory to place autogenerated contexts|any filepath string|"contexts"| |fileCase|Casing type to try and enforce when creating file names|"camel", "pascal", "dash", "snake", "dot"|"camel"| |pathCase|Casing type to try and enforce when creating file paths|"camel", "pascal", "dash", "snake"|"camel"| |useSemicolons|Whether to use semicolons in generated files|true or false|true|

Casing Examples (fileCase and pathCase)

  • camel: camelCaseNames
  • pascal: PascalCaseNames
  • dash: dash-case-names
  • snake: snake_case_names
  • dot: dot.case.names

Running

After installing, React Code Creator should add a new script to your package.json file.

Run npm run new to begin the CLI

Skipping prompts

If you already know the values you would like to provide the CLI, you can add them as args

For example: npm run new componenent myComponent

Commands

You can see the full list of commands by running npm run new

Changing the Run command

You can change the command from new by updating the scripts section of your package.json file.

Naming Conventions

When creating certain files, React Code Creator will use the exact name you specify as the filename. This is the case when creating a Component, Model, or a Service

For example:

  • Creating component / class component: userProfile -> userProfile
  • Creating model: user -> user
  • Creating service: userFetcher -> userFetcher

But when creating a Context or Reducer, React Code Creator will append Context or Reducer to the filename, so don't include them when naming them!

For example:

  • Creating context: user -> userContext
  • Creating a reducer: user -> userReducer

Troubleshooting

Avoid frequently changing the config

React Code Creator relies on regex patterns to track and modify some generated files. Avoid changing the config parameters (such as file casing patterns, directories, or enabling/disabling typescript) to avoid errors related to locating previously generated files.

License

You may use React Code Creator under the MIT license