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 🙏

© 2025 – Pkg Stats / Ryan Hefner

scaffoldjs-cli

v1.1.3

Published

A powerful CLI tool for scaffolding code templates with multi-variable support

Readme

ScaffoldJS 🏗️

npm version build License: MIT

A powerful CLI tool for scaffolding code templates with multi-variable support. Generate consistent, organized code structures across your projects with customizable templates and flexible variable transformations.

✨ Features

  • 🎯 Multi-Variable Support - Use multiple custom variables like module, feature, domain, etc.
  • 🔄 Smart Transformations - Built-in case transformations (camelCase, PascalCase, snake_case, etc.)
  • 📁 Flexible Structure - Generate files in any directory structure
  • 💉 Template Injection - Inject code snippets into existing files
  • 👥 Template Groups - Generate multiple related files at once
  • 🔧 Configurable - JSON-based configuration for all templates
  • ⚡ CLI Friendly - Simple, intuitive command-line interface
  • 🔄 Backward Compatible - Works with existing single-variable setups

🚀 Quick Start

# Install globally
npm install -g scaffoldjs-cli

# Or use directly with npx
npx scaffold help

Initialize Your Project

# Set up configuration and default templates
npx scaffold setup

# View available templates
npx scaffold list

# Get help
npx scaffold help

# View comprehensive guide
npx scaffold guide

📖 Usage

Basic Commands

# Generate a single file
npx scaffold make user controller

# Generate with custom variables
npx scaffold make table controller -v module=restaurant feature=dining

# Generate multiple files using a group
npx scaffold make booking crud-group -v module=hotel feature=reservations

# Inject code into existing files
npx scaffold inject import-statement src/app.module.ts -v module=auth

# Force overwrite existing files
npx scaffold make order service -v module=ecommerce --force

Command Reference

| Command | Description | Example | | ---------------------------- | ------------------------------------- | ------------------------------------------------ | | setup | Initialize scaffoldjs in your project | npx scaffold setup | | list | Show available templates and groups | npx scaffold list | | make <resource> <template> | Generate new files from templates | npx scaffold make user controller | | inject <template> <file> | Inject code into existing files | npx scaffold inject method src/user.service.ts | | help | Display help information | npx scaffold help | | guide | Show comprehensive usage guide | npx scaffold guide |

Options

| Option | Short | Description | Example | | ------------ | ----- | ------------------------------------ | ------------------------------ | | --vars | -v | Custom variables in key=value format | -v module=auth feature=users | | --force | -f | Force overwrite existing files | --force | | --target | -t | Target point for injection | -t "// inject:methods" | | --resource | -r | Resource name for injection | -r user |

⚙️ Configuration

scaffold.config.json

The configuration file defines your templates, injection points, and groups:

{
  "version": 1,
  "templates": {
    "controller": {
      "description": "Generate a controller file",
      "src": "./scaffolds/controller.tp",
      "dest": "./src/{{module}}/controllers/{{resource.singular.lowerCase}}.controller.ts"
    },
    "service": {
      "description": "Generate a service file",
      "src": "./scaffolds/service.tp",
      "dest": "./src/{{module}}/services/{{resource.singular.lowerCase}}.service.ts"
    },
    "import-statement": {
      "description": "Import statement for injection",
      "src": "./scaffolds/{{feature}}-import.tp",
      "dest": "inject"
    },
    "crud-group": ["controller", "service", "dto", "entity"]
  }
}

Template Structure

your-project/
├── scaffold.config.json
├── scaffolds/
│   ├── controller.tp
│   ├── service.tp
│   ├── dto.tp
│   └── auth-import.tp
└── src/
    └── (generated files will go here)

🔧 Variables & Transformations

Built-in Variables

  • resource - Automatically provided primary variable
  • Custom variables - Any variables you define (module, feature, domain, etc.)

Available Transformations

| Transformation | Example Input | Example Output | | -------------- | -------------- | -------------- | | raw | user-account | user-account | | singular | users | user | | plural | user | users | | lowerCase | UserAccount | useraccount | | upperCase | user | USER | | camelCase | user-account | userAccount | | pascalCase | user-account | UserAccount | | snakeCase | user-account | user_account | | spaceCase | user-account | user account | | hyphenCase | user account | user-account | | sentenceCase | user-account | Useraccount |

Chaining Transformations

{{resource.singular.pascalCase}}     // user-accounts → UserAccount
{{module.plural.upperCase}}          // auth → AUTHS
{{feature.singular.camelCase}}       // dining-tables → diningTable

📝 Template Examples

Controller Template (scaffolds/controller.tp)

import { Controller, Get, Post, Put, Delete, Body, Param } from '@nestjs/common';
import { {{resource.singular.pascalCase}}Service } from '../services/{{resource.singular.lowerCase}}.service';
import { Create{{resource.singular.pascalCase}}Dto } from '../dto/{{resource.singular.lowerCase}}.dto';

@Controller('{{module}}/{{feature}}/{{resource.plural.lowerCase}}')
export class {{resource.singular.pascalCase}}Controller {
  constructor(
    private readonly {{resource.singular.camelCase}}Service: {{resource.singular.pascalCase}}Service
  ) {}

  @Get()
  async findAll{{resource.plural.pascalCase}}() {
    return this.{{resource.singular.camelCase}}Service.findAll();
  }

  @Post()
  async create{{resource.singular.pascalCase}}(@Body() dto: Create{{resource.singular.pascalCase}}Dto) {
    return this.{{resource.singular.camelCase}}Service.create(dto);
  }
}

// Generated for {{module}} module, {{feature}} feature

Import Injection Template (scaffolds/auth-import.tp)

import { {{resource.singular.pascalCase}}Module } from './{{module}}/{{resource.singular.lowerCase}}.module';

🎯 Real-World Examples

E-commerce Application

# Generate product management
npx scaffold make product crud-group -v module=catalog feature=products

# Generate order processing
npx scaffold make order service -v module=sales feature=checkout

# Add authentication
npx scaffold make user controller -v module=auth feature=users

Generated structure:

src/
├── catalog/
│   ├── controllers/product.controller.ts
│   ├── services/product.service.ts
│   ├── dto/product.dto.ts
│   └── entities/product.entity.ts
├── sales/
│   └── services/order.service.ts
└── auth/
    └── controllers/user.controller.ts

Hotel Management System

# Room management
npx scaffold make room full-feature -v module=hotel feature=rooms

# Booking system
npx scaffold make booking crud-group -v module=reservations feature=bookings

# Guest services
npx scaffold make guest service -v module=hospitality feature=guests

Multi-tenant SaaS

# Tenant management
npx scaffold make tenant controller -v module=core domain=admin

# Feature modules per tenant
npx scaffold make dashboard service -v module=analytics domain=tenant

# Billing system
npx scaffold make invoice crud-group -v module=billing domain=finance

💉 Code Injection

Inject code snippets into existing files at specific points:

# Inject import statements
npx scaffold inject import-statement src/app.module.ts -v module=auth

# Inject methods into services
npx scaffold inject crud-methods src/user.service.ts -r user

# Inject routes with target point
npx scaffold inject api-route src/app.routes.ts -t "// inject:routes" -v module=auth

Injection Targets

  • Automatic placement - Top/bottom of file (prompted)
  • Specific markers - // inject:imports, <!-- inject:methods -->, etc.
  • Duplicate prevention - Automatically skips if content already exists

🔄 Migration from Single Variable

Existing templates using only {{resource}} variables continue to work seamlessly:

// Old template - still works
export class {{resource.pascalCase}}Service {}

// New multi-variable template
export class {{resource.pascalCase}}Service {
  // Module: {{module}}
  // Feature: {{feature}}
}

🛠️ Advanced Configuration

Dynamic Template Paths

{
  "templates": {
    "feature-controller": {
      "src": "./scaffolds/{{feature}}/controller.tp",
      "dest": "./src/{{module}}/{{feature}}/{{resource.plural.lowerCase}}.controller.ts"
    }
  }
}

Conditional Templates

{
  "templates": {
    "api-controller": {
      "src": "./scaffolds/{{module}}/api-controller.tp",
      "dest": "./src/{{module}}/controllers/{{resource.singular.lowerCase}}.controller.ts"
    },
    "web-controller": {
      "src": "./scaffolds/{{module}}/web-controller.tp",
      "dest": "./src/{{module}}/controllers/{{resource.singular.lowerCase}}.controller.ts"
    }
  }
}

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🆘 Support

☕️ Support the Project

If ScaffoldJS has saved you time and helped improve your development workflow, consider buying us a coffee! Your support helps us maintain and improve the project.

Buy Me A Coffee

Other ways to support:

  • Star the project on GitHub
  • 🐛 Report bugs and suggest features
  • 📖 Improve documentation
  • 📢 Share with your team and on social media

Every contribution, no matter how small, helps make ScaffoldJS better for everyone! 🙏

🗺️ Roadmap

  • [ ] Custom Transformations - User-defined transformation functions
  • [ ] Template Inheritance - Template extending and composition
  • [ ] IDE Integration - VSCode extension
  • [ ] Interactive Mode - Guided template generation
  • [ ] Template Marketplace - Community template sharing
  • [ ] TypeScript Definitions - Better IntelliSense support

Made with ❤️ by Ebuka Odini

Scaffold smarter, code faster! 🚀