@adobe/aio-cli-lib-app-config 1.0.1-pre.2023-07-14.sha-628de670 → 2.0.0
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 +4 -5
- package/src/index.js +9 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/aio-cli-lib-app-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "node lib to provide a consistent interface to various config files that make up Adobe Developer App Builder applications and extensions",
|
|
5
5
|
"repository": "https://github.com/adobe/aio-cli-lib-app-config/",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@adobe/aio-lib-core-config": "^3.0.0",
|
|
22
|
-
"@adobe/aio-lib-core-logging": "
|
|
22
|
+
"@adobe/aio-lib-core-logging": "^2.0.0",
|
|
23
23
|
"@adobe/aio-lib-env": "^2.0.0",
|
|
24
24
|
"ajv": "^8.12.0",
|
|
25
25
|
"ajv-formats": "^2.1.1",
|
|
@@ -74,6 +74,5 @@
|
|
|
74
74
|
"setupFilesAfterEnv": [
|
|
75
75
|
"./test/jest.setup.js"
|
|
76
76
|
]
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
}
|
|
77
|
+
}
|
|
78
|
+
}
|
package/src/index.js
CHANGED
|
@@ -264,28 +264,17 @@ async function loadCommonConfig (/* istanbul ignore next */options = {}) {
|
|
|
264
264
|
// }
|
|
265
265
|
|
|
266
266
|
/**
|
|
267
|
-
* Resolve all includes, update relative paths and return a coalesced app
|
|
268
|
-
* configuration object.
|
|
269
|
-
*
|
|
270
|
-
* Returns the appConfig along with an index of config keys to config file. The
|
|
271
|
-
* config file paths in the index are absolute.
|
|
267
|
+
* Resolve all includes, update relative paths and return a coalesced app configuration object.
|
|
272
268
|
*
|
|
273
269
|
* @param {string} appConfigFile path to the app.config.yaml
|
|
274
270
|
* @param {object} options options
|
|
275
|
-
* @param {object} options.absolutePaths boolean, true for
|
|
276
|
-
*
|
|
277
|
-
* directory. Defaults to false. Note, that config values will never be
|
|
278
|
-
* rewritten as relative to the cwd. But also note that
|
|
279
|
-
* this option doesn't have any effect on the includeIndex paths which stay
|
|
280
|
-
* relative to the cwd.
|
|
281
|
-
* @returns {object} { config, includeIndex }
|
|
271
|
+
* @param {object} options.absolutePaths boolean, true for absolute paths, default for relative to appConfigFile directory.
|
|
272
|
+
* @returns {object} single appConfig with resolved includes
|
|
282
273
|
*/
|
|
283
274
|
async function coalesce (appConfigFile, options = {}) {
|
|
284
275
|
// this code is traversing app.config.yaml recursively to resolve all $includes directives
|
|
285
276
|
|
|
286
277
|
const absolutePaths = options.absolutePaths === undefined ? false : options.absolutePaths
|
|
287
|
-
const appRoot = path.dirname(appConfigFile)
|
|
288
|
-
|
|
289
278
|
const config = yaml.safeLoad(await fs.readFile(appConfigFile, 'utf8'))
|
|
290
279
|
// keep an index that will map keys like 'extensions.abc.runtimeManifest' to the config file where there are defined
|
|
291
280
|
const includeIndex = {}
|
|
@@ -369,7 +358,7 @@ async function coalesce (appConfigFile, options = {}) {
|
|
|
369
358
|
}
|
|
370
359
|
|
|
371
360
|
const appConfigWithIncludeIndex = { config, includeIndex }
|
|
372
|
-
rewritePathsInPlace(appConfigWithIncludeIndex, { absolutePaths
|
|
361
|
+
rewritePathsInPlace(appConfigWithIncludeIndex, { absolutePaths })
|
|
373
362
|
|
|
374
363
|
return appConfigWithIncludeIndex
|
|
375
364
|
}
|
|
@@ -477,7 +466,7 @@ function rewritePathsInPlace (appConfigWithIncludeIndex, options) {
|
|
|
477
466
|
|
|
478
467
|
if (typeof value === 'string' && PATH_KEYS.filter(reg => fullKey.match(reg)).length) {
|
|
479
468
|
// rewrite path value to be relative to the root instead of being relative to the config file that includes it
|
|
480
|
-
parentObj[key] = resolveToRoot(value, includedFromConfigFile, options)
|
|
469
|
+
parentObj[key] = resolveToRoot(value, includedFromConfigFile, { absolutePaths: options.absolutePaths })
|
|
481
470
|
}
|
|
482
471
|
if (typeof value === 'object') {
|
|
483
472
|
// object or Array
|
|
@@ -696,16 +685,10 @@ async function buildSingleConfig (configName, singleUserConfig, commonConfig, in
|
|
|
696
685
|
function resolveToRoot (pathValue, includedFromConfigPath, options = {}) {
|
|
697
686
|
// path.resolve => support both absolute pathValue and relative (relative joins with
|
|
698
687
|
// config dir and process.cwd, absolute returns pathValue)
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
// relative paths
|
|
704
|
-
if (options.appRoot) {
|
|
705
|
-
// make sure path is relative to appRoot and not cwd
|
|
706
|
-
includedFromConfigPath = path.relative(options.appRoot, includedFromConfigPath)
|
|
707
|
-
}
|
|
708
|
-
return path.join(path.dirname(includedFromConfigPath), pathValue).split(path.sep).join(path.posix.sep)
|
|
688
|
+
return options.absolutePaths
|
|
689
|
+
? path.resolve(path.dirname(includedFromConfigPath), pathValue)
|
|
690
|
+
// if relative keep unix paths
|
|
691
|
+
: path.join(path.dirname(includedFromConfigPath), pathValue).split(path.sep).join(path.posix.sep)
|
|
709
692
|
}
|
|
710
693
|
|
|
711
694
|
module.exports = {
|