@nestjs/schematics 8.0.9 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -2
  3. package/dist/collection.json +3 -2
  4. package/dist/lib/application/application.factory.js +2 -2
  5. package/dist/lib/application/files/js/package.json +15 -15
  6. package/dist/lib/application/files/ts/.eslintrc.js +1 -0
  7. package/dist/lib/application/files/ts/README.md +1 -1
  8. package/dist/lib/application/files/ts/package.json +8 -8
  9. package/dist/lib/application/schema.json +4 -1
  10. package/dist/lib/class/class.factory.js +8 -1
  11. package/dist/lib/class/files/js/{__name__.spec.js → __name__.__specFileSuffix__.js} +0 -0
  12. package/dist/lib/class/files/ts/{__name__.spec.ts → __name__.__specFileSuffix__.ts} +0 -0
  13. package/dist/lib/class/schema.json +5 -0
  14. package/dist/lib/controller/controller.factory.js +8 -1
  15. package/dist/lib/controller/files/js/{__name__.controller.spec.js → __name__.controller.__specFileSuffix__.js} +0 -0
  16. package/dist/lib/controller/files/ts/{__name__.controller.spec.ts → __name__.controller.__specFileSuffix__.ts} +0 -0
  17. package/dist/lib/controller/schema.json +5 -0
  18. package/dist/lib/filter/files/js/{__name__.filter.spec.js → __name__.filter.__specFileSuffix__.js} +0 -0
  19. package/dist/lib/filter/files/ts/{__name__.filter.spec.ts → __name__.filter.__specFileSuffix__.ts} +0 -0
  20. package/dist/lib/filter/filter.factory.js +8 -1
  21. package/dist/lib/filter/schema.json +5 -0
  22. package/dist/lib/gateway/files/js/{__name__.gateway.spec.js → __name__.gateway.__specFileSuffix__.js} +0 -0
  23. package/dist/lib/gateway/files/ts/{__name__.gateway.spec.ts → __name__.gateway.__specFileSuffix__.ts} +0 -0
  24. package/dist/lib/gateway/gateway.factory.js +8 -0
  25. package/dist/lib/gateway/schema.json +5 -0
  26. package/dist/lib/guard/files/js/{__name__.guard.spec.js → __name__.guard.__specFileSuffix__.js} +0 -0
  27. package/dist/lib/guard/files/ts/{__name__.guard.spec.ts → __name__.guard.__specFileSuffix__.ts} +0 -0
  28. package/dist/lib/guard/guard.factory.js +8 -1
  29. package/dist/lib/guard/schema.json +5 -0
  30. package/dist/lib/interceptor/files/js/{__name__.interceptor.spec.js → __name__.interceptor.__specFileSuffix__.js} +0 -0
  31. package/dist/lib/interceptor/files/ts/{__name__.interceptor.spec.ts → __name__.interceptor.__specFileSuffix__.ts} +0 -0
  32. package/dist/lib/interceptor/interceptor.factory.js +8 -0
  33. package/dist/lib/interceptor/schema.json +5 -0
  34. package/dist/lib/middleware/files/js/{__name__.middleware.spec.js → __name__.middleware.__specFileSuffix__.js} +0 -0
  35. package/dist/lib/middleware/files/ts/{__name__.middleware.spec.ts → __name__.middleware.__specFileSuffix__.ts} +0 -0
  36. package/dist/lib/middleware/middleware.factory.js +8 -1
  37. package/dist/lib/middleware/schema.json +5 -0
  38. package/dist/lib/pipe/files/js/{__name__.pipe.spec.js → __name__.pipe.__specFileSuffix__.js} +0 -0
  39. package/dist/lib/pipe/files/ts/{__name__.pipe.spec.ts → __name__.pipe.__specFileSuffix__.ts} +0 -0
  40. package/dist/lib/pipe/pipe.factory.js +8 -0
  41. package/dist/lib/pipe/schema.json +5 -0
  42. package/dist/lib/provider/files/js/{__name__.spec.js → __name__.__specFileSuffix__.js} +0 -0
  43. package/dist/lib/provider/files/ts/{__name__.spec.ts → __name__.__specFileSuffix__.ts} +0 -0
  44. package/dist/lib/provider/provider.factory.js +8 -1
  45. package/dist/lib/provider/schema.json +5 -0
  46. package/dist/lib/resolver/files/js/{__name__.resolver.spec.js → __name__.resolver.__specFileSuffix__.js} +0 -0
  47. package/dist/lib/resolver/files/ts/{__name__.resolver.spec.ts → __name__.resolver.__specFileSuffix__.ts} +0 -0
  48. package/dist/lib/resolver/resolver.factory.js +8 -1
  49. package/dist/lib/resolver/schema.json +5 -0
  50. package/dist/lib/resource/files/ts/{__name__.controller.spec.ts → __name__.controller.__specFileSuffix__.ts} +0 -0
  51. package/dist/lib/resource/files/ts/{__name__.gateway.spec.ts → __name__.gateway.__specFileSuffix__.ts} +0 -0
  52. package/dist/lib/resource/files/ts/{__name__.resolver.spec.ts → __name__.resolver.__specFileSuffix__.ts} +0 -0
  53. package/dist/lib/resource/files/ts/{__name__.service.spec.ts → __name__.service.__specFileSuffix__.ts} +0 -0
  54. package/dist/lib/resource/resource.factory.js +10 -4
  55. package/dist/lib/resource/schema.json +5 -0
  56. package/dist/lib/service/files/js/{__name__.service.spec.js → __name__.service.__specFileSuffix__.js} +0 -0
  57. package/dist/lib/service/files/ts/{__name__.service.spec.ts → __name__.service.__specFileSuffix__.ts} +0 -0
  58. package/dist/lib/service/schema.json +5 -0
  59. package/dist/lib/service/service.factory.js +8 -1
  60. package/dist/lib/sub-app/files/js/src/{app.controller.spec.js → app.controller.__specFileSuffix__.js} +0 -0
  61. package/dist/lib/sub-app/files/js/test/{app.e2e-spec.js → app.e2e-__specFileSuffix__.js} +0 -0
  62. package/dist/lib/sub-app/files/ts/src/{__name__.controller.spec.ts → __name__.controller.__specFileSuffix__.ts} +0 -0
  63. package/dist/lib/sub-app/files/ts/test/{app.e2e-spec.ts → app.e2e-__specFileSuffix__.ts} +0 -0
  64. package/dist/lib/sub-app/files/ts/tsconfig.app.json +1 -1
  65. package/dist/lib/sub-app/schema.json +5 -0
  66. package/dist/lib/sub-app/workspace/ts/tsconfig.app.json +1 -1
  67. package/dist/utils/metadata.manager.js +4 -6
  68. package/package.json +24 -25
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2018 nestjs
3
+ Copyright (c) 2018-2022 nestjs
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
2
+ <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
3
3
  </p>
4
4
 
5
5
  <p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
@@ -20,7 +20,7 @@ The Nest CLI is a command-line interface tool that helps you to initialize, deve
20
20
 
21
21
  ## Installation
22
22
 
23
- ```
23
+ ```bash
24
24
  $ npm install -g @nestjs/schematics
25
25
  ```
26
26
 
@@ -51,12 +51,13 @@
51
51
  "factory": "./lib/interceptor/interceptor.factory#main",
52
52
  "description": "Create a Nest interceptor.",
53
53
  "schema": "./lib/interceptor/schema.json",
54
- "aliases": ["in"]
54
+ "aliases": ["itc"]
55
55
  },
56
56
  "interface": {
57
57
  "factory": "./lib/interface/interface.factory#main",
58
58
  "description": "Create a Nest interface.",
59
- "schema": "./lib/interface/schema.json"
59
+ "schema": "./lib/interface/schema.json",
60
+ "aliases": ["itf"]
60
61
  },
61
62
  "middleware": {
62
63
  "factory": "./lib/middleware/middleware.factory#main",
@@ -7,7 +7,7 @@ const path_1 = require("path");
7
7
  const formatting_1 = require("../../utils/formatting");
8
8
  const defaults_1 = require("../defaults");
9
9
  function main(options) {
10
- options.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.name);
10
+ options.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.name.toString());
11
11
  const path = !options.directory || options.directory === 'undefined'
12
12
  ? options.name
13
13
  : options.directory;
@@ -22,7 +22,7 @@ function transform(options) {
22
22
  ? target.description
23
23
  : defaults_1.DEFAULT_DESCRIPTION;
24
24
  target.language = !!target.language ? target.language : defaults_1.DEFAULT_LANGUAGE;
25
- target.name = resolvePackageName(target.name);
25
+ target.name = resolvePackageName(target.name.toString());
26
26
  target.version = !!target.version ? target.version : defaults_1.DEFAULT_VERSION;
27
27
  target.packageManager =
28
28
  !target.packageManager || target.packageManager === 'undefined'
@@ -14,25 +14,25 @@
14
14
  "test:e2e": "jest --config ./test/jest-e2e.json"
15
15
  },
16
16
  "dependencies": {
17
- "@nestjs/common": "^8.0.0",
18
- "@nestjs/core": "^8.0.0",
19
- "@nestjs/platform-express": "^8.0.0",
17
+ "@nestjs/common": "^9.0.0",
18
+ "@nestjs/core": "^9.0.0",
19
+ "@nestjs/platform-express": "^9.0.0",
20
20
  "reflect-metadata": "^0.1.13",
21
21
  "rxjs": "^7.2.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@nestjs/testing": "^8.0.0",
25
- "@babel/core": "7.17.8",
26
- "@babel/node": "7.16.8",
27
- "@babel/plugin-proposal-decorators": "7.17.8",
28
- "@babel/plugin-transform-runtime": "7.17.0",
29
- "@babel/preset-env": "7.16.11",
30
- "@babel/register": "7.17.7",
31
- "@babel/runtime": "7.17.8",
32
- "jest": "27.5.1",
33
- "nodemon": "2.0.15",
34
- "prettier": "2.6.1",
35
- "supertest": "6.2.2"
24
+ "@nestjs/testing": "^9.0.0",
25
+ "@babel/core": "7.18.6",
26
+ "@babel/node": "7.18.6",
27
+ "@babel/plugin-proposal-decorators": "7.18.6",
28
+ "@babel/plugin-transform-runtime": "7.18.6",
29
+ "@babel/preset-env": "7.18.6",
30
+ "@babel/register": "7.18.6",
31
+ "@babel/runtime": "7.18.6",
32
+ "jest": "28.1.2",
33
+ "nodemon": "2.0.19",
34
+ "prettier": "2.7.1",
35
+ "supertest": "6.2.4"
36
36
  },
37
37
  "jest": {
38
38
  "moduleFileExtensions": [
@@ -2,6 +2,7 @@ module.exports = {
2
2
  parser: '@typescript-eslint/parser',
3
3
  parserOptions: {
4
4
  project: 'tsconfig.json',
5
+ tsconfigRootDir : __dirname,
5
6
  sourceType: 'module',
6
7
  },
7
8
  plugins: ['@typescript-eslint/eslint-plugin'],
@@ -1,5 +1,5 @@
1
1
  <p align="center">
2
- <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
2
+ <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
3
3
  </p>
4
4
 
5
5
  [circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
@@ -21,9 +21,9 @@
21
21
  "test:e2e": "jest --config ./test/jest-e2e.json"
22
22
  },
23
23
  "dependencies": {
24
- "@nestjs/common": "^8.0.0",
25
- "@nestjs/core": "^8.0.0",
26
- "@nestjs/platform-express": "^8.0.0",
24
+ "@nestjs/common": "^9.0.0",
25
+ "@nestjs/core": "^9.0.0",
26
+ "@nestjs/platform-express": "^9.0.0",
27
27
  "reflect-metadata": "^0.1.13",
28
28
  "rimraf": "^3.0.2",
29
29
  "rxjs": "^7.2.0"
@@ -31,9 +31,9 @@
31
31
  "devDependencies": {
32
32
  "@nestjs/cli": "^8.0.0",
33
33
  "@nestjs/schematics": "^8.0.0",
34
- "@nestjs/testing": "^8.0.0",
34
+ "@nestjs/testing": "^9.0.0",
35
35
  "@types/express": "^4.17.13",
36
- "@types/jest": "27.4.1",
36
+ "@types/jest": "28.1.4",
37
37
  "@types/node": "^16.0.0",
38
38
  "@types/supertest": "^2.0.11",
39
39
  "@typescript-eslint/eslint-plugin": "^5.0.0",
@@ -41,14 +41,14 @@
41
41
  "eslint": "^8.0.1",
42
42
  "eslint-config-prettier": "^8.3.0",
43
43
  "eslint-plugin-prettier": "^4.0.0",
44
- "jest": "^27.2.5",
44
+ "jest": "28.1.2",
45
45
  "prettier": "^2.3.2",
46
46
  "source-map-support": "^0.5.20",
47
47
  "supertest": "^6.1.3",
48
- "ts-jest": "^27.0.3",
48
+ "ts-jest": "28.0.5",
49
49
  "ts-loader": "^9.2.3",
50
50
  "ts-node": "^10.0.0",
51
- "tsconfig-paths": "^3.10.1",
51
+ "tsconfig-paths": "4.0.0",
52
52
  "typescript": "^4.3.5"
53
53
  },
54
54
  "jest": {
@@ -5,7 +5,10 @@
5
5
  "type": "object",
6
6
  "properties": {
7
7
  "name": {
8
- "type": "string",
8
+ "oneOf": [
9
+ { "type": "string" },
10
+ { "type": "number" }
11
+ ],
9
12
  "description": "The name of the application.",
10
13
  "$default": {
11
14
  "$source": "argv",
@@ -19,6 +19,7 @@ function transform(options) {
19
19
  }
20
20
  const location = new name_parser_1.NameParser().parse(target);
21
21
  target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
22
+ target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.specFileSuffix || 'spec');
22
23
  if (target.name.includes('.')) {
23
24
  target.className = core_1.strings.classify(target.name).replace('.', '');
24
25
  }
@@ -35,7 +36,13 @@ function transform(options) {
35
36
  }
36
37
  function generate(options) {
37
38
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
38
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
39
+ options.spec
40
+ ? (0, schematics_1.noop)()
41
+ : (0, schematics_1.filter)((path) => {
42
+ const languageExtension = options.language || 'ts';
43
+ const suffix = `.__specFileSuffix__.${languageExtension}`;
44
+ return !path.endsWith(suffix);
45
+ }),
39
46
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
40
47
  (0, schematics_1.move)(options.path),
41
48
  ])(context);
@@ -23,6 +23,11 @@
23
23
  "default": true,
24
24
  "description": "Specifies if a spec file is generated."
25
25
  },
26
+ "specFileSuffix": {
27
+ "type": "string",
28
+ "default": "spec",
29
+ "description": "Specifies the file suffix of spec files."
30
+ },
26
31
  "path": {
27
32
  "type": "string",
28
33
  "format": "path",
@@ -31,6 +31,7 @@ function transform(source) {
31
31
  target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
32
32
  target.language =
33
33
  target.language !== undefined ? target.language : defaults_1.DEFAULT_LANGUAGE;
34
+ target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(source.specFileSuffix || 'spec');
34
35
  target.path = target.flat
35
36
  ? target.path
36
37
  : (0, core_1.join)(target.path, target.name);
@@ -38,7 +39,13 @@ function transform(source) {
38
39
  }
39
40
  function generate(options) {
40
41
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
41
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
42
+ options.spec
43
+ ? (0, schematics_1.noop)()
44
+ : (0, schematics_1.filter)((path) => {
45
+ const languageExtension = options.language || 'ts';
46
+ const suffix = `.__specFileSuffix__.${languageExtension}`;
47
+ return !path.endsWith(suffix);
48
+ }),
42
49
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
43
50
  (0, schematics_1.move)(options.path),
44
51
  ])(context);
@@ -44,6 +44,11 @@
44
44
  "type": "boolean",
45
45
  "default": true,
46
46
  "description": "Specifies if a spec file is generated."
47
+ },
48
+ "specFileSuffix": {
49
+ "type": "string",
50
+ "default": "spec",
51
+ "description": "Specifies the file suffix of spec files."
47
52
  }
48
53
  },
49
54
  "required": ["name"]
@@ -20,6 +20,7 @@ function transform(options) {
20
20
  target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
21
21
  target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
22
22
  target.language = target.language !== undefined ? target.language : 'ts';
23
+ target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.specFileSuffix || 'spec');
23
24
  target.path = target.flat
24
25
  ? target.path
25
26
  : (0, core_1.join)(target.path, target.name);
@@ -27,7 +28,13 @@ function transform(options) {
27
28
  }
28
29
  function generate(options) {
29
30
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
30
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
31
+ options.spec
32
+ ? (0, schematics_1.noop)()
33
+ : (0, schematics_1.filter)((path) => {
34
+ const languageExtension = options.language || 'ts';
35
+ const suffix = `.__specFileSuffix__.${languageExtension}`;
36
+ return !path.endsWith(suffix);
37
+ }),
31
38
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
32
39
  (0, schematics_1.move)(options.path),
33
40
  ])(context);
@@ -35,6 +35,11 @@
35
35
  "type": "boolean",
36
36
  "default": true,
37
37
  "description": "Specifies if a spec file is generated."
38
+ },
39
+ "specFileSuffix": {
40
+ "type": "string",
41
+ "default": "spec",
42
+ "description": "Specifies the file suffix of spec files."
38
43
  }
39
44
  },
40
45
  "required": ["name"]
@@ -26,6 +26,7 @@ function transform(options) {
26
26
  }
27
27
  target.metadata = 'providers';
28
28
  target.type = 'gateway';
29
+ target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.specFileSuffix || 'spec');
29
30
  const location = new name_parser_1.NameParser().parse(target);
30
31
  target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
31
32
  target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
@@ -38,6 +39,13 @@ function transform(options) {
38
39
  function generate(options) {
39
40
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
40
41
  options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
42
+ options.spec
43
+ ? (0, schematics_1.noop)()
44
+ : (0, schematics_1.filter)((path) => {
45
+ const languageExtension = options.language || 'ts';
46
+ const suffix = `.__specFileSuffix__.${languageExtension}`;
47
+ return !path.endsWith(suffix);
48
+ }),
41
49
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
42
50
  (0, schematics_1.move)(options.path),
43
51
  ])(context);
@@ -35,6 +35,11 @@
35
35
  "type": "boolean",
36
36
  "default": true,
37
37
  "description": "Specifies if a spec file is generated."
38
+ },
39
+ "specFileSuffix": {
40
+ "type": "string",
41
+ "default": "spec",
42
+ "description": "Specifies the file suffix of spec files."
38
43
  }
39
44
  },
40
45
  "required": ["name"]
@@ -20,6 +20,7 @@ function transform(options) {
20
20
  target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
21
21
  target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
22
22
  target.language = target.language !== undefined ? target.language : 'ts';
23
+ target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.specFileSuffix || 'spec');
23
24
  target.path = target.flat
24
25
  ? target.path
25
26
  : (0, core_1.join)(target.path, target.name);
@@ -27,7 +28,13 @@ function transform(options) {
27
28
  }
28
29
  function generate(options) {
29
30
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
30
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
31
+ options.spec
32
+ ? (0, schematics_1.noop)()
33
+ : (0, schematics_1.filter)((path) => {
34
+ const languageExtension = options.language || 'ts';
35
+ const suffix = `.__specFileSuffix__.${languageExtension}`;
36
+ return !path.endsWith(suffix);
37
+ }),
31
38
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
32
39
  (0, schematics_1.move)(options.path),
33
40
  ])(context);
@@ -35,6 +35,11 @@
35
35
  "type": "boolean",
36
36
  "default": true,
37
37
  "description": "Specifies if a spec file is generated."
38
+ },
39
+ "specFileSuffix": {
40
+ "type": "string",
41
+ "default": "spec",
42
+ "description": "Specifies the file suffix of spec files."
38
43
  }
39
44
  },
40
45
  "required": ["name"]
@@ -20,6 +20,7 @@ function transform(options) {
20
20
  target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
21
21
  target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
22
22
  target.language = target.language !== undefined ? target.language : 'ts';
23
+ target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.specFileSuffix || 'spec');
23
24
  target.path = target.flat
24
25
  ? target.path
25
26
  : (0, core_1.join)(target.path, target.name);
@@ -28,6 +29,13 @@ function transform(options) {
28
29
  function generate(options) {
29
30
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
30
31
  options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
32
+ options.spec
33
+ ? (0, schematics_1.noop)()
34
+ : (0, schematics_1.filter)((path) => {
35
+ const languageExtension = options.language || 'ts';
36
+ const suffix = `.__specFileSuffix__.${languageExtension}`;
37
+ return !path.endsWith(suffix);
38
+ }),
31
39
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
32
40
  (0, schematics_1.move)(options.path),
33
41
  ])(context);
@@ -35,6 +35,11 @@
35
35
  "type": "boolean",
36
36
  "default": true,
37
37
  "description": "Specifies if a spec file is generated."
38
+ },
39
+ "specFileSuffix": {
40
+ "type": "string",
41
+ "default": "spec",
42
+ "description": "Specifies the file suffix of spec files."
38
43
  }
39
44
  },
40
45
  "required": ["name"]
@@ -20,6 +20,7 @@ function transform(options) {
20
20
  target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
21
21
  target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
22
22
  target.language = target.language !== undefined ? target.language : 'ts';
23
+ target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.specFileSuffix || 'spec');
23
24
  target.path = target.flat
24
25
  ? target.path
25
26
  : (0, core_1.join)(target.path, target.name);
@@ -27,7 +28,13 @@ function transform(options) {
27
28
  }
28
29
  function generate(options) {
29
30
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
30
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
31
+ options.spec
32
+ ? (0, schematics_1.noop)()
33
+ : (0, schematics_1.filter)((path) => {
34
+ const languageExtension = options.language || 'ts';
35
+ const suffix = `.__specFileSuffix__.${languageExtension}`;
36
+ return !path.endsWith(suffix);
37
+ }),
31
38
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
32
39
  (0, schematics_1.move)(options.path),
33
40
  ])(context);
@@ -35,6 +35,11 @@
35
35
  "type": "boolean",
36
36
  "default": true,
37
37
  "description": "Specifies if a spec file is generated."
38
+ },
39
+ "specFileSuffix": {
40
+ "type": "string",
41
+ "default": "spec",
42
+ "description": "Specifies the file suffix of spec files."
38
43
  }
39
44
  },
40
45
  "required": ["name"]
@@ -20,6 +20,7 @@ function transform(options) {
20
20
  target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
21
21
  target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
22
22
  target.language = target.language !== undefined ? target.language : 'ts';
23
+ target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.specFileSuffix || 'spec');
23
24
  target.path = target.flat
24
25
  ? target.path
25
26
  : (0, core_1.join)(target.path, target.name);
@@ -28,6 +29,13 @@ function transform(options) {
28
29
  function generate(options) {
29
30
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
30
31
  options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
32
+ options.spec
33
+ ? (0, schematics_1.noop)()
34
+ : (0, schematics_1.filter)((path) => {
35
+ const languageExtension = options.language || 'ts';
36
+ const suffix = `.__specFileSuffix__.${languageExtension}`;
37
+ return !path.endsWith(suffix);
38
+ }),
31
39
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
32
40
  (0, schematics_1.move)(options.path),
33
41
  ])(context);
@@ -35,6 +35,11 @@
35
35
  "type": "boolean",
36
36
  "default": true,
37
37
  "description": "Specifies if a spec file is generated."
38
+ },
39
+ "specFileSuffix": {
40
+ "type": "string",
41
+ "default": "spec",
42
+ "description": "Specifies the file suffix of spec files."
38
43
  }
39
44
  },
40
45
  "required": ["name"]
@@ -22,6 +22,7 @@ exports.main = main;
22
22
  function transform(options) {
23
23
  const target = Object.assign({}, options);
24
24
  target.metadata = 'providers';
25
+ target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.specFileSuffix || 'spec');
25
26
  if (!target.name) {
26
27
  throw new schematics_1.SchematicsException('Option (name) is required.');
27
28
  }
@@ -42,7 +43,13 @@ function transform(options) {
42
43
  }
43
44
  function generate(options) {
44
45
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
45
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
46
+ options.spec
47
+ ? (0, schematics_1.noop)()
48
+ : (0, schematics_1.filter)((path) => {
49
+ const languageExtension = options.language || 'ts';
50
+ const suffix = `.__specFileSuffix__.${languageExtension}`;
51
+ return !path.endsWith(suffix);
52
+ }),
46
53
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
47
54
  (0, schematics_1.move)(options.path),
48
55
  ])(context);
@@ -36,6 +36,11 @@
36
36
  "default": true,
37
37
  "description": "Specifies if a spec file is generated."
38
38
  },
39
+ "specFileSuffix": {
40
+ "type": "string",
41
+ "default": "spec",
42
+ "description": "Specifies the file suffix of spec files."
43
+ },
39
44
  "className": {
40
45
  "type": "string",
41
46
  "description": "Class name to be used internally."
@@ -26,6 +26,7 @@ function transform(options) {
26
26
  }
27
27
  target.metadata = 'providers';
28
28
  target.type = 'resolver';
29
+ target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.specFileSuffix || 'spec');
29
30
  const location = new name_parser_1.NameParser().parse(target);
30
31
  target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
31
32
  target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
@@ -37,7 +38,13 @@ function transform(options) {
37
38
  }
38
39
  function generate(options) {
39
40
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
40
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
41
+ options.spec
42
+ ? (0, schematics_1.noop)()
43
+ : (0, schematics_1.filter)((path) => {
44
+ const languageExtension = options.language || 'ts';
45
+ const suffix = `.__specFileSuffix__.${languageExtension}`;
46
+ return !path.endsWith(suffix);
47
+ }),
41
48
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
42
49
  (0, schematics_1.move)(options.path),
43
50
  ])(context);
@@ -35,6 +35,11 @@
35
35
  "type": "boolean",
36
36
  "default": true,
37
37
  "description": "Specifies if a spec file is generated."
38
+ },
39
+ "specFileSuffix": {
40
+ "type": "string",
41
+ "default": "spec",
42
+ "description": "Specifies the file suffix of spec files."
38
43
  }
39
44
  },
40
45
  "required": ["name"]
@@ -37,6 +37,7 @@ function transform(options) {
37
37
  if (target.language === 'js') {
38
38
  throw new Error('The "resource" schematic does not support JavaScript language (only TypeScript is supported).');
39
39
  }
40
+ target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.specFileSuffix || 'spec');
40
41
  target.path = target.flat
41
42
  ? target.path
42
43
  : (0, core_1.join)(target.path, target.name);
@@ -57,7 +58,7 @@ function generate(options) {
57
58
  options.crud);
58
59
  }
59
60
  if (path.endsWith('.resolver.ts') ||
60
- path.endsWith('.resolver.spec.ts')) {
61
+ path.endsWith('.resolver.__specFileSuffix__.ts')) {
61
62
  return (options.type === 'graphql-code-first' ||
62
63
  options.type === 'graphql-schema-first');
63
64
  }
@@ -65,10 +66,10 @@ function generate(options) {
65
66
  return options.type === 'graphql-schema-first' && options.crud;
66
67
  }
67
68
  if (path.endsWith('controller.ts') ||
68
- path.endsWith('.controller.spec.ts')) {
69
+ path.endsWith('.controller.__specFileSuffix__.ts')) {
69
70
  return options.type === 'microservice' || options.type === 'rest';
70
71
  }
71
- if (path.endsWith('.gateway.ts') || path.endsWith('.gateway.spec.ts')) {
72
+ if (path.endsWith('.gateway.ts') || path.endsWith('.gateway.__specFileSuffix__.ts')) {
72
73
  return options.type === 'ws';
73
74
  }
74
75
  if (path.includes('@ent')) {
@@ -76,7 +77,12 @@ function generate(options) {
76
77
  }
77
78
  return true;
78
79
  }),
79
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
80
+ options.spec
81
+ ? (0, schematics_1.noop)()
82
+ : (0, schematics_1.filter)((path) => {
83
+ const suffix = `.__specFileSuffix__.ts`;
84
+ return !path.endsWith(suffix);
85
+ }),
80
86
  (0, schematics_1.template)(Object.assign(Object.assign(Object.assign({}, core_1.strings), options), { lowercased: (name) => {
81
87
  const classifiedName = (0, strings_1.classify)(name);
82
88
  return (classifiedName.charAt(0).toLowerCase() + classifiedName.slice(1));
@@ -36,6 +36,11 @@
36
36
  "default": true,
37
37
  "description": "Specifies if specs file are generated."
38
38
  },
39
+ "specFileSuffix": {
40
+ "type": "string",
41
+ "default": "spec",
42
+ "description": "Specifies the file suffix of spec files."
43
+ },
39
44
  "type": {
40
45
  "type": "string",
41
46
  "description": "The transport layer.",
@@ -35,6 +35,11 @@
35
35
  "type": "boolean",
36
36
  "default": true,
37
37
  "description": "Specifies if a spec file is generated."
38
+ },
39
+ "specFileSuffix": {
40
+ "type": "string",
41
+ "default": "spec",
42
+ "description": "Specifies the file suffix of spec files."
38
43
  }
39
44
  },
40
45
  "required": ["name"]
@@ -31,6 +31,7 @@ function transform(source) {
31
31
  target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
32
32
  target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
33
33
  target.language = target.language !== undefined ? target.language : 'ts';
34
+ target.specFileSuffix = (0, formatting_1.normalizeToKebabOrSnakeCase)(source.specFileSuffix || 'spec');
34
35
  target.path = target.flat
35
36
  ? target.path
36
37
  : (0, core_1.join)(target.path, target.name);
@@ -38,7 +39,13 @@ function transform(source) {
38
39
  }
39
40
  function generate(options) {
40
41
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
41
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
42
+ options.spec
43
+ ? (0, schematics_1.noop)()
44
+ : (0, schematics_1.filter)((path) => {
45
+ const languageExtension = options.language || 'ts';
46
+ const suffix = `.__specFileSuffix__.${languageExtension}`;
47
+ return !path.endsWith(suffix);
48
+ }),
42
49
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
43
50
  (0, schematics_1.move)(options.path),
44
51
  ])(context);
@@ -5,5 +5,5 @@
5
5
  "outDir": "../../dist/apps/<%= name %>"
6
6
  },
7
7
  "include": ["src/**/*"],
8
- "exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
8
+ "exclude": ["node_modules", "dist", "test", "**/*<%= specFileSuffix %>.ts"]
9
9
  }
@@ -26,6 +26,11 @@
26
26
  "type": "string",
27
27
  "format": "path",
28
28
  "description": "Applications root directory."
29
+ },
30
+ "specFileSuffix": {
31
+ "type": "string",
32
+ "default": "spec",
33
+ "description": "Specifies the file suffix of spec files."
29
34
  }
30
35
  },
31
36
  "required": ["name"]
@@ -5,5 +5,5 @@
5
5
  "outDir": "../../dist/apps/<%= name %>"
6
6
  },
7
7
  "include": ["src/**/*"],
8
- "exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
8
+ "exclude": ["node_modules", "dist", "test", "**/*<%= specFileSuffix %>.ts"]
9
9
  }
@@ -127,12 +127,10 @@ class MetadataManager {
127
127
  }
128
128
  else {
129
129
  const text = node.getFullText(source);
130
- if (text.match(/^\r?\n/)) {
131
- toInsert = `,${text.match(/^\r?\n(\r?)\s+/)[0]}${symbol}`;
132
- }
133
- else {
134
- toInsert = `, ${symbol}`;
135
- }
130
+ const itemSeparator = (text.match(/^\r?\n(\r?)\s+/) ||
131
+ text.match(/^\r?\n/) ||
132
+ ' ')[0];
133
+ toInsert = `,${itemSeparator}${symbol}`;
136
134
  }
137
135
  return this.content.split('').reduce((content, char, index) => {
138
136
  if (index === position) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/schematics",
3
- "version": "8.0.9",
3
+ "version": "9.0.0",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@schematics)",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -23,7 +23,8 @@
23
23
  "test": "npm run clean && NODE_ENV=test jest -w 1 --no-cache --config jest.json",
24
24
  "test:dev": "NODE_ENV=test npm run -s test -- --watchAll",
25
25
  "prerelease": "npm run build",
26
- "release": "release-it"
26
+ "release": "release-it",
27
+ "prepare": "husky install"
27
28
  },
28
29
  "repository": {
29
30
  "type": "git",
@@ -40,43 +41,38 @@
40
41
  },
41
42
  "homepage": "https://github.com/nestjs/schematics#readme",
42
43
  "dependencies": {
43
- "@angular-devkit/core": "13.3.1",
44
- "@angular-devkit/schematics": "13.3.1",
45
- "fs-extra": "10.0.1",
44
+ "@angular-devkit/core": "14.0.5",
45
+ "@angular-devkit/schematics": "14.0.5",
46
+ "fs-extra": "10.1.0",
46
47
  "jsonc-parser": "3.0.0",
47
48
  "pluralize": "8.0.0"
48
49
  },
49
50
  "devDependencies": {
50
- "@commitlint/cli": "16.2.3",
51
- "@commitlint/config-angular": "16.2.3",
51
+ "@commitlint/cli": "17.0.3",
52
+ "@commitlint/config-angular": "17.0.3",
52
53
  "@types/fs-extra": "9.0.13",
53
- "@types/jest": "27.4.1",
54
- "@types/node": "16.11.26",
55
- "@typescript-eslint/eslint-plugin": "5.17.0",
56
- "@typescript-eslint/parser": "5.17.0",
54
+ "@types/jest": "28.1.4",
55
+ "@types/node": "16.11.43",
56
+ "@typescript-eslint/eslint-plugin": "5.30.5",
57
+ "@typescript-eslint/parser": "5.30.5",
57
58
  "cpx": "1.5.0",
58
- "eslint": "8.12.0",
59
+ "eslint": "8.19.0",
59
60
  "eslint-config-prettier": "8.5.0",
60
- "eslint-plugin-import": "2.25.4",
61
+ "eslint-plugin-import": "2.26.0",
61
62
  "gulp": "4.0.2",
62
63
  "gulp-clean": "0.4.0",
63
- "husky": "7.0.4",
64
- "jest": "27.5.1",
64
+ "husky": "8.0.1",
65
+ "jest": "28.1.2",
65
66
  "nyc": "15.1.0",
66
- "release-it": "14.14.0",
67
- "ts-jest": "27.1.4",
68
- "ts-node": "10.7.0",
69
- "typescript": "4.6.3"
67
+ "release-it": "15.1.1",
68
+ "ts-jest": "28.0.5",
69
+ "ts-node": "10.8.2",
70
+ "typescript": "4.7.4"
70
71
  },
71
72
  "peerDependencies": {
72
- "typescript": "^3.4.5 || ^4.3.5"
73
+ "typescript": "^4.3.5"
73
74
  },
74
75
  "schematics": "./dist/collection.json",
75
- "husky": {
76
- "hooks": {
77
- "commit-msg": "commitlint -c .commitlintrc.json -E HUSKY_GIT_PARAMS"
78
- }
79
- },
80
76
  "nyc": {
81
77
  "include": [
82
78
  "src"
@@ -97,5 +93,8 @@
97
93
  ],
98
94
  "sourceMap": true,
99
95
  "instrument": true
96
+ },
97
+ "lint-staged": {
98
+ "**/*.{ts,json}": []
100
99
  }
101
100
  }