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

@jmjs/comp-template

v1.0.5

Published

A lightweight and customizable template generator for JavaScript/TypeScript projects. Create and manage reusable code templates with automatic variable substitution and intelligent naming conventions.

Readme

@jmjs/comp-template

A lightweight and customizable template generator for JavaScript/TypeScript projects. Create and manage reusable code templates with automatic variable substitution and intelligent naming conventions.

✨ Features

  • 🚀 Zero dependencies except for CLI prompts (inquirer)
  • 📁 Smart directory structure - Templates stored in hidden .template/ folder
  • 🔄 Automatic variable substitution - PascalCase, camelCase, kebab-case
  • 📂 Configurable output directories - Choose where to generate files
  • File and directory templates - Single files or complete folder structures
  • 🛠️ Easy customization - Add your own templates and output locations
  • 🔧 One-time setup - Initialize once, commit to git, ready for the team

🚀 Quick Start

Installation & Setup

npm install @jmjs/comp-template
# or use directly with npx

# Initialize in your project (one time only)
npx template init

This will create:

  • .template/ directory with default templates
  • template.config.js with output directory configuration

💡 Commit these files to git so your team can use the same templates!

Daily Usage

npx template
# Choose template → Enter name → Choose destination → Done!

📂 Output Directory Configuration

comp-template allows you to configure where generated files are placed using a template.config.js file:

module.exports = {
  outputDirectories: [
    {
      name: "Components",
      path: "src/components",
      description: "React components directory",
    },
    {
      name: "Pages",
      path: "src/pages", 
      description: "Application pages",
    },
    {
      name: "Utils",
      path: "src/utils",
      description: "Utility functions and helpers",
    },
  ],
};

Configuration Properties

  • name: Display name for the directory choice
  • path: Relative path where files will be generated
  • description (optional): Additional description shown in the CLI

When you run template, you'll be prompted to:

  1. Choose a template
  2. Enter a component/file name
  3. Choose an output directory from your configured options

🔄 Variable Substitution

Templates support automatic variable replacement:

| Variable | Example Input | Output | | --------------------------------------- | -------------- | ------------------- | | __templateNameToPascalCase__ | "user profile" | UserProfile | | __templateNameToCamelCase__ | "user profile" | userProfile | | __templateNameToDashCase__ | "user profile" | user-profile | | __templateNameToSnakeCase__ | "user profile" | user_profile | | __templateNameToConstantCase__ | "user profile" | USER_PROFILE | | __templateNameToTitleCase__ | "user profile" | User Profile | | __templateNameToLowerCase__ | "user profile" | userprofile | | __templateNameToLowerCaseWithSpaces__ | "user profile" | user profile |

📁 Template Structure

Templates are stored in the .template/ directory:

.template/
├── README.md
├── component/                     # Directory template
│   ├── __templateNameToPascalCase__.tsx
│   ├── __templateNameToCamelCase__.test.tsx
│   └── __templateNameToDashCase__.css
└── util.ts                       # File template

File Templates

Single files with variable substitution:

// .template/service.ts
export class __templateNameToPascalCase__Service {
  // Service implementation
}

Directory Templates

Complete folder structures:

.template/api-endpoint/
├── __templateNameToDashCase__.controller.ts
├── __templateNameToDashCase__.service.ts
└── __templateNameToPascalCase__.dto.ts

🛠️ Commands

| Command | Description | | ------------------ | ------------------------------------------------------------- | | template | Interactive template generation (default) | | template init | Initialize comp-template (templates + config) in your project | | template install | Manually install templates (useful with npm link) | | template config | Create/update template.config.js |

📖 Examples

First Time Setup

# In your project directory
npx template init

# Commit the generated files
git add .template/ template.config.js
git commit -m "Add @jmjs/comp-template configuration"

Generate a React Component

  1. Run template
  2. Choose "component (directory)"
  3. Enter name: "user-card"
  4. Choose output: "Components (src/components)"

Result in src/components/UserCard/:

UserCard/
├── UserCard.tsx
├── userCard.test.tsx
├── user-card.css
└── README.md

Generate a Utility Function

  1. Run template
  2. Choose "util.ts (file)"
  3. Enter name: "date helper"
  4. Choose output: "Utils (src/utils)"

Result: src/utils/DateHelper.ts

🏗️ Project Structure

src/
├── cli.ts              # Main CLI interface
├── template-manager.ts # Template processing logic
├── config-manager.ts   # Configuration handling
├── file-utils.ts      # Custom file operations  
├── utils.ts           # String case utilities
├── install.ts         # Post-install template setup
└── types.ts           # TypeScript definitions

🧪 Testing

npm test                # Run all tests with Node.js test runner
npm run test:watch      # Watch mode for development
npm run coverage        # Run tests with coverage analysis
npm run coverage:open   # Run coverage and open HTML report

Coverage Reports

This project maintains high test coverage:

  • Lines: >72%
  • Functions: >77%
  • Branches: >76%
  • Statements: >72%

Coverage reports are generated in multiple formats:

  • Console: Immediate feedback during development
  • HTML: Detailed report in coverage/index.html
  • LCOV: For CI/CD integration

Development Workflow

For development, read the development workflow file.

📝 License

MIT