create-nest-ddd-starter
v0.1.3
Published
Scaffold a NestJS starter project
Downloads
21
Readme
nest-ddd-starter
Scaffold a NestJS starter project from a template using npm create.
This repository contains:
- The CLI (repo root): the publishable
create-nest-ddd-starterpackage - A preserved starter project: the NestJS starter lives in
template/(a maintained copy of the starter; the CLI downloads a GitHub template by default)
Requirements
- Node.js >= 20
- npm >= 10
Quick start
Create a new project:
npm create nest-ddd-starter@latest my-appOr run via npx:
npx --package create-nest-ddd-starter@latest create-nest-ddd-starter my-appAfter generation:
cd my-app
npm run start:devHow the CLI works
- Downloads the template (via
degit, no git history) into the target folder - Customizes a few files based on your choices (database, Docker)
- Runs
npm installunless you opt out
If the target directory already exists and is not empty, the CLI will exit with an error.
Usage
create-nest-ddd-starter [projectName] [options]When using npm create, pass CLI flags after --:
npm create nest-ddd-starter@latest my-app -- --db postgres --dockerInteractive mode
Any missing values will be prompted for:
- Project name (if omitted or invalid)
- Database (
postgresormysql) - Include Docker files? (default: yes)
Example:
npm create nest-ddd-starter@latestOptions
--db <postgres|mysql>: Database to configure--docker: Include Docker files (Dockerfile,compose.yaml)--skip-install: Skip runningnpm install
Notes:
- To run completely non-interactive, provide
projectName,--db ..., and--docker(otherwise you’ll be prompted). - There is currently no
--no-dockerflag. If you want no Docker files, run interactively and answer “no” to the Docker prompt.
Examples
# Postgres + Docker + install deps
npm create nest-ddd-starter@latest my-app -- --db postgres --docker
# MySQL + Docker + skip install
npm create nest-ddd-starter@latest my-app -- --db mysql --docker --skip-installTemplate source
By default, the CLI downloads this template:
jeffpham2906/nestjs-starter-template/template
Override the template repo via env var (format: owner/repo/subdir):
export CREATE_NEST_STARTER_TEMPLATE_REPO="<owner>/<repo>/template"Example:
export CREATE_NEST_STARTER_TEMPLATE_REPO="jeffpham/nest-ddd-starter/template"
npm create nest-ddd-starter@latest my-appImportant:
- The template repository must be public (otherwise
degitwill fail to download).
What gets customized
After download, the CLI updates the generated project:
- Sets
package.jsonnameto your project name - Writes
.envand.env.examplefor the chosen database - If Docker is not included, removes
Dockerfileandcompose.yaml
If you choose MySQL, it also makes a few MySQL-specific adjustments (when the files exist in the template):
- Switches Prisma provider in
prisma/schema.prismafrom Postgres to MySQL - Rewrites
src/cross-cutting/db/prisma.module.tsto a minimal Prisma module - Replaces
compose.yamlwith a MySQL service definition
Local development (for contributors)
Install dependencies:
npm installRun the CLI in dev mode (TypeScript via tsx):
npm run dev -- my-app --db postgres --dockerBuild:
npm run buildSmoke test the built CLI:
node dist/index.js --helpPublishing
To make this available as:
npm create nest-ddd-starter@latest my-apppublish this package to npm under the name create-nest-ddd-starter:
npm login
npm version patch
npm publish --access publicVerify:
npm view create-nest-ddd-starter versionLicense
MIT
