@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.
Files changed (132) hide show
  1. package/dist/lib/application/files/js/package.json +10 -10
  2. package/dist/lib/application/files/ts/package.json +3 -3
  3. package/dist/lib/application/files/ts/tsconfig.json +0 -1
  4. package/dist/lib/application/files/ts-esm/.prettierrc +4 -0
  5. package/dist/lib/application/files/ts-esm/README.md +98 -0
  6. package/dist/lib/application/files/ts-esm/eslint.config.mjs +34 -0
  7. package/dist/lib/application/files/ts-esm/nest-cli.json +8 -0
  8. package/dist/lib/application/files/ts-esm/package.json +50 -0
  9. package/dist/lib/application/files/ts-esm/src/app.controller.__specFileSuffix__.ts +22 -0
  10. package/dist/lib/application/files/ts-esm/src/app.controller.ts +12 -0
  11. package/dist/lib/application/files/ts-esm/src/app.module.ts +10 -0
  12. package/dist/lib/application/files/ts-esm/src/app.service.ts +8 -0
  13. package/dist/lib/application/files/ts-esm/src/main.ts +8 -0
  14. package/dist/lib/application/files/ts-esm/test/app.e2e-__specFileSuffix__.ts +25 -0
  15. package/dist/lib/application/files/ts-esm/tsconfig.build.json +4 -0
  16. package/dist/lib/application/files/ts-esm/tsconfig.json +24 -0
  17. package/dist/lib/application/files/ts-esm/vitest.config.e2e.ts +10 -0
  18. package/dist/lib/application/files/ts-esm/vitest.config.ts +10 -0
  19. package/dist/lib/application/schema.json +14 -0
  20. package/dist/lib/library/files/ts/tsconfig.lib.json +1 -0
  21. package/dist/lib/sub-app/files/ts/tsconfig.app.json +1 -0
  22. package/dist/lib/sub-app/workspace/ts/tsconfig.app.json +1 -0
  23. package/dist/src/index.d.ts +2 -0
  24. package/dist/src/index.js +2 -0
  25. package/dist/{lib → src/lib}/application/application.factory.d.ts +1 -1
  26. package/dist/src/lib/application/application.factory.js +64 -0
  27. package/dist/{lib → src/lib}/class/class.factory.d.ts +1 -1
  28. package/dist/src/lib/class/class.factory.js +48 -0
  29. package/dist/{lib → src/lib}/client-app/angular/angular.factory.d.ts +1 -1
  30. package/dist/{lib → src/lib}/client-app/angular/angular.factory.js +23 -26
  31. package/dist/{lib → src/lib}/configuration/configuration.factory.d.ts +1 -1
  32. package/dist/src/lib/configuration/configuration.factory.js +24 -0
  33. package/dist/{lib → src/lib}/controller/controller.factory.d.ts +1 -1
  34. package/dist/src/lib/controller/controller.factory.js +69 -0
  35. package/dist/{lib → src/lib}/decorator/decorator.factory.d.ts +1 -1
  36. package/dist/src/lib/decorator/decorator.factory.js +32 -0
  37. package/dist/src/lib/defaults.js +14 -0
  38. package/dist/{lib → src/lib}/filter/filter.factory.d.ts +1 -1
  39. package/dist/src/lib/filter/filter.factory.js +40 -0
  40. package/dist/{lib → src/lib}/gateway/gateway.factory.d.ts +1 -1
  41. package/dist/src/lib/gateway/gateway.factory.js +69 -0
  42. package/dist/{lib → src/lib}/guard/guard.factory.d.ts +1 -1
  43. package/dist/src/lib/guard/guard.factory.js +40 -0
  44. package/dist/{lib → src/lib}/interceptor/interceptor.factory.d.ts +1 -1
  45. package/dist/src/lib/interceptor/interceptor.factory.js +41 -0
  46. package/dist/{lib → src/lib}/interface/interface.factory.d.ts +1 -1
  47. package/dist/src/lib/interface/interface.factory.js +31 -0
  48. package/dist/{lib → src/lib}/library/library.factory.d.ts +1 -1
  49. package/dist/{lib → src/lib}/library/library.factory.js +51 -64
  50. package/dist/{lib → src/lib}/middleware/middleware.factory.d.ts +1 -1
  51. package/dist/src/lib/middleware/middleware.factory.js +40 -0
  52. package/dist/{lib → src/lib}/module/module.factory.d.ts +1 -1
  53. package/dist/src/lib/module/module.factory.js +57 -0
  54. package/dist/{lib → src/lib}/pipe/pipe.factory.d.ts +1 -1
  55. package/dist/src/lib/pipe/pipe.factory.js +41 -0
  56. package/dist/{lib → src/lib}/provider/provider.factory.d.ts +1 -1
  57. package/dist/src/lib/provider/provider.factory.js +73 -0
  58. package/dist/{lib → src/lib}/readers/file-system.reader.d.ts +1 -1
  59. package/dist/{lib → src/lib}/readers/file-system.reader.js +3 -7
  60. package/dist/src/lib/readers/index.d.ts +2 -0
  61. package/dist/src/lib/readers/index.js +2 -0
  62. package/dist/src/lib/readers/reader.js +1 -0
  63. package/dist/{lib → src/lib}/resolver/resolver.factory.d.ts +1 -1
  64. package/dist/src/lib/resolver/resolver.factory.js +68 -0
  65. package/dist/{lib → src/lib}/resource/resource.factory.d.ts +1 -1
  66. package/dist/{lib → src/lib}/resource/resource.factory.js +35 -38
  67. package/dist/{lib → src/lib}/service/service.factory.d.ts +1 -1
  68. package/dist/src/lib/service/service.factory.js +71 -0
  69. package/dist/{lib → src/lib}/sub-app/sub-app.factory.d.ts +1 -1
  70. package/dist/{lib → src/lib}/sub-app/sub-app.factory.js +94 -69
  71. package/dist/{utils → src/utils}/dependencies.utils.js +7 -12
  72. package/dist/{utils → src/utils}/formatting.js +1 -4
  73. package/dist/src/utils/index.d.ts +11 -0
  74. package/dist/src/utils/index.js +11 -0
  75. package/dist/src/utils/jest-module-mapper.js +6 -0
  76. package/dist/{utils → src/utils}/json-file.util.js +9 -13
  77. package/dist/{utils → src/utils}/metadata.manager.d.ts +1 -1
  78. package/dist/{utils → src/utils}/metadata.manager.js +11 -15
  79. package/dist/{utils → src/utils}/module-import.declarator.d.ts +2 -2
  80. package/dist/{utils → src/utils}/module-import.declarator.js +6 -10
  81. package/dist/{utils → src/utils}/module-metadata.declarator.d.ts +1 -1
  82. package/dist/src/utils/module-metadata.declarator.js +8 -0
  83. package/dist/{utils → src/utils}/module.declarator.d.ts +2 -2
  84. package/dist/src/utils/module.declarator.js +30 -0
  85. package/dist/{utils → src/utils}/module.finder.js +3 -7
  86. package/dist/src/utils/name.parser.js +13 -0
  87. package/dist/{utils → src/utils}/object-sorting.js +1 -4
  88. package/dist/src/utils/path.solver.js +8 -0
  89. package/dist/src/utils/source-root.helpers.js +20 -0
  90. package/dist/tsconfig.lib.tsbuildinfo +1 -0
  91. package/package.json +21 -49
  92. package/dist/index.d.ts +0 -2
  93. package/dist/index.js +0 -18
  94. package/dist/lib/application/application.factory.js +0 -63
  95. package/dist/lib/class/class.factory.js +0 -51
  96. package/dist/lib/configuration/configuration.factory.js +0 -27
  97. package/dist/lib/controller/controller.factory.js +0 -72
  98. package/dist/lib/decorator/decorator.factory.js +0 -35
  99. package/dist/lib/defaults.js +0 -17
  100. package/dist/lib/filter/filter.factory.js +0 -43
  101. package/dist/lib/gateway/gateway.factory.js +0 -72
  102. package/dist/lib/guard/guard.factory.js +0 -43
  103. package/dist/lib/interceptor/interceptor.factory.js +0 -44
  104. package/dist/lib/interface/interface.factory.js +0 -34
  105. package/dist/lib/middleware/middleware.factory.js +0 -43
  106. package/dist/lib/module/module.factory.js +0 -60
  107. package/dist/lib/pipe/pipe.factory.js +0 -44
  108. package/dist/lib/provider/provider.factory.js +0 -76
  109. package/dist/lib/readers/index.d.ts +0 -2
  110. package/dist/lib/readers/index.js +0 -18
  111. package/dist/lib/readers/reader.js +0 -2
  112. package/dist/lib/resolver/resolver.factory.js +0 -71
  113. package/dist/lib/service/service.factory.js +0 -74
  114. package/dist/utils/index.d.ts +0 -11
  115. package/dist/utils/index.js +0 -27
  116. package/dist/utils/jest-module-mapper.js +0 -9
  117. package/dist/utils/module-metadata.declarator.js +0 -12
  118. package/dist/utils/module.declarator.js +0 -34
  119. package/dist/utils/name.parser.js +0 -17
  120. package/dist/utils/path.solver.js +0 -12
  121. package/dist/utils/source-root.helpers.js +0 -24
  122. /package/dist/{lib → src/lib}/defaults.d.ts +0 -0
  123. /package/dist/{lib → src/lib}/readers/reader.d.ts +0 -0
  124. /package/dist/{utils → src/utils}/dependencies.utils.d.ts +0 -0
  125. /package/dist/{utils → src/utils}/formatting.d.ts +0 -0
  126. /package/dist/{utils → src/utils}/jest-module-mapper.d.ts +0 -0
  127. /package/dist/{utils → src/utils}/json-file.util.d.ts +0 -0
  128. /package/dist/{utils → src/utils}/module.finder.d.ts +0 -0
  129. /package/dist/{utils → src/utils}/name.parser.d.ts +0 -0
  130. /package/dist/{utils → src/utils}/object-sorting.d.ts +0 -0
  131. /package/dist/{utils → src/utils}/path.solver.d.ts +0 -0
  132. /package/dist/{utils → src/utils}/source-root.helpers.d.ts +0 -0
@@ -1,57 +1,54 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.main = main;
4
- const core_1 = require("@angular-devkit/core");
5
- const schematics_1 = require("@angular-devkit/schematics");
6
- const path_1 = require("path");
7
- const module_declarator_1 = require("../../../utils/module.declarator");
8
- const module_finder_1 = require("../../../utils/module.finder");
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 (0, schematics_1.branchAndMerge)((0, schematics_1.chain)([
11
+ return branchAndMerge(chain([
15
12
  createAngularApplication(options),
16
- (0, source_root_helpers_1.mergeSourceRoot)(options),
13
+ mergeSourceRoot(options),
17
14
  addDeclarationToModule(options),
18
15
  addGlobalPrefix(),
19
- (0, schematics_1.mergeWith)(generate(options)),
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 ? core_1.strings.dasherize(target.name) : 'client';
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 name_parser_1.NameParser().parse(target);
30
- target.name = core_1.strings.dasherize(location.name);
31
- target.path = (0, path_1.join)(core_1.strings.dasherize(location.path), target.name);
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) => (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
36
- (0, schematics_1.template)({
37
- ...core_1.strings,
32
+ return (context) => apply(url('./files'), [
33
+ template({
34
+ ...strings,
38
35
  ...options,
39
36
  }),
40
- (0, schematics_1.move)(options.path),
37
+ move(options.path),
41
38
  ])(context);
42
39
  }
43
40
  function createAngularApplication(options) {
44
41
  if (!options.initApp) {
45
- return (0, schematics_1.noop)();
42
+ return noop();
46
43
  }
47
- return (0, schematics_1.externalSchematic)('@schematics/angular', 'ng-new', {
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 module_finder_1.ModuleFinder(tree).find({
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 module_declarator_1.ModuleDeclarator();
59
+ const declarator = new ModuleDeclarator();
63
60
  const rootPath = `${options.directory}/dist/${options.directory}`;
64
61
  const staticOptions = {
65
62
  name: 'forRoot',
@@ -1,3 +1,3 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
- import { ConfigurationOptions } from './configuration.schema';
2
+ import type { ConfigurationOptions } from './configuration.schema.js';
3
3
  export declare function main(options: ConfigurationOptions): Rule;
@@ -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
+ }
@@ -1,3 +1,3 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
- import { ControllerOptions } from './controller.schema';
2
+ import type { ControllerOptions } from './controller.schema.js';
3
3
  export declare function main(options: ControllerOptions): Rule;
@@ -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
+ }
@@ -1,3 +1,3 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
- import { DecoratorOptions } from './decorator.schema';
2
+ import type { DecoratorOptions } from './decorator.schema.js';
3
3
  export declare function main(options: DecoratorOptions): Rule;
@@ -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
+ };
@@ -1,3 +1,3 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
- import { FilterOptions } from './filter.schema';
2
+ import type { FilterOptions } from './filter.schema.js';
3
3
  export declare function main(options: FilterOptions): Rule;
@@ -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
+ }
@@ -1,3 +1,3 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
- import { GatewayOptions } from './gateway.schema';
2
+ import type { GatewayOptions } from './gateway.schema.js';
3
3
  export declare function main(options: GatewayOptions): Rule;
@@ -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
+ }
@@ -1,3 +1,3 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
- import { GuardOptions } from './guard.schema';
2
+ import type { GuardOptions } from './guard.schema.js';
3
3
  export declare function main(options: GuardOptions): Rule;
@@ -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
+ }
@@ -1,3 +1,3 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
- import { InterceptorOptions } from './interceptor.schema';
2
+ import type { InterceptorOptions } from './interceptor.schema.js';
3
3
  export declare function main(options: InterceptorOptions): Rule;
@@ -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
+ }
@@ -1,3 +1,3 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
- import { InterfaceOptions } from './interface.schema';
2
+ import type { InterfaceOptions } from './interface.schema.js';
3
3
  export declare function main(options: InterfaceOptions): Rule;
@@ -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
+ }
@@ -1,3 +1,3 @@
1
1
  import { Rule } from '@angular-devkit/schematics';
2
- import { LibraryOptions } from './library.schema';
2
+ import type { LibraryOptions } from './library.schema.js';
3
3
  export declare function main(options: LibraryOptions): Rule;