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

@itsjonq/remake

v2.0.0

Published

A simple generator from locally defined templates

Downloads

27

Readme

🦋 Remake

Build Status npm version

A simple generator from locally defined templates!

Usage: remake
  🦋  Remake

  remake <cmd> --option

  Example:
  remake component --name=MyComponent --someProp=value


Options:
  -V, --version    output the version number
  -n, --name       The name for the generate file(s)
  -o, --output     Location to output generated file(s)
  -i, --entry      Location of the template file(s)
  -w, --overwrite  Overwrite existing files
  -s, --silence    Suppresses the logs
  -h, --help       output usage information

Commands:
  *              The directory name for the template under .remake/

Table of contents

Installation

npm install --save-dev @itsjonq/remake

To install it globally, run:

npm install -g @itsjonq/remake

Usage

Create the template files

In your project's root directory, create a new directory called .remake:

my-app/
├── .remake/
└── .../

Within the .remake directory, create sub directories to associate with "commands" that you would like Remake to run. In this example, we'll create a directory called component, which Remake will use when running the command component:

my-app/
├── .remake/
│   └── component/
└── .../

Under the new component directory, we'll add a couple of files that we want Remake to generate for us:

my-app/
├── .remake/
│   └── component/
│       └── remake-name/
│           ├── index.js
│           └── remake-name.js
└── .../

Notice the remake-name directory and remake-name.js file. Remake will use props you provide to replace any remake-* file name. For this example, the file name will be replaced with the name prop.

Within the remake-name.js, let's add some template content:

// component/remake-name/remake-name.js
import React from 'react'

export class <%= name %> extends React.PureComponent {
  render () {
    return <div />
  }
}

export default <%= name %>

Notice the <%= name %>. Remake uses lodash.template to parse and modify template files. The name prop is provided to the template through CLI arguments. You can specify anything you'd like! Including if/else logic, if you wanna get fancy.

Run the command

Once you're happy with your template files, run the remake command.

The recommended way is to add a remake script to your project's package.json, like so:

  ...
  "remake": "remake",
  ...

You can even add the options to dedicated remake scripts for more commonly generated templates:

"remake:component": "remake component --output=src/components"

Alternatively, if you've installed remake globally, you can run:

remake component --name=Hello

For this example, remake will generate the following files:

my-app/
├── .remake/
│   └── component/
│       └── remake-name/
│           ├── index.js
│           └── remake-name.js
├── Hello
│   ├── index.js
│   └── Hello.js
└── .../

If we take a look at Hello.js, you'll see that the <%= name %> variables have been replaced by Hello, specified by --name=Hello:

// Hello/Hello.js
import React from 'react';

export class Hello extends React.PureComponent {
	render() {
		return <div />;
	}
}

export default Hello;

Example

Check out the example in the example directory 🙌

License

MIT © Q