@nestjs-dash/cli
v1.0.6
Published
CLI generators for NestJS Dash
Downloads
1,365
Readme
@nestjs-dash/cli
CLI scaffolding for NestJS Dash — a thin wrapper that runs @nestjs-dash/schematics against your NestJS project via @angular-devkit/schematics.
Install
pnpm add -D @nestjs-dash/cli
# or
npm install -D @nestjs-dash/cli
# or
bun add -d @nestjs-dash/cliInstalls the nestjs-dash binary. Run it through your package manager:
pnpm exec nestjs-dash generate resource Bid # pnpm
npx nestjs-dash generate resource Bid # npm
bunx nestjs-dash generate resource Bid # bunOr one-off without installing: npx @nestjs-dash/cli generate resource Bid (or pnpm dlx @nestjs-dash/cli ...).
Usage
Run from anywhere inside a NestJS project. The CLI walks up from the current directory to the nearest package.json that lists @nestjs/core in dependencies or devDependencies, and treats that folder as the project root. Path flags (--dir, --resource, --panel) are resolved relative to the current directory (absolute paths are accepted) and must point inside the project root — paths that escape it are rejected.
nestjs-dash --version
nestjs-dash --help
nestjs-dash generate --help
nestjs-dash generate resource --helpgenerate has the alias g, so nestjs-dash g res Bid is the same as nestjs-dash generate resource Bid.
Common flags
| Flag | Commands | Meaning |
| --- | --- | --- |
| --dry-run | all | Print the files that would be written; write nothing. |
| --verbose | all | Print detailed diagnostics (each created/updated path, fuzzy-match reasoning, codemod results). |
| --force | resource, panel, relation-manager only | Overwrite existing generated files. On an interactive terminal you are asked to confirm first; in a non-interactive session (CI) --force proceeds without asking. |
Without --force, generated files that already exist are skipped with a Skipped (already exists): <path> warning. If the schematics engine itself hits a file conflict, it prints ERROR! <path> already exists. (or does not exist.) and nothing is written.
Prompts and non-interactive sessions
The <Name> argument and each command's required option (--dir, --resource, --panel) must be given on the command line — they are never prompted for. On an interactive terminal the CLI may ask:
resource: whether to also scaffold a custom page (when--pageis not passed);resource: which entity file is the model, when the target folder has several*.entity.tsfiles;resource: to confirm a fuzzy-matched existing module folder (when--diris not passed);--force: to confirm overwriting existing files.
In a non-interactive session (CI, piped output) these questions are skipped: optional values fall back to their defaults, a fuzzy-matched folder is used as-is, and the multiple-entity-files case fails with an error listing the candidates.
Exit codes
0 on success; 1 when the project root can't be found, an argument/option is invalid, the schematic fails, or a confirmation prompt is declined.
Commands
generate resource <Name> (alias res)
Scaffold an entity + Resource (and optionally a custom page) into a module folder, wiring it into <folder>.module.ts and, for a new module, the root app module. Without --dir, an existing *.module.ts whose name matches <Name> is reused (you are asked to confirm on a terminal); otherwise src/<kebab-name>s/ is used. If the target folder already has an *.entity.ts, it is reused as the model and its columns drive the table/form declarations.
| Flag | Default | Meaning |
| --- | --- | --- |
| --dir <path> | auto-detected | Target directory, relative to the current directory. |
| --page | false | Also scaffold a custom <Name>Page. |
| --no-entity | entity generated | Skip entity generation and reuse an existing <name>.entity.ts. |
| --force / --dry-run / --verbose | | See Common flags. |
nestjs-dash generate resource Bid --dir src/ads
nestjs-dash g res Bid --dir src/ads --page
nestjs-dash generate resource Bid --dir src/ads --no-entity
nestjs-dash generate resource Bid --dry-rungenerate panel <Name>
Scaffold a standalone Panel + AdminModule.forRoot() file (<name>.panel.ts).
| Flag | Default | Meaning |
| --- | --- | --- |
| --force | false | Overwrite an existing <name>.panel.ts. |
| --dry-run / --verbose | | See Common flags. |
nestjs-dash generate panel Admingenerate relation-manager <Name> (alias rm)
Scaffold a RelationManager subclass under <dir>/relation-managers/, optionally wiring it into an existing Resource file's relationManagers array.
| Flag | Default | Meaning |
| --- | --- | --- |
| --dir <path> | required | Target directory (a relation-managers/ subfolder is added). |
| --related-resource <slug> | dasherized name | Slug of the related resource. |
| --type <type> | has-many | has-many or belongs-to-many. |
| --foreign-key <key> | | Foreign key column on the related entity (has-many only). |
| --title <text> | humanized name | Tab/section title. |
| --resource <path> | | Existing Resource file to wire the generated class into. |
| --force / --dry-run / --verbose | | See Common flags. |
nestjs-dash generate relation-manager Comments --dir src/ads \
--resource src/ads/resources/bid.resource.ts
nestjs-dash g rm Tags --dir src/ads --type belongs-to-many --title "Tags"generate filter <Name> (alias fi)
Wire a TextFilter / SelectFilter / DateFilter on column <Name> into an existing resource's table(). Edits the file in place; writes no new files.
| Flag | Default | Meaning |
| --- | --- | --- |
| --resource <path> | required | Resource (or RelationManager) file to wire into. |
| --kind <kind> | text | text, select or date. |
| --label <text> | humanized column name | Filter label. |
| --options <list> | | --kind select only: comma-separated value:Label pairs, e.g. "active:Active,banned:Banned". |
| --operators <list> | builder default | Comma-separated FilterOperator list, e.g. "$eq,$ilike". |
| --dry-run / --verbose | | See Common flags. |
nestjs-dash generate filter status --resource src/ads/resources/bid.resource.ts \
--kind select --options "open:Open,closed:Closed"generate action <Name> (alias ac)
Wire a custom Action.make(...).handler(...) into an existing resource's table(). Edits the file in place; writes no new files.
| Flag | Default | Meaning |
| --- | --- | --- |
| --resource <path> | required | Resource (or RelationManager) file to wire into. |
| --variant <variant> | record | record (row action), bulk or toolbar. |
| --icon <name> | | Lucide icon name, e.g. star. |
| --label <text> | humanized action name | Button label. |
| --dry-run / --verbose | | See Common flags. |
nestjs-dash generate action publish --resource src/ads/resources/bid.resource.ts --icon star
nestjs-dash g ac archive --resource src/ads/resources/bid.resource.ts --variant bulkgenerate widget <Name> (alias wi)
Wire a DashboardWidget (a StatCard, or a bar/line/pie chart) titled <Name> into an existing Panel's widgets(). Edits the file in place; writes no new files.
| Flag | Default | Meaning |
| --- | --- | --- |
| --panel <path> | required | Panel factory file (as scaffolded by generate panel) to wire into. |
| --kind <kind> | stat | stat, bar, line or pie. |
| --side | false | Render in the narrow side column instead of the main column. |
| --dry-run / --verbose | | See Common flags. |
nestjs-dash generate widget "Total Bids" --panel src/admin/admin.panel.ts
nestjs-dash generate widget "Bids by status" --panel src/admin/admin.panel.ts --kind bar --sideDocs: CLI.
License
MIT
