@nestjs/schematics 11.0.9 → 11.1.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 (45) hide show
  1. package/dist/lib/application/application.factory.js +5 -1
  2. package/dist/lib/application/files/js/package.json +11 -11
  3. package/dist/lib/application/files/js/test/app.e2e-__specFileSuffix__.js +4 -0
  4. package/dist/lib/application/files/ts/package.json +3 -3
  5. package/dist/lib/application/files/ts/test/app.e2e-__specFileSuffix__.ts +4 -0
  6. package/dist/lib/application/schema.json +5 -0
  7. package/dist/lib/class/class.factory.js +6 -1
  8. package/dist/lib/class/schema.json +5 -0
  9. package/dist/lib/controller/controller.factory.js +2 -0
  10. package/dist/lib/controller/schema.json +5 -0
  11. package/dist/lib/decorator/decorator.factory.js +6 -1
  12. package/dist/lib/decorator/schema.json +5 -0
  13. package/dist/lib/filter/filter.factory.js +6 -1
  14. package/dist/lib/filter/schema.json +5 -0
  15. package/dist/lib/gateway/gateway.factory.js +2 -0
  16. package/dist/lib/gateway/schema.json +5 -0
  17. package/dist/lib/guard/guard.factory.js +6 -1
  18. package/dist/lib/guard/schema.json +5 -0
  19. package/dist/lib/interceptor/interceptor.factory.js +6 -1
  20. package/dist/lib/interceptor/schema.json +5 -0
  21. package/dist/lib/interface/interface.factory.js +6 -1
  22. package/dist/lib/interface/schema.json +5 -0
  23. package/dist/lib/library/library.factory.js +2 -0
  24. package/dist/lib/library/schema.json +5 -0
  25. package/dist/lib/middleware/middleware.factory.js +6 -1
  26. package/dist/lib/middleware/schema.json +5 -0
  27. package/dist/lib/module/module.factory.js +2 -0
  28. package/dist/lib/module/schema.json +5 -0
  29. package/dist/lib/pipe/pipe.factory.js +6 -1
  30. package/dist/lib/pipe/schema.json +5 -0
  31. package/dist/lib/provider/provider.factory.js +2 -0
  32. package/dist/lib/provider/schema.json +5 -0
  33. package/dist/lib/resolver/resolver.factory.js +2 -0
  34. package/dist/lib/resolver/schema.json +5 -0
  35. package/dist/lib/resource/resource.factory.js +2 -0
  36. package/dist/lib/resource/schema.json +5 -0
  37. package/dist/lib/service/schema.json +5 -0
  38. package/dist/lib/service/service.factory.js +2 -0
  39. package/dist/lib/sub-app/schema.json +5 -0
  40. package/dist/lib/sub-app/sub-app.factory.js +2 -0
  41. package/dist/utils/format-files.rule.d.ts +3 -0
  42. package/dist/utils/format-files.rule.js +48 -0
  43. package/dist/utils/index.d.ts +1 -0
  44. package/dist/utils/index.js +1 -0
  45. package/package.json +25 -19
@@ -4,6 +4,7 @@ exports.main = main;
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 format_files_rule_1 = require("../../utils/format-files.rule");
7
8
  const formatting_1 = require("../../utils/formatting");
8
9
  const defaults_1 = require("../defaults");
9
10
  function main(options) {
@@ -12,7 +13,10 @@ function main(options) {
12
13
  ? options.name
13
14
  : options.directory;
14
15
  options = transform(options);
15
- return (0, schematics_1.mergeWith)(generate(options, path));
16
+ return (0, schematics_1.chain)([
17
+ (0, schematics_1.mergeWith)(generate(options, path)),
18
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
19
+ ]);
16
20
  }
17
21
  function transform(options) {
18
22
  const target = Object.assign({}, options);
@@ -22,17 +22,17 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "@nestjs/testing": "^11.0.1",
25
- "@babel/core": "7.28.4",
26
- "@babel/node": "7.28.0",
27
- "@babel/plugin-proposal-decorators": "7.28.0",
28
- "@babel/plugin-transform-runtime": "7.28.3",
29
- "@babel/preset-env": "7.28.3",
30
- "@babel/register": "7.28.3",
31
- "@babel/runtime": "7.28.4",
32
- "jest": "30.2.0",
33
- "nodemon": "3.1.10",
34
- "prettier": "3.6.2",
35
- "supertest": "7.1.4"
25
+ "@babel/core": "7.29.0",
26
+ "@babel/node": "7.29.0",
27
+ "@babel/plugin-proposal-decorators": "7.29.0",
28
+ "@babel/plugin-transform-runtime": "7.29.0",
29
+ "@babel/preset-env": "7.29.2",
30
+ "@babel/register": "7.28.6",
31
+ "@babel/runtime": "7.29.2",
32
+ "jest": "30.3.0",
33
+ "nodemon": "3.1.14",
34
+ "prettier": "3.8.3",
35
+ "supertest": "7.2.2"
36
36
  },
37
37
  "jest": {
38
38
  "moduleFileExtensions": [
@@ -20,4 +20,8 @@ describe('AppController (e2e)', () => {
20
20
  .expect(200)
21
21
  .expect('Hello World!');
22
22
  });
23
+
24
+ afterEach(async () => {
25
+ await app.close();
26
+ });
23
27
  });
@@ -34,12 +34,12 @@
34
34
  "@nestjs/testing": "^11.0.1",
35
35
  "@types/express": "^5.0.0",
36
36
  "@types/jest": "^30.0.0",
37
- "@types/node": "^22.10.7",
38
- "@types/supertest": "^6.0.2",
37
+ "@types/node": "^24.0.0",
38
+ "@types/supertest": "^7.0.0",
39
39
  "eslint": "^9.18.0",
40
40
  "eslint-config-prettier": "^10.0.1",
41
41
  "eslint-plugin-prettier": "^5.2.2",
42
- "globals": "^16.0.0",
42
+ "globals": "^17.0.0",
43
43
  "jest": "^30.0.0",
44
44
  "prettier": "^3.4.2",
45
45
  "source-map-support": "^0.5.21",
@@ -22,4 +22,8 @@ describe('AppController (e2e)', () => {
22
22
  .expect(200)
23
23
  .expect('Hello World!');
24
24
  });
25
+
26
+ afterEach(async () => {
27
+ await app.close();
28
+ });
25
29
  });
@@ -65,6 +65,11 @@
65
65
  "type": "string",
66
66
  "default": "spec",
67
67
  "description": "Specifies the file suffix of spec files."
68
+ },
69
+ "format": {
70
+ "type": "boolean",
71
+ "default": false,
72
+ "description": "Format generated files using Prettier if available."
68
73
  }
69
74
  },
70
75
  "required": ["name"]
@@ -3,13 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const format_files_rule_1 = require("../../utils/format-files.rule");
6
7
  const formatting_1 = require("../../utils/formatting");
7
8
  const name_parser_1 = require("../../utils/name.parser");
8
9
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
9
10
  const defaults_1 = require("../defaults");
10
11
  function main(options) {
11
12
  options = transform(options);
12
- return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
13
+ return (0, schematics_1.chain)([
14
+ (0, source_root_helpers_1.mergeSourceRoot)(options),
15
+ (0, schematics_1.mergeWith)(generate(options)),
16
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
17
+ ]);
13
18
  }
14
19
  function transform(options) {
15
20
  const target = Object.assign({}, options);
@@ -44,6 +44,11 @@
44
44
  "className": {
45
45
  "type": "string",
46
46
  "description": "Class name to be used internally."
47
+ },
48
+ "format": {
49
+ "type": "boolean",
50
+ "default": false,
51
+ "description": "Format generated files using Prettier if available."
47
52
  }
48
53
  },
49
54
  "required": ["name"]
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const format_files_rule_1 = require("../../utils/format-files.rule");
6
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");
@@ -18,6 +19,7 @@ function main(options) {
18
19
  (0, source_root_helpers_1.mergeSourceRoot)(options),
19
20
  (0, schematics_1.mergeWith)(generate(options)),
20
21
  addDeclarationToModule(options),
22
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
21
23
  ]))(tree, context);
22
24
  };
23
25
  }
@@ -49,6 +49,11 @@
49
49
  "type": "string",
50
50
  "default": "spec",
51
51
  "description": "Specifies the file suffix of spec files."
52
+ },
53
+ "format": {
54
+ "type": "boolean",
55
+ "default": false,
56
+ "description": "Format generated files using Prettier if available."
52
57
  }
53
58
  },
54
59
  "required": ["name"]
@@ -3,12 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const format_files_rule_1 = require("../../utils/format-files.rule");
6
7
  const formatting_1 = require("../../utils/formatting");
7
8
  const name_parser_1 = require("../../utils/name.parser");
8
9
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
9
10
  function main(options) {
10
11
  options = transform(options);
11
- return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
12
+ return (0, schematics_1.chain)([
13
+ (0, source_root_helpers_1.mergeSourceRoot)(options),
14
+ (0, schematics_1.mergeWith)(generate(options)),
15
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
16
+ ]);
12
17
  }
13
18
  function transform(options) {
14
19
  const target = Object.assign({}, options);
@@ -30,6 +30,11 @@
30
30
  "type": "boolean",
31
31
  "default": true,
32
32
  "description": "Flag to indicate if a directory is created."
33
+ },
34
+ "format": {
35
+ "type": "boolean",
36
+ "default": false,
37
+ "description": "Format generated files using Prettier if available."
33
38
  }
34
39
  },
35
40
  "required": ["name"]
@@ -3,12 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const format_files_rule_1 = require("../../utils/format-files.rule");
6
7
  const formatting_1 = require("../../utils/formatting");
7
8
  const name_parser_1 = require("../../utils/name.parser");
8
9
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
9
10
  function main(options) {
10
11
  options = transform(options);
11
- return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
12
+ return (0, schematics_1.chain)([
13
+ (0, source_root_helpers_1.mergeSourceRoot)(options),
14
+ (0, schematics_1.mergeWith)(generate(options)),
15
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
16
+ ]);
12
17
  }
13
18
  function transform(options) {
14
19
  const target = Object.assign({}, options);
@@ -40,6 +40,11 @@
40
40
  "type": "string",
41
41
  "default": "spec",
42
42
  "description": "Specifies the file suffix of spec files."
43
+ },
44
+ "format": {
45
+ "type": "boolean",
46
+ "default": false,
47
+ "description": "Format generated files using Prettier if available."
43
48
  }
44
49
  },
45
50
  "required": ["name"]
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const format_files_rule_1 = require("../../utils/format-files.rule");
6
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");
@@ -15,6 +16,7 @@ function main(options) {
15
16
  (0, source_root_helpers_1.mergeSourceRoot)(options),
16
17
  addDeclarationToModule(options),
17
18
  (0, schematics_1.mergeWith)(generate(options)),
19
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
18
20
  ]))(tree, context);
19
21
  };
20
22
  }
@@ -40,6 +40,11 @@
40
40
  "type": "string",
41
41
  "default": "spec",
42
42
  "description": "Specifies the file suffix of spec files."
43
+ },
44
+ "format": {
45
+ "type": "boolean",
46
+ "default": false,
47
+ "description": "Format generated files using Prettier if available."
43
48
  }
44
49
  },
45
50
  "required": ["name"]
@@ -3,12 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const format_files_rule_1 = require("../../utils/format-files.rule");
6
7
  const formatting_1 = require("../../utils/formatting");
7
8
  const name_parser_1 = require("../../utils/name.parser");
8
9
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
9
10
  function main(options) {
10
11
  options = transform(options);
11
- return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
12
+ return (0, schematics_1.chain)([
13
+ (0, source_root_helpers_1.mergeSourceRoot)(options),
14
+ (0, schematics_1.mergeWith)(generate(options)),
15
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
16
+ ]);
12
17
  }
13
18
  function transform(options) {
14
19
  const target = Object.assign({}, options);
@@ -40,6 +40,11 @@
40
40
  "type": "string",
41
41
  "default": "spec",
42
42
  "description": "Specifies the file suffix of spec files."
43
+ },
44
+ "format": {
45
+ "type": "boolean",
46
+ "default": false,
47
+ "description": "Format generated files using Prettier if available."
43
48
  }
44
49
  },
45
50
  "required": ["name"]
@@ -3,12 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const format_files_rule_1 = require("../../utils/format-files.rule");
6
7
  const formatting_1 = require("../../utils/formatting");
7
8
  const name_parser_1 = require("../../utils/name.parser");
8
9
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
9
10
  function main(options) {
10
11
  options = transform(options);
11
- return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
12
+ return (0, schematics_1.chain)([
13
+ (0, source_root_helpers_1.mergeSourceRoot)(options),
14
+ (0, schematics_1.mergeWith)(generate(options)),
15
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
16
+ ]);
12
17
  }
13
18
  function transform(options) {
14
19
  const target = Object.assign({}, options);
@@ -40,6 +40,11 @@
40
40
  "type": "string",
41
41
  "default": "spec",
42
42
  "description": "Specifies the file suffix of spec files."
43
+ },
44
+ "format": {
45
+ "type": "boolean",
46
+ "default": false,
47
+ "description": "Format generated files using Prettier if available."
43
48
  }
44
49
  },
45
50
  "required": ["name"]
@@ -3,12 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const format_files_rule_1 = require("../../utils/format-files.rule");
6
7
  const formatting_1 = require("../../utils/formatting");
7
8
  const name_parser_1 = require("../../utils/name.parser");
8
9
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
9
10
  function main(options) {
10
11
  options = transform(options);
11
- return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
12
+ return (0, schematics_1.chain)([
13
+ (0, source_root_helpers_1.mergeSourceRoot)(options),
14
+ (0, schematics_1.mergeWith)(generate(options)),
15
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
16
+ ]);
12
17
  }
13
18
  function transform(options) {
14
19
  const target = Object.assign({}, options);
@@ -26,6 +26,11 @@
26
26
  "type": "boolean",
27
27
  "default": true,
28
28
  "description": "Flag to indicate if a directory is created."
29
+ },
30
+ "format": {
31
+ "type": "boolean",
32
+ "default": false,
33
+ "description": "Format generated files using Prettier if available."
29
34
  }
30
35
  },
31
36
  "required": ["name"]
@@ -4,6 +4,7 @@ exports.main = main;
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 format_files_rule_1 = require("../../utils/format-files.rule");
7
8
  const utils_1 = require("../../utils");
8
9
  const defaults_1 = require("../defaults");
9
10
  const readers_1 = require("../readers");
@@ -15,6 +16,7 @@ function main(options) {
15
16
  updateJestEndToEnd(options),
16
17
  updateTsConfig(options.name, options.prefix, options.path),
17
18
  (0, schematics_1.branchAndMerge)((0, schematics_1.mergeWith)(generate(options))),
19
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
18
20
  ]);
19
21
  }
20
22
  function getDefaultLibraryPrefix(defaultLibraryPrefix = '@app') {
@@ -31,6 +31,11 @@
31
31
  "type": "string",
32
32
  "format": "path",
33
33
  "description": "The libraries root directory."
34
+ },
35
+ "format": {
36
+ "type": "boolean",
37
+ "default": false,
38
+ "description": "Format generated files using Prettier if available."
34
39
  }
35
40
  },
36
41
  "required": ["name", "prefix"]
@@ -3,12 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const format_files_rule_1 = require("../../utils/format-files.rule");
6
7
  const formatting_1 = require("../../utils/formatting");
7
8
  const name_parser_1 = require("../../utils/name.parser");
8
9
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
9
10
  function main(options) {
10
11
  options = transform(options);
11
- return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
12
+ return (0, schematics_1.chain)([
13
+ (0, source_root_helpers_1.mergeSourceRoot)(options),
14
+ (0, schematics_1.mergeWith)(generate(options)),
15
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
16
+ ]);
12
17
  }
13
18
  function transform(options) {
14
19
  const target = Object.assign({}, options);
@@ -40,6 +40,11 @@
40
40
  "type": "string",
41
41
  "default": "spec",
42
42
  "description": "Specifies the file suffix of spec files."
43
+ },
44
+ "format": {
45
+ "type": "boolean",
46
+ "default": false,
47
+ "description": "Format generated files using Prettier if available."
43
48
  }
44
49
  },
45
50
  "required": ["name"]
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const format_files_rule_1 = require("../../utils/format-files.rule");
6
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");
@@ -15,6 +16,7 @@ function main(options) {
15
16
  (0, source_root_helpers_1.mergeSourceRoot)(options),
16
17
  addDeclarationToModule(options),
17
18
  (0, schematics_1.mergeWith)(generate(options)),
19
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
18
20
  ]))(tree, context);
19
21
  };
20
22
  }
@@ -40,6 +40,11 @@
40
40
  "type": "boolean",
41
41
  "default": false,
42
42
  "description": "Flag to indicate if a directory is created."
43
+ },
44
+ "format": {
45
+ "type": "boolean",
46
+ "default": false,
47
+ "description": "Format generated files using Prettier if available."
43
48
  }
44
49
  },
45
50
  "required": ["name"]
@@ -3,12 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const format_files_rule_1 = require("../../utils/format-files.rule");
6
7
  const formatting_1 = require("../../utils/formatting");
7
8
  const name_parser_1 = require("../../utils/name.parser");
8
9
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
9
10
  function main(options) {
10
11
  options = transform(options);
11
- return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
12
+ return (0, schematics_1.chain)([
13
+ (0, source_root_helpers_1.mergeSourceRoot)(options),
14
+ (0, schematics_1.mergeWith)(generate(options)),
15
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
16
+ ]);
12
17
  }
13
18
  function transform(options) {
14
19
  const target = Object.assign({}, options);
@@ -40,6 +40,11 @@
40
40
  "type": "string",
41
41
  "default": "spec",
42
42
  "description": "Specifies the file suffix of spec files."
43
+ },
44
+ "format": {
45
+ "type": "boolean",
46
+ "default": false,
47
+ "description": "Format generated files using Prettier if available."
43
48
  }
44
49
  },
45
50
  "required": ["name"]
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const format_files_rule_1 = require("../../utils/format-files.rule");
6
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");
@@ -15,6 +16,7 @@ function main(options) {
15
16
  (0, source_root_helpers_1.mergeSourceRoot)(options),
16
17
  addDeclarationToModule(options),
17
18
  (0, schematics_1.mergeWith)(generate(options)),
19
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
18
20
  ]))(tree, context);
19
21
  };
20
22
  }
@@ -44,6 +44,11 @@
44
44
  "className": {
45
45
  "type": "string",
46
46
  "description": "Class name to be used internally."
47
+ },
48
+ "format": {
49
+ "type": "boolean",
50
+ "default": false,
51
+ "description": "Format generated files using Prettier if available."
47
52
  }
48
53
  },
49
54
  "required": ["name"]
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const format_files_rule_1 = require("../../utils/format-files.rule");
6
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");
@@ -15,6 +16,7 @@ function main(options) {
15
16
  (0, source_root_helpers_1.mergeSourceRoot)(options),
16
17
  addDeclarationToModule(options),
17
18
  (0, schematics_1.mergeWith)(generate(options)),
19
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
18
20
  ]))(tree, context);
19
21
  };
20
22
  }
@@ -40,6 +40,11 @@
40
40
  "type": "string",
41
41
  "default": "spec",
42
42
  "description": "Specifies the file suffix of spec files."
43
+ },
44
+ "format": {
45
+ "type": "boolean",
46
+ "default": false,
47
+ "description": "Format generated files using Prettier if available."
43
48
  }
44
49
  },
45
50
  "required": ["name"]
@@ -8,6 +8,7 @@ const tasks_1 = require("@angular-devkit/schematics/tasks");
8
8
  const pluralize = require("pluralize");
9
9
  const __1 = require("../..");
10
10
  const dependencies_utils_1 = require("../../utils/dependencies.utils");
11
+ const format_files_rule_1 = require("../../utils/format-files.rule");
11
12
  const formatting_1 = require("../../utils/formatting");
12
13
  const name_parser_1 = require("../../utils/name.parser");
13
14
  const source_root_helpers_1 = require("../../utils/source-root.helpers");
@@ -19,6 +20,7 @@ function main(options) {
19
20
  (0, source_root_helpers_1.mergeSourceRoot)(options),
20
21
  addDeclarationToModule(options),
21
22
  (0, schematics_1.mergeWith)(generate(options)),
23
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
22
24
  ]))(tree, context);
23
25
  };
24
26
  }
@@ -89,6 +89,11 @@
89
89
  "message": "Would you like to generate CRUD entry points?",
90
90
  "type": "confirmation"
91
91
  }
92
+ },
93
+ "format": {
94
+ "type": "boolean",
95
+ "default": false,
96
+ "description": "Format generated files using Prettier if available."
92
97
  }
93
98
  },
94
99
  "required": ["name"]
@@ -40,6 +40,11 @@
40
40
  "type": "string",
41
41
  "default": "spec",
42
42
  "description": "Specifies the file suffix of spec files."
43
+ },
44
+ "format": {
45
+ "type": "boolean",
46
+ "default": false,
47
+ "description": "Format generated files using Prettier if available."
43
48
  }
44
49
  },
45
50
  "required": ["name"]
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = main;
4
4
  const core_1 = require("@angular-devkit/core");
5
5
  const schematics_1 = require("@angular-devkit/schematics");
6
+ const format_files_rule_1 = require("../../utils/format-files.rule");
6
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");
@@ -18,6 +19,7 @@ function main(options) {
18
19
  (0, source_root_helpers_1.mergeSourceRoot)(options),
19
20
  addDeclarationToModule(options),
20
21
  (0, schematics_1.mergeWith)(generate(options)),
22
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
21
23
  ]))(tree, context);
22
24
  };
23
25
  }
@@ -31,6 +31,11 @@
31
31
  "type": "string",
32
32
  "default": "spec",
33
33
  "description": "Specifies the file suffix of spec files."
34
+ },
35
+ "format": {
36
+ "type": "boolean",
37
+ "default": false,
38
+ "description": "Format generated files using Prettier if available."
34
39
  }
35
40
  },
36
41
  "required": ["name"]
@@ -6,6 +6,7 @@ const schematics_1 = require("@angular-devkit/schematics");
6
6
  const fs_1 = require("fs");
7
7
  const comment_json_1 = require("comment-json");
8
8
  const utils_1 = require("../../utils");
9
+ const format_files_rule_1 = require("../../utils/format-files.rule");
9
10
  const defaults_1 = require("../defaults");
10
11
  function main(options) {
11
12
  const appName = getAppNameFromPackageJson();
@@ -21,6 +22,7 @@ function main(options) {
21
22
  ])(tree, context),
22
23
  addAppsToCliOptions(options.path, options.name, appName),
23
24
  (0, schematics_1.branchAndMerge)((0, schematics_1.mergeWith)(generate(options))),
25
+ options.format === true ? (0, format_files_rule_1.formatFiles)() : (0, schematics_1.noop)(),
24
26
  ]);
25
27
  }
26
28
  function getAppNameFromPackageJson() {
@@ -0,0 +1,3 @@
1
+ import { Path } from '@angular-devkit/core';
2
+ import { Rule } from '@angular-devkit/schematics';
3
+ export declare function formatFiles(paths?: Array<string | Path>): Rule;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatFiles = formatFiles;
4
+ const FORMATTABLE_EXTENSIONS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'];
5
+ function formatFiles(paths) {
6
+ return async (tree, _context) => {
7
+ let prettier;
8
+ try {
9
+ prettier = await Promise.resolve().then(() => require('prettier'));
10
+ }
11
+ catch {
12
+ return tree;
13
+ }
14
+ const candidates = (paths ??
15
+ tree.actions
16
+ .filter((action) => action.kind === 'c' ||
17
+ action.kind === 'o' ||
18
+ action.kind === 'r')
19
+ .map((action) => action.path))
20
+ .map((p) => (typeof p === 'string' ? p : String(p)))
21
+ .filter((p) => FORMATTABLE_EXTENSIONS.some((ext) => p.endsWith(ext)));
22
+ const uniquePaths = Array.from(new Set(candidates));
23
+ for (const filePath of uniquePaths) {
24
+ if (!tree.exists(filePath)) {
25
+ continue;
26
+ }
27
+ const buffer = tree.read(filePath);
28
+ if (!buffer) {
29
+ continue;
30
+ }
31
+ const source = buffer.toString('utf-8');
32
+ try {
33
+ const resolvedOptions = (await prettier.resolveConfig(filePath)) ?? undefined;
34
+ const formatted = await prettier.format(source, {
35
+ ...resolvedOptions,
36
+ filepath: filePath,
37
+ });
38
+ if (formatted !== source) {
39
+ tree.overwrite(filePath, formatted);
40
+ }
41
+ }
42
+ catch {
43
+ continue;
44
+ }
45
+ }
46
+ return tree;
47
+ };
48
+ }
@@ -1,3 +1,4 @@
1
+ export * from './format-files.rule';
1
2
  export * from './metadata.manager';
2
3
  export * from './module-import.declarator';
3
4
  export * from './module-metadata.declarator';
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./format-files.rule"), exports);
17
18
  __exportStar(require("./metadata.manager"), exports);
18
19
  __exportStar(require("./module-import.declarator"), exports);
19
20
  __exportStar(require("./module-metadata.declarator"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/schematics",
3
- "version": "11.0.9",
3
+ "version": "11.1.0",
4
4
  "description": "Nest - modern, fast, powerful node.js web framework (@schematics)",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -41,42 +41,48 @@
41
41
  },
42
42
  "homepage": "https://github.com/nestjs/schematics#readme",
43
43
  "dependencies": {
44
- "@angular-devkit/core": "19.2.17",
45
- "@angular-devkit/schematics": "19.2.17",
46
- "comment-json": "4.4.1",
44
+ "@angular-devkit/core": "19.2.24",
45
+ "@angular-devkit/schematics": "19.2.24",
46
+ "comment-json": "5.0.0",
47
47
  "jsonc-parser": "3.3.1",
48
48
  "pluralize": "8.0.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@commitlint/cli": "20.1.0",
52
- "@commitlint/config-angular": "20.0.0",
53
- "@eslint/eslintrc": "3.3.1",
54
- "@eslint/js": "9.37.0",
51
+ "@commitlint/cli": "20.5.0",
52
+ "@commitlint/config-angular": "20.5.0",
53
+ "@eslint/eslintrc": "3.3.5",
54
+ "@eslint/js": "9.39.4",
55
55
  "@types/jest": "30.0.0",
56
- "@types/node": "22.18.9",
57
- "@typescript-eslint/eslint-plugin": "8.46.0",
58
- "@typescript-eslint/parser": "8.46.0",
59
- "cpx2": "8.0.0",
60
- "eslint": "9.37.0",
56
+ "@types/node": "24.12.2",
57
+ "@typescript-eslint/eslint-plugin": "8.58.2",
58
+ "@typescript-eslint/parser": "8.58.2",
59
+ "cpx2": "8.0.2",
60
+ "eslint": "9.39.4",
61
61
  "eslint-config-prettier": "10.1.8",
62
62
  "eslint-plugin-import": "2.32.0",
63
63
  "eslint-plugin-prettier": "^5.2.1",
64
- "globals": "16.4.0",
64
+ "globals": "17.5.0",
65
65
  "gulp": "5.0.1",
66
66
  "gulp-clean": "0.4.0",
67
67
  "husky": "9.1.7",
68
- "jest": "30.2.0",
69
- "nyc": "17.1.0",
70
- "prettier": "3.6.2",
71
- "release-it": "19.0.5",
72
- "ts-jest": "29.4.4",
68
+ "jest": "30.3.0",
69
+ "nyc": "18.0.0",
70
+ "prettier": "3.8.3",
71
+ "release-it": "20.0.0",
72
+ "ts-jest": "29.4.9",
73
73
  "ts-node": "10.9.2",
74
74
  "typescript": "5.9.3",
75
75
  "typescript-eslint": "^8.15.0"
76
76
  },
77
77
  "peerDependencies": {
78
+ "prettier": "^3.0.0",
78
79
  "typescript": ">=4.8.2"
79
80
  },
81
+ "peerDependenciesMeta": {
82
+ "prettier": {
83
+ "optional": true
84
+ }
85
+ },
80
86
  "schematics": "./dist/collection.json",
81
87
  "nyc": {
82
88
  "include": [