@tsed/components-scan 7.0.0-beta.9 → 7.0.0-rc.3

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 (66) hide show
  1. package/lib/cjs/__mock__/controllers/rest/TestCtrl.js +12 -0
  2. package/lib/cjs/__mock__/controllers/rest/TestCtrl.js.map +1 -0
  3. package/lib/cjs/__mock__/module1/Module1.js +19 -0
  4. package/lib/cjs/__mock__/module1/Module1.js.map +1 -0
  5. package/lib/cjs/__mock__/module1/controllers/M1Ctrl1.js +18 -0
  6. package/lib/cjs/__mock__/module1/controllers/M1Ctrl1.js.map +1 -0
  7. package/lib/cjs/__mock__/module1/services/M1Service.js +18 -0
  8. package/lib/cjs/__mock__/module1/services/M1Service.js.map +1 -0
  9. package/lib/cjs/__mock__/module1/submodule/SubModule.js +15 -0
  10. package/lib/cjs/__mock__/module1/submodule/SubModule.js.map +1 -0
  11. package/lib/cjs/__mock__/module1/submodule/SubService.js +12 -0
  12. package/lib/cjs/__mock__/module1/submodule/SubService.js.map +1 -0
  13. package/lib/cjs/__mock__/module2/Module2.js +18 -0
  14. package/lib/cjs/__mock__/module2/Module2.js.map +1 -0
  15. package/lib/cjs/__mock__/module2/controllers/M2Ctrl.js +12 -0
  16. package/lib/cjs/__mock__/module2/controllers/M2Ctrl.js.map +1 -0
  17. package/lib/cjs/importFiles.js +3 -11
  18. package/lib/cjs/importFiles.js.map +1 -1
  19. package/lib/cjs/importProviders.js +50 -0
  20. package/lib/cjs/importProviders.js.map +1 -0
  21. package/lib/cjs/index.js +1 -1
  22. package/lib/cjs/index.js.map +1 -1
  23. package/lib/cjs/isTsEnv.js +1 -2
  24. package/lib/cjs/isTsEnv.js.map +1 -1
  25. package/lib/esm/__mock__/controllers/rest/TestCtrl.js +9 -0
  26. package/lib/esm/__mock__/controllers/rest/TestCtrl.js.map +1 -0
  27. package/lib/esm/__mock__/module1/Module1.js +16 -0
  28. package/lib/esm/__mock__/module1/Module1.js.map +1 -0
  29. package/lib/esm/__mock__/module1/controllers/M1Ctrl1.js +15 -0
  30. package/lib/esm/__mock__/module1/controllers/M1Ctrl1.js.map +1 -0
  31. package/lib/esm/__mock__/module1/services/M1Service.js +15 -0
  32. package/lib/esm/__mock__/module1/services/M1Service.js.map +1 -0
  33. package/lib/esm/__mock__/module1/submodule/SubModule.js +12 -0
  34. package/lib/esm/__mock__/module1/submodule/SubModule.js.map +1 -0
  35. package/lib/esm/__mock__/module1/submodule/SubService.js +9 -0
  36. package/lib/esm/__mock__/module1/submodule/SubService.js.map +1 -0
  37. package/lib/esm/__mock__/module2/Module2.js +15 -0
  38. package/lib/esm/__mock__/module2/Module2.js.map +1 -0
  39. package/lib/esm/__mock__/module2/controllers/M2Ctrl.js +9 -0
  40. package/lib/esm/__mock__/module2/controllers/M2Ctrl.js.map +1 -0
  41. package/lib/esm/importFiles.js +3 -11
  42. package/lib/esm/importFiles.js.map +1 -1
  43. package/lib/esm/importProviders.js +46 -0
  44. package/lib/esm/importProviders.js.map +1 -0
  45. package/lib/esm/index.js +1 -1
  46. package/lib/esm/index.js.map +1 -1
  47. package/lib/esm/isTsEnv.js +1 -2
  48. package/lib/esm/isTsEnv.js.map +1 -1
  49. package/lib/types/__mock__/controllers/rest/TestCtrl.d.ts +2 -0
  50. package/lib/types/__mock__/module1/Module1.d.ts +2 -0
  51. package/lib/types/__mock__/module1/controllers/M1Ctrl1.d.ts +5 -0
  52. package/lib/types/__mock__/module1/services/M1Service.d.ts +5 -0
  53. package/lib/types/__mock__/module1/submodule/SubModule.d.ts +2 -0
  54. package/lib/types/__mock__/module1/submodule/SubService.d.ts +2 -0
  55. package/lib/types/__mock__/module2/Module2.d.ts +2 -0
  56. package/lib/types/__mock__/module2/controllers/M2Ctrl.d.ts +2 -0
  57. package/lib/types/importProviders.d.ts +6 -0
  58. package/lib/types/index.d.ts +1 -1
  59. package/package.json +9 -5
  60. package/readme.md +3 -2
  61. package/tsconfig.compile.esm.json +1 -1
  62. package/lib/cjs/importComponents.js +0 -50
  63. package/lib/cjs/importComponents.js.map +0 -1
  64. package/lib/esm/importComponents.js +0 -45
  65. package/lib/esm/importComponents.js.map +0 -1
  66. package/lib/types/importComponents.d.ts +0 -8
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TestCtrl = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@tsed/di");
6
+ let TestCtrl = class TestCtrl {
7
+ };
8
+ TestCtrl = tslib_1.__decorate([
9
+ (0, di_1.Controller)("/root")
10
+ ], TestCtrl);
11
+ exports.TestCtrl = TestCtrl;
12
+ //# sourceMappingURL=TestCtrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestCtrl.js","sourceRoot":"","sources":["../../../../../src/__mock__/controllers/rest/TestCtrl.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AAGpC,IAAa,QAAQ,GAArB,MAAa,QAAQ;CAAG,CAAA;AAAX,QAAQ;IADpB,IAAA,eAAU,EAAC,OAAO,CAAC;GACP,QAAQ,CAAG;AAAX,4BAAQ","sourcesContent":["import {Controller} from \"@tsed/di\";\n\n@Controller(\"/root\")\nexport class TestCtrl {}\n"]}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Module1 = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const SubModule_1 = require("./submodule/SubModule");
6
+ const di_1 = require("@tsed/di");
7
+ const M1Ctrl1_1 = require("./controllers/M1Ctrl1");
8
+ let Module1 = class Module1 {
9
+ };
10
+ Module1 = tslib_1.__decorate([
11
+ (0, di_1.Module)({
12
+ mount: {
13
+ "/m1": [M1Ctrl1_1.M1Ctrl1]
14
+ },
15
+ imports: [SubModule_1.SubModule]
16
+ })
17
+ ], Module1);
18
+ exports.Module1 = Module1;
19
+ //# sourceMappingURL=Module1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Module1.js","sourceRoot":"","sources":["../../../../src/__mock__/module1/Module1.ts"],"names":[],"mappings":";;;;AAAA,qDAAgD;AAChD,iCAAgC;AAChC,mDAA8C;AAQ9C,IAAa,OAAO,GAApB,MAAa,OAAO;CAAG,CAAA;AAAV,OAAO;IANnB,IAAA,WAAM,EAAC;QACN,KAAK,EAAE;YACL,KAAK,EAAE,CAAC,iBAAO,CAAC;SACjB;QACD,OAAO,EAAE,CAAC,qBAAS,CAAC;KACrB,CAAC;GACW,OAAO,CAAG;AAAV,0BAAO","sourcesContent":["import {SubModule} from \"./submodule/SubModule\";\nimport {Module} from \"@tsed/di\";\nimport {M1Ctrl1} from \"./controllers/M1Ctrl1\";\n\n@Module({\n mount: {\n \"/m1\": [M1Ctrl1]\n },\n imports: [SubModule]\n})\nexport class Module1 {}\n"]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.M1Ctrl1 = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@tsed/di");
6
+ const M1Service_1 = require("../services/M1Service");
7
+ let M1Ctrl1 = class M1Ctrl1 {
8
+ service;
9
+ constructor(service) {
10
+ this.service = service;
11
+ }
12
+ };
13
+ M1Ctrl1 = tslib_1.__decorate([
14
+ (0, di_1.Controller)("/m1"),
15
+ tslib_1.__metadata("design:paramtypes", [M1Service_1.M1Service])
16
+ ], M1Ctrl1);
17
+ exports.M1Ctrl1 = M1Ctrl1;
18
+ //# sourceMappingURL=M1Ctrl1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"M1Ctrl1.js","sourceRoot":"","sources":["../../../../../src/__mock__/module1/controllers/M1Ctrl1.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AACpC,qDAAgD;AAGhD,IAAa,OAAO,GAApB,MAAa,OAAO;IACC;IAAnB,YAAmB,OAAkB;QAAlB,YAAO,GAAP,OAAO,CAAW;IAAG,CAAC;CAC1C,CAAA;AAFY,OAAO;IADnB,IAAA,eAAU,EAAC,KAAK,CAAC;6CAEY,qBAAS;GAD1B,OAAO,CAEnB;AAFY,0BAAO","sourcesContent":["import {Controller} from \"@tsed/di\";\nimport {M1Service} from \"../services/M1Service\";\n\n@Controller(\"/m1\")\nexport class M1Ctrl1 {\n constructor(public service: M1Service) {}\n}\n"]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.M1Service = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@tsed/di");
6
+ const SubService_1 = require("../submodule/SubService");
7
+ let M1Service = class M1Service {
8
+ subService;
9
+ constructor(subService) {
10
+ this.subService = subService;
11
+ }
12
+ };
13
+ M1Service = tslib_1.__decorate([
14
+ (0, di_1.Injectable)(),
15
+ tslib_1.__metadata("design:paramtypes", [SubService_1.SubService])
16
+ ], M1Service);
17
+ exports.M1Service = M1Service;
18
+ //# sourceMappingURL=M1Service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"M1Service.js","sourceRoot":"","sources":["../../../../../src/__mock__/module1/services/M1Service.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AACpC,wDAAmD;AAGnD,IAAa,SAAS,GAAtB,MAAa,SAAS;IACD;IAAnB,YAAmB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;CAC9C,CAAA;AAFY,SAAS;IADrB,IAAA,eAAU,GAAE;6CAEoB,uBAAU;GAD9B,SAAS,CAErB;AAFY,8BAAS","sourcesContent":["import {Injectable} from \"@tsed/di\";\nimport {SubService} from \"../submodule/SubService\";\n\n@Injectable()\nexport class M1Service {\n constructor(public subService: SubService) {}\n}\n"]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SubModule = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@tsed/di");
6
+ const SubService_1 = require("./SubService");
7
+ let SubModule = class SubModule {
8
+ };
9
+ SubModule = tslib_1.__decorate([
10
+ (0, di_1.Module)({
11
+ imports: [SubService_1.SubService]
12
+ })
13
+ ], SubModule);
14
+ exports.SubModule = SubModule;
15
+ //# sourceMappingURL=SubModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubModule.js","sourceRoot":"","sources":["../../../../../src/__mock__/module1/submodule/SubModule.ts"],"names":[],"mappings":";;;;AAAA,iCAAgC;AAChC,6CAAwC;AAKxC,IAAa,SAAS,GAAtB,MAAa,SAAS;CAAG,CAAA;AAAZ,SAAS;IAHrB,IAAA,WAAM,EAAC;QACN,OAAO,EAAE,CAAC,uBAAU,CAAC;KACtB,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS","sourcesContent":["import {Module} from \"@tsed/di\";\nimport {SubService} from \"./SubService\";\n\n@Module({\n imports: [SubService]\n})\nexport class SubModule {}\n"]}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SubService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@tsed/di");
6
+ let SubService = class SubService {
7
+ };
8
+ SubService = tslib_1.__decorate([
9
+ (0, di_1.Injectable)()
10
+ ], SubService);
11
+ exports.SubService = SubService;
12
+ //# sourceMappingURL=SubService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubService.js","sourceRoot":"","sources":["../../../../../src/__mock__/module1/submodule/SubService.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AAGpC,IAAa,UAAU,GAAvB,MAAa,UAAU;CAAG,CAAA;AAAb,UAAU;IADtB,IAAA,eAAU,GAAE;GACA,UAAU,CAAG;AAAb,gCAAU","sourcesContent":["import {Injectable} from \"@tsed/di\";\n\n@Injectable()\nexport class SubService {}\n"]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Module2 = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@tsed/di");
6
+ const M2Ctrl_1 = require("./controllers/M2Ctrl");
7
+ let Module2 = class Module2 {
8
+ };
9
+ Module2 = tslib_1.__decorate([
10
+ (0, di_1.Module)({
11
+ mount: {
12
+ "/mod2": [M2Ctrl_1.M2Ctrl]
13
+ },
14
+ imports: []
15
+ })
16
+ ], Module2);
17
+ exports.Module2 = Module2;
18
+ //# sourceMappingURL=Module2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Module2.js","sourceRoot":"","sources":["../../../../src/__mock__/module2/Module2.ts"],"names":[],"mappings":";;;;AAAA,iCAAgC;AAChC,iDAA4C;AAQ5C,IAAa,OAAO,GAApB,MAAa,OAAO;CAAG,CAAA;AAAV,OAAO;IANnB,IAAA,WAAM,EAAC;QACN,KAAK,EAAE;YACL,OAAO,EAAE,CAAC,eAAM,CAAC;SAClB;QACD,OAAO,EAAE,EAAE;KACZ,CAAC;GACW,OAAO,CAAG;AAAV,0BAAO","sourcesContent":["import {Module} from \"@tsed/di\";\nimport {M2Ctrl} from \"./controllers/M2Ctrl\";\n\n@Module({\n mount: {\n \"/mod2\": [M2Ctrl]\n },\n imports: []\n})\nexport class Module2 {}\n"]}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.M2Ctrl = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@tsed/di");
6
+ let M2Ctrl = class M2Ctrl {
7
+ };
8
+ M2Ctrl = tslib_1.__decorate([
9
+ (0, di_1.Controller)("/m2")
10
+ ], M2Ctrl);
11
+ exports.M2Ctrl = M2Ctrl;
12
+ //# sourceMappingURL=M2Ctrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"M2Ctrl.js","sourceRoot":"","sources":["../../../../../src/__mock__/module2/controllers/M2Ctrl.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AAGpC,IAAa,MAAM,GAAnB,MAAa,MAAM;CAAG,CAAA;AAAT,MAAM;IADlB,IAAA,eAAU,EAAC,KAAK,CAAC;GACL,MAAM,CAAG;AAAT,wBAAM","sourcesContent":["import {Controller} from \"@tsed/di\";\n\n@Controller(\"/m2\")\nexport class M2Ctrl {}\n"]}
@@ -30,19 +30,11 @@ async function importFiles(patterns, exclude) {
30
30
  const { default: globby } = await Promise.resolve().then(() => __importStar(require("globby")));
31
31
  const files = await globby((0, cleanGlobPatterns_1.cleanGlobPatterns)(patterns, exclude));
32
32
  const symbols = [];
33
- for (const file of files) {
33
+ for (const file of files.sort((a, b) => (a < b ? -1 : 1))) {
34
34
  if (!file.endsWith(".d.ts")) {
35
35
  // prevent .d.ts import if the global pattern isn't correctly configured
36
- try {
37
- const exports = await (0, core_1.importPackage)(file);
38
- Object.keys(exports).forEach((key) => symbols.push(exports[key]));
39
- }
40
- catch (er) {
41
- // istanbul ignore next
42
- console.error(er);
43
- // istanbul ignore next
44
- process.exit(1);
45
- }
36
+ const exports = await (0, core_1.importPackage)(file);
37
+ Object.keys(exports).forEach((key) => symbols.push(exports[key]));
46
38
  }
47
39
  }
48
40
  return symbols;
@@ -1 +1 @@
1
- {"version":3,"file":"importFiles.js","sourceRoot":"","sources":["../../src/importFiles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyC;AACzC,2DAAsD;AAE/C,KAAK,UAAU,WAAW,CAAC,QAA2B,EAAE,OAAiB;IAC9E,MAAM,EAAC,OAAO,EAAE,MAAM,EAAC,GAAG,wDAAa,QAAQ,GAAC,CAAC;IACjD,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,IAAA,qCAAiB,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IACjE,MAAM,OAAO,GAAU,EAAE,CAAC;IAE1B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC3B,wEAAwE;YACxE,IAAI;gBACF,MAAM,OAAO,GAAG,MAAM,IAAA,oBAAa,EAAC,IAAI,CAAC,CAAC;gBAC1C,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;aACnE;YAAC,OAAO,EAAE,EAAE;gBACX,uBAAuB;gBACvB,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBAClB,uBAAuB;gBACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACjB;SACF;KACF;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AArBD,kCAqBC","sourcesContent":["import {importPackage} from \"@tsed/core\";\nimport {cleanGlobPatterns} from \"./cleanGlobPatterns\";\n\nexport async function importFiles(patterns: string | string[], exclude: string[]): Promise<any[]> {\n const {default: globby} = await import(\"globby\");\n const files = await globby(cleanGlobPatterns(patterns, exclude));\n const symbols: any[] = [];\n\n for (const file of files) {\n if (!file.endsWith(\".d.ts\")) {\n // prevent .d.ts import if the global pattern isn't correctly configured\n try {\n const exports = await importPackage(file);\n Object.keys(exports).forEach((key) => symbols.push(exports[key]));\n } catch (er) {\n // istanbul ignore next\n console.error(er);\n // istanbul ignore next\n process.exit(1);\n }\n }\n }\n\n return symbols;\n}\n"]}
1
+ {"version":3,"file":"importFiles.js","sourceRoot":"","sources":["../../src/importFiles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyC;AACzC,2DAAsD;AAE/C,KAAK,UAAU,WAAW,CAAC,QAA2B,EAAE,OAAiB;IAC9E,MAAM,EAAC,OAAO,EAAE,MAAM,EAAC,GAAG,wDAAa,QAAQ,GAAC,CAAC;IAEjD,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,IAAA,qCAAiB,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IACjE,MAAM,OAAO,GAAU,EAAE,CAAC;IAE1B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;QACzD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC3B,wEAAwE;YACxE,MAAM,OAAO,GAAG,MAAM,IAAA,oBAAa,EAAC,IAAI,CAAC,CAAC;YAC1C,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACnE;KACF;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAfD,kCAeC","sourcesContent":["import {importPackage} from \"@tsed/core\";\nimport {cleanGlobPatterns} from \"./cleanGlobPatterns\";\n\nexport async function importFiles(patterns: string | string[], exclude: string[]): Promise<any[]> {\n const {default: globby} = await import(\"globby\");\n\n const files = await globby(cleanGlobPatterns(patterns, exclude));\n const symbols: any[] = [];\n\n for (const file of files.sort((a, b) => (a < b ? -1 : 1))) {\n if (!file.endsWith(\".d.ts\")) {\n // prevent .d.ts import if the global pattern isn't correctly configured\n const exports = await importPackage(file);\n Object.keys(exports).forEach((key) => symbols.push(exports[key]));\n }\n }\n\n return symbols;\n}\n"]}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.importProviders = void 0;
4
+ const di_1 = require("@tsed/di");
5
+ const core_1 = require("@tsed/core");
6
+ const importFiles_1 = require("./importFiles");
7
+ const lookup = ["imports", "componentsScan", "mount"];
8
+ async function resolveRecursively(items, exclude, rootDir) {
9
+ for (const index in items) {
10
+ if ((0, core_1.isString)(items[index])) {
11
+ items[index] = await (0, importFiles_1.importFiles)(items[index].replace("${rootDir}", rootDir), exclude);
12
+ }
13
+ }
14
+ const providers = items.flat().filter(core_1.isClass);
15
+ for (const token of providers) {
16
+ const provider = di_1.GlobalProviders.get(token);
17
+ if (provider?.type === di_1.ProviderType.MODULE && provider.configuration) {
18
+ provider.configuration.exclude = exclude;
19
+ provider.configuration.rootDir = provider.configuration.rootDir || rootDir;
20
+ provider.configuration = await importProviders(provider.configuration);
21
+ }
22
+ }
23
+ return providers;
24
+ }
25
+ /**
26
+ * Lookup settings and replace glob pattern by the resolved providers
27
+ *
28
+ * @param settings
29
+ */
30
+ async function importProviders(settings) {
31
+ const { exclude = [], rootDir } = settings;
32
+ for (const property of lookup) {
33
+ if (settings[property]) {
34
+ if (!(0, core_1.isArray)(settings[property])) {
35
+ const current = settings[property];
36
+ const promises = Object.entries(current).map(async ([key, items]) => {
37
+ current[key] = await resolveRecursively([].concat(items), exclude, rootDir);
38
+ });
39
+ await Promise.all(promises);
40
+ }
41
+ else {
42
+ settings[property] = await resolveRecursively(settings[property], exclude, rootDir);
43
+ }
44
+ }
45
+ }
46
+ settings.disableComponentsScan = true;
47
+ return settings;
48
+ }
49
+ exports.importProviders = importProviders;
50
+ //# sourceMappingURL=importProviders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importProviders.js","sourceRoot":"","sources":["../../src/importProviders.ts"],"names":[],"mappings":";;;AAAA,iCAAuD;AACvD,qCAAsD;AACtD,+CAA0C;AAE1C,MAAM,MAAM,GAAG,CAAC,SAAS,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAEtD,KAAK,UAAU,kBAAkB,CAAC,KAAY,EAAE,OAAiB,EAAE,OAAe;IAChF,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE;QACzB,IAAI,IAAA,eAAQ,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE;YAC1B,KAAK,CAAC,KAAK,CAAC,GAAG,MAAM,IAAA,yBAAW,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;SACxF;KACF;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,cAAO,CAAC,CAAC;IAE/C,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE;QAC7B,MAAM,QAAQ,GAAG,oBAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAE5C,IAAI,QAAQ,EAAE,IAAI,KAAK,iBAAY,CAAC,MAAM,IAAI,QAAQ,CAAC,aAAa,EAAE;YACpE,QAAQ,CAAC,aAAa,CAAC,OAAO,GAAG,OAAO,CAAC;YACzC,QAAQ,CAAC,aAAa,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,IAAI,OAAO,CAAC;YAE3E,QAAQ,CAAC,aAAa,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;SACxE;KACF;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACI,KAAK,UAAU,eAAe,CAAC,QAA6B;IACjE,MAAM,EAAC,OAAO,GAAG,EAAE,EAAE,OAAO,EAAC,GAAG,QAAQ,CAAC;IAEzC,KAAK,MAAM,QAAQ,IAAI,MAAM,EAAE;QAC7B,IAAI,QAAQ,CAAC,QAAQ,CAAC,EAAE;YACtB,IAAI,CAAC,IAAA,cAAO,EAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE;gBAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,KAAK,CAAgB,EAAE,EAAE;oBACjF,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,kBAAkB,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;gBAC9E,CAAC,CAAC,CAAC;gBAEH,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;aAC7B;iBAAM;gBACL,QAAQ,CAAC,QAAQ,CAAC,GAAG,MAAM,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;aACrF;SACF;KACF;IAED,QAAQ,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAEtC,OAAO,QAAQ,CAAC;AAClB,CAAC;AArBD,0CAqBC","sourcesContent":["import {GlobalProviders, ProviderType} from \"@tsed/di\";\nimport {isArray, isClass, isString} from \"@tsed/core\";\nimport {importFiles} from \"./importFiles\";\n\nconst lookup = [\"imports\", \"componentsScan\", \"mount\"];\n\nasync function resolveRecursively(items: any[], exclude: string[], rootDir: string) {\n for (const index in items) {\n if (isString(items[index])) {\n items[index] = await importFiles(items[index].replace(\"${rootDir}\", rootDir), exclude);\n }\n }\n\n const providers = items.flat().filter(isClass);\n\n for (const token of providers) {\n const provider = GlobalProviders.get(token);\n\n if (provider?.type === ProviderType.MODULE && provider.configuration) {\n provider.configuration.exclude = exclude;\n provider.configuration.rootDir = provider.configuration.rootDir || rootDir;\n\n provider.configuration = await importProviders(provider.configuration);\n }\n }\n\n return providers;\n}\n\n/**\n * Lookup settings and replace glob pattern by the resolved providers\n *\n * @param settings\n */\nexport async function importProviders(settings: Record<string, any>): Promise<Partial<TsED.Configuration>> {\n const {exclude = [], rootDir} = settings;\n\n for (const property of lookup) {\n if (settings[property]) {\n if (!isArray(settings[property])) {\n const current = settings[property];\n const promises = Object.entries(current).map(async ([key, items]: [string, any]) => {\n current[key] = await resolveRecursively([].concat(items), exclude, rootDir);\n });\n\n await Promise.all(promises);\n } else {\n settings[property] = await resolveRecursively(settings[property], exclude, rootDir);\n }\n }\n }\n\n settings.disableComponentsScan = true;\n\n return settings;\n}\n"]}
package/lib/cjs/index.js CHANGED
@@ -5,8 +5,8 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const tslib_1 = require("tslib");
7
7
  tslib_1.__exportStar(require("./cleanGlobPatterns"), exports);
8
- tslib_1.__exportStar(require("./importComponents"), exports);
9
8
  tslib_1.__exportStar(require("./importFiles"), exports);
9
+ tslib_1.__exportStar(require("./importProviders"), exports);
10
10
  tslib_1.__exportStar(require("./isTsEnv"), exports);
11
11
  tslib_1.__exportStar(require("./normalizePath"), exports);
12
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,8DAAoC;AACpC,6DAAmC;AACnC,wDAA8B;AAC9B,oDAA0B;AAC1B,0DAAgC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./cleanGlobPatterns\";\nexport * from \"./importComponents\";\nexport * from \"./importFiles\";\nexport * from \"./isTsEnv\";\nexport * from \"./normalizePath\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,8DAAoC;AACpC,wDAA8B;AAC9B,4DAAkC;AAClC,oDAA0B;AAC1B,0DAAgC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./cleanGlobPatterns\";\nexport * from \"./importFiles\";\nexport * from \"./importProviders\";\nexport * from \"./isTsEnv\";\nexport * from \"./normalizePath\";\n"]}
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isTsEnv = void 0;
4
4
  function isTsEnv() {
5
- var _a;
6
5
  try {
7
6
  if (require && require.extensions && require.extensions[".ts"]) {
8
7
  return true;
@@ -10,7 +9,7 @@ function isTsEnv() {
10
9
  }
11
10
  catch (er) { }
12
11
  return (process.env["TS_NODE_DEV"] ||
13
- ((_a = process.env["_"]) === null || _a === void 0 ? void 0 : _a.includes("ts-node")) ||
12
+ process.env["_"]?.includes("ts-node") ||
14
13
  process.env["TS_TEST"] ||
15
14
  process.env.JEST_WORKER_ID !== undefined ||
16
15
  process.env.NODE_ENV === "test");
@@ -1 +1 @@
1
- {"version":3,"file":"isTsEnv.js","sourceRoot":"","sources":["../../src/isTsEnv.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO;;IACrB,IAAI;QACF,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;YAC9D,OAAO,IAAI,CAAC;SACb;KACF;IAAC,OAAO,EAAE,EAAE,GAAE;IACf,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;SAC1B,MAAA,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,0CAAE,QAAQ,CAAC,SAAS,CAAC,CAAA;QACrC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,SAAS;QACxC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAChC,CAAC;AACJ,CAAC;AAbD,0BAaC","sourcesContent":["export function isTsEnv() {\n try {\n if (require && require.extensions && require.extensions[\".ts\"]) {\n return true;\n }\n } catch (er) {}\n return (\n process.env[\"TS_NODE_DEV\"] ||\n process.env[\"_\"]?.includes(\"ts-node\") ||\n process.env[\"TS_TEST\"] ||\n process.env.JEST_WORKER_ID !== undefined ||\n process.env.NODE_ENV === \"test\"\n );\n}\n"]}
1
+ {"version":3,"file":"isTsEnv.js","sourceRoot":"","sources":["../../src/isTsEnv.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO;IACrB,IAAI;QACF,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;YAC9D,OAAO,IAAI,CAAC;SACb;KACF;IAAC,OAAO,EAAE,EAAE,GAAE;IACf,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;QAC1B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,SAAS;QACxC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAChC,CAAC;AACJ,CAAC;AAbD,0BAaC","sourcesContent":["export function isTsEnv() {\n try {\n if (require && require.extensions && require.extensions[\".ts\"]) {\n return true;\n }\n } catch (er) {}\n return (\n process.env[\"TS_NODE_DEV\"] ||\n process.env[\"_\"]?.includes(\"ts-node\") ||\n process.env[\"TS_TEST\"] ||\n process.env.JEST_WORKER_ID !== undefined ||\n process.env.NODE_ENV === \"test\"\n );\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { __decorate } from "tslib";
2
+ import { Controller } from "@tsed/di";
3
+ let TestCtrl = class TestCtrl {
4
+ };
5
+ TestCtrl = __decorate([
6
+ Controller("/root")
7
+ ], TestCtrl);
8
+ export { TestCtrl };
9
+ //# sourceMappingURL=TestCtrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TestCtrl.js","sourceRoot":"","sources":["../../../../../src/__mock__/controllers/rest/TestCtrl.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAGpC,IAAa,QAAQ,GAArB,MAAa,QAAQ;CAAG,CAAA;AAAX,QAAQ;IADpB,UAAU,CAAC,OAAO,CAAC;GACP,QAAQ,CAAG;SAAX,QAAQ","sourcesContent":["import {Controller} from \"@tsed/di\";\n\n@Controller(\"/root\")\nexport class TestCtrl {}\n"]}
@@ -0,0 +1,16 @@
1
+ import { __decorate } from "tslib";
2
+ import { SubModule } from "./submodule/SubModule.js";
3
+ import { Module } from "@tsed/di";
4
+ import { M1Ctrl1 } from "./controllers/M1Ctrl1.js";
5
+ let Module1 = class Module1 {
6
+ };
7
+ Module1 = __decorate([
8
+ Module({
9
+ mount: {
10
+ "/m1": [M1Ctrl1]
11
+ },
12
+ imports: [SubModule]
13
+ })
14
+ ], Module1);
15
+ export { Module1 };
16
+ //# sourceMappingURL=Module1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Module1.js","sourceRoot":"","sources":["../../../../src/__mock__/module1/Module1.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAQ9C,IAAa,OAAO,GAApB,MAAa,OAAO;CAAG,CAAA;AAAV,OAAO;IANnB,MAAM,CAAC;QACN,KAAK,EAAE;YACL,KAAK,EAAE,CAAC,OAAO,CAAC;SACjB;QACD,OAAO,EAAE,CAAC,SAAS,CAAC;KACrB,CAAC;GACW,OAAO,CAAG;SAAV,OAAO","sourcesContent":["import {SubModule} from \"./submodule/SubModule\";\nimport {Module} from \"@tsed/di\";\nimport {M1Ctrl1} from \"./controllers/M1Ctrl1\";\n\n@Module({\n mount: {\n \"/m1\": [M1Ctrl1]\n },\n imports: [SubModule]\n})\nexport class Module1 {}\n"]}
@@ -0,0 +1,15 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Controller } from "@tsed/di";
3
+ import { M1Service } from "../services/M1Service.js";
4
+ let M1Ctrl1 = class M1Ctrl1 {
5
+ service;
6
+ constructor(service) {
7
+ this.service = service;
8
+ }
9
+ };
10
+ M1Ctrl1 = __decorate([
11
+ Controller("/m1"),
12
+ __metadata("design:paramtypes", [M1Service])
13
+ ], M1Ctrl1);
14
+ export { M1Ctrl1 };
15
+ //# sourceMappingURL=M1Ctrl1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"M1Ctrl1.js","sourceRoot":"","sources":["../../../../../src/__mock__/module1/controllers/M1Ctrl1.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAGhD,IAAa,OAAO,GAApB,MAAa,OAAO;IACC;IAAnB,YAAmB,OAAkB;QAAlB,YAAO,GAAP,OAAO,CAAW;IAAG,CAAC;CAC1C,CAAA;AAFY,OAAO;IADnB,UAAU,CAAC,KAAK,CAAC;qCAEY,SAAS;GAD1B,OAAO,CAEnB;SAFY,OAAO","sourcesContent":["import {Controller} from \"@tsed/di\";\nimport {M1Service} from \"../services/M1Service\";\n\n@Controller(\"/m1\")\nexport class M1Ctrl1 {\n constructor(public service: M1Service) {}\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { Injectable } from "@tsed/di";
3
+ import { SubService } from "../submodule/SubService.js";
4
+ let M1Service = class M1Service {
5
+ subService;
6
+ constructor(subService) {
7
+ this.subService = subService;
8
+ }
9
+ };
10
+ M1Service = __decorate([
11
+ Injectable(),
12
+ __metadata("design:paramtypes", [SubService])
13
+ ], M1Service);
14
+ export { M1Service };
15
+ //# sourceMappingURL=M1Service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"M1Service.js","sourceRoot":"","sources":["../../../../../src/__mock__/module1/services/M1Service.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AACpC,OAAO,EAAC,UAAU,EAAC,MAAM,yBAAyB,CAAC;AAGnD,IAAa,SAAS,GAAtB,MAAa,SAAS;IACD;IAAnB,YAAmB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;CAC9C,CAAA;AAFY,SAAS;IADrB,UAAU,EAAE;qCAEoB,UAAU;GAD9B,SAAS,CAErB;SAFY,SAAS","sourcesContent":["import {Injectable} from \"@tsed/di\";\nimport {SubService} from \"../submodule/SubService\";\n\n@Injectable()\nexport class M1Service {\n constructor(public subService: SubService) {}\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { __decorate } from "tslib";
2
+ import { Module } from "@tsed/di";
3
+ import { SubService } from "./SubService.js";
4
+ let SubModule = class SubModule {
5
+ };
6
+ SubModule = __decorate([
7
+ Module({
8
+ imports: [SubService]
9
+ })
10
+ ], SubModule);
11
+ export { SubModule };
12
+ //# sourceMappingURL=SubModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubModule.js","sourceRoot":"","sources":["../../../../../src/__mock__/module1/submodule/SubModule.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAKxC,IAAa,SAAS,GAAtB,MAAa,SAAS;CAAG,CAAA;AAAZ,SAAS;IAHrB,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,UAAU,CAAC;KACtB,CAAC;GACW,SAAS,CAAG;SAAZ,SAAS","sourcesContent":["import {Module} from \"@tsed/di\";\nimport {SubService} from \"./SubService\";\n\n@Module({\n imports: [SubService]\n})\nexport class SubModule {}\n"]}
@@ -0,0 +1,9 @@
1
+ import { __decorate } from "tslib";
2
+ import { Injectable } from "@tsed/di";
3
+ let SubService = class SubService {
4
+ };
5
+ SubService = __decorate([
6
+ Injectable()
7
+ ], SubService);
8
+ export { SubService };
9
+ //# sourceMappingURL=SubService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SubService.js","sourceRoot":"","sources":["../../../../../src/__mock__/module1/submodule/SubService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAGpC,IAAa,UAAU,GAAvB,MAAa,UAAU;CAAG,CAAA;AAAb,UAAU;IADtB,UAAU,EAAE;GACA,UAAU,CAAG;SAAb,UAAU","sourcesContent":["import {Injectable} from \"@tsed/di\";\n\n@Injectable()\nexport class SubService {}\n"]}
@@ -0,0 +1,15 @@
1
+ import { __decorate } from "tslib";
2
+ import { Module } from "@tsed/di";
3
+ import { M2Ctrl } from "./controllers/M2Ctrl.js";
4
+ let Module2 = class Module2 {
5
+ };
6
+ Module2 = __decorate([
7
+ Module({
8
+ mount: {
9
+ "/mod2": [M2Ctrl]
10
+ },
11
+ imports: []
12
+ })
13
+ ], Module2);
14
+ export { Module2 };
15
+ //# sourceMappingURL=Module2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Module2.js","sourceRoot":"","sources":["../../../../src/__mock__/module2/Module2.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAQ5C,IAAa,OAAO,GAApB,MAAa,OAAO;CAAG,CAAA;AAAV,OAAO;IANnB,MAAM,CAAC;QACN,KAAK,EAAE;YACL,OAAO,EAAE,CAAC,MAAM,CAAC;SAClB;QACD,OAAO,EAAE,EAAE;KACZ,CAAC;GACW,OAAO,CAAG;SAAV,OAAO","sourcesContent":["import {Module} from \"@tsed/di\";\nimport {M2Ctrl} from \"./controllers/M2Ctrl\";\n\n@Module({\n mount: {\n \"/mod2\": [M2Ctrl]\n },\n imports: []\n})\nexport class Module2 {}\n"]}
@@ -0,0 +1,9 @@
1
+ import { __decorate } from "tslib";
2
+ import { Controller } from "@tsed/di";
3
+ let M2Ctrl = class M2Ctrl {
4
+ };
5
+ M2Ctrl = __decorate([
6
+ Controller("/m2")
7
+ ], M2Ctrl);
8
+ export { M2Ctrl };
9
+ //# sourceMappingURL=M2Ctrl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"M2Ctrl.js","sourceRoot":"","sources":["../../../../../src/__mock__/module2/controllers/M2Ctrl.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAGpC,IAAa,MAAM,GAAnB,MAAa,MAAM;CAAG,CAAA;AAAT,MAAM;IADlB,UAAU,CAAC,KAAK,CAAC;GACL,MAAM,CAAG;SAAT,MAAM","sourcesContent":["import {Controller} from \"@tsed/di\";\n\n@Controller(\"/m2\")\nexport class M2Ctrl {}\n"]}
@@ -4,19 +4,11 @@ export async function importFiles(patterns, exclude) {
4
4
  const { default: globby } = await import("globby");
5
5
  const files = await globby(cleanGlobPatterns(patterns, exclude));
6
6
  const symbols = [];
7
- for (const file of files) {
7
+ for (const file of files.sort((a, b) => (a < b ? -1 : 1))) {
8
8
  if (!file.endsWith(".d.ts")) {
9
9
  // prevent .d.ts import if the global pattern isn't correctly configured
10
- try {
11
- const exports = await importPackage(file);
12
- Object.keys(exports).forEach((key) => symbols.push(exports[key]));
13
- }
14
- catch (er) {
15
- // istanbul ignore next
16
- console.error(er);
17
- // istanbul ignore next
18
- process.exit(1);
19
- }
10
+ const exports = await importPackage(file);
11
+ Object.keys(exports).forEach((key) => symbols.push(exports[key]));
20
12
  }
21
13
  }
22
14
  return symbols;
@@ -1 +1 @@
1
- {"version":3,"file":"importFiles.js","sourceRoot":"","sources":["../../src/importFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAEtD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAA2B,EAAE,OAAiB;IAC9E,MAAM,EAAC,OAAO,EAAE,MAAM,EAAC,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IACjE,MAAM,OAAO,GAAU,EAAE,CAAC;IAE1B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC3B,wEAAwE;YACxE,IAAI;gBACF,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,CAAC;gBAC1C,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;aACnE;YAAC,OAAO,EAAE,EAAE;gBACX,uBAAuB;gBACvB,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;gBAClB,uBAAuB;gBACvB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;aACjB;SACF;KACF;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {importPackage} from \"@tsed/core\";\nimport {cleanGlobPatterns} from \"./cleanGlobPatterns\";\n\nexport async function importFiles(patterns: string | string[], exclude: string[]): Promise<any[]> {\n const {default: globby} = await import(\"globby\");\n const files = await globby(cleanGlobPatterns(patterns, exclude));\n const symbols: any[] = [];\n\n for (const file of files) {\n if (!file.endsWith(\".d.ts\")) {\n // prevent .d.ts import if the global pattern isn't correctly configured\n try {\n const exports = await importPackage(file);\n Object.keys(exports).forEach((key) => symbols.push(exports[key]));\n } catch (er) {\n // istanbul ignore next\n console.error(er);\n // istanbul ignore next\n process.exit(1);\n }\n }\n }\n\n return symbols;\n}\n"]}
1
+ {"version":3,"file":"importFiles.js","sourceRoot":"","sources":["../../src/importFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAEtD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAA2B,EAAE,OAAiB;IAC9E,MAAM,EAAC,OAAO,EAAE,MAAM,EAAC,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEjD,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IACjE,MAAM,OAAO,GAAU,EAAE,CAAC;IAE1B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;QACzD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC3B,wEAAwE;YACxE,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,CAAC;YAC1C,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACnE;KACF;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {importPackage} from \"@tsed/core\";\nimport {cleanGlobPatterns} from \"./cleanGlobPatterns\";\n\nexport async function importFiles(patterns: string | string[], exclude: string[]): Promise<any[]> {\n const {default: globby} = await import(\"globby\");\n\n const files = await globby(cleanGlobPatterns(patterns, exclude));\n const symbols: any[] = [];\n\n for (const file of files.sort((a, b) => (a < b ? -1 : 1))) {\n if (!file.endsWith(\".d.ts\")) {\n // prevent .d.ts import if the global pattern isn't correctly configured\n const exports = await importPackage(file);\n Object.keys(exports).forEach((key) => symbols.push(exports[key]));\n }\n }\n\n return symbols;\n}\n"]}
@@ -0,0 +1,46 @@
1
+ import { GlobalProviders, ProviderType } from "@tsed/di";
2
+ import { isArray, isClass, isString } from "@tsed/core";
3
+ import { importFiles } from "./importFiles.js";
4
+ const lookup = ["imports", "componentsScan", "mount"];
5
+ async function resolveRecursively(items, exclude, rootDir) {
6
+ for (const index in items) {
7
+ if (isString(items[index])) {
8
+ items[index] = await importFiles(items[index].replace("${rootDir}", rootDir), exclude);
9
+ }
10
+ }
11
+ const providers = items.flat().filter(isClass);
12
+ for (const token of providers) {
13
+ const provider = GlobalProviders.get(token);
14
+ if (provider?.type === ProviderType.MODULE && provider.configuration) {
15
+ provider.configuration.exclude = exclude;
16
+ provider.configuration.rootDir = provider.configuration.rootDir || rootDir;
17
+ provider.configuration = await importProviders(provider.configuration);
18
+ }
19
+ }
20
+ return providers;
21
+ }
22
+ /**
23
+ * Lookup settings and replace glob pattern by the resolved providers
24
+ *
25
+ * @param settings
26
+ */
27
+ export async function importProviders(settings) {
28
+ const { exclude = [], rootDir } = settings;
29
+ for (const property of lookup) {
30
+ if (settings[property]) {
31
+ if (!isArray(settings[property])) {
32
+ const current = settings[property];
33
+ const promises = Object.entries(current).map(async ([key, items]) => {
34
+ current[key] = await resolveRecursively([].concat(items), exclude, rootDir);
35
+ });
36
+ await Promise.all(promises);
37
+ }
38
+ else {
39
+ settings[property] = await resolveRecursively(settings[property], exclude, rootDir);
40
+ }
41
+ }
42
+ }
43
+ settings.disableComponentsScan = true;
44
+ return settings;
45
+ }
46
+ //# sourceMappingURL=importProviders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importProviders.js","sourceRoot":"","sources":["../../src/importProviders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AACvD,OAAO,EAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AACtD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C,MAAM,MAAM,GAAG,CAAC,SAAS,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAEtD,KAAK,UAAU,kBAAkB,CAAC,KAAY,EAAE,OAAiB,EAAE,OAAe;IAChF,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE;QACzB,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE;YAC1B,KAAK,CAAC,KAAK,CAAC,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;SACxF;KACF;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE/C,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE;QAC7B,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAE5C,IAAI,QAAQ,EAAE,IAAI,KAAK,YAAY,CAAC,MAAM,IAAI,QAAQ,CAAC,aAAa,EAAE;YACpE,QAAQ,CAAC,aAAa,CAAC,OAAO,GAAG,OAAO,CAAC;YACzC,QAAQ,CAAC,aAAa,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,IAAI,OAAO,CAAC;YAE3E,QAAQ,CAAC,aAAa,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;SACxE;KACF;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,QAA6B;IACjE,MAAM,EAAC,OAAO,GAAG,EAAE,EAAE,OAAO,EAAC,GAAG,QAAQ,CAAC;IAEzC,KAAK,MAAM,QAAQ,IAAI,MAAM,EAAE;QAC7B,IAAI,QAAQ,CAAC,QAAQ,CAAC,EAAE;YACtB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE;gBAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,KAAK,CAAgB,EAAE,EAAE;oBACjF,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,kBAAkB,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;gBAC9E,CAAC,CAAC,CAAC;gBAEH,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;aAC7B;iBAAM;gBACL,QAAQ,CAAC,QAAQ,CAAC,GAAG,MAAM,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;aACrF;SACF;KACF;IAED,QAAQ,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAEtC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {GlobalProviders, ProviderType} from \"@tsed/di\";\nimport {isArray, isClass, isString} from \"@tsed/core\";\nimport {importFiles} from \"./importFiles\";\n\nconst lookup = [\"imports\", \"componentsScan\", \"mount\"];\n\nasync function resolveRecursively(items: any[], exclude: string[], rootDir: string) {\n for (const index in items) {\n if (isString(items[index])) {\n items[index] = await importFiles(items[index].replace(\"${rootDir}\", rootDir), exclude);\n }\n }\n\n const providers = items.flat().filter(isClass);\n\n for (const token of providers) {\n const provider = GlobalProviders.get(token);\n\n if (provider?.type === ProviderType.MODULE && provider.configuration) {\n provider.configuration.exclude = exclude;\n provider.configuration.rootDir = provider.configuration.rootDir || rootDir;\n\n provider.configuration = await importProviders(provider.configuration);\n }\n }\n\n return providers;\n}\n\n/**\n * Lookup settings and replace glob pattern by the resolved providers\n *\n * @param settings\n */\nexport async function importProviders(settings: Record<string, any>): Promise<Partial<TsED.Configuration>> {\n const {exclude = [], rootDir} = settings;\n\n for (const property of lookup) {\n if (settings[property]) {\n if (!isArray(settings[property])) {\n const current = settings[property];\n const promises = Object.entries(current).map(async ([key, items]: [string, any]) => {\n current[key] = await resolveRecursively([].concat(items), exclude, rootDir);\n });\n\n await Promise.all(promises);\n } else {\n settings[property] = await resolveRecursively(settings[property], exclude, rootDir);\n }\n }\n }\n\n settings.disableComponentsScan = true;\n\n return settings;\n}\n"]}
package/lib/esm/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
  * @file Automatically generated by barrelsby.
3
3
  */
4
4
  export * from "./cleanGlobPatterns.js";
5
- export * from "./importComponents.js";
6
5
  export * from "./importFiles.js";
6
+ export * from "./importProviders.js";
7
7
  export * from "./isTsEnv.js";
8
8
  export * from "./normalizePath.js";
9
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./cleanGlobPatterns\";\nexport * from \"./importComponents\";\nexport * from \"./importFiles\";\nexport * from \"./isTsEnv\";\nexport * from \"./normalizePath\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./cleanGlobPatterns\";\nexport * from \"./importFiles\";\nexport * from \"./importProviders\";\nexport * from \"./isTsEnv\";\nexport * from \"./normalizePath\";\n"]}
@@ -1,5 +1,4 @@
1
1
  export function isTsEnv() {
2
- var _a;
3
2
  try {
4
3
  if (require && require.extensions && require.extensions[".ts"]) {
5
4
  return true;
@@ -7,7 +6,7 @@ export function isTsEnv() {
7
6
  }
8
7
  catch (er) { }
9
8
  return (process.env["TS_NODE_DEV"] ||
10
- ((_a = process.env["_"]) === null || _a === void 0 ? void 0 : _a.includes("ts-node")) ||
9
+ process.env["_"]?.includes("ts-node") ||
11
10
  process.env["TS_TEST"] ||
12
11
  process.env.JEST_WORKER_ID !== undefined ||
13
12
  process.env.NODE_ENV === "test");
@@ -1 +1 @@
1
- {"version":3,"file":"isTsEnv.js","sourceRoot":"","sources":["../../src/isTsEnv.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO;;IACrB,IAAI;QACF,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;YAC9D,OAAO,IAAI,CAAC;SACb;KACF;IAAC,OAAO,EAAE,EAAE,GAAE;IACf,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;SAC1B,MAAA,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,0CAAE,QAAQ,CAAC,SAAS,CAAC,CAAA;QACrC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,SAAS;QACxC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAChC,CAAC;AACJ,CAAC","sourcesContent":["export function isTsEnv() {\n try {\n if (require && require.extensions && require.extensions[\".ts\"]) {\n return true;\n }\n } catch (er) {}\n return (\n process.env[\"TS_NODE_DEV\"] ||\n process.env[\"_\"]?.includes(\"ts-node\") ||\n process.env[\"TS_TEST\"] ||\n process.env.JEST_WORKER_ID !== undefined ||\n process.env.NODE_ENV === \"test\"\n );\n}\n"]}
1
+ {"version":3,"file":"isTsEnv.js","sourceRoot":"","sources":["../../src/isTsEnv.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO;IACrB,IAAI;QACF,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;YAC9D,OAAO,IAAI,CAAC;SACb;KACF;IAAC,OAAO,EAAE,EAAE,GAAE;IACf,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;QAC1B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,SAAS;QACxC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAChC,CAAC;AACJ,CAAC","sourcesContent":["export function isTsEnv() {\n try {\n if (require && require.extensions && require.extensions[\".ts\"]) {\n return true;\n }\n } catch (er) {}\n return (\n process.env[\"TS_NODE_DEV\"] ||\n process.env[\"_\"]?.includes(\"ts-node\") ||\n process.env[\"TS_TEST\"] ||\n process.env.JEST_WORKER_ID !== undefined ||\n process.env.NODE_ENV === \"test\"\n );\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare class TestCtrl {
2
+ }
@@ -0,0 +1,2 @@
1
+ export declare class Module1 {
2
+ }
@@ -0,0 +1,5 @@
1
+ import { M1Service } from "../services/M1Service";
2
+ export declare class M1Ctrl1 {
3
+ service: M1Service;
4
+ constructor(service: M1Service);
5
+ }
@@ -0,0 +1,5 @@
1
+ import { SubService } from "../submodule/SubService";
2
+ export declare class M1Service {
3
+ subService: SubService;
4
+ constructor(subService: SubService);
5
+ }
@@ -0,0 +1,2 @@
1
+ export declare class SubModule {
2
+ }
@@ -0,0 +1,2 @@
1
+ export declare class SubService {
2
+ }
@@ -0,0 +1,2 @@
1
+ export declare class Module2 {
2
+ }
@@ -0,0 +1,2 @@
1
+ export declare class M2Ctrl {
2
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Lookup settings and replace glob pattern by the resolved providers
3
+ *
4
+ * @param settings
5
+ */
6
+ export declare function importProviders(settings: Record<string, any>): Promise<Partial<TsED.Configuration>>;
@@ -2,7 +2,7 @@
2
2
  * @file Automatically generated by barrelsby.
3
3
  */
4
4
  export * from "./cleanGlobPatterns";
5
- export * from "./importComponents";
6
5
  export * from "./importFiles";
6
+ export * from "./importProviders";
7
7
  export * from "./isTsEnv";
8
8
  export * from "./normalizePath";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/components-scan",
3
- "version": "7.0.0-beta.9",
3
+ "version": "7.0.0-rc.3",
4
4
  "description": "Components scan utilities for Ts.ED Framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -23,10 +23,11 @@
23
23
  "dependencies": {
24
24
  "globby": "11.0.3",
25
25
  "normalize-path": "3.0.0",
26
- "tslib": "2.3.1"
26
+ "tslib": "2.4.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@tsed/core": "7.0.0-beta.9",
29
+ "@tsed/core": "7.0.0-rc.3",
30
+ "@tsed/di": "7.0.0-rc.3",
30
31
  "@types/normalize-path": "^3.0.0"
31
32
  },
32
33
  "peerDependencies": {},
@@ -34,7 +35,10 @@
34
35
  "bugs": {
35
36
  "url": "https://github.com/tsedio/tsed/issues"
36
37
  },
37
- "homepage": "https://github.com/tsedio/tsed/tree/beta/packages/utils/components-scan",
38
+ "homepage": "https://github.com/tsedio/tsed/tree/rc/packages/third-parties/components-scan",
38
39
  "author": "Romain Lenzotti",
39
- "license": "MIT"
40
+ "license": "MIT",
41
+ "publishConfig": {
42
+ "tag": "rc"
43
+ }
40
44
  }
package/readme.md CHANGED
@@ -11,7 +11,8 @@
11
11
  [![npm version](https://badge.fury.io/js/%40tsed%2Fcommon.svg)](https://badge.fury.io/js/%40tsed%2Fcommon)
12
12
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
13
13
  [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
14
- [![backers](https://opencollective.com/tsed/tiers/badge.svg)](https://opencollective.com/tsed)
14
+ [![github](https://img.shields.io/static/v1?label=Github%20sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/romakita)
15
+ [![opencollective](https://img.shields.io/static/v1?label=OpenCollective%20sponsor&message=%E2%9D%A4&logo=OpenCollective&color=%23fe8e86)](https://opencollective.com/tsed)
15
16
 
16
17
  </div>
17
18
 
@@ -49,7 +50,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
49
50
 
50
51
  The MIT License (MIT)
51
52
 
52
- Copyright (c) 2016 - 2018 Romain Lenzotti
53
+ Copyright (c) 2016 - 2022 Romain Lenzotti
53
54
 
54
55
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
55
56
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "extends": "./tsconfig.compile.json",
3
3
  "compilerOptions": {
4
- "baseUrl": ".",
4
+ "baseUrl": "./",
5
5
  "module": "ES2020",
6
6
  "rootDir": "src",
7
7
  "outDir": "./lib/esm",
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.importComponents = exports.mapConfiguration = void 0;
4
- const core_1 = require("@tsed/core");
5
- const importFiles_1 = require("./importFiles");
6
- async function resolveSymbols(item, excludes, disableComponentsScan = false) {
7
- if ((0, core_1.isClass)(item)) {
8
- return [item];
9
- }
10
- /* istanbul ignore else */
11
- if (!disableComponentsScan) {
12
- return (0, importFiles_1.importFiles)(item, excludes);
13
- }
14
- /* istanbul ignore next */
15
- return [];
16
- }
17
- function mapConfiguration(config) {
18
- if ((0, core_1.isArray)(config)) {
19
- return config.map((value) => {
20
- return {
21
- values: [].concat(value)
22
- };
23
- });
24
- }
25
- return Object.keys(config).reduce((list, key) => {
26
- list.push({
27
- endpoint: key,
28
- values: [].concat(config[key])
29
- });
30
- return list;
31
- }, []);
32
- }
33
- exports.mapConfiguration = mapConfiguration;
34
- async function importComponents(config, excludes, disableComponentsScan = false) {
35
- if (!config) {
36
- return [];
37
- }
38
- config = mapConfiguration(config);
39
- const promises = [];
40
- for (const option of config) {
41
- promises.push(...option.values.map(async (value) => {
42
- const symbols = await resolveSymbols(value, excludes, disableComponentsScan);
43
- return symbols.filter(core_1.isClass).map((symbol) => ({ token: symbol, route: option.endpoint }));
44
- }));
45
- }
46
- const result = await Promise.all(promises);
47
- return result.flat();
48
- }
49
- exports.importComponents = importComponents;
50
- //# sourceMappingURL=importComponents.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"importComponents.js","sourceRoot":"","sources":["../../src/importComponents.ts"],"names":[],"mappings":";;;AAAA,qCAA4C;AAC5C,+CAA0C;AAE1C,KAAK,UAAU,cAAc,CAAC,IAAS,EAAE,QAAkB,EAAE,qBAAqB,GAAG,KAAK;IACxF,IAAI,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC;KACf;IACD,0BAA0B;IAC1B,IAAI,CAAC,qBAAqB,EAAE;QAC1B,OAAO,IAAA,yBAAW,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;KACpC;IAED,0BAA0B;IAC1B,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAgB,gBAAgB,CAAC,MAAW;IAC1C,IAAI,IAAA,cAAO,EAAC,MAAM,CAAC,EAAE;QACnB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE;YAC/B,OAAO;gBACL,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;aACzB,CAAC;QACJ,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,IAAW,EAAE,GAAW,EAAE,EAAE;QAC7D,IAAI,CAAC,IAAI,CAAC;YACR,QAAQ,EAAE,GAAG;YACb,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SAC/B,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAjBD,4CAiBC;AAEM,KAAK,UAAU,gBAAgB,CACpC,MAAW,EACX,QAAkB,EAClB,qBAAqB,GAAG,KAAK;IAE7B,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,EAAE,CAAC;KACX;IAED,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAElC,MAAM,QAAQ,GAAQ,EAAE,CAAC;IAEzB,KAAK,MAAM,MAAM,IAAI,MAAM,EAAE;QAC3B,QAAQ,CAAC,IAAI,CACX,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAU,EAAE,EAAE;YACxC,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,qBAAqB,CAAC,CAAC;YAE7E,OAAO,OAAO,CAAC,MAAM,CAAC,cAAO,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAC,CAAC,CAAC,CAAC;QAC5F,CAAC,CAAC,CACH,CAAC;KACH;IAED,MAAM,MAAM,GAAwC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEhF,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC;AA1BD,4CA0BC","sourcesContent":["import {isArray, isClass} from \"@tsed/core\";\nimport {importFiles} from \"./importFiles\";\n\nasync function resolveSymbols(item: any, excludes: string[], disableComponentsScan = false) {\n if (isClass(item)) {\n return [item];\n }\n /* istanbul ignore else */\n if (!disableComponentsScan) {\n return importFiles(item, excludes);\n }\n\n /* istanbul ignore next */\n return [];\n}\n\nexport function mapConfiguration(config: any): {endpoint?: string; values: any[]}[] {\n if (isArray(config)) {\n return config.map((value: any) => {\n return {\n values: [].concat(value)\n };\n });\n }\n\n return Object.keys(config).reduce((list: any[], key: string) => {\n list.push({\n endpoint: key,\n values: [].concat(config[key])\n });\n\n return list;\n }, []);\n}\n\nexport async function importComponents(\n config: any,\n excludes: string[],\n disableComponentsScan = false\n): Promise<{token: string; route?: string}[]> {\n if (!config) {\n return [];\n }\n\n config = mapConfiguration(config);\n\n const promises: any = [];\n\n for (const option of config) {\n promises.push(\n ...option.values.map(async (value: any) => {\n const symbols = await resolveSymbols(value, excludes, disableComponentsScan);\n\n return symbols.filter(isClass).map((symbol) => ({token: symbol, route: option.endpoint}));\n })\n );\n }\n\n const result: {token: string; route?: string}[][] = await Promise.all(promises);\n\n return result.flat();\n}\n"]}
@@ -1,45 +0,0 @@
1
- import { isArray, isClass } from "@tsed/core";
2
- import { importFiles } from "./importFiles.js";
3
- async function resolveSymbols(item, excludes, disableComponentsScan = false) {
4
- if (isClass(item)) {
5
- return [item];
6
- }
7
- /* istanbul ignore else */
8
- if (!disableComponentsScan) {
9
- return importFiles(item, excludes);
10
- }
11
- /* istanbul ignore next */
12
- return [];
13
- }
14
- export function mapConfiguration(config) {
15
- if (isArray(config)) {
16
- return config.map((value) => {
17
- return {
18
- values: [].concat(value)
19
- };
20
- });
21
- }
22
- return Object.keys(config).reduce((list, key) => {
23
- list.push({
24
- endpoint: key,
25
- values: [].concat(config[key])
26
- });
27
- return list;
28
- }, []);
29
- }
30
- export async function importComponents(config, excludes, disableComponentsScan = false) {
31
- if (!config) {
32
- return [];
33
- }
34
- config = mapConfiguration(config);
35
- const promises = [];
36
- for (const option of config) {
37
- promises.push(...option.values.map(async (value) => {
38
- const symbols = await resolveSymbols(value, excludes, disableComponentsScan);
39
- return symbols.filter(isClass).map((symbol) => ({ token: symbol, route: option.endpoint }));
40
- }));
41
- }
42
- const result = await Promise.all(promises);
43
- return result.flat();
44
- }
45
- //# sourceMappingURL=importComponents.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"importComponents.js","sourceRoot":"","sources":["../../src/importComponents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C,KAAK,UAAU,cAAc,CAAC,IAAS,EAAE,QAAkB,EAAE,qBAAqB,GAAG,KAAK;IACxF,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC;KACf;IACD,0BAA0B;IAC1B,IAAI,CAAC,qBAAqB,EAAE;QAC1B,OAAO,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;KACpC;IAED,0BAA0B;IAC1B,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAW;IAC1C,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE;QACnB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE;YAC/B,OAAO;gBACL,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;aACzB,CAAC;QACJ,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,IAAW,EAAE,GAAW,EAAE,EAAE;QAC7D,IAAI,CAAC,IAAI,CAAC;YACR,QAAQ,EAAE,GAAG;YACb,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SAC/B,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAW,EACX,QAAkB,EAClB,qBAAqB,GAAG,KAAK;IAE7B,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,EAAE,CAAC;KACX;IAED,MAAM,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAElC,MAAM,QAAQ,GAAQ,EAAE,CAAC;IAEzB,KAAK,MAAM,MAAM,IAAI,MAAM,EAAE;QAC3B,QAAQ,CAAC,IAAI,CACX,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAU,EAAE,EAAE;YACxC,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,qBAAqB,CAAC,CAAC;YAE7E,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAC,CAAC,CAAC,CAAC;QAC5F,CAAC,CAAC,CACH,CAAC;KACH;IAED,MAAM,MAAM,GAAwC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEhF,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC","sourcesContent":["import {isArray, isClass} from \"@tsed/core\";\nimport {importFiles} from \"./importFiles\";\n\nasync function resolveSymbols(item: any, excludes: string[], disableComponentsScan = false) {\n if (isClass(item)) {\n return [item];\n }\n /* istanbul ignore else */\n if (!disableComponentsScan) {\n return importFiles(item, excludes);\n }\n\n /* istanbul ignore next */\n return [];\n}\n\nexport function mapConfiguration(config: any): {endpoint?: string; values: any[]}[] {\n if (isArray(config)) {\n return config.map((value: any) => {\n return {\n values: [].concat(value)\n };\n });\n }\n\n return Object.keys(config).reduce((list: any[], key: string) => {\n list.push({\n endpoint: key,\n values: [].concat(config[key])\n });\n\n return list;\n }, []);\n}\n\nexport async function importComponents(\n config: any,\n excludes: string[],\n disableComponentsScan = false\n): Promise<{token: string; route?: string}[]> {\n if (!config) {\n return [];\n }\n\n config = mapConfiguration(config);\n\n const promises: any = [];\n\n for (const option of config) {\n promises.push(\n ...option.values.map(async (value: any) => {\n const symbols = await resolveSymbols(value, excludes, disableComponentsScan);\n\n return symbols.filter(isClass).map((symbol) => ({token: symbol, route: option.endpoint}));\n })\n );\n }\n\n const result: {token: string; route?: string}[][] = await Promise.all(promises);\n\n return result.flat();\n}\n"]}
@@ -1,8 +0,0 @@
1
- export declare function mapConfiguration(config: any): {
2
- endpoint?: string;
3
- values: any[];
4
- }[];
5
- export declare function importComponents(config: any, excludes: string[], disableComponentsScan?: boolean): Promise<{
6
- token: string;
7
- route?: string;
8
- }[]>;