configorama 0.6.7 → 0.6.9
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 +1 -1
- package/src/index.js +19 -1
- package/src/main.js +785 -190
- package/src/resolvers/valueFromGit.js +21 -1
- package/src/sync.js +18 -3
- package/src/utils/enrichMetadata.js +229 -0
- package/src/utils/find-nested-variables.js +7 -4
- package/src/utils/find-nested-variables.test.js +43 -4
- package/src/utils/isValidValue.js +1 -1
- package/src/utils/splitByComma.js +33 -9
- package/src/utils/splitByComma.test.js +47 -2
package/package.json
CHANGED
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
|
-
* @
|
|
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
|
|