@nestjs/schematics 8.0.7 → 8.0.10

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 (30) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -2
  3. package/dist/lib/application/application.factory.js +2 -1
  4. package/dist/lib/application/files/js/nest-cli.json +1 -0
  5. package/dist/lib/application/files/js/package.json +5 -5
  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/nest-cli.json +1 -0
  9. package/dist/lib/class/class.factory.js +4 -3
  10. package/dist/lib/configuration/files/js/nest-cli.json +1 -0
  11. package/dist/lib/configuration/files/ts/nest-cli.json +1 -0
  12. package/dist/lib/controller/controller.factory.js +4 -3
  13. package/dist/lib/decorator/decorator.factory.js +3 -2
  14. package/dist/lib/filter/filter.factory.js +4 -3
  15. package/dist/lib/gateway/gateway.factory.js +4 -3
  16. package/dist/lib/guard/guard.factory.js +3 -2
  17. package/dist/lib/interceptor/interceptor.factory.js +4 -3
  18. package/dist/lib/interface/interface.factory.js +3 -2
  19. package/dist/lib/library/library.factory.js +2 -1
  20. package/dist/lib/middleware/middleware.factory.js +4 -3
  21. package/dist/lib/module/module.factory.js +3 -2
  22. package/dist/lib/pipe/pipe.factory.js +4 -3
  23. package/dist/lib/provider/provider.factory.js +3 -2
  24. package/dist/lib/resolver/resolver.factory.js +4 -3
  25. package/dist/lib/resource/resource.factory.js +7 -6
  26. package/dist/lib/service/service.factory.js +4 -3
  27. package/dist/lib/sub-app/sub-app.factory.js +3 -2
  28. package/dist/utils/formatting.d.ts +1 -0
  29. package/dist/utils/formatting.js +12 -0
  30. package/package.json +15 -15
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
 
@@ -4,9 +4,10 @@ exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
6
  const path_1 = require("path");
7
+ const formatting_1 = require("../../utils/formatting");
7
8
  const defaults_1 = require("../defaults");
8
9
  function main(options) {
9
- options.name = core_1.strings.dasherize(options.name);
10
+ options.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(options.name);
10
11
  const path = !options.directory || options.directory === 'undefined'
11
12
  ? options.name
12
13
  : options.directory;
@@ -1,4 +1,5 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/nest-cli",
2
3
  "language": "js",
3
4
  "collection": "@nestjs/schematics",
4
5
  "sourceRoot": "src"
@@ -22,16 +22,16 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "@nestjs/testing": "^8.0.0",
25
- "@babel/core": "7.17.5",
25
+ "@babel/core": "7.17.9",
26
26
  "@babel/node": "7.16.8",
27
- "@babel/plugin-proposal-decorators": "7.17.2",
27
+ "@babel/plugin-proposal-decorators": "7.17.9",
28
28
  "@babel/plugin-transform-runtime": "7.17.0",
29
29
  "@babel/preset-env": "7.16.11",
30
- "@babel/register": "7.17.0",
31
- "@babel/runtime": "7.17.2",
30
+ "@babel/register": "7.17.7",
31
+ "@babel/runtime": "7.17.9",
32
32
  "jest": "27.5.1",
33
33
  "nodemon": "2.0.15",
34
- "prettier": "2.5.1",
34
+ "prettier": "2.6.2",
35
35
  "supertest": "6.2.2"
36
36
  },
37
37
  "jest": {
@@ -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
@@ -1,4 +1,5 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/nest-cli",
2
3
  "collection": "@nestjs/schematics",
3
4
  "sourceRoot": "src"
4
5
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const formatting_1 = require("../../utils/formatting");
6
7
  const name_parser_1 = require("../../utils/name.parser");
7
8
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
8
9
  const defaults_1 = require("../defaults");
@@ -17,7 +18,7 @@ function transform(options) {
17
18
  throw new schematics_1.SchematicsException('Option (name) is required.');
18
19
  }
19
20
  const location = new name_parser_1.NameParser().parse(target);
20
- target.name = core_1.strings.dasherize(location.name);
21
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
21
22
  if (target.name.includes('.')) {
22
23
  target.className = core_1.strings.classify(target.name).replace('.', '');
23
24
  }
@@ -26,7 +27,7 @@ function transform(options) {
26
27
  }
27
28
  target.language =
28
29
  target.language !== undefined ? target.language : defaults_1.DEFAULT_LANGUAGE;
29
- target.path = core_1.strings.dasherize(location.path);
30
+ target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
30
31
  target.path = target.flat
31
32
  ? target.path
32
33
  : (0, core_1.join)(target.path, target.name);
@@ -34,7 +35,7 @@ function transform(options) {
34
35
  }
35
36
  function generate(options) {
36
37
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
37
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
38
+ options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
38
39
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
39
40
  (0, schematics_1.move)(options.path),
40
41
  ])(context);
@@ -1,4 +1,5 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/nest-cli",
2
3
  "language": "<%= language %>",
3
4
  "collection": "<%= collection %>",
4
5
  "sourceRoot": "src"
@@ -1,4 +1,5 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/nest-cli",
2
3
  "collection": "<%= collection %>",
3
4
  "sourceRoot": "src"
4
5
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const formatting_1 = require("../../utils/formatting");
6
7
  const module_declarator_1 = require("../../utils/module.declarator");
7
8
  const module_finder_1 = require("../../utils/module.finder");
8
9
  const name_parser_1 = require("../../utils/name.parser");
@@ -26,8 +27,8 @@ function transform(source) {
26
27
  target.metadata = ELEMENT_METADATA;
27
28
  target.type = ELEMENT_TYPE;
28
29
  const location = new name_parser_1.NameParser().parse(target);
29
- target.name = core_1.strings.dasherize(location.name);
30
- target.path = core_1.strings.dasherize(location.path);
30
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
31
+ target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
31
32
  target.language =
32
33
  target.language !== undefined ? target.language : defaults_1.DEFAULT_LANGUAGE;
33
34
  target.path = target.flat
@@ -37,7 +38,7 @@ function transform(source) {
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 ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
41
42
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
42
43
  (0, schematics_1.move)(options.path),
43
44
  ])(context);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const formatting_1 = require("../../utils/formatting");
6
7
  const name_parser_1 = require("../../utils/name.parser");
7
8
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
8
9
  function main(options) {
@@ -16,8 +17,8 @@ function transform(options) {
16
17
  throw new schematics_1.SchematicsException('Option (name) is required.');
17
18
  }
18
19
  const location = new name_parser_1.NameParser().parse(target);
19
- target.name = core_1.strings.dasherize(location.name);
20
- target.path = core_1.strings.dasherize(location.path);
20
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
21
+ target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
21
22
  target.language = target.language !== undefined ? target.language : 'ts';
22
23
  target.path = target.flat
23
24
  ? target.path
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const formatting_1 = require("../../utils/formatting");
6
7
  const name_parser_1 = require("../../utils/name.parser");
7
8
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
8
9
  function main(options) {
@@ -16,8 +17,8 @@ function transform(options) {
16
17
  throw new schematics_1.SchematicsException('Option (name) is required.');
17
18
  }
18
19
  const location = new name_parser_1.NameParser().parse(target);
19
- target.name = core_1.strings.dasherize(location.name);
20
- target.path = core_1.strings.dasherize(location.path);
20
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
21
+ target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
21
22
  target.language = target.language !== undefined ? target.language : 'ts';
22
23
  target.path = target.flat
23
24
  ? target.path
@@ -26,7 +27,7 @@ function transform(options) {
26
27
  }
27
28
  function generate(options) {
28
29
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
29
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
30
+ options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
30
31
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
31
32
  (0, schematics_1.move)(options.path),
32
33
  ])(context);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const formatting_1 = require("../../utils/formatting");
6
7
  const module_declarator_1 = require("../../utils/module.declarator");
7
8
  const module_finder_1 = require("../../utils/module.finder");
8
9
  const name_parser_1 = require("../../utils/name.parser");
@@ -26,8 +27,8 @@ function transform(options) {
26
27
  target.metadata = 'providers';
27
28
  target.type = 'gateway';
28
29
  const location = new name_parser_1.NameParser().parse(target);
29
- target.name = core_1.strings.dasherize(location.name);
30
- target.path = core_1.strings.dasherize(location.path);
30
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
31
+ target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
31
32
  target.language = target.language !== undefined ? target.language : 'ts';
32
33
  target.path = target.flat
33
34
  ? target.path
@@ -36,7 +37,7 @@ function transform(options) {
36
37
  }
37
38
  function generate(options) {
38
39
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
39
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
40
+ options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
40
41
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
41
42
  (0, schematics_1.move)(options.path),
42
43
  ])(context);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const formatting_1 = require("../../utils/formatting");
6
7
  const name_parser_1 = require("../../utils/name.parser");
7
8
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
8
9
  function main(options) {
@@ -16,8 +17,8 @@ function transform(options) {
16
17
  throw new schematics_1.SchematicsException('Option (name) is required.');
17
18
  }
18
19
  const location = new name_parser_1.NameParser().parse(target);
19
- target.name = core_1.strings.dasherize(location.name);
20
- target.path = core_1.strings.dasherize(location.path);
20
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
21
+ target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
21
22
  target.language = target.language !== undefined ? target.language : 'ts';
22
23
  target.path = target.flat
23
24
  ? target.path
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const formatting_1 = require("../../utils/formatting");
6
7
  const name_parser_1 = require("../../utils/name.parser");
7
8
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
8
9
  function main(options) {
@@ -16,8 +17,8 @@ function transform(options) {
16
17
  throw new schematics_1.SchematicsException('Option (name) is required.');
17
18
  }
18
19
  const location = new name_parser_1.NameParser().parse(target);
19
- target.name = core_1.strings.dasherize(location.name);
20
- target.path = core_1.strings.dasherize(location.path);
20
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
21
+ target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
21
22
  target.language = target.language !== undefined ? target.language : 'ts';
22
23
  target.path = target.flat
23
24
  ? target.path
@@ -26,7 +27,7 @@ function transform(options) {
26
27
  }
27
28
  function generate(options) {
28
29
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
29
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
30
+ options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
30
31
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
31
32
  (0, schematics_1.move)(options.path),
32
33
  ])(context);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const formatting_1 = require("../../utils/formatting");
6
7
  const name_parser_1 = require("../../utils/name.parser");
7
8
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
8
9
  function main(options) {
@@ -16,8 +17,8 @@ function transform(options) {
16
17
  throw new schematics_1.SchematicsException('Option (name) is required.');
17
18
  }
18
19
  const location = new name_parser_1.NameParser().parse(target);
19
- target.name = core_1.strings.dasherize(location.name);
20
- target.path = core_1.strings.dasherize(location.path);
20
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
21
+ target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
21
22
  target.path = target.flat
22
23
  ? target.path
23
24
  : (0, core_1.join)(target.path, target.name);
@@ -4,6 +4,7 @@ exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
6
  const jsonc_parser_1 = require("jsonc-parser");
7
+ const formatting_1 = require("../../utils/formatting");
7
8
  const defaults_1 = require("../defaults");
8
9
  function main(options) {
9
10
  options = transform(options);
@@ -23,7 +24,7 @@ function transform(options) {
23
24
  throw new schematics_1.SchematicsException('Option (name) is required.');
24
25
  }
25
26
  target.language = !!target.language ? target.language : defaults_1.DEFAULT_LANGUAGE;
26
- target.name = core_1.strings.dasherize(target.name);
27
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(target.name);
27
28
  target.path =
28
29
  target.path !== undefined
29
30
  ? (0, core_1.join)((0, core_1.normalize)(defaultSourceRoot), target.path)
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const formatting_1 = require("../../utils/formatting");
6
7
  const name_parser_1 = require("../../utils/name.parser");
7
8
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
8
9
  function main(options) {
@@ -16,8 +17,8 @@ function transform(options) {
16
17
  throw new schematics_1.SchematicsException('Option (name) is required.');
17
18
  }
18
19
  const location = new name_parser_1.NameParser().parse(target);
19
- target.name = core_1.strings.dasherize(location.name);
20
- target.path = core_1.strings.dasherize(location.path);
20
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
21
+ target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
21
22
  target.language = target.language !== undefined ? target.language : 'ts';
22
23
  target.path = target.flat
23
24
  ? target.path
@@ -26,7 +27,7 @@ function transform(options) {
26
27
  }
27
28
  function generate(options) {
28
29
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
29
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
30
+ options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
30
31
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
31
32
  (0, schematics_1.move)(options.path),
32
33
  ])(context);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const formatting_1 = require("../../utils/formatting");
6
7
  const module_declarator_1 = require("../../utils/module.declarator");
7
8
  const module_finder_1 = require("../../utils/module.finder");
8
9
  const name_parser_1 = require("../../utils/name.parser");
@@ -23,9 +24,9 @@ function transform(source) {
23
24
  target.metadata = 'imports';
24
25
  target.type = 'module';
25
26
  const location = new name_parser_1.NameParser().parse(target);
26
- target.name = core_1.strings.dasherize(location.name);
27
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
28
+ target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
27
29
  target.language = target.language !== undefined ? target.language : 'ts';
28
- target.path = core_1.strings.dasherize(location.path);
29
30
  target.path = target.flat
30
31
  ? target.path
31
32
  : (0, core_1.join)(target.path, target.name);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const formatting_1 = require("../../utils/formatting");
6
7
  const name_parser_1 = require("../../utils/name.parser");
7
8
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
8
9
  function main(options) {
@@ -16,8 +17,8 @@ function transform(options) {
16
17
  throw new schematics_1.SchematicsException('Option (name) is required.');
17
18
  }
18
19
  const location = new name_parser_1.NameParser().parse(target);
19
- target.name = core_1.strings.dasherize(location.name);
20
- target.path = core_1.strings.dasherize(location.path);
20
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
21
+ target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
21
22
  target.language = target.language !== undefined ? target.language : 'ts';
22
23
  target.path = target.flat
23
24
  ? target.path
@@ -26,7 +27,7 @@ function transform(options) {
26
27
  }
27
28
  function generate(options) {
28
29
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
29
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
30
+ options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
30
31
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
31
32
  (0, schematics_1.move)(options.path),
32
33
  ])(context);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const formatting_1 = require("../../utils/formatting");
6
7
  const module_declarator_1 = require("../../utils/module.declarator");
7
8
  const module_finder_1 = require("../../utils/module.finder");
8
9
  const name_parser_1 = require("../../utils/name.parser");
@@ -25,14 +26,14 @@ function transform(options) {
25
26
  throw new schematics_1.SchematicsException('Option (name) is required.');
26
27
  }
27
28
  const location = new name_parser_1.NameParser().parse(target);
28
- target.name = core_1.strings.dasherize(location.name);
29
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
29
30
  if (target.name.includes('.')) {
30
31
  target.className = core_1.strings.classify(target.name).replace('.', '');
31
32
  }
32
33
  else {
33
34
  target.className = core_1.strings.classify(target.name);
34
35
  }
35
- target.path = core_1.strings.dasherize(location.path);
36
+ target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
36
37
  target.language = target.language !== undefined ? target.language : 'ts';
37
38
  target.path = target.flat
38
39
  ? target.path
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const formatting_1 = require("../../utils/formatting");
6
7
  const module_declarator_1 = require("../../utils/module.declarator");
7
8
  const module_finder_1 = require("../../utils/module.finder");
8
9
  const name_parser_1 = require("../../utils/name.parser");
@@ -26,8 +27,8 @@ function transform(options) {
26
27
  target.metadata = 'providers';
27
28
  target.type = 'resolver';
28
29
  const location = new name_parser_1.NameParser().parse(target);
29
- target.name = core_1.strings.dasherize(location.name);
30
- target.path = core_1.strings.dasherize(location.path);
30
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
31
+ target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
31
32
  target.language = target.language !== undefined ? target.language : 'ts';
32
33
  target.path = target.flat
33
34
  ? target.path
@@ -36,7 +37,7 @@ function transform(options) {
36
37
  }
37
38
  function generate(options) {
38
39
  return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
39
- options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
40
+ options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
40
41
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
41
42
  (0, schematics_1.move)(options.path),
42
43
  ])(context);
@@ -2,14 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
- const schematics_1 = require("@angular-devkit/schematics");
6
- const name_parser_1 = require("../../utils/name.parser");
7
- const source_root_helpers_1 = require("../../utils/source-root.helpers");
8
5
  const strings_1 = require("@angular-devkit/core/src/utils/strings");
6
+ const schematics_1 = require("@angular-devkit/schematics");
7
+ const tasks_1 = require("@angular-devkit/schematics/tasks");
9
8
  const pluralize = require("pluralize");
10
9
  const __1 = require("../..");
11
10
  const dependencies_utils_1 = require("../../utils/dependencies.utils");
12
- const tasks_1 = require("@angular-devkit/schematics/tasks");
11
+ const formatting_1 = require("../../utils/formatting");
12
+ const name_parser_1 = require("../../utils/name.parser");
13
+ const source_root_helpers_1 = require("../../utils/source-root.helpers");
13
14
  function main(options) {
14
15
  options = transform(options);
15
16
  return (tree, context) => {
@@ -30,8 +31,8 @@ function transform(options) {
30
31
  }
31
32
  target.metadata = 'imports';
32
33
  const location = new name_parser_1.NameParser().parse(target);
33
- target.name = core_1.strings.dasherize(location.name);
34
- target.path = core_1.strings.dasherize(location.path);
34
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
35
+ target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
35
36
  target.language = target.language !== undefined ? target.language : 'ts';
36
37
  if (target.language === 'js') {
37
38
  throw new Error('The "resource" schematic does not support JavaScript language (only TypeScript is supported).');
@@ -4,6 +4,7 @@ exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
6
  const util_1 = require("util");
7
+ const formatting_1 = require("../../utils/formatting");
7
8
  const module_declarator_1 = require("../../utils/module.declarator");
8
9
  const module_finder_1 = require("../../utils/module.finder");
9
10
  const name_parser_1 = require("../../utils/name.parser");
@@ -27,8 +28,8 @@ function transform(source) {
27
28
  throw new schematics_1.SchematicsException('Option (name) is required.');
28
29
  }
29
30
  const location = new name_parser_1.NameParser().parse(target);
30
- target.name = core_1.strings.dasherize(location.name);
31
- target.path = core_1.strings.dasherize(location.path);
31
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.name);
32
+ target.path = (0, formatting_1.normalizeToKebabOrSnakeCase)(location.path);
32
33
  target.language = target.language !== undefined ? target.language : 'ts';
33
34
  target.path = target.flat
34
35
  ? target.path
@@ -37,7 +38,7 @@ function transform(source) {
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 ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
41
42
  (0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
42
43
  (0, schematics_1.move)(options.path),
43
44
  ])(context);
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
- const jsonc_parser_1 = require("jsonc-parser");
7
6
  const fse = require("fs-extra");
7
+ const jsonc_parser_1 = require("jsonc-parser");
8
+ const formatting_1 = require("../../utils/formatting");
8
9
  const defaults_1 = require("../defaults");
9
10
  function main(options) {
10
11
  const appName = getAppNameFromPackageJson();
@@ -47,7 +48,7 @@ function transform(options) {
47
48
  target.name = defaults_1.DEFAULT_APP_NAME;
48
49
  }
49
50
  target.language = !!target.language ? target.language : defaults_1.DEFAULT_LANGUAGE;
50
- target.name = core_1.strings.dasherize(target.name);
51
+ target.name = (0, formatting_1.normalizeToKebabOrSnakeCase)(target.name);
51
52
  target.path =
52
53
  target.path !== undefined
53
54
  ? (0, core_1.join)((0, core_1.normalize)(defaultSourceRoot), target.path)
@@ -0,0 +1 @@
1
+ export declare function normalizeToKebabOrSnakeCase(str: string): string;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeToKebabOrSnakeCase = void 0;
4
+ function normalizeToKebabOrSnakeCase(str) {
5
+ const STRING_DASHERIZE_REGEXP = /\s/g;
6
+ const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
7
+ return str
8
+ .replace(STRING_DECAMELIZE_REGEXP, '$1-$2')
9
+ .toLowerCase()
10
+ .replace(STRING_DASHERIZE_REGEXP, '-');
11
+ }
12
+ exports.normalizeToKebabOrSnakeCase = normalizeToKebabOrSnakeCase;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/schematics",
3
- "version": "8.0.7",
3
+ "version": "8.0.10",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@schematics)",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -40,33 +40,33 @@
40
40
  },
41
41
  "homepage": "https://github.com/nestjs/schematics#readme",
42
42
  "dependencies": {
43
- "@angular-devkit/core": "13.2.4",
44
- "@angular-devkit/schematics": "13.2.4",
43
+ "@angular-devkit/core": "13.3.2",
44
+ "@angular-devkit/schematics": "13.3.2",
45
45
  "fs-extra": "10.0.1",
46
46
  "jsonc-parser": "3.0.0",
47
47
  "pluralize": "8.0.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@commitlint/cli": "16.2.1",
51
- "@commitlint/config-angular": "16.2.1",
50
+ "@commitlint/cli": "16.2.3",
51
+ "@commitlint/config-angular": "16.2.3",
52
52
  "@types/fs-extra": "9.0.13",
53
53
  "@types/jest": "27.4.1",
54
- "@types/node": "16.11.25",
55
- "@typescript-eslint/eslint-plugin": "5.12.1",
56
- "@typescript-eslint/parser": "5.12.1",
54
+ "@types/node": "16.11.26",
55
+ "@typescript-eslint/eslint-plugin": "5.18.0",
56
+ "@typescript-eslint/parser": "5.18.0",
57
57
  "cpx": "1.5.0",
58
- "eslint": "8.9.0",
59
- "eslint-config-prettier": "8.4.0",
60
- "eslint-plugin-import": "2.25.4",
58
+ "eslint": "8.12.0",
59
+ "eslint-config-prettier": "8.5.0",
60
+ "eslint-plugin-import": "2.26.0",
61
61
  "gulp": "4.0.2",
62
62
  "gulp-clean": "0.4.0",
63
63
  "husky": "7.0.4",
64
64
  "jest": "27.5.1",
65
65
  "nyc": "15.1.0",
66
- "release-it": "14.12.5",
67
- "ts-jest": "27.1.3",
68
- "ts-node": "10.5.0",
69
- "typescript": "4.5.5"
66
+ "release-it": "14.14.0",
67
+ "ts-jest": "27.1.4",
68
+ "ts-node": "10.7.0",
69
+ "typescript": "4.6.3"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "typescript": "^3.4.5 || ^4.3.5"