@nx/nest 20.0.0-beta.4 → 20.0.0-beta.6

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 (32) hide show
  1. package/migrations.json +2 -74
  2. package/package.json +6 -8
  3. package/src/generators/application/application.js +2 -0
  4. package/src/generators/application/lib/normalize-options.js +2 -4
  5. package/src/generators/application/schema.d.ts +2 -4
  6. package/src/generators/application/schema.json +8 -12
  7. package/src/generators/class/schema.json +7 -21
  8. package/src/generators/controller/schema.json +7 -12
  9. package/src/generators/decorator/schema.json +7 -12
  10. package/src/generators/filter/schema.json +7 -12
  11. package/src/generators/gateway/schema.json +7 -12
  12. package/src/generators/guard/schema.json +6 -11
  13. package/src/generators/init/init.js +2 -0
  14. package/src/generators/interceptor/schema.json +6 -11
  15. package/src/generators/interface/schema.json +7 -21
  16. package/src/generators/library/lib/normalize-options.js +2 -3
  17. package/src/generators/library/library.js +2 -0
  18. package/src/generators/library/schema.d.ts +2 -4
  19. package/src/generators/library/schema.json +9 -14
  20. package/src/generators/middleware/schema.json +7 -12
  21. package/src/generators/module/schema.json +7 -12
  22. package/src/generators/pipe/schema.json +7 -12
  23. package/src/generators/provider/schema.json +7 -12
  24. package/src/generators/resolver/schema.json +7 -12
  25. package/src/generators/resource/schema.json +7 -12
  26. package/src/generators/service/schema.json +0 -10
  27. package/src/generators/utils/normalize-options.js +1 -2
  28. package/src/generators/utils/types.d.ts +2 -4
  29. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +0 -2
  30. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +0 -9
  31. package/src/migrations/update-16-4-0-cache-manager/nestjs-10-updates.d.ts +0 -5
  32. package/src/migrations/update-16-4-0-cache-manager/nestjs-10-updates.js +0 -80
package/migrations.json CHANGED
@@ -1,76 +1,4 @@
1
1
  {
2
- "generators": {
3
- "update-16-0-0-add-nx-packages": {
4
- "cli": "nx",
5
- "version": "16.0.0-beta.1",
6
- "description": "Replace @nrwl/nest with @nx/nest",
7
- "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
8
- },
9
- "update-16-4-0-support-nestjs-10": {
10
- "cli": "nx",
11
- "version": "16.4.0-beta.16",
12
- "description": "Update TsConfig target to es2021 and CacheModule if being used. Read more at https://docs.nestjs.com/migration-guide",
13
- "implementation": "./src/migrations/update-16-4-0-cache-manager/nestjs-10-updates"
14
- }
15
- },
16
- "packageJsonUpdates": {
17
- "16.1.0": {
18
- "version": "16.1.0-beta.0",
19
- "packages": {
20
- "@nestjs/common": {
21
- "version": "^9.1.1",
22
- "alwaysAddToPackageJson": false
23
- },
24
- "@nestjs/core": {
25
- "version": "^9.1.1",
26
- "alwaysAddToPackageJson": false
27
- },
28
- "@nestjs/platform-express": {
29
- "version": "^9.1.1",
30
- "alwaysAddToPackageJson": false
31
- },
32
- "@nestjs/schematics": {
33
- "version": "^9.1.0",
34
- "alwaysAddToPackageJson": false
35
- },
36
- "@nestjs/swagger": {
37
- "version": "^6.3.0",
38
- "alwaysAddToPackageJson": false
39
- },
40
- "@nestjs/testing": {
41
- "version": "^9.1.1",
42
- "alwaysAddToPackageJson": false
43
- }
44
- }
45
- },
46
- "16.4.0": {
47
- "version": "16.4.0-beta.11",
48
- "packages": {
49
- "@nestjs/common": {
50
- "version": "^10.0.2",
51
- "alwaysAddToPackageJson": false
52
- },
53
- "@nestjs/core": {
54
- "version": "^10.0.2",
55
- "alwaysAddToPackageJson": false
56
- },
57
- "@nestjs/platform-express": {
58
- "version": "^10.0.2",
59
- "alwaysAddToPackageJson": false
60
- },
61
- "@nestjs/schematics": {
62
- "version": "^10.0.1",
63
- "alwaysAddToPackageJson": false
64
- },
65
- "@nestjs/swagger": {
66
- "version": "^7.0.2",
67
- "alwaysAddToPackageJson": false
68
- },
69
- "@nestjs/testing": {
70
- "version": "^10.0.2",
71
- "alwaysAddToPackageJson": false
72
- }
73
- }
74
- }
75
- }
2
+ "generators": {},
3
+ "packageJsonUpdates": {}
76
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/nest",
3
- "version": "20.0.0-beta.4",
3
+ "version": "20.0.0-beta.6",
4
4
  "private": false,
5
5
  "description": "The Nx Plugin for Nest contains executors and generators for allowing your workspace to create powerful Nest best in class APIs.",
6
6
  "repository": {
@@ -32,13 +32,11 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@nestjs/schematics": "^9.1.0",
35
- "@nx/devkit": "20.0.0-beta.4",
36
- "@nx/js": "20.0.0-beta.4",
37
- "@nx/eslint": "20.0.0-beta.4",
38
- "@nx/node": "20.0.0-beta.4",
39
- "@phenomnomnominal/tsquery": "~5.0.1",
40
- "tslib": "^2.3.0",
41
- "@nrwl/nest": "20.0.0-beta.4"
35
+ "@nx/devkit": "20.0.0-beta.6",
36
+ "@nx/js": "20.0.0-beta.6",
37
+ "@nx/eslint": "20.0.0-beta.6",
38
+ "@nx/node": "20.0.0-beta.6",
39
+ "tslib": "^2.3.0"
42
40
  },
43
41
  "publishConfig": {
44
42
  "access": "public"
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.applicationGenerator = applicationGenerator;
4
4
  exports.applicationGeneratorInternal = applicationGeneratorInternal;
5
5
  const devkit_1 = require("@nx/devkit");
6
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
6
7
  const node_1 = require("@nx/node");
7
8
  const init_1 = require("../init/init");
8
9
  const lib_1 = require("./lib");
@@ -14,6 +15,7 @@ async function applicationGenerator(tree, rawOptions) {
14
15
  });
15
16
  }
16
17
  async function applicationGeneratorInternal(tree, rawOptions) {
18
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'nest', 'application');
17
19
  const options = await (0, lib_1.normalizeOptions)(tree, rawOptions);
18
20
  const tasks = [];
19
21
  const initTask = await (0, init_1.initGenerator)(tree, {
@@ -6,15 +6,14 @@ const devkit_1 = require("@nx/devkit");
6
6
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
7
7
  const eslint_1 = require("@nx/eslint");
8
8
  async function normalizeOptions(tree, options) {
9
- const { projectName: appProjectName, projectRoot: appProjectRoot, projectNameAndRootFormat, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
9
+ await (0, project_name_and_root_utils_1.ensureProjectName)(tree, options, 'application');
10
+ const { projectName: appProjectName, projectRoot: appProjectRoot } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
10
11
  name: options.name,
11
12
  projectType: 'application',
12
13
  directory: options.directory,
13
- projectNameAndRootFormat: options.projectNameAndRootFormat,
14
14
  rootProject: options.rootProject,
15
15
  });
16
16
  options.rootProject = appProjectRoot === '.';
17
- options.projectNameAndRootFormat = projectNameAndRootFormat;
18
17
  const nxJson = (0, devkit_1.readNxJson)(tree);
19
18
  const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
20
19
  nxJson.useInferencePlugins !== false;
@@ -34,7 +33,6 @@ function toNodeApplicationGeneratorOptions(options) {
34
33
  name: options.name,
35
34
  directory: options.directory,
36
35
  frontendProject: options.frontendProject,
37
- projectNameAndRootFormat: options.projectNameAndRootFormat,
38
36
  linter: options.linter,
39
37
  skipFormat: true,
40
38
  skipPackageJson: options.skipPackageJson,
@@ -1,10 +1,8 @@
1
- import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
1
  import type { Linter, LinterType } from '@nx/eslint';
3
2
 
4
3
  export interface ApplicationGeneratorOptions {
5
- name: string;
6
- directory?: string;
7
- projectNameAndRootFormat?: ProjectNameAndRootFormat;
4
+ directory: string;
5
+ name?: string;
8
6
  frontendProject?: string;
9
7
  linter?: Linter | LinterType;
10
8
  skipFormat?: boolean;
@@ -6,24 +6,20 @@
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
10
- "description": "The name of the application.",
9
+ "directory": {
10
+ "description": "The directory of the new application.",
11
11
  "type": "string",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "What name would you like to use for the node application?",
17
- "pattern": "^[a-zA-Z][^:]*$"
16
+ "x-prompt": "Which directory do you want to create the application in?"
18
17
  },
19
- "directory": {
20
- "description": "The directory of the new application.",
21
- "type": "string"
22
- },
23
- "projectNameAndRootFormat": {
24
- "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
18
+ "name": {
19
+ "description": "The name of the application.",
25
20
  "type": "string",
26
- "enum": ["as-provided", "derived"]
21
+ "pattern": "^[a-zA-Z][^:]*$",
22
+ "x-priority": "important"
27
23
  },
28
24
  "skipFormat": {
29
25
  "description": "Skip formatting files.",
@@ -82,5 +78,5 @@
82
78
  }
83
79
  },
84
80
  "additionalProperties": false,
85
- "required": ["name"]
81
+ "required": ["directory"]
86
82
  }
@@ -6,33 +6,19 @@
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
10
- "description": "The name of the class.",
9
+ "path": {
10
+ "description": "Path where the class will be generated.",
11
11
  "type": "string",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "What name would you like to use?"
17
- },
18
- "nameAndDirectoryFormat": {
19
- "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
20
- "type": "string",
21
- "enum": ["as-provided", "derived"]
22
- },
23
- "project": {
24
- "description": "The Nest project to target.",
25
- "type": "string",
26
- "$default": {
27
- "$source": "projectName"
28
- },
29
- "alias": "p",
30
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. The project will be determined from the directory provided. It will be removed in Nx v20."
16
+ "x-prompt": "Where should the class be generated?"
31
17
  },
32
- "directory": {
33
- "description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
18
+ "name": {
19
+ "description": "The name of the class.",
34
20
  "type": "string",
35
- "aliases": ["dir", "path"]
21
+ "x-prompt": "What name would you like to use?"
36
22
  },
37
23
  "skipFormat": {
38
24
  "description": "Skip formatting files.",
@@ -59,5 +45,5 @@
59
45
  }
60
46
  },
61
47
  "additionalProperties": false,
62
- "required": ["name"]
48
+ "required": ["path"]
63
49
  }
@@ -6,24 +6,19 @@
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
10
- "description": "The name of the controller.",
9
+ "path": {
10
+ "description": "Path where the controller will be generated.",
11
11
  "type": "string",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "What name would you like to use?"
17
- },
18
- "nameAndDirectoryFormat": {
19
- "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
20
- "type": "string",
21
- "enum": ["as-provided", "derived"]
16
+ "x-prompt": "Where should the controller be generated?"
22
17
  },
23
- "directory": {
24
- "description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
18
+ "name": {
19
+ "description": "The name of the controller.",
25
20
  "type": "string",
26
- "aliases": ["dir", "path"]
21
+ "x-prompt": "What name would you like to use?"
27
22
  },
28
23
  "skipFormat": {
29
24
  "description": "Skip formatting files.",
@@ -53,5 +48,5 @@
53
48
  }
54
49
  },
55
50
  "additionalProperties": false,
56
- "required": ["name"]
51
+ "required": ["path"]
57
52
  }
@@ -6,24 +6,19 @@
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
10
- "description": "The name of the decorator.",
9
+ "path": {
10
+ "description": "Path where the decorator will be generated.",
11
11
  "type": "string",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "What name would you like to use?"
17
- },
18
- "nameAndDirectoryFormat": {
19
- "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
20
- "type": "string",
21
- "enum": ["as-provided", "derived"]
16
+ "x-prompt": "Where should the decorator be generated?"
22
17
  },
23
- "directory": {
24
- "description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
18
+ "name": {
19
+ "description": "The name of the decorator.",
25
20
  "type": "string",
26
- "aliases": ["dir", "path"]
21
+ "x-prompt": "What name would you like to use?"
27
22
  },
28
23
  "skipFormat": {
29
24
  "description": "Skip formatting files.",
@@ -38,5 +33,5 @@
38
33
  }
39
34
  },
40
35
  "additionalProperties": false,
41
- "required": ["name"]
36
+ "required": ["path"]
42
37
  }
@@ -6,24 +6,19 @@
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
10
- "description": "The name of the filter.",
9
+ "path": {
10
+ "description": "Path where the filter will be generated.",
11
11
  "type": "string",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "What name would you like to use?"
17
- },
18
- "nameAndDirectoryFormat": {
19
- "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
20
- "type": "string",
21
- "enum": ["as-provided", "derived"]
16
+ "x-prompt": "Where should the filter be generated?"
22
17
  },
23
- "directory": {
24
- "description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
18
+ "name": {
19
+ "description": "The name of the filter.",
25
20
  "type": "string",
26
- "aliases": ["dir", "path"]
21
+ "x-prompt": "What name would you like to use?"
27
22
  },
28
23
  "skipFormat": {
29
24
  "type": "boolean",
@@ -44,5 +39,5 @@
44
39
  }
45
40
  },
46
41
  "additionalProperties": false,
47
- "required": ["name"]
42
+ "required": ["path"]
48
43
  }
@@ -6,24 +6,19 @@
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
10
- "description": "The name of the gateway.",
9
+ "path": {
10
+ "description": "Path where the gateway will be generated.",
11
11
  "type": "string",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "What name would you like to use?"
17
- },
18
- "nameAndDirectoryFormat": {
19
- "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
20
- "type": "string",
21
- "enum": ["as-provided", "derived"]
16
+ "x-prompt": "Where should the gateway be generated?"
22
17
  },
23
- "directory": {
24
- "description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
18
+ "name": {
19
+ "description": "The name of the gateway.",
25
20
  "type": "string",
26
- "aliases": ["dir", "path"]
21
+ "x-prompt": "What name would you like to use?"
27
22
  },
28
23
  "skipFormat": {
29
24
  "description": "Skip formatting files.",
@@ -44,5 +39,5 @@
44
39
  }
45
40
  },
46
41
  "additionalProperties": false,
47
- "required": ["name"]
42
+ "required": ["path"]
48
43
  }
@@ -6,24 +6,19 @@
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
10
- "description": "The name of the guard.",
9
+ "path": {
10
+ "description": "Path where the guard will be generated.",
11
11
  "type": "string",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "What name would you like to use?"
17
- },
18
- "nameAndDirectoryFormat": {
19
- "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
20
- "type": "string",
21
- "enum": ["as-provided", "derived"]
16
+ "x-prompt": "Where should the guard be generated?"
22
17
  },
23
- "directory": {
24
- "description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
18
+ "name": {
19
+ "description": "The name of the guard.",
25
20
  "type": "string",
26
- "aliases": ["dir", "path"]
21
+ "x-prompt": "What name would you like to use?"
27
22
  },
28
23
  "skipFormat": {
29
24
  "description": "Skip formatting files.",
@@ -2,8 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initGenerator = initGenerator;
4
4
  const devkit_1 = require("@nx/devkit");
5
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
5
6
  const lib_1 = require("./lib");
6
7
  async function initGenerator(tree, options) {
8
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'nest', 'init');
7
9
  let installPackagesTask = () => { };
8
10
  if (!options.skipPackageJson) {
9
11
  installPackagesTask = (0, lib_1.addDependencies)(tree, options);
@@ -6,24 +6,19 @@
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
10
- "description": "The name of the interceptor.",
9
+ "path": {
10
+ "description": "Path where the interceptor will be generated.",
11
11
  "type": "string",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "What name would you like to use?"
17
- },
18
- "nameAndDirectoryFormat": {
19
- "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
20
- "type": "string",
21
- "enum": ["as-provided", "derived"]
16
+ "x-prompt": "Where should the interceptor be generated?"
22
17
  },
23
- "directory": {
24
- "description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
18
+ "name": {
19
+ "description": "The name of the interceptor.",
25
20
  "type": "string",
26
- "aliases": ["dir", "path"]
21
+ "x-prompt": "What name would you like to use?"
27
22
  },
28
23
  "skipFormat": {
29
24
  "description": "Skip formatting files.",
@@ -6,33 +6,19 @@
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
10
- "description": "The name of the interface.",
9
+ "path": {
10
+ "description": "Path where the interface will be generated.",
11
11
  "type": "string",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "What name would you like to use?"
17
- },
18
- "nameAndDirectoryFormat": {
19
- "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
20
- "type": "string",
21
- "enum": ["as-provided", "derived"]
22
- },
23
- "project": {
24
- "description": "The Nest project to target.",
25
- "type": "string",
26
- "$default": {
27
- "$source": "projectName"
28
- },
29
- "alias": "p",
30
- "x-deprecated": "Provide The `directory` option instead and use the `as-provided` format. the project will be determined from the directory provided. It will be removed in Nx v20."
16
+ "x-prompt": "Where should the interface be generated?"
31
17
  },
32
- "directory": {
33
- "description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
18
+ "name": {
19
+ "description": "The name of the interface.",
34
20
  "type": "string",
35
- "aliases": ["dir", "path"]
21
+ "x-prompt": "What name would you like to use?"
36
22
  },
37
23
  "skipFormat": {
38
24
  "description": "Skip formatting files.",
@@ -48,5 +34,5 @@
48
34
  }
49
35
  },
50
36
  "additionalProperties": false,
51
- "required": ["name"]
37
+ "required": ["path"]
52
38
  }
@@ -7,12 +7,12 @@ const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project
7
7
  const get_npm_scope_1 = require("@nx/js/src/utils/package-json/get-npm-scope");
8
8
  const eslint_1 = require("@nx/eslint");
9
9
  async function normalizeOptions(tree, options) {
10
+ await (0, project_name_and_root_utils_1.ensureProjectName)(tree, options, 'library');
10
11
  const { projectName, names: projectNames, projectRoot, importPath, } = await (0, project_name_and_root_utils_1.determineProjectNameAndRootOptions)(tree, {
11
12
  name: options.name,
12
13
  projectType: 'library',
13
14
  directory: options.directory,
14
15
  importPath: options.importPath,
15
- projectNameAndRootFormat: options.projectNameAndRootFormat,
16
16
  });
17
17
  const nxJson = (0, devkit_1.readNxJson)(tree);
18
18
  const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
@@ -46,7 +46,7 @@ async function normalizeOptions(tree, options) {
46
46
  function toJsLibraryGeneratorOptions(options) {
47
47
  return {
48
48
  name: options.name,
49
- bundler: options?.buildable ? 'tsc' : 'none',
49
+ bundler: options.buildable || options.publishable ? 'tsc' : 'none',
50
50
  directory: options.directory,
51
51
  importPath: options.importPath,
52
52
  linter: options.linter,
@@ -60,7 +60,6 @@ function toJsLibraryGeneratorOptions(options) {
60
60
  unitTestRunner: options.unitTestRunner,
61
61
  config: options.standaloneConfig ? 'project' : 'workspace',
62
62
  setParserOptionsProject: options.setParserOptionsProject,
63
- projectNameAndRootFormat: options.projectNameAndRootFormat,
64
63
  addPlugin: options.addPlugin,
65
64
  };
66
65
  }
@@ -4,6 +4,7 @@ exports.libraryGenerator = libraryGenerator;
4
4
  exports.libraryGeneratorInternal = libraryGeneratorInternal;
5
5
  const devkit_1 = require("@nx/devkit");
6
6
  const js_1 = require("@nx/js");
7
+ const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
7
8
  const lib_1 = require("./lib");
8
9
  const init_1 = require("../init/init");
9
10
  const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
@@ -15,6 +16,7 @@ async function libraryGenerator(tree, rawOptions) {
15
16
  });
16
17
  }
17
18
  async function libraryGeneratorInternal(tree, rawOptions) {
19
+ (0, ts_solution_setup_1.assertNotUsingTsSolutionSetup)(tree, 'nest', 'library');
18
20
  const options = await (0, lib_1.normalizeOptions)(tree, rawOptions);
19
21
  await (0, js_1.libraryGenerator)(tree, (0, lib_1.toJsLibraryGeneratorOptions)(options));
20
22
  const initTask = await (0, init_1.default)(tree, rawOptions);
@@ -1,13 +1,11 @@
1
- import type { ProjectNameAndRootFormat } from '@nx/devkit/src/generators/project-name-and-root-utils';
2
1
  import type { Linter, LinterType } from '@nx/eslint';
3
2
  import type { UnitTestRunner } from '../utils';
4
3
 
5
4
  export interface LibraryGeneratorOptions {
6
- name: string;
5
+ directory: string;
6
+ name?: string;
7
7
  buildable?: boolean;
8
8
  controller?: boolean;
9
- directory?: string;
10
- projectNameAndRootFormat?: ProjectNameAndRootFormat;
11
9
  global?: boolean;
12
10
  importPath?: string;
13
11
  linter?: Linter | LinterType;
@@ -12,25 +12,20 @@
12
12
  }
13
13
  ],
14
14
  "properties": {
15
- "name": {
16
- "description": "Library name.",
15
+ "directory": {
16
+ "description": "A directory where the library is placed.",
17
17
  "type": "string",
18
+ "alias": "dir",
18
19
  "$default": {
19
20
  "$source": "argv",
20
21
  "index": 0
21
22
  },
22
- "x-prompt": "What name would you like to use for the library?",
23
- "pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$"
24
- },
25
- "directory": {
26
- "description": "A directory where the library is placed.",
27
- "type": "string",
28
- "alias": "dir"
23
+ "x-prompt": "Which directory do you want to create the library in?"
29
24
  },
30
- "projectNameAndRootFormat": {
31
- "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
32
- "type": "string",
33
- "enum": ["as-provided"]
25
+ "name": {
26
+ "description": "Library name.",
27
+ "pattern": "(?:^@[a-zA-Z0-9-*~][a-zA-Z0-9-*._~]*\\/[a-zA-Z0-9-~][a-zA-Z0-9-._~]*|^[a-zA-Z][^:]*)$",
28
+ "type": "string"
34
29
  },
35
30
  "linter": {
36
31
  "description": "The tool to use for running lint checks.",
@@ -143,5 +138,5 @@
143
138
  }
144
139
  },
145
140
  "additionalProperties": false,
146
- "required": ["name"]
141
+ "required": ["directory"]
147
142
  }
@@ -6,24 +6,19 @@
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
10
- "description": "The name of the middleware.",
9
+ "path": {
10
+ "description": "Path where the middleware will be generated.",
11
11
  "type": "string",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "What name would you like to use?"
17
- },
18
- "nameAndDirectoryFormat": {
19
- "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
20
- "type": "string",
21
- "enum": ["as-provided"]
16
+ "x-prompt": "Where should the middleware be generated?"
22
17
  },
23
- "directory": {
24
- "description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
18
+ "name": {
19
+ "description": "The name of the middleware.",
25
20
  "type": "string",
26
- "aliases": ["dir", "path"]
21
+ "x-prompt": "What name would you like to use?"
27
22
  },
28
23
  "skipFormat": {
29
24
  "description": "Skip formatting files.",
@@ -44,5 +39,5 @@
44
39
  }
45
40
  },
46
41
  "additionalProperties": false,
47
- "required": ["name"]
42
+ "required": ["path"]
48
43
  }
@@ -6,24 +6,19 @@
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
10
- "description": "The name of the module.",
9
+ "path": {
10
+ "description": "Path where the module will be generated.",
11
11
  "type": "string",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "What name would you like to use?"
17
- },
18
- "nameAndDirectoryFormat": {
19
- "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
20
- "type": "string",
21
- "enum": ["as-provided", "derived"]
16
+ "x-prompt": "Where should the module be generated?"
22
17
  },
23
- "directory": {
24
- "description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
18
+ "name": {
19
+ "description": "The name of the module.",
25
20
  "type": "string",
26
- "aliases": ["dir", "path"]
21
+ "x-prompt": "What name would you like to use?"
27
22
  },
28
23
  "skipFormat": {
29
24
  "description": "Skip formatting files.",
@@ -48,5 +43,5 @@
48
43
  }
49
44
  },
50
45
  "additionalProperties": false,
51
- "required": ["name"]
46
+ "required": ["path"]
52
47
  }
@@ -6,24 +6,19 @@
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
10
- "description": "The name of the pipe.",
9
+ "path": {
10
+ "description": "Path where the pipe will be generated.",
11
11
  "type": "string",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "What name would you like to use?"
17
- },
18
- "nameAndDirectoryFormat": {
19
- "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
20
- "type": "string",
21
- "enum": ["as-provided", "derived"]
16
+ "x-prompt": "Where should the pipe be generated?"
22
17
  },
23
- "directory": {
24
- "description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
18
+ "name": {
19
+ "description": "The name of the pipe.",
25
20
  "type": "string",
26
- "aliases": ["dir", "path"]
21
+ "x-prompt": "What name would you like to use?"
27
22
  },
28
23
  "skipFormat": {
29
24
  "description": "Skip formatting files.",
@@ -44,5 +39,5 @@
44
39
  }
45
40
  },
46
41
  "additionalProperties": false,
47
- "required": ["name"]
42
+ "required": ["path"]
48
43
  }
@@ -6,24 +6,19 @@
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
10
- "description": "The name of the provider.",
9
+ "path": {
10
+ "description": "Path where the provider will be generated.",
11
11
  "type": "string",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "What name would you like to use?"
17
- },
18
- "nameAndDirectoryFormat": {
19
- "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
20
- "type": "string",
21
- "enum": ["as-provided", "derived"]
16
+ "x-prompt": "Where should the provider be generated?"
22
17
  },
23
- "directory": {
24
- "description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
18
+ "name": {
19
+ "description": "The name of the provider.",
25
20
  "type": "string",
26
- "aliases": ["dir", "path"]
21
+ "x-prompt": "What name would you like to use?"
27
22
  },
28
23
  "skipFormat": {
29
24
  "description": "Skip formatting files.",
@@ -44,5 +39,5 @@
44
39
  }
45
40
  },
46
41
  "additionalProperties": false,
47
- "required": ["name"]
42
+ "required": ["path"]
48
43
  }
@@ -6,24 +6,19 @@
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
10
- "description": "The name of the resolver.",
9
+ "path": {
10
+ "description": "Path where the resolver will be generated.",
11
11
  "type": "string",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "What name would you like to use?"
17
- },
18
- "nameAndDirectoryFormat": {
19
- "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
20
- "type": "string",
21
- "enum": ["as-provided", "derived"]
16
+ "x-prompt": "Where should the resolver be generated?"
22
17
  },
23
- "directory": {
24
- "description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
18
+ "name": {
19
+ "description": "The name of the resolver.",
25
20
  "type": "string",
26
- "aliases": ["dir", "path"]
21
+ "x-prompt": "What name would you like to use?"
27
22
  },
28
23
  "skipFormat": {
29
24
  "description": "Skip formatting files.",
@@ -44,5 +39,5 @@
44
39
  }
45
40
  },
46
41
  "additionalProperties": false,
47
- "required": ["name"]
42
+ "required": ["path"]
48
43
  }
@@ -6,24 +6,19 @@
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
9
- "name": {
9
+ "path": {
10
10
  "type": "string",
11
- "description": "The name of the resource.",
11
+ "description": "Path where the resource will be generated.",
12
12
  "$default": {
13
13
  "$source": "argv",
14
14
  "index": 0
15
15
  },
16
- "x-prompt": "What name would you like to use for this resource (plural, e.g., `users`)?"
17
- },
18
- "nameAndDirectoryFormat": {
19
- "description": "Whether to generate the project name and root directory as provided (`as-provided`) or generate them composing their values and taking the configured layout into account (`derived`).",
20
- "type": "string",
21
- "enum": ["as-provided", "derived"]
16
+ "x-prompt": "Where should the resource be generated?"
22
17
  },
23
- "directory": {
24
- "description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
18
+ "name": {
25
19
  "type": "string",
26
- "aliases": ["dir", "path"]
20
+ "description": "The name of the resource.",
21
+ "x-prompt": "What name would you like to use for this resource (plural, e.g., `users`)?"
27
22
  },
28
23
  "skipFormat": {
29
24
  "description": "Skip formatting files.",
@@ -93,5 +88,5 @@
93
88
  }
94
89
  },
95
90
  "additionalProperties": false,
96
- "required": ["name"]
91
+ "required": ["path"]
97
92
  }
@@ -15,16 +15,6 @@
15
15
  },
16
16
  "x-prompt": "What name would you like to use?"
17
17
  },
18
- "nameAndDirectoryFormat": {
19
- "description": "Whether to generate the component in the directory as provided, relative to the current working directory and ignoring the project (`as-provided`) or generate it using the project and directory relative to the workspace root (`derived`).",
20
- "type": "string",
21
- "enum": ["as-provided", "derived"]
22
- },
23
- "directory": {
24
- "description": "Directory where the generated files are placed. when `--nameAndDirectoryFormat=as-provided`, it will be relative to the current working directory. otherwise, it will be relative to the workspace root.",
25
- "type": "string",
26
- "aliases": ["dir", "path"]
27
- },
28
18
  "skipFormat": {
29
19
  "description": "Skip formatting files.",
30
20
  "type": "boolean",
@@ -6,8 +6,7 @@ const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/a
6
6
  async function normalizeOptions(tree, options) {
7
7
  const { directory, fileName } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
8
8
  name: options.name,
9
- directory: options.directory,
10
- nameAndDirectoryFormat: options.nameAndDirectoryFormat,
9
+ path: options.path,
11
10
  });
12
11
  return {
13
12
  ...options,
@@ -1,13 +1,11 @@
1
- import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
2
1
  export type Language = 'js' | 'ts';
3
2
  export type UnitTestRunner = 'jest' | 'none';
4
3
  export type NestSchematic = 'class' | 'controller' | 'decorator' | 'filter' | 'gateway' | 'guard' | 'interceptor' | 'interface' | 'middleware' | 'module' | 'pipe' | 'provider' | 'resolver' | 'resource' | 'service';
5
4
  export type TransportLayer = 'rest' | 'graphql-code-first' | 'graphql-schema-first' | 'microservice' | 'ws';
6
5
  export type NestGeneratorOptions = {
7
- name: string;
8
- directory?: string;
6
+ path: string;
7
+ name?: string;
9
8
  skipFormat?: boolean;
10
- nameAndDirectoryFormat?: NameAndDirectoryFormat;
11
9
  };
12
10
  export type NestGeneratorWithLanguageOption = NestGeneratorOptions & {
13
11
  language?: Language;
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function replacePackage(tree: Tree): Promise<void>;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = replacePackage;
4
- const devkit_1 = require("@nx/devkit");
5
- const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
6
- async function replacePackage(tree) {
7
- await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/nest', '@nx/nest');
8
- await (0, devkit_1.formatFiles)(tree);
9
- }
@@ -1,5 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export declare function updateNestJs10(tree: Tree): Promise<import("@nx/devkit").GeneratorCallback>;
3
- export declare function updateCacheManagerImport(tree: Tree, filePath: string): boolean;
4
- export declare function updateTsConfigTarget(tree: Tree, tsConfigPath: string): void;
5
- export default updateNestJs10;
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateNestJs10 = updateNestJs10;
4
- exports.updateCacheManagerImport = updateCacheManagerImport;
5
- exports.updateTsConfigTarget = updateTsConfigTarget;
6
- const devkit_1 = require("@nx/devkit");
7
- const tsquery_1 = require("@phenomnomnominal/tsquery");
8
- const typescript_1 = require("typescript");
9
- const JS_TS_FILE_MATCHER = /\.[jt]sx?$/;
10
- const importMatch = ':matches(ImportDeclaration, VariableStatement):has(Identifier[name="CacheModule"], Identifier[name="CacheModule"]):has(StringLiteral[value="@nestjs/common"])';
11
- async function updateNestJs10(tree) {
12
- const nestProjects = await getNestProejcts();
13
- if (nestProjects.length === 0) {
14
- return;
15
- }
16
- let installCacheModuleDeps = false;
17
- const projects = (0, devkit_1.getProjects)(tree);
18
- for (const projectName of nestProjects) {
19
- const projectConfig = projects.get(projectName);
20
- const tsConfig = projectConfig.targets?.build?.options?.tsConfig ??
21
- (0, devkit_1.joinPathFragments)(projectConfig.root, projectConfig.projectType === 'application'
22
- ? 'tsconfig.app.json'
23
- : 'tsconfig.lib.json');
24
- if (tree.exists(tsConfig)) {
25
- updateTsConfigTarget(tree, tsConfig);
26
- }
27
- (0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.root, (filePath) => {
28
- if (!JS_TS_FILE_MATCHER.test(filePath)) {
29
- return;
30
- }
31
- installCacheModuleDeps =
32
- updateCacheManagerImport(tree, filePath) || installCacheModuleDeps;
33
- });
34
- }
35
- await (0, devkit_1.formatFiles)(tree);
36
- return installCacheModuleDeps
37
- ? (0, devkit_1.addDependenciesToPackageJson)(tree, {
38
- '@nestjs/cache-manager': '^2.0.0',
39
- 'cache-manager': '^5.2.3',
40
- }, {})
41
- : () => { };
42
- }
43
- async function getNestProejcts() {
44
- const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
45
- return Object.entries(projectGraph.dependencies)
46
- .filter(([node, dep]) => dep.some(({ target }) => !projectGraph.externalNodes?.[node] && target === 'npm:@nestjs/common'))
47
- .map(([projectName]) => projectName);
48
- }
49
- // change import { CacheModule } from '@nestjs/common';
50
- // to import { CacheModule } from '@nestjs/cache-manager';
51
- function updateCacheManagerImport(tree, filePath) {
52
- const content = tree.read(filePath, 'utf-8');
53
- const updated = tsquery_1.tsquery.replace(content, importMatch, (node) => {
54
- const text = node.getText();
55
- return `${text.replace('CacheModule', '')}\n${(0, typescript_1.isVariableStatement)(node)
56
- ? "const { CacheModule } = require('@nestjs/cache-manager')"
57
- : "import { CacheModule } from '@nestjs/cache-manager';"}`;
58
- });
59
- if (updated !== content) {
60
- tree.write(filePath, updated);
61
- return true;
62
- }
63
- }
64
- function updateTsConfigTarget(tree, tsConfigPath) {
65
- (0, devkit_1.updateJson)(tree, tsConfigPath, (json) => {
66
- if (!json.compilerOptions.target) {
67
- return json;
68
- }
69
- const normalizedTargetName = json.compilerOptions.target.toUpperCase();
70
- // es6 isn't apart of the ScriptTarget enum but is a valid tsconfig target in json file
71
- const existingTarget = normalizedTargetName === 'ES6'
72
- ? typescript_1.ScriptTarget.ES2015
73
- : typescript_1.ScriptTarget[normalizedTargetName];
74
- if (existingTarget < typescript_1.ScriptTarget.ES2021) {
75
- json.compilerOptions.target = 'es2021';
76
- }
77
- return json;
78
- });
79
- }
80
- exports.default = updateNestJs10;