@rhtml/schematics 0.0.113 → 0.0.116
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/component/component.factory.js +10 -10
- package/dist/lib/component/component.factory.ts +7 -7
- package/dist/lib/module/module.factory.js +8 -8
- package/dist/lib/module/module.factory.ts +6 -6
- package/dist/lib/provider/provider.factory.js +9 -9
- package/dist/lib/provider/provider.factory.ts +7 -7
- package/dist/lib/service/service.factory.js +10 -10
- package/dist/lib/service/service.factory.ts +7 -7
- package/dist/utils/metadata.manager.js +7 -7
- package/dist/utils/metadata.manager.ts +11 -9
- package/dist/utils/module-import.declarator.js +4 -4
- package/dist/utils/module-import.declarator.ts +2 -2
- package/dist/utils/module.declarator.js +2 -2
- package/dist/utils/module.finder.js +2 -2
- package/dist/utils/module.finder.ts +1 -1
- package/dist/utils/name.parser.js +3 -3
- package/dist/utils/name.parser.ts +1 -1
- package/dist/utils/path.solver.js +2 -4
- package/dist/utils/path.solver.ts +2 -3
- package/dist/utils/source-root.helpers.js +3 -3
- package/dist/utils/source-root.helpers.ts +1 -1
- package/package.json +6 -13
- package/src/lib/component/component.factory.ts +7 -7
- package/src/lib/module/module.factory.ts +6 -6
- package/src/lib/provider/provider.factory.ts +7 -7
- package/src/lib/service/service.factory.ts +7 -7
- package/src/utils/metadata.manager.ts +11 -9
- package/src/utils/module-import.declarator.ts +2 -2
- package/src/utils/module.finder.ts +1 -1
- package/src/utils/name.parser.ts +1 -1
- package/src/utils/path.solver.ts +2 -3
- package/src/utils/source-root.helpers.ts +1 -1
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -26
- package/.prettierrc +0 -4
- package/jest.config.js +0 -16
|
@@ -21,14 +21,14 @@ function transform(source) {
|
|
|
21
21
|
target.language !== undefined ? target.language : defaults_1.DEFAULT_LANGUAGE;
|
|
22
22
|
target.path = target.flat
|
|
23
23
|
? target.path
|
|
24
|
-
: core_1.join(target.path, target.name);
|
|
24
|
+
: (0, core_1.join)(target.path, target.name);
|
|
25
25
|
return target;
|
|
26
26
|
}
|
|
27
27
|
function generate(options) {
|
|
28
|
-
return (context) => schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
|
|
29
|
-
options.spec ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('.spec.ts')),
|
|
30
|
-
schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
31
|
-
schematics_1.move(options.path)
|
|
28
|
+
return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
29
|
+
options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
|
|
30
|
+
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
31
|
+
(0, schematics_1.move)(options.path),
|
|
32
32
|
])(context);
|
|
33
33
|
}
|
|
34
34
|
function addDeclarationToModule(options) {
|
|
@@ -38,7 +38,7 @@ function addDeclarationToModule(options) {
|
|
|
38
38
|
}
|
|
39
39
|
options.module = new module_finder_1.ModuleFinder(tree).find({
|
|
40
40
|
name: options.name,
|
|
41
|
-
path: options.path
|
|
41
|
+
path: options.path,
|
|
42
42
|
});
|
|
43
43
|
if (!options.module) {
|
|
44
44
|
return tree;
|
|
@@ -52,10 +52,10 @@ function addDeclarationToModule(options) {
|
|
|
52
52
|
function main(options) {
|
|
53
53
|
options = transform(options);
|
|
54
54
|
return (tree, context) => {
|
|
55
|
-
return schematics_1.branchAndMerge(schematics_1.chain([
|
|
56
|
-
source_root_helpers_1.mergeSourceRoot(options),
|
|
57
|
-
schematics_1.mergeWith(generate(options)),
|
|
58
|
-
addDeclarationToModule(options)
|
|
55
|
+
return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
|
|
56
|
+
(0, source_root_helpers_1.mergeSourceRoot)(options),
|
|
57
|
+
(0, schematics_1.mergeWith)(generate(options)),
|
|
58
|
+
addDeclarationToModule(options),
|
|
59
59
|
]))(tree, context);
|
|
60
60
|
};
|
|
61
61
|
}
|
|
@@ -11,12 +11,12 @@ import {
|
|
|
11
11
|
SchematicContext,
|
|
12
12
|
template,
|
|
13
13
|
Tree,
|
|
14
|
-
url
|
|
14
|
+
url,
|
|
15
15
|
} from '@angular-devkit/schematics';
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
18
|
DeclarationOptions,
|
|
19
|
-
ModuleDeclarator
|
|
19
|
+
ModuleDeclarator,
|
|
20
20
|
} from '../../utils/module.declarator';
|
|
21
21
|
import { ModuleFinder } from '../../utils/module.finder';
|
|
22
22
|
import { Location, NameParser } from '../../utils/name.parser';
|
|
@@ -47,12 +47,12 @@ function transform(source: ControllerOptions): ControllerOptions {
|
|
|
47
47
|
function generate(options: ControllerOptions) {
|
|
48
48
|
return (context: SchematicContext) =>
|
|
49
49
|
apply(url(join('./files' as Path, options.language)), [
|
|
50
|
-
options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
|
|
50
|
+
options.spec ? noop() : filter((path) => !path.endsWith('.spec.ts')),
|
|
51
51
|
template({
|
|
52
52
|
...strings,
|
|
53
|
-
...options
|
|
53
|
+
...options,
|
|
54
54
|
}),
|
|
55
|
-
move(options.path)
|
|
55
|
+
move(options.path),
|
|
56
56
|
])(context);
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -63,7 +63,7 @@ function addDeclarationToModule(options: ControllerOptions): Rule {
|
|
|
63
63
|
}
|
|
64
64
|
options.module = new ModuleFinder(tree).find({
|
|
65
65
|
name: options.name,
|
|
66
|
-
path: options.path as Path
|
|
66
|
+
path: options.path as Path,
|
|
67
67
|
});
|
|
68
68
|
if (!options.module) {
|
|
69
69
|
return tree;
|
|
@@ -85,7 +85,7 @@ export function main(options: ControllerOptions): Rule {
|
|
|
85
85
|
chain([
|
|
86
86
|
mergeSourceRoot(options),
|
|
87
87
|
mergeWith(generate(options)),
|
|
88
|
-
addDeclarationToModule(options)
|
|
88
|
+
addDeclarationToModule(options),
|
|
89
89
|
])
|
|
90
90
|
)(tree, context);
|
|
91
91
|
};
|
|
@@ -10,10 +10,10 @@ const source_root_helpers_1 = require("../../utils/source-root.helpers");
|
|
|
10
10
|
function main(options) {
|
|
11
11
|
options = transform(options);
|
|
12
12
|
return (tree, context) => {
|
|
13
|
-
return schematics_1.branchAndMerge(schematics_1.chain([
|
|
14
|
-
source_root_helpers_1.mergeSourceRoot(options),
|
|
13
|
+
return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
|
|
14
|
+
(0, source_root_helpers_1.mergeSourceRoot)(options),
|
|
15
15
|
addDeclarationToModule(options),
|
|
16
|
-
schematics_1.mergeWith(generate(options))
|
|
16
|
+
(0, schematics_1.mergeWith)(generate(options)),
|
|
17
17
|
]))(tree, context);
|
|
18
18
|
};
|
|
19
19
|
}
|
|
@@ -24,14 +24,14 @@ function transform(source) {
|
|
|
24
24
|
target.type = 'module';
|
|
25
25
|
const location = new name_parser_1.NameParser().parse(target);
|
|
26
26
|
target.name = core_1.strings.dasherize(location.name);
|
|
27
|
-
target.path = core_1.join(core_1.strings.dasherize(location.path), target.name);
|
|
27
|
+
target.path = (0, core_1.join)(core_1.strings.dasherize(location.path), target.name);
|
|
28
28
|
target.language = target.language !== undefined ? target.language : 'ts';
|
|
29
29
|
return target;
|
|
30
30
|
}
|
|
31
31
|
function generate(options) {
|
|
32
|
-
return (context) => schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
|
|
33
|
-
schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
34
|
-
schematics_1.move(options.path)
|
|
32
|
+
return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
33
|
+
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
34
|
+
(0, schematics_1.move)(options.path),
|
|
35
35
|
])(context);
|
|
36
36
|
}
|
|
37
37
|
function addDeclarationToModule(options) {
|
|
@@ -41,7 +41,7 @@ function addDeclarationToModule(options) {
|
|
|
41
41
|
}
|
|
42
42
|
options.module = new module_finder_1.ModuleFinder(tree).find({
|
|
43
43
|
name: options.name,
|
|
44
|
-
path: options.path
|
|
44
|
+
path: options.path,
|
|
45
45
|
});
|
|
46
46
|
if (!options.module) {
|
|
47
47
|
return tree;
|
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
SchematicContext,
|
|
10
10
|
template,
|
|
11
11
|
Tree,
|
|
12
|
-
url
|
|
12
|
+
url,
|
|
13
13
|
} from '@angular-devkit/schematics';
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
16
|
DeclarationOptions,
|
|
17
|
-
ModuleDeclarator
|
|
17
|
+
ModuleDeclarator,
|
|
18
18
|
} from '../../utils/module.declarator';
|
|
19
19
|
import { ModuleFinder } from '../../utils/module.finder';
|
|
20
20
|
import { Location, NameParser } from '../../utils/name.parser';
|
|
@@ -28,7 +28,7 @@ export function main(options: ModuleOptions): Rule {
|
|
|
28
28
|
chain([
|
|
29
29
|
mergeSourceRoot(options),
|
|
30
30
|
addDeclarationToModule(options),
|
|
31
|
-
mergeWith(generate(options))
|
|
31
|
+
mergeWith(generate(options)),
|
|
32
32
|
])
|
|
33
33
|
)(tree, context);
|
|
34
34
|
};
|
|
@@ -51,9 +51,9 @@ function generate(options: ModuleOptions) {
|
|
|
51
51
|
apply(url(join('./files' as Path, options.language)), [
|
|
52
52
|
template({
|
|
53
53
|
...strings,
|
|
54
|
-
...options
|
|
54
|
+
...options,
|
|
55
55
|
}),
|
|
56
|
-
move(options.path)
|
|
56
|
+
move(options.path),
|
|
57
57
|
])(context);
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -64,7 +64,7 @@ function addDeclarationToModule(options: ModuleOptions): Rule {
|
|
|
64
64
|
}
|
|
65
65
|
options.module = new ModuleFinder(tree).find({
|
|
66
66
|
name: options.name,
|
|
67
|
-
path: options.path as Path
|
|
67
|
+
path: options.path as Path,
|
|
68
68
|
});
|
|
69
69
|
if (!options.module) {
|
|
70
70
|
return tree;
|
|
@@ -19,14 +19,14 @@ function transform(options) {
|
|
|
19
19
|
target.language = target.language !== undefined ? target.language : 'ts';
|
|
20
20
|
target.path = target.flat
|
|
21
21
|
? target.path
|
|
22
|
-
: core_1.join(target.path, target.name);
|
|
22
|
+
: (0, core_1.join)(target.path, target.name);
|
|
23
23
|
return target;
|
|
24
24
|
}
|
|
25
25
|
function generate(options) {
|
|
26
|
-
return (context) => schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
|
|
27
|
-
options.spec ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('.spec.ts')),
|
|
28
|
-
schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
29
|
-
schematics_1.move(options.path)
|
|
26
|
+
return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
27
|
+
options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
|
|
28
|
+
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
29
|
+
(0, schematics_1.move)(options.path),
|
|
30
30
|
])(context);
|
|
31
31
|
}
|
|
32
32
|
function addDeclarationToModule(options) {
|
|
@@ -36,7 +36,7 @@ function addDeclarationToModule(options) {
|
|
|
36
36
|
}
|
|
37
37
|
options.module = new module_finder_1.ModuleFinder(tree).find({
|
|
38
38
|
name: options.name,
|
|
39
|
-
path: options.path
|
|
39
|
+
path: options.path,
|
|
40
40
|
});
|
|
41
41
|
if (!options.module) {
|
|
42
42
|
return tree;
|
|
@@ -50,10 +50,10 @@ function addDeclarationToModule(options) {
|
|
|
50
50
|
function main(options) {
|
|
51
51
|
options = transform(options);
|
|
52
52
|
return (tree, context) => {
|
|
53
|
-
return schematics_1.branchAndMerge(schematics_1.chain([
|
|
54
|
-
source_root_helpers_1.mergeSourceRoot(options),
|
|
53
|
+
return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
|
|
54
|
+
(0, source_root_helpers_1.mergeSourceRoot)(options),
|
|
55
55
|
addDeclarationToModule(options),
|
|
56
|
-
schematics_1.mergeWith(generate(options))
|
|
56
|
+
(0, schematics_1.mergeWith)(generate(options)),
|
|
57
57
|
]))(tree, context);
|
|
58
58
|
};
|
|
59
59
|
}
|
|
@@ -12,12 +12,12 @@ import {
|
|
|
12
12
|
SchematicsException,
|
|
13
13
|
template,
|
|
14
14
|
Tree,
|
|
15
|
-
url
|
|
15
|
+
url,
|
|
16
16
|
} from '@angular-devkit/schematics';
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
19
|
DeclarationOptions,
|
|
20
|
-
ModuleDeclarator
|
|
20
|
+
ModuleDeclarator,
|
|
21
21
|
} from '../../utils/module.declarator';
|
|
22
22
|
import { ModuleFinder } from '../../utils/module.finder';
|
|
23
23
|
import { Location, NameParser } from '../../utils/name.parser';
|
|
@@ -45,12 +45,12 @@ function transform(options: ProviderOptions): ProviderOptions {
|
|
|
45
45
|
function generate(options: ProviderOptions) {
|
|
46
46
|
return (context: SchematicContext) =>
|
|
47
47
|
apply(url(join('./files' as Path, options.language)), [
|
|
48
|
-
options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
|
|
48
|
+
options.spec ? noop() : filter((path) => !path.endsWith('.spec.ts')),
|
|
49
49
|
template({
|
|
50
50
|
...strings,
|
|
51
|
-
...options
|
|
51
|
+
...options,
|
|
52
52
|
}),
|
|
53
|
-
move(options.path)
|
|
53
|
+
move(options.path),
|
|
54
54
|
])(context);
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -61,7 +61,7 @@ function addDeclarationToModule(options: ProviderOptions): Rule {
|
|
|
61
61
|
}
|
|
62
62
|
options.module = new ModuleFinder(tree).find({
|
|
63
63
|
name: options.name,
|
|
64
|
-
path: options.path as Path
|
|
64
|
+
path: options.path as Path,
|
|
65
65
|
});
|
|
66
66
|
if (!options.module) {
|
|
67
67
|
return tree;
|
|
@@ -83,7 +83,7 @@ export function main(options: ProviderOptions): Rule {
|
|
|
83
83
|
chain([
|
|
84
84
|
mergeSourceRoot(options),
|
|
85
85
|
addDeclarationToModule(options),
|
|
86
|
-
mergeWith(generate(options))
|
|
86
|
+
mergeWith(generate(options)),
|
|
87
87
|
])
|
|
88
88
|
)(tree, context);
|
|
89
89
|
};
|
|
@@ -15,7 +15,7 @@ function addDeclarationToModule(options) {
|
|
|
15
15
|
}
|
|
16
16
|
options.module = new module_finder_1.ModuleFinder(tree).find({
|
|
17
17
|
name: options.name,
|
|
18
|
-
path: options.path
|
|
18
|
+
path: options.path,
|
|
19
19
|
});
|
|
20
20
|
if (!options.module) {
|
|
21
21
|
return tree;
|
|
@@ -30,7 +30,7 @@ function transform(source) {
|
|
|
30
30
|
const target = Object.assign({}, source);
|
|
31
31
|
target.metadata = 'providers';
|
|
32
32
|
target.type = 'service';
|
|
33
|
-
if (util_1.isNullOrUndefined(target.name)) {
|
|
33
|
+
if ((0, util_1.isNullOrUndefined)(target.name)) {
|
|
34
34
|
throw new schematics_1.SchematicsException('Option (name) is required.');
|
|
35
35
|
}
|
|
36
36
|
const location = new name_parser_1.NameParser().parse(target);
|
|
@@ -39,23 +39,23 @@ function transform(source) {
|
|
|
39
39
|
target.language = target.language !== undefined ? target.language : 'ts';
|
|
40
40
|
target.path = target.flat
|
|
41
41
|
? target.path
|
|
42
|
-
: core_1.join(target.path, target.name);
|
|
42
|
+
: (0, core_1.join)(target.path, target.name);
|
|
43
43
|
return target;
|
|
44
44
|
}
|
|
45
45
|
function generate(options) {
|
|
46
|
-
return (context) => schematics_1.apply(schematics_1.url(core_1.join('./files', options.language)), [
|
|
47
|
-
options.spec ? schematics_1.noop() : schematics_1.filter(path => !path.endsWith('.spec.ts')),
|
|
48
|
-
schematics_1.template(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
49
|
-
schematics_1.move(options.path)
|
|
46
|
+
return (context) => (0, schematics_1.apply)((0, schematics_1.url)((0, core_1.join)('./files', options.language)), [
|
|
47
|
+
options.spec ? (0, schematics_1.noop)() : (0, schematics_1.filter)((path) => !path.endsWith('.spec.ts')),
|
|
48
|
+
(0, schematics_1.template)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
49
|
+
(0, schematics_1.move)(options.path),
|
|
50
50
|
])(context);
|
|
51
51
|
}
|
|
52
52
|
function main(options) {
|
|
53
53
|
options = transform(options);
|
|
54
54
|
return (tree, context) => {
|
|
55
|
-
return schematics_1.branchAndMerge(schematics_1.chain([
|
|
56
|
-
source_root_helpers_1.mergeSourceRoot(options),
|
|
55
|
+
return (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
|
|
56
|
+
(0, source_root_helpers_1.mergeSourceRoot)(options),
|
|
57
57
|
addDeclarationToModule(options),
|
|
58
|
-
schematics_1.mergeWith(generate(options))
|
|
58
|
+
(0, schematics_1.mergeWith)(generate(options)),
|
|
59
59
|
]))(tree, context);
|
|
60
60
|
};
|
|
61
61
|
}
|
|
@@ -12,13 +12,13 @@ import {
|
|
|
12
12
|
SchematicsException,
|
|
13
13
|
template,
|
|
14
14
|
Tree,
|
|
15
|
-
url
|
|
15
|
+
url,
|
|
16
16
|
} from '@angular-devkit/schematics';
|
|
17
17
|
import { isNullOrUndefined } from 'util';
|
|
18
18
|
|
|
19
19
|
import {
|
|
20
20
|
DeclarationOptions,
|
|
21
|
-
ModuleDeclarator
|
|
21
|
+
ModuleDeclarator,
|
|
22
22
|
} from '../../utils/module.declarator';
|
|
23
23
|
import { ModuleFinder } from '../../utils/module.finder';
|
|
24
24
|
import { Location, NameParser } from '../../utils/name.parser';
|
|
@@ -32,7 +32,7 @@ function addDeclarationToModule(options: ServiceOptions): Rule {
|
|
|
32
32
|
}
|
|
33
33
|
options.module = new ModuleFinder(tree).find({
|
|
34
34
|
name: options.name,
|
|
35
|
-
path: options.path as Path
|
|
35
|
+
path: options.path as Path,
|
|
36
36
|
});
|
|
37
37
|
if (!options.module) {
|
|
38
38
|
return tree;
|
|
@@ -69,12 +69,12 @@ function transform(source: ServiceOptions): ServiceOptions {
|
|
|
69
69
|
function generate(options: ServiceOptions) {
|
|
70
70
|
return (context: SchematicContext) =>
|
|
71
71
|
apply(url(join('./files' as Path, options.language)), [
|
|
72
|
-
options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
|
|
72
|
+
options.spec ? noop() : filter((path) => !path.endsWith('.spec.ts')),
|
|
73
73
|
template({
|
|
74
74
|
...strings,
|
|
75
|
-
...options
|
|
75
|
+
...options,
|
|
76
76
|
}),
|
|
77
|
-
move(options.path)
|
|
77
|
+
move(options.path),
|
|
78
78
|
])(context);
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -85,7 +85,7 @@ export function main(options: ServiceOptions): Rule {
|
|
|
85
85
|
chain([
|
|
86
86
|
mergeSourceRoot(options),
|
|
87
87
|
addDeclarationToModule(options),
|
|
88
|
-
mergeWith(generate(options))
|
|
88
|
+
mergeWith(generate(options)),
|
|
89
89
|
])
|
|
90
90
|
)(tree, context);
|
|
91
91
|
};
|
|
@@ -7,11 +7,11 @@ class MetadataManager {
|
|
|
7
7
|
this.content = content;
|
|
8
8
|
}
|
|
9
9
|
insert(metadata, symbol, staticOptions) {
|
|
10
|
-
const source = typescript_1.createSourceFile('filename.ts', this.content, typescript_1.ScriptTarget.ES2017);
|
|
10
|
+
const source = (0, typescript_1.createSourceFile)('filename.ts', this.content, typescript_1.ScriptTarget.ES2017);
|
|
11
11
|
const decoratorNodes = this.getDecoratorMetadata(source, '@Module');
|
|
12
12
|
const node = decoratorNodes[0];
|
|
13
13
|
const matchingProperties = node.properties
|
|
14
|
-
.filter(prop => prop.kind === typescript_1.SyntaxKind.PropertyAssignment)
|
|
14
|
+
.filter((prop) => prop.kind === typescript_1.SyntaxKind.PropertyAssignment)
|
|
15
15
|
.filter((prop) => {
|
|
16
16
|
const name = prop.name;
|
|
17
17
|
switch (name.kind) {
|
|
@@ -45,12 +45,12 @@ class MetadataManager {
|
|
|
45
45
|
getDecoratorMetadata(source, identifier) {
|
|
46
46
|
identifier;
|
|
47
47
|
return this.getSourceNodes(source)
|
|
48
|
-
.filter(node => node.kind === typescript_1.SyntaxKind.Decorator &&
|
|
48
|
+
.filter((node) => node.kind === typescript_1.SyntaxKind.Decorator &&
|
|
49
49
|
node.expression.kind === typescript_1.SyntaxKind.CallExpression)
|
|
50
|
-
.map(node => node.expression)
|
|
51
|
-
.filter(expr => expr.arguments[0] &&
|
|
50
|
+
.map((node) => node.expression)
|
|
51
|
+
.filter((expr) => expr.arguments[0] &&
|
|
52
52
|
expr.arguments[0].kind === typescript_1.SyntaxKind.ObjectLiteralExpression)
|
|
53
|
-
.map(expr => expr.arguments[0]);
|
|
53
|
+
.map((expr) => expr.arguments[0]);
|
|
54
54
|
}
|
|
55
55
|
getSourceNodes(sourceFile) {
|
|
56
56
|
const nodes = [sourceFile];
|
|
@@ -111,7 +111,7 @@ class MetadataManager {
|
|
|
111
111
|
}
|
|
112
112
|
if (Array.isArray(node)) {
|
|
113
113
|
const nodeArray = node;
|
|
114
|
-
const symbolsArray = nodeArray.map(childNode => childNode.getText(source));
|
|
114
|
+
const symbolsArray = nodeArray.map((childNode) => childNode.getText(source));
|
|
115
115
|
if (symbolsArray.includes(symbol)) {
|
|
116
116
|
return this.content;
|
|
117
117
|
}
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
ScriptTarget,
|
|
14
14
|
SourceFile,
|
|
15
15
|
StringLiteral,
|
|
16
|
-
SyntaxKind
|
|
16
|
+
SyntaxKind,
|
|
17
17
|
} from 'typescript';
|
|
18
18
|
|
|
19
19
|
import { DeclarationOptions } from './module.declarator';
|
|
@@ -33,8 +33,10 @@ export class MetadataManager {
|
|
|
33
33
|
);
|
|
34
34
|
const decoratorNodes: Node[] = this.getDecoratorMetadata(source, '@Module');
|
|
35
35
|
const node: Node = decoratorNodes[0];
|
|
36
|
-
const matchingProperties: ObjectLiteralElement[] = (
|
|
37
|
-
|
|
36
|
+
const matchingProperties: ObjectLiteralElement[] = (
|
|
37
|
+
node as ObjectLiteralExpression
|
|
38
|
+
).properties
|
|
39
|
+
.filter((prop) => prop.kind === SyntaxKind.PropertyAssignment)
|
|
38
40
|
.filter((prop: PropertyAssignment) => {
|
|
39
41
|
const name = prop.name;
|
|
40
42
|
switch (name.kind) {
|
|
@@ -83,17 +85,17 @@ export class MetadataManager {
|
|
|
83
85
|
identifier;
|
|
84
86
|
return this.getSourceNodes(source)
|
|
85
87
|
.filter(
|
|
86
|
-
node =>
|
|
88
|
+
(node) =>
|
|
87
89
|
node.kind === SyntaxKind.Decorator &&
|
|
88
90
|
(node as Decorator).expression.kind === SyntaxKind.CallExpression
|
|
89
91
|
)
|
|
90
|
-
.map(node => (node as Decorator).expression as CallExpression)
|
|
92
|
+
.map((node) => (node as Decorator).expression as CallExpression)
|
|
91
93
|
.filter(
|
|
92
|
-
expr =>
|
|
94
|
+
(expr) =>
|
|
93
95
|
expr.arguments[0] &&
|
|
94
96
|
expr.arguments[0].kind === SyntaxKind.ObjectLiteralExpression
|
|
95
97
|
)
|
|
96
|
-
.map(expr => expr.arguments[0] as ObjectLiteralExpression);
|
|
98
|
+
.map((expr) => expr.arguments[0] as ObjectLiteralExpression);
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
private getSourceNodes(sourceFile: SourceFile): Node[] {
|
|
@@ -167,8 +169,8 @@ export class MetadataManager {
|
|
|
167
169
|
node = arrLiteral.elements;
|
|
168
170
|
}
|
|
169
171
|
if (Array.isArray(node)) {
|
|
170
|
-
const nodeArray =
|
|
171
|
-
const symbolsArray = nodeArray.map(childNode =>
|
|
172
|
+
const nodeArray = node as {} as Node[];
|
|
173
|
+
const symbolsArray = nodeArray.map((childNode) =>
|
|
172
174
|
childNode.getText(source)
|
|
173
175
|
);
|
|
174
176
|
if (symbolsArray.includes(symbol)) {
|
|
@@ -15,10 +15,10 @@ class ModuleImportDeclarator {
|
|
|
15
15
|
return importLines.join('\n').concat(otherLines.join('\n'));
|
|
16
16
|
}
|
|
17
17
|
findImports(content) {
|
|
18
|
-
return content.split('\n').filter(line => line.match(/import {/));
|
|
18
|
+
return content.split('\n').filter((line) => line.match(/import {/));
|
|
19
19
|
}
|
|
20
20
|
findOtherLines(content, importLines) {
|
|
21
|
-
return content.split('\n').filter(line => importLines.indexOf(line) < 0);
|
|
21
|
+
return content.split('\n').filter((line) => importLines.indexOf(line) < 0);
|
|
22
22
|
}
|
|
23
23
|
buildLineToInsert(options) {
|
|
24
24
|
return `import { ${options.symbol} } from '${this.computeRelativePath(options)}';\n`;
|
|
@@ -26,10 +26,10 @@ class ModuleImportDeclarator {
|
|
|
26
26
|
computeRelativePath(options) {
|
|
27
27
|
let importModulePath;
|
|
28
28
|
if (options.type !== undefined) {
|
|
29
|
-
importModulePath = core_1.normalize(`/${options.path}/${options.name}.${options.type}`);
|
|
29
|
+
importModulePath = (0, core_1.normalize)(`/${options.path}/${options.name}.${options.type}`);
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
|
-
importModulePath = core_1.normalize(`/${options.path}/${options.name}`);
|
|
32
|
+
importModulePath = (0, core_1.normalize)(`/${options.path}/${options.name}`);
|
|
33
33
|
}
|
|
34
34
|
return this.solver.relative(options.module, importModulePath);
|
|
35
35
|
}
|
|
@@ -15,11 +15,11 @@ export class ModuleImportDeclarator {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
private findImports(content: string): string[] {
|
|
18
|
-
return content.split('\n').filter(line => line.match(/import {/));
|
|
18
|
+
return content.split('\n').filter((line) => line.match(/import {/));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
private findOtherLines(content: string, importLines: string[]) {
|
|
22
|
-
return content.split('\n').filter(line => importLines.indexOf(line) < 0);
|
|
22
|
+
return content.split('\n').filter((line) => importLines.indexOf(line) < 0);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
private buildLineToInsert(options: DeclarationOptions): string {
|
|
@@ -18,10 +18,10 @@ class ModuleDeclarator {
|
|
|
18
18
|
computeSymbol(options) {
|
|
19
19
|
const target = Object.assign({}, options);
|
|
20
20
|
if (options.type !== undefined) {
|
|
21
|
-
target.symbol = strings_1.classify(options.name).concat(strings_1.capitalize(options.type));
|
|
21
|
+
target.symbol = (0, strings_1.classify)(options.name).concat((0, strings_1.capitalize)(options.type));
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
|
-
target.symbol = strings_1.classify(options.name);
|
|
24
|
+
target.symbol = (0, strings_1.classify)(options.name);
|
|
25
25
|
}
|
|
26
26
|
return target;
|
|
27
27
|
}
|
|
@@ -15,9 +15,9 @@ class ModuleFinder {
|
|
|
15
15
|
if (!directory) {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
|
-
const moduleFilename = directory.subfiles.find(filename => /\.module\.(t|j)s/.test(filename));
|
|
18
|
+
const moduleFilename = directory.subfiles.find((filename) => /\.module\.(t|j)s/.test(filename));
|
|
19
19
|
return moduleFilename !== undefined
|
|
20
|
-
? core_1.join(directory.path, moduleFilename.valueOf())
|
|
20
|
+
? (0, core_1.join)(directory.path, moduleFilename.valueOf())
|
|
21
21
|
: this.findIn(directory.parent);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -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
|
|
@@ -4,13 +4,13 @@ exports.NameParser = void 0;
|
|
|
4
4
|
const core_1 = require("@angular-devkit/core");
|
|
5
5
|
class NameParser {
|
|
6
6
|
parse(options) {
|
|
7
|
-
const nameWithoutPath = core_1.basename(options.name);
|
|
8
|
-
const namePath = core_1.dirname((options.path === undefined ? '' : options.path)
|
|
7
|
+
const nameWithoutPath = (0, core_1.basename)(options.name);
|
|
8
|
+
const namePath = (0, core_1.dirname)((options.path === undefined ? '' : options.path)
|
|
9
9
|
.concat('/')
|
|
10
10
|
.concat(options.name));
|
|
11
11
|
return {
|
|
12
12
|
name: nameWithoutPath,
|
|
13
|
-
path: core_1.normalize('/'.concat(namePath))
|
|
13
|
+
path: (0, core_1.normalize)('/'.concat(namePath)),
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -5,10 +5,8 @@ const core_1 = require("@angular-devkit/core");
|
|
|
5
5
|
class PathSolver {
|
|
6
6
|
relative(from, to) {
|
|
7
7
|
const placeholder = '/placeholder';
|
|
8
|
-
const relativeDir = core_1.relative(core_1.dirname((placeholder + from)), core_1.dirname((placeholder + to)));
|
|
9
|
-
return (relativeDir.startsWith('.')
|
|
10
|
-
? relativeDir
|
|
11
|
-
: './' + relativeDir).concat(relativeDir.length === 0 ? core_1.basename(to) : '/' + core_1.basename(to));
|
|
8
|
+
const relativeDir = (0, core_1.relative)((0, core_1.dirname)((placeholder + from)), (0, core_1.dirname)((placeholder + to)));
|
|
9
|
+
return (relativeDir.startsWith('.') ? relativeDir : './' + relativeDir).concat(relativeDir.length === 0 ? (0, core_1.basename)(to) : '/' + (0, core_1.basename)(to));
|
|
12
10
|
}
|
|
13
11
|
}
|
|
14
12
|
exports.PathSolver = PathSolver;
|
|
@@ -7,9 +7,8 @@ export class PathSolver {
|
|
|
7
7
|
dirname((placeholder + from) as Path),
|
|
8
8
|
dirname((placeholder + to) as Path)
|
|
9
9
|
);
|
|
10
|
-
return (
|
|
11
|
-
? relativeDir
|
|
12
|
-
: './' + relativeDir
|
|
10
|
+
return (
|
|
11
|
+
relativeDir.startsWith('.') ? relativeDir : './' + relativeDir
|
|
13
12
|
).concat(relativeDir.length === 0 ? basename(to) : '/' + basename(to));
|
|
14
13
|
}
|
|
15
14
|
}
|
|
@@ -5,7 +5,7 @@ const core_1 = require("@angular-devkit/core");
|
|
|
5
5
|
const defaults_1 = require("../lib/defaults");
|
|
6
6
|
function isInRootDirectory(host, extraFiles = []) {
|
|
7
7
|
const files = ['nest-cli.json', 'nest.json'].concat(extraFiles || []);
|
|
8
|
-
return files.map(file => host.exists(file)).some(isPresent => isPresent);
|
|
8
|
+
return files.map((file) => host.exists(file)).some((isPresent) => isPresent);
|
|
9
9
|
}
|
|
10
10
|
exports.isInRootDirectory = isInRootDirectory;
|
|
11
11
|
function mergeSourceRoot(options) {
|
|
@@ -17,8 +17,8 @@ function mergeSourceRoot(options) {
|
|
|
17
17
|
const defaultSourceRoot = options.sourceRoot !== undefined ? options.sourceRoot : defaults_1.DEFAULT_PATH_NAME;
|
|
18
18
|
options.path =
|
|
19
19
|
options.path !== undefined
|
|
20
|
-
? core_1.join(core_1.normalize(defaultSourceRoot), options.path)
|
|
21
|
-
: core_1.normalize(defaultSourceRoot);
|
|
20
|
+
? (0, core_1.join)((0, core_1.normalize)(defaultSourceRoot), options.path)
|
|
21
|
+
: (0, core_1.normalize)(defaultSourceRoot);
|
|
22
22
|
return host;
|
|
23
23
|
};
|
|
24
24
|
}
|
|
@@ -8,7 +8,7 @@ export function isInRootDirectory(
|
|
|
8
8
|
extraFiles: string[] = []
|
|
9
9
|
): boolean {
|
|
10
10
|
const files = ['nest-cli.json', 'nest.json'].concat(extraFiles || []);
|
|
11
|
-
return files.map(file => host.exists(file)).some(isPresent => isPresent);
|
|
11
|
+
return files.map((file) => host.exists(file)).some((isPresent) => isPresent);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export function mergeSourceRoot<
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rhtml/schematics",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.116",
|
|
4
4
|
"description": "Reactive HyperText Markup Language",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "npx parcel ./examples/index.html --out-dir build/examples",
|
|
7
7
|
"patch": "npm run build && npm version patch && npm publish --update-readme --access public && npm run delete-dist",
|
|
8
8
|
"delete-dist": "rm -rf dist",
|
|
9
9
|
"clean": "git clean -dxf",
|
|
10
|
-
"lint": "
|
|
11
|
-
"lint-fix": "
|
|
10
|
+
"lint": "echo LINT",
|
|
11
|
+
"lint-fix": "echo LINT-FIX",
|
|
12
|
+
"lint-old": "npx eslint . --ext .ts || true",
|
|
13
|
+
"lint-fix-old": "npx eslint . --fix --ext .ts",
|
|
12
14
|
"build": "rm -rf dist && tsc || true && rsync -a --prune-empty-dirs --include '*/' --include '*' --exclude '*' src/ dist/"
|
|
13
15
|
},
|
|
14
16
|
"dependencies": {
|
|
@@ -17,16 +19,7 @@
|
|
|
17
19
|
"@angular-devkit/schematics-cli": "^0.13.7",
|
|
18
20
|
"ts-morph": "^1.3.1"
|
|
19
21
|
},
|
|
20
|
-
"devDependencies": {
|
|
21
|
-
"eslint": "^6.7.2",
|
|
22
|
-
"eslint-config-prettier": "^6.7.0",
|
|
23
|
-
"eslint-plugin-prettier": "^3.1.1",
|
|
24
|
-
"eslint-plugin-simple-import-sort": "^5.0.0",
|
|
25
|
-
"@typescript-eslint/eslint-plugin": "^2.10.0",
|
|
26
|
-
"@typescript-eslint/parser": "^2.10.0",
|
|
27
|
-
"prettier": "^1.19.1",
|
|
28
|
-
"ts-jest": "25.2.1"
|
|
29
|
-
},
|
|
22
|
+
"devDependencies": {},
|
|
30
23
|
"repository": {
|
|
31
24
|
"type": "git",
|
|
32
25
|
"url": "git@github.com:rhtml/rhtml.git"
|
|
@@ -11,12 +11,12 @@ import {
|
|
|
11
11
|
SchematicContext,
|
|
12
12
|
template,
|
|
13
13
|
Tree,
|
|
14
|
-
url
|
|
14
|
+
url,
|
|
15
15
|
} from '@angular-devkit/schematics';
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
18
|
DeclarationOptions,
|
|
19
|
-
ModuleDeclarator
|
|
19
|
+
ModuleDeclarator,
|
|
20
20
|
} from '../../utils/module.declarator';
|
|
21
21
|
import { ModuleFinder } from '../../utils/module.finder';
|
|
22
22
|
import { Location, NameParser } from '../../utils/name.parser';
|
|
@@ -47,12 +47,12 @@ function transform(source: ControllerOptions): ControllerOptions {
|
|
|
47
47
|
function generate(options: ControllerOptions) {
|
|
48
48
|
return (context: SchematicContext) =>
|
|
49
49
|
apply(url(join('./files' as Path, options.language)), [
|
|
50
|
-
options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
|
|
50
|
+
options.spec ? noop() : filter((path) => !path.endsWith('.spec.ts')),
|
|
51
51
|
template({
|
|
52
52
|
...strings,
|
|
53
|
-
...options
|
|
53
|
+
...options,
|
|
54
54
|
}),
|
|
55
|
-
move(options.path)
|
|
55
|
+
move(options.path),
|
|
56
56
|
])(context);
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -63,7 +63,7 @@ function addDeclarationToModule(options: ControllerOptions): Rule {
|
|
|
63
63
|
}
|
|
64
64
|
options.module = new ModuleFinder(tree).find({
|
|
65
65
|
name: options.name,
|
|
66
|
-
path: options.path as Path
|
|
66
|
+
path: options.path as Path,
|
|
67
67
|
});
|
|
68
68
|
if (!options.module) {
|
|
69
69
|
return tree;
|
|
@@ -85,7 +85,7 @@ export function main(options: ControllerOptions): Rule {
|
|
|
85
85
|
chain([
|
|
86
86
|
mergeSourceRoot(options),
|
|
87
87
|
mergeWith(generate(options)),
|
|
88
|
-
addDeclarationToModule(options)
|
|
88
|
+
addDeclarationToModule(options),
|
|
89
89
|
])
|
|
90
90
|
)(tree, context);
|
|
91
91
|
};
|
|
@@ -9,12 +9,12 @@ import {
|
|
|
9
9
|
SchematicContext,
|
|
10
10
|
template,
|
|
11
11
|
Tree,
|
|
12
|
-
url
|
|
12
|
+
url,
|
|
13
13
|
} from '@angular-devkit/schematics';
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
16
|
DeclarationOptions,
|
|
17
|
-
ModuleDeclarator
|
|
17
|
+
ModuleDeclarator,
|
|
18
18
|
} from '../../utils/module.declarator';
|
|
19
19
|
import { ModuleFinder } from '../../utils/module.finder';
|
|
20
20
|
import { Location, NameParser } from '../../utils/name.parser';
|
|
@@ -28,7 +28,7 @@ export function main(options: ModuleOptions): Rule {
|
|
|
28
28
|
chain([
|
|
29
29
|
mergeSourceRoot(options),
|
|
30
30
|
addDeclarationToModule(options),
|
|
31
|
-
mergeWith(generate(options))
|
|
31
|
+
mergeWith(generate(options)),
|
|
32
32
|
])
|
|
33
33
|
)(tree, context);
|
|
34
34
|
};
|
|
@@ -51,9 +51,9 @@ function generate(options: ModuleOptions) {
|
|
|
51
51
|
apply(url(join('./files' as Path, options.language)), [
|
|
52
52
|
template({
|
|
53
53
|
...strings,
|
|
54
|
-
...options
|
|
54
|
+
...options,
|
|
55
55
|
}),
|
|
56
|
-
move(options.path)
|
|
56
|
+
move(options.path),
|
|
57
57
|
])(context);
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -64,7 +64,7 @@ function addDeclarationToModule(options: ModuleOptions): Rule {
|
|
|
64
64
|
}
|
|
65
65
|
options.module = new ModuleFinder(tree).find({
|
|
66
66
|
name: options.name,
|
|
67
|
-
path: options.path as Path
|
|
67
|
+
path: options.path as Path,
|
|
68
68
|
});
|
|
69
69
|
if (!options.module) {
|
|
70
70
|
return tree;
|
|
@@ -12,12 +12,12 @@ import {
|
|
|
12
12
|
SchematicsException,
|
|
13
13
|
template,
|
|
14
14
|
Tree,
|
|
15
|
-
url
|
|
15
|
+
url,
|
|
16
16
|
} from '@angular-devkit/schematics';
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
19
|
DeclarationOptions,
|
|
20
|
-
ModuleDeclarator
|
|
20
|
+
ModuleDeclarator,
|
|
21
21
|
} from '../../utils/module.declarator';
|
|
22
22
|
import { ModuleFinder } from '../../utils/module.finder';
|
|
23
23
|
import { Location, NameParser } from '../../utils/name.parser';
|
|
@@ -45,12 +45,12 @@ function transform(options: ProviderOptions): ProviderOptions {
|
|
|
45
45
|
function generate(options: ProviderOptions) {
|
|
46
46
|
return (context: SchematicContext) =>
|
|
47
47
|
apply(url(join('./files' as Path, options.language)), [
|
|
48
|
-
options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
|
|
48
|
+
options.spec ? noop() : filter((path) => !path.endsWith('.spec.ts')),
|
|
49
49
|
template({
|
|
50
50
|
...strings,
|
|
51
|
-
...options
|
|
51
|
+
...options,
|
|
52
52
|
}),
|
|
53
|
-
move(options.path)
|
|
53
|
+
move(options.path),
|
|
54
54
|
])(context);
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -61,7 +61,7 @@ function addDeclarationToModule(options: ProviderOptions): Rule {
|
|
|
61
61
|
}
|
|
62
62
|
options.module = new ModuleFinder(tree).find({
|
|
63
63
|
name: options.name,
|
|
64
|
-
path: options.path as Path
|
|
64
|
+
path: options.path as Path,
|
|
65
65
|
});
|
|
66
66
|
if (!options.module) {
|
|
67
67
|
return tree;
|
|
@@ -83,7 +83,7 @@ export function main(options: ProviderOptions): Rule {
|
|
|
83
83
|
chain([
|
|
84
84
|
mergeSourceRoot(options),
|
|
85
85
|
addDeclarationToModule(options),
|
|
86
|
-
mergeWith(generate(options))
|
|
86
|
+
mergeWith(generate(options)),
|
|
87
87
|
])
|
|
88
88
|
)(tree, context);
|
|
89
89
|
};
|
|
@@ -12,13 +12,13 @@ import {
|
|
|
12
12
|
SchematicsException,
|
|
13
13
|
template,
|
|
14
14
|
Tree,
|
|
15
|
-
url
|
|
15
|
+
url,
|
|
16
16
|
} from '@angular-devkit/schematics';
|
|
17
17
|
import { isNullOrUndefined } from 'util';
|
|
18
18
|
|
|
19
19
|
import {
|
|
20
20
|
DeclarationOptions,
|
|
21
|
-
ModuleDeclarator
|
|
21
|
+
ModuleDeclarator,
|
|
22
22
|
} from '../../utils/module.declarator';
|
|
23
23
|
import { ModuleFinder } from '../../utils/module.finder';
|
|
24
24
|
import { Location, NameParser } from '../../utils/name.parser';
|
|
@@ -32,7 +32,7 @@ function addDeclarationToModule(options: ServiceOptions): Rule {
|
|
|
32
32
|
}
|
|
33
33
|
options.module = new ModuleFinder(tree).find({
|
|
34
34
|
name: options.name,
|
|
35
|
-
path: options.path as Path
|
|
35
|
+
path: options.path as Path,
|
|
36
36
|
});
|
|
37
37
|
if (!options.module) {
|
|
38
38
|
return tree;
|
|
@@ -69,12 +69,12 @@ function transform(source: ServiceOptions): ServiceOptions {
|
|
|
69
69
|
function generate(options: ServiceOptions) {
|
|
70
70
|
return (context: SchematicContext) =>
|
|
71
71
|
apply(url(join('./files' as Path, options.language)), [
|
|
72
|
-
options.spec ? noop() : filter(path => !path.endsWith('.spec.ts')),
|
|
72
|
+
options.spec ? noop() : filter((path) => !path.endsWith('.spec.ts')),
|
|
73
73
|
template({
|
|
74
74
|
...strings,
|
|
75
|
-
...options
|
|
75
|
+
...options,
|
|
76
76
|
}),
|
|
77
|
-
move(options.path)
|
|
77
|
+
move(options.path),
|
|
78
78
|
])(context);
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -85,7 +85,7 @@ export function main(options: ServiceOptions): Rule {
|
|
|
85
85
|
chain([
|
|
86
86
|
mergeSourceRoot(options),
|
|
87
87
|
addDeclarationToModule(options),
|
|
88
|
-
mergeWith(generate(options))
|
|
88
|
+
mergeWith(generate(options)),
|
|
89
89
|
])
|
|
90
90
|
)(tree, context);
|
|
91
91
|
};
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
ScriptTarget,
|
|
14
14
|
SourceFile,
|
|
15
15
|
StringLiteral,
|
|
16
|
-
SyntaxKind
|
|
16
|
+
SyntaxKind,
|
|
17
17
|
} from 'typescript';
|
|
18
18
|
|
|
19
19
|
import { DeclarationOptions } from './module.declarator';
|
|
@@ -33,8 +33,10 @@ export class MetadataManager {
|
|
|
33
33
|
);
|
|
34
34
|
const decoratorNodes: Node[] = this.getDecoratorMetadata(source, '@Module');
|
|
35
35
|
const node: Node = decoratorNodes[0];
|
|
36
|
-
const matchingProperties: ObjectLiteralElement[] = (
|
|
37
|
-
|
|
36
|
+
const matchingProperties: ObjectLiteralElement[] = (
|
|
37
|
+
node as ObjectLiteralExpression
|
|
38
|
+
).properties
|
|
39
|
+
.filter((prop) => prop.kind === SyntaxKind.PropertyAssignment)
|
|
38
40
|
.filter((prop: PropertyAssignment) => {
|
|
39
41
|
const name = prop.name;
|
|
40
42
|
switch (name.kind) {
|
|
@@ -83,17 +85,17 @@ export class MetadataManager {
|
|
|
83
85
|
identifier;
|
|
84
86
|
return this.getSourceNodes(source)
|
|
85
87
|
.filter(
|
|
86
|
-
node =>
|
|
88
|
+
(node) =>
|
|
87
89
|
node.kind === SyntaxKind.Decorator &&
|
|
88
90
|
(node as Decorator).expression.kind === SyntaxKind.CallExpression
|
|
89
91
|
)
|
|
90
|
-
.map(node => (node as Decorator).expression as CallExpression)
|
|
92
|
+
.map((node) => (node as Decorator).expression as CallExpression)
|
|
91
93
|
.filter(
|
|
92
|
-
expr =>
|
|
94
|
+
(expr) =>
|
|
93
95
|
expr.arguments[0] &&
|
|
94
96
|
expr.arguments[0].kind === SyntaxKind.ObjectLiteralExpression
|
|
95
97
|
)
|
|
96
|
-
.map(expr => expr.arguments[0] as ObjectLiteralExpression);
|
|
98
|
+
.map((expr) => expr.arguments[0] as ObjectLiteralExpression);
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
private getSourceNodes(sourceFile: SourceFile): Node[] {
|
|
@@ -167,8 +169,8 @@ export class MetadataManager {
|
|
|
167
169
|
node = arrLiteral.elements;
|
|
168
170
|
}
|
|
169
171
|
if (Array.isArray(node)) {
|
|
170
|
-
const nodeArray =
|
|
171
|
-
const symbolsArray = nodeArray.map(childNode =>
|
|
172
|
+
const nodeArray = node as {} as Node[];
|
|
173
|
+
const symbolsArray = nodeArray.map((childNode) =>
|
|
172
174
|
childNode.getText(source)
|
|
173
175
|
);
|
|
174
176
|
if (symbolsArray.includes(symbol)) {
|
|
@@ -15,11 +15,11 @@ export class ModuleImportDeclarator {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
private findImports(content: string): string[] {
|
|
18
|
-
return content.split('\n').filter(line => line.match(/import {/));
|
|
18
|
+
return content.split('\n').filter((line) => line.match(/import {/));
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
private findOtherLines(content: string, importLines: string[]) {
|
|
22
|
-
return content.split('\n').filter(line => importLines.indexOf(line) < 0);
|
|
22
|
+
return content.split('\n').filter((line) => importLines.indexOf(line) < 0);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
private buildLineToInsert(options: DeclarationOptions): string {
|
|
@@ -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
package/src/utils/path.solver.ts
CHANGED
|
@@ -7,9 +7,8 @@ export class PathSolver {
|
|
|
7
7
|
dirname((placeholder + from) as Path),
|
|
8
8
|
dirname((placeholder + to) as Path)
|
|
9
9
|
);
|
|
10
|
-
return (
|
|
11
|
-
? relativeDir
|
|
12
|
-
: './' + relativeDir
|
|
10
|
+
return (
|
|
11
|
+
relativeDir.startsWith('.') ? relativeDir : './' + relativeDir
|
|
13
12
|
).concat(relativeDir.length === 0 ? basename(to) : '/' + basename(to));
|
|
14
13
|
}
|
|
15
14
|
}
|
|
@@ -8,7 +8,7 @@ export function isInRootDirectory(
|
|
|
8
8
|
extraFiles: string[] = []
|
|
9
9
|
): boolean {
|
|
10
10
|
const files = ['nest-cli.json', 'nest.json'].concat(extraFiles || []);
|
|
11
|
-
return files.map(file => host.exists(file)).some(isPresent => isPresent);
|
|
11
|
+
return files.map((file) => host.exists(file)).some((isPresent) => isPresent);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export function mergeSourceRoot<
|
package/.eslintignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
./src/lib/**/*
|
package/.eslintrc.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
// Specifies the ESLint parser
|
|
3
|
-
parser: "@typescript-eslint/parser",
|
|
4
|
-
extends: [
|
|
5
|
-
// Uses the recommended rules from the @typescript-eslint/eslint-plugin
|
|
6
|
-
"plugin:@typescript-eslint/recommended",
|
|
7
|
-
// Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
|
|
8
|
-
"prettier/@typescript-eslint",
|
|
9
|
-
// Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
|
|
10
|
-
"plugin:prettier/recommended"
|
|
11
|
-
],
|
|
12
|
-
parserOptions: {
|
|
13
|
-
// Allows for the parsing of modern ECMAScript features
|
|
14
|
-
ecmaVersion: 2018,
|
|
15
|
-
// Allows for the use of imports
|
|
16
|
-
sourceType: "module"
|
|
17
|
-
},
|
|
18
|
-
rules: {
|
|
19
|
-
"@typescript-eslint/explicit-function-return-type": 0,
|
|
20
|
-
"simple-import-sort/sort": "error",
|
|
21
|
-
"sort-imports": "off",
|
|
22
|
-
"import/order": "off",
|
|
23
|
-
"@typescript-eslint/camelcase": 0
|
|
24
|
-
},
|
|
25
|
-
plugins: ["simple-import-sort"]
|
|
26
|
-
};
|
package/.prettierrc
DELETED
package/jest.config.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
testEnvironment: 'node',
|
|
3
|
-
testPathIgnorePatterns: ['/node_modules/'],
|
|
4
|
-
coverageReporters: ['lcov', 'html'],
|
|
5
|
-
rootDir: './',
|
|
6
|
-
moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'node'],
|
|
7
|
-
globals: {
|
|
8
|
-
__DEV__: true
|
|
9
|
-
},
|
|
10
|
-
transform: {
|
|
11
|
-
'\\.(ts|tsx)$': 'ts-jest'
|
|
12
|
-
},
|
|
13
|
-
testRegex: '/src/.*\\.spec.(ts|tsx|js)$',
|
|
14
|
-
verbose: true,
|
|
15
|
-
collectCoverage: true
|
|
16
|
-
};
|