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

@nest-boot/command

v8.0.0

Published

Type-safe modular NestJS commands with project CLI entry loading

Readme

@nest-boot/command

Type-safe NestJS commands powered by Clipanion 4. Run nb from your application directory to execute its CLI entry script.

Quick start

pnpm add @nest-boot/command @nest-boot/request-context
import { BaseCommand, Command, Option } from "@nest-boot/command";

@Command({
  paths: [["greet"], ["hello", "user"]],
  usage: { description: "Greet a user." },
})
export class GreetCommand extends BaseCommand {
  name = Option.String({ required: true }); // string
  loud = Option.Boolean("--loud", false); // boolean
  prefix = Option.String("--prefix"); // string | undefined

  async execute(): Promise<void> {
    const name = this.loud ? this.name.toUpperCase() : this.name;
    this.context.stdout.write(`${this.prefix ?? "Hello"} ${name}!\n`);
  }
}
// src/app/app.module.ts
import { CommandModule } from "@nest-boot/command";
import { Module } from "@nestjs/common";

import { GreetCommand } from "../greet.command.js";

@Module({ providers: [GreetCommand] })
class GreetingModule {}

@Module({ imports: [CommandModule, GreetingModule] })
export class AppModule {}
// src/cli.ts
import { CommandFactory } from "@nest-boot/command";

import { AppModule } from "./app/app.module.js";

async function bootstrap() {
  await CommandFactory.run(AppModule);
}

void bootstrap();
pnpm exec nb greet Alice --loud
pnpm exec nb --help

Modules register command classes in providers; the CLI discovers commands across the imported module tree and retains Nest dependency injection. Commands and dependencies must be singletons. Parameter types are inferred by Option helpers. Commands implement async execute() and can return an exit code.

Development prefers src/cli.ts; production (NODE_ENV=production) prefers dist/cli.js. The entry calls CommandFactory.run(AppModule), which sets process.exitCode internally; it needs no exports. Call the factory once from the CLI bootstrap. Every command runs in an independent RequestContext of type "command", including registered context middleware. CommandModule imports RequestContextModule automatically. Application initialization and shutdown hooks run normally; execution always closes the Nest application context. Source execution uses ts-node in transpile-only mode with its experimentalResolver and preferTsExts options enabled. ESM loading, relative extension remapping, decorator metadata and JSX follow the project tsconfig and ts-node settings. Source applications use "type": "module" and module/moduleResolution set to "NodeNext". Configure experimentalDecorators and emitDecoratorMetadata for Nest dependency injection. Without a tsconfig, the CLI uses NodeNext and Nest decorator defaults.

ts-node does not automatically implement paths, baseUrl or dist-to-src mappings. Configure any runtime aliases in your project. See the ts-node documentation.

Use CommandFactory.run(AppModule, { args }) for programmatic command execution; it returns an exit code without exiting the process. runCli({ cwd, production }) executes the project entry script, which calls the factory to bootstrap the application and set its exit code.

RequestContext.get(token) falls back to Nest singleton providers; unavailable or scoped providers return undefined.

After publication, npm install -g @nest-boot/command provides a global nb executable. Run it from the application directory; the project still installs this package and its peers and provides its own CLI entry and module registration.

The repository example is runnable with pnpm --filter @nest-boot/example-server command greet Alice --loud after configuring its services and applying database migrations.

Unit tests live beside the source and run with pnpm --filter @nest-boot/command test:cov. CLI e2e tests run with pnpm --filter @nest-boot/command test:e2e after building the package. Vitest reports module coverage in coverage; c8 reports coverage from the CLI child processes and loader threads in coverage/e2e. Both reports contribute to Codecov, together covering every production source file.

Full documentation