Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: zazoomauro/node-dependency-injection
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.9.0
Choose a base ref
...
head repository: zazoomauro/node-dependency-injection
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 18,529 additions and 1,309 deletions.
  1. +16 −0 .eslintrc
  2. +41 −0 .github/workflows/build.yml
  3. +20 −0 .github/workflows/publish.yml
  4. +3 −1 .gitignore
  5. +4 −0 .mocharc.yaml
  6. +0 −11 .travis.yml
  7. +71 −0 CHANGELOG-2.md
  8. +12 −0 CHANGELOG-3.md
  9. +84 −30 CHANGELOG.md
  10. +2 −2 CONTRIBUTING.md
  11. +1 −1 LICENCE
  12. +225 −3 README.md
  13. +7 −0 UPGRADE-2.0.md
  14. +9 −0 UPGRADE-3.0.md
  15. +22 −0 bin/Resources/services.yaml
  16. +26 −0 bin/Services/File/BaseAdapter.js
  17. +32 −0 bin/Services/File/FileManager.js
  18. +20 −0 bin/Services/File/JsAdapter.js
  19. +17 −0 bin/Services/File/JsonAdapter.js
  20. +25 −0 bin/Services/File/YamlAdapter.js
  21. +44 −0 bin/ndi-config:check.js
  22. +45 −0 bin/ndi-config:create.js
  23. +116 −0 bin/ndi-container:service.js
  24. +11 −0 bin/ndi.js
  25. +339 −0 lib/Autowire.js
  26. +17 −0 lib/AutowireIdentifier.js
  27. +53 −0 lib/Compiler.js
  28. +52 −0 lib/CompilerPass/AutowireOverridePass.js
  29. +48 −15 lib/CompilerPass/DecoratePass.js
  30. +6 −4 lib/CompilerPass/OptimizePass.js
  31. +2 −2 lib/CompilerPass/RemovePass.js
  32. +84 −0 lib/CompilerPass/index.js
  33. +151 −252 lib/ContainerBuilder.js
  34. +133 −32 lib/Definition.js
  35. +6 −0 lib/Dump/Dumper.js
  36. +16 −0 lib/Dump/JsDumper.js
  37. +13 −0 lib/Dump/JsonDumper.js
  38. +14 −0 lib/Dump/YamlDumper.js
  39. +10 −0 lib/Exception/AbstractServiceException.js
  40. +7 −0 lib/Exception/AttributesMapException.js
  41. +7 −0 lib/Exception/CannotAutowireOverrideSearch.js
  42. +10 −0 lib/Exception/ConfigurationFileNotFoundException.js
  43. +10 −0 lib/Exception/ContainerDefaultDirMustBeSet.js
  44. +10 −0 lib/Exception/DefinitionNotFoundException.js
  45. +7 −0 lib/Exception/FrozenContainerException.js
  46. +10 −0 lib/Exception/LoadMethodNotFoundException.js
  47. +7 −0 lib/Exception/LoggerWarnMethodNotFoundException.js
  48. +7 −0 lib/Exception/MethodCallEmptyException.js
  49. +10 −0 lib/Exception/MethodCallNotFoundException.js
  50. +10 −0 lib/Exception/NotAbstractServiceException.js
  51. +10 −0 lib/Exception/PrivateServiceException.js
  52. +10 −0 lib/Exception/ProcessMethodNotFoundException.js
  53. +7 −0 lib/Exception/RootDirectoryMustBeAbsolute.js
  54. +7 −0 lib/Exception/RootDirectoryNotFound.js
  55. +7 −0 lib/Exception/ServiceCircularReferenceException.js
  56. +7 −0 lib/Exception/ServiceFileNotAbsolute.js
  57. +10 −0 lib/Exception/ServiceFileNotFoundException.js
  58. +10 −0 lib/Exception/ServiceFileNotLoadedException.js
  59. +7 −0 lib/Exception/ServiceFileNotValidExtension.js
  60. +11 −0 lib/Exception/ServiceNotFoundException.js
  61. +11 −0 lib/Exception/UnableToGetInstanceFromId.js
  62. +10 −0 lib/Exception/WrongCompilerPassTypeException.js
  63. +7 −0 lib/Exception/WrongDefinitionException.js
  64. +370 −0 lib/InstanceManager.js
  65. +81 −0 lib/Loader/Argument.js
  66. +136 −82 lib/Loader/FileLoader.js
  67. +8 −16 lib/Loader/JsFileLoader.js
  68. +1 −3 lib/Loader/JsonFileLoader.js
  69. +18 −17 lib/Loader/YamlFileLoader.js
  70. +107 −0 lib/ServiceFile.js
  71. +17 −0 lib/TagReference.js
  72. +7 −1 lib/index.js
  73. +193 −0 lib/types/index.d.ts
  74. +194 −0 lib/types/tests.ts
  75. +9,456 −0 package-lock.json
  76. +66 −36 package.json
  77. BIN test/.DS_Store
  78. +14 −0 test/Resources-ts/Autowire-Override/config/services-noimports.yaml
  79. +9 −0 test/Resources-ts/Autowire-Override/config/services-not-exists.yaml
  80. +18 −0 test/Resources-ts/Autowire-Override/config/services.yaml
  81. +3 −0 test/Resources-ts/Autowire-Override/src/Adapter.ts
  82. +7 −0 test/Resources-ts/Autowire-Override/src/Adapters/BarAdapter.ts
  83. +7 −0 test/Resources-ts/Autowire-Override/src/Adapters/CiAdapter.ts
  84. +7 −0 test/Resources-ts/Autowire-Override/src/Adapters/FooAdapter.ts
  85. +20 −0 test/Resources-ts/Autowire-Override/src/AnotherFooBarAutowireOverride.ts
  86. +1 −0 test/Resources-ts/Autowire-Override/src/AnotherService.ts
  87. +20 −0 test/Resources-ts/Autowire-Override/src/FooBarAutowireOverride.ts
  88. +1 −0 test/Resources-ts/Autowire-Override/src/SomeService.ts
  89. +4 −0 test/Resources-ts/Autowire/config/services-absolute-root-dir.yaml
  90. +9 −0 test/Resources-ts/Autowire/config/services.js
  91. +11 −0 test/Resources-ts/Autowire/config/services.json
  92. +5 −0 test/Resources-ts/Autowire/config/services.yaml
  93. +19 −0 test/Resources-ts/Autowire/src/Abstract/AbstractFoo.ts
  94. +23 −0 test/Resources-ts/Autowire/src/FooBar.ts
  95. +3 −0 test/Resources-ts/Autowire/src/Interface/IBar.ts
  96. +1 −0 test/Resources-ts/Autowire/src/Interface/IMultiple.ts
  97. +7 −0 test/Resources-ts/Autowire/src/NotUsed/Foo.ts
  98. +6 −0 test/Resources-ts/Autowire/src/NotUsed/Params.ts
  99. +7 −0 test/Resources-ts/Autowire/src/Service/Bar.ts
  100. +7 −0 test/Resources-ts/Autowire/src/Service/Foo.ts
  101. +7 −0 test/Resources-ts/Autowire/src/Service/FooTwo.ts
  102. +3 −0 test/Resources-ts/Autowire/src/Service/ImplementsOne.ts
  103. +3 −0 test/Resources-ts/Autowire/src/Service/ImplementsTwo.ts
  104. +5 −0 test/Resources-ts/Autowire/src/Service/SomeService.ts
  105. +7 −0 test/Resources-ts/Autowire/src/ToExclude/ExcludedService.ts
  106. +7 −0 test/Resources-ts/Autowire/src/ToExclude/InFolderExclude/InFolderExcludedService.ts
  107. +5 −0 test/Resources-ts/Autowire/src/init.ts
  108. +1 −0 test/Resources-ts/Autowire/src/notTsFile.json
  109. +13 −0 test/Resources-ts/AutowireModulePath/src/Abstract/AbstractFoo.ts
  110. +23 −0 test/Resources-ts/AutowireModulePath/src/FooBar.ts
  111. +3 −0 test/Resources-ts/AutowireModulePath/src/Interface/IBar.ts
  112. +1 −0 test/Resources-ts/AutowireModulePath/src/Interface/IMultiple.ts
  113. +11 −0 test/Resources-ts/AutowireModulePath/src/NotUsed/CustomString.ts
  114. +7 −0 test/Resources-ts/AutowireModulePath/src/NotUsed/Foo.ts
  115. +7 −0 test/Resources-ts/AutowireModulePath/src/NotUsed/NotAService.ts
  116. +7 −0 test/Resources-ts/AutowireModulePath/src/Service/Bar.ts
  117. +7 −0 test/Resources-ts/AutowireModulePath/src/Service/Foo.ts
  118. +3 −0 test/Resources-ts/AutowireModulePath/src/Service/ImplementsOne.ts
  119. +3 −0 test/Resources-ts/AutowireModulePath/src/Service/ImplementsTwo.ts
  120. +5 −0 test/Resources-ts/AutowireModulePath/src/Service/SomeService.ts
  121. +7 −0 test/Resources-ts/AutowireModulePath/src/ToExclude/ExcludedService.ts
  122. +7 −0 test/Resources-ts/AutowireModulePath/src/ToExclude/InFolderExclude/InFolderExcludedService.ts
  123. +13 −0 test/Resources-ts/Bar.ts
  124. +12 −0 test/Resources-ts/BarManager.ts
  125. +3 −0 test/Resources-ts/CompilerPass/FileClassPass.ts
  126. +10 −0 test/Resources-ts/DecoratingMailer.ts
  127. +8 −0 test/Resources-ts/DecoratingMailerOne.ts
  128. +5 −0 test/Resources-ts/DecoratingMailerTwo.ts
  129. +24 −0 test/Resources-ts/Factory.ts
  130. +34 −0 test/Resources-ts/Foo.ts
  131. +6 −0 test/Resources-ts/FooManager.ts
  132. +12 −0 test/Resources-ts/Foobar.ts
  133. +1 −0 test/Resources-ts/Listener.ts
  134. +1 −0 test/Resources-ts/Mailer.ts
  135. +11 −0 test/Resources-ts/MissingDependencies.ts
  136. +5 −0 test/Resources-ts/MultipleExports.ts
  137. +7 −0 test/Resources-ts/MultipleExportsWithDefault.ts
  138. +1 −0 test/Resources-ts/NamedService.ts
  139. +1 −0 test/Resources-ts/RepositoryBar.ts
  140. +1 −0 test/Resources-ts/RepositoryFoo.ts
  141. +8 −0 test/Resources-ts/RepositoryManager.ts
  142. +8 −0 test/Resources-ts/SomeManagerWithContainer.ts
  143. +1 −0 test/Resources-ts/SyntheticService.ts
  144. +12 −0 test/Resources-ts/abstract/BaseClass.ts
  145. +3 −0 test/Resources-ts/abstract/ChildClass.ts
  146. +1 −0 test/Resources-ts/abstract/Service.ts
  147. +20 −0 test/Resources-ts/config/abstract.yml
  148. +4 −0 test/Resources-ts/config/container-self-reference.yml
  149. +23 −0 test/Resources-ts/config/defaultdir.yaml
  150. +6 −0 test/Resources-ts/config/fake-import-subfolder.js
  151. +10 −0 test/Resources-ts/config/fake-import-subfolder.json
  152. +3 −0 test/Resources-ts/config/fake-import-subfolder.yml
  153. +5 −0 test/Resources-ts/config/fake-imports.js
  154. +7 −0 test/Resources-ts/config/fake-imports.json
  155. +3 −0 test/Resources-ts/config/fake-imports.yml
  156. +7 −0 test/Resources-ts/config/fake-services-2.yml
  157. +30 −0 test/Resources-ts/config/fake-services.js
  158. +60 −0 test/Resources-ts/config/fake-services.json
  159. +147 −0 test/Resources-ts/config/fake-services.yml
  160. +5 −0 test/Resources-ts/config/foo/bar.js
  161. +7 −0 test/Resources-ts/config/foo/bar.json
  162. +3 −0 test/Resources-ts/config/foo/bar.yml
  163. +5 −0 test/Resources-ts/config/foo/baz.js
  164. +7 −0 test/Resources-ts/config/foo/baz.json
  165. +3 −0 test/Resources-ts/config/foo/baz.yml
  166. +2 −0 test/Resources-ts/config/invalid-yaml-syntax.yml
  167. +16 −0 test/Resources-ts/config/main.yml
  168. +3 −0 test/Resources-ts/config/named-service.yml
  169. +4 −0 test/Resources-ts/config/private.yml
  170. +6 −0 test/Resources-ts/config/service_from_package.yml
  171. +6 −0 test/Resources-ts/config/services-no-autowire.yml
  172. +20 −0 test/Resources-ts/config/tagged-arguments.js
  173. +16 −0 test/Resources-ts/config/tagged-arguments.json
  174. +13 −0 test/Resources-ts/config/tagged-arguments.yml
  175. +7 −0 test/Resources-ts/kebab-case-filename-factory.ts
  176. +9 −0 test/Resources/DecoratingMailerOne.js
  177. +5 −0 test/Resources/DecoratingMailerTwo.js
  178. +5 −0 test/Resources/MultipleExports.js
  179. +7 −0 test/Resources/MultipleExportsWithDefault.js
  180. +1 −0 test/Resources/NamedService.js
  181. +1 −0 test/Resources/RepositoryBar.js
  182. +1 −0 test/Resources/RepositoryFoo.js
  183. +9 −0 test/Resources/RepositoryManager.js
  184. +7 −0 test/Resources/SyntaxErrorClass.js
  185. +9 −0 test/Resources/abstract/BaseClass.js
  186. +3 −0 test/Resources/abstract/ChildClass.js
  187. +3 −0 test/Resources/abstract/ChildClassTwo.js
  188. +6 −0 test/Resources/abstract/Service.js
  189. +24 −0 test/Resources/config/abstract.yml
  190. +4 −0 test/Resources/config/container-self-reference.yml
  191. +23 −0 test/Resources/config/defaultdir.yaml
  192. +2 −2 test/Resources/config/fake-import-subfolder.js
  193. +1 −1 test/Resources/config/fake-imports.js
  194. +5 −5 test/Resources/config/fake-services.js
  195. +15 −4 test/Resources/config/fake-services.json
  196. +31 −5 test/Resources/config/fake-services.yml
  197. +1 −1 test/Resources/config/foo/bar.js
  198. +1 −1 test/Resources/config/foo/baz.js
  199. +2 −0 test/Resources/config/invalid-yaml-syntax.yml
  200. +16 −0 test/Resources/config/main.yml
  201. +3 −0 test/Resources/config/named-service.yml
  202. +4 −0 test/Resources/config/private.yml
  203. +6 −0 test/Resources/config/service_from_package.yml
  204. +3 −0 test/Resources/config/service_with_errors.yml
  205. +20 −0 test/Resources/config/tagged-arguments.js
  206. +16 −0 test/Resources/config/tagged-arguments.json
  207. +13 −0 test/Resources/config/tagged-arguments.yml
  208. +6 −1 test/Resources/foo.js
  209. +7 −0 test/Resources/kebab-case-filename-factory.js
  210. +9 −0 test/Resources/someManagerWithContainer.js
  211. +0 −4 test/mocha.opts
  212. +0 −132 test/node-dependency-injection/Loader/JsFileLoader.spec.js
  213. +0 −132 test/node-dependency-injection/Loader/JsonFileLoader.spec.js
  214. +0 −203 test/node-dependency-injection/Loader/YamlFileLoader.spec.js
  215. +131 −0 test/node-dependency-injection/bin/File/FileManager.spec.js
  216. +605 −0 test/node-dependency-injection/lib-ts/Autowire.spec.js
  217. +584 −266 test/node-dependency-injection/{ → lib-ts}/ContainerBuilder.spec.js
  218. +135 −0 test/node-dependency-injection/lib-ts/Loader/JsFileLoader.spec.js
  219. +138 −0 test/node-dependency-injection/lib-ts/Loader/JsonFileLoader.spec.js
  220. +403 −0 test/node-dependency-injection/lib-ts/Loader/YamlFileLoader.spec.js
  221. +33 −0 test/node-dependency-injection/lib-ts/ServiceFile.spec.js
  222. +1,768 −0 test/node-dependency-injection/lib/ContainerBuilder.spec.js
  223. +74 −30 test/node-dependency-injection/{ → lib}/Definition.spec.js
  224. +135 −0 test/node-dependency-injection/lib/Loader/JsFileLoader.spec.js
  225. +144 −0 test/node-dependency-injection/lib/Loader/JsonFileLoader.spec.js
  226. +410 −0 test/node-dependency-injection/lib/Loader/YamlFileLoader.spec.js
  227. +5 −6 test/node-dependency-injection/{ → lib}/PackageReference.spec.js
  228. +7 −8 test/node-dependency-injection/{ → lib}/Reference.spec.js
  229. +20 −0 test/node-dependency-injection/lib/TagReference.spec.js
  230. +12 −0 tsconfig.json
16 changes: 16 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": [
"plugin:sonarjs/recommended"
],
"plugins": [
"sonarjs"
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
"sonarjs/cognitive-complexity": "error",
"sonarjs/no-identical-expressions": "error"
}
}
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [15.x, 16.x, 17.x, 18.x, 19.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm run test:standard
- run: npm test

coverage:
needs: [build]
name: coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: "17"
- run: npm ci
- uses: paambaati/codeclimate-action@v3.2.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: npm run test:coverage
coverageLocations: ${{github.workspace}}/coverage/lcov.info:lcov
20 changes: 20 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Publish

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -4,4 +4,6 @@ node_modules/
.nyc_output/
coverage/
coverage.lcov
npm-debug.log
npm-debug.log
.DS_STORE
.vscode
4 changes: 4 additions & 0 deletions .mocharc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require: '@babel/register'
spec: test/node-dependency-injection/**/*.spec.js
color: true
ui: bdd
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

71 changes: 71 additions & 0 deletions CHANGELOG-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Change Log

# [2.7.2] - 2022-02-21
### Changed
- Add warning log when service is not registered

# [2.4.8] - 2020-01-09
### Changed
- Add process.env variables support to services arguments using %env(ENV_VAR)% syntax

# [2.3.4] - 2019-05-28
### Changed
- Avoid collections lib usage

# [2.3.3] - 2019-04-11
### Changed
- Fix tstypes path

# [2.3.2] - 2019-04-11
### Added
- add typescript types

# [2.3.1] - 2019-04-02
### Changed
- package.json & package-lock.json to reduce vulnerabilities

# [2.3.0] - 2019-03-25
### Changed
- add default directory
- removing path library
- improving README file

[2.2.1] - 2018-10-01
### Changed
- Do not report file error on yaml syntax errors

# [2.2.0] - 2018-09-13
### Changed
* Added control to register container as a service and can recover
* Added control to retrieve container instance as service.
* container reference as service

# [2.1.1] - 2018-08-22
### Changed
- package dependencies update

# [2.1.0] - 2018-06-13
### Changed
- add express middleware link and minimal documentation
- update dependencies for production and development

# [2.1.0] - 2018-06-13
### Changed
- add express middleware link and minimal documentation
- update dependencies for production and development

# [2.0.1] - 2018-04-11
### Changed
- fixing bug injecting private npm modules from configuration files (yml, js or json)

# [2.0.0] - 2017-09-26
### Changed
- updating production and developers dependencies
### Added
- adding new project logo
- preparing version 2
- create a new node-dependency-injection-cli on /bin folder called
- can create a new config file: $ ndi config:create --name=services --format=yml|json|js /path/folder/
- adding config:check command to check if the configuration file contains any error
- node dependency injection throws custom exceptions instead of general Error
- adding container:service command to show service details
12 changes: 12 additions & 0 deletions CHANGELOG-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Change Log

# [3.0.0] - 2022-05-19
### Changed
- File Loader load method is now Promised
- ContainerBuilder compile is now Promised
- ContainerBuilder findDefinition is now Promised
- Custom Compiler Pass process needs to be Promised
- Container Builder findTaggedServiceIds returns an Iterable object instead of Map
### Added
- Autowire support for TypeScript
- Get container service from a class instance
Loading