@nx/nest 0.0.0-pr-22179-271588f
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.
- package/LICENSE +22 -0
- package/README.md +68 -0
- package/generators.json +103 -0
- package/index.d.ts +18 -0
- package/index.js +39 -0
- package/migrations.json +76 -0
- package/package.json +46 -0
- package/src/generators/application/application.d.ts +5 -0
- package/src/generators/application/application.js +38 -0
- package/src/generators/application/files/app/app.controller.spec.ts__tmpl__ +22 -0
- package/src/generators/application/files/app/app.controller.ts__tmpl__ +13 -0
- package/src/generators/application/files/app/app.module.ts__tmpl__ +11 -0
- package/src/generators/application/files/app/app.service.spec.ts__tmpl__ +21 -0
- package/src/generators/application/files/app/app.service.ts__tmpl__ +8 -0
- package/src/generators/application/files/main.ts__tmpl__ +20 -0
- package/src/generators/application/lib/create-files.d.ts +3 -0
- package/src/generators/application/lib/create-files.js +12 -0
- package/src/generators/application/lib/index.d.ts +3 -0
- package/src/generators/application/lib/index.js +6 -0
- package/src/generators/application/lib/normalize-options.d.ts +5 -0
- package/src/generators/application/lib/normalize-options.js +53 -0
- package/src/generators/application/lib/update-tsconfig.d.ts +3 -0
- package/src/generators/application/lib/update-tsconfig.js +22 -0
- package/src/generators/application/schema.d.ts +25 -0
- package/src/generators/application/schema.json +86 -0
- package/src/generators/class/class.d.ts +6 -0
- package/src/generators/class/class.js +25 -0
- package/src/generators/class/schema.json +63 -0
- package/src/generators/controller/controller.d.ts +9 -0
- package/src/generators/controller/controller.js +27 -0
- package/src/generators/controller/schema.json +72 -0
- package/src/generators/decorator/decorator.d.ts +6 -0
- package/src/generators/decorator/decorator.js +24 -0
- package/src/generators/decorator/schema.json +57 -0
- package/src/generators/filter/filter.d.ts +6 -0
- package/src/generators/filter/filter.js +25 -0
- package/src/generators/filter/schema.json +63 -0
- package/src/generators/gateway/gateway.d.ts +6 -0
- package/src/generators/gateway/gateway.js +25 -0
- package/src/generators/gateway/schema.json +63 -0
- package/src/generators/guard/guard.d.ts +6 -0
- package/src/generators/guard/guard.js +25 -0
- package/src/generators/guard/schema.json +63 -0
- package/src/generators/init/init.d.ts +4 -0
- package/src/generators/init/init.js +17 -0
- package/src/generators/init/lib/add-dependencies.d.ts +3 -0
- package/src/generators/init/lib/add-dependencies.js +12 -0
- package/src/generators/init/lib/index.d.ts +1 -0
- package/src/generators/init/lib/index.js +4 -0
- package/src/generators/init/schema.d.ts +7 -0
- package/src/generators/init/schema.json +28 -0
- package/src/generators/interceptor/interceptor.d.ts +6 -0
- package/src/generators/interceptor/interceptor.js +25 -0
- package/src/generators/interceptor/schema.json +63 -0
- package/src/generators/interface/interface.d.ts +6 -0
- package/src/generators/interface/interface.js +17 -0
- package/src/generators/interface/schema.json +52 -0
- package/src/generators/library/files/common/src/lib/__fileName__.module.ts__tmpl__ +11 -0
- package/src/generators/library/files/controller/src/lib/__fileName__.controller.spec.ts__tmpl__ +20 -0
- package/src/generators/library/files/controller/src/lib/__fileName__.controller.ts__tmpl__ +7 -0
- package/src/generators/library/files/service/src/lib/__fileName__.service.spec.ts__tmpl__ +18 -0
- package/src/generators/library/files/service/src/lib/__fileName__.service.ts__tmpl__ +4 -0
- package/src/generators/library/lib/add-exports-to-barrel.d.ts +3 -0
- package/src/generators/library/lib/add-exports-to-barrel.js +25 -0
- package/src/generators/library/lib/add-project.d.ts +3 -0
- package/src/generators/library/lib/add-project.js +23 -0
- package/src/generators/library/lib/create-files.d.ts +3 -0
- package/src/generators/library/lib/create-files.js +27 -0
- package/src/generators/library/lib/delete-files.d.ts +3 -0
- package/src/generators/library/lib/delete-files.js +14 -0
- package/src/generators/library/lib/index.d.ts +6 -0
- package/src/generators/library/lib/index.js +9 -0
- package/src/generators/library/lib/normalize-options.d.ts +5 -0
- package/src/generators/library/lib/normalize-options.js +68 -0
- package/src/generators/library/lib/update-tsconfig.d.ts +3 -0
- package/src/generators/library/lib/update-tsconfig.js +22 -0
- package/src/generators/library/library.d.ts +5 -0
- package/src/generators/library/library.js +40 -0
- package/src/generators/library/schema.d.ts +46 -0
- package/src/generators/library/schema.json +147 -0
- package/src/generators/middleware/middleware.d.ts +6 -0
- package/src/generators/middleware/middleware.js +25 -0
- package/src/generators/middleware/schema.json +63 -0
- package/src/generators/module/module.d.ts +9 -0
- package/src/generators/module/module.js +26 -0
- package/src/generators/module/schema.json +67 -0
- package/src/generators/pipe/pipe.d.ts +6 -0
- package/src/generators/pipe/pipe.js +25 -0
- package/src/generators/pipe/schema.json +63 -0
- package/src/generators/provider/provider.d.ts +6 -0
- package/src/generators/provider/provider.js +25 -0
- package/src/generators/provider/schema.json +63 -0
- package/src/generators/resolver/resolver.d.ts +6 -0
- package/src/generators/resolver/resolver.js +25 -0
- package/src/generators/resolver/schema.json +58 -0
- package/src/generators/resource/resource.d.ts +6 -0
- package/src/generators/resource/resource.js +25 -0
- package/src/generators/resource/schema.json +107 -0
- package/src/generators/service/schema.json +63 -0
- package/src/generators/service/service.d.ts +6 -0
- package/src/generators/service/service.js +25 -0
- package/src/generators/utils/index.d.ts +3 -0
- package/src/generators/utils/index.js +6 -0
- package/src/generators/utils/normalize-options.d.ts +4 -0
- package/src/generators/utils/normalize-options.js +28 -0
- package/src/generators/utils/run-nest-schematic.d.ts +3 -0
- package/src/generators/utils/run-nest-schematic.js +15 -0
- package/src/generators/utils/testing.d.ts +2 -0
- package/src/generators/utils/testing.js +16 -0
- package/src/generators/utils/types.d.ts +40 -0
- package/src/generators/utils/types.js +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
- package/src/migrations/update-16-4-0-cache-manager/nestjs-10-updates.d.ts +5 -0
- package/src/migrations/update-16-4-0-cache-manager/nestjs-10-updates.js +81 -0
- package/src/utils/ensure-dependencies.d.ts +2 -0
- package/src/utils/ensure-dependencies.js +18 -0
- package/src/utils/versions.d.ts +6 -0
- package/src/utils/versions.js +9 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "NxNestResolverGenerator",
|
|
4
|
+
"title": "Nest Resolver Options Schema",
|
|
5
|
+
"description": "Nest Resolver Options Schema.",
|
|
6
|
+
"cli": "nx",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"description": "The name of the resolver.",
|
|
11
|
+
"type": "string",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "argv",
|
|
14
|
+
"index": 0
|
|
15
|
+
},
|
|
16
|
+
"x-prompt": "What name would you like to use?"
|
|
17
|
+
},
|
|
18
|
+
"project": {
|
|
19
|
+
"description": "The Nest project to target.",
|
|
20
|
+
"type": "string",
|
|
21
|
+
"$default": {
|
|
22
|
+
"$source": "projectName"
|
|
23
|
+
},
|
|
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 v19."
|
|
26
|
+
},
|
|
27
|
+
"directory": {
|
|
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.",
|
|
29
|
+
"type": "string",
|
|
30
|
+
"aliases": ["dir", "path"]
|
|
31
|
+
},
|
|
32
|
+
"skipFormat": {
|
|
33
|
+
"description": "Skip formatting files.",
|
|
34
|
+
"type": "boolean",
|
|
35
|
+
"default": false,
|
|
36
|
+
"x-priority": "internal"
|
|
37
|
+
},
|
|
38
|
+
"unitTestRunner": {
|
|
39
|
+
"description": "Test runner to use for unit tests.",
|
|
40
|
+
"type": "string",
|
|
41
|
+
"enum": ["jest", "none"],
|
|
42
|
+
"default": "jest"
|
|
43
|
+
},
|
|
44
|
+
"flat": {
|
|
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 v19.",
|
|
47
|
+
"type": "boolean",
|
|
48
|
+
"default": false
|
|
49
|
+
},
|
|
50
|
+
"language": {
|
|
51
|
+
"description": "Nest resolver language.",
|
|
52
|
+
"type": "string",
|
|
53
|
+
"enum": ["js", "ts"]
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"additionalProperties": false,
|
|
57
|
+
"required": ["name"]
|
|
58
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Tree } from '@nx/devkit';
|
|
2
|
+
import type { NestGeneratorWithLanguageOption, NestGeneratorWithResourceOption, NestGeneratorWithTestOption } from '../utils';
|
|
3
|
+
export type ResourceGeneratorOptions = NestGeneratorWithLanguageOption & NestGeneratorWithTestOption & NestGeneratorWithResourceOption;
|
|
4
|
+
export declare function resourceGenerator(tree: Tree, rawOptions: ResourceGeneratorOptions): Promise<void>;
|
|
5
|
+
export declare function resourceGeneratorInternal(tree: Tree, rawOptions: ResourceGeneratorOptions): Promise<any>;
|
|
6
|
+
export default resourceGenerator;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resourceGeneratorInternal = exports.resourceGenerator = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
async function resourceGenerator(tree, rawOptions) {
|
|
6
|
+
await resourceGeneratorInternal(tree, {
|
|
7
|
+
nameAndDirectoryFormat: 'derived',
|
|
8
|
+
...rawOptions,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.resourceGenerator = resourceGenerator;
|
|
12
|
+
async function resourceGeneratorInternal(tree, rawOptions) {
|
|
13
|
+
const options = await normalizeResourceOptions(tree, rawOptions);
|
|
14
|
+
return (0, utils_1.runNestSchematic)(tree, 'resource', options);
|
|
15
|
+
}
|
|
16
|
+
exports.resourceGeneratorInternal = resourceGeneratorInternal;
|
|
17
|
+
exports.default = resourceGenerator;
|
|
18
|
+
async function normalizeResourceOptions(tree, options) {
|
|
19
|
+
const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, 'resource', '@nx/nest:resource', options);
|
|
20
|
+
return {
|
|
21
|
+
...normalizedOptions,
|
|
22
|
+
language: options.language,
|
|
23
|
+
spec: (0, utils_1.unitTestRunnerToSpec)(options.unitTestRunner),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "NxNestResourceGenerator",
|
|
4
|
+
"title": "Nest Resource Options Schema",
|
|
5
|
+
"description": "Nest Resource Options Schema.",
|
|
6
|
+
"cli": "nx",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The name of the resource.",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "argv",
|
|
14
|
+
"index": 0
|
|
15
|
+
},
|
|
16
|
+
"x-prompt": "What name would you like to use for this resource (plural, e.g., `users`)?"
|
|
17
|
+
},
|
|
18
|
+
"project": {
|
|
19
|
+
"description": "The Nest project to target.",
|
|
20
|
+
"type": "string",
|
|
21
|
+
"$default": {
|
|
22
|
+
"$source": "projectName"
|
|
23
|
+
},
|
|
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 v19."
|
|
26
|
+
},
|
|
27
|
+
"directory": {
|
|
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.",
|
|
29
|
+
"type": "string",
|
|
30
|
+
"aliases": ["dir", "path"]
|
|
31
|
+
},
|
|
32
|
+
"skipFormat": {
|
|
33
|
+
"description": "Skip formatting files.",
|
|
34
|
+
"type": "boolean",
|
|
35
|
+
"default": false,
|
|
36
|
+
"x-priority": "internal"
|
|
37
|
+
},
|
|
38
|
+
"unitTestRunner": {
|
|
39
|
+
"description": "Test runner to use for unit tests.",
|
|
40
|
+
"type": "string",
|
|
41
|
+
"enum": ["jest", "none"],
|
|
42
|
+
"default": "jest"
|
|
43
|
+
},
|
|
44
|
+
"flat": {
|
|
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 v19.",
|
|
47
|
+
"type": "boolean",
|
|
48
|
+
"default": false
|
|
49
|
+
},
|
|
50
|
+
"language": {
|
|
51
|
+
"description": "Nest class language.",
|
|
52
|
+
"type": "string",
|
|
53
|
+
"enum": ["js", "ts"]
|
|
54
|
+
},
|
|
55
|
+
"type": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"description": "The transport layer.",
|
|
58
|
+
"default": "rest",
|
|
59
|
+
"enum": [
|
|
60
|
+
"rest",
|
|
61
|
+
"graphql-code-first",
|
|
62
|
+
"graphql-schema-first",
|
|
63
|
+
"microservice",
|
|
64
|
+
"ws"
|
|
65
|
+
],
|
|
66
|
+
"x-prompt": {
|
|
67
|
+
"message": "What transport layer do you use?",
|
|
68
|
+
"type": "list",
|
|
69
|
+
"items": [
|
|
70
|
+
{ "value": "rest", "label": "REST API" },
|
|
71
|
+
{
|
|
72
|
+
"value": "graphql-code-first",
|
|
73
|
+
"label": "GraphQL (code first)"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"value": "graphql-schema-first",
|
|
77
|
+
"label": "GraphQL (schema first)"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"value": "microservice",
|
|
81
|
+
"label": "Microservice (non-HTTP)"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"value": "ws",
|
|
85
|
+
"label": "WebSockets"
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"skipImport": {
|
|
91
|
+
"type": "boolean",
|
|
92
|
+
"description": "Flag to skip the module import.",
|
|
93
|
+
"default": false
|
|
94
|
+
},
|
|
95
|
+
"crud": {
|
|
96
|
+
"type": "boolean",
|
|
97
|
+
"description": "When true, CRUD entry points are generated.",
|
|
98
|
+
"default": true,
|
|
99
|
+
"x-prompt": {
|
|
100
|
+
"message": "Would you like to generate CRUD entry points?",
|
|
101
|
+
"type": "confirmation"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"additionalProperties": false,
|
|
106
|
+
"required": ["name"]
|
|
107
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "NxNestServiceGenerator",
|
|
4
|
+
"title": "Nest Service Options Schema",
|
|
5
|
+
"description": "Nest Service Options Schema.",
|
|
6
|
+
"cli": "nx",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"description": "The name of the service.",
|
|
11
|
+
"type": "string",
|
|
12
|
+
"$default": {
|
|
13
|
+
"$source": "argv",
|
|
14
|
+
"index": 0
|
|
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 v19."
|
|
31
|
+
},
|
|
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.",
|
|
34
|
+
"type": "string",
|
|
35
|
+
"aliases": ["dir", "path"]
|
|
36
|
+
},
|
|
37
|
+
"skipFormat": {
|
|
38
|
+
"description": "Skip formatting files.",
|
|
39
|
+
"type": "boolean",
|
|
40
|
+
"default": false,
|
|
41
|
+
"x-priority": "internal"
|
|
42
|
+
},
|
|
43
|
+
"unitTestRunner": {
|
|
44
|
+
"description": "Test runner to use for unit tests.",
|
|
45
|
+
"type": "string",
|
|
46
|
+
"enum": ["jest", "none"],
|
|
47
|
+
"default": "jest"
|
|
48
|
+
},
|
|
49
|
+
"flat": {
|
|
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 v19.",
|
|
52
|
+
"type": "boolean",
|
|
53
|
+
"default": false
|
|
54
|
+
},
|
|
55
|
+
"language": {
|
|
56
|
+
"description": "Nest service language.",
|
|
57
|
+
"type": "string",
|
|
58
|
+
"enum": ["js", "ts"]
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"additionalProperties": false,
|
|
62
|
+
"required": ["name"]
|
|
63
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Tree } from '@nx/devkit';
|
|
2
|
+
import type { NestGeneratorWithLanguageOption, NestGeneratorWithTestOption } from '../utils';
|
|
3
|
+
export type ServiceGeneratorOptions = NestGeneratorWithLanguageOption & NestGeneratorWithTestOption;
|
|
4
|
+
export declare function serviceGenerator(tree: Tree, rawOptions: ServiceGeneratorOptions): Promise<void>;
|
|
5
|
+
export declare function serviceGeneratorInternal(tree: Tree, rawOptions: ServiceGeneratorOptions): Promise<any>;
|
|
6
|
+
export default serviceGenerator;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serviceGeneratorInternal = exports.serviceGenerator = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
async function serviceGenerator(tree, rawOptions) {
|
|
6
|
+
await serviceGeneratorInternal(tree, {
|
|
7
|
+
nameAndDirectoryFormat: 'derived',
|
|
8
|
+
...rawOptions,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.serviceGenerator = serviceGenerator;
|
|
12
|
+
async function serviceGeneratorInternal(tree, rawOptions) {
|
|
13
|
+
const options = await normalizeServiceOptions(tree, rawOptions);
|
|
14
|
+
return (0, utils_1.runNestSchematic)(tree, 'service', options);
|
|
15
|
+
}
|
|
16
|
+
exports.serviceGeneratorInternal = serviceGeneratorInternal;
|
|
17
|
+
exports.default = serviceGenerator;
|
|
18
|
+
async function normalizeServiceOptions(tree, options) {
|
|
19
|
+
const normalizedOptions = await (0, utils_1.normalizeOptions)(tree, 'service', '@nx/nest:service', options);
|
|
20
|
+
return {
|
|
21
|
+
...normalizedOptions,
|
|
22
|
+
language: options.language,
|
|
23
|
+
spec: (0, utils_1.unitTestRunnerToSpec)(options.unitTestRunner),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./normalize-options"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./run-nest-schematic"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Tree } from '@nx/devkit';
|
|
2
|
+
import type { NestGeneratorOptions, NormalizedOptions, UnitTestRunner } from './types';
|
|
3
|
+
export declare function normalizeOptions(tree: Tree, artifactType: string, callingGenerator: string, options: NestGeneratorOptions): Promise<NormalizedOptions>;
|
|
4
|
+
export declare function unitTestRunnerToSpec(unitTestRunner: UnitTestRunner | undefined): boolean | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.unitTestRunnerToSpec = exports.normalizeOptions = void 0;
|
|
4
|
+
const artifact_name_and_directory_utils_1 = require("@nx/devkit/src/generators/artifact-name-and-directory-utils");
|
|
5
|
+
async function normalizeOptions(tree, artifactType, callingGenerator, options) {
|
|
6
|
+
const { directory, fileName } = await (0, artifact_name_and_directory_utils_1.determineArtifactNameAndDirectoryOptions)(tree, {
|
|
7
|
+
callingGenerator,
|
|
8
|
+
artifactType,
|
|
9
|
+
name: options.name,
|
|
10
|
+
directory: options.directory,
|
|
11
|
+
project: options.project,
|
|
12
|
+
flat: options.flat,
|
|
13
|
+
derivedDirectory: options.directory,
|
|
14
|
+
nameAndDirectoryFormat: options.nameAndDirectoryFormat,
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
...options,
|
|
18
|
+
flat: true,
|
|
19
|
+
name: fileName,
|
|
20
|
+
skipFormat: options.skipFormat,
|
|
21
|
+
sourceRoot: directory,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.normalizeOptions = normalizeOptions;
|
|
25
|
+
function unitTestRunnerToSpec(unitTestRunner) {
|
|
26
|
+
return unitTestRunner !== undefined ? unitTestRunner === 'jest' : undefined;
|
|
27
|
+
}
|
|
28
|
+
exports.unitTestRunnerToSpec = unitTestRunnerToSpec;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runNestSchematic = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
async function runNestSchematic(tree, schematic, options) {
|
|
6
|
+
const { skipFormat, ...schematicOptions } = options;
|
|
7
|
+
const { wrapAngularDevkitSchematic } = require('@nx/devkit/ngcli-adapter');
|
|
8
|
+
const nestSchematic = wrapAngularDevkitSchematic('@nestjs/schematics', schematic);
|
|
9
|
+
const result = await nestSchematic(tree, schematicOptions);
|
|
10
|
+
if (!skipFormat) {
|
|
11
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
exports.runNestSchematic = runNestSchematic;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTreeWithNestApplication = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const testing_1 = require("@nx/devkit/testing");
|
|
6
|
+
function createTreeWithNestApplication(appName) {
|
|
7
|
+
const tree = (0, testing_1.createTreeWithEmptyWorkspace)();
|
|
8
|
+
(0, devkit_1.addProjectConfiguration)(tree, appName, {
|
|
9
|
+
root: `${appName}`,
|
|
10
|
+
sourceRoot: `${appName}/src`,
|
|
11
|
+
projectType: 'application',
|
|
12
|
+
targets: {},
|
|
13
|
+
});
|
|
14
|
+
return tree;
|
|
15
|
+
}
|
|
16
|
+
exports.createTreeWithNestApplication = createTreeWithNestApplication;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { NameAndDirectoryFormat } from '@nx/devkit/src/generators/artifact-name-and-directory-utils';
|
|
2
|
+
export type Language = 'js' | 'ts';
|
|
3
|
+
export type UnitTestRunner = 'jest' | 'none';
|
|
4
|
+
export type NestSchematic = 'class' | 'controller' | 'decorator' | 'filter' | 'gateway' | 'guard' | 'interceptor' | 'interface' | 'middleware' | 'module' | 'pipe' | 'provider' | 'resolver' | 'resource' | 'service';
|
|
5
|
+
export type TransportLayer = 'rest' | 'graphql-code-first' | 'graphql-schema-first' | 'microservice' | 'ws';
|
|
6
|
+
export type NestGeneratorOptions = {
|
|
7
|
+
name: string;
|
|
8
|
+
directory?: string;
|
|
9
|
+
skipFormat?: boolean;
|
|
10
|
+
nameAndDirectoryFormat?: NameAndDirectoryFormat;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Provide the `directory` option instead and use the `as-provided` format. It will be removed in Nx v19.
|
|
13
|
+
*/
|
|
14
|
+
flat?: boolean;
|
|
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 v19.
|
|
17
|
+
*/
|
|
18
|
+
project?: string;
|
|
19
|
+
};
|
|
20
|
+
export type NestGeneratorWithLanguageOption = NestGeneratorOptions & {
|
|
21
|
+
language?: Language;
|
|
22
|
+
};
|
|
23
|
+
export type NestGeneratorWithTestOption = NestGeneratorOptions & {
|
|
24
|
+
unitTestRunner?: UnitTestRunner;
|
|
25
|
+
};
|
|
26
|
+
export type NestGeneratorWithResourceOption = NestGeneratorOptions & {
|
|
27
|
+
type?: TransportLayer;
|
|
28
|
+
crud?: boolean;
|
|
29
|
+
};
|
|
30
|
+
export type NormalizedOptions = {
|
|
31
|
+
name: string;
|
|
32
|
+
sourceRoot: string;
|
|
33
|
+
flat?: boolean;
|
|
34
|
+
language?: 'js' | 'ts';
|
|
35
|
+
module?: string;
|
|
36
|
+
path?: string;
|
|
37
|
+
skipFormat?: boolean;
|
|
38
|
+
skipImport?: boolean;
|
|
39
|
+
spec?: boolean;
|
|
40
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const devkit_1 = require("@nx/devkit");
|
|
4
|
+
const replace_package_1 = require("@nx/devkit/src/utils/replace-package");
|
|
5
|
+
async function replacePackage(tree) {
|
|
6
|
+
await (0, replace_package_1.replaceNrwlPackageWithNxPackage)(tree, '@nrwl/nest', '@nx/nest');
|
|
7
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
8
|
+
}
|
|
9
|
+
exports.default = replacePackage;
|
|
@@ -0,0 +1,5 @@
|
|
|
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;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateTsConfigTarget = exports.updateCacheManagerImport = exports.updateNestJs10 = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const tsquery_1 = require("@phenomnomnominal/tsquery");
|
|
6
|
+
const typescript_1 = require("typescript");
|
|
7
|
+
const JS_TS_FILE_MATCHER = /\.[jt]sx?$/;
|
|
8
|
+
const importMatch = ':matches(ImportDeclaration, VariableStatement):has(Identifier[name="CacheModule"], Identifier[name="CacheModule"]):has(StringLiteral[value="@nestjs/common"])';
|
|
9
|
+
async function updateNestJs10(tree) {
|
|
10
|
+
const nestProjects = await getNestProejcts();
|
|
11
|
+
if (nestProjects.length === 0) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
let installCacheModuleDeps = false;
|
|
15
|
+
const projects = (0, devkit_1.getProjects)(tree);
|
|
16
|
+
for (const projectName of nestProjects) {
|
|
17
|
+
const projectConfig = projects.get(projectName);
|
|
18
|
+
const tsConfig = projectConfig.targets?.build?.options?.tsConfig ??
|
|
19
|
+
(0, devkit_1.joinPathFragments)(projectConfig.root, projectConfig.projectType === 'application'
|
|
20
|
+
? 'tsconfig.app.json'
|
|
21
|
+
: 'tsconfig.lib.json');
|
|
22
|
+
if (tree.exists(tsConfig)) {
|
|
23
|
+
updateTsConfigTarget(tree, tsConfig);
|
|
24
|
+
}
|
|
25
|
+
(0, devkit_1.visitNotIgnoredFiles)(tree, projectConfig.root, (filePath) => {
|
|
26
|
+
if (!JS_TS_FILE_MATCHER.test(filePath)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
installCacheModuleDeps =
|
|
30
|
+
updateCacheManagerImport(tree, filePath) || installCacheModuleDeps;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
34
|
+
return installCacheModuleDeps
|
|
35
|
+
? (0, devkit_1.addDependenciesToPackageJson)(tree, {
|
|
36
|
+
'@nestjs/cache-manager': '^2.0.0',
|
|
37
|
+
'cache-manager': '^5.2.3',
|
|
38
|
+
}, {})
|
|
39
|
+
: () => { };
|
|
40
|
+
}
|
|
41
|
+
exports.updateNestJs10 = updateNestJs10;
|
|
42
|
+
async function getNestProejcts() {
|
|
43
|
+
const projectGraph = await (0, devkit_1.createProjectGraphAsync)();
|
|
44
|
+
return Object.entries(projectGraph.dependencies)
|
|
45
|
+
.filter(([node, dep]) => dep.some(({ target }) => !projectGraph.externalNodes?.[node] && target === 'npm:@nestjs/common'))
|
|
46
|
+
.map(([projectName]) => projectName);
|
|
47
|
+
}
|
|
48
|
+
// change import { CacheModule } from '@nestjs/common';
|
|
49
|
+
// to import { CacheModule } from '@nestjs/cache-manager';
|
|
50
|
+
function updateCacheManagerImport(tree, filePath) {
|
|
51
|
+
const content = tree.read(filePath, 'utf-8');
|
|
52
|
+
const updated = tsquery_1.tsquery.replace(content, importMatch, (node) => {
|
|
53
|
+
const text = node.getText();
|
|
54
|
+
return `${text.replace('CacheModule', '')}\n${(0, typescript_1.isVariableStatement)(node)
|
|
55
|
+
? "const { CacheModule } = require('@nestjs/cache-manager')"
|
|
56
|
+
: "import { CacheModule } from '@nestjs/cache-manager';"}`;
|
|
57
|
+
});
|
|
58
|
+
if (updated !== content) {
|
|
59
|
+
tree.write(filePath, updated);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.updateCacheManagerImport = updateCacheManagerImport;
|
|
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.updateTsConfigTarget = updateTsConfigTarget;
|
|
81
|
+
exports.default = updateNestJs10;
|
|
@@ -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;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const nxVersion: any;
|
|
2
|
+
export declare const nestJsVersion = "^10.0.2";
|
|
3
|
+
export declare const nestJsSchematicsVersion = "^10.0.1";
|
|
4
|
+
export declare const rxjsVersion = "^7.8.0";
|
|
5
|
+
export declare const reflectMetadataVersion = "^0.1.13";
|
|
6
|
+
export declare const tsLibVersion = "^2.3.0";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tsLibVersion = exports.reflectMetadataVersion = exports.rxjsVersion = exports.nestJsSchematicsVersion = exports.nestJsVersion = exports.nxVersion = void 0;
|
|
4
|
+
exports.nxVersion = require('../../package.json').version;
|
|
5
|
+
exports.nestJsVersion = '^10.0.2';
|
|
6
|
+
exports.nestJsSchematicsVersion = '^10.0.1';
|
|
7
|
+
exports.rxjsVersion = '^7.8.0';
|
|
8
|
+
exports.reflectMetadataVersion = '^0.1.13';
|
|
9
|
+
exports.tsLibVersion = '^2.3.0';
|