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

daniel-code-generator

v1.2.4

Published

Generate code files.

Readme

daniel-code-generator

A tiny, focused CLI that generates TypeScript class boilerplate for you.

Given a class name, it will:

  • Create a .ts file next to the compiled CLI
  • Define a class with that name
  • Export a singleton instance of that class

This is handy when you’re rapidly sketching new classes and don’t want to keep writing the same scaffolding over and over.


Installation

Add it to your project as a dev dependency:

npm install daniel-code-generator --save-dev

Or with pnpm:

pnpm add daniel-code-generator -D

Build the TypeScript once so the CLI is available:

npm run build

This compiles to the build directory and wires the generate binary (see bin.generate in package.json).


Usage

From your project root, run:

npx generate MyService

or, if installed locally and your node_modules/.bin is on PATH:

generate MyService

This will create a new file MyService.ts next to the built CLI (inside the compiled build directory), containing:

class MyService {
    
}

export const myService = new MyService();

Where:

  • className is the argument you pass (e.g. MyService)
  • The exported constant name is the same but with a lower‑cased first letter (e.g. myService)

How it works (internals)

  • Entry point: src/app.ts
    • Reads the class name from process.argv[2]
    • Calls generateCode(className)
  • Core logic: src/generator.ts
    • Builds a small TypeScript snippet with a class and exported singleton
    • Writes it synchronously using fs.writeFileSync
    • Resolves the output path with Node’s path.join(__dirname, className + ".ts")

You don’t need to interact with these files directly to use the CLI, but they’re simple enough to tweak if you want to change the generated template.


Examples

  • Generate a repository class

    npx generate UserRepository

    Produces UserRepository.ts:

    class UserRepository {
          
    }
    
    export const userRepository = new UserRepository();
  • Generate a controller

    npx generate AuthController

    Produces AuthController.ts with export const authController = new AuthController();


Notes & limitations

  • Single responsibility: the generator currently only creates:
    • an empty class body, and
    • a default exported instance.
  • Output directory: files are created relative to the compiled CLI (build folder after npm run build), not your project src folder.
  • TypeScript only: the generated files are .ts files.

If you want to evolve this into a more powerful scaffolding tool (e.g. templates, custom output paths, multiple files), this project is a good minimal starting point.


License

ISC © Daniel Machluf