@nestjs/schematics 11.0.9 → 12.0.0-alpha.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/dist/lib/application/files/js/package.json +10 -10
- package/dist/lib/application/files/ts/package.json +3 -3
- package/dist/lib/application/files/ts/tsconfig.json +0 -1
- package/dist/lib/application/files/ts-esm/.prettierrc +4 -0
- package/dist/lib/application/files/ts-esm/README.md +98 -0
- package/dist/lib/application/files/ts-esm/eslint.config.mjs +34 -0
- package/dist/lib/application/files/ts-esm/nest-cli.json +8 -0
- package/dist/lib/application/files/ts-esm/package.json +50 -0
- package/dist/lib/application/files/ts-esm/src/app.controller.__specFileSuffix__.ts +22 -0
- package/dist/lib/application/files/ts-esm/src/app.controller.ts +12 -0
- package/dist/lib/application/files/ts-esm/src/app.module.ts +10 -0
- package/dist/lib/application/files/ts-esm/src/app.service.ts +8 -0
- package/dist/lib/application/files/ts-esm/src/main.ts +8 -0
- package/dist/lib/application/files/ts-esm/test/app.e2e-__specFileSuffix__.ts +25 -0
- package/dist/lib/application/files/ts-esm/tsconfig.build.json +4 -0
- package/dist/lib/application/files/ts-esm/tsconfig.json +24 -0
- package/dist/lib/application/files/ts-esm/vitest.config.e2e.ts +10 -0
- package/dist/lib/application/files/ts-esm/vitest.config.ts +10 -0
- package/dist/lib/application/schema.json +14 -0
- package/dist/lib/library/files/ts/tsconfig.lib.json +1 -0
- package/dist/lib/sub-app/files/ts/tsconfig.app.json +1 -0
- package/dist/lib/sub-app/workspace/ts/tsconfig.app.json +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/{lib → src/lib}/application/application.factory.d.ts +1 -1
- package/dist/src/lib/application/application.factory.js +64 -0
- package/dist/{lib → src/lib}/class/class.factory.d.ts +1 -1
- package/dist/src/lib/class/class.factory.js +48 -0
- package/dist/{lib → src/lib}/client-app/angular/angular.factory.d.ts +1 -1
- package/dist/{lib → src/lib}/client-app/angular/angular.factory.js +23 -26
- package/dist/{lib → src/lib}/configuration/configuration.factory.d.ts +1 -1
- package/dist/src/lib/configuration/configuration.factory.js +24 -0
- package/dist/{lib → src/lib}/controller/controller.factory.d.ts +1 -1
- package/dist/src/lib/controller/controller.factory.js +69 -0
- package/dist/{lib → src/lib}/decorator/decorator.factory.d.ts +1 -1
- package/dist/src/lib/decorator/decorator.factory.js +32 -0
- package/dist/src/lib/defaults.js +14 -0
- package/dist/{lib → src/lib}/filter/filter.factory.d.ts +1 -1
- package/dist/src/lib/filter/filter.factory.js +40 -0
- package/dist/{lib → src/lib}/gateway/gateway.factory.d.ts +1 -1
- package/dist/src/lib/gateway/gateway.factory.js +69 -0
- package/dist/{lib → src/lib}/guard/guard.factory.d.ts +1 -1
- package/dist/src/lib/guard/guard.factory.js +40 -0
- package/dist/{lib → src/lib}/interceptor/interceptor.factory.d.ts +1 -1
- package/dist/src/lib/interceptor/interceptor.factory.js +41 -0
- package/dist/{lib → src/lib}/interface/interface.factory.d.ts +1 -1
- package/dist/src/lib/interface/interface.factory.js +31 -0
- package/dist/{lib → src/lib}/library/library.factory.d.ts +1 -1
- package/dist/{lib → src/lib}/library/library.factory.js +51 -64
- package/dist/{lib → src/lib}/middleware/middleware.factory.d.ts +1 -1
- package/dist/src/lib/middleware/middleware.factory.js +40 -0
- package/dist/{lib → src/lib}/module/module.factory.d.ts +1 -1
- package/dist/src/lib/module/module.factory.js +57 -0
- package/dist/{lib → src/lib}/pipe/pipe.factory.d.ts +1 -1
- package/dist/src/lib/pipe/pipe.factory.js +41 -0
- package/dist/{lib → src/lib}/provider/provider.factory.d.ts +1 -1
- package/dist/src/lib/provider/provider.factory.js +73 -0
- package/dist/{lib → src/lib}/readers/file-system.reader.d.ts +1 -1
- package/dist/{lib → src/lib}/readers/file-system.reader.js +3 -7
- package/dist/src/lib/readers/index.d.ts +2 -0
- package/dist/src/lib/readers/index.js +2 -0
- package/dist/src/lib/readers/reader.js +1 -0
- package/dist/{lib → src/lib}/resolver/resolver.factory.d.ts +1 -1
- package/dist/src/lib/resolver/resolver.factory.js +68 -0
- package/dist/{lib → src/lib}/resource/resource.factory.d.ts +1 -1
- package/dist/{lib → src/lib}/resource/resource.factory.js +35 -38
- package/dist/{lib → src/lib}/service/service.factory.d.ts +1 -1
- package/dist/src/lib/service/service.factory.js +71 -0
- package/dist/{lib → src/lib}/sub-app/sub-app.factory.d.ts +1 -1
- package/dist/{lib → src/lib}/sub-app/sub-app.factory.js +94 -69
- package/dist/{utils → src/utils}/dependencies.utils.js +7 -12
- package/dist/{utils → src/utils}/formatting.js +1 -4
- package/dist/src/utils/index.d.ts +11 -0
- package/dist/src/utils/index.js +11 -0
- package/dist/src/utils/jest-module-mapper.js +6 -0
- package/dist/{utils → src/utils}/json-file.util.js +9 -13
- package/dist/{utils → src/utils}/metadata.manager.d.ts +1 -1
- package/dist/{utils → src/utils}/metadata.manager.js +11 -15
- package/dist/{utils → src/utils}/module-import.declarator.d.ts +2 -2
- package/dist/{utils → src/utils}/module-import.declarator.js +6 -10
- package/dist/{utils → src/utils}/module-metadata.declarator.d.ts +1 -1
- package/dist/src/utils/module-metadata.declarator.js +8 -0
- package/dist/{utils → src/utils}/module.declarator.d.ts +2 -2
- package/dist/src/utils/module.declarator.js +30 -0
- package/dist/{utils → src/utils}/module.finder.js +3 -7
- package/dist/src/utils/name.parser.js +13 -0
- package/dist/{utils → src/utils}/object-sorting.js +1 -4
- package/dist/src/utils/path.solver.js +8 -0
- package/dist/src/utils/source-root.helpers.js +20 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +21 -49
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -18
- package/dist/lib/application/application.factory.js +0 -63
- package/dist/lib/class/class.factory.js +0 -51
- package/dist/lib/configuration/configuration.factory.js +0 -27
- package/dist/lib/controller/controller.factory.js +0 -72
- package/dist/lib/decorator/decorator.factory.js +0 -35
- package/dist/lib/defaults.js +0 -17
- package/dist/lib/filter/filter.factory.js +0 -43
- package/dist/lib/gateway/gateway.factory.js +0 -72
- package/dist/lib/guard/guard.factory.js +0 -43
- package/dist/lib/interceptor/interceptor.factory.js +0 -44
- package/dist/lib/interface/interface.factory.js +0 -34
- package/dist/lib/middleware/middleware.factory.js +0 -43
- package/dist/lib/module/module.factory.js +0 -60
- package/dist/lib/pipe/pipe.factory.js +0 -44
- package/dist/lib/provider/provider.factory.js +0 -76
- package/dist/lib/readers/index.d.ts +0 -2
- package/dist/lib/readers/index.js +0 -18
- package/dist/lib/readers/reader.js +0 -2
- package/dist/lib/resolver/resolver.factory.js +0 -71
- package/dist/lib/service/service.factory.js +0 -74
- package/dist/utils/index.d.ts +0 -11
- package/dist/utils/index.js +0 -27
- package/dist/utils/jest-module-mapper.js +0 -9
- package/dist/utils/module-metadata.declarator.js +0 -12
- package/dist/utils/module.declarator.js +0 -34
- package/dist/utils/name.parser.js +0 -17
- package/dist/utils/path.solver.js +0 -12
- package/dist/utils/source-root.helpers.js +0 -24
- /package/dist/{lib → src/lib}/defaults.d.ts +0 -0
- /package/dist/{lib → src/lib}/readers/reader.d.ts +0 -0
- /package/dist/{utils → src/utils}/dependencies.utils.d.ts +0 -0
- /package/dist/{utils → src/utils}/formatting.d.ts +0 -0
- /package/dist/{utils → src/utils}/jest-module-mapper.d.ts +0 -0
- /package/dist/{utils → src/utils}/json-file.util.d.ts +0 -0
- /package/dist/{utils → src/utils}/module.finder.d.ts +0 -0
- /package/dist/{utils → src/utils}/name.parser.d.ts +0 -0
- /package/dist/{utils → src/utils}/object-sorting.d.ts +0 -0
- /package/dist/{utils → src/utils}/path.solver.d.ts +0 -0
- /package/dist/{utils → src/utils}/source-root.helpers.d.ts +0 -0
|
@@ -1,57 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const name_parser_1 = require("../../../utils/name.parser");
|
|
10
|
-
const source_root_helpers_1 = require("../../../utils/source-root.helpers");
|
|
11
|
-
function main(options) {
|
|
1
|
+
import { strings } from '@angular-devkit/core';
|
|
2
|
+
import { apply, branchAndMerge, chain, externalSchematic, mergeWith, move, noop, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { ModuleDeclarator, } from '../../../utils/module.declarator.js';
|
|
5
|
+
import { ModuleFinder } from '../../../utils/module.finder.js';
|
|
6
|
+
import { NameParser } from '../../../utils/name.parser.js';
|
|
7
|
+
import { mergeSourceRoot } from '../../../utils/source-root.helpers.js';
|
|
8
|
+
export function main(options) {
|
|
12
9
|
options = transform(options);
|
|
13
10
|
return (tree, context) => {
|
|
14
|
-
return
|
|
11
|
+
return branchAndMerge(chain([
|
|
15
12
|
createAngularApplication(options),
|
|
16
|
-
|
|
13
|
+
mergeSourceRoot(options),
|
|
17
14
|
addDeclarationToModule(options),
|
|
18
15
|
addGlobalPrefix(),
|
|
19
|
-
|
|
16
|
+
mergeWith(generate(options)),
|
|
20
17
|
]))(tree, context);
|
|
21
18
|
};
|
|
22
19
|
}
|
|
23
20
|
function transform(source) {
|
|
24
21
|
const target = Object.assign({}, source);
|
|
25
|
-
target.directory = target.name ?
|
|
22
|
+
target.directory = target.name ? strings.dasherize(target.name) : 'client';
|
|
26
23
|
target.name = 'Angular';
|
|
27
24
|
target.metadata = 'imports';
|
|
28
25
|
target.type = 'module';
|
|
29
|
-
const location = new
|
|
30
|
-
target.name =
|
|
31
|
-
target.path =
|
|
26
|
+
const location = new NameParser().parse(target);
|
|
27
|
+
target.name = strings.dasherize(location.name);
|
|
28
|
+
target.path = join(strings.dasherize(location.path), target.name);
|
|
32
29
|
return target;
|
|
33
30
|
}
|
|
34
31
|
function generate(options) {
|
|
35
|
-
return (context) =>
|
|
36
|
-
|
|
37
|
-
...
|
|
32
|
+
return (context) => apply(url('./files'), [
|
|
33
|
+
template({
|
|
34
|
+
...strings,
|
|
38
35
|
...options,
|
|
39
36
|
}),
|
|
40
|
-
|
|
37
|
+
move(options.path),
|
|
41
38
|
])(context);
|
|
42
39
|
}
|
|
43
40
|
function createAngularApplication(options) {
|
|
44
41
|
if (!options.initApp) {
|
|
45
|
-
return
|
|
42
|
+
return noop();
|
|
46
43
|
}
|
|
47
|
-
return
|
|
44
|
+
return externalSchematic('@schematics/angular', 'ng-new', {
|
|
48
45
|
name: options.directory,
|
|
49
46
|
version: '8.0.0',
|
|
50
47
|
});
|
|
51
48
|
}
|
|
52
49
|
function addDeclarationToModule(options) {
|
|
53
50
|
return (tree) => {
|
|
54
|
-
options.module = new
|
|
51
|
+
options.module = new ModuleFinder(tree).find({
|
|
55
52
|
name: options.name,
|
|
56
53
|
path: options.path,
|
|
57
54
|
});
|
|
@@ -59,7 +56,7 @@ function addDeclarationToModule(options) {
|
|
|
59
56
|
return tree;
|
|
60
57
|
}
|
|
61
58
|
const content = tree.read(options.module).toString();
|
|
62
|
-
const declarator = new
|
|
59
|
+
const declarator = new ModuleDeclarator();
|
|
63
60
|
const rootPath = `${options.directory}/dist/${options.directory}`;
|
|
64
61
|
const staticOptions = {
|
|
65
62
|
name: 'forRoot',
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { join, strings } from '@angular-devkit/core';
|
|
2
|
+
import { apply, mergeWith, move, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { DEFAULT_LANGUAGE } from '../defaults.js';
|
|
4
|
+
export function main(options) {
|
|
5
|
+
return mergeWith(generate(transform(options)));
|
|
6
|
+
}
|
|
7
|
+
function transform(options) {
|
|
8
|
+
const target = Object.assign({}, options);
|
|
9
|
+
target.language =
|
|
10
|
+
target.language !== undefined ? target.language : DEFAULT_LANGUAGE;
|
|
11
|
+
target.collection =
|
|
12
|
+
target.collection !== undefined ? target.collection : '@nestjs/schematics';
|
|
13
|
+
return target;
|
|
14
|
+
}
|
|
15
|
+
function generate(options) {
|
|
16
|
+
const projectOrPath = options.project ?? '.';
|
|
17
|
+
return apply(url(join('./files', options.language)), [
|
|
18
|
+
template({
|
|
19
|
+
...strings,
|
|
20
|
+
...options,
|
|
21
|
+
}),
|
|
22
|
+
move(projectOrPath),
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { join, strings } from '@angular-devkit/core';
|
|
2
|
+
import { apply, branchAndMerge, chain, filter, mergeWith, move, noop, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
|
+
import { ModuleDeclarator, } from '../../utils/module.declarator.js';
|
|
5
|
+
import { ModuleFinder } from '../../utils/module.finder.js';
|
|
6
|
+
import { NameParser } from '../../utils/name.parser.js';
|
|
7
|
+
import { mergeSourceRoot } from '../../utils/source-root.helpers.js';
|
|
8
|
+
import { DEFAULT_LANGUAGE } from '../defaults.js';
|
|
9
|
+
const ELEMENT_METADATA = 'controllers';
|
|
10
|
+
const ELEMENT_TYPE = 'controller';
|
|
11
|
+
export function main(options) {
|
|
12
|
+
options = transform(options);
|
|
13
|
+
return (tree, context) => {
|
|
14
|
+
return branchAndMerge(chain([
|
|
15
|
+
mergeSourceRoot(options),
|
|
16
|
+
mergeWith(generate(options)),
|
|
17
|
+
addDeclarationToModule(options),
|
|
18
|
+
]))(tree, context);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function transform(source) {
|
|
22
|
+
const target = Object.assign({}, source);
|
|
23
|
+
target.metadata = ELEMENT_METADATA;
|
|
24
|
+
target.type = ELEMENT_TYPE;
|
|
25
|
+
const location = new NameParser().parse(target);
|
|
26
|
+
target.name = normalizeToKebabOrSnakeCase(location.name);
|
|
27
|
+
target.path = normalizeToKebabOrSnakeCase(location.path);
|
|
28
|
+
target.language =
|
|
29
|
+
target.language !== undefined ? target.language : DEFAULT_LANGUAGE;
|
|
30
|
+
target.specFileSuffix = normalizeToKebabOrSnakeCase(source.specFileSuffix || 'spec');
|
|
31
|
+
target.path = target.flat
|
|
32
|
+
? target.path
|
|
33
|
+
: join(target.path, target.name);
|
|
34
|
+
return target;
|
|
35
|
+
}
|
|
36
|
+
function generate(options) {
|
|
37
|
+
return (context) => apply(url(join('./files', options.language)), [
|
|
38
|
+
options.spec
|
|
39
|
+
? noop()
|
|
40
|
+
: filter((path) => {
|
|
41
|
+
const languageExtension = options.language || 'ts';
|
|
42
|
+
const suffix = `.__specFileSuffix__.${languageExtension}`;
|
|
43
|
+
return !path.endsWith(suffix);
|
|
44
|
+
}),
|
|
45
|
+
template({
|
|
46
|
+
...strings,
|
|
47
|
+
...options,
|
|
48
|
+
}),
|
|
49
|
+
move(options.path),
|
|
50
|
+
])(context);
|
|
51
|
+
}
|
|
52
|
+
function addDeclarationToModule(options) {
|
|
53
|
+
return (tree) => {
|
|
54
|
+
if (options.skipImport !== undefined && options.skipImport) {
|
|
55
|
+
return tree;
|
|
56
|
+
}
|
|
57
|
+
options.module = new ModuleFinder(tree).find({
|
|
58
|
+
name: options.name,
|
|
59
|
+
path: options.path,
|
|
60
|
+
});
|
|
61
|
+
if (!options.module) {
|
|
62
|
+
return tree;
|
|
63
|
+
}
|
|
64
|
+
const content = tree.read(options.module).toString();
|
|
65
|
+
const declarator = new ModuleDeclarator();
|
|
66
|
+
tree.overwrite(options.module, declarator.declare(content, options));
|
|
67
|
+
return tree;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { join, strings } from '@angular-devkit/core';
|
|
2
|
+
import { apply, chain, mergeWith, move, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
|
+
import { NameParser } from '../../utils/name.parser.js';
|
|
5
|
+
import { mergeSourceRoot } from '../../utils/source-root.helpers.js';
|
|
6
|
+
export function main(options) {
|
|
7
|
+
options = transform(options);
|
|
8
|
+
return chain([mergeSourceRoot(options), mergeWith(generate(options))]);
|
|
9
|
+
}
|
|
10
|
+
function transform(options) {
|
|
11
|
+
const target = Object.assign({}, options);
|
|
12
|
+
if (!target.name) {
|
|
13
|
+
throw new SchematicsException('Option (name) is required.');
|
|
14
|
+
}
|
|
15
|
+
const location = new NameParser().parse(target);
|
|
16
|
+
target.name = normalizeToKebabOrSnakeCase(location.name);
|
|
17
|
+
target.path = normalizeToKebabOrSnakeCase(location.path);
|
|
18
|
+
target.language = target.language !== undefined ? target.language : 'ts';
|
|
19
|
+
target.path = target.flat
|
|
20
|
+
? target.path
|
|
21
|
+
: join(target.path, target.name);
|
|
22
|
+
return target;
|
|
23
|
+
}
|
|
24
|
+
function generate(options) {
|
|
25
|
+
return (context) => apply(url(join('./files', options.language)), [
|
|
26
|
+
template({
|
|
27
|
+
...strings,
|
|
28
|
+
...options,
|
|
29
|
+
}),
|
|
30
|
+
move(options.path),
|
|
31
|
+
])(context);
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const DEFAULT_AUTHOR = '';
|
|
2
|
+
export const DEFAULT_DESCRIPTION = '';
|
|
3
|
+
export const DEFAULT_LANGUAGE = 'ts';
|
|
4
|
+
export const DEFAULT_VERSION = '0.0.1';
|
|
5
|
+
export const DEFAULT_PATH_NAME = 'src';
|
|
6
|
+
export const DEFAULT_LIB_PATH = 'libs';
|
|
7
|
+
export const DEFAULT_APPS_PATH = 'apps';
|
|
8
|
+
export const DEFAULT_APP_NAME = 'app';
|
|
9
|
+
export const DEFAULT_DIR_ENTRY_APP = 'main';
|
|
10
|
+
export const TEST_ENV = 'test';
|
|
11
|
+
export const PROJECT_TYPE = {
|
|
12
|
+
LIBRARY: 'library',
|
|
13
|
+
APPLICATION: 'application',
|
|
14
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { join, strings } from '@angular-devkit/core';
|
|
2
|
+
import { apply, chain, filter, mergeWith, move, noop, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
|
+
import { NameParser } from '../../utils/name.parser.js';
|
|
5
|
+
import { mergeSourceRoot } from '../../utils/source-root.helpers.js';
|
|
6
|
+
export function main(options) {
|
|
7
|
+
options = transform(options);
|
|
8
|
+
return chain([mergeSourceRoot(options), mergeWith(generate(options))]);
|
|
9
|
+
}
|
|
10
|
+
function transform(options) {
|
|
11
|
+
const target = Object.assign({}, options);
|
|
12
|
+
if (!target.name) {
|
|
13
|
+
throw new SchematicsException('Option (name) is required.');
|
|
14
|
+
}
|
|
15
|
+
const location = new NameParser().parse(target);
|
|
16
|
+
target.name = normalizeToKebabOrSnakeCase(location.name);
|
|
17
|
+
target.path = normalizeToKebabOrSnakeCase(location.path);
|
|
18
|
+
target.language = target.language !== undefined ? target.language : 'ts';
|
|
19
|
+
target.specFileSuffix = normalizeToKebabOrSnakeCase(options.specFileSuffix || 'spec');
|
|
20
|
+
target.path = target.flat
|
|
21
|
+
? target.path
|
|
22
|
+
: join(target.path, target.name);
|
|
23
|
+
return target;
|
|
24
|
+
}
|
|
25
|
+
function generate(options) {
|
|
26
|
+
return (context) => apply(url(join('./files', options.language)), [
|
|
27
|
+
options.spec
|
|
28
|
+
? noop()
|
|
29
|
+
: filter((path) => {
|
|
30
|
+
const languageExtension = options.language || 'ts';
|
|
31
|
+
const suffix = `.__specFileSuffix__.${languageExtension}`;
|
|
32
|
+
return !path.endsWith(suffix);
|
|
33
|
+
}),
|
|
34
|
+
template({
|
|
35
|
+
...strings,
|
|
36
|
+
...options,
|
|
37
|
+
}),
|
|
38
|
+
move(options.path),
|
|
39
|
+
])(context);
|
|
40
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { join, strings } from '@angular-devkit/core';
|
|
2
|
+
import { apply, branchAndMerge, chain, filter, mergeWith, move, noop, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
|
+
import { ModuleDeclarator, } from '../../utils/module.declarator.js';
|
|
5
|
+
import { ModuleFinder } from '../../utils/module.finder.js';
|
|
6
|
+
import { NameParser } from '../../utils/name.parser.js';
|
|
7
|
+
import { mergeSourceRoot } from '../../utils/source-root.helpers.js';
|
|
8
|
+
export function main(options) {
|
|
9
|
+
options = transform(options);
|
|
10
|
+
return (tree, context) => {
|
|
11
|
+
return branchAndMerge(chain([
|
|
12
|
+
mergeSourceRoot(options),
|
|
13
|
+
addDeclarationToModule(options),
|
|
14
|
+
mergeWith(generate(options)),
|
|
15
|
+
]))(tree, context);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function transform(options) {
|
|
19
|
+
const target = Object.assign({}, options);
|
|
20
|
+
if (!target.name) {
|
|
21
|
+
throw new SchematicsException('Option (name) is required.');
|
|
22
|
+
}
|
|
23
|
+
target.metadata = 'providers';
|
|
24
|
+
target.type = 'gateway';
|
|
25
|
+
target.specFileSuffix = normalizeToKebabOrSnakeCase(options.specFileSuffix || 'spec');
|
|
26
|
+
const location = new NameParser().parse(target);
|
|
27
|
+
target.name = normalizeToKebabOrSnakeCase(location.name);
|
|
28
|
+
target.path = normalizeToKebabOrSnakeCase(location.path);
|
|
29
|
+
target.language = target.language !== undefined ? target.language : 'ts';
|
|
30
|
+
target.path = target.flat
|
|
31
|
+
? target.path
|
|
32
|
+
: join(target.path, target.name);
|
|
33
|
+
return target;
|
|
34
|
+
}
|
|
35
|
+
function generate(options) {
|
|
36
|
+
return (context) => apply(url(join('./files', options.language)), [
|
|
37
|
+
options.spec ? noop() : filter((path) => !path.endsWith('.spec.ts')),
|
|
38
|
+
options.spec
|
|
39
|
+
? noop()
|
|
40
|
+
: filter((path) => {
|
|
41
|
+
const languageExtension = options.language || 'ts';
|
|
42
|
+
const suffix = `.__specFileSuffix__.${languageExtension}`;
|
|
43
|
+
return !path.endsWith(suffix);
|
|
44
|
+
}),
|
|
45
|
+
template({
|
|
46
|
+
...strings,
|
|
47
|
+
...options,
|
|
48
|
+
}),
|
|
49
|
+
move(options.path),
|
|
50
|
+
])(context);
|
|
51
|
+
}
|
|
52
|
+
function addDeclarationToModule(options) {
|
|
53
|
+
return (tree) => {
|
|
54
|
+
if (options.skipImport !== undefined && options.skipImport) {
|
|
55
|
+
return tree;
|
|
56
|
+
}
|
|
57
|
+
options.module = new ModuleFinder(tree).find({
|
|
58
|
+
name: options.name,
|
|
59
|
+
path: options.path,
|
|
60
|
+
});
|
|
61
|
+
if (!options.module) {
|
|
62
|
+
return tree;
|
|
63
|
+
}
|
|
64
|
+
const content = tree.read(options.module).toString();
|
|
65
|
+
const declarator = new ModuleDeclarator();
|
|
66
|
+
tree.overwrite(options.module, declarator.declare(content, options));
|
|
67
|
+
return tree;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { join, strings } from '@angular-devkit/core';
|
|
2
|
+
import { apply, chain, filter, mergeWith, move, noop, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
|
+
import { NameParser } from '../../utils/name.parser.js';
|
|
5
|
+
import { mergeSourceRoot } from '../../utils/source-root.helpers.js';
|
|
6
|
+
export function main(options) {
|
|
7
|
+
options = transform(options);
|
|
8
|
+
return chain([mergeSourceRoot(options), mergeWith(generate(options))]);
|
|
9
|
+
}
|
|
10
|
+
function transform(options) {
|
|
11
|
+
const target = Object.assign({}, options);
|
|
12
|
+
if (!target.name) {
|
|
13
|
+
throw new SchematicsException('Option (name) is required.');
|
|
14
|
+
}
|
|
15
|
+
const location = new NameParser().parse(target);
|
|
16
|
+
target.name = normalizeToKebabOrSnakeCase(location.name);
|
|
17
|
+
target.path = normalizeToKebabOrSnakeCase(location.path);
|
|
18
|
+
target.language = target.language !== undefined ? target.language : 'ts';
|
|
19
|
+
target.specFileSuffix = normalizeToKebabOrSnakeCase(options.specFileSuffix || 'spec');
|
|
20
|
+
target.path = target.flat
|
|
21
|
+
? target.path
|
|
22
|
+
: join(target.path, target.name);
|
|
23
|
+
return target;
|
|
24
|
+
}
|
|
25
|
+
function generate(options) {
|
|
26
|
+
return (context) => apply(url(join('./files', options.language)), [
|
|
27
|
+
options.spec
|
|
28
|
+
? noop()
|
|
29
|
+
: filter((path) => {
|
|
30
|
+
const languageExtension = options.language || 'ts';
|
|
31
|
+
const suffix = `.__specFileSuffix__.${languageExtension}`;
|
|
32
|
+
return !path.endsWith(suffix);
|
|
33
|
+
}),
|
|
34
|
+
template({
|
|
35
|
+
...strings,
|
|
36
|
+
...options,
|
|
37
|
+
}),
|
|
38
|
+
move(options.path),
|
|
39
|
+
])(context);
|
|
40
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { join, strings } from '@angular-devkit/core';
|
|
2
|
+
import { apply, chain, filter, mergeWith, move, noop, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
|
+
import { NameParser } from '../../utils/name.parser.js';
|
|
5
|
+
import { mergeSourceRoot } from '../../utils/source-root.helpers.js';
|
|
6
|
+
export function main(options) {
|
|
7
|
+
options = transform(options);
|
|
8
|
+
return chain([mergeSourceRoot(options), mergeWith(generate(options))]);
|
|
9
|
+
}
|
|
10
|
+
function transform(options) {
|
|
11
|
+
const target = Object.assign({}, options);
|
|
12
|
+
if (!target.name) {
|
|
13
|
+
throw new SchematicsException('Option (name) is required.');
|
|
14
|
+
}
|
|
15
|
+
const location = new NameParser().parse(target);
|
|
16
|
+
target.name = normalizeToKebabOrSnakeCase(location.name);
|
|
17
|
+
target.path = normalizeToKebabOrSnakeCase(location.path);
|
|
18
|
+
target.language = target.language !== undefined ? target.language : 'ts';
|
|
19
|
+
target.specFileSuffix = normalizeToKebabOrSnakeCase(options.specFileSuffix || 'spec');
|
|
20
|
+
target.path = target.flat
|
|
21
|
+
? target.path
|
|
22
|
+
: join(target.path, target.name);
|
|
23
|
+
return target;
|
|
24
|
+
}
|
|
25
|
+
function generate(options) {
|
|
26
|
+
return (context) => apply(url(join('./files', options.language)), [
|
|
27
|
+
options.spec ? noop() : filter((path) => !path.endsWith('.spec.ts')),
|
|
28
|
+
options.spec
|
|
29
|
+
? noop()
|
|
30
|
+
: filter((path) => {
|
|
31
|
+
const languageExtension = options.language || 'ts';
|
|
32
|
+
const suffix = `.__specFileSuffix__.${languageExtension}`;
|
|
33
|
+
return !path.endsWith(suffix);
|
|
34
|
+
}),
|
|
35
|
+
template({
|
|
36
|
+
...strings,
|
|
37
|
+
...options,
|
|
38
|
+
}),
|
|
39
|
+
move(options.path),
|
|
40
|
+
])(context);
|
|
41
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { join, strings } from '@angular-devkit/core';
|
|
2
|
+
import { apply, chain, mergeWith, move, SchematicsException, template, url, } from '@angular-devkit/schematics';
|
|
3
|
+
import { normalizeToKebabOrSnakeCase } from '../../utils/formatting.js';
|
|
4
|
+
import { NameParser } from '../../utils/name.parser.js';
|
|
5
|
+
import { mergeSourceRoot } from '../../utils/source-root.helpers.js';
|
|
6
|
+
export function main(options) {
|
|
7
|
+
options = transform(options);
|
|
8
|
+
return chain([mergeSourceRoot(options), mergeWith(generate(options))]);
|
|
9
|
+
}
|
|
10
|
+
function transform(options) {
|
|
11
|
+
const target = Object.assign({}, options);
|
|
12
|
+
if (!target.name) {
|
|
13
|
+
throw new SchematicsException('Option (name) is required.');
|
|
14
|
+
}
|
|
15
|
+
const location = new NameParser().parse(target);
|
|
16
|
+
target.name = normalizeToKebabOrSnakeCase(location.name);
|
|
17
|
+
target.path = normalizeToKebabOrSnakeCase(location.path);
|
|
18
|
+
target.path = target.flat
|
|
19
|
+
? target.path
|
|
20
|
+
: join(target.path, target.name);
|
|
21
|
+
return target;
|
|
22
|
+
}
|
|
23
|
+
function generate(options) {
|
|
24
|
+
return (context) => apply(url('./files'), [
|
|
25
|
+
template({
|
|
26
|
+
...strings,
|
|
27
|
+
...options,
|
|
28
|
+
}),
|
|
29
|
+
move(options.path),
|
|
30
|
+
])(context);
|
|
31
|
+
}
|