@nx/nest 20.2.1 → 20.3.0-beta.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 (32) hide show
  1. package/package.json +5 -5
  2. package/src/generators/class/schema.json +5 -1
  3. package/src/generators/controller/controller.js +3 -1
  4. package/src/generators/controller/schema.json +5 -1
  5. package/src/generators/decorator/decorator.js +3 -1
  6. package/src/generators/decorator/schema.json +5 -1
  7. package/src/generators/filter/filter.js +3 -1
  8. package/src/generators/filter/schema.json +5 -1
  9. package/src/generators/gateway/gateway.js +3 -1
  10. package/src/generators/gateway/schema.json +5 -1
  11. package/src/generators/guard/guard.js +3 -1
  12. package/src/generators/guard/schema.json +5 -1
  13. package/src/generators/interceptor/interceptor.js +3 -1
  14. package/src/generators/interceptor/schema.json +5 -1
  15. package/src/generators/interface/interface.js +5 -1
  16. package/src/generators/interface/schema.json +5 -1
  17. package/src/generators/middleware/middleware.js +3 -1
  18. package/src/generators/middleware/schema.json +5 -1
  19. package/src/generators/module/module.js +3 -1
  20. package/src/generators/module/schema.json +5 -1
  21. package/src/generators/pipe/pipe.js +3 -1
  22. package/src/generators/pipe/schema.json +5 -1
  23. package/src/generators/provider/schema.json +5 -1
  24. package/src/generators/resolver/resolver.js +3 -1
  25. package/src/generators/resolver/schema.json +5 -1
  26. package/src/generators/resource/resource.d.ts +2 -2
  27. package/src/generators/resource/resource.js +3 -2
  28. package/src/generators/resource/schema.json +1 -6
  29. package/src/generators/service/schema.json +5 -1
  30. package/src/generators/service/service.js +3 -1
  31. package/src/generators/utils/normalize-options.d.ts +6 -2
  32. package/src/generators/utils/normalize-options.js +17 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/nest",
3
- "version": "20.2.1",
3
+ "version": "20.3.0-beta.0",
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,10 +32,10 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@nestjs/schematics": "^9.1.0",
35
- "@nx/devkit": "20.2.1",
36
- "@nx/js": "20.2.1",
37
- "@nx/eslint": "20.2.1",
38
- "@nx/node": "20.2.1",
35
+ "@nx/devkit": "20.3.0-beta.0",
36
+ "@nx/js": "20.3.0-beta.0",
37
+ "@nx/eslint": "20.3.0-beta.0",
38
+ "@nx/node": "20.3.0-beta.0",
39
39
  "tslib": "^2.3.0"
40
40
  },
41
41
  "publishConfig": {
@@ -8,12 +8,16 @@
8
8
  "examples": [
9
9
  {
10
10
  "description": "Generate the class `Foo` at `myapp/src/app/foo.ts`",
11
+ "command": "nx g @nx/nest:class myapp/src/app/foo.ts"
12
+ },
13
+ {
14
+ "description": "Generate the class without providing the file extension. It results in the class `Foo` at `myapp/src/app/foo.ts`",
11
15
  "command": "nx g @nx/nest:class myapp/src/app/foo"
12
16
  }
13
17
  ],
14
18
  "properties": {
15
19
  "path": {
16
- "description": "The file path to the class without the file extension. Relative to the current working directory.",
20
+ "description": "The file path to the class. Relative to the current working directory.",
17
21
  "type": "string",
18
22
  "$default": {
19
23
  "$source": "argv",
@@ -8,7 +8,9 @@ async function controllerGenerator(tree, rawOptions) {
8
8
  }
9
9
  exports.default = controllerGenerator;
10
10
  async function normalizeControllerOptions(tree, options) {
11
- const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options);
11
+ const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options, {
12
+ suffix: 'controller',
13
+ });
12
14
  return {
13
15
  ...normalizedOptions,
14
16
  language: options.language,
@@ -8,12 +8,16 @@
8
8
  "examples": [
9
9
  {
10
10
  "description": "Generate the controller `FooController` at `myapp/src/app/foo.controller.ts`",
11
+ "command": "nx g @nx/nest:controller myapp/src/app/foo.controller.ts"
12
+ },
13
+ {
14
+ "description": "Generate the controller without providing the file extension. It results in the controller `FooController` at `myapp/src/app/foo.controller.ts`",
11
15
  "command": "nx g @nx/nest:controller myapp/src/app/foo"
12
16
  }
13
17
  ],
14
18
  "properties": {
15
19
  "path": {
16
- "description": "The file path to the controller without the file extension and suffix. Relative to the current working directory.",
20
+ "description": "The file path to the controller. Relative to the current working directory.",
17
21
  "type": "string",
18
22
  "$default": {
19
23
  "$source": "argv",
@@ -8,7 +8,9 @@ async function decoratorGenerator(tree, rawOptions) {
8
8
  }
9
9
  exports.default = decoratorGenerator;
10
10
  async function normalizeDecoratorOptions(tree, options) {
11
- const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options);
11
+ const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options, {
12
+ suffix: 'decorator',
13
+ });
12
14
  return {
13
15
  ...normalizedOptions,
14
16
  language: options.language,
@@ -8,12 +8,16 @@
8
8
  "examples": [
9
9
  {
10
10
  "description": "Generate the decorator `Foo` at `myapp/src/app/foo.decorator.ts`",
11
+ "command": "nx g @nx/nest:decorator myapp/src/app/foo.decorator.ts"
12
+ },
13
+ {
14
+ "description": "Generate the decorator without providing the file extension. It results in the decorator `Foo` at `myapp/src/app/foo.decorator.ts`",
11
15
  "command": "nx g @nx/nest:decorator myapp/src/app/foo"
12
16
  }
13
17
  ],
14
18
  "properties": {
15
19
  "path": {
16
- "description": "The file path to the decorator without the file extension and suffix. Relative to the current working directory.",
20
+ "description": "The file path to the decorator. Relative to the current working directory.",
17
21
  "type": "string",
18
22
  "$default": {
19
23
  "$source": "argv",
@@ -8,7 +8,9 @@ async function filterGenerator(tree, rawOptions) {
8
8
  }
9
9
  exports.default = filterGenerator;
10
10
  async function normalizeFilterOptions(tree, options) {
11
- const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options);
11
+ const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options, {
12
+ suffix: 'filter',
13
+ });
12
14
  return {
13
15
  ...normalizedOptions,
14
16
  language: options.language,
@@ -8,12 +8,16 @@
8
8
  "examples": [
9
9
  {
10
10
  "description": "Generate the filter `FooFilter` at `myapp/src/app/foo.filter.ts`",
11
+ "command": "nx g @nx/nest:filter myapp/src/app/foo.filter.ts"
12
+ },
13
+ {
14
+ "description": "Generate the filter without providing the file extension. It results in the filter `FooFilter` at `myapp/src/app/foo.filter.ts`",
11
15
  "command": "nx g @nx/nest:filter myapp/src/app/foo"
12
16
  }
13
17
  ],
14
18
  "properties": {
15
19
  "path": {
16
- "description": "The file path to the filter without the file extension and suffix. Relative to the current working directory.",
20
+ "description": "The file path to the filter. Relative to the current working directory.",
17
21
  "type": "string",
18
22
  "$default": {
19
23
  "$source": "argv",
@@ -8,7 +8,9 @@ async function gatewayGenerator(tree, rawOptions) {
8
8
  }
9
9
  exports.default = gatewayGenerator;
10
10
  async function normalizeGatewayOptions(tree, options) {
11
- const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options);
11
+ const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options, {
12
+ suffix: 'gateway',
13
+ });
12
14
  return {
13
15
  ...normalizedOptions,
14
16
  language: options.language,
@@ -8,12 +8,16 @@
8
8
  "examples": [
9
9
  {
10
10
  "description": "Generate the gateway `FooGateway` at `myapp/src/app/foo.gateway.ts`",
11
+ "command": "nx g @nx/nest:gateway myapp/src/app/foo.gateway.ts"
12
+ },
13
+ {
14
+ "description": "Generate the gateway without providing the file extension. It results in the gateway `FooGateway` at `myapp/src/app/foo.gateway.ts`",
11
15
  "command": "nx g @nx/nest:gateway myapp/src/app/foo"
12
16
  }
13
17
  ],
14
18
  "properties": {
15
19
  "path": {
16
- "description": "The file path to the gateway without the file extension and suffix. Relative to the current working directory.",
20
+ "description": "The file path to the gateway. Relative to the current working directory.",
17
21
  "type": "string",
18
22
  "$default": {
19
23
  "$source": "argv",
@@ -8,7 +8,9 @@ async function guardGenerator(tree, rawOptions) {
8
8
  }
9
9
  exports.default = guardGenerator;
10
10
  async function normalizeGuardOptions(tree, options) {
11
- const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options);
11
+ const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options, {
12
+ suffix: 'guard',
13
+ });
12
14
  return {
13
15
  ...normalizedOptions,
14
16
  language: options.language,
@@ -8,12 +8,16 @@
8
8
  "examples": [
9
9
  {
10
10
  "description": "Generate the guard `FooGuard` at `myapp/src/app/foo.guard.ts`",
11
+ "command": "nx g @nx/nest:guard myapp/src/app/foo.guard.ts"
12
+ },
13
+ {
14
+ "description": "Generate the guard without providing the file extension. It results in the guard `FooGuard` at `myapp/src/app/foo.guard.ts`",
11
15
  "command": "nx g @nx/nest:guard myapp/src/app/foo"
12
16
  }
13
17
  ],
14
18
  "properties": {
15
19
  "path": {
16
- "description": "The file path to the guard without the file extension and suffix. Relative to the current working directory.",
20
+ "description": "The file path to the guard. Relative to the current working directory.",
17
21
  "type": "string",
18
22
  "$default": {
19
23
  "$source": "argv",
@@ -8,7 +8,9 @@ async function interceptorGenerator(tree, rawOptions) {
8
8
  }
9
9
  exports.default = interceptorGenerator;
10
10
  async function normalizeInterceptorOptions(tree, options) {
11
- const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options);
11
+ const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options, {
12
+ suffix: 'interceptor',
13
+ });
12
14
  return {
13
15
  ...normalizedOptions,
14
16
  language: options.language,
@@ -8,12 +8,16 @@
8
8
  "examples": [
9
9
  {
10
10
  "description": "Generate the interceptor `FooInterceptor` at `myapp/src/app/foo.interceptor.ts`",
11
+ "command": "nx g @nx/nest:interceptor myapp/src/app/foo.interceptor.ts"
12
+ },
13
+ {
14
+ "description": "Generate the interceptor without providing the file extension. It results in the interceptor `FooInterceptor` at `myapp/src/app/foo.interceptor.ts`",
11
15
  "command": "nx g @nx/nest:interceptor myapp/src/app/foo"
12
16
  }
13
17
  ],
14
18
  "properties": {
15
19
  "path": {
16
- "description": "The file path to the interceptor without the file extension and suffix. Relative to the current working directory.",
20
+ "description": "The file path to the interceptor. Relative to the current working directory.",
17
21
  "type": "string",
18
22
  "$default": {
19
23
  "$source": "argv",
@@ -3,7 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.interfaceGenerator = interfaceGenerator;
4
4
  const utils_1 = require("../utils");
5
5
  async function interfaceGenerator(tree, rawOptions) {
6
- const options = await (0, utils_1.normalizeOptions)(tree, rawOptions);
6
+ const options = await (0, utils_1.normalizeOptions)(tree, rawOptions, {
7
+ allowedFileExtensions: ['ts'],
8
+ skipLanguageOption: true,
9
+ suffix: 'interface',
10
+ });
7
11
  return (0, utils_1.runNestSchematic)(tree, 'interface', options);
8
12
  }
9
13
  exports.default = interfaceGenerator;
@@ -8,12 +8,16 @@
8
8
  "examples": [
9
9
  {
10
10
  "description": "Generate the interface `Foo` at `myapp/src/app/foo.interface.ts`",
11
+ "command": "nx g @nx/nest:interface myapp/src/app/foo.interface.ts"
12
+ },
13
+ {
14
+ "description": "Generate the interface without providing the file extension. It results in the interface `Foo` at `myapp/src/app/foo.interface.ts`",
11
15
  "command": "nx g @nx/nest:interface myapp/src/app/foo"
12
16
  }
13
17
  ],
14
18
  "properties": {
15
19
  "path": {
16
- "description": "The file path to the interface without the file extension and suffix. Relative to the current working directory.",
20
+ "description": "The file path to the interface. Relative to the current working directory.",
17
21
  "type": "string",
18
22
  "$default": {
19
23
  "$source": "argv",
@@ -8,7 +8,9 @@ async function middlewareGenerator(tree, rawOptions) {
8
8
  }
9
9
  exports.default = middlewareGenerator;
10
10
  async function normalizeMiddlewareOptions(tree, options) {
11
- const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options);
11
+ const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options, {
12
+ suffix: 'middleware',
13
+ });
12
14
  return {
13
15
  ...normalizedOptions,
14
16
  language: options.language,
@@ -8,12 +8,16 @@
8
8
  "examples": [
9
9
  {
10
10
  "description": "Generate the middleware `FooMiddleware` at `myapp/src/app/foo.middleware.ts`",
11
+ "command": "nx g @nx/nest:middleware myapp/src/app/foo.middleware.ts"
12
+ },
13
+ {
14
+ "description": "Generate the middleware without providing the file extension. It results in the middleware `FooMiddleware` at `myapp/src/app/foo.middleware.ts`",
11
15
  "command": "nx g @nx/nest:middleware myapp/src/app/foo"
12
16
  }
13
17
  ],
14
18
  "properties": {
15
19
  "path": {
16
- "description": "The file path to the middleware without the file extension and suffix. Relative to the current working directory.",
20
+ "description": "The file path to the middleware. Relative to the current working directory.",
17
21
  "type": "string",
18
22
  "$default": {
19
23
  "$source": "argv",
@@ -8,7 +8,9 @@ async function moduleGenerator(tree, rawOptions) {
8
8
  }
9
9
  exports.default = moduleGenerator;
10
10
  async function normalizeModuleOptions(tree, options) {
11
- const normalizedOption = await (0, utils_1.normalizeOptions)(tree, options);
11
+ const normalizedOption = await (0, utils_1.normalizeOptions)(tree, options, {
12
+ suffix: 'module',
13
+ });
12
14
  return {
13
15
  ...normalizedOption,
14
16
  language: options.language,
@@ -8,12 +8,16 @@
8
8
  "examples": [
9
9
  {
10
10
  "description": "Generate the module `FooModule` at `myapp/src/app/foo.module.ts`",
11
+ "command": "nx g @nx/nest:module myapp/src/app/foo.module.ts"
12
+ },
13
+ {
14
+ "description": "Generate the module without providing the file extension. It results in the module `FooModule` at `myapp/src/app/foo.module.ts`",
11
15
  "command": "nx g @nx/nest:module myapp/src/app/foo"
12
16
  }
13
17
  ],
14
18
  "properties": {
15
19
  "path": {
16
- "description": "The file path to the module without the file extension and suffix. Relative to the current working directory.",
20
+ "description": "The file path to the module. Relative to the current working directory.",
17
21
  "type": "string",
18
22
  "$default": {
19
23
  "$source": "argv",
@@ -8,7 +8,9 @@ async function pipeGenerator(tree, rawOptions) {
8
8
  }
9
9
  exports.default = pipeGenerator;
10
10
  async function normalizePipeOptions(tree, options) {
11
- const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options);
11
+ const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options, {
12
+ suffix: 'pipe',
13
+ });
12
14
  return {
13
15
  ...normalizedOptions,
14
16
  language: options.language,
@@ -8,12 +8,16 @@
8
8
  "examples": [
9
9
  {
10
10
  "description": "Generate the pipe `FooPipe` at `myapp/src/app/foo.pipe.ts`",
11
+ "command": "nx g @nx/nest:pipe myapp/src/app/foo.pipe.ts"
12
+ },
13
+ {
14
+ "description": "Generate the pipe without providing the file extension. It results in the pipe `FooPipe` at `myapp/src/app/foo.pipe.ts`",
11
15
  "command": "nx g @nx/nest:pipe myapp/src/app/foo"
12
16
  }
13
17
  ],
14
18
  "properties": {
15
19
  "path": {
16
- "description": "The file path to the pipe without the file extension and suffix. Relative to the current working directory.",
20
+ "description": "The file path to the pipe. Relative to the current working directory.",
17
21
  "type": "string",
18
22
  "$default": {
19
23
  "$source": "argv",
@@ -8,12 +8,16 @@
8
8
  "examples": [
9
9
  {
10
10
  "description": "Generate the provider `Foo` at `myapp/src/app/foo.ts`",
11
+ "command": "nx g @nx/nest:provider myapp/src/app/foo.ts"
12
+ },
13
+ {
14
+ "description": "Generate the provider without providing the file extension. It results in the provider `Foo` at `myapp/src/app/foo.ts`",
11
15
  "command": "nx g @nx/nest:provider myapp/src/app/foo"
12
16
  }
13
17
  ],
14
18
  "properties": {
15
19
  "path": {
16
- "description": "The file path to the provider without the file extension and suffix. Relative to the current working directory.",
20
+ "description": "The file path to the provider. Relative to the current working directory.",
17
21
  "type": "string",
18
22
  "$default": {
19
23
  "$source": "argv",
@@ -8,7 +8,9 @@ async function resolverGenerator(tree, rawOptions) {
8
8
  }
9
9
  exports.default = resolverGenerator;
10
10
  async function normalizeResolverOptions(tree, options) {
11
- const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options);
11
+ const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options, {
12
+ suffix: 'resolver',
13
+ });
12
14
  return {
13
15
  ...normalizedOptions,
14
16
  language: options.language,
@@ -8,12 +8,16 @@
8
8
  "examples": [
9
9
  {
10
10
  "description": "Generate the resolver `FooResolver` at `myapp/src/app/foo.resolver.ts`",
11
+ "command": "nx g @nx/nest:resolver myapp/src/app/foo.resolver.ts"
12
+ },
13
+ {
14
+ "description": "Generate the resolver without providing the file extension. It results in the resolver `FooResolver` at `myapp/src/app/foo.resolver.ts`",
11
15
  "command": "nx g @nx/nest:resolver myapp/src/app/foo"
12
16
  }
13
17
  ],
14
18
  "properties": {
15
19
  "path": {
16
- "description": "The file path to the resolver without the file extension and suffix. Relative to the current working directory.",
20
+ "description": "The file path to the resolver. Relative to the current working directory.",
17
21
  "type": "string",
18
22
  "$default": {
19
23
  "$source": "argv",
@@ -1,5 +1,5 @@
1
1
  import type { Tree } from '@nx/devkit';
2
- import type { NestGeneratorWithLanguageOption, NestGeneratorWithResourceOption, NestGeneratorWithTestOption } from '../utils';
3
- export type ResourceGeneratorOptions = NestGeneratorWithLanguageOption & NestGeneratorWithTestOption & NestGeneratorWithResourceOption;
2
+ import type { NestGeneratorWithResourceOption, NestGeneratorWithTestOption } from '../utils';
3
+ export type ResourceGeneratorOptions = NestGeneratorWithTestOption & NestGeneratorWithResourceOption;
4
4
  export declare function resourceGenerator(tree: Tree, rawOptions: ResourceGeneratorOptions): Promise<any>;
5
5
  export default resourceGenerator;
@@ -8,10 +8,11 @@ async function resourceGenerator(tree, rawOptions) {
8
8
  }
9
9
  exports.default = resourceGenerator;
10
10
  async function normalizeResourceOptions(tree, options) {
11
- const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options);
11
+ const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options, {
12
+ skipLanguageOption: true,
13
+ });
12
14
  return {
13
15
  ...normalizedOptions,
14
- language: options.language,
15
16
  spec: (0, utils_1.unitTestRunnerToSpec)(options.unitTestRunner),
16
17
  };
17
18
  }
@@ -14,7 +14,7 @@
14
14
  "properties": {
15
15
  "path": {
16
16
  "type": "string",
17
- "description": "The file path to the resource without the file extension and suffix. Relative to the current working directory.",
17
+ "description": "The file path to the resource. Relative to the current working directory.",
18
18
  "$default": {
19
19
  "$source": "argv",
20
20
  "index": 0
@@ -33,11 +33,6 @@
33
33
  "enum": ["jest", "none"],
34
34
  "default": "jest"
35
35
  },
36
- "language": {
37
- "description": "Nest class language.",
38
- "type": "string",
39
- "enum": ["js", "ts"]
40
- },
41
36
  "type": {
42
37
  "type": "string",
43
38
  "description": "The transport layer.",
@@ -8,12 +8,16 @@
8
8
  "examples": [
9
9
  {
10
10
  "description": "Generate the service `FooService` at `myapp/src/app/foo.service.ts`",
11
+ "command": "nx g @nx/nest:service myapp/src/app/foo.service.ts"
12
+ },
13
+ {
14
+ "description": "Generate the service without providing the file extension. It results in the service `FooService` at `myapp/src/app/foo.service.ts`",
11
15
  "command": "nx g @nx/nest:service myapp/src/app/foo"
12
16
  }
13
17
  ],
14
18
  "properties": {
15
19
  "path": {
16
- "description": "The file path to the service without the file extension and suffix. Relative to the current working directory.",
20
+ "description": "The file path to the service. Relative to the current working directory.",
17
21
  "type": "string",
18
22
  "$default": {
19
23
  "$source": "argv",
@@ -8,7 +8,9 @@ async function serviceGenerator(tree, rawOptions) {
8
8
  }
9
9
  exports.default = serviceGenerator;
10
10
  async function normalizeServiceOptions(tree, options) {
11
- const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options);
11
+ const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, options, {
12
+ suffix: 'service',
13
+ });
12
14
  return {
13
15
  ...normalizedOptions,
14
16
  language: options.language,
@@ -1,4 +1,8 @@
1
1
  import type { Tree } from '@nx/devkit';
2
- import type { NestGeneratorOptions, NormalizedOptions, UnitTestRunner } from './types';
3
- export declare function normalizeOptions(tree: Tree, options: NestGeneratorOptions): Promise<NormalizedOptions>;
2
+ import type { NestGeneratorWithLanguageOption, NormalizedOptions, UnitTestRunner } from './types';
3
+ export declare function normalizeOptions(tree: Tree, options: NestGeneratorWithLanguageOption, normalizationOptions?: {
4
+ allowedFileExtensions?: Array<'js' | 'ts'>;
5
+ skipLanguageOption?: boolean;
6
+ suffix?: string;
7
+ }): Promise<NormalizedOptions>;
4
8
  export declare function unitTestRunnerToSpec(unitTestRunner: UnitTestRunner | undefined): boolean | undefined;
@@ -3,16 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeOptions = normalizeOptions;
4
4
  exports.unitTestRunnerToSpec = unitTestRunnerToSpec;
5
5
  const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
6
- async function normalizeOptions(tree, options) {
7
- const { directory, artifactName } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
6
+ async function normalizeOptions(tree, options, normalizationOptions = {}) {
7
+ const { allowedFileExtensions = ['js', 'ts'], skipLanguageOption = false, suffix, } = normalizationOptions;
8
+ const { directory, artifactName, fileExtension } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
8
9
  path: options.path,
10
+ allowedFileExtensions,
11
+ fileExtension: options.language === 'js' ? 'js' : 'ts',
12
+ js: options.language ? options.language === 'js' : undefined,
13
+ jsOptionName: 'language',
9
14
  });
10
15
  options.path = undefined; // Now that we have `directory` we don't need `path`
16
+ if (!skipLanguageOption) {
17
+ // we assign the language based on the normalized file extension
18
+ options.language = fileExtension;
19
+ }
20
+ let name = artifactName;
21
+ if (suffix && artifactName.endsWith(`.${suffix}`)) {
22
+ // strip the suffix if it exists, the nestjs schematic will always add it
23
+ name = artifactName.replace(`.${suffix}`, '');
24
+ }
11
25
  return {
12
26
  ...options,
13
27
  flat: true,
14
- name: artifactName,
15
- skipFormat: options.skipFormat,
28
+ name,
16
29
  sourceRoot: directory,
17
30
  };
18
31
  }