node-dependency-injection 3.0.0-alpha.3 → 3.0.0-alpha.6
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 +35 -7
- package/package.json +7 -4
- package/tsconfig.json +7 -1
package/dist/lib/Autowire.js
CHANGED
|
@@ -19,7 +19,7 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
19
19
|
|
|
20
20
|
var _fs = _interopRequireDefault(require("fs"));
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _typescriptEstree = require("@typescript-eslint/typescript-estree");
|
|
23
23
|
|
|
24
24
|
var _Definition = _interopRequireDefault(require("./Definition"));
|
|
25
25
|
|
|
@@ -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}
|
|
@@ -181,7 +189,7 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
181
189
|
value: function _getClassDeclaration(filePath) {
|
|
182
190
|
var sourceCode = _fs["default"].readFileSync(filePath, 'utf8');
|
|
183
191
|
|
|
184
|
-
var body = (0,
|
|
192
|
+
var body = (0, _typescriptEstree.parse)(sourceCode).body;
|
|
185
193
|
var classDeclaration = body.find(function (declaration) {
|
|
186
194
|
return declaration.type === 'ExportDefaultDeclaration';
|
|
187
195
|
});
|
|
@@ -217,11 +225,14 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
217
225
|
try {
|
|
218
226
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
219
227
|
var parameterDeclaration = _step3.value;
|
|
220
|
-
var typeNameForArgument = parameterDeclaration.parameter.typeAnnotation.typeAnnotation.typeName.name;
|
|
221
228
|
|
|
222
|
-
|
|
229
|
+
try {
|
|
230
|
+
var typeNameForArgument = parameterDeclaration.parameter.typeAnnotation.typeAnnotation.typeName.name;
|
|
231
|
+
|
|
232
|
+
var argumentId = this._getIdentifierFromImports(typeNameForArgument, body, parsedFile);
|
|
223
233
|
|
|
224
|
-
|
|
234
|
+
definition.addArgument(new _Reference["default"](argumentId), definition["abstract"]);
|
|
235
|
+
} catch (e) {}
|
|
225
236
|
}
|
|
226
237
|
} catch (err) {
|
|
227
238
|
_iterator3.e(err);
|
|
@@ -260,6 +271,7 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
260
271
|
}, {
|
|
261
272
|
key: "_getIdentifierFromImports",
|
|
262
273
|
value: function _getIdentifierFromImports(type, body, parsedFile) {
|
|
274
|
+
var rootDir = parsedFile.dir;
|
|
263
275
|
var relativeImportForImplement = body.find(function (declaration) {
|
|
264
276
|
if (declaration.specifiers) {
|
|
265
277
|
return declaration.specifiers.find(function (specifier) {
|
|
@@ -270,7 +282,23 @@ var Autowire = /*#__PURE__*/function () {
|
|
|
270
282
|
return null;
|
|
271
283
|
}).source.value;
|
|
272
284
|
|
|
273
|
-
|
|
285
|
+
if (this._tsConfigPaths) {
|
|
286
|
+
for (var pathConfig in this._tsConfigPaths) {
|
|
287
|
+
var tsConfigPath = pathConfig.replace(/\*/g, '');
|
|
288
|
+
var tsRelativePath = this._tsConfigPaths[pathConfig][0];
|
|
289
|
+
tsRelativePath = tsRelativePath.replace(/\*/g, '');
|
|
290
|
+
|
|
291
|
+
if (relativeImportForImplement.includes(tsConfigPath)) {
|
|
292
|
+
relativeImportForImplement = relativeImportForImplement.replace(tsConfigPath, tsRelativePath);
|
|
293
|
+
|
|
294
|
+
var parsedTsConfigPath = _path["default"].parse(this._tsConfigFullPath);
|
|
295
|
+
|
|
296
|
+
rootDir = parsedTsConfigPath.dir;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
var absolutePathImportForImplement = _path["default"].join(rootDir, relativeImportForImplement);
|
|
274
302
|
|
|
275
303
|
return this._getServiceIdFromPath(absolutePathImportForImplement, type);
|
|
276
304
|
}
|
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.6",
|
|
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",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@babel/plugin-transform-runtime": "^7.17.10",
|
|
54
54
|
"@babel/runtime": "^7.17.9",
|
|
55
|
-
"@typescript-eslint/
|
|
55
|
+
"@typescript-eslint/typescript-estree": "^5.23.0",
|
|
56
56
|
"chalk": "^4.1.0",
|
|
57
57
|
"commander": "^8.3.0",
|
|
58
58
|
"console.table": "^0.10.0",
|
|
@@ -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": {
|