@rxdi/schematics 0.7.189 → 0.7.191-nightly.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.
- package/lib/component/component.factory.js +1 -2
- package/lib/controller/controller.factory.js +1 -2
- package/lib/effect/effect.factory.js +2 -4
- package/lib/effect/effect.factory.ts +1 -2
- package/lib/guard/guard.factory.js +1 -2
- package/lib/interceptor/interceptor.factory.js +1 -2
- package/lib/module/module.factory.js +1 -2
- package/lib/service/service.factory.js +2 -4
- package/lib/service/service.factory.ts +1 -2
- package/package.json +8 -8
- package/utils/source-root.helpers.js +2 -3
- package/lib/application/application.factory.d.ts +0 -3
- package/lib/application/application.factory.js +0 -35
- package/lib/application/application.factory.test.ts +0 -88
- package/lib/application/application.factory.ts +0 -54
- package/lib/application/application.schema.d.ts +0 -34
- package/lib/application/files/js/.babelrc +0 -4
- package/lib/application/files/js/.prettierrc +0 -4
- package/lib/application/files/js/README.md +0 -37
- package/lib/application/files/js/index.js +0 -3
- package/lib/application/files/js/jsconfig.json +0 -9
- package/lib/application/files/js/nest-cli.json +0 -5
- package/lib/application/files/js/nodemon.json +0 -6
- package/lib/application/files/js/package.json +0 -46
- package/lib/application/files/js/test/app.e2e-spec.js +0 -23
- package/lib/application/files/js/test/jest-e2e.json +0 -5
- package/lib/application/files/ts/.prettierrc +0 -4
- package/lib/application/files/ts/README.md +0 -75
- package/lib/application/files/ts/nest-cli.json +0 -5
- package/lib/application/files/ts/nodemon-debug.json +0 -6
- package/lib/application/files/ts/nodemon.json +0 -6
- package/lib/application/files/ts/package.json +0 -58
- package/lib/application/files/ts/test/app.e2e-spec.ts +0 -23
- package/lib/application/files/ts/test/jest-e2e.json +0 -9
- package/lib/application/files/ts/tsconfig.build.json +0 -4
- package/lib/application/schema.json +0 -49
- package/lib/class/class.factory.d.ts +0 -3
- package/lib/class/class.factory.js +0 -35
- package/lib/class/class.factory.test.ts +0 -100
- package/lib/class/class.factory.ts +0 -54
- package/lib/class/class.schema.d.ts +0 -28
- package/lib/class/files/js/__name__.js +0 -1
- package/lib/class/files/js/__name__.spec.js +0 -7
- package/lib/class/files/ts/__name__.spec.ts +0 -7
- package/lib/class/files/ts/__name__.ts +0 -1
- package/lib/class/schema.json +0 -39
- package/lib/client-app/angular/angular.factory.d.ts +0 -3
- package/lib/client-app/angular/angular.factory.js +0 -97
- package/lib/client-app/angular/angular.factory.ts +0 -139
- package/lib/client-app/angular/angular.schema.d.ts +0 -32
- package/lib/client-app/angular/files/angular.constants.ts +0 -4
- package/lib/client-app/angular/files/angular.module.ts +0 -41
- package/lib/client-app/angular/files/angular.providers.ts +0 -27
- package/lib/client-app/angular/files/angular.utils.ts +0 -19
- package/lib/client-app/angular/files/interfaces/angular-options.interface.ts +0 -87
- package/lib/client-app/angular/files/loaders/abstract.loader.ts +0 -16
- package/lib/client-app/angular/files/loaders/express.loader.ts +0 -25
- package/lib/client-app/angular/files/loaders/fastify.loader.ts +0 -34
- package/lib/client-app/angular/files/loaders/noop.loader.ts +0 -12
- package/lib/client-app/angular/schema.json +0 -24
- package/lib/configuration/configuration.factory.d.ts +0 -3
- package/lib/configuration/configuration.factory.js +0 -24
- package/lib/configuration/configuration.factory.test.ts +0 -60
- package/lib/configuration/configuration.factory.ts +0 -35
- package/lib/configuration/configuration.schema.d.ts +0 -18
- package/lib/configuration/files/js/nest-cli.json +0 -5
- package/lib/configuration/files/ts/nest-cli.json +0 -5
- package/lib/decorator/decorator.factory.d.ts +0 -3
- package/lib/decorator/decorator.factory.js +0 -32
- package/lib/decorator/decorator.factory.test.ts +0 -111
- package/lib/decorator/decorator.factory.ts +0 -48
- package/lib/decorator/decorator.schema.d.ts +0 -24
- package/lib/decorator/files/js/__name__.decorator.js +0 -3
- package/lib/decorator/files/ts/__name__.decorator.ts +0 -3
- package/lib/decorator/schema.json +0 -35
- package/lib/filter/files/js/__name__.filter.js +0 -6
- package/lib/filter/files/js/__name__.filter.spec.js +0 -7
- package/lib/filter/files/ts/__name__.filter.spec.ts +0 -7
- package/lib/filter/files/ts/__name__.filter.ts +0 -6
- package/lib/filter/filter.factory.d.ts +0 -3
- package/lib/filter/filter.factory.js +0 -33
- package/lib/filter/filter.factory.test.ts +0 -147
- package/lib/filter/filter.factory.ts +0 -51
- package/lib/filter/filter.schema.d.ts +0 -28
- package/lib/filter/schema.json +0 -39
- package/lib/gateway/files/js/__name__.gateway.js +0 -9
- package/lib/gateway/files/js/__name__.gateway.spec.js +0 -18
- package/lib/gateway/files/ts/__name__.gateway.spec.ts +0 -18
- package/lib/gateway/files/ts/__name__.gateway.ts +0 -9
- package/lib/gateway/gateway.factory.d.ts +0 -3
- package/lib/gateway/gateway.factory.js +0 -61
- package/lib/gateway/gateway.factory.test.ts +0 -147
- package/lib/gateway/gateway.factory.ts +0 -92
- package/lib/gateway/gateway.schema.d.ts +0 -36
- package/lib/gateway/schema.json +0 -39
- package/lib/interface/files/__name__.interface.ts +0 -1
- package/lib/interface/interface.factory.d.ts +0 -3
- package/lib/interface/interface.factory.js +0 -31
- package/lib/interface/interface.factory.test.ts +0 -84
- package/lib/interface/interface.factory.ts +0 -47
- package/lib/interface/interface.schema.d.ts +0 -20
- package/lib/interface/schema.json +0 -31
- package/lib/library/files/js/.babelrc +0 -4
- package/lib/library/files/js/jsconfig.json +0 -9
- package/lib/library/files/js/package.json +0 -8
- package/lib/library/files/js/src/__name__.module.js +0 -8
- package/lib/library/files/js/src/__name__.service.js +0 -4
- package/lib/library/files/js/src/__name__.service.spec.js +0 -18
- package/lib/library/files/js/src/index.js +0 -2
- package/lib/library/files/ts/package.json +0 -8
- package/lib/library/files/ts/src/__name__.module.ts +0 -8
- package/lib/library/files/ts/src/__name__.service.spec.ts +0 -18
- package/lib/library/files/ts/src/__name__.service.ts +0 -4
- package/lib/library/files/ts/src/index.ts +0 -2
- package/lib/library/files/ts/tsconfig.lib.json +0 -5
- package/lib/library/library.factory.d.ts +0 -3
- package/lib/library/library.factory.js +0 -97
- package/lib/library/library.factory.test.ts +0 -68
- package/lib/library/library.factory.ts +0 -158
- package/lib/library/library.schema.d.ts +0 -24
- package/lib/library/schema.json +0 -37
- package/lib/pipe/files/js/__name__.pipe.js +0 -8
- package/lib/pipe/files/js/__name__.pipe.spec.js +0 -7
- package/lib/pipe/files/ts/__name__.pipe.spec.ts +0 -7
- package/lib/pipe/files/ts/__name__.pipe.ts +0 -8
- package/lib/pipe/pipe.factory.d.ts +0 -3
- package/lib/pipe/pipe.factory.js +0 -33
- package/lib/pipe/pipe.factory.test.ts +0 -141
- package/lib/pipe/pipe.factory.ts +0 -51
- package/lib/pipe/pipe.schema.d.ts +0 -28
- package/lib/pipe/schema.json +0 -39
- package/lib/resolver/files/js/__name__.resolver.js +0 -4
- package/lib/resolver/files/js/__name__.resolver.spec.js +0 -18
- package/lib/resolver/files/ts/__name__.resolver.spec.ts +0 -18
- package/lib/resolver/files/ts/__name__.resolver.ts +0 -4
- package/lib/resolver/resolver.factory.d.ts +0 -3
- package/lib/resolver/resolver.factory.js +0 -61
- package/lib/resolver/resolver.factory.test.ts +0 -117
- package/lib/resolver/resolver.factory.ts +0 -92
- package/lib/resolver/resolver.schema.d.ts +0 -36
- package/lib/resolver/schema.json +0 -39
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main = void 0;
|
|
4
|
-
const core_1 = require("@angular-devkit/core");
|
|
5
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
-
const module_declarator_1 = require("../../utils/module.declarator");
|
|
7
|
-
const module_finder_1 = require("../../utils/module.finder");
|
|
8
|
-
const name_parser_1 = require("../../utils/name.parser");
|
|
9
|
-
const source_root_helpers_1 = require("../../utils/source-root.helpers");
|
|
10
|
-
function main(options) {
|
|
11
|
-
options = transform(options);
|
|
12
|
-
return (tree, context) => {
|
|
13
|
-
return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
|
|
14
|
-
(0, source_root_helpers_1.mergeSourceRoot)(options),
|
|
15
|
-
addDeclarationToModule(options),
|
|
16
|
-
(0, schematics_1.mergeWith)(generate(options)),
|
|
17
|
-
]))(tree, context);
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
exports.main = main;
|
|
21
|
-
function transform(options) {
|
|
22
|
-
const target = Object.assign({}, options);
|
|
23
|
-
if (!target.name) {
|
|
24
|
-
throw new schematics_1.SchematicsException('Option (name) is required.');
|
|
25
|
-
}
|
|
26
|
-
target.metadata = 'providers';
|
|
27
|
-
target.type = 'gateway';
|
|
28
|
-
const location = new name_parser_1.NameParser().parse(target);
|
|
29
|
-
target.name = core_1.strings.dasherize(location.name);
|
|
30
|
-
target.path = core_1.strings.dasherize(location.path);
|
|
31
|
-
target.language = target.language !== undefined ? target.language : 'ts';
|
|
32
|
-
target.path = target.flat
|
|
33
|
-
? target.path
|
|
34
|
-
: (0, core_1.join)(target.path, target.name);
|
|
35
|
-
return target;
|
|
36
|
-
}
|
|
37
|
-
function generate(options) {
|
|
38
|
-
return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
39
|
-
options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)(path => !path.endsWith('.spec.ts')),
|
|
40
|
-
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
41
|
-
(0, schematics_1.move)(options.path),
|
|
42
|
-
])(context);
|
|
43
|
-
}
|
|
44
|
-
function addDeclarationToModule(options) {
|
|
45
|
-
return (tree) => {
|
|
46
|
-
if (options.skipImport !== undefined && options.skipImport) {
|
|
47
|
-
return tree;
|
|
48
|
-
}
|
|
49
|
-
options.module = new module_finder_1.ModuleFinder(tree).find({
|
|
50
|
-
name: options.name,
|
|
51
|
-
path: options.path,
|
|
52
|
-
});
|
|
53
|
-
if (!options.module) {
|
|
54
|
-
return tree;
|
|
55
|
-
}
|
|
56
|
-
const content = tree.read(options.module).toString();
|
|
57
|
-
const declarator = new module_declarator_1.ModuleDeclarator();
|
|
58
|
-
tree.overwrite(options.module, declarator.declare(content, options));
|
|
59
|
-
return tree;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SchematicTestRunner,
|
|
3
|
-
UnitTestTree,
|
|
4
|
-
} from '@angular-devkit/schematics/testing';
|
|
5
|
-
import * as path from 'path';
|
|
6
|
-
import { GatewayOptions } from './gateway.schema';
|
|
7
|
-
|
|
8
|
-
describe('Gateway Factory', () => {
|
|
9
|
-
const runner: SchematicTestRunner = new SchematicTestRunner(
|
|
10
|
-
'.',
|
|
11
|
-
path.join(process.cwd(), 'src/collection.json'),
|
|
12
|
-
);
|
|
13
|
-
it('should manage name only', () => {
|
|
14
|
-
const options: GatewayOptions = {
|
|
15
|
-
name: 'foo',
|
|
16
|
-
flat: false,
|
|
17
|
-
};
|
|
18
|
-
const tree: UnitTestTree = runner.runSchematic('gateway', options);
|
|
19
|
-
const files: string[] = tree.files;
|
|
20
|
-
expect(
|
|
21
|
-
files.find(filename => filename === '/foo/foo.gateway.ts'),
|
|
22
|
-
).not.toBeUndefined();
|
|
23
|
-
expect(tree.readContent('/foo/foo.gateway.ts')).toEqual(
|
|
24
|
-
"import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets';\n" +
|
|
25
|
-
'\n' +
|
|
26
|
-
'@WebSocketGateway()\n' +
|
|
27
|
-
'export class FooGateway {\n' +
|
|
28
|
-
" @SubscribeMessage('message')\n" +
|
|
29
|
-
' handleMessage(client: any, payload: any): string {\n' +
|
|
30
|
-
" return 'Hello world!';\n" +
|
|
31
|
-
' }\n' +
|
|
32
|
-
'}\n',
|
|
33
|
-
);
|
|
34
|
-
});
|
|
35
|
-
it('should manage name as a path', () => {
|
|
36
|
-
const options: GatewayOptions = {
|
|
37
|
-
name: 'bar/foo',
|
|
38
|
-
flat: false,
|
|
39
|
-
};
|
|
40
|
-
const tree: UnitTestTree = runner.runSchematic('gateway', options);
|
|
41
|
-
const files: string[] = tree.files;
|
|
42
|
-
expect(
|
|
43
|
-
files.find(filename => filename === '/bar/foo/foo.gateway.ts'),
|
|
44
|
-
).not.toBeUndefined();
|
|
45
|
-
expect(tree.readContent('/bar/foo/foo.gateway.ts')).toEqual(
|
|
46
|
-
"import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets';\n" +
|
|
47
|
-
'\n' +
|
|
48
|
-
'@WebSocketGateway()\n' +
|
|
49
|
-
'export class FooGateway {\n' +
|
|
50
|
-
" @SubscribeMessage('message')\n" +
|
|
51
|
-
' handleMessage(client: any, payload: any): string {\n' +
|
|
52
|
-
" return 'Hello world!';\n" +
|
|
53
|
-
' }\n' +
|
|
54
|
-
'}\n',
|
|
55
|
-
);
|
|
56
|
-
});
|
|
57
|
-
it('should manage name and path', () => {
|
|
58
|
-
const options: GatewayOptions = {
|
|
59
|
-
name: 'foo',
|
|
60
|
-
path: 'baz',
|
|
61
|
-
flat: false,
|
|
62
|
-
};
|
|
63
|
-
const tree: UnitTestTree = runner.runSchematic('gateway', options);
|
|
64
|
-
const files: string[] = tree.files;
|
|
65
|
-
expect(
|
|
66
|
-
files.find(filename => filename === '/baz/foo/foo.gateway.ts'),
|
|
67
|
-
).not.toBeUndefined();
|
|
68
|
-
expect(tree.readContent('/baz/foo/foo.gateway.ts')).toEqual(
|
|
69
|
-
"import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets';\n" +
|
|
70
|
-
'\n' +
|
|
71
|
-
'@WebSocketGateway()\n' +
|
|
72
|
-
'export class FooGateway {\n' +
|
|
73
|
-
" @SubscribeMessage('message')\n" +
|
|
74
|
-
' handleMessage(client: any, payload: any): string {\n' +
|
|
75
|
-
" return 'Hello world!';\n" +
|
|
76
|
-
' }\n' +
|
|
77
|
-
'}\n',
|
|
78
|
-
);
|
|
79
|
-
});
|
|
80
|
-
it('should manage name to dasherize', () => {
|
|
81
|
-
const options: GatewayOptions = {
|
|
82
|
-
name: 'fooBar',
|
|
83
|
-
flat: false,
|
|
84
|
-
};
|
|
85
|
-
const tree: UnitTestTree = runner.runSchematic('gateway', options);
|
|
86
|
-
const files: string[] = tree.files;
|
|
87
|
-
expect(
|
|
88
|
-
files.find(filename => filename === '/foo-bar/foo-bar.gateway.ts'),
|
|
89
|
-
).not.toBeUndefined();
|
|
90
|
-
expect(tree.readContent('/foo-bar/foo-bar.gateway.ts')).toEqual(
|
|
91
|
-
"import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets';\n" +
|
|
92
|
-
'\n' +
|
|
93
|
-
'@WebSocketGateway()\n' +
|
|
94
|
-
'export class FooBarGateway {\n' +
|
|
95
|
-
" @SubscribeMessage('message')\n" +
|
|
96
|
-
' handleMessage(client: any, payload: any): string {\n' +
|
|
97
|
-
" return 'Hello world!';\n" +
|
|
98
|
-
' }\n' +
|
|
99
|
-
'}\n',
|
|
100
|
-
);
|
|
101
|
-
});
|
|
102
|
-
it('should manage path to dasherize', () => {
|
|
103
|
-
const options: GatewayOptions = {
|
|
104
|
-
name: 'barBaz/foo',
|
|
105
|
-
flat: false,
|
|
106
|
-
};
|
|
107
|
-
const tree: UnitTestTree = runner.runSchematic('gateway', options);
|
|
108
|
-
const files: string[] = tree.files;
|
|
109
|
-
expect(
|
|
110
|
-
files.find(filename => filename === '/bar-baz/foo/foo.gateway.ts'),
|
|
111
|
-
).not.toBeUndefined();
|
|
112
|
-
expect(tree.readContent('/bar-baz/foo/foo.gateway.ts')).toEqual(
|
|
113
|
-
"import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets';\n" +
|
|
114
|
-
'\n' +
|
|
115
|
-
'@WebSocketGateway()\n' +
|
|
116
|
-
'export class FooGateway {\n' +
|
|
117
|
-
" @SubscribeMessage('message')\n" +
|
|
118
|
-
' handleMessage(client: any, payload: any): string {\n' +
|
|
119
|
-
" return 'Hello world!';\n" +
|
|
120
|
-
' }\n' +
|
|
121
|
-
'}\n',
|
|
122
|
-
);
|
|
123
|
-
});
|
|
124
|
-
it('should manage javascript file', () => {
|
|
125
|
-
const options: GatewayOptions = {
|
|
126
|
-
name: 'foo',
|
|
127
|
-
language: 'js',
|
|
128
|
-
flat: false,
|
|
129
|
-
};
|
|
130
|
-
const tree: UnitTestTree = runner.runSchematic('gateway', options);
|
|
131
|
-
const files: string[] = tree.files;
|
|
132
|
-
expect(
|
|
133
|
-
files.find(filename => filename === '/foo/foo.gateway.js'),
|
|
134
|
-
).not.toBeUndefined();
|
|
135
|
-
expect(tree.readContent('/foo/foo.gateway.js')).toEqual(
|
|
136
|
-
"import { SubscribeMessage, WebSocketGateway } from '@nestjs/websockets';\n" +
|
|
137
|
-
'\n' +
|
|
138
|
-
'@WebSocketGateway()\n' +
|
|
139
|
-
'export class FooGateway {\n' +
|
|
140
|
-
" @SubscribeMessage('message')\n" +
|
|
141
|
-
' handleMessage(client, payload) {\n' +
|
|
142
|
-
" return 'Hello world!';\n" +
|
|
143
|
-
' }\n' +
|
|
144
|
-
'}\n',
|
|
145
|
-
);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { join, Path, strings } from '@angular-devkit/core';
|
|
2
|
-
import {
|
|
3
|
-
apply,
|
|
4
|
-
branchAndMerge,
|
|
5
|
-
chain,
|
|
6
|
-
filter,
|
|
7
|
-
mergeWith,
|
|
8
|
-
move,
|
|
9
|
-
noop,
|
|
10
|
-
Rule,
|
|
11
|
-
SchematicContext,
|
|
12
|
-
SchematicsException,
|
|
13
|
-
Source,
|
|
14
|
-
template,
|
|
15
|
-
Tree,
|
|
16
|
-
url,
|
|
17
|
-
} from '@angular-devkit/schematics';
|
|
18
|
-
import {
|
|
19
|
-
DeclarationOptions,
|
|
20
|
-
ModuleDeclarator,
|
|
21
|
-
} from '../../utils/module.declarator';
|
|
22
|
-
import { ModuleFinder } from '../../utils/module.finder';
|
|
23
|
-
import { Location, NameParser } from '../../utils/name.parser';
|
|
24
|
-
import { mergeSourceRoot } from '../../utils/source-root.helpers';
|
|
25
|
-
import { ProviderOptions } from '../provider/provider.schema';
|
|
26
|
-
import { GatewayOptions } from './gateway.schema';
|
|
27
|
-
|
|
28
|
-
export function main(options: GatewayOptions): Rule {
|
|
29
|
-
options = transform(options);
|
|
30
|
-
return (tree: Tree, context: SchematicContext) => {
|
|
31
|
-
return branchAndMerge(
|
|
32
|
-
chain([
|
|
33
|
-
mergeSourceRoot(options),
|
|
34
|
-
addDeclarationToModule(options),
|
|
35
|
-
mergeWith(generate(options)),
|
|
36
|
-
]),
|
|
37
|
-
)(tree, context);
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function transform(options: GatewayOptions): GatewayOptions {
|
|
42
|
-
const target: GatewayOptions = Object.assign({}, options);
|
|
43
|
-
if (!target.name) {
|
|
44
|
-
throw new SchematicsException('Option (name) is required.');
|
|
45
|
-
}
|
|
46
|
-
target.metadata = 'providers';
|
|
47
|
-
target.type = 'gateway';
|
|
48
|
-
|
|
49
|
-
const location: Location = new NameParser().parse(target);
|
|
50
|
-
target.name = strings.dasherize(location.name);
|
|
51
|
-
target.path = strings.dasherize(location.path);
|
|
52
|
-
target.language = target.language !== undefined ? target.language : 'ts';
|
|
53
|
-
|
|
54
|
-
target.path = target.flat
|
|
55
|
-
? target.path
|
|
56
|
-
: join(target.path as Path, target.name);
|
|
57
|
-
return target;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function generate(options: GatewayOptions): Source {
|
|
61
|
-
return (context: SchematicContext) =>
|
|
62
|
-
apply(url(join('./files' as Path, options.language)), [
|
|
63
|
-
options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
|
|
64
|
-
template({
|
|
65
|
-
...strings,
|
|
66
|
-
...options,
|
|
67
|
-
}),
|
|
68
|
-
move(options.path),
|
|
69
|
-
])(context);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function addDeclarationToModule(options: ProviderOptions): Rule {
|
|
73
|
-
return (tree: Tree) => {
|
|
74
|
-
if (options.skipImport !== undefined && options.skipImport) {
|
|
75
|
-
return tree;
|
|
76
|
-
}
|
|
77
|
-
options.module = new ModuleFinder(tree).find({
|
|
78
|
-
name: options.name,
|
|
79
|
-
path: options.path as Path,
|
|
80
|
-
});
|
|
81
|
-
if (!options.module) {
|
|
82
|
-
return tree;
|
|
83
|
-
}
|
|
84
|
-
const content = tree.read(options.module).toString();
|
|
85
|
-
const declarator: ModuleDeclarator = new ModuleDeclarator();
|
|
86
|
-
tree.overwrite(
|
|
87
|
-
options.module,
|
|
88
|
-
declarator.declare(content, options as DeclarationOptions),
|
|
89
|
-
);
|
|
90
|
-
return tree;
|
|
91
|
-
};
|
|
92
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Path } from '@angular-devkit/core';
|
|
2
|
-
|
|
3
|
-
export interface GatewayOptions {
|
|
4
|
-
/**
|
|
5
|
-
* The name of the gateway.
|
|
6
|
-
*/
|
|
7
|
-
name: string;
|
|
8
|
-
/**
|
|
9
|
-
* The path to create the gateway.
|
|
10
|
-
*/
|
|
11
|
-
path?: string | Path;
|
|
12
|
-
/**
|
|
13
|
-
* Application language.
|
|
14
|
-
*/
|
|
15
|
-
language?: string;
|
|
16
|
-
/**
|
|
17
|
-
* The source root path
|
|
18
|
-
*/
|
|
19
|
-
sourceRoot?: string;
|
|
20
|
-
/**
|
|
21
|
-
* Specifies if a spec file is generated.
|
|
22
|
-
*/
|
|
23
|
-
spec?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Flag to indicate if a directory is created.
|
|
26
|
-
*/
|
|
27
|
-
flat?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* Metadata name affected by declaration insertion.
|
|
30
|
-
*/
|
|
31
|
-
metadata?: string;
|
|
32
|
-
/**
|
|
33
|
-
* Nest element type name
|
|
34
|
-
*/
|
|
35
|
-
type?: string;
|
|
36
|
-
}
|
package/lib/gateway/schema.json
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"id": "SchematicsNestGateway",
|
|
4
|
-
"title": "Nest Gateway Options Schema",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"name": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"description": "The name of the gateway.",
|
|
10
|
-
"$default": {
|
|
11
|
-
"$source": "argv",
|
|
12
|
-
"index": 0
|
|
13
|
-
},
|
|
14
|
-
"x-prompt": "What name would you like to use for the gateway?"
|
|
15
|
-
},
|
|
16
|
-
"path": {
|
|
17
|
-
"type": "string",
|
|
18
|
-
"format": "path",
|
|
19
|
-
"description": "The path to create the gateway."
|
|
20
|
-
},
|
|
21
|
-
"language": {
|
|
22
|
-
"type": "string",
|
|
23
|
-
"description": "Nest gateway language (ts/js)."
|
|
24
|
-
},
|
|
25
|
-
"sourceRoot": {
|
|
26
|
-
"type": "string",
|
|
27
|
-
"description": "Nest gateway source root directory."
|
|
28
|
-
},
|
|
29
|
-
"flat": {
|
|
30
|
-
"default": true,
|
|
31
|
-
"description": "Flag to indicate if a directory is created."
|
|
32
|
-
},
|
|
33
|
-
"spec": {
|
|
34
|
-
"default": true,
|
|
35
|
-
"description": "Specifies if a spec file is generated."
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"required": ["name"]
|
|
39
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export interface <%= classify(name) %> {}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main = void 0;
|
|
4
|
-
const core_1 = require("@angular-devkit/core");
|
|
5
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
|
-
const name_parser_1 = require("../../utils/name.parser");
|
|
7
|
-
const source_root_helpers_1 = require("../../utils/source-root.helpers");
|
|
8
|
-
function main(options) {
|
|
9
|
-
options = transform(options);
|
|
10
|
-
return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
|
|
11
|
-
}
|
|
12
|
-
exports.main = main;
|
|
13
|
-
function transform(options) {
|
|
14
|
-
const target = Object.assign({}, options);
|
|
15
|
-
if (!target.name) {
|
|
16
|
-
throw new schematics_1.SchematicsException('Option (name) is required.');
|
|
17
|
-
}
|
|
18
|
-
const location = new name_parser_1.NameParser().parse(target);
|
|
19
|
-
target.name = core_1.strings.dasherize(location.name);
|
|
20
|
-
target.path = core_1.strings.dasherize(location.path);
|
|
21
|
-
target.path = target.flat
|
|
22
|
-
? target.path
|
|
23
|
-
: (0, core_1.join)(target.path, target.name);
|
|
24
|
-
return target;
|
|
25
|
-
}
|
|
26
|
-
function generate(options) {
|
|
27
|
-
return (context) => (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
28
|
-
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
29
|
-
(0, schematics_1.move)(options.path),
|
|
30
|
-
])(context);
|
|
31
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SchematicTestRunner,
|
|
3
|
-
UnitTestTree,
|
|
4
|
-
} from '@angular-devkit/schematics/testing';
|
|
5
|
-
import * as path from 'path';
|
|
6
|
-
import { InterfaceOptions } from './interface.schema';
|
|
7
|
-
|
|
8
|
-
describe('Interface Factory', () => {
|
|
9
|
-
const runner: SchematicTestRunner = new SchematicTestRunner(
|
|
10
|
-
'.',
|
|
11
|
-
path.join(process.cwd(), 'src/collection.json'),
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
it('should manage name only', () => {
|
|
15
|
-
const options: InterfaceOptions = {
|
|
16
|
-
name: 'foo',
|
|
17
|
-
};
|
|
18
|
-
const tree: UnitTestTree = runner.runSchematic('interface', options);
|
|
19
|
-
const files: string[] = tree.files;
|
|
20
|
-
expect(
|
|
21
|
-
files.find(filename => filename === '/foo.interface.ts'),
|
|
22
|
-
).toBeDefined();
|
|
23
|
-
expect(tree.readContent('/foo.interface.ts')).toEqual(
|
|
24
|
-
'export interface Foo {}\n',
|
|
25
|
-
);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('should manage name as a path', () => {
|
|
29
|
-
const options: InterfaceOptions = {
|
|
30
|
-
name: 'bar/foo',
|
|
31
|
-
};
|
|
32
|
-
const tree: UnitTestTree = runner.runSchematic('interface', options);
|
|
33
|
-
const files: string[] = tree.files;
|
|
34
|
-
expect(
|
|
35
|
-
files.find(filename => filename === '/bar/foo.interface.ts'),
|
|
36
|
-
).toBeDefined();
|
|
37
|
-
expect(tree.readContent('/bar/foo.interface.ts')).toEqual(
|
|
38
|
-
'export interface Foo {}\n',
|
|
39
|
-
);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should manage name and path', () => {
|
|
43
|
-
const options: InterfaceOptions = {
|
|
44
|
-
name: 'foo',
|
|
45
|
-
path: 'baz',
|
|
46
|
-
};
|
|
47
|
-
const tree: UnitTestTree = runner.runSchematic('interface', options);
|
|
48
|
-
const files: string[] = tree.files;
|
|
49
|
-
expect(
|
|
50
|
-
files.find(filename => filename === '/baz/foo.interface.ts'),
|
|
51
|
-
).toBeDefined();
|
|
52
|
-
expect(tree.readContent('/baz/foo.interface.ts')).toEqual(
|
|
53
|
-
'export interface Foo {}\n',
|
|
54
|
-
);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('should manage name to dasherize', () => {
|
|
58
|
-
const options: InterfaceOptions = {
|
|
59
|
-
name: 'fooBar',
|
|
60
|
-
};
|
|
61
|
-
const tree: UnitTestTree = runner.runSchematic('interface', options);
|
|
62
|
-
const files: string[] = tree.files;
|
|
63
|
-
expect(
|
|
64
|
-
files.find(filename => filename === '/foo-bar.interface.ts'),
|
|
65
|
-
).toBeDefined();
|
|
66
|
-
expect(tree.readContent('/foo-bar.interface.ts')).toEqual(
|
|
67
|
-
'export interface FooBar {}\n',
|
|
68
|
-
);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it('should manage path to dasherize', () => {
|
|
72
|
-
const options: InterfaceOptions = {
|
|
73
|
-
name: 'barBaz/foo',
|
|
74
|
-
};
|
|
75
|
-
const tree: UnitTestTree = runner.runSchematic('interface', options);
|
|
76
|
-
const files: string[] = tree.files;
|
|
77
|
-
expect(
|
|
78
|
-
files.find(filename => filename === '/bar-baz/foo.interface.ts'),
|
|
79
|
-
).toBeDefined();
|
|
80
|
-
expect(tree.readContent('/bar-baz/foo.interface.ts')).toEqual(
|
|
81
|
-
'export interface Foo {}\n',
|
|
82
|
-
);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { join, Path, strings } from '@angular-devkit/core';
|
|
2
|
-
import {
|
|
3
|
-
apply,
|
|
4
|
-
chain,
|
|
5
|
-
mergeWith,
|
|
6
|
-
move,
|
|
7
|
-
Rule,
|
|
8
|
-
SchematicContext,
|
|
9
|
-
SchematicsException,
|
|
10
|
-
Source,
|
|
11
|
-
template,
|
|
12
|
-
url,
|
|
13
|
-
} from '@angular-devkit/schematics';
|
|
14
|
-
import { Location, NameParser } from '../../utils/name.parser';
|
|
15
|
-
import { mergeSourceRoot } from '../../utils/source-root.helpers';
|
|
16
|
-
import { InterfaceOptions } from './interface.schema';
|
|
17
|
-
|
|
18
|
-
export function main(options: InterfaceOptions): Rule {
|
|
19
|
-
options = transform(options);
|
|
20
|
-
return chain([mergeSourceRoot(options), mergeWith(generate(options))]);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function transform(options: InterfaceOptions): InterfaceOptions {
|
|
24
|
-
const target: InterfaceOptions = Object.assign({}, options);
|
|
25
|
-
if (!target.name) {
|
|
26
|
-
throw new SchematicsException('Option (name) is required.');
|
|
27
|
-
}
|
|
28
|
-
const location: Location = new NameParser().parse(target);
|
|
29
|
-
target.name = strings.dasherize(location.name);
|
|
30
|
-
target.path = strings.dasherize(location.path);
|
|
31
|
-
|
|
32
|
-
target.path = target.flat
|
|
33
|
-
? target.path
|
|
34
|
-
: join(target.path as Path, target.name);
|
|
35
|
-
return target;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function generate(options: InterfaceOptions): Source {
|
|
39
|
-
return (context: SchematicContext) =>
|
|
40
|
-
apply(url('./files'), [
|
|
41
|
-
template({
|
|
42
|
-
...strings,
|
|
43
|
-
...options,
|
|
44
|
-
}),
|
|
45
|
-
move(options.path),
|
|
46
|
-
])(context);
|
|
47
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Path } from '@angular-devkit/core';
|
|
2
|
-
|
|
3
|
-
export interface InterfaceOptions {
|
|
4
|
-
/**
|
|
5
|
-
* The name of the interface.
|
|
6
|
-
*/
|
|
7
|
-
name: string;
|
|
8
|
-
/**
|
|
9
|
-
* The path to create the interface.
|
|
10
|
-
*/
|
|
11
|
-
path?: string | Path;
|
|
12
|
-
/**
|
|
13
|
-
* The source root path
|
|
14
|
-
*/
|
|
15
|
-
sourceRoot?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Flag to indicate if a directory is created.
|
|
18
|
-
*/
|
|
19
|
-
flat?: boolean;
|
|
20
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"id": "SchematicsNestInterface",
|
|
4
|
-
"title": "Nest Interface Options Schema",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"name": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"description": "The name of the interface.",
|
|
10
|
-
"$default": {
|
|
11
|
-
"$source": "argv",
|
|
12
|
-
"index": 0
|
|
13
|
-
},
|
|
14
|
-
"x-prompt": "What name would you like to use for the interface?"
|
|
15
|
-
},
|
|
16
|
-
"path": {
|
|
17
|
-
"type": "string",
|
|
18
|
-
"format": "path",
|
|
19
|
-
"description": "The path to create the interface."
|
|
20
|
-
},
|
|
21
|
-
"sourceRoot": {
|
|
22
|
-
"type": "string",
|
|
23
|
-
"description": "Nest interface source root directory."
|
|
24
|
-
},
|
|
25
|
-
"flat": {
|
|
26
|
-
"default": true,
|
|
27
|
-
"description": "Flag to indicate if a directory is created."
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"required": ["name"]
|
|
31
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Test } from '@nestjs/testing';
|
|
2
|
-
import { <%= classify(name) %>Service } from './<%= name %>.service';
|
|
3
|
-
|
|
4
|
-
describe('<%= classify(name) %>Service', () => {
|
|
5
|
-
let service;
|
|
6
|
-
|
|
7
|
-
beforeEach(async () => {
|
|
8
|
-
const module = await Test.createTestingModule({
|
|
9
|
-
providers: [<%= classify(name) %>Service],
|
|
10
|
-
}).compile();
|
|
11
|
-
|
|
12
|
-
service = module.get(<%= classify(name) %>Service);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should be defined', () => {
|
|
16
|
-
expect(service).toBeDefined();
|
|
17
|
-
});
|
|
18
|
-
});
|