@open-rlb/nestjs-amqp 1.0.13 → 1.0.15

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 (81) hide show
  1. package/modules/broker/index.d.ts +2 -0
  2. package/modules/broker/index.js +2 -0
  3. package/modules/broker/index.js.map +1 -1
  4. package/modules/broker/services/broker.service.js +1 -1
  5. package/modules/broker/services/broker.service.js.map +1 -1
  6. package/package.json +14 -5
  7. package/schematics/collection.json +10 -0
  8. package/schematics/defaults.d.ts +14 -0
  9. package/schematics/defaults.js +18 -0
  10. package/schematics/defaults.js.map +1 -0
  11. package/schematics/defaults.ts +14 -0
  12. package/schematics/nest-add/index.d.ts +3 -0
  13. package/schematics/nest-add/index.js +315 -0
  14. package/schematics/nest-add/index.js.map +1 -0
  15. package/schematics/nest-add/index.ts +440 -0
  16. package/schematics/nest-add/init.schema.d.ts +15 -0
  17. package/schematics/nest-add/init.schema.js +3 -0
  18. package/schematics/nest-add/init.schema.js.map +1 -0
  19. package/schematics/nest-add/init.schema.ts +52 -0
  20. package/schematics/nest-add/schema.d.ts +5 -0
  21. package/schematics/nest-add/schema.js +3 -0
  22. package/schematics/nest-add/schema.js.map +1 -0
  23. package/schematics/nest-add/schema.json +20 -0
  24. package/schematics/nest-add/schema.ts +9 -0
  25. package/schematics/utils/dependencies.utils.d.ts +15 -0
  26. package/schematics/utils/dependencies.utils.js +43 -0
  27. package/schematics/utils/dependencies.utils.js.map +1 -0
  28. package/schematics/utils/dependencies.utils.ts +61 -0
  29. package/schematics/utils/formatting.d.ts +2 -0
  30. package/schematics/utils/formatting.js +23 -0
  31. package/schematics/utils/formatting.js.map +1 -0
  32. package/schematics/utils/formatting.spec.ts +45 -0
  33. package/schematics/utils/formatting.ts +31 -0
  34. package/schematics/utils/index.d.ts +9 -0
  35. package/schematics/utils/index.js +26 -0
  36. package/schematics/utils/index.js.map +1 -0
  37. package/schematics/utils/index.ts +9 -0
  38. package/schematics/utils/json-file.util.d.ts +15 -0
  39. package/schematics/utils/json-file.util.js +69 -0
  40. package/schematics/utils/json-file.util.js.map +1 -0
  41. package/schematics/utils/json-file.util.ts +100 -0
  42. package/schematics/utils/metadata.manager.d.ts +13 -0
  43. package/schematics/utils/metadata.manager.js +175 -0
  44. package/schematics/utils/metadata.manager.js.map +1 -0
  45. package/schematics/utils/metadata.manager.spec.ts +357 -0
  46. package/schematics/utils/metadata.manager.ts +241 -0
  47. package/schematics/utils/module-import.declarator.d.ts +10 -0
  48. package/schematics/utils/module-import.declarator.js +40 -0
  49. package/schematics/utils/module-import.declarator.js.map +1 -0
  50. package/schematics/utils/module-import.declarator.spec.ts +122 -0
  51. package/schematics/utils/module-import.declarator.ts +44 -0
  52. package/schematics/utils/module-metadata.declarator.d.ts +4 -0
  53. package/schematics/utils/module-metadata.declarator.js +13 -0
  54. package/schematics/utils/module-metadata.declarator.js.map +1 -0
  55. package/schematics/utils/module-metadata.declarator.spec.ts +404 -0
  56. package/schematics/utils/module-metadata.declarator.ts +14 -0
  57. package/schematics/utils/module.declarator.d.ts +23 -0
  58. package/schematics/utils/module.declarator.js +33 -0
  59. package/schematics/utils/module.declarator.js.map +1 -0
  60. package/schematics/utils/module.declarator.spec.ts +52 -0
  61. package/schematics/utils/module.declarator.ts +44 -0
  62. package/schematics/utils/module.finder.d.ts +13 -0
  63. package/schematics/utils/module.finder.js +25 -0
  64. package/schematics/utils/module.finder.js.map +1 -0
  65. package/schematics/utils/module.finder.spec.ts +59 -0
  66. package/schematics/utils/module.finder.ts +32 -0
  67. package/schematics/utils/name.parser.d.ts +12 -0
  68. package/schematics/utils/name.parser.js +18 -0
  69. package/schematics/utils/name.parser.js.map +1 -0
  70. package/schematics/utils/name.parser.spec.ts +50 -0
  71. package/schematics/utils/name.parser.ts +26 -0
  72. package/schematics/utils/path.solver.d.ts +4 -0
  73. package/schematics/utils/path.solver.js +15 -0
  74. package/schematics/utils/path.solver.js.map +1 -0
  75. package/schematics/utils/path.solver.spec.ts +11 -0
  76. package/schematics/utils/path.solver.ts +15 -0
  77. package/schematics/utils/source-root.helpers.d.ts +6 -0
  78. package/schematics/utils/source-root.helpers.js +25 -0
  79. package/schematics/utils/source-root.helpers.js.map +1 -0
  80. package/schematics/utils/source-root.helpers.ts +30 -0
  81. package/tsconfig.build.tsbuildinfo +1 -1
@@ -0,0 +1,52 @@
1
+ import { normalize } from '@angular-devkit/core';
2
+ import { DeclarationOptions, ModuleDeclarator } from './module.declarator';
3
+
4
+ describe('Module Declarator', () => {
5
+ it('should add module declaration when declare', () => {
6
+ const content: string =
7
+ 'import { Module } from \'@nestjs/common\';\n' +
8
+ '\n' +
9
+ '@Module({})\n' +
10
+ 'export class FooModule {}\n';
11
+ const declarator = new ModuleDeclarator();
12
+ const options: DeclarationOptions = {
13
+ metadata: 'imports',
14
+ type: 'module',
15
+ name: 'bar',
16
+ path: normalize('/src/foo/bar'),
17
+ module: normalize('/src/foo/foo.module.ts')
18
+ };
19
+ expect(declarator.declare(content, options)).toEqual(
20
+ 'import { Module } from \'@nestjs/common\';\n' +
21
+ 'import { BarModule } from \'./bar/bar.module\';\n' +
22
+ '\n' +
23
+ '@Module({\n' +
24
+ ' imports: [BarModule]\n' +
25
+ '})\n' +
26
+ 'export class FooModule {}\n'
27
+ );
28
+ });
29
+ it('should manage no type', () => {
30
+ const content: string =
31
+ 'import { Module } from \'@nestjs/common\';\n' +
32
+ '\n' +
33
+ '@Module({})\n' +
34
+ 'export class FooModule {}\n';
35
+ const declarator = new ModuleDeclarator();
36
+ const options: DeclarationOptions = {
37
+ metadata: 'providers',
38
+ name: 'foo',
39
+ path: normalize('/src/foo'),
40
+ module: normalize('/src/foo.ts')
41
+ };
42
+ expect(declarator.declare(content, options)).toEqual(
43
+ 'import { Module } from \'@nestjs/common\';\n' +
44
+ 'import { Foo } from \'./foo/foo\';\n' +
45
+ '\n' +
46
+ '@Module({\n' +
47
+ ' providers: [Foo]\n' +
48
+ '})\n' +
49
+ 'export class FooModule {}\n'
50
+ );
51
+ });
52
+ });
@@ -0,0 +1,44 @@
1
+ import { Path } from '@angular-devkit/core';
2
+ import { capitalize, classify } from '@angular-devkit/core/src/utils/strings';
3
+ import { ModuleImportDeclarator } from './module-import.declarator';
4
+ import { ModuleMetadataDeclarator } from './module-metadata.declarator';
5
+
6
+ export interface DeclarationOptions {
7
+ metadata: string;
8
+ type?: string;
9
+ name: string;
10
+ className?: string;
11
+ path: Path;
12
+ module: Path;
13
+ symbol?: string;
14
+ staticOptions?: {
15
+ name: string;
16
+ value: Record<string, any>;
17
+ };
18
+ }
19
+
20
+ export class ModuleDeclarator {
21
+ constructor(
22
+ private imports: ModuleImportDeclarator = new ModuleImportDeclarator(),
23
+ private metadata: ModuleMetadataDeclarator = new ModuleMetadataDeclarator(),
24
+ ) {}
25
+
26
+ public declare(content: string, options: DeclarationOptions): string {
27
+ options = this.computeSymbol(options);
28
+ content = this.imports.declare(content, options);
29
+ content = this.metadata.declare(content, options);
30
+ return content;
31
+ }
32
+
33
+ private computeSymbol(options: DeclarationOptions): DeclarationOptions {
34
+ const target = Object.assign({}, options);
35
+ if (options.className) {
36
+ target.symbol = options.className;
37
+ } else if (options.type !== undefined) {
38
+ target.symbol = classify(options.name).concat(capitalize(options.type));
39
+ } else {
40
+ target.symbol = classify(options.name);
41
+ }
42
+ return target;
43
+ }
44
+ }
@@ -0,0 +1,13 @@
1
+ import { Path } from '@angular-devkit/core';
2
+ import { Tree } from '@angular-devkit/schematics';
3
+ export interface FindOptions {
4
+ name?: string;
5
+ path: Path;
6
+ kind?: string;
7
+ }
8
+ export declare class ModuleFinder {
9
+ private tree;
10
+ constructor(tree: Tree);
11
+ find(options: FindOptions): Path | null;
12
+ private findIn;
13
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ModuleFinder = void 0;
4
+ const core_1 = require("@angular-devkit/core");
5
+ class ModuleFinder {
6
+ constructor(tree) {
7
+ this.tree = tree;
8
+ }
9
+ find(options) {
10
+ const generatedDirectoryPath = options.path;
11
+ const generatedDirectory = this.tree.getDir(generatedDirectoryPath);
12
+ return this.findIn(generatedDirectory);
13
+ }
14
+ findIn(directory) {
15
+ if (!directory) {
16
+ return null;
17
+ }
18
+ const moduleFilename = directory.subfiles.find(filename => /\.module\.(t|j)s$/.test(filename));
19
+ return moduleFilename !== undefined
20
+ ? (0, core_1.join)(directory.path, moduleFilename.valueOf())
21
+ : this.findIn(directory.parent);
22
+ }
23
+ }
24
+ exports.ModuleFinder = ModuleFinder;
25
+ //# sourceMappingURL=module.finder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.finder.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/schematics/utils/module.finder.ts"],"names":[],"mappings":";;;AAAA,+CAAgE;AAShE,MAAa,YAAY;IACvB,YAAoB,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;IAAG,CAAC;IAE3B,IAAI,CAAC,OAAoB;QAC9B,MAAM,sBAAsB,GAAS,OAAO,CAAC,IAAI,CAAC;QAClD,MAAM,kBAAkB,GAAa,IAAI,CAAC,IAAI,CAAC,MAAM,CACnD,sBAAsB,CACvB,CAAC;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACzC,CAAC;IAEO,MAAM,CAAC,SAAmB;QAChC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,cAAc,GAAiB,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CACtE,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CACnC,CAAC;QACF,OAAO,cAAc,KAAK,SAAS;YACjC,CAAC,CAAC,IAAA,WAAI,EAAC,SAAS,CAAC,IAAI,EAAE,cAAc,CAAC,OAAO,EAAE,CAAC;YAChD,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACF;AAtBD,oCAsBC"}
@@ -0,0 +1,59 @@
1
+ import { normalize } from '@angular-devkit/core';
2
+ import { EmptyTree } from '@angular-devkit/schematics';
3
+ import { FindOptions, ModuleFinder } from './module.finder';
4
+
5
+ describe('Module Finder', () => {
6
+ it('should return the app module path', () => {
7
+ const tree = new EmptyTree();
8
+ tree.create('/src/app.module.ts', 'app module content');
9
+ const finder = new ModuleFinder(tree);
10
+ const options: FindOptions = {
11
+ name: 'foo',
12
+ path: normalize('/src'),
13
+ };
14
+ expect(finder.find(options)).toEqual(normalize('/src/app.module.ts'));
15
+ });
16
+ it('should return the intermediate module path', () => {
17
+ const tree = new EmptyTree();
18
+ tree.create('/src/app.module.ts', 'app module content');
19
+ tree.create('/src/foo/foo.module.ts', 'foo module content');
20
+ const finder = new ModuleFinder(tree);
21
+ const options: FindOptions = {
22
+ name: 'name',
23
+ path: normalize('/src/foo'),
24
+ };
25
+ expect(finder.find(options)).toEqual(normalize('/src/foo/foo.module.ts'));
26
+ });
27
+ it('should manage javascript module file', () => {
28
+ const tree = new EmptyTree();
29
+ tree.create('/src/app.module.js', 'app module content');
30
+ const finder = new ModuleFinder(tree);
31
+ const options: FindOptions = {
32
+ name: 'foo',
33
+ path: normalize('/src'),
34
+ };
35
+ expect(finder.find(options)).toEqual(normalize('/src/app.module.js'));
36
+ });
37
+
38
+ it('should return null when directory does not exist', () => {
39
+ const tree = new EmptyTree();
40
+
41
+ const finder = new ModuleFinder(tree);
42
+ const options: FindOptions = {
43
+ name: 'foo',
44
+ path: normalize('/src'),
45
+ };
46
+ expect(finder.find(options)).toEqual(null);
47
+ });
48
+
49
+ it('should ignore vim swap files', () => {
50
+ const tree = new EmptyTree();
51
+ tree.create('/src/foo/foo.module.ts.swp', 'foo module content');
52
+ const finder = new ModuleFinder(tree);
53
+ const options: FindOptions = {
54
+ name: 'name',
55
+ path: normalize('/src/foo'),
56
+ };
57
+ expect(finder.find(options)).toEqual(null);
58
+ });
59
+ });
@@ -0,0 +1,32 @@
1
+ import { join, Path, PathFragment } from '@angular-devkit/core';
2
+ import { DirEntry, Tree } from '@angular-devkit/schematics';
3
+
4
+ export interface FindOptions {
5
+ name?: string;
6
+ path: Path;
7
+ kind?: string;
8
+ }
9
+
10
+ export class ModuleFinder {
11
+ constructor(private tree: Tree) {}
12
+
13
+ public find(options: FindOptions): Path | null {
14
+ const generatedDirectoryPath: Path = options.path;
15
+ const generatedDirectory: DirEntry = this.tree.getDir(
16
+ generatedDirectoryPath,
17
+ );
18
+ return this.findIn(generatedDirectory);
19
+ }
20
+
21
+ private findIn(directory: DirEntry): Path | null {
22
+ if (!directory) {
23
+ return null;
24
+ }
25
+ const moduleFilename: PathFragment = directory.subfiles.find(filename =>
26
+ /\.module\.(t|j)s$/.test(filename),
27
+ );
28
+ return moduleFilename !== undefined
29
+ ? join(directory.path, moduleFilename.valueOf())
30
+ : this.findIn(directory.parent);
31
+ }
32
+ }
@@ -0,0 +1,12 @@
1
+ import { Path } from '@angular-devkit/core';
2
+ export interface ParseOptions {
3
+ name: string;
4
+ path?: string;
5
+ }
6
+ export interface Location {
7
+ name: string;
8
+ path: Path;
9
+ }
10
+ export declare class NameParser {
11
+ parse(options: ParseOptions): Location;
12
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NameParser = void 0;
4
+ const core_1 = require("@angular-devkit/core");
5
+ class NameParser {
6
+ parse(options) {
7
+ const nameWithoutPath = (0, core_1.basename)(options.name);
8
+ const namePath = (0, core_1.dirname)((options.path === undefined ? '' : options.path)
9
+ .concat('/')
10
+ .concat(options.name));
11
+ return {
12
+ name: nameWithoutPath,
13
+ path: (0, core_1.normalize)('/'.concat(namePath)),
14
+ };
15
+ }
16
+ }
17
+ exports.NameParser = NameParser;
18
+ //# sourceMappingURL=name.parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name.parser.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/schematics/utils/name.parser.ts"],"names":[],"mappings":";;;AAAA,+CAA0E;AAY1E,MAAa,UAAU;IACd,KAAK,CAAC,OAAqB;QAChC,MAAM,eAAe,GAAW,IAAA,eAAQ,EAAC,OAAO,CAAC,IAAY,CAAC,CAAC;QAC/D,MAAM,QAAQ,GAAW,IAAA,cAAO,EAC9B,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;aAC7C,MAAM,CAAC,GAAG,CAAC;aACX,MAAM,CAAC,OAAO,CAAC,IAAI,CAAS,CAChC,CAAC;QACF,OAAO;YACL,IAAI,EAAE,eAAe;YACrB,IAAI,EAAE,IAAA,gBAAS,EAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;SACtC,CAAC;IACJ,CAAC;CACF;AAbD,gCAaC"}
@@ -0,0 +1,50 @@
1
+ import { Location, NameParser, ParseOptions } from './name.parser';
2
+
3
+ describe('Name Parser', () => {
4
+ let parser: NameParser;
5
+ beforeAll(() => parser = new NameParser());
6
+ it('should handle no path', () => {
7
+ const options: ParseOptions = {
8
+ name: 'foo'
9
+ };
10
+ const location: Location = parser.parse(options);
11
+ expect(location.name).toEqual('foo');
12
+ expect(location.path).toEqual('/');
13
+ });
14
+ it('should handle just the name', () => {
15
+ const options: ParseOptions = {
16
+ name: 'foo',
17
+ path: 'baz'
18
+ };
19
+ const location: Location = parser.parse(options);
20
+ expect(location.name).toEqual('foo');
21
+ expect(location.path).toEqual('/baz');
22
+ });
23
+ it('should handle name has a path (sub-dir)', () => {
24
+ const options: ParseOptions = {
25
+ name: 'bar/foo',
26
+ path: 'baz'
27
+ };
28
+ const location: Location = parser.parse(options);
29
+ expect(location.name).toEqual('foo');
30
+ expect(location.path).toEqual('/baz/bar');
31
+ });
32
+
33
+ it('should handle name has a higher path', () => {
34
+ const options: ParseOptions = {
35
+ name: '../foo',
36
+ path: 'bar/baz'
37
+ };
38
+ const location: Location = parser.parse(options);
39
+ expect(location.name).toEqual('foo');
40
+ expect(location.path).toEqual('/bar');
41
+ });
42
+
43
+ it('should handle name has a higher path above root', () => {
44
+ const options: ParseOptions = {
45
+ name: '../../../foo',
46
+ path: 'baz'
47
+ };
48
+ expect(() => parser.parse(options)).toThrow();
49
+ });
50
+ });
@@ -0,0 +1,26 @@
1
+ import { basename, dirname, normalize, Path } from '@angular-devkit/core';
2
+
3
+ export interface ParseOptions {
4
+ name: string;
5
+ path?: string;
6
+ }
7
+
8
+ export interface Location {
9
+ name: string;
10
+ path: Path;
11
+ }
12
+
13
+ export class NameParser {
14
+ public parse(options: ParseOptions): Location {
15
+ const nameWithoutPath: string = basename(options.name as Path);
16
+ const namePath: string = dirname(
17
+ (options.path === undefined ? '' : options.path)
18
+ .concat('/')
19
+ .concat(options.name) as Path,
20
+ );
21
+ return {
22
+ name: nameWithoutPath,
23
+ path: normalize('/'.concat(namePath)),
24
+ };
25
+ }
26
+ }
@@ -0,0 +1,4 @@
1
+ import { Path } from '@angular-devkit/core';
2
+ export declare class PathSolver {
3
+ relative(from: Path, to: Path): string;
4
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PathSolver = void 0;
4
+ const core_1 = require("@angular-devkit/core");
5
+ class PathSolver {
6
+ relative(from, to) {
7
+ const placeholder = '/placeholder';
8
+ const relativeDir = (0, core_1.relative)((0, core_1.dirname)((placeholder + from)), (0, core_1.dirname)((placeholder + to)));
9
+ return (relativeDir.startsWith('.')
10
+ ? relativeDir
11
+ : './' + relativeDir).concat(relativeDir.length === 0 ? (0, core_1.basename)(to) : '/' + (0, core_1.basename)(to));
12
+ }
13
+ }
14
+ exports.PathSolver = PathSolver;
15
+ //# sourceMappingURL=path.solver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.solver.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/schematics/utils/path.solver.ts"],"names":[],"mappings":";;;AAAA,+CAAyE;AAEzE,MAAa,UAAU;IACd,QAAQ,CAAC,IAAU,EAAE,EAAQ;QAClC,MAAM,WAAW,GAAG,cAAc,CAAC;QACnC,MAAM,WAAW,GAAG,IAAA,eAAQ,EAC1B,IAAA,cAAO,EAAC,CAAC,WAAW,GAAG,IAAI,CAAS,CAAC,EACrC,IAAA,cAAO,EAAC,CAAC,WAAW,GAAG,EAAE,CAAS,CAAC,CACpC,CAAC;QACF,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC;YACjC,CAAC,CAAC,WAAW;YACb,CAAC,CAAC,IAAI,GAAG,WAAW,CACrB,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAA,eAAQ,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAA,eAAQ,EAAC,EAAE,CAAC,CAAC,CAAC;IACzE,CAAC;CACF;AAZD,gCAYC"}
@@ -0,0 +1,11 @@
1
+ import { normalize, Path } from '@angular-devkit/core';
2
+ import { PathSolver } from './path.solver';
3
+
4
+ describe('Path Solver', () => {
5
+ it('should relative path between path', () => {
6
+ const solver = new PathSolver();
7
+ const from: Path = normalize('/src/app.module.ts');
8
+ const to: Path = normalize('/src/foo/foo.module');
9
+ expect(solver.relative(from, to)).toEqual('./foo/foo.module');
10
+ });
11
+ });
@@ -0,0 +1,15 @@
1
+ import { basename, dirname, Path, relative } from '@angular-devkit/core';
2
+
3
+ export class PathSolver {
4
+ public relative(from: Path, to: Path): string {
5
+ const placeholder = '/placeholder';
6
+ const relativeDir = relative(
7
+ dirname((placeholder + from) as Path),
8
+ dirname((placeholder + to) as Path),
9
+ );
10
+ return (relativeDir.startsWith('.')
11
+ ? relativeDir
12
+ : './' + relativeDir
13
+ ).concat(relativeDir.length === 0 ? basename(to) : '/' + basename(to));
14
+ }
15
+ }
@@ -0,0 +1,6 @@
1
+ import { Rule, Tree } from '@angular-devkit/schematics';
2
+ export declare function isInRootDirectory(host: Tree, extraFiles?: string[]): boolean;
3
+ export declare function mergeSourceRoot<T extends {
4
+ sourceRoot?: string;
5
+ path?: string;
6
+ } = any>(options: T): Rule;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isInRootDirectory = isInRootDirectory;
4
+ exports.mergeSourceRoot = mergeSourceRoot;
5
+ const core_1 = require("@angular-devkit/core");
6
+ const defaults_1 = require("../defaults");
7
+ function isInRootDirectory(host, extraFiles = []) {
8
+ const files = ['nest-cli.json', 'nest.json'].concat(extraFiles || []);
9
+ return files.map(file => host.exists(file)).some(isPresent => isPresent);
10
+ }
11
+ function mergeSourceRoot(options) {
12
+ return (host) => {
13
+ const isInRoot = isInRootDirectory(host, ['tsconfig.json', 'package.json']);
14
+ if (!isInRoot) {
15
+ return host;
16
+ }
17
+ const defaultSourceRoot = options.sourceRoot !== undefined ? options.sourceRoot : defaults_1.DEFAULT_PATH_NAME;
18
+ options.path =
19
+ options.path !== undefined
20
+ ? (0, core_1.join)((0, core_1.normalize)(defaultSourceRoot), options.path)
21
+ : (0, core_1.normalize)(defaultSourceRoot);
22
+ return host;
23
+ };
24
+ }
25
+ //# sourceMappingURL=source-root.helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source-root.helpers.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/schematics/utils/source-root.helpers.ts"],"names":[],"mappings":";;AAIA,8CAMC;AAED,0CAiBC;AA7BD,+CAAuD;AAEvD,0CAAgD;AAEhD,SAAgB,iBAAiB,CAC/B,IAAU,EACV,aAAuB,EAAE;IAEzB,MAAM,KAAK,GAAG,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;IACtE,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;AAC3E,CAAC;AAED,SAAgB,eAAe,CAE7B,OAAU;IACV,OAAO,CAAC,IAAU,EAAE,EAAE;QACpB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,EAAE,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC,CAAC;QAC5E,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,iBAAiB,GACrB,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,4BAAiB,CAAC;QAE5E,OAAO,CAAC,IAAI;YACV,OAAO,CAAC,IAAI,KAAK,SAAS;gBACxB,CAAC,CAAC,IAAA,WAAI,EAAC,IAAA,gBAAS,EAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC;gBAClD,CAAC,CAAC,IAAA,gBAAS,EAAC,iBAAiB,CAAC,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { join, normalize } from '@angular-devkit/core';
2
+ import { Rule, Tree } from '@angular-devkit/schematics';
3
+ import { DEFAULT_PATH_NAME } from '../defaults';
4
+
5
+ export function isInRootDirectory(
6
+ host: Tree,
7
+ extraFiles: string[] = [],
8
+ ): boolean {
9
+ const files = ['nest-cli.json', 'nest.json'].concat(extraFiles || []);
10
+ return files.map(file => host.exists(file)).some(isPresent => isPresent);
11
+ }
12
+
13
+ export function mergeSourceRoot<
14
+ T extends { sourceRoot?: string; path?: string } = any
15
+ >(options: T): Rule {
16
+ return (host: Tree) => {
17
+ const isInRoot = isInRootDirectory(host, ['tsconfig.json', 'package.json']);
18
+ if (!isInRoot) {
19
+ return host;
20
+ }
21
+ const defaultSourceRoot =
22
+ options.sourceRoot !== undefined ? options.sourceRoot : DEFAULT_PATH_NAME;
23
+
24
+ options.path =
25
+ options.path !== undefined
26
+ ? join(normalize(defaultSourceRoot), options.path)
27
+ : normalize(defaultSourceRoot);
28
+ return host;
29
+ };
30
+ }