Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update major for aio-cli-lib-app-config #682

Closed
wants to merge 10 commits into from
Closed
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Adobe Inc.",
"bugs": "https://github.com/adobe/aio-cli-plugin-app/issues",
"dependencies": {
"@adobe/aio-cli-lib-app-config": "^1.0.1",
"@adobe/aio-cli-lib-app-config": "^2.0.0",
"@adobe/aio-cli-lib-console": "^4.1.0",
"@adobe/aio-lib-core-config": "^4.0.0",
"@adobe/aio-lib-core-logging": "^2.0.0",
Expand Down
157 changes: 0 additions & 157 deletions schema/app.config.yaml.schema.json

This file was deleted.

3 changes: 1 addition & 2 deletions schema/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

const { USER_CONFIG_FILE, DEPLOY_CONFIG_FILE, IMPORT_CONFIG_FILE } = require('../src/lib/defaults')
const { DEPLOY_CONFIG_FILE, IMPORT_CONFIG_FILE } = require('../src/lib/defaults')

module.exports = {
[IMPORT_CONFIG_FILE]: require('./config.schema.json'),
[USER_CONFIG_FILE]: require('./app.config.yaml.schema.json'),
[DEPLOY_CONFIG_FILE]: require('./deploy.yaml.schema.json')
}
20 changes: 10 additions & 10 deletions src/BaseCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const chalk = require('chalk')
const coreConfig = require('@adobe/aio-lib-core-config')
const DEFAULT_LAUNCH_PREFIX = 'https://experience.adobe.com/?devMode=true#/custom-apps/?localDevUrl='
const STAGE_LAUNCH_PREFIX = 'https://experience-stage.adobe.com/?devMode=true#/custom-apps/?localDevUrl='
const loadConfig = require('@adobe/aio-cli-lib-app-config')
const libAppConfig = require('@adobe/aio-cli-lib-app-config')
const inquirer = require('inquirer')
const { CONSOLE_API_KEYS, APPLICATION_CONFIG_KEY, EXTENSIONS_CONFIG_KEY } = require('./lib/defaults')
const { getCliInfo } = require('./lib/app-helper')
Expand Down Expand Up @@ -71,8 +71,8 @@ class BaseCommand extends Command {
LibConsoleCLI.cleanStdOut()
}

getAppExtConfigs (flags, options = {}) {
const all = this.getFullConfig(options).all
async getAppExtConfigs (flags, options = {}) {
const all = (await this.getFullConfig(options)).all

// default case: no flags, return all
let ret = all
Expand Down Expand Up @@ -102,25 +102,25 @@ class BaseCommand extends Command {
return ret
}

getRuntimeManifestConfigFile (implName) {
async getRuntimeManifestConfigFile (implName) {
let configKey
if (implName === APPLICATION_CONFIG_KEY) {
configKey = APPLICATION_CONFIG_KEY
} else {
configKey = `${EXTENSIONS_CONFIG_KEY}.${implName}`
}
let configData = this.getConfigFileForKey(`${configKey}.runtimeManifest`)
let configData = await this.getConfigFileForKey(`${configKey}.runtimeManifest`)
if (!configData.file) {
// first action manifest is not defined
configData = this.getConfigFileForKey(`${configKey}`)
configData = await this.getConfigFileForKey(`${configKey}`)
configData.key = configData.key + '.runtimeManifest'
}
return configData
}

getConfigFileForKey (fullKey) {
async getConfigFileForKey (fullKey) {
// NOTE: the index returns undefined if the key is loaded from a legacy configuration file
const fullConfig = this.getFullConfig()
const fullConfig = await this.getFullConfig()
// full key like 'extensions.dx/excshell/1.runtimeManifest'
// returns { key: relKey, file: configFile}
const configData = fullConfig.includeIndex[fullKey]
Expand All @@ -132,9 +132,9 @@ class BaseCommand extends Command {
return configData || {}
}

getFullConfig (options = {}) {
async getFullConfig (options = {}) {
if (!this.appConfig) {
this.appConfig = loadConfig(options)
this.appConfig = await libAppConfig.load(options)
}
return this.appConfig
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/app/add/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ class AddActionCommand extends TemplatesCommand {
aioLogger.debug(`add actions with flags: ${JSON.stringify(flags)}`)

// guaranteed to have at least one, otherwise would throw in config load or in matching the ext name
const entries = Object.entries(this.getAppExtConfigs(flags))
const entries = Object.entries(await this.getAppExtConfigs(flags))
if (entries.length > 1) {
this.error('Please use the \'-e\' flag to specify to which implementation you want to add actions to.')
}
const configName = entries[0][0]
const config = entries[0][1]

const actionFolder = path.relative(config.root, config.actions.src)
const configData = this.getRuntimeManifestConfigFile(configName)
const configData = await this.getRuntimeManifestConfigFile(configName)

const projectOrgId = aioConfigLoader.get('project.org.id')
if (!projectOrgId) {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/app/add/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ class AddEventCommand extends AddCommand {
const spinner = ora()

// guaranteed to have at least one, otherwise would throw in config load or in matching the ext name
const entries = Object.entries(this.getAppExtConfigs(flags))
const entries = Object.entries(await this.getAppExtConfigs(flags))
if (entries.length > 1) {
this.error('Please use the \'-e\' flag to specify to which implementation you want to add events to.')
}
const configName = entries[0][0]
const config = entries[0][1]
const actionFolder = path.relative(config.root, config.actions.src)
const configData = this.getRuntimeManifestConfigFile(configName)
const configData = await this.getRuntimeManifestConfigFile(configName)

const env = yeoman.createEnv()
// by default yeoman runs the install, we control installation from the app plugin
Expand Down
2 changes: 1 addition & 1 deletion src/commands/app/add/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class AddExtensionCommand extends TemplatesCommand {
this.error('--extension= must also be provided when using --yes')
}

const fullConfig = this.getFullConfig({ allowNoImpl: true })
const fullConfig = await this.getFullConfig({ allowNoImpl: true })
const alreadyImplemented = fullConfig.implements

if (flags.extension) {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/app/add/web-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class AddWebAssetsCommand extends TemplatesCommand {
const { flags } = await this.parse(AddWebAssetsCommand)
aioLogger.debug(`add web-assets with flags: ${JSON.stringify(flags)}`)

const projectName = this.getFullConfig().packagejson.name
const projectName = (await this.getFullConfig()).packagejson.name
// guaranteed to have at least one, otherwise would throw in config load or in matching the ext name
const entries = Object.entries(this.getAppExtConfigs(flags))
const entries = Object.entries(await this.getAppExtConfigs(flags))
if (entries.length > 1) {
this.error('Please use the \'-e\' flag to specify to which implementation you want to add web-assets to.')
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/app/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Build extends BaseCommand {
// flags
flags['web-assets'] = flags['web-assets'] && !flags.action

const buildConfigs = this.getAppExtConfigs(flags)
const buildConfigs = await this.getAppExtConfigs(flags)

// 1. build actions and web assets for each extension
const keys = Object.keys(buildConfigs)
Expand Down
2 changes: 1 addition & 1 deletion src/commands/app/config/get/log-forwarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const LogForwarding = require('../../../../lib/log-forwarding')

class LogForwardingCommand extends BaseCommand {
async run () {
const lf = await LogForwarding.init(this.getFullConfig().aio)
const lf = await LogForwarding.init((await this.getFullConfig()).aio)

const localConfig = lf.getLocalConfig()
const serverConfig = await lf.getServerConfig()
Expand Down
2 changes: 1 addition & 1 deletion src/commands/app/config/get/log-forwarding/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ErrorsCommand extends BaseCommand {
}

async getLogForwarding () {
const runtimeConfig = this.getFullConfig().aio.runtime
const runtimeConfig = (await this.getFullConfig()).aio.runtime
rtLib.utils.checkOpenWhiskCredentials({ ow: runtimeConfig })
const rt = await rtLib.init({
...runtimeConfig,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/app/config/set/log-forwarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const LogForwarding = require('../../../../lib/log-forwarding')

class LogForwardingCommand extends BaseCommand {
async run () {
const lf = await LogForwarding.init(this.getFullConfig().aio)
const lf = await LogForwarding.init((await this.getFullConfig()).aio)

const destination = await this.promptDestination(lf.getSupportedDestinations())
const destinationSettingsConfig = lf.getSettingsConfig(destination)
Expand Down
23 changes: 13 additions & 10 deletions src/commands/app/delete/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class DeleteActionCommand extends BaseCommand {
this.error('<action-name> must also be provided when using --yes')
}

const fullConfig = this.getFullConfig()
const { actions, actionsByImpl } = this.getAllActions(fullConfig)
const fullConfig = await this.getFullConfig()
const { actions, actionsByImpl } = await this.getAllActions(fullConfig)
if (actions.length <= 0) {
this.error('There are no actions in this project!')
}
Expand Down Expand Up @@ -108,17 +108,20 @@ class DeleteActionCommand extends BaseCommand {
)))
}

getAllActions (config) {
async getAllActions (config) {
const actions = []
const actionsByImpl = {}
Object.entries(config.all).forEach(([implName, implConfig]) => {
const allConfigEntries = Object.entries(config.all)
for (const [implName, implConfig] of allConfigEntries) {
if (implConfig.app.hasBackend) {
actionsByImpl[implName] = []
Object.entries(implConfig.manifest.full.packages).forEach(([pkgName, pkg]) => {
Object.entries(pkg.actions).forEach(([actionName, action]) => {
const allPackagesEntries = Object.entries(implConfig.manifest.full.packages)
for (const [pkgName, pkg] of allPackagesEntries) {
const actionEntries = Object.entries(pkg.actions)
for (const [actionName, action] of actionEntries) {
const fullActionName = `${pkgName}/${actionName}`
const startKey = implName === 'application' ? 'application' : `extensions.${implName}`
const configData = this.getConfigFileForKey(`${startKey}.runtimeManifest.packages.${pkgName}.actions.${actionName}`)
const configData = await this.getConfigFileForKey(`${startKey}.runtimeManifest.packages.${pkgName}.actions.${actionName}`)
const actionObj = {
// assumes path is not relative
path: action.function,
Expand All @@ -131,12 +134,12 @@ class DeleteActionCommand extends BaseCommand {
}
actions.push(actionObj)
actionsByImpl[implName].push(actionObj)
})
})
}
}
} else {
aioLogger.debug(`'${implName}' .app.hasBackend is not true`)
}
})
}
return { actions, actionsByImpl }
}
}
Expand Down
Loading