@gapi/schematics 1.8.169 → 1.8.170
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/dist/lib/application/application.factory.js +5 -6
- package/dist/lib/application/application.factory.test.ts +5 -1
- package/dist/lib/application/application.factory.ts +1 -0
- package/dist/lib/application/files/ts/src/app.controller.spec.ts +1 -0
- package/dist/lib/application/files/ts/src/app.controller.ts +1 -0
- package/dist/lib/application/files/ts/src/app.module.ts +1 -0
- package/dist/lib/application/files/ts/src/main.ts +1 -0
- package/dist/lib/application/files/ts/test/app.e2e-spec.ts +1 -0
- package/dist/lib/class/class.factory.js +7 -8
- package/dist/lib/class/class.factory.test.ts +9 -6
- package/dist/lib/class/class.factory.ts +2 -1
- package/dist/lib/client-app/angular/angular.factory.js +12 -13
- package/dist/lib/client-app/angular/angular.factory.ts +5 -4
- package/dist/lib/client-app/angular/files/angular.module.ts +1 -0
- package/dist/lib/client-app/angular/files/angular.providers.ts +1 -0
- package/dist/lib/client-app/angular/files/loaders/abstract.loader.ts +1 -0
- package/dist/lib/client-app/angular/files/loaders/express.loader.ts +1 -0
- package/dist/lib/client-app/angular/files/loaders/fastify.loader.ts +1 -0
- package/dist/lib/client-app/angular/files/loaders/noop.loader.ts +1 -0
- package/dist/lib/component/component.factory.js +9 -10
- package/dist/lib/component/component.factory.test.ts +13 -12
- package/dist/lib/component/component.factory.ts +2 -1
- package/dist/lib/configuration/configuration.factory.js +5 -6
- package/dist/lib/configuration/configuration.factory.test.ts +4 -3
- package/dist/lib/configuration/configuration.factory.ts +1 -0
- package/dist/lib/controller/controller.factory.js +9 -10
- package/dist/lib/controller/controller.factory.test.ts +13 -12
- package/dist/lib/controller/controller.factory.ts +2 -1
- package/dist/lib/decorator/decorator.factory.js +6 -7
- package/dist/lib/decorator/decorator.factory.test.ts +7 -6
- package/dist/lib/decorator/decorator.factory.ts +1 -0
- package/dist/lib/effect/effect.factory.js +10 -12
- package/dist/lib/effect/effect.factory.test.ts +12 -11
- package/dist/lib/effect/effect.factory.ts +3 -3
- package/dist/lib/filter/filter.factory.js +7 -8
- package/dist/lib/filter/filter.factory.test.ts +12 -7
- package/dist/lib/filter/filter.factory.ts +2 -1
- package/dist/lib/gateway/gateway.factory.js +9 -10
- package/dist/lib/gateway/gateway.factory.test.ts +7 -6
- package/dist/lib/gateway/gateway.factory.ts +2 -1
- package/dist/lib/guard/guard.factory.js +7 -8
- package/dist/lib/guard/guard.factory.test.ts +7 -6
- package/dist/lib/guard/guard.factory.ts +2 -1
- package/dist/lib/interceptor/interceptor.factory.js +7 -8
- package/dist/lib/interceptor/interceptor.factory.test.ts +7 -6
- package/dist/lib/interceptor/interceptor.factory.ts +2 -1
- package/dist/lib/interface/interface.factory.js +6 -7
- package/dist/lib/interface/interface.factory.test.ts +6 -5
- package/dist/lib/interface/interface.factory.ts +1 -0
- package/dist/lib/library/library.factory.js +13 -14
- package/dist/lib/library/library.factory.test.ts +1 -0
- package/dist/lib/library/library.factory.ts +2 -1
- package/dist/lib/module/module.factory.js +8 -9
- package/dist/lib/module/module.factory.test.ts +7 -6
- package/dist/lib/module/module.factory.ts +1 -0
- package/dist/lib/pipe/pipe.factory.js +7 -8
- package/dist/lib/pipe/pipe.factory.test.ts +7 -6
- package/dist/lib/pipe/pipe.factory.ts +2 -1
- package/dist/lib/plugin/plugin.factory.d.ts +1 -0
- package/dist/lib/plugin/plugin.factory.test.ts +13 -12
- package/dist/lib/plugin/plugin.factory.ts +2 -1
- package/dist/lib/provider/provider.factory.d.ts +1 -0
- package/dist/lib/provider/provider.factory.test.ts +11 -10
- package/dist/lib/provider/provider.factory.ts +2 -1
- package/dist/lib/resolver/resolver.factory.js +9 -10
- package/dist/lib/resolver/resolver.factory.test.ts +13 -12
- package/dist/lib/resolver/resolver.factory.ts +2 -1
- package/dist/lib/service/service.factory.js +10 -12
- package/dist/lib/service/service.factory.test.ts +12 -11
- package/dist/lib/service/service.factory.ts +3 -3
- package/dist/lib/type/type.factory.d.ts +1 -0
- package/dist/lib/type/type.factory.test.ts +13 -12
- package/dist/lib/type/type.factory.ts +2 -1
- package/dist/utils/metadata.manager.js +9 -9
- package/dist/utils/metadata.manager.ts +13 -10
- package/dist/utils/module-import.declarator.js +4 -4
- package/dist/utils/module-import.declarator.ts +3 -2
- package/dist/utils/module.declarator.js +2 -2
- package/dist/utils/module.declarator.ts +2 -0
- package/dist/utils/module.finder.js +2 -2
- package/dist/utils/module.finder.ts +1 -1
- package/dist/utils/name.parser.js +3 -5
- package/dist/utils/name.parser.ts +5 -6
- package/dist/utils/path.solver.js +2 -4
- package/dist/utils/path.solver.ts +2 -3
- package/dist/utils/source-root.helpers.js +6 -6
- package/dist/utils/source-root.helpers.ts +4 -2
- package/eslint.config.mjs +38 -0
- package/package.json +2 -2
- package/src/lib/application/application.factory.test.ts +5 -1
- package/src/lib/application/application.factory.ts +1 -0
- package/src/lib/application/files/ts/src/app.controller.spec.ts +1 -0
- package/src/lib/application/files/ts/src/app.controller.ts +1 -0
- package/src/lib/application/files/ts/src/app.module.ts +1 -0
- package/src/lib/application/files/ts/src/main.ts +1 -0
- package/src/lib/application/files/ts/test/app.e2e-spec.ts +1 -0
- package/src/lib/class/class.factory.test.ts +9 -6
- package/src/lib/class/class.factory.ts +2 -1
- package/src/lib/client-app/angular/angular.factory.ts +5 -4
- package/src/lib/client-app/angular/files/angular.module.ts +1 -0
- package/src/lib/client-app/angular/files/angular.providers.ts +1 -0
- package/src/lib/client-app/angular/files/loaders/abstract.loader.ts +1 -0
- package/src/lib/client-app/angular/files/loaders/express.loader.ts +1 -0
- package/src/lib/client-app/angular/files/loaders/fastify.loader.ts +1 -0
- package/src/lib/client-app/angular/files/loaders/noop.loader.ts +1 -0
- package/src/lib/component/component.factory.test.ts +13 -12
- package/src/lib/component/component.factory.ts +2 -1
- package/src/lib/configuration/configuration.factory.test.ts +4 -3
- package/src/lib/configuration/configuration.factory.ts +1 -0
- package/src/lib/controller/controller.factory.test.ts +13 -12
- package/src/lib/controller/controller.factory.ts +2 -1
- package/src/lib/decorator/decorator.factory.test.ts +7 -6
- package/src/lib/decorator/decorator.factory.ts +1 -0
- package/src/lib/effect/effect.factory.test.ts +12 -11
- package/src/lib/effect/effect.factory.ts +3 -3
- package/src/lib/filter/filter.factory.test.ts +12 -7
- package/src/lib/filter/filter.factory.ts +2 -1
- package/src/lib/gateway/gateway.factory.test.ts +7 -6
- package/src/lib/gateway/gateway.factory.ts +2 -1
- package/src/lib/guard/guard.factory.test.ts +7 -6
- package/src/lib/guard/guard.factory.ts +2 -1
- package/src/lib/interceptor/interceptor.factory.test.ts +7 -6
- package/src/lib/interceptor/interceptor.factory.ts +2 -1
- package/src/lib/interface/interface.factory.test.ts +6 -5
- package/src/lib/interface/interface.factory.ts +1 -0
- package/src/lib/library/library.factory.test.ts +1 -0
- package/src/lib/library/library.factory.ts +2 -1
- package/src/lib/module/module.factory.test.ts +7 -6
- package/src/lib/module/module.factory.ts +1 -0
- package/src/lib/pipe/pipe.factory.test.ts +7 -6
- package/src/lib/pipe/pipe.factory.ts +2 -1
- package/src/lib/plugin/plugin.factory.d.ts +1 -0
- package/src/lib/plugin/plugin.factory.test.ts +13 -12
- package/src/lib/plugin/plugin.factory.ts +2 -1
- package/src/lib/provider/provider.factory.d.ts +1 -0
- package/src/lib/provider/provider.factory.test.ts +11 -10
- package/src/lib/provider/provider.factory.ts +2 -1
- package/src/lib/resolver/resolver.factory.test.ts +13 -12
- package/src/lib/resolver/resolver.factory.ts +2 -1
- package/src/lib/service/service.factory.test.ts +12 -11
- package/src/lib/service/service.factory.ts +3 -3
- package/src/lib/type/type.factory.d.ts +1 -0
- package/src/lib/type/type.factory.test.ts +13 -12
- package/src/lib/type/type.factory.ts +2 -1
- package/src/utils/metadata.manager.ts +13 -10
- package/src/utils/module-import.declarator.ts +3 -2
- package/src/utils/module.declarator.ts +2 -0
- package/src/utils/module.finder.ts +1 -1
- package/src/utils/name.parser.ts +5 -6
- package/src/utils/path.solver.ts +2 -3
- package/src/utils/source-root.helpers.ts +4 -2
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
UnitTestTree,
|
|
4
4
|
} from '@angular-devkit/schematics/testing';
|
|
5
5
|
import * as path from 'path';
|
|
6
|
+
|
|
6
7
|
import { ResolverOptions } from './resolver.schema';
|
|
7
8
|
|
|
8
9
|
describe('Resolver Factory', () => {
|
|
@@ -18,12 +19,12 @@ describe('Resolver Factory', () => {
|
|
|
18
19
|
const tree: UnitTestTree = runner.runSchematic('resolver', options);
|
|
19
20
|
const files: string[] = tree.files;
|
|
20
21
|
expect(
|
|
21
|
-
files.find(filename => filename === '/foo/foo.resolver.ts'),
|
|
22
|
+
files.find((filename) => filename === '/foo/foo.resolver.ts'),
|
|
22
23
|
).not.toBeUndefined();
|
|
23
24
|
expect(tree.readContent('/foo/foo.resolver.ts')).toEqual(
|
|
24
25
|
"import { Resolver } from '@nestjs/graphql';\n" +
|
|
25
26
|
'\n' +
|
|
26
|
-
|
|
27
|
+
"@Resolver('Foo')\n" +
|
|
27
28
|
'export class FooResolver {}\n',
|
|
28
29
|
);
|
|
29
30
|
});
|
|
@@ -35,12 +36,12 @@ describe('Resolver Factory', () => {
|
|
|
35
36
|
const tree: UnitTestTree = runner.runSchematic('resolver', options);
|
|
36
37
|
const files: string[] = tree.files;
|
|
37
38
|
expect(
|
|
38
|
-
files.find(filename => filename === '/bar/foo/foo.resolver.ts'),
|
|
39
|
+
files.find((filename) => filename === '/bar/foo/foo.resolver.ts'),
|
|
39
40
|
).not.toBeUndefined();
|
|
40
41
|
expect(tree.readContent('/bar/foo/foo.resolver.ts')).toEqual(
|
|
41
42
|
"import { Resolver } from '@nestjs/graphql';\n" +
|
|
42
43
|
'\n' +
|
|
43
|
-
|
|
44
|
+
"@Resolver('Foo')\n" +
|
|
44
45
|
'export class FooResolver {}\n',
|
|
45
46
|
);
|
|
46
47
|
});
|
|
@@ -53,12 +54,12 @@ describe('Resolver Factory', () => {
|
|
|
53
54
|
const tree: UnitTestTree = runner.runSchematic('resolver', options);
|
|
54
55
|
const files: string[] = tree.files;
|
|
55
56
|
expect(
|
|
56
|
-
files.find(filename => filename === '/baz/foo/foo.resolver.ts'),
|
|
57
|
+
files.find((filename) => filename === '/baz/foo/foo.resolver.ts'),
|
|
57
58
|
).not.toBeUndefined();
|
|
58
59
|
expect(tree.readContent('/baz/foo/foo.resolver.ts')).toEqual(
|
|
59
60
|
"import { Resolver } from '@nestjs/graphql';\n" +
|
|
60
61
|
'\n' +
|
|
61
|
-
|
|
62
|
+
"@Resolver('Foo')\n" +
|
|
62
63
|
'export class FooResolver {}\n',
|
|
63
64
|
);
|
|
64
65
|
});
|
|
@@ -70,12 +71,12 @@ describe('Resolver Factory', () => {
|
|
|
70
71
|
const tree: UnitTestTree = runner.runSchematic('resolver', options);
|
|
71
72
|
const files: string[] = tree.files;
|
|
72
73
|
expect(
|
|
73
|
-
files.find(filename => filename === '/foo-bar/foo-bar.resolver.ts'),
|
|
74
|
+
files.find((filename) => filename === '/foo-bar/foo-bar.resolver.ts'),
|
|
74
75
|
).not.toBeUndefined();
|
|
75
76
|
expect(tree.readContent('/foo-bar/foo-bar.resolver.ts')).toEqual(
|
|
76
77
|
"import { Resolver } from '@nestjs/graphql';\n" +
|
|
77
78
|
'\n' +
|
|
78
|
-
|
|
79
|
+
"@Resolver('FooBar')\n" +
|
|
79
80
|
'export class FooBarResolver {}\n',
|
|
80
81
|
);
|
|
81
82
|
});
|
|
@@ -87,12 +88,12 @@ describe('Resolver Factory', () => {
|
|
|
87
88
|
const tree: UnitTestTree = runner.runSchematic('resolver', options);
|
|
88
89
|
const files: string[] = tree.files;
|
|
89
90
|
expect(
|
|
90
|
-
files.find(filename => filename === '/bar-baz/foo/foo.resolver.ts'),
|
|
91
|
+
files.find((filename) => filename === '/bar-baz/foo/foo.resolver.ts'),
|
|
91
92
|
).not.toBeUndefined();
|
|
92
93
|
expect(tree.readContent('/bar-baz/foo/foo.resolver.ts')).toEqual(
|
|
93
94
|
"import { Resolver } from '@nestjs/graphql';\n" +
|
|
94
95
|
'\n' +
|
|
95
|
-
|
|
96
|
+
"@Resolver('Foo')\n" +
|
|
96
97
|
'export class FooResolver {}\n',
|
|
97
98
|
);
|
|
98
99
|
});
|
|
@@ -105,12 +106,12 @@ describe('Resolver Factory', () => {
|
|
|
105
106
|
const tree: UnitTestTree = runner.runSchematic('resolver', options);
|
|
106
107
|
const files: string[] = tree.files;
|
|
107
108
|
expect(
|
|
108
|
-
files.find(filename => filename === '/foo/foo.resolver.js'),
|
|
109
|
+
files.find((filename) => filename === '/foo/foo.resolver.js'),
|
|
109
110
|
).not.toBeUndefined();
|
|
110
111
|
expect(tree.readContent('/foo/foo.resolver.js')).toEqual(
|
|
111
112
|
"import { Resolver } from '@nestjs/graphql';\n" +
|
|
112
113
|
'\n' +
|
|
113
|
-
|
|
114
|
+
"@Resolver('Foo')\n" +
|
|
114
115
|
'export class FooResolver {}\n',
|
|
115
116
|
);
|
|
116
117
|
});
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
Tree,
|
|
16
16
|
url,
|
|
17
17
|
} from '@angular-devkit/schematics';
|
|
18
|
+
|
|
18
19
|
import {
|
|
19
20
|
DeclarationOptions,
|
|
20
21
|
ModuleDeclarator,
|
|
@@ -60,7 +61,7 @@ function transform(options: ResolverOptions): ResolverOptions {
|
|
|
60
61
|
function generate(options: ResolverOptions): Source {
|
|
61
62
|
return (context: SchematicContext) =>
|
|
62
63
|
apply(url(join('./files' as Path, options.language)), [
|
|
63
|
-
options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
|
|
64
|
+
options.spec ? noop() : filter((path) => !path.endsWith('.spec.ts')),
|
|
64
65
|
template({
|
|
65
66
|
...strings,
|
|
66
67
|
...options,
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
UnitTestTree,
|
|
5
5
|
} from '@angular-devkit/schematics/testing';
|
|
6
6
|
import * as path from 'path';
|
|
7
|
+
|
|
7
8
|
import { ApplicationOptions } from '../application/application.schema';
|
|
8
9
|
import { ModuleOptions } from '../module/module.schema';
|
|
9
10
|
import { ServiceOptions } from './service.schema';
|
|
@@ -22,10 +23,10 @@ describe('Service Factory', () => {
|
|
|
22
23
|
const tree: UnitTestTree = runner.runSchematic('service', options);
|
|
23
24
|
const files: string[] = tree.files;
|
|
24
25
|
expect(
|
|
25
|
-
files.find(filename => filename === '/foo.service.ts'),
|
|
26
|
+
files.find((filename) => filename === '/foo.service.ts'),
|
|
26
27
|
).toBeDefined();
|
|
27
28
|
expect(
|
|
28
|
-
files.find(filename => filename === '/foo.service.spec.ts'),
|
|
29
|
+
files.find((filename) => filename === '/foo.service.spec.ts'),
|
|
29
30
|
).toBeDefined();
|
|
30
31
|
expect(tree.readContent('/foo.service.ts')).toEqual(
|
|
31
32
|
"import { Injectable } from '@nestjs/common';\n" +
|
|
@@ -43,10 +44,10 @@ describe('Service Factory', () => {
|
|
|
43
44
|
const tree: UnitTestTree = runner.runSchematic('service', options);
|
|
44
45
|
const files: string[] = tree.files;
|
|
45
46
|
expect(
|
|
46
|
-
files.find(filename => filename === '/bar/foo.service.ts'),
|
|
47
|
+
files.find((filename) => filename === '/bar/foo.service.ts'),
|
|
47
48
|
).toBeDefined();
|
|
48
49
|
expect(
|
|
49
|
-
files.find(filename => filename === '/bar/foo.service.spec.ts'),
|
|
50
|
+
files.find((filename) => filename === '/bar/foo.service.spec.ts'),
|
|
50
51
|
).toBeDefined();
|
|
51
52
|
expect(tree.readContent('/bar/foo.service.ts')).toEqual(
|
|
52
53
|
"import { Injectable } from '@nestjs/common';\n" +
|
|
@@ -65,10 +66,10 @@ describe('Service Factory', () => {
|
|
|
65
66
|
const tree: UnitTestTree = runner.runSchematic('service', options);
|
|
66
67
|
const files: string[] = tree.files;
|
|
67
68
|
expect(
|
|
68
|
-
files.find(filename => filename === '/bar/foo.service.ts'),
|
|
69
|
+
files.find((filename) => filename === '/bar/foo.service.ts'),
|
|
69
70
|
).toBeDefined();
|
|
70
71
|
expect(
|
|
71
|
-
files.find(filename => filename === '/bar/foo.service.spec.ts'),
|
|
72
|
+
files.find((filename) => filename === '/bar/foo.service.spec.ts'),
|
|
72
73
|
).toBeDefined();
|
|
73
74
|
expect(tree.readContent('/bar/foo.service.ts')).toEqual(
|
|
74
75
|
"import { Injectable } from '@nestjs/common';\n" +
|
|
@@ -86,7 +87,7 @@ describe('Service Factory', () => {
|
|
|
86
87
|
const tree: UnitTestTree = runner.runSchematic('service', options);
|
|
87
88
|
const files: string[] = tree.files;
|
|
88
89
|
expect(
|
|
89
|
-
files.find(filename => filename === '/foo-bar.service.ts'),
|
|
90
|
+
files.find((filename) => filename === '/foo-bar.service.ts'),
|
|
90
91
|
).toBeDefined();
|
|
91
92
|
expect(tree.readContent('/foo-bar.service.ts')).toEqual(
|
|
92
93
|
"import { Injectable } from '@nestjs/common';\n" +
|
|
@@ -104,10 +105,10 @@ describe('Service Factory', () => {
|
|
|
104
105
|
const tree: UnitTestTree = runner.runSchematic('service', options);
|
|
105
106
|
const files: string[] = tree.files;
|
|
106
107
|
expect(
|
|
107
|
-
files.find(filename => filename === '/bar-baz/foo.service.ts'),
|
|
108
|
+
files.find((filename) => filename === '/bar-baz/foo.service.ts'),
|
|
108
109
|
).toBeDefined();
|
|
109
110
|
expect(
|
|
110
|
-
files.find(filename => filename === '/bar-baz/foo.service.spec.ts'),
|
|
111
|
+
files.find((filename) => filename === '/bar-baz/foo.service.spec.ts'),
|
|
111
112
|
).toBeDefined();
|
|
112
113
|
expect(tree.readContent('/bar-baz/foo.service.ts')).toEqual(
|
|
113
114
|
"import { Injectable } from '@nestjs/common';\n" +
|
|
@@ -126,10 +127,10 @@ describe('Service Factory', () => {
|
|
|
126
127
|
const tree: UnitTestTree = runner.runSchematic('service', options);
|
|
127
128
|
const files: string[] = tree.files;
|
|
128
129
|
expect(
|
|
129
|
-
files.find(filename => filename === '/foo.service.js'),
|
|
130
|
+
files.find((filename) => filename === '/foo.service.js'),
|
|
130
131
|
).toBeDefined();
|
|
131
132
|
expect(
|
|
132
|
-
files.find(filename => filename === '/foo.service.spec.js'),
|
|
133
|
+
files.find((filename) => filename === '/foo.service.spec.js'),
|
|
133
134
|
).toBeDefined();
|
|
134
135
|
expect(tree.readContent('/foo.service.js')).toEqual(
|
|
135
136
|
"import { Injectable } from '@nestjs/common';\n" +
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
Tree,
|
|
15
15
|
url,
|
|
16
16
|
} from '@angular-devkit/schematics';
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
import {
|
|
19
19
|
DeclarationOptions,
|
|
20
20
|
ModuleDeclarator,
|
|
@@ -42,7 +42,7 @@ function transform(source: ServiceOptions): ServiceOptions {
|
|
|
42
42
|
target.metadata = 'providers';
|
|
43
43
|
target.type = 'service';
|
|
44
44
|
|
|
45
|
-
if (
|
|
45
|
+
if (target.name === null || target.name === undefined) {
|
|
46
46
|
throw new SchematicsException('Option (name) is required.');
|
|
47
47
|
}
|
|
48
48
|
const location: Location = new NameParser().parse(target);
|
|
@@ -59,7 +59,7 @@ function transform(source: ServiceOptions): ServiceOptions {
|
|
|
59
59
|
function generate(options: ServiceOptions) {
|
|
60
60
|
return (context: SchematicContext) =>
|
|
61
61
|
apply(url(join('./files' as Path, options.language)), [
|
|
62
|
-
options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
|
|
62
|
+
options.spec ? noop() : filter((path) => !path.endsWith('.spec.ts')),
|
|
63
63
|
template({
|
|
64
64
|
...strings,
|
|
65
65
|
...options,
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
UnitTestTree,
|
|
5
5
|
} from '@angular-devkit/schematics/testing';
|
|
6
6
|
import * as path from 'path';
|
|
7
|
+
|
|
7
8
|
import { ApplicationOptions } from '../application/application.schema';
|
|
8
9
|
import { ModuleOptions } from '../module/module.schema';
|
|
9
10
|
import { ControllerOptions } from './controller.schema';
|
|
@@ -24,10 +25,10 @@ describe('Controller Factory', () => {
|
|
|
24
25
|
const files: string[] = tree.files;
|
|
25
26
|
|
|
26
27
|
expect(
|
|
27
|
-
files.find(filename => filename === '/foo/foo.controller.ts'),
|
|
28
|
+
files.find((filename) => filename === '/foo/foo.controller.ts'),
|
|
28
29
|
).toBeDefined();
|
|
29
30
|
expect(
|
|
30
|
-
files.find(filename => filename === '/foo/foo.controller.spec.ts'),
|
|
31
|
+
files.find((filename) => filename === '/foo/foo.controller.spec.ts'),
|
|
31
32
|
).not.toBeDefined();
|
|
32
33
|
expect(tree.readContent('/foo/foo.controller.ts')).toEqual(
|
|
33
34
|
"import { Controller } from '@nestjs/common';\n" +
|
|
@@ -44,10 +45,10 @@ describe('Controller Factory', () => {
|
|
|
44
45
|
const tree: UnitTestTree = runner.runSchematic('controller', options);
|
|
45
46
|
const files: string[] = tree.files;
|
|
46
47
|
expect(
|
|
47
|
-
files.find(filename => filename === '/bar/foo/foo.controller.ts'),
|
|
48
|
+
files.find((filename) => filename === '/bar/foo/foo.controller.ts'),
|
|
48
49
|
).toBeDefined();
|
|
49
50
|
expect(
|
|
50
|
-
files.find(filename => filename === '/bar/foo/foo.controller.spec.ts'),
|
|
51
|
+
files.find((filename) => filename === '/bar/foo/foo.controller.spec.ts'),
|
|
51
52
|
).toBeDefined();
|
|
52
53
|
expect(tree.readContent('/bar/foo/foo.controller.ts')).toEqual(
|
|
53
54
|
"import { Controller } from '@nestjs/common';\n" +
|
|
@@ -65,10 +66,10 @@ describe('Controller Factory', () => {
|
|
|
65
66
|
const tree: UnitTestTree = runner.runSchematic('controller', options);
|
|
66
67
|
const files: string[] = tree.files;
|
|
67
68
|
expect(
|
|
68
|
-
files.find(filename => filename === '/bar/foo/foo.controller.ts'),
|
|
69
|
+
files.find((filename) => filename === '/bar/foo/foo.controller.ts'),
|
|
69
70
|
).toBeDefined();
|
|
70
71
|
expect(
|
|
71
|
-
files.find(filename => filename === '/bar/foo/foo.controller.spec.ts'),
|
|
72
|
+
files.find((filename) => filename === '/bar/foo/foo.controller.spec.ts'),
|
|
72
73
|
).toBeDefined();
|
|
73
74
|
expect(tree.readContent('/bar/foo/foo.controller.ts')).toEqual(
|
|
74
75
|
"import { Controller } from '@nestjs/common';\n" +
|
|
@@ -85,11 +86,11 @@ describe('Controller Factory', () => {
|
|
|
85
86
|
const tree: UnitTestTree = runner.runSchematic('controller', options);
|
|
86
87
|
const files: string[] = tree.files;
|
|
87
88
|
expect(
|
|
88
|
-
files.find(filename => filename === '/foo-bar/foo-bar.controller.ts'),
|
|
89
|
+
files.find((filename) => filename === '/foo-bar/foo-bar.controller.ts'),
|
|
89
90
|
).toBeDefined();
|
|
90
91
|
expect(
|
|
91
92
|
files.find(
|
|
92
|
-
filename => filename === '/foo-bar/foo-bar.controller.spec.ts',
|
|
93
|
+
(filename) => filename === '/foo-bar/foo-bar.controller.spec.ts',
|
|
93
94
|
),
|
|
94
95
|
).toBeDefined();
|
|
95
96
|
expect(tree.readContent('/foo-bar/foo-bar.controller.ts')).toEqual(
|
|
@@ -107,11 +108,11 @@ describe('Controller Factory', () => {
|
|
|
107
108
|
const tree: UnitTestTree = runner.runSchematic('controller', options);
|
|
108
109
|
const files: string[] = tree.files;
|
|
109
110
|
expect(
|
|
110
|
-
files.find(filename => filename === '/bar-baz/foo/foo.controller.ts'),
|
|
111
|
+
files.find((filename) => filename === '/bar-baz/foo/foo.controller.ts'),
|
|
111
112
|
).toBeDefined();
|
|
112
113
|
expect(
|
|
113
114
|
files.find(
|
|
114
|
-
filename => filename === '/bar-baz/foo/foo.controller.spec.ts',
|
|
115
|
+
(filename) => filename === '/bar-baz/foo/foo.controller.spec.ts',
|
|
115
116
|
),
|
|
116
117
|
).toBeDefined();
|
|
117
118
|
expect(tree.readContent('/bar-baz/foo/foo.controller.ts')).toEqual(
|
|
@@ -130,10 +131,10 @@ describe('Controller Factory', () => {
|
|
|
130
131
|
const tree: UnitTestTree = runner.runSchematic('controller', options);
|
|
131
132
|
const files: string[] = tree.files;
|
|
132
133
|
expect(
|
|
133
|
-
files.find(filename => filename === '/foo/foo.controller.js'),
|
|
134
|
+
files.find((filename) => filename === '/foo/foo.controller.js'),
|
|
134
135
|
).toBeDefined();
|
|
135
136
|
expect(
|
|
136
|
-
files.find(filename => filename === '/foo/foo.controller.spec.js'),
|
|
137
|
+
files.find((filename) => filename === '/foo/foo.controller.spec.js'),
|
|
137
138
|
).toBeDefined();
|
|
138
139
|
expect(tree.readContent('/foo/foo.controller.js')).toEqual(
|
|
139
140
|
"import { Controller } from '@nestjs/common';\n" +
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
Tree,
|
|
14
14
|
url,
|
|
15
15
|
} from '@angular-devkit/schematics';
|
|
16
|
+
|
|
16
17
|
import {
|
|
17
18
|
DeclarationOptions,
|
|
18
19
|
ModuleDeclarator,
|
|
@@ -59,7 +60,7 @@ function transform(source: ControllerOptions): ControllerOptions {
|
|
|
59
60
|
function generate(options: ControllerOptions) {
|
|
60
61
|
return (context: SchematicContext) =>
|
|
61
62
|
apply(url(join('./files' as Path, options.language)), [
|
|
62
|
-
options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
|
|
63
|
+
options.spec ? noop() : filter((path) => !path.endsWith('.spec.ts')),
|
|
63
64
|
template({
|
|
64
65
|
...strings,
|
|
65
66
|
...options,
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
StringLiteral,
|
|
16
16
|
SyntaxKind,
|
|
17
17
|
} from 'typescript';
|
|
18
|
+
|
|
18
19
|
import { DeclarationOptions } from './module.declarator';
|
|
19
20
|
|
|
20
21
|
export class MetadataManager {
|
|
@@ -30,10 +31,12 @@ export class MetadataManager {
|
|
|
30
31
|
this.content,
|
|
31
32
|
ScriptTarget.ES2017,
|
|
32
33
|
);
|
|
33
|
-
const decoratorNodes: Node[] = this.getDecoratorMetadata(source
|
|
34
|
+
const decoratorNodes: Node[] = this.getDecoratorMetadata(source);
|
|
34
35
|
const node: Node = decoratorNodes[0];
|
|
35
|
-
const matchingProperties: ObjectLiteralElement[] = (
|
|
36
|
-
|
|
36
|
+
const matchingProperties: ObjectLiteralElement[] = (
|
|
37
|
+
node as ObjectLiteralExpression
|
|
38
|
+
).properties
|
|
39
|
+
.filter((prop) => prop.kind === SyntaxKind.PropertyAssignment)
|
|
37
40
|
.filter((prop: PropertyAssignment) => {
|
|
38
41
|
const name = prop.name;
|
|
39
42
|
switch (name.kind) {
|
|
@@ -78,20 +81,20 @@ export class MetadataManager {
|
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
|
|
81
|
-
private getDecoratorMetadata(source: SourceFile
|
|
84
|
+
private getDecoratorMetadata(source: SourceFile): Node[] {
|
|
82
85
|
return this.getSourceNodes(source)
|
|
83
86
|
.filter(
|
|
84
|
-
node =>
|
|
87
|
+
(node) =>
|
|
85
88
|
node.kind === SyntaxKind.Decorator &&
|
|
86
89
|
(node as Decorator).expression.kind === SyntaxKind.CallExpression,
|
|
87
90
|
)
|
|
88
|
-
.map(node => (node as Decorator).expression as CallExpression)
|
|
91
|
+
.map((node) => (node as Decorator).expression as CallExpression)
|
|
89
92
|
.filter(
|
|
90
|
-
expr =>
|
|
93
|
+
(expr) =>
|
|
91
94
|
expr.arguments[0] &&
|
|
92
95
|
expr.arguments[0].kind === SyntaxKind.ObjectLiteralExpression,
|
|
93
96
|
)
|
|
94
|
-
.map(expr => expr.arguments[0] as ObjectLiteralExpression);
|
|
97
|
+
.map((expr) => expr.arguments[0] as ObjectLiteralExpression);
|
|
95
98
|
}
|
|
96
99
|
|
|
97
100
|
private getSourceNodes(sourceFile: SourceFile): Node[] {
|
|
@@ -165,8 +168,8 @@ export class MetadataManager {
|
|
|
165
168
|
node = arrLiteral.elements;
|
|
166
169
|
}
|
|
167
170
|
if (Array.isArray(node)) {
|
|
168
|
-
const nodeArray =
|
|
169
|
-
const symbolsArray = nodeArray.map(childNode =>
|
|
171
|
+
const nodeArray = node as never as Node[];
|
|
172
|
+
const symbolsArray = nodeArray.map((childNode) =>
|
|
170
173
|
childNode.getText(source),
|
|
171
174
|
);
|
|
172
175
|
if (symbolsArray.includes(symbol)) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { normalize, Path } from '@angular-devkit/core';
|
|
2
|
+
|
|
2
3
|
import { DeclarationOptions } from './module.declarator';
|
|
3
4
|
import { PathSolver } from './path.solver';
|
|
4
5
|
|
|
@@ -14,11 +15,11 @@ export class ModuleImportDeclarator {
|
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
private findImports(content: string): string[] {
|
|
17
|
-
return content.split('\n').filter(line => line.match(/import {/));
|
|
18
|
+
return content.split('\n').filter((line) => line.match(/import {/));
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
private findOtherLines(content: string, importLines: string[]) {
|
|
21
|
-
return content.split('\n').filter(line => importLines.indexOf(line) < 0);
|
|
22
|
+
return content.split('\n').filter((line) => importLines.indexOf(line) < 0);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
private buildLineToInsert(options: DeclarationOptions): string {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Path } from '@angular-devkit/core';
|
|
2
2
|
import { capitalize, classify } from '@angular-devkit/core/src/utils/strings';
|
|
3
|
+
|
|
3
4
|
import { ModuleImportDeclarator } from './module-import.declarator';
|
|
4
5
|
import { ModuleMetadataDeclarator } from './module-metadata.declarator';
|
|
5
6
|
|
|
@@ -12,6 +13,7 @@ export interface DeclarationOptions {
|
|
|
12
13
|
symbol?: string;
|
|
13
14
|
staticOptions?: {
|
|
14
15
|
name: string;
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
17
|
value: Record<string, any>;
|
|
16
18
|
};
|
|
17
19
|
}
|
|
@@ -22,7 +22,7 @@ export class ModuleFinder {
|
|
|
22
22
|
if (!directory) {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
-
const moduleFilename: PathFragment = directory.subfiles.find(filename =>
|
|
25
|
+
const moduleFilename: PathFragment = directory.subfiles.find((filename) =>
|
|
26
26
|
/\.module\.(t|j)s/.test(filename),
|
|
27
27
|
);
|
|
28
28
|
return moduleFilename !== undefined
|
package/src/utils/name.parser.ts
CHANGED
|
@@ -15,12 +15,11 @@ export class NameParser {
|
|
|
15
15
|
|
|
16
16
|
public parse(options: ParseOptions): Location {
|
|
17
17
|
const nameWithoutPath: string = basename(options.name as Path);
|
|
18
|
-
const namePath: string = dirname(
|
|
19
|
-
? ''
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.concat(options.name) as Path);
|
|
18
|
+
const namePath: string = dirname(
|
|
19
|
+
(options.path === undefined ? '' : options.path)
|
|
20
|
+
.concat('/')
|
|
21
|
+
.concat(options.name) as Path,
|
|
22
|
+
);
|
|
24
23
|
return {
|
|
25
24
|
name: nameWithoutPath,
|
|
26
25
|
path: normalize('/'.concat(namePath)),
|
package/src/utils/path.solver.ts
CHANGED
|
@@ -9,9 +9,8 @@ export class PathSolver {
|
|
|
9
9
|
dirname((placeholder + from) as Path),
|
|
10
10
|
dirname((placeholder + to) as Path),
|
|
11
11
|
);
|
|
12
|
-
return (
|
|
13
|
-
? relativeDir
|
|
14
|
-
: './' + relativeDir
|
|
12
|
+
return (
|
|
13
|
+
relativeDir.startsWith('.') ? relativeDir : './' + relativeDir
|
|
15
14
|
).concat(relativeDir.length === 0 ? basename(to) : '/' + basename(to));
|
|
16
15
|
}
|
|
17
16
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
import { join, normalize } from '@angular-devkit/core';
|
|
2
3
|
import { Rule, Tree } from '@angular-devkit/schematics';
|
|
4
|
+
|
|
3
5
|
import { DEFAULT_PATH_NAME } from '../lib/defaults';
|
|
4
6
|
|
|
5
7
|
export function isInRootDirectory(
|
|
@@ -7,11 +9,11 @@ export function isInRootDirectory(
|
|
|
7
9
|
extraFiles: string[] = [],
|
|
8
10
|
): boolean {
|
|
9
11
|
const files = ['nest-cli.json', 'nest.json'].concat(extraFiles || []);
|
|
10
|
-
return files.map(file => host.exists(file)).some(isPresent => isPresent);
|
|
12
|
+
return files.map((file) => host.exists(file)).some((isPresent) => isPresent);
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
export function mergeSourceRoot<
|
|
14
|
-
T extends { sourceRoot?: string; path?: string } = any
|
|
16
|
+
T extends { sourceRoot?: string; path?: string } = any,
|
|
15
17
|
>(options: T): Rule {
|
|
16
18
|
return (host: Tree) => {
|
|
17
19
|
const isInRoot = isInRootDirectory(host, ['tsconfig.json', 'package.json']);
|