# @hodfords/nestjs-command

> A utility for running CLI commands in NestJS apps

Latest version **12.3.1** (published 2026-09-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install @hodfords/nestjs-command
pnpm add @hodfords/nestjs-command
yarn add @hodfords/nestjs-command
bun add @hodfords/nestjs-command
```

Provides the command `wz-command`.

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 12.3.1 |
| Published | 2026-09-13 |
| First published | 2022-11-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20.19.0 |
| Dependencies | 2 |
| Unpacked size | 82.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 46 |
| Maintainers | nguyentiendung-dev |

## Links

- npm: https://www.npmjs.com/package/@hodfords/nestjs-command
- Repository: https://github.com/hodfords-solutions/nestjs-command
- Homepage: https://github.com/hodfords-solutions/nestjs-command#readme
- Issues: https://github.com/hodfords-solutions/nestjs-command/issues
- npm.io page: https://npm.io/package/@hodfords/nestjs-command

## Dependencies (2)

- [pluralize](https://npm.io/package/pluralize.md) ^8.0.0
- [es-toolkit](https://npm.io/package/es-toolkit.md) 1.52.0

## Recent versions

- 12.3.1 (latest) — 2026-09-13
- 12.3.0 — 2026-09-01
- 12.2.0 — 2026-08-31
- 12.1.1 — 2026-08-29
- 12.1.0 — 2026-08-29
- 12.0.0 — 2026-08-28
- 11.0.10 — 2026-03-17
- 11.0.9 — 2026-03-03
- 11.0.8 — 2026-02-04
- 11.0.6 — 2025-04-21
- 11.0.5 — 2025-04-17
- 11.0.4 — 2025-03-18
- 11.0.3 — 2025-02-11
- 11.0.2 — 2025-02-10
- 11.0.1 — 2025-02-10
- … 16 more at https://npm.io/package/@hodfords/nestjs-command/versions

## README

<p align="center">
  <a href="http://opensource.hodfords.uk" target="blank"><img src="https://opensource.hodfords.uk/img/logo.svg" width="320" alt="Hodfords Logo" /></a>
</p>

<p align="center"> <b>nestjs-command</b> simplifies creating and managing CLI commands in NestJS applications. It offers an easy way to define and execute commands, streamlining CLI integration and boosting productivity with minimal configuration.</p>

## Requirements 📋

-   This package is **ESM-only**. Your project must be able to `import` it — CommonJS `require()` of it is not supported.
-   Node.js `>= 20.19.0` (or `>= 22.12`, `>= 24.15`, `>= 26`).
-   NestJS 12.

| `@hodfords/nestjs-command` | NestJS |
| -------------------------- | ------ |
| `12.x`                     | `12.x` |
| `11.x`                     | `11.x` |

## Installation 🤖

Install the `nestjs-command` package with:

```
npm install @hodfords/nestjs-command --save
```

Set up in your codebase:

-   `src/config/command.config.ts`

```typescript
import { CommandModule } from '@hodfords/nestjs-command';

export const commandConfig = CommandModule.register();

// export const = CommandModule.register(false) if typeorm is disabled
```

-   `src/app.module.ts`

```typescript
import { Module } from '@nestjs/common';
import { commandConfig } from '~config/command.config';

@Module({
    imports: [commandConfig],
    controllers: [],
    providers: []
})
export class AppModule {}
```

-   `src/cli.ts`

```typescript
import { NestFactory } from '@nestjs/core';
import { CommandService } from '@hodfords/nestjs-command';
import { commandConfig } from '~config/command.config';

async function bootstrap() {
    const app = await NestFactory.createApplicationContext(AppModule);
    const commandService: CommandService = app.select(commandConfig).get(CommandService, { strict: true });
    await commandService.exec();
    await app.close();
}

bootstrap();
```

-   `package.json`

```json
"wz-command": "wz-command"
```

The entry file is resolved from `CLI_PATH` (default `./src/cli.ts`), relative to the directory you run the command from. When the entry is a TypeScript file, install `ts-node`, `tsx` or `@swc-node/register` in your application: it is registered as an ESM loader for projects with `"type": "module"`, and through `ts-node/register` plus `tsconfig-paths` for CommonJS projects.

## Usage 🚀

Here’s how you can use them. For each type of component, you can use one of the two available command formats: with `npm run` or directly with `wz-command`

### Make a command

```bash
npm run wz-command make-command <file-name> -- --module <module-name>
```

```bash
wz-command make-command <file-name> --module <module-name>
```

### Make a controller

```bash
npm run wz-command make-controller <file-name> -- --module <module-name>
```

```bash
wz-command make-controller <file-name> --module <module-name>
```

### Make a dto

```bash
npm run wz-command make-dto <file-name> -- --module <module-name>
```

```bash
wz-command make-dto <file-name> --module <module-name>
```

### Make an e2e test

```bash
npm run wz-command make-e2e-test <file-name> -- --module <module-name>
```

```bash
wz-command make-e2e-test <file-name> --module <module-name>
```

### Make an entity

```bash
npm run wz-command make-entity <file-name> -- --module <module-name>
```

```bash
wz-command make-entity <file-name> --module <module-name>
```

### Make a migration

#### Create table

```bash
npm run wz-command make-migration <file-name> -- --module <module-name> --create=<entity-name>
```

```bash
wz-command make-migration <file-name> --module <module-name> --create=<entity-name>
```

#### Update table

```bash
npm run wz-command make-migration <file-name> -- --module <module-name> --update=<entity-name>
```

```bash
wz-command make-migration <file-name> --module <module-name> --update=<entity-name>
```

### Make a module

```bash
npm run wz-command make-module <module-name>
```

```bash
wz-command make-module <file-name>
```

### Make a repository

```bash
npm run wz-command make-repository <file-name> -- --module <module-name>
```

```bash
wz-command make-repository <file-name> --module <module-name>
```

### Make a service

```bash
npm run wz-command make-service <file-name> -- --module <module-name>
```

```bash
wz-command make-service <file-name> --module <module-name>
```

### List all scheduled cron jobs

```bash
npm run wz-command list-cron-jobs
```

```bash
wz-command list-cron-jobs
```

### Run specific cron jobs

```bash
npm run wz-command run-cron-jobs -- --jobs <jobName>
```

```bash
wz-command run-cron-jobs --jobs <jobName>
```

## License 📝

This project is licensed under the MIT License

---
_Source: https://npm.io/package/@hodfords/nestjs-command · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
