CLI Reference

The @nest-extended/cli package installs the nest-cli binary for scaffolding apps and resources.

$npm install -g @nest-extended/cli

Commands

CommandAliasPurpose
nest-cli generate app <name>g appScaffold a complete NestJS app
nest-cli generate service <name>g serviceGenerate a CRUD resource bundle
nest-cli generate authg authAdd an auth + users module to an app
nest-cli migration runm runRun version migration scripts
nest-cli migration eventsm eventsSwitch controllers to the event-firing service methods
nest-cli versionvPrint the CLI version

generate app

nest-cli g app my-api --db PostgreSQL --orm prisma --validator zod --pm npm --auth
FlagAliasValues
--database--dbPostgreSQL, MySQL, SQLite, MongoDB
--orm-oprisma, typeorm, mongoose
--validator-vzod, class-validator
--pkg-manager--pmnpm, yarn, pnpm
--authInclude JWT auth + users module
--skip-authExclude auth

Run without flags for an interactive prompt:

nest-cli g app my-shop

Prisma is pinned to v7. The generator installs @prisma/client@^7, a driver adapter at ^7, and dev prisma@^7. Prisma 8 ("Prisma Next") is a different product — prisma generate and prisma db push no longer exist and the ORM commands moved under prisma orm — and the emitted prisma-client generator block, the ../generated/prisma/client import and the driver adapters all target Prisma 7.

Scaffolded apps are emitted as CommonJS since 1.5.0.

generate service

Generates a full resource — schema/model/entity, module, service, controller, events class, DTO and specs:

nest-cli g service product
nest-cli g service qna/category   # nested path
Generated files
src/schemas/product.schema.ts
src/services/product/product.module.ts
src/services/product/product.service.ts
src/services/product/product.controller.ts
src/services/product/product.events.ts
src/services/product/dto/product.dto.ts
src/services/product/product.service.spec.ts
src/services/product/product.controller.spec.ts
FlagAliasValues
--database-d, --dbPostgreSQL, MySQL, SQLite, MongoDB
--orm-oprisma, typeorm, mongoose
--validator-vzod, class-validator
--events / --skip-eventsGenerate {name}.events.ts — default yes
--broadcast / --skip-broadcastAlso broadcast events via @nestjs/event-emitter — default no
nest-cli g service product --db MongoDB --orm mongoose -v zod --skip-events
nest-cli g service product --db MongoDB --orm mongoose -v zod --events --broadcast

The generated controller calls the event-firing methods (find, get, create, patch, remove) and the events class is registered in the module's providers — see Service Events. --broadcast also installs @nestjs/event-emitter and adds EventEmitterModule.forRoot() to src/app.module.ts.

Events are wired at boot by NestExtendedModule.forRoot(). If that is missing from src/app.module.ts, the CLI warns — the generated events class would never fire.

Name transformation

InputClassVariableFolderRoute
user-profileUserProfileuserProfilesrc/services/userProfile/user-profile
qna/categoryCategorycategorysrc/services/qna/category/qna/category

generate auth

Adds an Auth module (JWT + bcrypt) and a Users module to an existing app:

nest-cli g auth

migration run

Rewrites imports that moved between packages — ModifyBody, User, Public and setCreatedBy from @nest-extended/core to @nest-extended/decorators. Runs over src/**/*.ts.

nest-cli m run

migration events

New in 1.5.0. Switches controllers from the event-free _find / _get / _create / _patch / _remove to their event-firing counterparts, so an existing project starts firing service events.

By default it only touches src/**/*.controller.ts — internal service-to-service calls should keep using the underscore methods so they stay event-free.

FlagPurpose
--dry-runPrint the changes without writing anything
-y, --yesApply without the confirmation prompt
--path <glob>Migrate a different set of files (default src/**/*.controller.ts)
cd my-app
nest-cli m events --dry-run
  src/services/company/company.controller.ts
    _find -> find (line 24)
    _get -> get (line 31)
    ...
 
2 file(s), 10 replacement(s).

It then asks before writing. Because on* hooks are detached and cannot alter a response, this migration does not change any endpoint's output.

Next steps