@tsed/components-scan 6.87.2 → 6.90.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 (60) hide show
  1. package/lib/{cleanGlobPatterns.d.ts → cjs/cleanGlobPatterns.d.ts} +0 -0
  2. package/lib/cjs/cleanGlobPatterns.js +25 -0
  3. package/lib/cjs/cleanGlobPatterns.js.map +1 -0
  4. package/lib/cjs/data/Test1.d.ts +3 -0
  5. package/lib/cjs/data/Test1.js +8 -0
  6. package/lib/cjs/data/Test1.js.map +1 -0
  7. package/lib/cjs/data/Test2.d.ts +3 -0
  8. package/lib/cjs/data/Test2.js +8 -0
  9. package/lib/cjs/data/Test2.js.map +1 -0
  10. package/lib/{importComponents.d.ts → cjs/importComponents.d.ts} +0 -0
  11. package/lib/cjs/importComponents.js +50 -0
  12. package/lib/cjs/importComponents.js.map +1 -0
  13. package/lib/{importFiles.d.ts → cjs/importFiles.d.ts} +0 -0
  14. package/lib/cjs/importFiles.js +47 -0
  15. package/lib/cjs/importFiles.js.map +1 -0
  16. package/lib/{importProviders.d.ts → cjs/importProviders.d.ts} +0 -0
  17. package/lib/cjs/importProviders.js +29 -0
  18. package/lib/cjs/importProviders.js.map +1 -0
  19. package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
  20. package/lib/cjs/index.js +9 -0
  21. package/lib/cjs/index.js.map +1 -0
  22. package/lib/{isTsEnv.d.ts → cjs/isTsEnv.d.ts} +0 -0
  23. package/lib/cjs/isTsEnv.js +11 -0
  24. package/lib/cjs/isTsEnv.js.map +1 -0
  25. package/lib/{normalizePath.d.ts → cjs/normalizePath.d.ts} +0 -0
  26. package/lib/cjs/normalizePath.js +18 -0
  27. package/lib/cjs/normalizePath.js.map +1 -0
  28. package/lib/esm/cleanGlobPatterns.js +21 -0
  29. package/lib/esm/cleanGlobPatterns.js.map +1 -0
  30. package/lib/esm/data/Test1.js +4 -0
  31. package/lib/esm/data/Test1.js.map +1 -0
  32. package/lib/esm/data/Test2.js +4 -0
  33. package/lib/esm/data/Test2.js.map +1 -0
  34. package/lib/esm/importComponents.js +45 -0
  35. package/lib/esm/importComponents.js.map +1 -0
  36. package/lib/esm/importFiles.js +24 -0
  37. package/lib/esm/importFiles.js.map +1 -0
  38. package/lib/esm/importProviders.js +25 -0
  39. package/lib/esm/importProviders.js.map +1 -0
  40. package/lib/esm/index.js +6 -0
  41. package/lib/esm/index.js.map +1 -0
  42. package/lib/esm/isTsEnv.js +7 -0
  43. package/lib/esm/isTsEnv.js.map +1 -0
  44. package/lib/esm/normalizePath.js +14 -0
  45. package/lib/esm/normalizePath.js.map +1 -0
  46. package/lib/types/cleanGlobPatterns.d.ts +1 -0
  47. package/lib/types/data/Test1.d.ts +3 -0
  48. package/lib/types/data/Test2.d.ts +3 -0
  49. package/lib/types/importComponents.d.ts +8 -0
  50. package/lib/types/importFiles.d.ts +1 -0
  51. package/lib/types/importProviders.d.ts +10 -0
  52. package/lib/types/index.d.ts +5 -0
  53. package/lib/types/isTsEnv.d.ts +2 -0
  54. package/lib/types/normalizePath.d.ts +2 -0
  55. package/package.json +12 -8
  56. package/tsconfig.compile.esm.json +23 -0
  57. package/lib/index.js +0 -194
  58. package/lib/index.js.map +0 -1
  59. package/lib/index.modern.js +0 -169
  60. package/lib/index.modern.js.map +0 -1
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cleanGlobPatterns = void 0;
4
+ const path_1 = require("path");
5
+ const isTsEnv_1 = require("./isTsEnv");
6
+ const normalizePath_1 = require("./normalizePath");
7
+ function mapExcludes(excludes) {
8
+ return excludes.map((s) => `!${s.replace(/!/gi, "")}`);
9
+ }
10
+ function mapExtensions(file) {
11
+ if (!(0, isTsEnv_1.isTsEnv)()) {
12
+ file = file.replace(/\.ts$/i, ".js").replace(/{\.ts,\.js}$/i, ".js");
13
+ }
14
+ return file;
15
+ }
16
+ function cleanGlobPatterns(files, excludes) {
17
+ return []
18
+ .concat(files)
19
+ .map((s) => (0, path_1.resolve)(s))
20
+ .concat(mapExcludes(excludes))
21
+ .map(mapExtensions)
22
+ .map((s) => (0, normalizePath_1.normalizePath)(s));
23
+ }
24
+ exports.cleanGlobPatterns = cleanGlobPatterns;
25
+ //# sourceMappingURL=cleanGlobPatterns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanGlobPatterns.js","sourceRoot":"","sources":["../../src/cleanGlobPatterns.ts"],"names":[],"mappings":";;;AAAA,+BAA6B;AAC7B,uCAAkC;AAClC,mDAA8C;AAE9C,SAAS,WAAW,CAAC,QAAkB;IACrC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,aAAa,CAAC,IAAY;IACjC,IAAI,CAAC,IAAA,iBAAO,GAAE,EAAE;QACd,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;KACtE;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,iBAAiB,CAAC,KAAwB,EAAE,QAAkB;IAC5E,OAAO,EAAE;SACN,MAAM,CAAC,KAAc,CAAC;SACtB,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,IAAA,cAAO,EAAC,CAAC,CAAC,CAAC;SAC9B,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAU,CAAC;SACtC,GAAG,CAAC,aAAa,CAAC;SAClB,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,IAAA,6BAAa,EAAC,CAAC,CAAC,CAAC,CAAC;AAC1C,CAAC;AAPD,8CAOC","sourcesContent":["import {resolve} from \"path\";\nimport {isTsEnv} from \"./isTsEnv\";\nimport {normalizePath} from \"./normalizePath\";\n\nfunction mapExcludes(excludes: string[]) {\n return excludes.map((s: string) => `!${s.replace(/!/gi, \"\")}`);\n}\n\nfunction mapExtensions(file: string): string {\n if (!isTsEnv()) {\n file = file.replace(/\\.ts$/i, \".js\").replace(/{\\.ts,\\.js}$/i, \".js\");\n }\n\n return file;\n}\n\nexport function cleanGlobPatterns(files: string | string[], excludes: string[]): string[] {\n return []\n .concat(files as never)\n .map((s: string) => resolve(s))\n .concat(mapExcludes(excludes) as never)\n .map(mapExtensions)\n .map((s: string) => normalizePath(s));\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const value1 = "value";
2
+ export declare class Test1 {
3
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Test1 = exports.value1 = void 0;
4
+ exports.value1 = "value";
5
+ class Test1 {
6
+ }
7
+ exports.Test1 = Test1;
8
+ //# sourceMappingURL=Test1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Test1.js","sourceRoot":"","sources":["../../../src/data/Test1.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG,OAAO,CAAC;AAE9B,MAAa,KAAK;CAAG;AAArB,sBAAqB","sourcesContent":["export const value1 = \"value\";\n\nexport class Test1 {}\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const value2 = "value";
2
+ export declare class Test2 {
3
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Test2 = exports.value2 = void 0;
4
+ exports.value2 = "value";
5
+ class Test2 {
6
+ }
7
+ exports.Test2 = Test2;
8
+ //# sourceMappingURL=Test2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Test2.js","sourceRoot":"","sources":["../../../src/data/Test2.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG,OAAO,CAAC;AAE9B,MAAa,KAAK;CAAG;AAArB,sBAAqB","sourcesContent":["export const value2 = \"value\";\n\nexport class Test2 {}\n"]}
@@ -0,0 +1,50 @@
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
@@ -0,0 +1 @@
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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O,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"]}
File without changes
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.importFiles = void 0;
23
+ const core_1 = require("@tsed/core");
24
+ const cleanGlobPatterns_1 = require("./cleanGlobPatterns");
25
+ async function importFiles(patterns, exclude) {
26
+ const { default: globby } = await Promise.resolve().then(() => __importStar(require("globby")));
27
+ const files = await globby((0, cleanGlobPatterns_1.cleanGlobPatterns)(patterns, exclude));
28
+ const symbols = [];
29
+ for (const file of files) {
30
+ if (!file.endsWith(".d.ts")) {
31
+ // prevent .d.ts import if the global pattern isn't correctly configured
32
+ try {
33
+ const exports = await (0, core_1.importPackage)(file);
34
+ Object.keys(exports).forEach((key) => symbols.push(exports[key]));
35
+ }
36
+ catch (er) {
37
+ // istanbul ignore next
38
+ console.error(er);
39
+ // istanbul ignore next
40
+ process.exit(1);
41
+ }
42
+ }
43
+ }
44
+ return symbols;
45
+ }
46
+ exports.importFiles = importFiles;
47
+ //# sourceMappingURL=importFiles.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.importProviders = void 0;
4
+ const di_1 = require("@tsed/di");
5
+ const importComponents_1 = require("./importComponents");
6
+ async function recursiveImports(providers, settings, properties) {
7
+ const { exclude = [] } = settings;
8
+ const promises = providers
9
+ .map(({ token }) => di_1.GlobalProviders.get(token))
10
+ .filter((provider) => (provider === null || provider === void 0 ? void 0 : provider.type) === di_1.ProviderType.MODULE && provider.configuration)
11
+ .map((provider) => importProviders({ exclude, ...provider.configuration }, properties));
12
+ return (await Promise.all(promises)).flat();
13
+ }
14
+ /**
15
+ * Import providers from given patterns.
16
+ *
17
+ * @param settings
18
+ * @param properties
19
+ */
20
+ async function importProviders(settings, properties = ["imports"]) {
21
+ const { exclude = [] } = settings;
22
+ const disableComponentsScan = settings.disableComponentsScan || !!process.env.WEBPACK;
23
+ const promises = properties.map((key) => (0, importComponents_1.importComponents)(settings[key], exclude, disableComponentsScan));
24
+ const providers = (await Promise.all(promises)).flat();
25
+ const children = await recursiveImports(providers, settings, properties);
26
+ return [...children, ...providers];
27
+ }
28
+ exports.importProviders = importProviders;
29
+ //# sourceMappingURL=importProviders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importProviders.js","sourceRoot":"","sources":["../../src/importProviders.ts"],"names":[],"mappings":";;;AAAA,iCAAiE;AACjE,yDAAoD;AAEpD,KAAK,UAAU,gBAAgB,CAAC,SAA4C,EAAE,QAAqC,EAAE,UAAoB;IACvI,MAAM,EAAC,OAAO,GAAG,EAAE,EAAC,GAAG,QAAQ,CAAC;IAEhC,MAAM,QAAQ,GAAG,SAAS;SACvB,GAAG,CAAC,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE,CAAC,oBAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SAC5C,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,MAAK,iBAAY,CAAC,MAAM,IAAI,QAAQ,CAAC,aAAa,CAAC;SACtF,GAAG,CAAC,CAAC,QAAkB,EAAE,EAAE,CAAC,eAAe,CAAC,EAAC,OAAO,EAAE,GAAG,QAAQ,CAAC,aAAa,EAAC,EAAE,UAAU,CAAC,CAAC,CAAC;IAElG,OAAO,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9C,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,eAAe,CACnC,QAAqC,EACrC,aAAuB,CAAC,SAAS,CAAC;IAElC,MAAM,EAAC,OAAO,GAAG,EAAE,EAAC,GAAG,QAAQ,CAAC;IAChC,MAAM,qBAAqB,GAAG,QAAQ,CAAC,qBAAqB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;IAEtF,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAA,mCAAgB,EAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAC1G,MAAM,SAAS,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvD,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IAEzE,OAAO,CAAC,GAAG,QAAQ,EAAE,GAAG,SAAS,CAAC,CAAC;AACrC,CAAC;AAZD,0CAYC","sourcesContent":["import {GlobalProviders, Provider, ProviderType} from \"@tsed/di\";\nimport {importComponents} from \"./importComponents\";\n\nasync function recursiveImports(providers: {token: string; route?: string}[], settings: Partial<TsED.Configuration>, properties: string[]) {\n const {exclude = []} = settings;\n\n const promises = providers\n .map(({token}) => GlobalProviders.get(token))\n .filter((provider) => provider?.type === ProviderType.MODULE && provider.configuration)\n .map((provider: Provider) => importProviders({exclude, ...provider.configuration}, properties));\n\n return (await Promise.all(promises)).flat();\n}\n\n/**\n * Import providers from given patterns.\n *\n * @param settings\n * @param properties\n */\nexport async function importProviders(\n settings: Partial<TsED.Configuration>,\n properties: string[] = [\"imports\"]\n): Promise<{token: string; route?: string}[]> {\n const {exclude = []} = settings;\n const disableComponentsScan = settings.disableComponentsScan || !!process.env.WEBPACK;\n\n const promises = properties.map((key) => importComponents(settings[key], exclude, disableComponentsScan));\n const providers = (await Promise.all(promises)).flat();\n const children = await recursiveImports(providers, settings, properties);\n\n return [...children, ...providers];\n}\n"]}
File without changes
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./importFiles"), exports);
5
+ (0, tslib_1.__exportStar)(require("./importComponents"), exports);
6
+ (0, tslib_1.__exportStar)(require("./importProviders"), exports);
7
+ (0, tslib_1.__exportStar)(require("./cleanGlobPatterns"), exports);
8
+ (0, tslib_1.__exportStar)(require("./normalizePath"), exports);
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAA8B;AAC9B,kEAAmC;AACnC,iEAAkC;AAClC,mEAAoC;AACpC,+DAAgC","sourcesContent":["export * from \"./importFiles\";\nexport * from \"./importComponents\";\nexport * from \"./importProviders\";\nexport * from \"./cleanGlobPatterns\";\nexport * from \"./normalizePath\";\n"]}
File without changes
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTsEnv = void 0;
4
+ function isTsEnv() {
5
+ return ((require && require.extensions && require.extensions[".ts"]) ||
6
+ process.env["TS_TEST"] ||
7
+ process.env.JEST_WORKER_ID !== undefined ||
8
+ process.env.NODE_ENV === "test");
9
+ }
10
+ exports.isTsEnv = isTsEnv;
11
+ //# sourceMappingURL=isTsEnv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isTsEnv.js","sourceRoot":"","sources":["../../src/isTsEnv.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO;IACrB,OAAO,CACL,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC5D,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;AAPD,0BAOC","sourcesContent":["export function isTsEnv() {\n return (\n (require && require.extensions && require.extensions[\".ts\"]) ||\n process.env[\"TS_TEST\"] ||\n process.env.JEST_WORKER_ID !== undefined ||\n process.env.NODE_ENV === \"test\"\n );\n}\n"]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizePath = void 0;
4
+ const core_1 = require("@tsed/core");
5
+ const path_1 = require("path");
6
+ const fixPath = require("normalize-path");
7
+ function normalizePath(item, ...paths) {
8
+ if ((0, core_1.isString)(item)) {
9
+ const path = (0, path_1.join)(item, ...paths);
10
+ return fixPath(path);
11
+ }
12
+ if ((0, core_1.isArray)(item)) {
13
+ return item.map((item) => normalizePath(item));
14
+ }
15
+ return item;
16
+ }
17
+ exports.normalizePath = normalizePath;
18
+ //# sourceMappingURL=normalizePath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizePath.js","sourceRoot":"","sources":["../../src/normalizePath.ts"],"names":[],"mappings":";;;AAAA,qCAA6C;AAC7C,+BAA0B;AAE1B,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAI1C,SAAgB,aAAa,CAAC,IAAS,EAAE,GAAG,KAAe;IACzD,IAAI,IAAA,eAAQ,EAAC,IAAI,CAAC,EAAE;QAClB,MAAM,IAAI,GAAG,IAAA,WAAI,EAAC,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC;QAClC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;KACtB;IAED,IAAI,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE;QACjB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;KACrD;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAXD,sCAWC","sourcesContent":["import {isArray, isString} from \"@tsed/core\";\nimport {join} from \"path\";\n\nconst fixPath = require(\"normalize-path\");\n\nexport function normalizePath(item: string, ...paths: string[]): string;\nexport function normalizePath(item: (string | any)[]): (string | any)[];\nexport function normalizePath(item: any, ...paths: string[]) {\n if (isString(item)) {\n const path = join(item, ...paths);\n return fixPath(path);\n }\n\n if (isArray(item)) {\n return item.map((item: any) => normalizePath(item));\n }\n\n return item;\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import { resolve } from "path";
2
+ import { isTsEnv } from "./isTsEnv";
3
+ import { normalizePath } from "./normalizePath";
4
+ function mapExcludes(excludes) {
5
+ return excludes.map((s) => `!${s.replace(/!/gi, "")}`);
6
+ }
7
+ function mapExtensions(file) {
8
+ if (!isTsEnv()) {
9
+ file = file.replace(/\.ts$/i, ".js").replace(/{\.ts,\.js}$/i, ".js");
10
+ }
11
+ return file;
12
+ }
13
+ export function cleanGlobPatterns(files, excludes) {
14
+ return []
15
+ .concat(files)
16
+ .map((s) => resolve(s))
17
+ .concat(mapExcludes(excludes))
18
+ .map(mapExtensions)
19
+ .map((s) => normalizePath(s));
20
+ }
21
+ //# sourceMappingURL=cleanGlobPatterns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cleanGlobPatterns.js","sourceRoot":"","sources":["../../src/cleanGlobPatterns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAE9C,SAAS,WAAW,CAAC,QAAkB;IACrC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,aAAa,CAAC,IAAY;IACjC,IAAI,CAAC,OAAO,EAAE,EAAE;QACd,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;KACtE;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAwB,EAAE,QAAkB;IAC5E,OAAO,EAAE;SACN,MAAM,CAAC,KAAc,CAAC;SACtB,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;SAC9B,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAU,CAAC;SACtC,GAAG,CAAC,aAAa,CAAC;SAClB,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["import {resolve} from \"path\";\nimport {isTsEnv} from \"./isTsEnv\";\nimport {normalizePath} from \"./normalizePath\";\n\nfunction mapExcludes(excludes: string[]) {\n return excludes.map((s: string) => `!${s.replace(/!/gi, \"\")}`);\n}\n\nfunction mapExtensions(file: string): string {\n if (!isTsEnv()) {\n file = file.replace(/\\.ts$/i, \".js\").replace(/{\\.ts,\\.js}$/i, \".js\");\n }\n\n return file;\n}\n\nexport function cleanGlobPatterns(files: string | string[], excludes: string[]): string[] {\n return []\n .concat(files as never)\n .map((s: string) => resolve(s))\n .concat(mapExcludes(excludes) as never)\n .map(mapExtensions)\n .map((s: string) => normalizePath(s));\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export const value1 = "value";
2
+ export class Test1 {
3
+ }
4
+ //# sourceMappingURL=Test1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Test1.js","sourceRoot":"","sources":["../../../src/data/Test1.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC;AAE9B,MAAM,OAAO,KAAK;CAAG","sourcesContent":["export const value1 = \"value\";\n\nexport class Test1 {}\n"]}
@@ -0,0 +1,4 @@
1
+ export const value2 = "value";
2
+ export class Test2 {
3
+ }
4
+ //# sourceMappingURL=Test2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Test2.js","sourceRoot":"","sources":["../../../src/data/Test2.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,OAAO,CAAC;AAE9B,MAAM,OAAO,KAAK;CAAG","sourcesContent":["export const value2 = \"value\";\n\nexport class Test2 {}\n"]}
@@ -0,0 +1,45 @@
1
+ import { isArray, isClass } from "@tsed/core";
2
+ import { importFiles } from "./importFiles";
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
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,24 @@
1
+ import { importPackage } from "@tsed/core";
2
+ import { cleanGlobPatterns } from "./cleanGlobPatterns";
3
+ export async function importFiles(patterns, exclude) {
4
+ const { default: globby } = await import("globby");
5
+ const files = await globby(cleanGlobPatterns(patterns, exclude));
6
+ const symbols = [];
7
+ for (const file of files) {
8
+ if (!file.endsWith(".d.ts")) {
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
+ }
20
+ }
21
+ }
22
+ return symbols;
23
+ }
24
+ //# sourceMappingURL=importFiles.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,25 @@
1
+ import { GlobalProviders, ProviderType } from "@tsed/di";
2
+ import { importComponents } from "./importComponents";
3
+ async function recursiveImports(providers, settings, properties) {
4
+ const { exclude = [] } = settings;
5
+ const promises = providers
6
+ .map(({ token }) => GlobalProviders.get(token))
7
+ .filter((provider) => (provider === null || provider === void 0 ? void 0 : provider.type) === ProviderType.MODULE && provider.configuration)
8
+ .map((provider) => importProviders({ exclude, ...provider.configuration }, properties));
9
+ return (await Promise.all(promises)).flat();
10
+ }
11
+ /**
12
+ * Import providers from given patterns.
13
+ *
14
+ * @param settings
15
+ * @param properties
16
+ */
17
+ export async function importProviders(settings, properties = ["imports"]) {
18
+ const { exclude = [] } = settings;
19
+ const disableComponentsScan = settings.disableComponentsScan || !!process.env.WEBPACK;
20
+ const promises = properties.map((key) => importComponents(settings[key], exclude, disableComponentsScan));
21
+ const providers = (await Promise.all(promises)).flat();
22
+ const children = await recursiveImports(providers, settings, properties);
23
+ return [...children, ...providers];
24
+ }
25
+ //# sourceMappingURL=importProviders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"importProviders.js","sourceRoot":"","sources":["../../src/importProviders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAY,YAAY,EAAC,MAAM,UAAU,CAAC;AACjE,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAEpD,KAAK,UAAU,gBAAgB,CAAC,SAA4C,EAAE,QAAqC,EAAE,UAAoB;IACvI,MAAM,EAAC,OAAO,GAAG,EAAE,EAAC,GAAG,QAAQ,CAAC;IAEhC,MAAM,QAAQ,GAAG,SAAS;SACvB,GAAG,CAAC,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SAC5C,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,MAAK,YAAY,CAAC,MAAM,IAAI,QAAQ,CAAC,aAAa,CAAC;SACtF,GAAG,CAAC,CAAC,QAAkB,EAAE,EAAE,CAAC,eAAe,CAAC,EAAC,OAAO,EAAE,GAAG,QAAQ,CAAC,aAAa,EAAC,EAAE,UAAU,CAAC,CAAC,CAAC;IAElG,OAAO,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9C,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,QAAqC,EACrC,aAAuB,CAAC,SAAS,CAAC;IAElC,MAAM,EAAC,OAAO,GAAG,EAAE,EAAC,GAAG,QAAQ,CAAC;IAChC,MAAM,qBAAqB,GAAG,QAAQ,CAAC,qBAAqB,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;IAEtF,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAC1G,MAAM,SAAS,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvD,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;IAEzE,OAAO,CAAC,GAAG,QAAQ,EAAE,GAAG,SAAS,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import {GlobalProviders, Provider, ProviderType} from \"@tsed/di\";\nimport {importComponents} from \"./importComponents\";\n\nasync function recursiveImports(providers: {token: string; route?: string}[], settings: Partial<TsED.Configuration>, properties: string[]) {\n const {exclude = []} = settings;\n\n const promises = providers\n .map(({token}) => GlobalProviders.get(token))\n .filter((provider) => provider?.type === ProviderType.MODULE && provider.configuration)\n .map((provider: Provider) => importProviders({exclude, ...provider.configuration}, properties));\n\n return (await Promise.all(promises)).flat();\n}\n\n/**\n * Import providers from given patterns.\n *\n * @param settings\n * @param properties\n */\nexport async function importProviders(\n settings: Partial<TsED.Configuration>,\n properties: string[] = [\"imports\"]\n): Promise<{token: string; route?: string}[]> {\n const {exclude = []} = settings;\n const disableComponentsScan = settings.disableComponentsScan || !!process.env.WEBPACK;\n\n const promises = properties.map((key) => importComponents(settings[key], exclude, disableComponentsScan));\n const providers = (await Promise.all(promises)).flat();\n const children = await recursiveImports(providers, settings, properties);\n\n return [...children, ...providers];\n}\n"]}
@@ -0,0 +1,6 @@
1
+ export * from "./importFiles";
2
+ export * from "./importComponents";
3
+ export * from "./importProviders";
4
+ export * from "./cleanGlobPatterns";
5
+ export * from "./normalizePath";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC","sourcesContent":["export * from \"./importFiles\";\nexport * from \"./importComponents\";\nexport * from \"./importProviders\";\nexport * from \"./cleanGlobPatterns\";\nexport * from \"./normalizePath\";\n"]}
@@ -0,0 +1,7 @@
1
+ export function isTsEnv() {
2
+ return ((require && require.extensions && require.extensions[".ts"]) ||
3
+ process.env["TS_TEST"] ||
4
+ process.env.JEST_WORKER_ID !== undefined ||
5
+ process.env.NODE_ENV === "test");
6
+ }
7
+ //# sourceMappingURL=isTsEnv.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isTsEnv.js","sourceRoot":"","sources":["../../src/isTsEnv.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO;IACrB,OAAO,CACL,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC5D,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 return (\n (require && require.extensions && require.extensions[\".ts\"]) ||\n process.env[\"TS_TEST\"] ||\n process.env.JEST_WORKER_ID !== undefined ||\n process.env.NODE_ENV === \"test\"\n );\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { isArray, isString } from "@tsed/core";
2
+ import { join } from "path";
3
+ const fixPath = require("normalize-path");
4
+ export function normalizePath(item, ...paths) {
5
+ if (isString(item)) {
6
+ const path = join(item, ...paths);
7
+ return fixPath(path);
8
+ }
9
+ if (isArray(item)) {
10
+ return item.map((item) => normalizePath(item));
11
+ }
12
+ return item;
13
+ }
14
+ //# sourceMappingURL=normalizePath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizePath.js","sourceRoot":"","sources":["../../src/normalizePath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAE1B,MAAM,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAI1C,MAAM,UAAU,aAAa,CAAC,IAAS,EAAE,GAAG,KAAe;IACzD,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE;QAClB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,CAAC;QAClC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;KACtB;IAED,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;QACjB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;KACrD;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import {isArray, isString} from \"@tsed/core\";\nimport {join} from \"path\";\n\nconst fixPath = require(\"normalize-path\");\n\nexport function normalizePath(item: string, ...paths: string[]): string;\nexport function normalizePath(item: (string | any)[]): (string | any)[];\nexport function normalizePath(item: any, ...paths: string[]) {\n if (isString(item)) {\n const path = join(item, ...paths);\n return fixPath(path);\n }\n\n if (isArray(item)) {\n return item.map((item: any) => normalizePath(item));\n }\n\n return item;\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare function cleanGlobPatterns(files: string | string[], excludes: string[]): string[];
@@ -0,0 +1,3 @@
1
+ export declare const value1 = "value";
2
+ export declare class Test1 {
3
+ }
@@ -0,0 +1,3 @@
1
+ export declare const value2 = "value";
2
+ export declare class Test2 {
3
+ }
@@ -0,0 +1,8 @@
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
+ }[]>;
@@ -0,0 +1 @@
1
+ export declare function importFiles(patterns: string | string[], exclude: string[]): Promise<any[]>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Import providers from given patterns.
3
+ *
4
+ * @param settings
5
+ * @param properties
6
+ */
7
+ export declare function importProviders(settings: Partial<TsED.Configuration>, properties?: string[]): Promise<{
8
+ token: string;
9
+ route?: string;
10
+ }[]>;
@@ -0,0 +1,5 @@
1
+ export * from "./importFiles";
2
+ export * from "./importComponents";
3
+ export * from "./importProviders";
4
+ export * from "./cleanGlobPatterns";
5
+ export * from "./normalizePath";
@@ -0,0 +1,2 @@
1
+ /// <reference types="node" />
2
+ export declare function isTsEnv(): string | boolean | ((m: NodeJS.Module, filename: string) => any);
@@ -0,0 +1,2 @@
1
+ export declare function normalizePath(item: string, ...paths: string[]): string;
2
+ export declare function normalizePath(item: (string | any)[]): (string | any)[];
package/package.json CHANGED
@@ -1,22 +1,26 @@
1
1
  {
2
2
  "name": "@tsed/components-scan",
3
- "version": "6.87.2",
3
+ "version": "6.90.0",
4
4
  "description": "Components scan utilities for Ts.ED Framework",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
7
- "main": "./lib/index.js",
8
- "typings": "./lib/index.d.ts",
7
+ "main": "./lib/cjs/index.js",
8
+ "typings": "./lib/types/index.d.ts",
9
9
  "exports": {
10
- "require": "./lib/index.js",
11
- "default": "./lib/index.modern.js"
10
+ "types": "./lib/types/index.d.ts",
11
+ "import": "./lib/esm/index.js",
12
+ "require": "./lib/cjs/index.js",
13
+ "default": "./lib/esm/index.js"
12
14
  },
13
15
  "scripts": {
14
- "build": "microbundle --target node --no-compress --format modern,cjs --tsconfig ./tsconfig.compile.json",
16
+ "build": "yarn run build:esm && yarn run build:cjs",
17
+ "build:cjs": "tsc --build tsconfig.compile.json",
18
+ "build:esm": "tsc --build tsconfig.compile.esm.json",
15
19
  "test": "cross-env NODE_ENV=test jest"
16
20
  },
17
21
  "dependencies": {
18
- "@tsed/core": "6.87.2",
19
- "@tsed/di": "6.87.2",
22
+ "@tsed/core": "6.90.0",
23
+ "@tsed/di": "6.90.0",
20
24
  "globby": "11.0.3",
21
25
  "normalize-path": "3.0.0",
22
26
  "tslib": "2.2.0"
@@ -0,0 +1,23 @@
1
+ {
2
+ "extends": "./tsconfig.compile.json",
3
+ "compilerOptions": {
4
+ "baseUrl": ".",
5
+ "module": "ES2020",
6
+ "rootDir": "src",
7
+ "outDir": "./lib/esm",
8
+ "declaration": true,
9
+ "declarationDir": "./lib/types"
10
+ },
11
+ "exclude": [
12
+ "node_modules",
13
+ "test",
14
+ "lib",
15
+ "benchmark",
16
+ "coverage",
17
+ "spec",
18
+ "**/*.benchmark.ts",
19
+ "**/*.spec.ts",
20
+ "keys",
21
+ "jest.config.js"
22
+ ]
23
+ }
package/lib/index.js DELETED
@@ -1,194 +0,0 @@
1
- var core = require('@tsed/core');
2
- var path = require('path');
3
- var di = require('@tsed/di');
4
-
5
- function _interopNamespace(e) {
6
- if (e && e.__esModule) return e;
7
- var n = Object.create(null);
8
- if (e) {
9
- Object.keys(e).forEach(function (k) {
10
- if (k !== 'default') {
11
- var d = Object.getOwnPropertyDescriptor(e, k);
12
- Object.defineProperty(n, k, d.get ? d : {
13
- enumerable: true,
14
- get: function () {
15
- return e[k];
16
- }
17
- });
18
- }
19
- });
20
- }
21
- n['default'] = e;
22
- return n;
23
- }
24
-
25
- function isTsEnv() {
26
- return require && require.extensions && require.extensions[".ts"] || process.env["TS_TEST"] || process.env.JEST_WORKER_ID !== undefined || process.env.NODE_ENV === "test";
27
- }
28
-
29
- const fixPath = require("normalize-path");
30
-
31
- function normalizePath(item, ...paths) {
32
- if (core.isString(item)) {
33
- const path$1 = path.join(item, ...paths);
34
- return fixPath(path$1);
35
- }
36
-
37
- if (core.isArray(item)) {
38
- return item.map(item => normalizePath(item));
39
- }
40
-
41
- return item;
42
- }
43
-
44
- function mapExcludes(excludes) {
45
- return excludes.map(s => `!${s.replace(/!/gi, "")}`);
46
- }
47
-
48
- function mapExtensions(file) {
49
- if (!isTsEnv()) {
50
- file = file.replace(/\.ts$/i, ".js").replace(/{\.ts,\.js}$/i, ".js");
51
- }
52
-
53
- return file;
54
- }
55
-
56
- function cleanGlobPatterns(files, excludes) {
57
- return [].concat(files).map(s => path.resolve(s)).concat(mapExcludes(excludes)).map(mapExtensions).map(s => normalizePath(s));
58
- }
59
-
60
- async function importFiles(patterns, exclude) {
61
- const {
62
- default: globby
63
- } = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('globby')); });
64
- const files = await globby(cleanGlobPatterns(patterns, exclude));
65
- const symbols = [];
66
-
67
- for (const file of files) {
68
- if (!file.endsWith(".d.ts")) {
69
- // prevent .d.ts import if the global pattern isn't correctly configured
70
- try {
71
- const exports = await core.importPackage(file);
72
- Object.keys(exports).forEach(key => symbols.push(exports[key]));
73
- } catch (er) {
74
- // istanbul ignore next
75
- console.error(er); // istanbul ignore next
76
-
77
- process.exit(1);
78
- }
79
- }
80
- }
81
-
82
- return symbols;
83
- }
84
-
85
- async function resolveSymbols(item, excludes, disableComponentsScan = false) {
86
- if (core.isClass(item)) {
87
- return [item];
88
- }
89
- /* istanbul ignore else */
90
-
91
-
92
- if (!disableComponentsScan) {
93
- return importFiles(item, excludes);
94
- }
95
- /* istanbul ignore next */
96
-
97
-
98
- return [];
99
- }
100
-
101
- function mapConfiguration(config) {
102
- if (core.isArray(config)) {
103
- return config.map(value => {
104
- return {
105
- values: [].concat(value)
106
- };
107
- });
108
- }
109
-
110
- return Object.keys(config).reduce((list, key) => {
111
- list.push({
112
- endpoint: key,
113
- values: [].concat(config[key])
114
- });
115
- return list;
116
- }, []);
117
- }
118
- async function importComponents(config, excludes, disableComponentsScan = false) {
119
- if (!config) {
120
- return [];
121
- }
122
-
123
- config = mapConfiguration(config);
124
- const promises = [];
125
-
126
- for (const option of config) {
127
- promises.push(...option.values.map(async value => {
128
- const symbols = await resolveSymbols(value, excludes, disableComponentsScan);
129
- return symbols.filter(core.isClass).map(symbol => ({
130
- token: symbol,
131
- route: option.endpoint
132
- }));
133
- }));
134
- }
135
-
136
- const result = await Promise.all(promises);
137
- return result.flat();
138
- }
139
-
140
- function _extends() {
141
- _extends = Object.assign || function (target) {
142
- for (var i = 1; i < arguments.length; i++) {
143
- var source = arguments[i];
144
-
145
- for (var key in source) {
146
- if (Object.prototype.hasOwnProperty.call(source, key)) {
147
- target[key] = source[key];
148
- }
149
- }
150
- }
151
-
152
- return target;
153
- };
154
-
155
- return _extends.apply(this, arguments);
156
- }
157
-
158
- async function recursiveImports(providers, settings, properties) {
159
- const {
160
- exclude = []
161
- } = settings;
162
- const promises = providers.map(({
163
- token
164
- }) => di.GlobalProviders.get(token)).filter(provider => (provider == null ? void 0 : provider.type) === di.ProviderType.MODULE && provider.configuration).map(provider => importProviders(_extends({
165
- exclude
166
- }, provider.configuration), properties));
167
- return (await Promise.all(promises)).flat();
168
- }
169
- /**
170
- * Import providers from given patterns.
171
- *
172
- * @param settings
173
- * @param properties
174
- */
175
-
176
-
177
- async function importProviders(settings, properties = ["imports"]) {
178
- const {
179
- exclude = []
180
- } = settings;
181
- const disableComponentsScan = settings.disableComponentsScan || !!process.env.WEBPACK;
182
- const promises = properties.map(key => importComponents(settings[key], exclude, disableComponentsScan));
183
- const providers = (await Promise.all(promises)).flat();
184
- const children = await recursiveImports(providers, settings, properties);
185
- return [...children, ...providers];
186
- }
187
-
188
- exports.cleanGlobPatterns = cleanGlobPatterns;
189
- exports.importComponents = importComponents;
190
- exports.importFiles = importFiles;
191
- exports.importProviders = importProviders;
192
- exports.mapConfiguration = mapConfiguration;
193
- exports.normalizePath = normalizePath;
194
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/isTsEnv.ts","../src/normalizePath.ts","../src/cleanGlobPatterns.ts","../src/importFiles.ts","../src/importComponents.ts","../src/importProviders.ts"],"sourcesContent":["export function isTsEnv() {\n return (\n (require && require.extensions && require.extensions[\".ts\"]) ||\n process.env[\"TS_TEST\"] ||\n process.env.JEST_WORKER_ID !== undefined ||\n process.env.NODE_ENV === \"test\"\n );\n}\n","import {isArray, isString} from \"@tsed/core\";\nimport {join} from \"path\";\n\nconst fixPath = require(\"normalize-path\");\n\nexport function normalizePath(item: string, ...paths: string[]): string;\nexport function normalizePath(item: (string | any)[]): (string | any)[];\nexport function normalizePath(item: any, ...paths: string[]) {\n if (isString(item)) {\n const path = join(item, ...paths);\n return fixPath(path);\n }\n\n if (isArray(item)) {\n return item.map((item: any) => normalizePath(item));\n }\n\n return item;\n}\n","import {resolve} from \"path\";\nimport {isTsEnv} from \"./isTsEnv\";\nimport {normalizePath} from \"./normalizePath\";\n\nfunction mapExcludes(excludes: string[]) {\n return excludes.map((s: string) => `!${s.replace(/!/gi, \"\")}`);\n}\n\nfunction mapExtensions(file: string): string {\n if (!isTsEnv()) {\n file = file.replace(/\\.ts$/i, \".js\").replace(/{\\.ts,\\.js}$/i, \".js\");\n }\n\n return file;\n}\n\nexport function cleanGlobPatterns(files: string | string[], excludes: string[]): string[] {\n return []\n .concat(files as never)\n .map((s: string) => resolve(s))\n .concat(mapExcludes(excludes) as never)\n .map(mapExtensions)\n .map((s: string) => normalizePath(s));\n}\n","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","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","import {GlobalProviders, Provider, ProviderType} from \"@tsed/di\";\nimport {importComponents} from \"./importComponents\";\n\nasync function recursiveImports(providers: {token: string; route?: string}[], settings: Partial<TsED.Configuration>, properties: string[]) {\n const {exclude = []} = settings;\n\n const promises = providers\n .map(({token}) => GlobalProviders.get(token))\n .filter((provider) => provider?.type === ProviderType.MODULE && provider.configuration)\n .map((provider: Provider) => importProviders({exclude, ...provider.configuration}, properties));\n\n return (await Promise.all(promises)).flat();\n}\n\n/**\n * Import providers from given patterns.\n *\n * @param settings\n * @param properties\n */\nexport async function importProviders(\n settings: Partial<TsED.Configuration>,\n properties: string[] = [\"imports\"]\n): Promise<{token: string; route?: string}[]> {\n const {exclude = []} = settings;\n const disableComponentsScan = settings.disableComponentsScan || !!process.env.WEBPACK;\n\n const promises = properties.map((key) => importComponents(settings[key], exclude, disableComponentsScan));\n const providers = (await Promise.all(promises)).flat();\n const children = await recursiveImports(providers, settings, properties);\n\n return [...children, ...providers];\n}\n"],"names":["isTsEnv","require","extensions","process","env","JEST_WORKER_ID","undefined","NODE_ENV","fixPath","normalizePath","item","paths","isString","path","join","isArray","map","mapExcludes","excludes","s","replace","mapExtensions","file","cleanGlobPatterns","files","concat","resolve","importFiles","patterns","exclude","default","globby","symbols","endsWith","exports","importPackage","Object","keys","forEach","key","push","er","console","error","exit","resolveSymbols","disableComponentsScan","isClass","mapConfiguration","config","value","values","reduce","list","endpoint","importComponents","promises","option","filter","symbol","token","route","result","Promise","all","flat","recursiveImports","providers","settings","properties","GlobalProviders","get","provider","type","ProviderType","MODULE","configuration","importProviders","WEBPACK","children"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;SAAgBA;AACd,SACGC,OAAO,IAAIA,OAAO,CAACC,UAAnB,IAAiCD,OAAO,CAACC,UAAR,CAAmB,KAAnB,CAAlC,IACAC,OAAO,CAACC,GAAR,CAAY,SAAZ,CADA,IAEAD,OAAO,CAACC,GAAR,CAAYC,cAAZ,KAA+BC,SAF/B,IAGAH,OAAO,CAACC,GAAR,CAAYG,QAAZ,KAAyB,MAJ3B;AAMD;;ACJD,MAAMC,OAAO,GAAGP,OAAO,CAAC,gBAAD,CAAvB;;SAIgBQ,cAAcC,MAAW,GAAGC;AAC1C,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,QAAQ,CAACI,aAF1D,EAGd5D,GAHc,CAGTwD,QAAD,IAAwBK,eAAe;AAAEhD,IAAAA;AAAF,KAAc2C,QAAQ,CAACI,aAAvB,GAAuCP,UAAvC,CAH7B,CAAjB;AAKA,SAAO,CAAC,MAAMN,OAAO,CAACC,GAAR,CAAYR,QAAZ,CAAP,EAA8BS,IAA9B,EAAP;AACD;AAED;;;;;;;;AAMO,eAAeY,eAAf,CACLT,QADK,EAELC,aAAuB,CAAC,SAAD,CAFlB;AAIL,QAAM;AAACxC,IAAAA,OAAO,GAAG;AAAX,MAAiBuC,QAAvB;AACA,QAAMtB,qBAAqB,GAAGsB,QAAQ,CAACtB,qBAAT,IAAkC,CAAC,CAAC3C,OAAO,CAACC,GAAR,CAAY0E,OAA9E;AAEA,QAAMtB,QAAQ,GAAGa,UAAU,CAACrD,GAAX,CAAgBuB,GAAD,IAASgB,gBAAgB,CAACa,QAAQ,CAAC7B,GAAD,CAAT,EAAgBV,OAAhB,EAAyBiB,qBAAzB,CAAxC,CAAjB;AACA,QAAMqB,SAAS,GAAG,CAAC,MAAMJ,OAAO,CAACC,GAAR,CAAYR,QAAZ,CAAP,EAA8BS,IAA9B,EAAlB;AACA,QAAMc,QAAQ,GAAG,MAAMb,gBAAgB,CAACC,SAAD,EAAYC,QAAZ,EAAsBC,UAAtB,CAAvC;AAEA,SAAO,CAAC,GAAGU,QAAJ,EAAc,GAAGZ,SAAjB,CAAP;AACD;;;;;;;;;"}
@@ -1,169 +0,0 @@
1
- import { isString, isArray, importPackage, isClass } from '@tsed/core';
2
- import { join, resolve } from 'path';
3
- import { GlobalProviders, ProviderType } from '@tsed/di';
4
-
5
- function isTsEnv() {
6
- return require && require.extensions && require.extensions[".ts"] || process.env["TS_TEST"] || process.env.JEST_WORKER_ID !== undefined || process.env.NODE_ENV === "test";
7
- }
8
-
9
- const fixPath = require("normalize-path");
10
-
11
- function normalizePath(item, ...paths) {
12
- if (isString(item)) {
13
- const path = join(item, ...paths);
14
- return fixPath(path);
15
- }
16
-
17
- if (isArray(item)) {
18
- return item.map(item => normalizePath(item));
19
- }
20
-
21
- return item;
22
- }
23
-
24
- function mapExcludes(excludes) {
25
- return excludes.map(s => `!${s.replace(/!/gi, "")}`);
26
- }
27
-
28
- function mapExtensions(file) {
29
- if (!isTsEnv()) {
30
- file = file.replace(/\.ts$/i, ".js").replace(/{\.ts,\.js}$/i, ".js");
31
- }
32
-
33
- return file;
34
- }
35
-
36
- function cleanGlobPatterns(files, excludes) {
37
- return [].concat(files).map(s => resolve(s)).concat(mapExcludes(excludes)).map(mapExtensions).map(s => normalizePath(s));
38
- }
39
-
40
- async function importFiles(patterns, exclude) {
41
- const {
42
- default: globby
43
- } = await import('globby');
44
- const files = await globby(cleanGlobPatterns(patterns, exclude));
45
- const symbols = [];
46
-
47
- for (const file of files) {
48
- if (!file.endsWith(".d.ts")) {
49
- // prevent .d.ts import if the global pattern isn't correctly configured
50
- try {
51
- const exports = await importPackage(file);
52
- Object.keys(exports).forEach(key => symbols.push(exports[key]));
53
- } catch (er) {
54
- // istanbul ignore next
55
- console.error(er); // istanbul ignore next
56
-
57
- process.exit(1);
58
- }
59
- }
60
- }
61
-
62
- return symbols;
63
- }
64
-
65
- async function resolveSymbols(item, excludes, disableComponentsScan = false) {
66
- if (isClass(item)) {
67
- return [item];
68
- }
69
- /* istanbul ignore else */
70
-
71
-
72
- if (!disableComponentsScan) {
73
- return importFiles(item, excludes);
74
- }
75
- /* istanbul ignore next */
76
-
77
-
78
- return [];
79
- }
80
-
81
- function mapConfiguration(config) {
82
- if (isArray(config)) {
83
- return config.map(value => {
84
- return {
85
- values: [].concat(value)
86
- };
87
- });
88
- }
89
-
90
- return Object.keys(config).reduce((list, key) => {
91
- list.push({
92
- endpoint: key,
93
- values: [].concat(config[key])
94
- });
95
- return list;
96
- }, []);
97
- }
98
- async function importComponents(config, excludes, disableComponentsScan = false) {
99
- if (!config) {
100
- return [];
101
- }
102
-
103
- config = mapConfiguration(config);
104
- const promises = [];
105
-
106
- for (const option of config) {
107
- promises.push(...option.values.map(async value => {
108
- const symbols = await resolveSymbols(value, excludes, disableComponentsScan);
109
- return symbols.filter(isClass).map(symbol => ({
110
- token: symbol,
111
- route: option.endpoint
112
- }));
113
- }));
114
- }
115
-
116
- const result = await Promise.all(promises);
117
- return result.flat();
118
- }
119
-
120
- function _extends() {
121
- _extends = Object.assign || function (target) {
122
- for (var i = 1; i < arguments.length; i++) {
123
- var source = arguments[i];
124
-
125
- for (var key in source) {
126
- if (Object.prototype.hasOwnProperty.call(source, key)) {
127
- target[key] = source[key];
128
- }
129
- }
130
- }
131
-
132
- return target;
133
- };
134
-
135
- return _extends.apply(this, arguments);
136
- }
137
-
138
- async function recursiveImports(providers, settings, properties) {
139
- const {
140
- exclude = []
141
- } = settings;
142
- const promises = providers.map(({
143
- token
144
- }) => GlobalProviders.get(token)).filter(provider => (provider == null ? void 0 : provider.type) === ProviderType.MODULE && provider.configuration).map(provider => importProviders(_extends({
145
- exclude
146
- }, provider.configuration), properties));
147
- return (await Promise.all(promises)).flat();
148
- }
149
- /**
150
- * Import providers from given patterns.
151
- *
152
- * @param settings
153
- * @param properties
154
- */
155
-
156
-
157
- async function importProviders(settings, properties = ["imports"]) {
158
- const {
159
- exclude = []
160
- } = settings;
161
- const disableComponentsScan = settings.disableComponentsScan || !!process.env.WEBPACK;
162
- const promises = properties.map(key => importComponents(settings[key], exclude, disableComponentsScan));
163
- const providers = (await Promise.all(promises)).flat();
164
- const children = await recursiveImports(providers, settings, properties);
165
- return [...children, ...providers];
166
- }
167
-
168
- export { cleanGlobPatterns, importComponents, importFiles, importProviders, mapConfiguration, normalizePath };
169
- //# sourceMappingURL=index.modern.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.modern.js","sources":["../src/isTsEnv.ts","../src/normalizePath.ts","../src/cleanGlobPatterns.ts","../src/importFiles.ts","../src/importComponents.ts","../src/importProviders.ts"],"sourcesContent":["export function isTsEnv() {\n return (\n (require && require.extensions && require.extensions[\".ts\"]) ||\n process.env[\"TS_TEST\"] ||\n process.env.JEST_WORKER_ID !== undefined ||\n process.env.NODE_ENV === \"test\"\n );\n}\n","import {isArray, isString} from \"@tsed/core\";\nimport {join} from \"path\";\n\nconst fixPath = require(\"normalize-path\");\n\nexport function normalizePath(item: string, ...paths: string[]): string;\nexport function normalizePath(item: (string | any)[]): (string | any)[];\nexport function normalizePath(item: any, ...paths: string[]) {\n if (isString(item)) {\n const path = join(item, ...paths);\n return fixPath(path);\n }\n\n if (isArray(item)) {\n return item.map((item: any) => normalizePath(item));\n }\n\n return item;\n}\n","import {resolve} from \"path\";\nimport {isTsEnv} from \"./isTsEnv\";\nimport {normalizePath} from \"./normalizePath\";\n\nfunction mapExcludes(excludes: string[]) {\n return excludes.map((s: string) => `!${s.replace(/!/gi, \"\")}`);\n}\n\nfunction mapExtensions(file: string): string {\n if (!isTsEnv()) {\n file = file.replace(/\\.ts$/i, \".js\").replace(/{\\.ts,\\.js}$/i, \".js\");\n }\n\n return file;\n}\n\nexport function cleanGlobPatterns(files: string | string[], excludes: string[]): string[] {\n return []\n .concat(files as never)\n .map((s: string) => resolve(s))\n .concat(mapExcludes(excludes) as never)\n .map(mapExtensions)\n .map((s: string) => normalizePath(s));\n}\n","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","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","import {GlobalProviders, Provider, ProviderType} from \"@tsed/di\";\nimport {importComponents} from \"./importComponents\";\n\nasync function recursiveImports(providers: {token: string; route?: string}[], settings: Partial<TsED.Configuration>, properties: string[]) {\n const {exclude = []} = settings;\n\n const promises = providers\n .map(({token}) => GlobalProviders.get(token))\n .filter((provider) => provider?.type === ProviderType.MODULE && provider.configuration)\n .map((provider: Provider) => importProviders({exclude, ...provider.configuration}, properties));\n\n return (await Promise.all(promises)).flat();\n}\n\n/**\n * Import providers from given patterns.\n *\n * @param settings\n * @param properties\n */\nexport async function importProviders(\n settings: Partial<TsED.Configuration>,\n properties: string[] = [\"imports\"]\n): Promise<{token: string; route?: string}[]> {\n const {exclude = []} = settings;\n const disableComponentsScan = settings.disableComponentsScan || !!process.env.WEBPACK;\n\n const promises = properties.map((key) => importComponents(settings[key], exclude, disableComponentsScan));\n const providers = (await Promise.all(promises)).flat();\n const children = await recursiveImports(providers, settings, properties);\n\n return [...children, ...providers];\n}\n"],"names":["isTsEnv","require","extensions","process","env","JEST_WORKER_ID","undefined","NODE_ENV","fixPath","normalizePath","item","paths","isString","path","join","isArray","map","mapExcludes","excludes","s","replace","mapExtensions","file","cleanGlobPatterns","files","concat","resolve","importFiles","patterns","exclude","default","globby","symbols","endsWith","exports","importPackage","Object","keys","forEach","key","push","er","console","error","exit","resolveSymbols","disableComponentsScan","isClass","mapConfiguration","config","value","values","reduce","list","endpoint","importComponents","promises","option","filter","symbol","token","route","result","Promise","all","flat","recursiveImports","providers","settings","properties","GlobalProviders","get","provider","type","ProviderType","MODULE","configuration","importProviders","WEBPACK","children"],"mappings":";;;;SAAgBA;AACd,SACGC,OAAO,IAAIA,OAAO,CAACC,UAAnB,IAAiCD,OAAO,CAACC,UAAR,CAAmB,KAAnB,CAAlC,IACAC,OAAO,CAACC,GAAR,CAAY,SAAZ,CADA,IAEAD,OAAO,CAACC,GAAR,CAAYC,cAAZ,KAA+BC,SAF/B,IAGAH,OAAO,CAACC,GAAR,CAAYG,QAAZ,KAAyB,MAJ3B;AAMD;;ACJD,MAAMC,OAAO,GAAGP,OAAO,CAAC,gBAAD,CAAvB;;SAIgBQ,cAAcC,MAAW,GAAGC;AAC1C,MAAIC,QAAQ,CAACF,IAAD,CAAZ,EAAoB;AAClB,UAAMG,IAAI,GAAGC,IAAI,CAACJ,IAAD,EAAO,GAAGC,KAAV,CAAjB;AACA,WAAOH,OAAO,CAACK,IAAD,CAAd;AACD;;AAED,MAAIE,OAAO,CAACL,IAAD,CAAX,EAAmB;AACjB,WAAOA,IAAI,CAACM,GAAL,CAAUN,IAAD,IAAeD,aAAa,CAACC,IAAD,CAArC,CAAP;AACD;;AAED,SAAOA,IAAP;AACD;;ACdD,SAASO,WAAT,CAAqBC,QAArB;AACE,SAAOA,QAAQ,CAACF,GAAT,CAAcG,CAAD,QAAmBA,CAAC,CAACC,OAAF,CAAU,KAAV,EAAiB,EAAjB,GAAhC,CA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