configorama 0.6.7 → 0.6.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "configorama",
3
- "version": "0.6.7",
3
+ "version": "0.6.8",
4
4
  "description": "Variable support for configuration files",
5
5
  "main": "src/index.js",
6
6
  "types": "index.d.ts",
package/src/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const Configorama = require('./main')
2
2
  const parsers = require('./parsers')
3
+ const enrichMetadata = require('./utils/enrichMetadata')
3
4
 
4
5
  module.exports.Configorama = Configorama
5
6
 
@@ -16,12 +17,29 @@ module.exports.Configorama = Configorama
16
17
  * @param {boolean} [settings.allowUnknownVars] - allow unknown variables to pass through without throwing errors
17
18
  * @param {boolean} [settings.allowUndefinedValues] - allow undefined values to pass through without throwing errors
18
19
  * @param {object|function} [settings.dynamicArgs] - values passed into .js config files if user using javascript config.
19
- * @return {Promise} resolved configuration
20
+ * @param {boolean} [settings.returnMetadata] - return both config and metadata about variables found
21
+ * @return {Promise} resolved configuration or {config, metadata} if returnMetadata is true
20
22
  */
21
23
  module.exports = async (configPathOrObject, settings = {}) => {
22
24
  const instance = new Configorama(configPathOrObject, settings)
23
25
  const options = settings.options || {}
24
26
  const config = await instance.init(options)
27
+
28
+ if (settings.returnMetadata) {
29
+ const metadata = instance.collectVariableMetadata()
30
+
31
+ // Enrich metadata with resolution tracking data collected during execution
32
+ const enrichedMetadata = enrichMetadata(metadata, instance.resolutionTracking, instance.variableSyntax)
33
+
34
+ return {
35
+ config,
36
+ originalConfig: instance.originalConfig,
37
+ metadata: enrichedMetadata,
38
+ // Include resolution history per path for debugging and advanced use cases
39
+ resolutionHistory: instance.resolutionTracking
40
+ }
41
+ }
42
+
25
43
  return config
26
44
  }
27
45