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

gen-rf

v1.1.3

Published

Generate common tsx/jsx plus spec file

Downloads

3

Readme

gen-rf

Generates jsx or tsx file together with test or styles files, all with predefined snippets.

Component name is validated before usage (example for file: primary-button, component will be called PrimaryButton).

Usage

npx gen-rf

CLI Options

If --file or --out not specified, user will be prompted every time for input

Usage: index [options]

Options:
  -V, --version           output the version number
  -g, --gen-cfg           generate config file if one doesn't exist (default: true)
  type                    file type: tsx/jsx (default: "tsx")
  -f, --file <type>       specify file name
  -cnf, --config <type>   specify path to config file (default: ".genrfrc.json")
  -o, --out <type>        specify output dir
  -tsf, --test <type>     specify suffix for the test files: none/spec/test (default: "spec")
  -style, --style <type>  specify whenever to genereate css/scss/sass/less file or not (default: "none")
  -h, --help              display help for command

Config file

Configuration file overrides cli commands/options

.genrfrc.json:

{
  "rootDir": "./",
  "type": "tsx",
  "test": "spec",
  "style": "none"
}

Just run npx gen-rf and configuration file will be auto generated depending on user's input

package.json

npm

npm install gen-rf --save-dev

yarn

yarn add gen-rf -D
{
  "scripts": {
    "gen-rf": "gen-rf"
  }
}

Examples with options

npx gen-rf --tsx -o test -f secondary-button

test/secondary-button.tsx

import React from 'react'

interface SecondaryButtonProps {

}

export const SecondaryButton: React.FC<SecondaryButtonProps> = ({}) => {
    return ();
}

test/secondary-button.spec.ts

import { render } from "@testing-library/react";

import { SecondaryButton } from "./index";

describe("SecondaryButton component testing with testing-library", () => {
    const component = render(<SecondaryButton />);

    it("renders without crashing", () => {
        expect(component).toBeTruthy();
    });
});

Config File Options

| Option | Description | | ------- | --------------------------------------------------------------------------------------------------- | | rootDir | The root directory used for file creation | | type | Type for newly craeted files: .jsx|.tsx | | test | The suffix that should be appended to the test file: .(test|spec).(js|ts) or none | | test | The suffix that should be appended to the style file: .(module|none).(css|scss|less|sass|none) |