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

rapid-file-templates

v0.1.1

Published

Say goodbye to tedious and time-consuming manual file creation.

Downloads

44

Readme

Rapid File Templates

Say goodbye to tedious and time-consuming manual file creation.

The tool is designed to make it easy for you to generate common files for your projects and eliminates the need for repetitive manual work.

Installation

To install the package , run the following command in your terminal:

npm install --save-dev rapid-file-templates

Or you can install the package globally:

npm install -g rapid-file-templates

Once the installation is complete, you should be able to run the command rapid in your terminal to access the tool.

Usage

rapid make <path> -t <template-key>
  • <path> is the destination path where the generated files will be placed.
  • <template-name> is the name of the JSON template you want to use to generate the files.

Example

Add the rapid.config.json file in your project root folder

rapid.config.json

{
  "key-component": {
    "mergeFields": [
      { "label": "{{fileName}}", "defaultValue": "new-file-name" },
      { "label": "{{componentName}}", "defaultValue": "" },
      { "label": "{{cssClassName}}", "defaultValue": "container" }
    ],
    "enablePrettier": true,
    "root": {
      "type": "Folder",
      "elementProps": { "name": "{{fileName}}" },
      "elements": [
        {
          "type": "File",
          "elementProps": {
            "name": "{{fileName}}.tsx",
            "parser": "babel-ts",
            "content": [
              "import {FC} from 'react'",
              "import styles from './styles'",
              "type Props = {}",
              "const {{componentName}}:FC<Props> = (props) => {",
              "return <div className={styles.{{componentName}}Container}></div>",
              "}"
            ]
          }
        },
        {
          "type": "File",
          "elementProps": {
            "name": "styles.scss",
            "parser": "scss",
            "content": [
                ".{{cssClassName}} {",
                "border-radius: 1px solid black",
                "}"
                ]
          }
        }
      ]
    }
  }
}

Using the above example you can configure your template in any way you want.
Templates are accessed using the JSON file key, in the example above it's the "key-component"

rapid make ./src/ -t key-component

TemplateStructure

The TemplateStructure type is used to define the structure of a template file. It is defined as an object with the following properties:

Properties

  • root (required): a TemplateElement object representing the root element of the template file.
  • enablePrettier: an optional boolean indicating whether to format the output using Prettier.
  • mergeFields: an optional array of MergeField objects representing the merge fields in the template file.

TemplateElement

A TemplateElement is an object that defines a single file or directory. A TemplateElement has the following properties:

  • type (required): The type of the TemplateElement. It can be either "File" or "Folder".
  • elementProps (required): The properties of the TemplateElement. An object with the following properties:
    • name (required): The name of the file or directory.
    • content: An array of strings that define the contents of a file.
    • parser (optional): The name of a built-in prettier parser that will be used to parse the contents of a file.
  • elements (optional): An array of TemplateElement objects that define the contents of a directory.

MergeField

The MergeField type is used to represent a merge field within a template file. It is defined as an object with the following properties:

Properties

  • label (required): a string representing the label or key of the merge field.
  • value: an optional string representing the value to replace the merge field with.
  • defaultValue: an optional string representing the default value to use if the value property is not provided.

Code Generation - File Generation - Template Engine - Code Automation - CLI Tool - JSON Templates - File System - Code Scaffolding - Code Generation CLI - Code Templates - Project Boilerplate - Project Generation - Automated Code - Code Creation