nestjs/nest-cli

Add an option to skip testing and linting packages/configurations when creating a new project.

mkvlrn opened this issue · 3 comments

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

Not related to a problem, just a suggestion to add more flexibility when creating new projects with the CLI.

Describe the solution you'd like

I would like to be able to use options in the CLI when creating a new project in order to not add features that are currently added to all projects.

The features would be testing (no Jest, no Supertest, no testing configuration, no automatic spec creation, no test scripts in package.json) and linting (no Eslint and no Eslint configuration).

Teachability, documentation, adoption, migration strategy

Something like nest new --skip-testing --skip-linting to not install the packages and skip the configurations would be excellent.

It wouldn't change the default behavior of the CLI, adding just flags for an opt-in, more customized CLI experience.

What is the motivation / use case for changing the behavior?

  • Reduce "friction" to clean up the project of unused configurations/packages when using different tools such as Vitest/PactumJS for testing or Biome for linting
  • Make the CLI less opinionated when it comes to features not directly related to Nest (like it doesn't exactly push TypeORM out of the box, even presenting a help section for Prisma in the docs)
  • I know this isn't a big reason, but having the ability to prototype something without too many "extras" feels like a better experience to me

as of now you can run npm init nest in order to generate a really tiny standard nestjs project. See the code here: https://github.com/micalevisk/create-nest

example
├── nest-cli.json
├── package.json
├── package-lock.json
├── src
│   ├── app.module.ts
│   └── main.ts
├── tsconfig.build.json
└── tsconfig.json

1 directory, 7 files
{
  "name": "foo",
  "version": "1.0.0",
  "description": "",
  "main": "dist/src/main",
  "scripts": {
    "build": "nest build",
    "start:dev": "nest start --watch",
    "start:prod": "node ."
  },
  "keywords": [],
  "author": "Micael Levi L. C.",
  "license": "ISC",
  "dependencies": {
    "@nestjs/common": "^10.3.7",
    "@nestjs/core": "^10.3.7",
    "@nestjs/platform-express": "^10.3.7"
  },
  "devDependencies": {
    "@nestjs/cli": "^10.3.2",
    "@types/node": "^20.12.7",
    "typescript": "^5.4.5"
  }
}

@micalevisk this is VERY impressive, I love it!

The one thing I would like to suggest is to make it aware of pnpm, because, even though running pnpm create nest worked just fine, it installed dependencies with npm.

Edit: @micalevisk issue created

I'd suggest:

--skip-tests   Do not generate testing files for the new project.

inspired by Angular CLI.

This would set generateOptions.spec to false as well