@superhero/core 4.0.2 → 4.0.3
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/index.js +42 -28
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -290,7 +290,7 @@ export default class Core
|
|
|
290
290
|
}
|
|
291
291
|
else if(false === this.#isBooted)
|
|
292
292
|
{
|
|
293
|
-
await this.#
|
|
293
|
+
await this.#addDependencies()
|
|
294
294
|
await this.#confirmAbsoluteServcieMapPaths()
|
|
295
295
|
|
|
296
296
|
freeze && this.config.freeze()
|
|
@@ -608,61 +608,75 @@ export default class Core
|
|
|
608
608
|
}
|
|
609
609
|
}
|
|
610
610
|
|
|
611
|
-
async #
|
|
611
|
+
async #addDependencies()
|
|
612
612
|
{
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
613
|
+
let
|
|
614
|
+
dependencies = {},
|
|
615
|
+
loaded = []
|
|
616
616
|
|
|
617
617
|
do
|
|
618
618
|
{
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
loaded.push(...postLoaded)
|
|
619
|
+
loaded = Object.keys(dependencies)
|
|
620
|
+
dependencies = this.#loadNewDependencies(loaded)
|
|
621
|
+
await this.add(Object.values(dependencies))
|
|
623
622
|
}
|
|
624
|
-
while(
|
|
623
|
+
while(Object.keys(dependencies).length < loaded.length)
|
|
625
624
|
|
|
626
625
|
return this
|
|
627
626
|
}
|
|
628
627
|
|
|
629
|
-
#
|
|
628
|
+
#loadNewDependencies(loaded)
|
|
630
629
|
{
|
|
631
|
-
const
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
630
|
+
const
|
|
631
|
+
dependencies = this.config.find('dependency', {}),
|
|
632
|
+
dependenciesType = Object.prototype.toString.call(dependencies)
|
|
633
|
+
|
|
634
|
+
if('[object Object]' !== dependenciesType)
|
|
635
635
|
{
|
|
636
|
-
const error = new TypeError(`Invalid
|
|
637
|
-
error.code = '
|
|
638
|
-
error.cause = 'Config core/dependencies must be an array'
|
|
636
|
+
const error = new TypeError(`Invalid configured dependency type: ${dependenciesType}`)
|
|
637
|
+
error.code = 'E_CORE_INVALID_DEPENDENCY_TYPE'
|
|
639
638
|
throw error
|
|
640
639
|
}
|
|
641
640
|
|
|
642
|
-
for(
|
|
641
|
+
for(const id in dependencies)
|
|
643
642
|
{
|
|
644
|
-
|
|
643
|
+
if(loaded.includes(id))
|
|
644
|
+
{
|
|
645
|
+
continue
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
let dependencyPath = dependencies[id]
|
|
649
|
+
|
|
650
|
+
if(false === dependencyPath)
|
|
651
|
+
{
|
|
652
|
+
continue
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
if(true === path)
|
|
656
|
+
{
|
|
657
|
+
dependencyPath = id
|
|
658
|
+
}
|
|
645
659
|
|
|
646
|
-
if('string'
|
|
660
|
+
if('string' !== typeof dependencyPath)
|
|
647
661
|
{
|
|
648
|
-
const error = new TypeError(`Invalid dependency type: ${Object.prototype.toString.call(
|
|
649
|
-
error.code = '
|
|
650
|
-
error.cause = 'The
|
|
662
|
+
const error = new TypeError(`Invalid dependency path type: ${Object.prototype.toString.call(dependencyPath)}`)
|
|
663
|
+
error.code = 'E_CORE_INVALID_DEPENDENCY_PATH_TYPE'
|
|
664
|
+
error.cause = 'The values of configured dependency attribute must be of type string'
|
|
651
665
|
throw error
|
|
652
666
|
}
|
|
653
667
|
|
|
654
|
-
if(
|
|
668
|
+
if(dependencyPath.startsWith('.'))
|
|
655
669
|
{
|
|
656
|
-
const absolutePath = this.config.findAbsoluteDirPathByConfigEntry('
|
|
670
|
+
const absolutePath = this.config.findAbsoluteDirPathByConfigEntry('dependency', { [id]: dependencies[id] })
|
|
657
671
|
|
|
658
672
|
if('string' === typeof absolutePath)
|
|
659
673
|
{
|
|
660
|
-
dependencies[i] = path.normalize(path.join(absolutePath,
|
|
674
|
+
dependencies[i] = path.normalize(path.join(absolutePath, dependencyPath))
|
|
661
675
|
}
|
|
662
676
|
}
|
|
663
677
|
}
|
|
664
678
|
|
|
665
|
-
return dependencies
|
|
679
|
+
return dependencies
|
|
666
680
|
}
|
|
667
681
|
|
|
668
682
|
#normalizeConfigPaths(configPaths)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superhero/core",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "Core functionalities for the superhero framework.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
".": "./index.js"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@superhero/
|
|
13
|
-
"@superhero/
|
|
12
|
+
"@superhero/locator": "^4.2.3",
|
|
13
|
+
"@superhero/bootstrap": "^4.1.2"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"test": "node --trace-warnings --test --experimental-test-coverage"
|