@gapi/schematics 1.8.169 → 1.8.171
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
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main =
|
|
3
|
+
exports.main = main;
|
|
4
4
|
const core_1 = require("@angular-devkit/core");
|
|
5
5
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
6
|
const defaults_1 = require("../defaults");
|
|
7
7
|
function main(options) {
|
|
8
8
|
options = transform(options);
|
|
9
|
-
return schematics_1.mergeWith(generate(options));
|
|
9
|
+
return (0, schematics_1.mergeWith)(generate(options));
|
|
10
10
|
}
|
|
11
|
-
exports.main = main;
|
|
12
11
|
function transform(options) {
|
|
13
12
|
const target = Object.assign({}, options);
|
|
14
13
|
target.author = !!target.author ? target.author : defaults_1.DEFAULT_AUTHOR;
|
|
@@ -28,8 +27,8 @@ function transform(options) {
|
|
|
28
27
|
return target;
|
|
29
28
|
}
|
|
30
29
|
function generate(options) {
|
|
31
|
-
return schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
|
|
32
|
-
schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
33
|
-
schematics_1.move(options.name),
|
|
30
|
+
return (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
31
|
+
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
32
|
+
(0, schematics_1.move)(options.name),
|
|
34
33
|
]);
|
|
35
34
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
SchematicTestRunner,
|
|
3
|
+
UnitTestTree,
|
|
4
|
+
} from '@angular-devkit/schematics/testing';
|
|
2
5
|
import * as path from 'path';
|
|
6
|
+
|
|
3
7
|
import { ApplicationOptions } from './application.schema';
|
|
4
8
|
|
|
5
9
|
describe('Application Factory', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main =
|
|
3
|
+
exports.main = main;
|
|
4
4
|
const core_1 = require("@angular-devkit/core");
|
|
5
5
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
6
|
const name_parser_1 = require("../../utils/name.parser");
|
|
@@ -8,9 +8,8 @@ const source_root_helpers_1 = require("../../utils/source-root.helpers");
|
|
|
8
8
|
const defaults_1 = require("../defaults");
|
|
9
9
|
function main(options) {
|
|
10
10
|
options = transform(options);
|
|
11
|
-
return schematics_1.chain([source_root_helpers_1.mergeSourceRoot(options), schematics_1.mergeWith(generate(options))]);
|
|
11
|
+
return (0, schematics_1.chain)([(0, source_root_helpers_1.mergeSourceRoot)(options), (0, schematics_1.mergeWith)(generate(options))]);
|
|
12
12
|
}
|
|
13
|
-
exports.main = main;
|
|
14
13
|
function transform(options) {
|
|
15
14
|
const target = Object.assign({}, options);
|
|
16
15
|
if (!target.name) {
|
|
@@ -23,13 +22,13 @@ function transform(options) {
|
|
|
23
22
|
target.path = core_1.strings.dasherize(location.path);
|
|
24
23
|
target.path = target.flat
|
|
25
24
|
? target.path
|
|
26
|
-
: core_1.join(target.path, target.name);
|
|
25
|
+
: (0, core_1.join)(target.path, target.name);
|
|
27
26
|
return target;
|
|
28
27
|
}
|
|
29
28
|
function generate(options) {
|
|
30
|
-
return (context) => schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
|
|
31
|
-
options.spec ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('.spec.ts')),
|
|
32
|
-
schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
33
|
-
schematics_1.move(options.path),
|
|
29
|
+
return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
30
|
+
options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
|
|
31
|
+
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
32
|
+
(0, schematics_1.move)(options.path),
|
|
34
33
|
])(context);
|
|
35
34
|
}
|
|
@@ -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 { ClassOptions } from './class.schema';
|
|
7
8
|
|
|
8
9
|
describe('Class Factory', () => {
|
|
@@ -19,7 +20,9 @@ describe('Class Factory', () => {
|
|
|
19
20
|
const tree: UnitTestTree = runner.runSchematic('class', options);
|
|
20
21
|
const files: string[] = tree.files;
|
|
21
22
|
|
|
22
|
-
expect(
|
|
23
|
+
expect(
|
|
24
|
+
files.find((filename) => filename === '/foo.ts'),
|
|
25
|
+
).not.toBeUndefined();
|
|
23
26
|
expect(tree.readContent('/foo.ts')).toEqual('export class Foo {}\n');
|
|
24
27
|
});
|
|
25
28
|
it('should manage name as a path', () => {
|
|
@@ -31,7 +34,7 @@ describe('Class Factory', () => {
|
|
|
31
34
|
const tree: UnitTestTree = runner.runSchematic('class', options);
|
|
32
35
|
const files: string[] = tree.files;
|
|
33
36
|
expect(
|
|
34
|
-
files.find(filename => filename === '/bar/foo/foo.ts'),
|
|
37
|
+
files.find((filename) => filename === '/bar/foo/foo.ts'),
|
|
35
38
|
).not.toBeUndefined();
|
|
36
39
|
expect(tree.readContent('/bar/foo/foo.ts')).toEqual(
|
|
37
40
|
'export class Foo {}\n',
|
|
@@ -47,7 +50,7 @@ describe('Class Factory', () => {
|
|
|
47
50
|
const tree: UnitTestTree = runner.runSchematic('class', options);
|
|
48
51
|
const files: string[] = tree.files;
|
|
49
52
|
expect(
|
|
50
|
-
files.find(filename => filename === '/baz/foo/foo.ts'),
|
|
53
|
+
files.find((filename) => filename === '/baz/foo/foo.ts'),
|
|
51
54
|
).not.toBeUndefined();
|
|
52
55
|
expect(tree.readContent('/baz/foo/foo.ts')).toEqual(
|
|
53
56
|
'export class Foo {}\n',
|
|
@@ -62,7 +65,7 @@ describe('Class Factory', () => {
|
|
|
62
65
|
const tree: UnitTestTree = runner.runSchematic('class', options);
|
|
63
66
|
const files: string[] = tree.files;
|
|
64
67
|
expect(
|
|
65
|
-
files.find(filename => filename === '/foo-bar/foo-bar.ts'),
|
|
68
|
+
files.find((filename) => filename === '/foo-bar/foo-bar.ts'),
|
|
66
69
|
).not.toBeUndefined();
|
|
67
70
|
expect(tree.readContent('/foo-bar/foo-bar.ts')).toEqual(
|
|
68
71
|
'export class FooBar {}\n',
|
|
@@ -77,7 +80,7 @@ describe('Class Factory', () => {
|
|
|
77
80
|
const tree: UnitTestTree = runner.runSchematic('class', options);
|
|
78
81
|
const files: string[] = tree.files;
|
|
79
82
|
expect(
|
|
80
|
-
files.find(filename => filename === '/bar-baz/foo/foo.ts'),
|
|
83
|
+
files.find((filename) => filename === '/bar-baz/foo/foo.ts'),
|
|
81
84
|
).not.toBeUndefined();
|
|
82
85
|
expect(tree.readContent('/bar-baz/foo/foo.ts')).toEqual(
|
|
83
86
|
'export class Foo {}\n',
|
|
@@ -93,7 +96,7 @@ describe('Class Factory', () => {
|
|
|
93
96
|
const tree: UnitTestTree = runner.runSchematic('class', options);
|
|
94
97
|
const files: string[] = tree.files;
|
|
95
98
|
expect(
|
|
96
|
-
files.find(filename => filename === '/foo/foo.js'),
|
|
99
|
+
files.find((filename) => filename === '/foo/foo.js'),
|
|
97
100
|
).not.toBeUndefined();
|
|
98
101
|
expect(tree.readContent('/foo/foo.js')).toEqual('export class Foo {}\n');
|
|
99
102
|
});
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
template,
|
|
14
14
|
url,
|
|
15
15
|
} from '@angular-devkit/schematics';
|
|
16
|
+
|
|
16
17
|
import { Location, NameParser } from '../../utils/name.parser';
|
|
17
18
|
import { mergeSourceRoot } from '../../utils/source-root.helpers';
|
|
18
19
|
import { DEFAULT_LANGUAGE } from '../defaults';
|
|
@@ -44,7 +45,7 @@ function transform(options: ClassOptions): ClassOptions {
|
|
|
44
45
|
function generate(options: ClassOptions): Source {
|
|
45
46
|
return (context: SchematicContext) =>
|
|
46
47
|
apply(url(join('./files' as Path, options.language)), [
|
|
47
|
-
options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
|
|
48
|
+
options.spec ? noop() : filter((path) => !path.endsWith('.spec.ts')),
|
|
48
49
|
template({
|
|
49
50
|
...strings,
|
|
50
51
|
...options,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main =
|
|
3
|
+
exports.main = main;
|
|
4
4
|
const core_1 = require("@angular-devkit/core");
|
|
5
5
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
6
|
const path_1 = require("path");
|
|
@@ -12,16 +12,15 @@ const source_root_helpers_1 = require("../../../utils/source-root.helpers");
|
|
|
12
12
|
function main(options) {
|
|
13
13
|
options = transform(options);
|
|
14
14
|
return (tree, context) => {
|
|
15
|
-
return schematics_1.branchAndMerge(schematics_1.chain([
|
|
15
|
+
return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
|
|
16
16
|
createAngularApplication(options),
|
|
17
|
-
source_root_helpers_1.mergeSourceRoot(options),
|
|
17
|
+
(0, source_root_helpers_1.mergeSourceRoot)(options),
|
|
18
18
|
addDeclarationToModule(options),
|
|
19
19
|
addGlobalPrefix(),
|
|
20
|
-
schematics_1.mergeWith(generate(options)),
|
|
20
|
+
(0, schematics_1.mergeWith)(generate(options)),
|
|
21
21
|
]))(tree, context);
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
exports.main = main;
|
|
25
24
|
function transform(source) {
|
|
26
25
|
const target = Object.assign({}, source);
|
|
27
26
|
target.directory = target.name ? core_1.strings.dasherize(target.name) : 'client';
|
|
@@ -30,20 +29,20 @@ function transform(source) {
|
|
|
30
29
|
target.type = 'module';
|
|
31
30
|
const location = new name_parser_1.NameParser().parse(target);
|
|
32
31
|
target.name = core_1.strings.dasherize(location.name);
|
|
33
|
-
target.path = path_1.join(core_1.strings.dasherize(location.path), target.name);
|
|
32
|
+
target.path = (0, path_1.join)(core_1.strings.dasherize(location.path), target.name);
|
|
34
33
|
return target;
|
|
35
34
|
}
|
|
36
35
|
function generate(options) {
|
|
37
|
-
return (context) => schematics_1.apply(schematics_1.url('./files'), [
|
|
38
|
-
schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
39
|
-
schematics_1.move(options.path),
|
|
36
|
+
return (context) => (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
37
|
+
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
38
|
+
(0, schematics_1.move)(options.path),
|
|
40
39
|
])(context);
|
|
41
40
|
}
|
|
42
41
|
function createAngularApplication(options) {
|
|
43
42
|
if (!options.initApp) {
|
|
44
|
-
return schematics_1.noop();
|
|
43
|
+
return (0, schematics_1.noop)();
|
|
45
44
|
}
|
|
46
|
-
return schematics_1.externalSchematic('@schematics/angular', 'ng-new', {
|
|
45
|
+
return (0, schematics_1.externalSchematic)('@schematics/angular', 'ng-new', {
|
|
47
46
|
name: options.directory,
|
|
48
47
|
version: '7.0.0',
|
|
49
48
|
});
|
|
@@ -84,8 +83,8 @@ function addGlobalPrefix() {
|
|
|
84
83
|
});
|
|
85
84
|
const tsFile = tsProject.addExistingSourceFile(mainFilePath);
|
|
86
85
|
const bootstrapFunction = tsFile.getFunction('bootstrap');
|
|
87
|
-
const listenStatement = bootstrapFunction.getStatement(node => node.getText().includes('listen'));
|
|
88
|
-
const setPrefixStatement = bootstrapFunction.getStatement(node => node.getText().includes('setGlobalPrefix'));
|
|
86
|
+
const listenStatement = bootstrapFunction.getStatement((node) => node.getText().includes('listen'));
|
|
87
|
+
const setPrefixStatement = bootstrapFunction.getStatement((node) => node.getText().includes('setGlobalPrefix'));
|
|
89
88
|
if (!listenStatement || setPrefixStatement) {
|
|
90
89
|
return tree;
|
|
91
90
|
}
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
import { join } from 'path';
|
|
17
17
|
import * as ts from 'ts-morph';
|
|
18
18
|
import { Path } from 'typescript';
|
|
19
|
+
|
|
19
20
|
import {
|
|
20
21
|
DeclarationOptions,
|
|
21
22
|
ModuleDeclarator,
|
|
@@ -88,7 +89,7 @@ function addDeclarationToModule(options: AngularOptions): Rule {
|
|
|
88
89
|
const declarator: ModuleDeclarator = new ModuleDeclarator();
|
|
89
90
|
|
|
90
91
|
const rootPath = `${options.directory}/dist/${options.directory}`;
|
|
91
|
-
const declarationOptions =
|
|
92
|
+
const declarationOptions = {
|
|
92
93
|
...options,
|
|
93
94
|
staticOptions: {
|
|
94
95
|
name: 'forRoot',
|
|
@@ -96,7 +97,7 @@ function addDeclarationToModule(options: AngularOptions): Rule {
|
|
|
96
97
|
rootPath,
|
|
97
98
|
},
|
|
98
99
|
},
|
|
99
|
-
} as unknown
|
|
100
|
+
} as unknown as DeclarationOptions;
|
|
100
101
|
tree.overwrite(
|
|
101
102
|
options.module,
|
|
102
103
|
declarator.declare(content, declarationOptions),
|
|
@@ -119,10 +120,10 @@ function addGlobalPrefix(): Rule {
|
|
|
119
120
|
});
|
|
120
121
|
const tsFile = tsProject.addExistingSourceFile(mainFilePath);
|
|
121
122
|
const bootstrapFunction = tsFile.getFunction('bootstrap');
|
|
122
|
-
const listenStatement = bootstrapFunction.getStatement(node =>
|
|
123
|
+
const listenStatement = bootstrapFunction.getStatement((node) =>
|
|
123
124
|
node.getText().includes('listen'),
|
|
124
125
|
);
|
|
125
|
-
const setPrefixStatement = bootstrapFunction.getStatement(node =>
|
|
126
|
+
const setPrefixStatement = bootstrapFunction.getStatement((node) =>
|
|
126
127
|
node.getText().includes('setGlobalPrefix'),
|
|
127
128
|
);
|
|
128
129
|
if (!listenStatement || setPrefixStatement) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Provider } from '@nestjs/common';
|
|
2
2
|
import { HttpAdapterHost } from '@nestjs/core';
|
|
3
|
+
|
|
3
4
|
import { AbstractLoader } from './loaders/abstract.loader';
|
|
4
5
|
import { ExpressLoader } from './loaders/express.loader';
|
|
5
6
|
import { FastifyLoader } from './loaders/fastify.loader';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { AbstractHttpAdapter } from '@nestjs/core';
|
|
3
|
+
|
|
3
4
|
import { loadPackage } from '../angular.utils';
|
|
4
5
|
import { AngularModuleOptions } from '../interfaces/angular-options.interface';
|
|
5
6
|
import { AbstractLoader } from './abstract.loader';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Injectable } from '@nestjs/common';
|
|
2
2
|
import { AbstractHttpAdapter } from '@nestjs/core';
|
|
3
3
|
import * as fs from 'fs';
|
|
4
|
+
|
|
4
5
|
import { loadPackage } from '../angular.utils';
|
|
5
6
|
import { AngularModuleOptions } from '../interfaces/angular-options.interface';
|
|
6
7
|
import { AbstractLoader } from './abstract.loader';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main =
|
|
3
|
+
exports.main = main;
|
|
4
4
|
const core_1 = require("@angular-devkit/core");
|
|
5
5
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
6
|
const module_declarator_1 = require("../../utils/module.declarator");
|
|
@@ -13,14 +13,13 @@ const ELEMENT_TYPE = 'component';
|
|
|
13
13
|
function main(options) {
|
|
14
14
|
options = transform(options);
|
|
15
15
|
return (tree, context) => {
|
|
16
|
-
return schematics_1.branchAndMerge(schematics_1.chain([
|
|
17
|
-
source_root_helpers_1.mergeSourceRoot(options),
|
|
18
|
-
schematics_1.mergeWith(generate(options)),
|
|
16
|
+
return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
|
|
17
|
+
(0, source_root_helpers_1.mergeSourceRoot)(options),
|
|
18
|
+
(0, schematics_1.mergeWith)(generate(options)),
|
|
19
19
|
addDeclarationToModule(options),
|
|
20
20
|
]))(tree, context);
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
exports.main = main;
|
|
24
23
|
function transform(source) {
|
|
25
24
|
const target = Object.assign({}, source);
|
|
26
25
|
target.metadata = ELEMENT_METADATA;
|
|
@@ -32,14 +31,14 @@ function transform(source) {
|
|
|
32
31
|
target.language !== undefined ? target.language : defaults_1.DEFAULT_LANGUAGE;
|
|
33
32
|
target.path = target.flat
|
|
34
33
|
? target.path
|
|
35
|
-
: core_1.join(target.path, target.name);
|
|
34
|
+
: (0, core_1.join)(target.path, target.name);
|
|
36
35
|
return target;
|
|
37
36
|
}
|
|
38
37
|
function generate(options) {
|
|
39
|
-
return (context) => schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
|
|
40
|
-
options.spec ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('.spec.ts')),
|
|
41
|
-
schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
42
|
-
schematics_1.move(options.path),
|
|
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),
|
|
43
42
|
])(context);
|
|
44
43
|
}
|
|
45
44
|
function addDeclarationToModule(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 './component.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 { Component } from '@rxdi/core';\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,
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main =
|
|
3
|
+
exports.main = main;
|
|
4
4
|
const core_1 = require("@angular-devkit/core");
|
|
5
5
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
6
|
const defaults_1 = require("../defaults");
|
|
7
7
|
function main(options) {
|
|
8
|
-
return schematics_1.mergeWith(generate(transform(options)));
|
|
8
|
+
return (0, schematics_1.mergeWith)(generate(transform(options)));
|
|
9
9
|
}
|
|
10
|
-
exports.main = main;
|
|
11
10
|
function transform(options) {
|
|
12
11
|
const target = Object.assign({}, options);
|
|
13
12
|
target.language =
|
|
@@ -17,8 +16,8 @@ function transform(options) {
|
|
|
17
16
|
return target;
|
|
18
17
|
}
|
|
19
18
|
function generate(options) {
|
|
20
|
-
return schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
|
|
21
|
-
schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
22
|
-
schematics_1.move(options.project),
|
|
19
|
+
return (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
20
|
+
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
21
|
+
(0, schematics_1.move)(options.project),
|
|
23
22
|
]);
|
|
24
23
|
}
|
|
@@ -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 { ConfigurationOptions } from './configuration.schema';
|
|
7
8
|
|
|
8
9
|
describe('Configuration Factory', () => {
|
|
@@ -17,7 +18,7 @@ describe('Configuration Factory', () => {
|
|
|
17
18
|
const tree: UnitTestTree = runner.runSchematic('configuration', options);
|
|
18
19
|
const files: string[] = tree.files;
|
|
19
20
|
expect(
|
|
20
|
-
files.find(filename => filename === '/project/nest-cli.json'),
|
|
21
|
+
files.find((filename) => filename === '/project/nest-cli.json'),
|
|
21
22
|
).not.toBeUndefined();
|
|
22
23
|
expect(JSON.parse(tree.readContent('/project/nest-cli.json'))).toEqual({
|
|
23
24
|
language: 'ts',
|
|
@@ -33,7 +34,7 @@ describe('Configuration Factory', () => {
|
|
|
33
34
|
const tree: UnitTestTree = runner.runSchematic('configuration', options);
|
|
34
35
|
const files: string[] = tree.files;
|
|
35
36
|
expect(
|
|
36
|
-
files.find(filename => filename === '/project/nest-cli.json'),
|
|
37
|
+
files.find((filename) => filename === '/project/nest-cli.json'),
|
|
37
38
|
).not.toBeUndefined();
|
|
38
39
|
expect(JSON.parse(tree.readContent('/project/nest-cli.json'))).toEqual({
|
|
39
40
|
language: 'js',
|
|
@@ -49,7 +50,7 @@ describe('Configuration Factory', () => {
|
|
|
49
50
|
const tree: UnitTestTree = runner.runSchematic('configuration', options);
|
|
50
51
|
const files: string[] = tree.files;
|
|
51
52
|
expect(
|
|
52
|
-
files.find(filename => filename === '/project/nest-cli.json'),
|
|
53
|
+
files.find((filename) => filename === '/project/nest-cli.json'),
|
|
53
54
|
).not.toBeUndefined();
|
|
54
55
|
expect(JSON.parse(tree.readContent('/project/nest-cli.json'))).toEqual({
|
|
55
56
|
language: 'ts',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.main =
|
|
3
|
+
exports.main = main;
|
|
4
4
|
const core_1 = require("@angular-devkit/core");
|
|
5
5
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
6
6
|
const module_declarator_1 = require("../../utils/module.declarator");
|
|
@@ -13,14 +13,13 @@ const ELEMENT_TYPE = 'controller';
|
|
|
13
13
|
function main(options) {
|
|
14
14
|
options = transform(options);
|
|
15
15
|
return (tree, context) => {
|
|
16
|
-
return schematics_1.branchAndMerge(schematics_1.chain([
|
|
17
|
-
source_root_helpers_1.mergeSourceRoot(options),
|
|
18
|
-
schematics_1.mergeWith(generate(options)),
|
|
16
|
+
return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
|
|
17
|
+
(0, source_root_helpers_1.mergeSourceRoot)(options),
|
|
18
|
+
(0, schematics_1.mergeWith)(generate(options)),
|
|
19
19
|
addDeclarationToModule(options),
|
|
20
20
|
]))(tree, context);
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
exports.main = main;
|
|
24
23
|
function transform(source) {
|
|
25
24
|
const target = Object.assign({}, source);
|
|
26
25
|
target.metadata = ELEMENT_METADATA;
|
|
@@ -32,14 +31,14 @@ function transform(source) {
|
|
|
32
31
|
target.language !== undefined ? target.language : defaults_1.DEFAULT_LANGUAGE;
|
|
33
32
|
target.path = target.flat
|
|
34
33
|
? target.path
|
|
35
|
-
: core_1.join(target.path, target.name);
|
|
34
|
+
: (0, core_1.join)(target.path, target.name);
|
|
36
35
|
return target;
|
|
37
36
|
}
|
|
38
37
|
function generate(options) {
|
|
39
|
-
return (context) => schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
|
|
40
|
-
options.spec ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('.spec.ts')),
|
|
41
|
-
schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
42
|
-
schematics_1.move(options.path),
|
|
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),
|
|
43
42
|
])(context);
|
|
44
43
|
}
|
|
45
44
|
function addDeclarationToModule(options) {
|