node-dependency-injection 3.0.0-alpha.3 → 3.0.0-alpha.4
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/.nyc_output/65e34a77-efb9-4bcf-803d-282fd660b5a8.json +1 -0
- package/.nyc_output/f2f58129-8a27-4ea1-94b2-d5913ef6944d.json +1 -0
- package/.nyc_output/processinfo/65e34a77-efb9-4bcf-803d-282fd660b5a8.json +1 -0
- package/.nyc_output/processinfo/f2f58129-8a27-4ea1-94b2-d5913ef6944d.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/bin/Services/File/BaseAdapter.js.html +158 -0
- package/coverage/lcov-report/bin/Services/File/FileManager.js.html +176 -0
- package/coverage/lcov-report/bin/Services/File/JsAdapter.js.html +140 -0
- package/coverage/lcov-report/bin/Services/File/JsonAdapter.js.html +131 -0
- package/coverage/lcov-report/bin/Services/File/YamlAdapter.js.html +155 -0
- package/coverage/lcov-report/bin/Services/File/index.html +171 -0
- package/coverage/lcov-report/block-navigation.js +79 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +171 -0
- package/coverage/lcov-report/lib/Autowire.js.html +506 -0
- package/coverage/lcov-report/lib/Compiler.js.html +239 -0
- package/coverage/lcov-report/lib/CompilerPass/DecoratePass.js.html +248 -0
- package/coverage/lcov-report/lib/CompilerPass/OptimizePass.js.html +128 -0
- package/coverage/lcov-report/lib/CompilerPass/RemovePass.js.html +116 -0
- package/coverage/lcov-report/lib/CompilerPass/index.html +156 -0
- package/coverage/lcov-report/lib/CompilerPass/index.js.html +326 -0
- package/coverage/lcov-report/lib/ContainerBuilder.js.html +1115 -0
- package/coverage/lcov-report/lib/Definition.js.html +962 -0
- package/coverage/lcov-report/lib/Exception/AbstractServiceException.js.html +110 -0
- package/coverage/lcov-report/lib/Exception/AttributesMapException.js.html +101 -0
- package/coverage/lcov-report/lib/Exception/ConfigurationFileNotFoundException.js.html +110 -0
- package/coverage/lcov-report/lib/Exception/DefinitionNotFoundException.js.html +110 -0
- package/coverage/lcov-report/lib/Exception/FrozenContainerException.js.html +101 -0
- package/coverage/lcov-report/lib/Exception/LoadMethodNotFoundException.js.html +110 -0
- package/coverage/lcov-report/lib/Exception/LoggerWarnMethodNotFoundException.js.html +101 -0
- package/coverage/lcov-report/lib/Exception/MethodCallEmptyException.js.html +101 -0
- package/coverage/lcov-report/lib/Exception/MethodCallNotFoundException.js.html +110 -0
- package/coverage/lcov-report/lib/Exception/NotAbstractServiceException.js.html +110 -0
- package/coverage/lcov-report/lib/Exception/PrivateServiceException.js.html +110 -0
- package/coverage/lcov-report/lib/Exception/ProcessMethodNotFoundException.js.html +110 -0
- package/coverage/lcov-report/lib/Exception/ServiceCircularReferenceException.js.html +101 -0
- package/coverage/lcov-report/lib/Exception/ServiceFileNotFoundException.js.html +110 -0
- package/coverage/lcov-report/lib/Exception/ServiceFileNotLoadedException.js.html +110 -0
- package/coverage/lcov-report/lib/Exception/ServiceNotFoundException.js.html +113 -0
- package/coverage/lcov-report/lib/Exception/WrongCompilerPassTypeException.js.html +110 -0
- package/coverage/lcov-report/lib/Exception/WrongDefinitionException.js.html +101 -0
- package/coverage/lcov-report/lib/Exception/index.html +366 -0
- package/coverage/lcov-report/lib/InstanceManager.js.html +839 -0
- package/coverage/lcov-report/lib/Loader/FileLoader.js.html +1034 -0
- package/coverage/lcov-report/lib/Loader/JsFileLoader.js.html +155 -0
- package/coverage/lcov-report/lib/Loader/JsonFileLoader.js.html +98 -0
- package/coverage/lcov-report/lib/Loader/YamlFileLoader.js.html +188 -0
- package/coverage/lcov-report/lib/Loader/index.html +156 -0
- package/coverage/lcov-report/lib/PackageReference.js.html +131 -0
- package/coverage/lcov-report/lib/PassConfig.js.html +230 -0
- package/coverage/lcov-report/lib/Reference.js.html +158 -0
- package/coverage/lcov-report/lib/TagReference.js.html +131 -0
- package/coverage/lcov-report/lib/index.html +231 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +170 -0
- package/coverage/lcov.info +1516 -0
- package/dist/lib/Autowire.js +27 -2
- package/package.json +6 -3
- package/tsconfig.json +7 -1
package/dist/lib/Autowire.js
CHANGED
|
@@ -33,10 +33,18 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
33
33
|
|
|
34
34
|
var Autowire = /*#__PURE__*/function () {
|
|
35
35
|
function Autowire(container) {
|
|
36
|
+
var tsConfigFullPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
36
37
|
(0, _classCallCheck2["default"])(this, Autowire);
|
|
37
38
|
this._interfaceImplementation = new Map();
|
|
38
39
|
this._rootDirectory = container.defaultDir;
|
|
39
40
|
this._container = container;
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
this._tsConfigFullPath = tsConfigFullPath || _path["default"].join(process.cwd(), 'tsconfig.json');
|
|
44
|
+
this._tsConfigPaths = require(this._tsConfigFullPath).compilerOptions.paths;
|
|
45
|
+
} catch (e) {
|
|
46
|
+
this._tsConfigPaths = null;
|
|
47
|
+
}
|
|
40
48
|
}
|
|
41
49
|
/**
|
|
42
50
|
* @return {ContainerBuilder}
|
|
@@ -120,7 +128,7 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
120
128
|
key: "_getServiceIdFromPath",
|
|
121
129
|
value: function _getServiceIdFromPath(path, type) {
|
|
122
130
|
var extension = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.ts';
|
|
123
|
-
return path.replace(/\//g, '_').replace(extension, '').concat("_".concat(type));
|
|
131
|
+
return path.replace(/\//g, '_').replace(extension, '').replace('@', '_').concat("_".concat(type));
|
|
124
132
|
}
|
|
125
133
|
/**
|
|
126
134
|
* @returns {void}
|
|
@@ -260,6 +268,7 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
260
268
|
}, {
|
|
261
269
|
key: "_getIdentifierFromImports",
|
|
262
270
|
value: function _getIdentifierFromImports(type, body, parsedFile) {
|
|
271
|
+
var rootDir = parsedFile.dir;
|
|
263
272
|
var relativeImportForImplement = body.find(function (declaration) {
|
|
264
273
|
if (declaration.specifiers) {
|
|
265
274
|
return declaration.specifiers.find(function (specifier) {
|
|
@@ -270,7 +279,23 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
270
279
|
return null;
|
|
271
280
|
}).source.value;
|
|
272
281
|
|
|
273
|
-
|
|
282
|
+
if (this._tsConfigPaths) {
|
|
283
|
+
for (var pathConfig in this._tsConfigPaths) {
|
|
284
|
+
var tsConfigPath = pathConfig.replace(/\*/g, '');
|
|
285
|
+
var tsRelativePath = this._tsConfigPaths[pathConfig][0];
|
|
286
|
+
tsRelativePath = tsRelativePath.replace(/\*/g, '');
|
|
287
|
+
|
|
288
|
+
if (relativeImportForImplement.includes(tsConfigPath)) {
|
|
289
|
+
relativeImportForImplement = relativeImportForImplement.replace(tsConfigPath, tsRelativePath);
|
|
290
|
+
|
|
291
|
+
var parsedTsConfigPath = _path["default"].parse(this._tsConfigFullPath);
|
|
292
|
+
|
|
293
|
+
rootDir = parsedTsConfigPath.dir;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
var absolutePathImportForImplement = _path["default"].join(rootDir, relativeImportForImplement);
|
|
274
299
|
|
|
275
300
|
return this._getServiceIdFromPath(absolutePathImportForImplement, type);
|
|
276
301
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-dependency-injection",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.4",
|
|
4
4
|
"description": "The NodeDependencyInjection component allows you to standardize and centralize the way objects are constructed in your application.",
|
|
5
5
|
"main": "dist/lib/index.js",
|
|
6
6
|
"directories": {
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"ndi": "dist/bin/ndi.js"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"test": "cross-env NODE_ENV=test mocha
|
|
15
|
-
"test:coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha",
|
|
14
|
+
"test": "cross-env NODE_ENV=test ts-mocha --paths",
|
|
15
|
+
"test:coverage": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text ts-mocha --paths",
|
|
16
16
|
"test:standard": "standard",
|
|
17
17
|
"test:standard:fix": "standard --fix",
|
|
18
18
|
"build:lib": "rm -rf dist/lib/* && babel lib -d dist/lib -D",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"@babel/preset-env": "^7.17.10",
|
|
66
66
|
"@babel/register": "^7.17.7",
|
|
67
67
|
"@types/chai": "^4.3.1",
|
|
68
|
+
"@types/expect": "^24.3.0",
|
|
68
69
|
"@types/mocha": "^9.1.1",
|
|
69
70
|
"babel-plugin-istanbul": "^6.1.1",
|
|
70
71
|
"chai": "^4.3.6",
|
|
@@ -75,7 +76,9 @@
|
|
|
75
76
|
"nyc": "^15.1.0",
|
|
76
77
|
"sinon": "^11.1.2",
|
|
77
78
|
"standard": "^16.0.4",
|
|
79
|
+
"ts-mocha": "^10.0.0",
|
|
78
80
|
"ts-node": "^10.7.0",
|
|
81
|
+
"tsconfig-paths": "^4.0.0",
|
|
79
82
|
"typescript": "^4.6.4"
|
|
80
83
|
},
|
|
81
84
|
"babel": {
|