@superhero/core 4.0.5 → 4.0.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.
Files changed (2) hide show
  1. package/index.js +18 -45
  2. package/package.json +3 -3
package/index.js CHANGED
@@ -290,8 +290,7 @@ export default class Core
290
290
  }
291
291
  else if(false === this.#isBooted)
292
292
  {
293
- await this.#addDependencies()
294
- await this.#confirmAbsoluteServcieMapPaths()
293
+ await this.#normalizeServcieMapPaths()
295
294
 
296
295
  freeze && this.config.freeze()
297
296
 
@@ -378,7 +377,7 @@ export default class Core
378
377
  *
379
378
  * Resolves the absolute path by the config entry, through the config instance.
380
379
  */
381
- async #confirmAbsoluteServcieMapPaths()
380
+ async #normalizeServcieMapPaths()
382
381
  {
383
382
  const locatorMap = this.config.find('locator')
384
383
 
@@ -588,14 +587,18 @@ export default class Core
588
587
 
589
588
  async #addConfigPath(configPath)
590
589
  {
591
- await this.config.add(configPath)
590
+ const { filepath, config } = await this.config.resolve(configPath)
591
+ this.#addConfigDependencies(filepath, config)
592
+ this.config.add(filepath, config)
592
593
  Core.log.info`assigned config ${configPath}`
593
594
 
594
595
  if(this.branch)
595
596
  {
596
597
  try
597
598
  {
598
- await this.config.add(configPath, this.branch)
599
+ const { filepath, config } = await this.config.resolve(configPath, this.branch)
600
+ this.#addConfigDependencies(filepath, config)
601
+ this.config.add(filepath, config)
599
602
  Core.log.info`assigned config ${configPath + '-' + this.branch}`
600
603
  }
601
604
  catch(error)
@@ -608,28 +611,16 @@ export default class Core
608
611
  }
609
612
  }
610
613
 
611
- async #addDependencies()
614
+ async #addConfigDependencies(parentFilepath, parentConfig)
612
615
  {
613
- let
614
- dependencies = {},
615
- loaded = []
616
+ const dependencies = parentConfig.dependency
616
617
 
617
- do
618
+ if(false === !!dependencies)
618
619
  {
619
- loaded = Object.keys(dependencies)
620
- dependencies = this.#loadNewDependencies(loaded)
621
- await this.add(Object.values(dependencies))
620
+ return
622
621
  }
623
- while(Object.keys(dependencies).length < loaded.length)
624
622
 
625
- return this
626
- }
627
-
628
- #loadNewDependencies(loaded)
629
- {
630
- const
631
- dependencies = this.config.find('dependency', {}),
632
- dependenciesType = Object.prototype.toString.call(dependencies)
623
+ const dependenciesType = Object.prototype.toString.call(dependencies)
633
624
 
634
625
  if('[object Object]' !== dependenciesType)
635
626
  {
@@ -640,11 +631,6 @@ export default class Core
640
631
 
641
632
  for(const id in dependencies)
642
633
  {
643
- if(loaded.includes(id))
644
- {
645
- continue
646
- }
647
-
648
634
  let dependencyPath = dependencies[id]
649
635
 
650
636
  if(false === dependencyPath)
@@ -667,26 +653,13 @@ export default class Core
667
653
 
668
654
  if(dependencyPath.startsWith('.'))
669
655
  {
670
- const absolutePath = this.config.findAbsoluteDirPathByConfigEntry('dependency', { [id]: dependencies[id] })
671
-
672
- if('string' === typeof absolutePath)
673
- {
674
- dependencies[id] = path.normalize(path.join(absolutePath, dependencyPath))
675
- }
676
- else
677
- {
678
- const error = new Error(`Could not resolve path for dependency "${id}"`)
679
- error.code = 'E_CORE_RESOLVE_DEPENDENCY_PATH'
680
- throw error
681
- }
682
- }
683
- else
684
- {
685
- dependencies[id] = dependencyPath
656
+ dependencyPath = path.normalize(path.join(parentFilepath, dependencyPath))
686
657
  }
687
- }
688
658
 
689
- return dependencies
659
+ const { filepath, config } = await this.config.resolve(dependencyPath)
660
+ this.#addConfigDependencies(filepath, config)
661
+ this.config.add(filepath, config)
662
+ }
690
663
  }
691
664
 
692
665
  #normalizeConfigPaths(configPaths)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superhero/core",
3
- "version": "4.0.5",
3
+ "version": "4.0.6",
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/locator": "^4.2.3",
13
- "@superhero/bootstrap": "^4.1.2"
12
+ "@superhero/locator": "^4.2.4",
13
+ "@superhero/bootstrap": "^4.1.3"
14
14
  },
15
15
  "scripts": {
16
16
  "test": "node --trace-warnings --test --experimental-test-coverage"