@tsed/components-scan 6.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/jest.config.js ADDED
@@ -0,0 +1,14 @@
1
+ // For a detailed explanation regarding each configuration property, visit:
2
+ // https://jestjs.io/docs/en/configuration.html
3
+
4
+ module.exports = {
5
+ ...require("@tsed/jest-config")(__dirname, "platform-serverless"),
6
+ coverageThreshold: {
7
+ global: {
8
+ branches: 71.05,
9
+ functions: 84.31,
10
+ lines: 91.78,
11
+ statements: 91.55
12
+ }
13
+ }
14
+ };
@@ -0,0 +1 @@
1
+ export declare function cleanGlobPatterns(files: string | string[], excludes: string[]): string[];
@@ -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[]): 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
+ }[]>;
package/lib/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./importFiles";
2
+ export * from "./importComponents";
3
+ export * from "./importProviders";
4
+ export * from "./cleanGlobPatterns";
5
+ export * from "./normalizePath";
package/lib/index.js ADDED
@@ -0,0 +1,193 @@
1
+ var path = require('path');
2
+ var core = require('@tsed/core');
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 Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(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) {
86
+ if (core.isClass(item)) {
87
+ return [item];
88
+ }
89
+ /* istanbul ignore else */
90
+
91
+
92
+ if (!process.env.WEBPACK) {
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) {
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);
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 promises = properties.map(key => importComponents(settings[key], exclude));
182
+ const providers = (await Promise.all(promises)).flat();
183
+ const children = await recursiveImports(providers, settings, properties);
184
+ return [...children, ...providers];
185
+ }
186
+
187
+ exports.cleanGlobPatterns = cleanGlobPatterns;
188
+ exports.importComponents = importComponents;
189
+ exports.importFiles = importFiles;
190
+ exports.importProviders = importProviders;
191
+ exports.mapConfiguration = mapConfiguration;
192
+ exports.normalizePath = normalizePath;
193
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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 {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 import(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[]) {\n if (isClass(item)) {\n return [item];\n }\n /* istanbul ignore else */\n if (!process.env.WEBPACK) {\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(config: any, excludes: string[]): 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);\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\n const promises = properties.map((key) => importComponents(settings[key], exclude));\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","Object","keys","forEach","key","push","er","console","error","exit","resolveSymbols","isClass","WEBPACK","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","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,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GAHc,CAGTuD,QAAD,IAAwBK,eAAe;AAAE/C,IAAAA;AAAF,KAAc0C,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;AAACvC,IAAAA,OAAO,GAAG;AAAX,MAAiBsC,QAAvB;AAEA,QAAMZ,QAAQ,GAAGa,UAAU,CAACpD,GAAX,CAAgBsB,GAAD,IAASgB,gBAAgB,CAACa,QAAQ,CAAC7B,GAAD,CAAT,EAAgBT,OAAhB,CAAxC,CAAjB;AACA,QAAMqC,SAAS,GAAG,CAAC,MAAMJ,OAAO,CAACC,GAAR,CAAYR,QAAZ,CAAP,EAA8BS,IAA9B,EAAlB;AACA,QAAMa,QAAQ,GAAG,MAAMZ,gBAAgB,CAACC,SAAD,EAAYC,QAAZ,EAAsBC,UAAtB,CAAvC;AAEA,SAAO,CAAC,GAAGS,QAAJ,EAAc,GAAGX,SAAjB,CAAP;AACD;;;;;;;;;"}
@@ -0,0 +1,168 @@
1
+ import { join, resolve } from 'path';
2
+ import { isString, isArray, isClass } from '@tsed/core';
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 import(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) {
66
+ if (isClass(item)) {
67
+ return [item];
68
+ }
69
+ /* istanbul ignore else */
70
+
71
+
72
+ if (!process.env.WEBPACK) {
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) {
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);
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 promises = properties.map(key => importComponents(settings[key], exclude));
162
+ const providers = (await Promise.all(promises)).flat();
163
+ const children = await recursiveImports(providers, settings, properties);
164
+ return [...children, ...providers];
165
+ }
166
+
167
+ export { cleanGlobPatterns, importComponents, importFiles, importProviders, mapConfiguration, normalizePath };
168
+ //# sourceMappingURL=index.modern.js.map
@@ -0,0 +1 @@
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 {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 import(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[]) {\n if (isClass(item)) {\n return [item];\n }\n /* istanbul ignore else */\n if (!process.env.WEBPACK) {\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(config: any, excludes: string[]): 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);\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\n const promises = properties.map((key) => importComponents(settings[key], exclude));\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","Object","keys","forEach","key","push","er","console","error","exit","resolveSymbols","isClass","WEBPACK","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","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,CAAP;AACD;;AAED,SAASC,aAAT,CAAuBC,IAAvB;AACE,MAAI,CAACtB,OAAO,EAAZ,EAAgB;AACdsB,IAAAA,IAAI,GAAGA,IAAI,CAACF,OAAL,CAAa,QAAb,EAAuB,KAAvB,EAA8BA,OAA9B,CAAsC,eAAtC,EAAuD,KAAvD,CAAP;AACD;;AAED,SAAOE,IAAP;AACD;;S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,EAAc,GAAGX,SAAjB,CAAP;AACD;;;;"}
@@ -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 ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@tsed/components-scan",
3
+ "version": "6.70.0",
4
+ "description": "Components scan utilities for Ts.ED Framework",
5
+ "private": false,
6
+ "source": "./src/index.ts",
7
+ "main": "./lib/index.js",
8
+ "typings": "./lib/index.d.ts",
9
+ "exports": {
10
+ "require": "./lib/index.js",
11
+ "default": "./lib/index.modern.js"
12
+ },
13
+ "scripts": {
14
+ "build": "microbundle --target node --no-compress --format modern,cjs --tsconfig ./tsconfig.compile.json",
15
+ "test": "cross-env NODE_ENV=test jest"
16
+ },
17
+ "dependencies": {
18
+ "@tsed/core": "6.70.0",
19
+ "@tsed/di": "6.70.0",
20
+ "globby": "11.0.3",
21
+ "normalize-path": "3.0.0",
22
+ "tslib": "2.2.0"
23
+ },
24
+ "devDependencies": {
25
+ "@tsed/logger": "^5.16.0"
26
+ },
27
+ "peerDependencies": {
28
+ "@tsed/logger": "^5.16.0"
29
+ },
30
+ "repository": "https://github.com/tsedio/tsed",
31
+ "bugs": {
32
+ "url": "https://github.com/tsedio/tsed/issues"
33
+ },
34
+ "homepage": "https://github.com/tsedio/tsed/tree/production/packages/utils/components-scan",
35
+ "author": "Romain Lenzotti",
36
+ "license": "MIT"
37
+ }
package/readme.md ADDED
@@ -0,0 +1,60 @@
1
+ <p style="text-align: center" align="center">
2
+ <a href="https://tsed.io" target="_blank"><img src="https://tsed.io/tsed-og.png" width="200" alt="Ts.ED logo"/></a>
3
+ </p>
4
+
5
+ <div align="center">
6
+ <h1>@tsed/components-scan</h1>
7
+
8
+ [![Build & Release](https://github.com/tsedio/tsed/workflows/Build%20&%20Release/badge.svg)](https://github.com/tsedio/tsed/actions?query=workflow%3A%22Build+%26+Release%22)
9
+ [![PR Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/tsedio/tsed/blob/master/CONTRIBUTING.md)
10
+ [![Coverage Status](https://coveralls.io/repos/github/tsedio/tsed/badge.svg?branch=production)](https://coveralls.io/github/tsedio/tsed?branch=production)
11
+ [![npm version](https://badge.fury.io/js/%40tsed%2Fcommon.svg)](https://badge.fury.io/js/%40tsed%2Fcommon)
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
+ [![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)
15
+
16
+ </div>
17
+
18
+ <div align="center">
19
+ <a href="https://tsed.io/">Website</a>
20
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
21
+ <a href="https://tsed.io/getting-started/">Getting started</a>
22
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
23
+ <a href="https://api.tsed.io/rest/slack/tsedio/tsed">Slack</a>
24
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
25
+ <a href="https://twitter.com/TsED_io">Twitter</a>
26
+ </div>
27
+
28
+ <hr />
29
+
30
+ A package of Ts.ED framework. See website: https://tsed.io/
31
+
32
+ # Installation
33
+
34
+ ```bash
35
+ npm install --save @tsed/components-scan
36
+ ```
37
+
38
+
39
+ ## Backers
40
+
41
+ Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
42
+
43
+ <a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/tiers/backer.svg?width=890"></a>
44
+
45
+
46
+ ## Sponsors
47
+
48
+ Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
49
+
50
+ ## License
51
+
52
+ The MIT License (MIT)
53
+
54
+ Copyright (c) 2016 - 2018 Romain Lenzotti
55
+
56
+ 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:
57
+
58
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
59
+
60
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.