Skip to content

Commit

Permalink
feat: add loading event config
Browse files Browse the repository at this point in the history
  • Loading branch information
purplecabbage committed Mar 11, 2023
1 parent 437a3c5 commit eb67d90
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.json
@@ -1,3 +1,6 @@
{
"extends": ["@adobe/eslint-config-aio-lib-config"]
"extends": ["@adobe/eslint-config-aio-lib-config"],
"parserOptions": {
"ecmaVersion": 2020
}
}
16 changes: 12 additions & 4 deletions src/index.js
Expand Up @@ -158,7 +158,7 @@ function loadCommonConfig () {
ow: owConfig,
aio: aioConfig,
// soon not needed anymore (for old headless validator)
imsOrgId: aioConfig && aioConfig.project && aioConfig.project.org && aioConfig.project.org.ims_org_id
imsOrgId: aioConfig.project?.org?.ims_org_id
}
}

Expand Down Expand Up @@ -289,7 +289,9 @@ function loadUserConfigLegacy (commonConfig) {
// todo: new value usingLegacyConfig
// this module should not console.log/warn ... or include chalk ...
if (commonConfig.aio.cna !== undefined || commonConfig.aio.app !== undefined) {
aioLogger.warn('App config in \'.aio\' file is deprecated. Please move your \'.aio.app\' or \'.aio.cna\' to \'app.config.yaml\'.')
// this might have never have been seen in the wild as we don't know
// what log-level users have set
aioLogger.error('App config in \'.aio\' file is deprecated. Please move your \'.aio.app\' or \'.aio.cna\' to \'app.config.yaml\'.')
const appConfig = { ...commonConfig.aio.app, ...commonConfig.aio.cna }
Object.entries(appConfig).forEach(([k, v]) => {
legacyAppConfig[k] = v
Expand Down Expand Up @@ -344,7 +346,7 @@ function loadUserConfigLegacy (commonConfig) {
})
// todo: new val usingLegacyHooks:Boolean
if (Object.keys(hooks).length > 0) {
aioLogger.warn('hooks in \'package.json\' are deprecated. Please move your hooks to \'app.config.yaml\' under the \'hooks\' key')
aioLogger.error('hooks in \'package.json\' are deprecated. Please move your hooks to \'app.config.yaml\' under the \'hooks\' key')
legacyAppConfig.hooks = hooks
// build index
includeIndex[`${defaults.APPLICATION_CONFIG_KEY}.hooks`] = { file: 'package.json', key: 'scripts' }
Expand Down Expand Up @@ -421,7 +423,10 @@ function buildExtConfigs (userConfig, commonConfig, includeIndex) {

/** @private */
function buildAppConfig (userConfig, commonConfig, includeIndex) {
const fullAppConfig = buildSingleConfig(defaults.APPLICATION_CONFIG_KEY, userConfig[defaults.APPLICATION_CONFIG_KEY], commonConfig, includeIndex)
const fullAppConfig = buildSingleConfig(defaults.APPLICATION_CONFIG_KEY,
userConfig[defaults.APPLICATION_CONFIG_KEY],
commonConfig,
includeIndex)

if (!fullAppConfig.app.hasBackend && !fullAppConfig.app.hasFrontend) {
// only set application config if there is an actuall app, meaning either some backend or frontend
Expand All @@ -445,6 +450,7 @@ function buildSingleConfig (configName, singleUserConfig, commonConfig, includeI
manifest: {},
actions: {},
tests: {},
events: {},
// root of the app folder
root: process.cwd(),
name: configName
Expand Down Expand Up @@ -481,6 +487,8 @@ function buildSingleConfig (configName, singleUserConfig, commonConfig, includeI
config.app.hasFrontend = fs.existsSync(web)
config.app.dist = path.resolve(dist, dist === defaultDistPath ? subFolderName : '')

config.events = singleUserConfig.events

// actions
config.actions.src = path.resolve(actions) // needed for app add first action
if (config.app.hasBackend) {
Expand Down

0 comments on commit eb67d90

Please sign in to comment.