@adobe/aio-cli-lib-app-config 1.0.1 → 1.1.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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/index.js +40 -23
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/aio-cli-lib-app-config",
3
- "version": "1.0.1",
3
+ "version": "1.1.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",
@@ -31,11 +31,11 @@
31
31
  "eslint": "^8",
32
32
  "eslint-config-standard": "^17",
33
33
  "eslint-plugin-import": "^2.25.3",
34
- "eslint-plugin-jest": "^23",
35
- "eslint-plugin-jsdoc": "^37",
34
+ "eslint-plugin-jest": "^27",
35
+ "eslint-plugin-jsdoc": "^42",
36
+ "eslint-plugin-n": "^16",
36
37
  "eslint-plugin-node": "^11.1.0",
37
38
  "eslint-plugin-promise": "^6",
38
- "eslint-plugin-n": "^15",
39
39
  "eslint-plugin-standard": "^4.0.0",
40
40
  "jest": "^27",
41
41
  "jest-junit": "^10.0.0",
package/src/index.js CHANGED
@@ -34,6 +34,24 @@ const defaults = {
34
34
  EXTENSIONS_CONFIG_KEY: 'extensions'
35
35
  }
36
36
 
37
+ const HookKeys = [
38
+ 'pre-app-build',
39
+ 'post-app-build',
40
+ 'build-actions',
41
+ 'build-static',
42
+ 'pre-app-deploy',
43
+ 'post-app-deploy',
44
+ 'deploy-actions',
45
+ 'deploy-static',
46
+ 'pre-app-undeploy',
47
+ 'post-app-undeploy',
48
+ 'undeploy-actions',
49
+ 'undeploy-static',
50
+ 'pre-app-run',
51
+ 'post-app-run',
52
+ 'serve-static'
53
+ ]
54
+
37
55
  const {
38
56
  getCliEnv, /* function */
39
57
  STAGE_ENV /* string */
@@ -158,7 +176,7 @@ function loadCommonConfig () {
158
176
  ow: owConfig,
159
177
  aio: aioConfig,
160
178
  // soon not needed anymore (for old headless validator)
161
- imsOrgId: aioConfig && aioConfig.project && aioConfig.project.org && aioConfig.project.org.ims_org_id
179
+ imsOrgId: aioConfig.project?.org?.ims_org_id
162
180
  }
163
181
  }
164
182
 
@@ -289,7 +307,9 @@ function loadUserConfigLegacy (commonConfig) {
289
307
  // todo: new value usingLegacyConfig
290
308
  // this module should not console.log/warn ... or include chalk ...
291
309
  if (commonConfig.aio.cna !== undefined || commonConfig.aio.app !== undefined) {
292
- aioLogger.warn('App config in \'.aio\' file is deprecated. Please move your \'.aio.app\' or \'.aio.cna\' to \'app.config.yaml\'.')
310
+ // this might have never have been seen in the wild as we don't know
311
+ // what log-level users have set
312
+ aioLogger.error('App config in \'.aio\' file is deprecated. Please move your \'.aio.app\' or \'.aio.cna\' to \'app.config.yaml\'.')
293
313
  const appConfig = { ...commonConfig.aio.app, ...commonConfig.aio.cna }
294
314
  Object.entries(appConfig).forEach(([k, v]) => {
295
315
  legacyAppConfig[k] = v
@@ -321,30 +341,17 @@ function loadUserConfigLegacy (commonConfig) {
321
341
  if (pkgjsonscripts) {
322
342
  const hooks = {}
323
343
  // https://www.adobe.io/apis/experienceplatform/project-firefly/docs.html#!AdobeDocs/project-firefly/master/guides/app-hooks.md
324
- hooks['pre-app-build'] = pkgjsonscripts['pre-app-build']
325
- hooks['post-app-build'] = pkgjsonscripts['post-app-build']
326
- hooks['build-actions'] = pkgjsonscripts['build-actions']
327
- hooks['build-static'] = pkgjsonscripts['build-static']
328
- hooks['pre-app-deploy'] = pkgjsonscripts['pre-app-deploy']
329
- hooks['post-app-deploy'] = pkgjsonscripts['post-app-deploy']
330
- hooks['deploy-actions'] = pkgjsonscripts['deploy-actions']
331
- hooks['deploy-static'] = pkgjsonscripts['deploy-static']
332
- hooks['pre-app-undeploy'] = pkgjsonscripts['pre-app-undeploy']
333
- hooks['post-app-undeploy'] = pkgjsonscripts['post-app-undeploy']
334
- hooks['undeploy-actions'] = pkgjsonscripts['undeploy-actions']
335
- hooks['undeploy-static'] = pkgjsonscripts['undeploy-static']
336
- hooks['pre-app-run'] = pkgjsonscripts['pre-app-run']
337
- hooks['post-app-run'] = pkgjsonscripts['post-app-run']
338
- hooks['serve-static'] = pkgjsonscripts['serve-static']
339
- // remove undefined hooks
340
- Object.entries(hooks).forEach(([k, v]) => {
341
- if (!hooks[k]) {
342
- delete hooks[k]
344
+
345
+ HookKeys.forEach(hookKey => {
346
+ if (pkgjsonscripts[hookKey]) {
347
+ hooks[hookKey] = pkgjsonscripts[hookKey]
348
+ includeIndex[`${defaults.APPLICATION_CONFIG_KEY}.hooks.${hookKey}`] = { file: 'package.json', key: `scripts.${hookKey}` }
343
349
  }
344
350
  })
351
+
345
352
  // todo: new val usingLegacyHooks:Boolean
346
353
  if (Object.keys(hooks).length > 0) {
347
- aioLogger.warn('hooks in \'package.json\' are deprecated. Please move your hooks to \'app.config.yaml\' under the \'hooks\' key')
354
+ aioLogger.error('hooks in \'package.json\' are deprecated. Please move your hooks to \'app.config.yaml\' under the \'hooks\' key')
348
355
  legacyAppConfig.hooks = hooks
349
356
  // build index
350
357
  includeIndex[`${defaults.APPLICATION_CONFIG_KEY}.hooks`] = { file: 'package.json', key: 'scripts' }
@@ -421,7 +428,10 @@ function buildExtConfigs (userConfig, commonConfig, includeIndex) {
421
428
 
422
429
  /** @private */
423
430
  function buildAppConfig (userConfig, commonConfig, includeIndex) {
424
- const fullAppConfig = buildSingleConfig(defaults.APPLICATION_CONFIG_KEY, userConfig[defaults.APPLICATION_CONFIG_KEY], commonConfig, includeIndex)
431
+ const fullAppConfig = buildSingleConfig(defaults.APPLICATION_CONFIG_KEY,
432
+ userConfig[defaults.APPLICATION_CONFIG_KEY],
433
+ commonConfig,
434
+ includeIndex)
425
435
 
426
436
  if (!fullAppConfig.app.hasBackend && !fullAppConfig.app.hasFrontend) {
427
437
  // only set application config if there is an actuall app, meaning either some backend or frontend
@@ -488,6 +498,13 @@ function buildSingleConfig (configName, singleUserConfig, commonConfig, includeI
488
498
  config.app.hasFrontend = fs.existsSync(web)
489
499
  config.app.dist = path.resolve(dist, dist === defaultDistPath ? subFolderName : '')
490
500
 
501
+ if (singleUserConfig.events) {
502
+ config.events = { ...singleUserConfig.events }
503
+ }
504
+ if (commonConfig?.aio?.project) {
505
+ config.project = commonConfig.aio.project
506
+ }
507
+
491
508
  // actions
492
509
  config.actions.src = path.resolve(actions) // needed for app add first action
493
510
  if (config.app.hasBackend) {