@tsed/components-scan 7.0.0-beta.2 → 7.0.0-beta.20
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/lib/cjs/{data → __mock__}/Test1.js +0 -0
- package/lib/cjs/__mock__/Test1.js.map +1 -0
- package/lib/cjs/{data → __mock__}/Test2.js +0 -0
- package/lib/cjs/__mock__/Test2.js.map +1 -0
- package/lib/cjs/__mock__/controllers/rest/TestCtrl.js +12 -0
- package/lib/cjs/__mock__/controllers/rest/TestCtrl.js.map +1 -0
- package/lib/cjs/__mock__/module1/Module1.js +19 -0
- package/lib/cjs/__mock__/module1/Module1.js.map +1 -0
- package/lib/cjs/__mock__/module1/controllers/M1Ctrl1.js +18 -0
- package/lib/cjs/__mock__/module1/controllers/M1Ctrl1.js.map +1 -0
- package/lib/cjs/__mock__/module1/services/M1Service.js +18 -0
- package/lib/cjs/__mock__/module1/services/M1Service.js.map +1 -0
- package/lib/cjs/__mock__/module1/submodule/SubModule.js +15 -0
- package/lib/cjs/__mock__/module1/submodule/SubModule.js.map +1 -0
- package/lib/cjs/__mock__/module1/submodule/SubService.js +12 -0
- package/lib/cjs/__mock__/module1/submodule/SubService.js.map +1 -0
- package/lib/cjs/__mock__/module2/Module2.js +18 -0
- package/lib/cjs/__mock__/module2/Module2.js.map +1 -0
- package/lib/cjs/__mock__/module2/controllers/M2Ctrl.js +12 -0
- package/lib/cjs/__mock__/module2/controllers/M2Ctrl.js.map +1 -0
- package/lib/cjs/importFiles.js +8 -12
- package/lib/cjs/importFiles.js.map +1 -1
- package/lib/cjs/importProviders.js +38 -17
- package/lib/cjs/importProviders.js.map +1 -1
- package/lib/cjs/index.js +8 -5
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/isTsEnv.js +8 -1
- package/lib/cjs/isTsEnv.js.map +1 -1
- package/lib/cjs/normalizePath.js +3 -2
- package/lib/cjs/normalizePath.js.map +1 -1
- package/lib/cjs/package.json +3 -0
- package/lib/esm/{data → __mock__}/Test1.js +0 -0
- package/lib/esm/__mock__/Test1.js.map +1 -0
- package/lib/esm/{data → __mock__}/Test2.js +0 -0
- package/lib/esm/__mock__/Test2.js.map +1 -0
- package/lib/esm/__mock__/controllers/rest/TestCtrl.js +9 -0
- package/lib/esm/__mock__/controllers/rest/TestCtrl.js.map +1 -0
- package/lib/esm/__mock__/module1/Module1.js +16 -0
- package/lib/esm/__mock__/module1/Module1.js.map +1 -0
- package/lib/esm/__mock__/module1/controllers/M1Ctrl1.js +15 -0
- package/lib/esm/__mock__/module1/controllers/M1Ctrl1.js.map +1 -0
- package/lib/esm/__mock__/module1/services/M1Service.js +15 -0
- package/lib/esm/__mock__/module1/services/M1Service.js.map +1 -0
- package/lib/esm/__mock__/module1/submodule/SubModule.js +12 -0
- package/lib/esm/__mock__/module1/submodule/SubModule.js.map +1 -0
- package/lib/esm/__mock__/module1/submodule/SubService.js +9 -0
- package/lib/esm/__mock__/module1/submodule/SubService.js.map +1 -0
- package/lib/esm/__mock__/module2/Module2.js +15 -0
- package/lib/esm/__mock__/module2/Module2.js.map +1 -0
- package/lib/esm/__mock__/module2/controllers/M2Ctrl.js +9 -0
- package/lib/esm/__mock__/module2/controllers/M2Ctrl.js.map +1 -0
- package/lib/esm/cleanGlobPatterns.js +2 -2
- package/lib/esm/importFiles.js +4 -12
- package/lib/esm/importFiles.js.map +1 -1
- package/lib/esm/importProviders.js +38 -17
- package/lib/esm/importProviders.js.map +1 -1
- package/lib/esm/index.js +8 -5
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/isTsEnv.js +8 -1
- package/lib/esm/isTsEnv.js.map +1 -1
- package/lib/esm/normalizePath.js +1 -1
- package/lib/esm/normalizePath.js.map +1 -1
- package/lib/esm/package.json +3 -0
- package/lib/types/{data → __mock__}/Test1.d.ts +0 -0
- package/lib/types/{data → __mock__}/Test2.d.ts +0 -0
- package/lib/types/__mock__/controllers/rest/TestCtrl.d.ts +2 -0
- package/lib/types/__mock__/module1/Module1.d.ts +2 -0
- package/lib/types/__mock__/module1/controllers/M1Ctrl1.d.ts +5 -0
- package/lib/types/__mock__/module1/services/M1Service.d.ts +5 -0
- package/lib/types/__mock__/module1/submodule/SubModule.d.ts +2 -0
- package/lib/types/__mock__/module1/submodule/SubService.d.ts +2 -0
- package/lib/types/__mock__/module2/Module2.d.ts +2 -0
- package/lib/types/__mock__/module2/controllers/M2Ctrl.d.ts +2 -0
- package/lib/types/importProviders.d.ts +2 -6
- package/lib/types/index.d.ts +5 -2
- package/lib/types/isTsEnv.d.ts +1 -2
- package/package.json +14 -11
- package/readme.md +3 -4
- package/tsconfig.compile.esm.json +2 -13
- package/lib/cjs/data/Test1.js.map +0 -1
- package/lib/cjs/data/Test2.js.map +0 -1
- package/lib/cjs/importComponents.js +0 -50
- package/lib/cjs/importComponents.js.map +0 -1
- package/lib/esm/data/Test1.js.map +0 -1
- package/lib/esm/data/Test2.js.map +0 -1
- package/lib/esm/importComponents.js +0 -45
- package/lib/esm/importComponents.js.map +0 -1
- package/lib/types/importComponents.d.ts +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importFiles.js","sourceRoot":"","sources":["../../src/importFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAEtD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAA2B,EAAE,OAAiB;IAC9E,MAAM,EAAC,OAAO,EAAE,MAAM,EAAC,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"importFiles.js","sourceRoot":"","sources":["../../src/importFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAEtD,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAA2B,EAAE,OAAiB;IAC9E,MAAM,EAAC,OAAO,EAAE,MAAM,EAAC,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEjD,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IACjE,MAAM,OAAO,GAAU,EAAE,CAAC;IAE1B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE;QACzD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAC3B,wEAAwE;YACxE,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,CAAC;YAC1C,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACnE;KACF;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {importPackage} from \"@tsed/core\";\nimport {cleanGlobPatterns} from \"./cleanGlobPatterns\";\n\nexport async function importFiles(patterns: string | string[], exclude: string[]): Promise<any[]> {\n const {default: globby} = await import(\"globby\");\n\n const files = await globby(cleanGlobPatterns(patterns, exclude));\n const symbols: any[] = [];\n\n for (const file of files.sort((a, b) => (a < b ? -1 : 1))) {\n if (!file.endsWith(\".d.ts\")) {\n // prevent .d.ts import if the global pattern isn't correctly configured\n const exports = await importPackage(file);\n Object.keys(exports).forEach((key) => symbols.push(exports[key]));\n }\n }\n\n return symbols;\n}\n"]}
|
|
@@ -1,25 +1,46 @@
|
|
|
1
1
|
import { GlobalProviders, ProviderType } from "@tsed/di";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { isArray, isClass, isString } from "@tsed/core";
|
|
3
|
+
import { importFiles } from "./importFiles.js";
|
|
4
|
+
const lookup = ["imports", "componentsScan", "mount"];
|
|
5
|
+
async function resolveRecursively(items, exclude, rootDir) {
|
|
6
|
+
for (const index in items) {
|
|
7
|
+
if (isString(items[index])) {
|
|
8
|
+
items[index] = await importFiles(items[index].replace("${rootDir}", rootDir), exclude);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const providers = items.flat().filter(isClass);
|
|
12
|
+
for (const token of providers) {
|
|
13
|
+
const provider = GlobalProviders.get(token);
|
|
14
|
+
if (provider?.type === ProviderType.MODULE && provider.configuration) {
|
|
15
|
+
provider.configuration.exclude = exclude;
|
|
16
|
+
provider.configuration.rootDir = provider.configuration.rootDir || rootDir;
|
|
17
|
+
provider.configuration = await importProviders(provider.configuration);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return providers;
|
|
10
21
|
}
|
|
11
22
|
/**
|
|
12
|
-
*
|
|
23
|
+
* Lookup settings and replace glob pattern by the resolved providers
|
|
13
24
|
*
|
|
14
25
|
* @param settings
|
|
15
|
-
* @param properties
|
|
16
26
|
*/
|
|
17
|
-
export async function importProviders(settings
|
|
18
|
-
const { exclude = [] } = settings;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
27
|
+
export async function importProviders(settings) {
|
|
28
|
+
const { exclude = [], rootDir } = settings;
|
|
29
|
+
for (const property of lookup) {
|
|
30
|
+
if (settings[property]) {
|
|
31
|
+
if (!isArray(settings[property])) {
|
|
32
|
+
const current = settings[property];
|
|
33
|
+
const promises = Object.entries(current).map(async ([key, items]) => {
|
|
34
|
+
current[key] = await resolveRecursively([].concat(items), exclude, rootDir);
|
|
35
|
+
});
|
|
36
|
+
await Promise.all(promises);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
settings[property] = await resolveRecursively(settings[property], exclude, rootDir);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
settings.disableComponentsScan = true;
|
|
44
|
+
return settings;
|
|
24
45
|
}
|
|
25
46
|
//# sourceMappingURL=importProviders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importProviders.js","sourceRoot":"","sources":["../../src/importProviders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"importProviders.js","sourceRoot":"","sources":["../../src/importProviders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AACvD,OAAO,EAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAC;AACtD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C,MAAM,MAAM,GAAG,CAAC,SAAS,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAEtD,KAAK,UAAU,kBAAkB,CAAC,KAAY,EAAE,OAAiB,EAAE,OAAe;IAChF,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE;QACzB,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE;YAC1B,KAAK,CAAC,KAAK,CAAC,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;SACxF;KACF;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE/C,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE;QAC7B,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAE5C,IAAI,QAAQ,EAAE,IAAI,KAAK,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AO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {GlobalProviders, ProviderType} from \"@tsed/di\";\nimport {isArray, isClass, isString} from \"@tsed/core\";\nimport {importFiles} from \"./importFiles\";\n\nconst lookup = [\"imports\", \"componentsScan\", \"mount\"];\n\nasync function resolveRecursively(items: any[], exclude: string[], rootDir: string) {\n for (const index in items) {\n if (isString(items[index])) {\n items[index] = await importFiles(items[index].replace(\"${rootDir}\", rootDir), exclude);\n }\n }\n\n const providers = items.flat().filter(isClass);\n\n for (const token of providers) {\n const provider = GlobalProviders.get(token);\n\n if (provider?.type === ProviderType.MODULE && provider.configuration) {\n provider.configuration.exclude = exclude;\n provider.configuration.rootDir = provider.configuration.rootDir || rootDir;\n\n provider.configuration = await importProviders(provider.configuration);\n }\n }\n\n return providers;\n}\n\n/**\n * Lookup settings and replace glob pattern by the resolved providers\n *\n * @param settings\n */\nexport async function importProviders(settings: Record<string, any>): Promise<Partial<TsED.Configuration>> {\n const {exclude = [], rootDir} = settings;\n\n for (const property of lookup) {\n if (settings[property]) {\n if (!isArray(settings[property])) {\n const current = settings[property];\n const promises = Object.entries(current).map(async ([key, items]: [string, any]) => {\n current[key] = await resolveRecursively([].concat(items), exclude, rootDir);\n });\n\n await Promise.all(promises);\n } else {\n settings[property] = await resolveRecursively(settings[property], exclude, rootDir);\n }\n }\n }\n\n settings.disableComponentsScan = true;\n\n return settings;\n}\n"]}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export * from "./cleanGlobPatterns";
|
|
5
|
-
export * from "./
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./cleanGlobPatterns.js";
|
|
5
|
+
export * from "./importFiles.js";
|
|
6
|
+
export * from "./importProviders.js";
|
|
7
|
+
export * from "./isTsEnv.js";
|
|
8
|
+
export * from "./normalizePath.js";
|
|
6
9
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./cleanGlobPatterns\";\nexport * from \"./importFiles\";\nexport * from \"./importProviders\";\nexport * from \"./isTsEnv\";\nexport * from \"./normalizePath\";\n"]}
|
package/lib/esm/isTsEnv.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export function isTsEnv() {
|
|
2
|
-
|
|
2
|
+
try {
|
|
3
|
+
if (require && require.extensions && require.extensions[".ts"]) {
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
catch (er) { }
|
|
8
|
+
return (process.env["TS_NODE_DEV"] ||
|
|
9
|
+
process.env["_"]?.includes("ts-node") ||
|
|
3
10
|
process.env["TS_TEST"] ||
|
|
4
11
|
process.env.JEST_WORKER_ID !== undefined ||
|
|
5
12
|
process.env.NODE_ENV === "test");
|
package/lib/esm/isTsEnv.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isTsEnv.js","sourceRoot":"","sources":["../../src/isTsEnv.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO;IACrB,
|
|
1
|
+
{"version":3,"file":"isTsEnv.js","sourceRoot":"","sources":["../../src/isTsEnv.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO;IACrB,IAAI;QACF,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;YAC9D,OAAO,IAAI,CAAC;SACb;KACF;IAAC,OAAO,EAAE,EAAE,GAAE;IACf,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;QAC1B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,SAAS;QACxC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAChC,CAAC;AACJ,CAAC","sourcesContent":["export function isTsEnv() {\n try {\n if (require && require.extensions && require.extensions[\".ts\"]) {\n return true;\n }\n } catch (er) {}\n return (\n process.env[\"TS_NODE_DEV\"] ||\n process.env[\"_\"]?.includes(\"ts-node\") ||\n process.env[\"TS_TEST\"] ||\n process.env.JEST_WORKER_ID !== undefined ||\n process.env.NODE_ENV === \"test\"\n );\n}\n"]}
|
package/lib/esm/normalizePath.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isArray, isString } from "@tsed/core";
|
|
2
2
|
import { join } from "path";
|
|
3
|
-
|
|
3
|
+
import fixPath from "normalize-path";
|
|
4
4
|
export function normalizePath(item, ...paths) {
|
|
5
5
|
if (isString(item)) {
|
|
6
6
|
const path = join(item, ...paths);
|
|
@@ -1 +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;
|
|
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;AAC1B,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAIrC,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\";\nimport fixPath from \"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"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Lookup settings and replace glob pattern by the resolved providers
|
|
3
3
|
*
|
|
4
4
|
* @param settings
|
|
5
|
-
* @param properties
|
|
6
5
|
*/
|
|
7
|
-
export declare function importProviders(settings:
|
|
8
|
-
token: string;
|
|
9
|
-
route?: string;
|
|
10
|
-
}[]>;
|
|
6
|
+
export declare function importProviders(settings: Record<string, any>): Promise<Partial<TsED.Configuration>>;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./cleanGlobPatterns";
|
|
1
5
|
export * from "./importFiles";
|
|
2
|
-
export * from "./importComponents";
|
|
3
6
|
export * from "./importProviders";
|
|
4
|
-
export * from "./
|
|
7
|
+
export * from "./isTsEnv";
|
|
5
8
|
export * from "./normalizePath";
|
package/lib/types/isTsEnv.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function isTsEnv(): string | boolean | ((m: NodeJS.Module, filename: string) => any);
|
|
1
|
+
export declare function isTsEnv(): string | boolean;
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/components-scan",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.20",
|
|
4
4
|
"description": "Components scan utilities for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/cjs/index.js",
|
|
8
|
+
"module": "./lib/esm/index.js",
|
|
8
9
|
"typings": "./lib/types/index.d.ts",
|
|
9
10
|
"exports": {
|
|
10
11
|
"types": "./lib/types/index.d.ts",
|
|
@@ -13,29 +14,31 @@
|
|
|
13
14
|
"default": "./lib/esm/index.js"
|
|
14
15
|
},
|
|
15
16
|
"scripts": {
|
|
16
|
-
"build": "yarn run build:esm && yarn run build:cjs",
|
|
17
|
+
"build": "yarn barrels && yarn run build:esm && yarn run build:cjs",
|
|
17
18
|
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
18
19
|
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
20
|
+
"barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
|
|
19
21
|
"test": "cross-env NODE_ENV=test jest"
|
|
20
22
|
},
|
|
21
23
|
"dependencies": {
|
|
22
|
-
"@tsed/core": "7.0.0-beta.2",
|
|
23
|
-
"@tsed/di": "7.0.0-beta.2",
|
|
24
24
|
"globby": "11.0.3",
|
|
25
25
|
"normalize-path": "3.0.0",
|
|
26
|
-
"tslib": "2.
|
|
26
|
+
"tslib": "2.4.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@tsed/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"@tsed/logger": ">=6.0.0"
|
|
29
|
+
"@tsed/core": "7.0.0-beta.20",
|
|
30
|
+
"@tsed/di": "7.0.0-beta.20",
|
|
31
|
+
"@types/normalize-path": "^3.0.0"
|
|
33
32
|
},
|
|
33
|
+
"peerDependencies": {},
|
|
34
34
|
"repository": "https://github.com/tsedio/tsed",
|
|
35
35
|
"bugs": {
|
|
36
36
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
37
37
|
},
|
|
38
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
38
|
+
"homepage": "https://github.com/tsedio/tsed/tree/beta/packages/third-parties/components-scan",
|
|
39
39
|
"author": "Romain Lenzotti",
|
|
40
|
-
"license": "MIT"
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"tag": "beta"
|
|
43
|
+
}
|
|
41
44
|
}
|
package/readme.md
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
[](https://badge.fury.io/js/%40tsed%2Fcommon)
|
|
12
12
|
[](https://github.com/semantic-release/semantic-release)
|
|
13
13
|
[](https://github.com/prettier/prettier)
|
|
14
|
-
[](https://github.com/sponsors/romakita)
|
|
15
|
+
[](https://opencollective.com/tsed)
|
|
15
16
|
|
|
16
17
|
</div>
|
|
17
18
|
|
|
@@ -35,14 +36,12 @@ A package of Ts.ED framework. See website: https://tsed.io/
|
|
|
35
36
|
npm install --save @tsed/components-scan
|
|
36
37
|
```
|
|
37
38
|
|
|
38
|
-
|
|
39
39
|
## Backers
|
|
40
40
|
|
|
41
41
|
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
|
|
42
42
|
|
|
43
43
|
<a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/tiers/backer.svg?width=890"></a>
|
|
44
44
|
|
|
45
|
-
|
|
46
45
|
## Sponsors
|
|
47
46
|
|
|
48
47
|
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)]
|
|
@@ -51,7 +50,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
|
|
|
51
50
|
|
|
52
51
|
The MIT License (MIT)
|
|
53
52
|
|
|
54
|
-
Copyright (c) 2016 -
|
|
53
|
+
Copyright (c) 2016 - 2022 Romain Lenzotti
|
|
55
54
|
|
|
56
55
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
57
56
|
|
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "./tsconfig.compile.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
|
-
"baseUrl": "
|
|
4
|
+
"baseUrl": "./",
|
|
5
5
|
"module": "ES2020",
|
|
6
6
|
"rootDir": "src",
|
|
7
7
|
"outDir": "./lib/esm",
|
|
8
8
|
"declaration": true,
|
|
9
9
|
"declarationDir": "./lib/types"
|
|
10
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
|
-
]
|
|
11
|
+
"exclude": ["node_modules", "test", "lib", "benchmark", "coverage", "spec", "**/*.benchmark.ts", "**/*.spec.ts", "keys", "jest.config.js"]
|
|
23
12
|
}
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.importComponents = exports.mapConfiguration = void 0;
|
|
4
|
-
const core_1 = require("@tsed/core");
|
|
5
|
-
const importFiles_1 = require("./importFiles");
|
|
6
|
-
async function resolveSymbols(item, excludes, disableComponentsScan = false) {
|
|
7
|
-
if ((0, core_1.isClass)(item)) {
|
|
8
|
-
return [item];
|
|
9
|
-
}
|
|
10
|
-
/* istanbul ignore else */
|
|
11
|
-
if (!disableComponentsScan) {
|
|
12
|
-
return (0, importFiles_1.importFiles)(item, excludes);
|
|
13
|
-
}
|
|
14
|
-
/* istanbul ignore next */
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
function mapConfiguration(config) {
|
|
18
|
-
if ((0, core_1.isArray)(config)) {
|
|
19
|
-
return config.map((value) => {
|
|
20
|
-
return {
|
|
21
|
-
values: [].concat(value)
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return Object.keys(config).reduce((list, key) => {
|
|
26
|
-
list.push({
|
|
27
|
-
endpoint: key,
|
|
28
|
-
values: [].concat(config[key])
|
|
29
|
-
});
|
|
30
|
-
return list;
|
|
31
|
-
}, []);
|
|
32
|
-
}
|
|
33
|
-
exports.mapConfiguration = mapConfiguration;
|
|
34
|
-
async function importComponents(config, excludes, disableComponentsScan = false) {
|
|
35
|
-
if (!config) {
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
config = mapConfiguration(config);
|
|
39
|
-
const promises = [];
|
|
40
|
-
for (const option of config) {
|
|
41
|
-
promises.push(...option.values.map(async (value) => {
|
|
42
|
-
const symbols = await resolveSymbols(value, excludes, disableComponentsScan);
|
|
43
|
-
return symbols.filter(core_1.isClass).map((symbol) => ({ token: symbol, route: option.endpoint }));
|
|
44
|
-
}));
|
|
45
|
-
}
|
|
46
|
-
const result = await Promise.all(promises);
|
|
47
|
-
return result.flat();
|
|
48
|
-
}
|
|
49
|
-
exports.importComponents = importComponents;
|
|
50
|
-
//# sourceMappingURL=importComponents.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"importComponents.js","sourceRoot":"","sources":["../../src/importComponents.ts"],"names":[],"mappings":";;;AAAA,qCAA4C;AAC5C,+CAA0C;AAE1C,KAAK,UAAU,cAAc,CAAC,IAAS,EAAE,QAAkB,EAAE,qBAAqB,GAAG,KAAK;IACxF,IAAI,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC;KACf;IACD,0BAA0B;IAC1B,IAAI,CAAC,qBAAqB,EAAE;QAC1B,OAAO,IAAA,yBAAW,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;KACpC;IAED,0BAA0B;IAC1B,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAgB,gBAAgB,CAAC,MAAW;IAC1C,IAAI,IAAA,cAAO,EAAC,MAAM,CAAC,EAAE;QACnB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE;YAC/B,OAAO;gBACL,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;aACzB,CAAC;QACJ,CAAC,CAAC,CAAC;KAC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veSymbols(item: any, excludes: string[], disableComponentsScan = false) {\n if (isClass(item)) {\n return [item];\n }\n /* istanbul ignore else */\n if (!disableComponentsScan) {\n return importFiles(item, excludes);\n }\n\n /* istanbul ignore next */\n return [];\n}\n\nexport function mapConfiguration(config: any): {endpoint?: string; values: any[]}[] {\n if (isArray(config)) {\n return config.map((value: any) => {\n return {\n values: [].concat(value)\n };\n });\n }\n\n return Object.keys(config).reduce((list: any[], key: string) => {\n list.push({\n endpoint: key,\n values: [].concat(config[key])\n });\n\n return list;\n }, []);\n}\n\nexport async function importComponents(\n config: any,\n excludes: string[],\n disableComponentsScan = false\n): Promise<{token: string; route?: string}[]> {\n if (!config) {\n return [];\n }\n\n config = mapConfiguration(config);\n\n const promises: any = [];\n\n for (const option of config) {\n promises.push(\n ...option.values.map(async (value: any) => {\n const symbols = await resolveSymbols(value, excludes, disableComponentsScan);\n\n return symbols.filter(isClass).map((symbol) => ({token: symbol, route: option.endpoint}));\n })\n );\n }\n\n const result: {token: string; route?: string}[][] = await Promise.all(promises);\n\n return result.flat();\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|
|
@@ -1,45 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"importComponents.js","sourceRoot":"","sources":["../../src/importComponents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C,KAAK,U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AE,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"]}
|