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 🙏

© 2026 – Pkg Stats / Ryan Hefner

simple-template-gen

v1.0.0

Published

A template generator for everyone!

Readme

simple-template-gen

🖥 Just a simple CLI to generate you code template in a easy way.

npm

Table of contents

Getting Started

To install simple-template-gen command you should use the following command on NPM:

npm install -g simple-template-gen

If you need, you can install it on your project to use in some script, just removing the -g flag.

After installing the command, you can start using it just checking it's arguments using --help flag as following:

simple-template-gen --help

This is an example of use:

simple-template-gen --config config.json --output path/to/folder

Creating config file

The config file is a JSON where the user define how the files will be exported and set the template for them. You can have more examples on examples/config folder.

This is an example of it:

{
  "folder": "MyComponent",
  "files": [
    {
      "file": "MyComponent.js",
      "template": "./folder/to/MyComponentTemplate.txt"
    },
    {
      "file": "MyComponent.md",
    },
    {
      "folder": "Documents",
      "files": [
        {
          "file": "Document1.txt"
        },
        {
          "file": "Document2.txt"
        }
      ]
    }
  ]
}

This config file will generate the following folder structure:

MyComponent/
├── MyComponent.js (filled by template)
├── MyComponent.md
├── Documents/
│   ├── Document1.txt
│   └── Document2.txt

You can create a config file as a array to generate any folders you want on output path

[
  {
    "folder": "FolderA",
    "files": [
      {
        "file": "File1.txt"
      },
      {
        "file": "File2.txt"
      },
    ]
  },
  {
    "folder": "FolderB",
    "files": [
      {
        "file": "File3.txt"
      },
    ]
  },
  {
    "folder": "FolderC"
  }
]

This config file will generate the following folder structure:

FolderA/
├── File1.txt
├── File2.txt
FolderB/
├── File3.txt
FolderC/

Inserting variables

In this section will be described how to insert variables into exported files and config file. To set the variables that you want to apply on files, you can pass them in two ways:

The first way, you can set the variable through command line, using the -- prefix before each one, as any other argument:

simple-template-gen --config config.json --name MyComponent --type Sometype 

The other way is to create a JSON file and describe the variables on it, as you can see below:

simple-template-gen --config config.json --variables variables.json
// variables.json

{ 
  "name": "MyComponent",
  "type": "Sometype"
}

Using variables on config file

After inserting the variables as arguments of our command, you can use them to generate your files and inside your templates.

In the example below, you can see how it can be used on the config file, using the variables set on the last section:

// config.json


{
  "folder": "--name",
  "files": [
    {
      "file": "--name.js",
      "template": "./folder/to/MyComponentTemplate.txt"
    },
    {
      "file": "--name.md",
    },
  ]
}

This config file will generate the following folder structure:

MyComponent/
├── MyComponent.js (filled by template)
├── MyComponent.md

So as described on the example, to use your variables on config file you need to set a -- prefix to indicate that it is a variable set as command argument. In this case, we set name and type variables, that could be used on config file using --name and --type.

Using variables on template

Initially, we just set our template as a file which its content will be inserted on a certain file. Now with the variables feature, you can create a JS function on a file a use these variables to generate a customizable template, as you can see below.

simple-template-gen --config config.json --name MyComponent --packageName some-package
// config.json

{
  "file": "--name.js",
  "template": "./folder/to/TemplateFile.js"
}
// TemplateFile.js

module.exports = (variables) => (
  `
import React from 'react'
import content from '${variables.packageName}'

const ${variables.name} = (props) => {
  return <${variables.name} />
}

export default ${variables.name};
`)

This example will generate the following file:

// MyComponent.js

import React from 'react'
import content from 'some-package'

const MyComponent = (props) => {
  return <MyComponent />
}

export default MyComponent;