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

@govindgovind852/tmb

v0.0.8

Published

A tool to define templates and generate modules using YAML configurations.

Downloads

5

Readme

tmb - Template Module Builder

tmb is a powerful CLI tool that allows you to define template modules and generate them using YAML configuration files. It's ideal for projects where you need consistent module generation based on pre-defined templates.

Installation

You can install tmb as a dev dependency:

npm install @govindgovind852/tmb --save-dev

Usage

After installation, you can use the CLI tool by running:

npx @govindgovind852/tmb add-module [yaml-file-path]

or

add this in your package script

"tmb": "tmb add-module [yaml-file-path]"

If no file path is provided, the default ./mgrc.yaml will be used.

Example

Here’s an example YAML configuration to generate a module with folders and files:

configs:
  rootDir: "./src/modules"
  templatesDir: "./template-module"
  defaults:
    filepaths:
      dbTypeDef: "dbTypeDef.ts"
      entityTypeDef: "entityTypeDef.ts"
      dbSchema: "dbSchema.ts"
    value:
      moduleName: "test"
      entityName: "Test"
      pageLimit: "10"
variables:
  filepaths:
    - dbTypeDef
    - entityTypeDef
    - dbSchema
  value:
    - moduleName
    - entityName
    - pageLimit
folders:
  - name: $moduleName
    folders:
      - name: internals
        folders:
          - name: store
            files:
              - name: $moduleName-db.ts
                filePath: "internal/store/db-template.ts"
              - name: $moduleName-repository.ts
                filePath: "internal/store/repository-template.ts"
        files:
          - name: $moduleName-writer.ts
            filePath: "internal/writer-template.ts"
          - name: $moduleName-reader.ts
            filePath: "internal/reader-template.ts"
          - name: $moduleName-util.ts
            filePath: "internal/util-template.ts"
      - name: rest-api
        files:
          - name: $moduleName-controller.ts
            filePath: "rest-api/controller-template.ts"
          - name: $moduleName-router.ts
            filePath: "rest-api/router-template.ts"
          - name: $moduleName-serializer.ts
            filePath: "rest-api/serializer-template.ts"
          - name: $moduleName-server.ts
            filePath: "rest-api/server-template.ts"
      - files:
          - name: service.ts
            filePath: "service-template.ts"
          - name: index.ts
            filePath: "index-template.ts"
          - name: types.ts
            filePath: "types-template.ts"

Configuration Options

configs

  • rootDir: Specifies where the generated modules will be created. Defaults to the current directory if not specified.
  • templatesDir: Specifies the folder where your template files are stored. If not provided, you can specify inline content or use absolute paths for templates.
  • defaults: You can specify default values for variables like moduleName.

variables

A list of variables that will be replaced in folder and file names, and within file contents. The user is prompted to provide these unless defaults are given.

folders

Defines the folder structure for the module. It contains:

  • name: The folder name (can include variables like $moduleName).
  • folders: Subfolders inside the folder.
  • files: Files inside the folder.

files

Each folder can have multiple files. Files can specify:

  • name: The file name, which can contain variables like $moduleName.
  • filePath: Path to an external template file.
  • content: Inline content directly provided in the YAML file.

Development

For development, you can run the following command to test the module generation without building:

npm run dev

To build the package for distribution:

npm run build

License

tmb is licensed under the MIT License.