@nx/nest 17.0.3 → 17.0.4

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 (39) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +9 -4
  3. package/package.json +6 -6
  4. package/src/generators/application/application.js +9 -2
  5. package/src/generators/application/lib/normalize-options.js +7 -1
  6. package/src/generators/application/schema.d.ts +1 -0
  7. package/src/generators/application/schema.json +1 -1
  8. package/src/generators/class/schema.json +3 -3
  9. package/src/generators/controller/schema.json +3 -3
  10. package/src/generators/decorator/schema.json +3 -3
  11. package/src/generators/filter/schema.json +3 -3
  12. package/src/generators/gateway/schema.json +3 -3
  13. package/src/generators/guard/schema.json +3 -3
  14. package/src/generators/init/init.d.ts +1 -1
  15. package/src/generators/init/init.js +4 -12
  16. package/src/generators/init/lib/add-dependencies.d.ts +2 -1
  17. package/src/generators/init/lib/add-dependencies.js +3 -11
  18. package/src/generators/init/lib/index.d.ts +0 -1
  19. package/src/generators/init/lib/index.js +0 -1
  20. package/src/generators/init/schema.d.ts +1 -1
  21. package/src/generators/init/schema.json +7 -8
  22. package/src/generators/interceptor/schema.json +3 -3
  23. package/src/generators/interface/schema.json +3 -3
  24. package/src/generators/library/lib/normalize-options.js +8 -1
  25. package/src/generators/library/library.js +21 -11
  26. package/src/generators/library/schema.d.ts +1 -0
  27. package/src/generators/library/schema.json +1 -1
  28. package/src/generators/middleware/schema.json +3 -3
  29. package/src/generators/module/schema.json +3 -3
  30. package/src/generators/pipe/schema.json +3 -3
  31. package/src/generators/provider/schema.json +3 -3
  32. package/src/generators/resolver/schema.json +3 -3
  33. package/src/generators/resource/schema.json +3 -3
  34. package/src/generators/service/schema.json +3 -3
  35. package/src/generators/utils/types.d.ts +2 -2
  36. package/src/utils/ensure-dependencies.d.ts +2 -0
  37. package/src/utils/ensure-dependencies.js +18 -0
  38. package/src/generators/init/lib/normalize-options.d.ts +0 -2
  39. package/src/generators/init/lib/normalize-options.js +0 -10
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2017-2023 Narwhal Technologies Inc.
3
+ Copyright (c) 2017-2024 Narwhal Technologies Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/README.md CHANGED
@@ -1,4 +1,9 @@
1
- <p style="text-align: center;"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx.png" width="600" alt="Nx - Smart, Fast and Extensible Build System"></p>
1
+ <p style="text-align: center;">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
4
+ <img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
5
+ </picture>
6
+ </p>
2
7
 
3
8
  <div style="text-align: center;">
4
9
 
@@ -15,9 +20,9 @@
15
20
 
16
21
  <hr>
17
22
 
18
- # Nx: Smart, Fast and Extensible Build System
23
+ # Nx: Smart Monorepos · Fast CI
19
24
 
20
- Nx is a next generation build system with first class monorepo support and powerful integrations.
25
+ Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
21
26
 
22
27
  This package is a [NestJS plugin for Nx](https://nx.dev/nest/overview).
23
28
 
@@ -59,5 +64,5 @@ npx nx@latest init
59
64
  - [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
60
65
 
61
66
  <p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
62
- width="100%" alt="Nx - Smart, Fast and Extensible Build System"></a></p>
67
+ width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
63
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/nest",
3
- "version": "17.0.3",
3
+ "version": "17.0.4",
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": {
@@ -31,13 +31,13 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@nestjs/schematics": "^9.1.0",
34
- "@nx/devkit": "17.0.3",
35
- "@nx/js": "17.0.3",
36
- "@nx/eslint": "17.0.3",
37
- "@nx/node": "17.0.3",
34
+ "@nx/devkit": "17.0.4",
35
+ "@nx/js": "17.0.4",
36
+ "@nx/eslint": "17.0.4",
37
+ "@nx/node": "17.0.4",
38
38
  "@phenomnomnominal/tsquery": "~5.0.1",
39
39
  "tslib": "^2.3.0",
40
- "@nrwl/nest": "17.0.3"
40
+ "@nrwl/nest": "17.0.4"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"
@@ -5,8 +5,10 @@ const devkit_1 = require("@nx/devkit");
5
5
  const node_1 = require("@nx/node");
6
6
  const init_1 = require("../init/init");
7
7
  const lib_1 = require("./lib");
8
+ const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
8
9
  async function applicationGenerator(tree, rawOptions) {
9
10
  return await applicationGeneratorInternal(tree, {
11
+ addPlugin: false,
10
12
  projectNameAndRootFormat: 'derived',
11
13
  ...rawOptions,
12
14
  });
@@ -14,18 +16,23 @@ async function applicationGenerator(tree, rawOptions) {
14
16
  exports.applicationGenerator = applicationGenerator;
15
17
  async function applicationGeneratorInternal(tree, rawOptions) {
16
18
  const options = await (0, lib_1.normalizeOptions)(tree, rawOptions);
19
+ const tasks = [];
17
20
  const initTask = await (0, init_1.initGenerator)(tree, {
18
21
  skipPackageJson: options.skipPackageJson,
19
- unitTestRunner: options.unitTestRunner,
20
22
  skipFormat: true,
21
23
  });
24
+ tasks.push(initTask);
22
25
  const nodeApplicationTask = await (0, node_1.applicationGenerator)(tree, (0, lib_1.toNodeApplicationGeneratorOptions)(options));
26
+ tasks.push(nodeApplicationTask);
23
27
  (0, lib_1.createFiles)(tree, options);
24
28
  (0, lib_1.updateTsConfig)(tree, options);
29
+ if (!options.skipPackageJson) {
30
+ tasks.push((0, ensure_dependencies_1.ensureDependencies)(tree));
31
+ }
25
32
  if (!options.skipFormat) {
26
33
  await (0, devkit_1.formatFiles)(tree);
27
34
  }
28
- return (0, devkit_1.runTasksInSerial)(initTask, nodeApplicationTask);
35
+ return (0, devkit_1.runTasksInSerial)(...tasks);
29
36
  }
30
37
  exports.applicationGeneratorInternal = applicationGeneratorInternal;
31
38
  exports.default = applicationGenerator;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toNodeApplicationGeneratorOptions = exports.normalizeOptions = void 0;
4
+ const devkit_1 = require("@nx/devkit");
4
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
5
6
  const eslint_1 = require("@nx/eslint");
6
7
  async function normalizeOptions(tree, options) {
@@ -14,7 +15,11 @@ async function normalizeOptions(tree, options) {
14
15
  });
15
16
  options.rootProject = appProjectRoot === '.';
16
17
  options.projectNameAndRootFormat = projectNameAndRootFormat;
18
+ const nxJson = (0, devkit_1.readNxJson)(tree);
19
+ const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
20
+ nxJson.useInferencePlugins !== false;
17
21
  return {
22
+ addPlugin,
18
23
  ...options,
19
24
  strict: options.strict ?? false,
20
25
  appProjectName,
@@ -40,8 +45,9 @@ function toNodeApplicationGeneratorOptions(options) {
40
45
  e2eTestRunner: options.e2eTestRunner,
41
46
  setParserOptionsProject: options.setParserOptionsProject,
42
47
  rootProject: options.rootProject,
43
- bundler: 'webpack',
48
+ bundler: 'webpack', // Some features require webpack plugins such as TS transformers
44
49
  isNest: true,
50
+ addPlugin: options.addPlugin,
45
51
  };
46
52
  }
47
53
  exports.toNodeApplicationGeneratorOptions = toNodeApplicationGeneratorOptions;
@@ -16,6 +16,7 @@ export interface ApplicationGeneratorOptions {
16
16
  setParserOptionsProject?: boolean;
17
17
  rootProject?: boolean;
18
18
  strict?: boolean;
19
+ addPlugin?: boolean;
19
20
  }
20
21
 
21
22
  interface NormalizedOptions extends ApplicationGeneratorOptions {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestApplicationGenerator",
4
4
  "title": "Nx Application Options Schema",
5
5
  "description": "Nx Application Options Schema.",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestClassGenerator",
4
4
  "title": "Nest Class Options Schema",
5
5
  "description": "Nest Class Options Schema.",
@@ -27,7 +27,7 @@
27
27
  "$source": "projectName"
28
28
  },
29
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 v18."
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 v19."
31
31
  },
32
32
  "directory": {
33
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.",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "flat": {
50
50
  "description": "Flag to indicate if a directory is created.",
51
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.",
51
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.",
52
52
  "type": "boolean",
53
53
  "default": true
54
54
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestControllerGenerator",
4
4
  "title": "Nest Controller Options Schema",
5
5
  "description": "Nest Controller Options Schema.",
@@ -22,7 +22,7 @@
22
22
  "$source": "projectName"
23
23
  },
24
24
  "alias": "p",
25
- "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 v18."
25
+ "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 v19."
26
26
  },
27
27
  "nameAndDirectoryFormat": {
28
28
  "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`).",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "flat": {
50
50
  "description": "Flag to indicate if a directory is created.",
51
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.",
51
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.",
52
52
  "type": "boolean",
53
53
  "default": false
54
54
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestDecoratorGenerator",
4
4
  "title": "Nest Decorator Options Schema",
5
5
  "description": "Nest Decorator Options Schema.",
@@ -27,7 +27,7 @@
27
27
  "$source": "projectName"
28
28
  },
29
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 v18."
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 v19."
31
31
  },
32
32
  "directory": {
33
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.",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "flat": {
44
44
  "description": "Flag to indicate if a directory is created.",
45
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.",
45
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.",
46
46
  "type": "boolean",
47
47
  "default": true
48
48
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestFilterGenerator",
4
4
  "title": "Nest Filter Options Schema",
5
5
  "description": "Nest Filter Options Schema.",
@@ -27,7 +27,7 @@
27
27
  "$source": "projectName"
28
28
  },
29
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 v18."
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 v19."
31
31
  },
32
32
  "directory": {
33
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.",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "flat": {
50
50
  "description": "Flag to indicate if a directory is created.",
51
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.",
51
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.",
52
52
  "type": "boolean",
53
53
  "default": true
54
54
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestGatewayGenerator",
4
4
  "title": "Nest Gateway Options Schema",
5
5
  "description": "Nest Gateway Options Schema.",
@@ -27,7 +27,7 @@
27
27
  "$source": "projectName"
28
28
  },
29
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 v18."
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 v19."
31
31
  },
32
32
  "directory": {
33
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.",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "flat": {
50
50
  "description": "Flag to indicate if a directory is created.",
51
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.",
51
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.",
52
52
  "type": "boolean",
53
53
  "default": true
54
54
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestGuardGenerator",
4
4
  "title": "Nest Guard Options Schema",
5
5
  "description": "Nest Guard Options Schema.",
@@ -27,7 +27,7 @@
27
27
  "$source": "projectName"
28
28
  },
29
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 v18."
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 v19."
31
31
  },
32
32
  "directory": {
33
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.",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "flat": {
50
50
  "description": "Flag to indicate if a directory is created.",
51
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.",
51
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.",
52
52
  "type": "boolean",
53
53
  "default": true
54
54
  },
@@ -1,4 +1,4 @@
1
1
  import type { GeneratorCallback, Tree } from '@nx/devkit';
2
2
  import type { InitGeneratorOptions } from './schema';
3
- export declare function initGenerator(tree: Tree, rawOptions: InitGeneratorOptions): Promise<GeneratorCallback>;
3
+ export declare function initGenerator(tree: Tree, options: InitGeneratorOptions): Promise<GeneratorCallback>;
4
4
  export default initGenerator;
@@ -2,24 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
- const node_1 = require("@nx/node");
6
5
  const lib_1 = require("./lib");
7
- async function initGenerator(tree, rawOptions) {
8
- const options = (0, lib_1.normalizeOptions)(rawOptions);
9
- const tasks = [];
10
- const nodeInitTask = await (0, node_1.initGenerator)(tree, {
11
- ...options,
12
- skipFormat: true,
13
- });
14
- tasks.push(nodeInitTask);
6
+ async function initGenerator(tree, options) {
7
+ let installPackagesTask = () => { };
15
8
  if (!options.skipPackageJson) {
16
- const installPackagesTask = (0, lib_1.addDependencies)(tree);
17
- tasks.push(installPackagesTask);
9
+ installPackagesTask = (0, lib_1.addDependencies)(tree, options);
18
10
  }
19
11
  if (!options.skipFormat) {
20
12
  await (0, devkit_1.formatFiles)(tree);
21
13
  }
22
- return (0, devkit_1.runTasksInSerial)(...tasks);
14
+ return installPackagesTask;
23
15
  }
24
16
  exports.initGenerator = initGenerator;
25
17
  exports.default = initGenerator;
@@ -1,2 +1,3 @@
1
1
  import type { GeneratorCallback, Tree } from '@nx/devkit';
2
- export declare function addDependencies(tree: Tree): GeneratorCallback;
2
+ import { InitGeneratorOptions } from '../schema';
3
+ export declare function addDependencies(tree: Tree, options: InitGeneratorOptions): GeneratorCallback;
@@ -3,18 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addDependencies = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const versions_1 = require("../../../utils/versions");
6
- function addDependencies(tree) {
7
- return (0, devkit_1.addDependenciesToPackageJson)(tree, {
8
- '@nestjs/common': versions_1.nestJsVersion,
9
- '@nestjs/core': versions_1.nestJsVersion,
10
- '@nestjs/platform-express': versions_1.nestJsVersion,
11
- 'reflect-metadata': versions_1.reflectMetadataVersion,
12
- rxjs: versions_1.rxjsVersion,
13
- tslib: versions_1.tsLibVersion,
14
- }, {
6
+ function addDependencies(tree, options) {
7
+ return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
15
8
  '@nestjs/schematics': versions_1.nestJsSchematicsVersion,
16
- '@nestjs/testing': versions_1.nestJsVersion,
17
9
  '@nx/nest': versions_1.nxVersion,
18
- });
10
+ }, undefined, options.keepExistingVersions);
19
11
  }
20
12
  exports.addDependencies = addDependencies;
@@ -1,2 +1 @@
1
1
  export * from './add-dependencies';
2
- export * from './normalize-options';
@@ -2,4 +2,3 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./add-dependencies"), exports);
5
- tslib_1.__exportStar(require("./normalize-options"), exports);
@@ -2,6 +2,6 @@ import { UnitTestRunner } from '../utils';
2
2
 
3
3
  export interface InitGeneratorOptions {
4
4
  skipFormat?: boolean;
5
- unitTestRunner?: UnitTestRunner;
6
5
  skipPackageJson?: boolean;
6
+ keepExistingVersions?: boolean;
7
7
  }
@@ -1,17 +1,11 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestInitGenerator",
4
4
  "title": "Init Nest Plugin",
5
5
  "description": "Init Nest Plugin.",
6
6
  "cli": "nx",
7
7
  "type": "object",
8
8
  "properties": {
9
- "unitTestRunner": {
10
- "description": "Adds the specified unit test runner.",
11
- "type": "string",
12
- "enum": ["jest", "none"],
13
- "default": "jest"
14
- },
15
9
  "skipFormat": {
16
10
  "description": "Skip formatting files.",
17
11
  "type": "boolean",
@@ -22,8 +16,13 @@
22
16
  "type": "boolean",
23
17
  "default": false,
24
18
  "x-priority": "internal"
19
+ },
20
+ "keepExistingVersions": {
21
+ "type": "boolean",
22
+ "x-priority": "internal",
23
+ "description": "Keep existing dependencies versions",
24
+ "default": false
25
25
  }
26
26
  },
27
- "additionalProperties": false,
28
27
  "required": []
29
28
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestInterceptorGenerator",
4
4
  "title": "Nest Interceptor Options Schema",
5
5
  "description": "Nest Interceptor Options Schema.",
@@ -27,7 +27,7 @@
27
27
  "$source": "projectName"
28
28
  },
29
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 v18."
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 v19."
31
31
  },
32
32
  "directory": {
33
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.",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "flat": {
50
50
  "description": "Flag to indicate if a directory is created.",
51
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.",
51
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.",
52
52
  "type": "boolean",
53
53
  "default": true
54
54
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestInterfaceGenerator",
4
4
  "title": "Nest Interface Options Schema",
5
5
  "description": "Nest Interface Options Schema.",
@@ -27,7 +27,7 @@
27
27
  "$source": "projectName"
28
28
  },
29
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 v18."
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 v19."
31
31
  },
32
32
  "directory": {
33
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.",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "flat": {
44
44
  "description": "Flag to indicate if a directory is created.",
45
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.",
45
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.",
46
46
  "type": "boolean",
47
47
  "default": true
48
48
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toJsLibraryGeneratorOptions = exports.normalizeOptions = void 0;
4
+ const devkit_1 = require("@nx/devkit");
4
5
  const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
5
6
  const get_npm_scope_1 = require("@nx/js/src/utils/package-json/get-npm-scope");
6
7
  const eslint_1 = require("@nx/eslint");
@@ -13,6 +14,10 @@ async function normalizeOptions(tree, options) {
13
14
  projectNameAndRootFormat: options.projectNameAndRootFormat,
14
15
  callingGenerator: '@nx/nest:library',
15
16
  });
17
+ const nxJson = (0, devkit_1.readNxJson)(tree);
18
+ const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
19
+ nxJson.useInferencePlugins !== false;
20
+ options.addPlugin ??= addPlugin;
16
21
  const fileName = options.simpleName
17
22
  ? projectNames.projectSimpleName
18
23
  : projectNames.projectFileName;
@@ -27,7 +32,7 @@ async function normalizeOptions(tree, options) {
27
32
  global: options.global ?? false,
28
33
  linter: options.linter ?? eslint_1.Linter.EsLint,
29
34
  parsedTags,
30
- prefix: (0, get_npm_scope_1.getNpmScope)(tree),
35
+ prefix: (0, get_npm_scope_1.getNpmScope)(tree), // we could also allow customizing this
31
36
  projectName,
32
37
  projectRoot,
33
38
  importPath,
@@ -49,6 +54,7 @@ function toJsLibraryGeneratorOptions(options) {
49
54
  publishable: options.publishable,
50
55
  skipFormat: true,
51
56
  skipTsConfig: options.skipTsConfig,
57
+ skipPackageJson: options.skipPackageJson,
52
58
  strict: options.strict,
53
59
  tags: options.tags,
54
60
  testEnvironment: options.testEnvironment,
@@ -56,6 +62,7 @@ function toJsLibraryGeneratorOptions(options) {
56
62
  config: options.standaloneConfig ? 'project' : 'workspace',
57
63
  setParserOptionsProject: options.setParserOptionsProject,
58
64
  projectNameAndRootFormat: options.projectNameAndRootFormat,
65
+ addPlugin: options.addPlugin,
59
66
  };
60
67
  }
61
68
  exports.toJsLibraryGeneratorOptions = toJsLibraryGeneratorOptions;
@@ -3,28 +3,38 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.libraryGeneratorInternal = exports.libraryGenerator = void 0;
4
4
  const devkit_1 = require("@nx/devkit");
5
5
  const js_1 = require("@nx/js");
6
- const lib_1 = require("../init/lib");
7
- const lib_2 = require("./lib");
6
+ const lib_1 = require("./lib");
7
+ const init_1 = require("../init/init");
8
+ const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
9
+ const ensure_dependencies_1 = require("../../utils/ensure-dependencies");
8
10
  async function libraryGenerator(tree, rawOptions) {
9
11
  return await libraryGeneratorInternal(tree, {
12
+ addPlugin: false,
10
13
  projectNameAndRootFormat: 'derived',
11
14
  ...rawOptions,
12
15
  });
13
16
  }
14
17
  exports.libraryGenerator = libraryGenerator;
15
18
  async function libraryGeneratorInternal(tree, rawOptions) {
16
- const options = await (0, lib_2.normalizeOptions)(tree, rawOptions);
17
- await (0, js_1.libraryGenerator)(tree, (0, lib_2.toJsLibraryGeneratorOptions)(options));
18
- const installDepsTask = (0, lib_1.addDependencies)(tree);
19
- (0, lib_2.deleteFiles)(tree, options);
20
- (0, lib_2.createFiles)(tree, options);
21
- (0, lib_2.addExportsToBarrelFile)(tree, options);
22
- (0, lib_2.updateTsConfig)(tree, options);
23
- (0, lib_2.addProject)(tree, options);
19
+ const options = await (0, lib_1.normalizeOptions)(tree, rawOptions);
20
+ await (0, js_1.libraryGenerator)(tree, (0, lib_1.toJsLibraryGeneratorOptions)(options));
21
+ const initTask = await (0, init_1.default)(tree, rawOptions);
22
+ const depsTask = (0, ensure_dependencies_1.ensureDependencies)(tree);
23
+ (0, lib_1.deleteFiles)(tree, options);
24
+ (0, lib_1.createFiles)(tree, options);
25
+ (0, lib_1.addExportsToBarrelFile)(tree, options);
26
+ (0, lib_1.updateTsConfig)(tree, options);
27
+ (0, lib_1.addProject)(tree, options);
24
28
  if (!options.skipFormat) {
25
29
  await (0, devkit_1.formatFiles)(tree);
26
30
  }
27
- return installDepsTask;
31
+ return (0, devkit_1.runTasksInSerial)(...[
32
+ initTask,
33
+ depsTask,
34
+ () => {
35
+ (0, log_show_project_command_1.logShowProjectCommand)(options.projectName);
36
+ },
37
+ ]);
28
38
  }
29
39
  exports.libraryGeneratorInternal = libraryGeneratorInternal;
30
40
  exports.default = libraryGenerator;
@@ -34,6 +34,7 @@ export interface LibraryGeneratorOptions {
34
34
  setParserOptionsProject?: boolean;
35
35
  skipPackageJson?: boolean;
36
36
  simpleName?: boolean;
37
+ addPlugin?: boolean;
37
38
  }
38
39
 
39
40
  export interface NormalizedOptions extends LibraryGeneratorOptions {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestLibraryGenerator",
4
4
  "title": "Create a NestJS Library for Nx",
5
5
  "description": "Create a NestJS Library for Nx.",
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestMiddlewareGenerator",
4
4
  "title": "Nest Middleware Options Schema",
5
5
  "description": "Nest Middleware Options Schema.",
@@ -27,7 +27,7 @@
27
27
  "$source": "projectName"
28
28
  },
29
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 v18."
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 v19."
31
31
  },
32
32
  "directory": {
33
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.",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "flat": {
50
50
  "description": "Flag to indicate if a directory is created.",
51
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.",
51
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.",
52
52
  "type": "boolean",
53
53
  "default": true
54
54
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestModuleGenerator",
4
4
  "title": "Nest Module Options Schema",
5
5
  "description": "Nest Module Options Schema.",
@@ -27,7 +27,7 @@
27
27
  "$source": "projectName"
28
28
  },
29
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 v18."
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 v19."
31
31
  },
32
32
  "directory": {
33
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.",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "flat": {
44
44
  "description": "Flag to indicate if a directory is created.",
45
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.",
45
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.",
46
46
  "type": "boolean",
47
47
  "default": false
48
48
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestPipeGenerator",
4
4
  "title": "Nest Pipe Options Schema",
5
5
  "description": "Nest Pipe Options Schema.",
@@ -27,7 +27,7 @@
27
27
  "$source": "projectName"
28
28
  },
29
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 v18."
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 v19."
31
31
  },
32
32
  "directory": {
33
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.",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "flat": {
50
50
  "description": "Flag to indicate if a directory is created.",
51
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.",
51
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.",
52
52
  "type": "boolean",
53
53
  "default": true
54
54
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestProviderGenerator",
4
4
  "title": "Nest Provider Options Schema",
5
5
  "description": "Nest Provider Options Schema.",
@@ -27,7 +27,7 @@
27
27
  "$source": "projectName"
28
28
  },
29
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 v18."
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 v19."
31
31
  },
32
32
  "directory": {
33
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.",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "flat": {
50
50
  "description": "Flag to indicate if a directory is created.",
51
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.",
51
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.",
52
52
  "type": "boolean",
53
53
  "default": true
54
54
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestResolverGenerator",
4
4
  "title": "Nest Resolver Options Schema",
5
5
  "description": "Nest Resolver Options Schema.",
@@ -22,7 +22,7 @@
22
22
  "$source": "projectName"
23
23
  },
24
24
  "alias": "p",
25
- "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 v18."
25
+ "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 v19."
26
26
  },
27
27
  "directory": {
28
28
  "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.",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "flat": {
45
45
  "description": "Flag to indicate if a directory is created.",
46
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.",
46
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.",
47
47
  "type": "boolean",
48
48
  "default": false
49
49
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestResourceGenerator",
4
4
  "title": "Nest Resource Options Schema",
5
5
  "description": "Nest Resource Options Schema.",
@@ -22,7 +22,7 @@
22
22
  "$source": "projectName"
23
23
  },
24
24
  "alias": "p",
25
- "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 v18."
25
+ "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 v19."
26
26
  },
27
27
  "directory": {
28
28
  "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.",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "flat": {
45
45
  "description": "Flag to indicate if a directory is created.",
46
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.",
46
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.",
47
47
  "type": "boolean",
48
48
  "default": false
49
49
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "http://json-schema.org/schema",
2
+ "$schema": "https://json-schema.org/schema",
3
3
  "$id": "NxNestServiceGenerator",
4
4
  "title": "Nest Service Options Schema",
5
5
  "description": "Nest Service Options Schema.",
@@ -27,7 +27,7 @@
27
27
  "$source": "projectName"
28
28
  },
29
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 v18."
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 v19."
31
31
  },
32
32
  "directory": {
33
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.",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "flat": {
50
50
  "description": "Flag to indicate if a directory is created.",
51
- "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.",
51
+ "x-deprecated": "Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.",
52
52
  "type": "boolean",
53
53
  "default": false
54
54
  },
@@ -9,11 +9,11 @@ export type NestGeneratorOptions = {
9
9
  skipFormat?: boolean;
10
10
  nameAndDirectoryFormat?: NameAndDirectoryFormat;
11
11
  /**
12
- * @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v18.
12
+ * @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.
13
13
  */
14
14
  flat?: boolean;
15
15
  /**
16
- * @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 v18.
16
+ * @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 v19.
17
17
  */
18
18
  project?: string;
19
19
  };
@@ -0,0 +1,2 @@
1
+ import type { GeneratorCallback, Tree } from '@nx/devkit';
2
+ export declare function ensureDependencies(tree: Tree): GeneratorCallback;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ensureDependencies = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const versions_1 = require("./versions");
6
+ function ensureDependencies(tree) {
7
+ return (0, devkit_1.addDependenciesToPackageJson)(tree, {
8
+ '@nestjs/common': versions_1.nestJsVersion,
9
+ '@nestjs/core': versions_1.nestJsVersion,
10
+ '@nestjs/platform-express': versions_1.nestJsVersion,
11
+ 'reflect-metadata': versions_1.reflectMetadataVersion,
12
+ rxjs: versions_1.rxjsVersion,
13
+ tslib: versions_1.tsLibVersion,
14
+ }, {
15
+ '@nestjs/testing': versions_1.nestJsVersion,
16
+ });
17
+ }
18
+ exports.ensureDependencies = ensureDependencies;
@@ -1,2 +0,0 @@
1
- import type { InitGeneratorOptions } from '../schema';
2
- export declare function normalizeOptions(options: InitGeneratorOptions): InitGeneratorOptions;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeOptions = void 0;
4
- function normalizeOptions(options) {
5
- return {
6
- ...options,
7
- unitTestRunner: options.unitTestRunner ?? 'jest',
8
- };
9
- }
10
- exports.normalizeOptions = normalizeOptions;