Giter VIP home page Giter VIP logo

schematics's People

Contributors

adursun avatar avatsaev avatar avishayhajbi avatar bejewel-kyoungmin avatar dependabot[bot] avatar devule avatar elijaholmos avatar elylucas avatar fossamagna avatar garritfra avatar hiukky avatar johnbiundo avatar kamilmysliwiec avatar micalevisk avatar mickl avatar pdobrowolski99 avatar phillip9587 avatar renovate-bot avatar renovate[bot] avatar santoshyadavdev avatar sikora00 avatar simonniliussap avatar talentumtuum avatar thomas-waldbillig avatar thomrick avatar tony133 avatar udanpe avatar wonderpanda avatar xcambar avatar yigitkurtcu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

schematics's Issues

module-import.declarator.ts breaks when using multi-line imports

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When Prettier has formatted app.module.ts to make imports from @nestjs/common multi-line, new module generation fails.

Before:

import {
  Module,
  NestModule,
  MiddlewareConsumer,
  RequestMethod,
} from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ExamplesModule } from './examples/examples.module';
import { OpaModule } from './opa/opa.module';
import { ConfigModule } from './config/config.module';
import { HealthModule } from './health/health.module';
import { JwtDecoder } from './jwt/jwtDecoder.middleware';
import { StatsDMiddleware } from './stats-d/stats-d.middleware';
import { StatsDModule } from './stats-d/stats-d.module';
import ormconfig from './db/config';

@Module({
  imports: [
    TypeOrmModule.forRoot(ormconfig),
    ExamplesModule,
    OpaModule,
    ConfigModule,
    HealthModule,
    StatsDModule,
  ],
})
export class AppModule implements NestModule {
  public configure(consumer: MiddlewareConsumer): void {
    consumer
      .apply(StatsDMiddleware, JwtDecoder)
      .forRoutes({ path: '*', method: RequestMethod.ALL });
  }
}

After running nest g mo ExamplesSearch:

import {
import { TypeOrmModule } from '@nestjs/typeorm';
import { ExamplesModule } from './examples/examples.module';
import { OpaModule } from './opa/opa.module';
import { ConfigModule } from './config/config.module';
import { HealthModule } from './health/health.module';
import { JwtDecoder } from './jwt/jwtDecoder.middleware';
import { StatsDMiddleware } from './stats-d/stats-d.middleware';
import { StatsDModule } from './stats-d/stats-d.module';
import { ExamplesSearchModule } from './examples-search/examples-search.module';
  Module,
  NestModule,
  MiddlewareConsumer,
  RequestMethod,
} from '@nestjs/common';
import ormconfig from './db/config';

@Module({
  imports: [
    TypeOrmModule.forRoot(ormconfig),
    ExamplesModule,
    OpaModule,
    ConfigModule,
    HealthModule,
    StatsDModule,
    ExamplesSearchModule,
  ],
})
export class AppModule implements NestModule {
  public configure(consumer: MiddlewareConsumer): void {
    consumer
      .apply(StatsDMiddleware, JwtDecoder)
      .forRoutes({ path: '*', method: RequestMethod.ALL });
  }
}

Expected behavior

I would expect the code generation to not to produce invalid syntax.

Minimal reproduction of the problem with instructions

See above.

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

n/a

Environment

 _   _             _      ___  _____  _____  _     _____
| \ | |           | |    |_  |/  ___|/  __ \| |   |_   _|
|  \| |  ___  ___ | |_     | |\ `--. | /  \/| |     | |
| . ` | / _ \/ __|| __|    | | `--. \| |    | |     | |
| |\  ||  __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/  \____/\_____/\___/


[System Information]
OS Version     : macOS Mojave
NodeJS Version : v10.16.1
YARN Version    : 1.17.3
[Nest Information]
@nestjsx/crud-typeorm version : 4.2.0
platform-express version      : 6.0.0
@nestjsx/crud version         : 4.2.0
swagger version               : 3.1.0
typeorm version               : 6.1.3
common version                : 6.0.0
core version                  : 6.0.0

NODE_ENV not set when using start:prod task

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When using npm run start:prod to run the app, NODE_ENV is not set to production.

Expected behavior

When using npm run start:prod to run the app, NODE_ENV is set to production.

Minimal reproduction of the problem with instructions

Create a new nest application, choosing the typescript option. Run npm run start:prod.

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

When using .env files, I would like to load a different .env file for production.

Environment


Nest version: 6.0.0

 
For Tooling issues:
- Node version: 11.13.0
- Platform:  Linux

Use process.env for PORT

I'm submitting a...

  • Regression
  • Bug report
  • Feature request
  • Documentation issue or request
  • Support request

Current behavior

Starting a new project includes an anti-pattern concerning the handling of configuration. Specifically, src/main.ts has the app listen on a hardcoded port.

E.g.

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  await app.listen(3000);
}
bootstrap();

On its own this is a seemingly small thing, but it elevates the risk of projects neglecting one of the tenants of The Twelve-Factor App:

Store config in the environment

https://12factor.net/config

A consumer of the framework would need to be aware of this anti-pattern and discover the documentation recommending how to properly handle configuration with Nest.

Expected behavior

Instead of the app listening to a hardcoded port, use a ConfigService class as suggested in the docs to pull the port from the environment.

Documentation should also link users to the page on configuration techniques.

Minimal reproduction of the problem with instructions

Start a new project with Nest's CLI (nest new project) and see that src/main.ts has hardcoded port.

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

Two motivations for this feature request:

  1. Mitigate risk of applications being built on top of an anti-pattern.
  2. Educate developers who are newer to backend development by putting best practices in the critical path of using Nest.

Environment


@nestjs/cli: 5.8.0
@nestjs/common: 5.4.0
@nestjs/core: 5.4.0

default .gitignore file not match `coverage` after running script `test:cov`

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When using command nest new <appname> to generate new app,
and executing yarn test:cov executing jest with coverage report.

the coverage report folder will be generated under <projectDir>/src/coverage.

which can not ignored by default .gitignore rules /coverage

Expected behavior

coverage report dirs should be ignored by default.

e.g

should update /coverage in .gitignore to coverage ?

Minimal reproduction of the problem with instructions

please use below command to generate new application and run

nest new some-app
cd some-app
yarn test:cov   # or npm test:cov
git status

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

Environment


Nest version: 6.12.9

 
For Tooling issues:
- Node version: 12.13.1  
- Platform:  Mac 

Others:

Move to .template for schematics

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Right now we are using .ts and .js files in schematics, Angular has already move to .template to avoid the compilation issue.

Expected behavior

Move the schematics to .template.

Minimal reproduction of the problem with instructions

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

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Missing .eslintrc.js on new application

I'm submitting a...


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Now, as you change to ESLint, when you generate a new project the .eslintrc.js file is missing, but it is present at schematics/src/lib/application/files/ts

The same behaviour is happening with .prettierrc file.

Expected behavior

When you create a new Nest application, the .eslintrc.js file should be present.

Minimal reproduction of the problem with instructions

Create a new application using the nest new command.

Environment


Nest version: 
ฮป nest info

 _   _             _      ___  _____  _____  _     _____
| \ | |           | |    |_  |/  ___|/  __ \| |   |_   _|
|  \| |  ___  ___ | |_     | |\ `--. | /  \/| |     | |
| . ` | / _ \/ __|| __|    | | `--. \| |    | |     | |
| |\  ||  __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/  \____/\_____/\___/


[System Information]
OS Version     : Windows 10
NodeJS Version : v12.14.1
NPM Version    : 6.13.4

[Nest CLI]
Nest CLI Version : 6.14.1

[Nest Platform Information]
platform-express version : 6.10.14
common version           : 6.10.14
core version             : 6.10.14

 
For Tooling issues:
- Node version: 12.14.1  
- Platform:  Windows 

Others:
Package manager: yarn
Language: Typescript

Change tsconfig baseUrl from "./" to "./src"

Is there any argument against this change ?

Building and testing still works as expected.

In tsconfig.json change baseUrl from ./ to ./src

{
  "compilerOptions": {
    "baseUrl": "./src"
  }
}

This will allow us to use absolute paths without src prefix:

BEFORE

import { UserModel } from 'src/models';

AFTER CHANGE

import { UserModel } from 'models';

file I'm talking about: https://github.com/nestjs/schematics/blob/master/src/lib/application/files/ts/tsconfig.json

HMR main file - better developer experience

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

main.hmr.ts file makes people confused. CC nestjs/nest#1140

Expected behavior

Add explanatory comments to the main.hmr.ts file OR remove it by default.

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

To help prevent future new user confusion.

Allow switching the suffix for test files to `.test.ts` instead of `.spec.ts`

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Currently, the all the schematics use .spec.{ts,js} as a suffix for the test files.

Expected behavior

There is a configuration option (probably threaded through the cli from .nestcli.json to switch the test suffix from .spec.{ts,js} to .test.{ts,js}.

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

It's pretty common practice to give test files the suffix .test.{ts,js} (in fact, the tests for this very project itself follow that pattern). Could we add an option to make this configurable?

CLI schematics integration

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request

Current behavior

CLI schematics are in dependencies.

Expected behavior

Schematics should be in the CLI source code.

Minimal reproduction of the problem with instructions

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

  • Avoid development on 2 separate repositories.
  • Reduce dependency management issues.
  • Reduce release time.

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Improve compatibility with Nx

I'm submitting a...

[ ] Regression
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request

Current behavior

NestJS schematics are currently incompatible with Nx.

Expected behavior

As per the pull request by @FallenRiteMonk over at the Nx repository, NestJS should be compatible with Nx.

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

@FrozenPandaz mentioned that they have reached out to @kamilmysliwiec regarding the above mentioned pull request, and that he has expressed interest in making this happen. Whether that comes to fruition is to be decided, but I was hoping to at least start a conversation, as both Nx and NestJS are invaluable assets to many of us.

Environment

Nest version: 5.4.0

feature(javascript): Manage Javascript files

Now, when you use the application schematic, you only are able to create a Typescrit new project. Maybe if you add a parameter to choose between typescript and JavaScript will be useful for some ppl that dont want to use typescript. This is nothing strange, at nestjs official documentation you have a guide for this.

In my opinion, choose JavaScript instead typescript is a bad idea, but some ppl dont like or dont want to change to typescript. What is your opinion? It's just a suggestion and I want to know if you have any plan for JavaScript.

Thx 4 ur time.

Guards/Filters/Interceptors[..] are generated in dedicated directories

Current behavior

Guards/Filters/Interceptors[..] are generated in the dedicated directories, for example, http-filter is generated in the following manner:

./src/http-filter/http-filter.filter.ts

Expected behavior

Guards/filters/interceptors/middlewares should be generated without their directories, example:

./src/http-filter.filter.ts

That's the convention set out in the docs

Add GraphQL Schematics

As GraphQL is one of the most uprising technologies, please add a Resolver schematic :)

Generate .gitignore when create ts project

AS a user I WANT TO have a prepared .gitignore WHEN I use nest new command

How to demo :

  • execute schematics @nestjs/schematics:application --name=app
  • verify there is a .gitignore file

[Feature request] Generate class with suffix

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

command

nest g cl User.Entity

file

user.entity.ts

code

export class User.Entity {}

Expected behavior

command

nest g cl User --suffix entity or nest g cl User -s entity

file

user.entity.ts

code

export class User {}

additional

User.Entity is not a legal class name. If command like nest g cl User.Entity shall generate export class UserEntity {} without illegal characters. But in filename shall keep the dot because it legal and consider as a suffix.

Minimal reproduction of the problem with instructions

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

The file pattern of nest.js is like angular that each file has a suffix to represent its role in the project. So we shall add suffix to every file, but class generator is playing not well.

Environment


 _   _             _      ___  _____  _____  _     _____
| \ | |           | |    |_  |/  ___|/  __ \| |   |_   _|
|  \| |  ___  ___ | |_     | |\ `--. | /  \/| |     | |
| . ` | / _ \/ __|| __|    | | `--. \| |    | |     | |
| |\  ||  __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/  \____/\_____/\___/


[System Information]
OS Version     : macOS
NodeJS Version : v10.14.2
NPM Version    : 6.5.0
[Nest Information]
common version : 5.5.0
core version   : 5.5.0
cqrs version   : 5.1.1

App generation in monorepo should generate <appname>.* files

Feature Request

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

When generating apps in monorepo, each is created in the regular app structure, i.e. files named app.module.ts, app.controller.ts...

Describe the solution you'd like

These files (and contents accordingly) should be named differently - coolapp.module.ts, coolapp.controller.ts...

Teachability, Documentation, Adoption, Migration Strategy

No major change required to documentation. Migration is just renaming of components, though the change is backwards compatible anyways. Adoption should be immediate with release, as it affect only new code. Makes teaching monorepo easier as apps follow a naming convention rather than all sharing the same file names.

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

Readability, trackability, disambiguation. Angular-ness?

Update start:dev command (use incremental tsc)

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

ts-node is used

Expected behavior

Same as in typescript-starter, use tsc in the watch mode.

Minimal reproduction of the problem with instructions

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

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Add configuration step to application schematic

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

nest new app always generates a typical web application starter.

Expected behavior

It would be amazing to have an additional configuration step that determines which starter shall be used:

  • Type
    • Web
      • Express
      • Fastify
    • Micro service
      • Redis
      • [...] etc
    • App shell (context)

Minimal reproduction of the problem with instructions

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

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Incorrect README.md commands for yarn

I'm submitting a...


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Creating a new project using nest new and selecting yarn as package manager incorrectly populates README.md with npm commands.

Expected behavior

nest new with yarn should populate README.md with yarn commands.

Minimal reproduction of the problem with instructions

nest new asd -p yarn

Environment

$ nest -V: 6.11.3

Switch from tslint to eslint

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

TsLint is used.

Expected behavior

Use typescript-eslint because tslint is transitioning to typescript-eslint

Minimal reproduction of the problem with instructions

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

Continued maintenance

Add more control in service generate

AS a user I WANT to provide path WHEN I generate a service IN ORDER TO have more control and follow angular-cli usage

  • generate in root project folder by default
  • use provided path to create intermediate folders

ReferenceError: dependencies is not defined

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When clone this repo and use npm link to debug, i use npm link @nestjs/schematics on cli,but it ReferenceError: dependencies is not defined. I found directory structure is different

Current

โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ collection.json
โ”œโ”€โ”€ lib
โ”œโ”€โ”€ node_modules
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ utils

By npm link

.
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ Makefile
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ node_modules
โ”œโ”€โ”€ package-lock.json
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ renovate.json
โ”œโ”€โ”€ scripts
โ”œโ”€โ”€ src
โ”œโ”€โ”€ test
โ”œโ”€โ”€ tsconfig.json
โ”œโ”€โ”€ tslint.json
โ””โ”€โ”€ utils

So, i need copy the files to the correct directory after npm run build. i want know how do you publish this package or the script to publish. i cant't find script to handle this on this repo.

Environment


Nest version: 6.6.4

 
For Tooling issues:
- Node version: 10.15.3  
- Platform:  Mac

Others:

Error message 'supertest_1.default is not a function' when starting e2e test

The following error message is output when calling 'npm run test:e2e' in a newly generated nest.js app:

    TypeError: supertest_1.default is not a function

      17 |
      18 |   it('/ (GET)', () => {
    > 19 |     return request(app.getHttpServer())
         |            ^
      20 |       .get('/')
      21 |       .expect(200)
      22 |       .expect('Hello World!');

      at Object.it (app.e2e-spec.ts:19:12)

The problem is fixed when replacing the supertest import in the e2e spec file to this:

import * as request from 'supertest';

Add ts files to npmignore

I'm submitting a...


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

At this moment, the .ts files are included to the npm package. With this, the typescript module resolution will resolve the ts files instead of .d.ts files.

If someone wants to extend the actual schematics with its own, he can't use the strictNullChecks and noUnusedParameters because it will not compile the application.

Expected behavior

The .ts files should be excluded in the npmignore as you actually do in other repositories.

Minimal reproduction of the problem with instructions

Create a new schematic package which extends the @nestjs/schematics package. Use some utils from the @nestjs/schematics package. Enable the strictNullChecks and noUnusedParameters flags in the tsconfig.json.

When you try to build you will get some compilation erros. Example:


node_modules/@nestjs/schematics/utils/metadata.manager.ts:81:52 - error TS6
133: 'identifier' is declared but its value is never read.

81   private getDecoratorMetadata(source: SourceFile, identifier: string): 
Node[] {
                                                      ~~~~~~~~~~

node_modules/@nestjs/schematics/utils/metadata.manager.ts:186:24 - error TS
2531: Object is possibly 'null'.

186         toInsert = `,${text.match(/^\r?\n(\r?)\s+/)[0]}${symbol}`;     
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@nestjs/schematics/utils/module-metadata.declarator.ts:9:7 - e
rror TS2345: Argument of type 'string | undefined' is not assignable to par
ameter of type 'string'.
  Type 'undefined' is not assignable to type 'string'.

9       options.symbol,
        ~~~~~~~~~~~~~~

node_modules/@nestjs/schematics/utils/module.finder.ts:25:11 - error TS2322
: Type 'PathFragment | undefined' is not assignable to type 'PathFragment'.
  Type 'undefined' is not assignable to type 'PathFragment'.
    Type 'undefined' is not assignable to type 'string'.

25     const moduleFilename: PathFragment = directory.subfiles.find(filenam
e =>
             ~~~~~~~~~~~~~~

node_modules/@nestjs/schematics/utils/module.finder.ts:30:21 - error TS2345
: Argument of type 'DirEntry | null' is not assignable to parameter of type
 'DirEntry'.
  Type 'null' is not assignable to type 'DirEntry'.

30       : this.findIn(directory.parent);

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

The motivation is to be align with other NestJS repositories and also enable to extend this package with a stricter typescript compiler.

Environment


| \ | |           | |    |_  |/  ___|/  __ \| |   |_   _|
|  \| |  ___  ___ | |_     | |\ `--. | /  \/| |     | |
| . ` | / _ \/ __|| __|    | | `--. \| |    | |     | |
| |\  ||  __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/  \____/\_____/\___/


[System Information]
OS Version     : Windows 10
NodeJS Version : v10.15.0
YARN Version    : 1.17.3
[Nest Information]
schematics version : 6.4.3

@angular/cli version differs from latest angular version

I'm submitting a...


[] Regression
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

After running nest generate angular-app, and trying to build angular's app, I had some weird troubles.
Anormal errors like:

  • "Data path โ€œ.builders['app-shell']โ€ should have required property 'class'",
  • ERROR in Cannot find module 'node-sass'

Expected behavior

To build Angular properly

Minimal reproduction of the problem with instructions

nest n
nest g ng-app
cd && npm run build
errors

I suspected first about versioning mismatchings. I know that nest angular-app schematic generator is based on Angular's global version. Then I saw this line and suspected:

Then I check package.json of angular's app and found that all dependencies are comming from Angular 8, except @angular/cli that was 7.0.0

Then I checked that global @angular/cli was v8 because it's the latest, so it seems that project was based on Angular 8 but project's cli was v7.

I changed project's @angular/cli to v8 (~8.3.14) and error was gone.

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

New user's with Angular 8 at global will face this issue at build time.

Environment


Nest version: 
nestjs 6.8.5
nestjs/schematics: 6.7.0
 
For Tooling issues:
- Node version: 12.13.0
- Platform:  Windows

Incompatible with 8.16.2

Bug Report

Current behavior

Prerequisites in document said Node.js (>= 8.9.0) was supported, but execute yarn install under 8.16.2 throws

error @angular-devkit/[email protected]: The engine "node" is incompatible with this module. Expected version ">= 10.9.0". Got "8.16.2"
error Found incompatible module.

Logs of yarn why @angular-devkit/core.

yarn why v1.19.2
[1/4] ๐Ÿค”  Why do we have the module "@angular-devkit/core"...?
[2/4] ๐Ÿšš  Initialising dependency graph...
[3/4] ๐Ÿ”  Finding dependency...
[4/4] ๐Ÿšก  Calculating file sizes...
=> Found "@angular-devkit/[email protected]"
info Reasons this module exists
   - "@nestjs#schematics" depends on it
   - Hoisted from "@nestjs#schematics#@angular-devkit#core"
   - Hoisted from "@nestjs#cli#@angular-devkit#core"
   - Hoisted from "@nestjs#cli#@angular-devkit#schematics-cli#@angular-devkit#core"
   - Hoisted from "@nestjs#cli#@angular-devkit#schematics#@angular-devkit#core"
   - Hoisted from "@nestjs#cli#@angular-devkit#schematics-cli#@schematics#schematics#@angular-devkit#core"
info Disk size without dependencies: "18.19MB"
info Disk size with unique dependencies: "37.46MB"
info Disk size with transitive dependencies: "38.37MB"
info Number of shared dependencies: 7
โœจ  Done in 1.56s.

Input Code

package.json

{
  "dependencies": {
    "@nestjs/common": "^6.7.2",
    "@nestjs/core": "^6.7.2",
    "@nestjs/platform-express": "^6.7.2",
    "reflect-metadata": "^0.1.13",
    "rimraf": "^3.0.0",
    "rxjs": "^6.5.3"
  },
  "devDependencies": {
    "@nestjs/cli": "^6.9.0",
    "@nestjs/schematics": "^6.7.0",
    "@nestjs/testing": "^6.7.1",
    "@types/express": "^4.17.1",
    "@types/jest": "^24.0.18",
    "@types/json2md": "^1.5.0",
    "@types/node": "^12.7.5",
    "@types/qs": "^6.9.0",
    "@types/supertest": "^2.0.8",
    "jest": "^24.9.0",
    "prettier": "^1.18.2",
    "supertest": "^4.0.2",
    "ts-jest": "^24.1.0",
    "ts-loader": "^6.1.1",
    "ts-node": "^8.4.1",
    "tsconfig-paths": "^3.9.0",
    "tslint": "^5.20.0",
    "typescript": "^3.6.3"
  },
}

Expected behavior

Support 8.16.2 or update document.

Update templates

AS a user I WANT TO generate code according to best practices.

Error when update imports array of app.module.ts through generator

1- nest g module test1 >> ok and update app.module.ts
2- add "TypeOrmModule.forRoot()" in the imports array of app.module.ts
3- nest g module test2 >> fails, get some error about the "." of "TypeOrmModule.forRoot()" or even if there is a comment in that array.

error message: "Unexpected token . in JSON at position 285" or "Unexpected token / in JSON at position 270" when comment.

Nest dependencies

AS a user I WANT TO include only nest dependencies I need WHEN I generate a new project

How to demo :

  • execute schematics @nestjs/schematics --dependencies=core,common --dev-dependencies=testing
  • check there is only @nestjs/core and @nestjs/common dependencies
  • check there is only @nestjs/testing devDependencies

The lib generated by cli has no test settings.

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

The library generated via cli will generate a spec file, but it is not set in package.json.

The jest setting in package.json only executes the test files in the src folder, so the tests in the libs folder are not executed when npm run test.

Expected behavior

Modify jest.rootDir in package.json to an empty string.

Minimal reproduction of the problem with instructions

nest new reproduction
cd reproduction
nest g lib testable-lib
npm run test

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

Environment

[System Information]
OS Version     : macOS
NodeJS Version : v8.11.3
NPM Version    : 6.9.0
[Nest Information]
common version : 5.4.0
core version   : 5.4.0

Readme uses npm commands when yarn was selected

When creating a new project using the CLI, I can choose to use yarn as the dependency manager.

However, the created project has a readme file which contains commands such as npm install, npm run build, ... (which is expected, as they are hardcoded here https://github.com/nestjs/schematics/blob/master/src/templates/ts/application/README.md )

Wouldn't it be better if, when yarn was selected, all commands in the readme of the created project use yarn instead of npm ?


If you agree, I'd be happy to tackle this myself (I guess it shouln't be that hard, but might ping you for directions if needed).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.