@adobe/aio-cli-lib-app-config 3.0.2 → 4.0.1

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/package.json +5 -5
  2. package/src/index.js +16 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/aio-cli-lib-app-config",
3
- "version": "3.0.2",
3
+ "version": "4.0.1",
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",
@@ -18,9 +18,9 @@
18
18
  "generate-docs": "npm run typings && npm run jsdoc"
19
19
  },
20
20
  "dependencies": {
21
- "@adobe/aio-lib-core-config": "^3.0.0",
22
- "@adobe/aio-lib-core-logging": "^2.0.0",
23
- "@adobe/aio-lib-env": "^2.0.0",
21
+ "@adobe/aio-lib-core-config": "^5",
22
+ "@adobe/aio-lib-core-logging": "^3",
23
+ "@adobe/aio-lib-env": "^3",
24
24
  "ajv": "^8.12.0",
25
25
  "ajv-formats": "^2.1.1",
26
26
  "fs-extra": "^9.0.1",
@@ -49,7 +49,7 @@
49
49
  "typescript": "^4.5.2"
50
50
  },
51
51
  "engines": {
52
- "node": "^14.18 || ^16.13 || >=18"
52
+ "node": ">=18"
53
53
  },
54
54
  "jest": {
55
55
  "collectCoverage": true,
package/src/index.js CHANGED
@@ -137,13 +137,16 @@ const cloneDeep = require('lodash.clonedeep')
137
137
  * }
138
138
  *
139
139
  * @param {object} options options to load Config
140
- * @param {boolean} options.allowNoImpl do not throw if there is no implementation
141
- * @param {boolean} options.ignoreAioConfig do not load .aio config via aio-lib-core-config, which is loaded synchronously and blocks the main thread.
140
+ * @param {boolean} [options.allowNoImpl=false] do not throw if there is no implementation
141
+ * @param {boolean} [options.ignoreAioConfig=false] do not load .aio config via aio-lib-core-config, which is loaded synchronously and blocks the main thread.
142
+ * @param {boolean} [options.validateAppConfig=true] set to false to not validate
142
143
  * @returns {object} the config
143
144
  */
144
145
  async function load (options = {}) {
145
146
  const allowNoImpl = options.allowNoImpl === undefined ? false : options.allowNoImpl
146
147
  const ignoreAioConfig = options.ignoreAioConfig === undefined ? false : options.ignoreAioConfig
148
+ const validateAppConfig = options.validateAppConfig === undefined ? true : options.validateAppConfig
149
+
147
150
  // *NOTE* it would be nice to support an appFolder option to load config from a different folder.
148
151
  // However, this requires to update aio-lib-core-config to support loading
149
152
  // from a different folder aswell (or enforcing ignore).
@@ -164,7 +167,9 @@ async function load (options = {}) {
164
167
  // this will resolve $include directives and output the app config into a single object
165
168
  // paths config values in $included files will be rewritten
166
169
  const appConfigWithIndex = await coalesce(defaults.USER_CONFIG_FILE, { absolutePaths: true })
167
- await validate(appConfigWithIndex.config, { throws: true })
170
+ if (validateAppConfig) {
171
+ await validate(appConfigWithIndex.config, { throws: true })
172
+ }
168
173
  const mergedAppConfig = await mergeLegacyAppConfig(appConfigWithIndex, legacyAppConfigWithIndex)
169
174
 
170
175
  appConfig = mergedAppConfig.config
@@ -200,6 +205,7 @@ async function load (options = {}) {
200
205
  * @param {object} options options
201
206
  * @param {boolean} options.throws defaults to false, if true throws on validation error instead of returning the error
202
207
  * @throws if not valid
208
+ * @returns {object} keys: valid (boolean), errors (array)
203
209
  */
204
210
  async function validate (coalescedAppConfigObj, options = {}) {
205
211
  const throws = options.throws === undefined ? false : options.throws
@@ -589,7 +595,13 @@ async function buildSingleConfig (configName, singleUserConfig, commonConfig, in
589
595
  // Let's search the config path that defines a key in the same config object level as 'web' or
590
596
  // 'action'
591
597
  const otherKeyInObject = Object.keys(singleUserConfig)[0]
592
- const configFilePath = includeIndex[`${fullKeyPrefix}.${otherKeyInObject}`].file
598
+ let configFilePath
599
+ if (otherKeyInObject === undefined) {
600
+ // corner case if config is empty e.g. application: {}
601
+ configFilePath = includeIndex[`${fullKeyPrefix}`].file
602
+ } else {
603
+ configFilePath = includeIndex[`${fullKeyPrefix}.${otherKeyInObject}`].file
604
+ }
593
605
 
594
606
  const defaultActionPath = resolveToRoot('actions/', configFilePath)
595
607
  const defaultWebPath = resolveToRoot('web-src/', configFilePath)