UNPKG

@zowe/imperative

Version:
601 lines 33.1 kB
"use strict"; /* * This program and the accompanying materials are made available under the terms of the * Eclipse Public License v2.0 which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-v20.html * * SPDX-License-Identifier: EPL-2.0 * * Copyright Contributors to the Zowe Project. * */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Imperative = void 0; /** * Main class of the Imperative framework, returned when you * require("@zowe/imperative") e.g. const imperative = require("@zowe/imperative"); */ const Logger_1 = require("../../logger/src/Logger"); const LoggerConfigBuilder_1 = require("../../logger/src/LoggerConfigBuilder"); const yargs = require("yargs"); const ConfigurationLoader_1 = require("./ConfigurationLoader"); const ConfigurationValidator_1 = require("./ConfigurationValidator"); const ImperativeApi_1 = require("./api/ImperativeApi"); const Constants_1 = require("../../constants/src/Constants"); const TextUtils_1 = require("../../utilities/src/TextUtils"); const ImperativeConfig_1 = require("../../utilities/src/ImperativeConfig"); const LoggingConfigurer_1 = require("./LoggingConfigurer"); const error_1 = require("../../error"); const PluginManagementFacility_1 = require("./plugins/PluginManagementFacility"); // import { ConfigManagementFacility } from "./config/ConfigManagementFacility"; const AbstractCommandYargs_1 = require("../../cmd/src/yargs/AbstractCommandYargs"); const CommandPreparer_1 = require("../../cmd/src/CommandPreparer"); const CommandYargs_1 = require("../../cmd/src/yargs/CommandYargs"); const WebHelpManager_1 = require("../../cmd/src/help/WebHelpManager"); const YargsConfigurer_1 = require("../../cmd/src/yargs/YargsConfigurer"); const YargsDefiner_1 = require("../../cmd/src/yargs/YargsDefiner"); const ImperativeHelpGeneratorFactory_1 = require("./help/ImperativeHelpGeneratorFactory"); const OverridesLoader_1 = require("./OverridesLoader"); const DefinitionTreeResolver_1 = require("./DefinitionTreeResolver"); const EnvironmentalVariableSettings_1 = require("./env/EnvironmentalVariableSettings"); const AppSettings_1 = require("../../settings/src/AppSettings"); const path_1 = require("path"); const Console_1 = require("../../console/src/Console"); const ImperativeExpect_1 = require("../../expect/src/ImperativeExpect"); const CompleteAuthGroupBuilder_1 = require("./auth/builders/CompleteAuthGroupBuilder"); const Config_1 = require("../../config/src/Config"); const CompleteAutoInitCommandBuilder_1 = require("./config/cmd/auto-init/builders/CompleteAutoInitCommandBuilder"); const EnvFileUtils_1 = require("../../utilities/src/EnvFileUtils"); class Imperative { /** * Retrieve the root command name. * @example * For example, in "banana a b --c", "banana" is the root command name. * @returns {string} - root command name */ static get rootCommandName() { return this.mRootCommandName; } /** * Retrieve the command line. * @example * For example, in "banana a b --c", "a b --c" is the command line. * @returns {string} - command line */ static get commandLine() { return this.mCommandLine; } /** * Set the command line (needed for daemon where command changes and is not static) * @static * @memberof Imperative */ static set commandLine(args) { this.mCommandLine = args; ImperativeConfig_1.ImperativeConfig.instance.commandLine = args; } /** * Get the complete full command tree * @returns {ICommandDefinition} */ static get fullCommandTree() { return this.mFullCommandTree; } /** * Initialize the configuration for your CLI. * Wipes out any existing config that has already been set. * * @param {IImperativeConfig} [config] Configuration for Imperative provided by your application. * If this parameter is not set, we will look in the closest * package.json up the directory tree from the main entry * point of your cli. * * package.imperative.configurationModule should point to the * compiled module that exports the configuration. * * @returns {Promise<void>} A promise indicating that we are done here. */ static init(config) { return __awaiter(this, void 0, void 0, function* () { try { /** * Config Logger Manager to enable log messages in memory prior to logger init. */ Logger_1.Logger.setLogInMemory(true); /** * Identify caller's location on the system */ ImperativeConfig_1.ImperativeConfig.instance.callerLocation = require.main.filename; /** * Load callers configuration, validate, and save */ config = ConfigurationLoader_1.ConfigurationLoader.load(config, ImperativeConfig_1.ImperativeConfig.instance.callerPackageJson, ImperativeConfig_1.ImperativeConfig.instance.getCallerFile); ConfigurationValidator_1.ConfigurationValidator.validate(config); ImperativeConfig_1.ImperativeConfig.instance.loadedConfig = config; // Detect CLI arguments to determine if errors should be ignored const ignoreErrors = process.argv.includes(Constants_1.Constants.OPT_LONG_DASH + Constants_1.Constants.HELP_OPTION) || process.argv.includes(Constants_1.Constants.OPT_SHORT_DASH + Constants_1.Constants.HELP_OPTION_ALIAS) || process.argv.includes(Constants_1.Constants.OPT_LONG_DASH + Constants_1.Constants.HELP_WEB_OPTION) || process.argv.includes(Constants_1.Constants.OPT_LONG_DASH + Constants_1.Constants.HELP_WEB_OPTION_ALIAS) || process.argv.includes(Constants_1.Constants.OPT_LONG_DASH + Constants_1.Constants.VERSION_OPTION) || process.argv.includes(Constants_1.Constants.OPT_SHORT_DASH + Constants_1.Constants.VERSION_OPTION_ALIAS) || process.argv[process.argv.length - 1] === require.resolve('@zowe/cli'); /** * Get the command name from the package bin. * If no command name exists, we will instead use the file name invoked * and log a debug warning. */ if (ImperativeConfig_1.ImperativeConfig.instance.findPackageBinName() != null) { this.mRootCommandName = ImperativeConfig_1.ImperativeConfig.instance.findPackageBinName(); } else { this.mRootCommandName = ImperativeConfig_1.ImperativeConfig.instance.callerLocation; this.log.debug("WARNING: No \"bin\" configuration was found in your package.json," + " or your package.json could not be found. " + "Defaulting command name to filepath instead."); } ImperativeConfig_1.ImperativeConfig.instance.rootCommandName = this.mRootCommandName; let delayedEnvFileSetupError = undefined; try { EnvFileUtils_1.EnvFileUtils.setEnvironmentForApp(ImperativeConfig_1.ImperativeConfig.instance.rootCommandName, true, ImperativeConfig_1.ImperativeConfig.instance.envVariablePrefix); } catch (err) { delayedEnvFileSetupError = err; } // Initialize our settings file this.initAppSettings(); // If config group is enabled add config commands if (config.allowConfigGroup) { const ConfigManagementFacility = require("./config/ConfigManagementFacility"); // Delayed load req for init help text to work ConfigManagementFacility.ConfigManagementFacility.instance.init(); } let delayedConfigLoadError = undefined; // Load the base config, save any error from config load const configAppName = ImperativeConfig_1.ImperativeConfig.instance.findPackageBinName() ? this.mRootCommandName : config.name; try { ImperativeConfig_1.ImperativeConfig.instance.config = yield Config_1.Config.load(configAppName, { homeDir: ImperativeConfig_1.ImperativeConfig.instance.cliHome, ignoreErrors }); } catch (err) { delayedConfigLoadError = err; } // If plugins are allowed, enable core plugins commands if (config.allowPlugins) { PluginManagementFacility_1.PluginManagementFacility.instance.init(); // load the configuration of every installed plugin for later processing PluginManagementFacility_1.PluginManagementFacility.instance.loadAllPluginCfgProps(); // Override the config object with things loaded from plugins Object.assign(ImperativeConfig_1.ImperativeConfig.instance.loadedConfig.overrides, PluginManagementFacility_1.PluginManagementFacility.instance.pluginOverrides); } /** * Once we have a complete representation of the config object, we should be able to * use that and populate all required categories and expose them on our API object * so that an app using imperative can write to the imperative log, its own log, or * even a plug-in log. * * Any other initialization added to this routine should occur after logging has been initialized. */ this.initLogging(); /** * If there was an error trying to load the user's environment variable configuration, tell them about it now. * Do not stop the process from running. */ if (delayedEnvFileSetupError) { const appLogger = Logger_1.Logger.getAppLogger(); appLogger.logError(delayedEnvFileSetupError); new Console_1.Console().error(delayedEnvFileSetupError); } /** * If there was an error trying to load the user's configuration, tell them about it now. */ if (delayedConfigLoadError) { if (config.daemonMode) { ImperativeConfig_1.ImperativeConfig.instance.config = yield Config_1.Config.load(configAppName, { homeDir: ImperativeConfig_1.ImperativeConfig.instance.cliHome, ignoreErrors, noLoad: true }); const imperativeLogger = Logger_1.Logger.getImperativeLogger(); imperativeLogger.logError(delayedConfigLoadError); } else { throw delayedConfigLoadError; } } /** * Now we should apply any overrides to default Imperative functionality. This is where CLI * developers are able to really start customizing Imperative and how it operates internally. * For the "config convert-profiles" command, we skip loading the CredentialManager override * because we need to be able to uninstall the plugin that provides it. */ // eslint-disable-next-line @typescript-eslint/no-magic-numbers if (!(process.argv.length > 3 && process.argv[2] === "config" && process.argv[3].startsWith("convert"))) { yield OverridesLoader_1.OverridesLoader.load(ImperativeConfig_1.ImperativeConfig.instance.loadedConfig, ImperativeConfig_1.ImperativeConfig.instance.callerPackageJson); } /** * Build API object */ this.mApi = this.constructApiObject(); /** * Build the help generator factory - requires the root command name and the loaded configuration document */ this.mHelpGeneratorFactory = new ImperativeHelpGeneratorFactory_1.ImperativeHelpGeneratorFactory(this.rootCommandName, ImperativeConfig_1.ImperativeConfig.instance.loadedConfig); // resolve command module globs, forming the root of the CLI command tree this.log.info(`Loaded and validated config for '${config.name}'. Config details at trace level of logging.`); this.log.trace(`The config object for '${config.name}' is:\n` + JSON.stringify(config, null, 2)); const resolvedHostCliCmdTree = this.getResolvedCmdTree(config); // If plugins are allowed, add plugins' commands and profiles to the CLI command tree if (config.allowPlugins) { PluginManagementFacility_1.PluginManagementFacility.instance.addAllPluginsToHostCli(resolvedHostCliCmdTree); this.log.info("Plugins added to the CLI command tree."); } // final preparation of the command tree const preparedHostCliCmdTree = this.getPreparedCmdTree(resolvedHostCliCmdTree, config.baseProfile); /** * Define all known commands */ this.log.info("Inherited traits applied to CLI command tree children. " + "Cmd tree details at trace level of logging."); this.log.trace("The CLI command tree before being defined to yargs: " + JSON.stringify(preparedHostCliCmdTree, null, 2)); this.defineCommands(preparedHostCliCmdTree); /** * Notify caller initialization is complete */ return Promise.resolve(); } catch (error) { const imperativeLogger = Logger_1.Logger.getImperativeLogger(); if (error === null || error === void 0 ? void 0 : error.suppressDump) { imperativeLogger.fatal(error.message); // Error generated by a bad config is printed } else { imperativeLogger.fatal(require("util").inspect(error)); const os = require("os"); imperativeLogger.fatal("Diagnostic information:\n" + "Platform: '%s', Architecture: '%s', Process.argv: '%s'\n" + "Node versions: '%s'" + "Environmental variables: '%s'", os.platform(), os.arch(), process.argv.join(" "), JSON.stringify(process.versions, null, 2), JSON.stringify(process.env, null, 2)); Logger_1.Logger.writeInMemoryMessages(Imperative.DEFAULT_DEBUG_FILE); if (error.report) { const { writeFileSync } = require("fs"); writeFileSync(Imperative.DEFAULT_DEBUG_FILE, error.report); } if (!(error instanceof error_1.ImperativeError)) { const oldError = error; error = new error_1.ImperativeError({ msg: "Unexpected Error Encountered", causeErrors: error }); error.stack = "\n" + oldError.stack; } } return Promise.reject(error); } }); } /** * Returns the default console object to be used for messaging for * imperative fails to initialize or to be used before logging * is initialized. * @return {Logger}: an instance of the default console object */ static get console() { return this.constructConsoleApi(); } /** * Parse command line arguments and issue the user's specified command * @returns {Imperative} this, for chaining syntax */ static parse(args, context) { ImperativeConfig_1.ImperativeConfig.instance.daemonContext = context; AbstractCommandYargs_1.AbstractCommandYargs.STOP_YARGS = false; yargs.parse(args); return this; } /** * * @param {string} type the profile type to search for configuration for * @returns {IImperativeProfileConfig | undefined} The profile configuration if found, otherwise, undefined. */ static getProfileConfiguration(type) { const profileConfigs = ImperativeConfig_1.ImperativeConfig.instance.loadedConfig.profiles; if (profileConfigs == null || profileConfigs.length === 0) { return undefined; } let foundConfig; for (const profile of profileConfigs) { if (profile.type === type) { foundConfig = profile; } } return foundConfig; } /** * Get the configured help generator for your CLI. If you have not specified a custom generator, * the DefaultHelpGenerator will be used. * You probably won't need to call this from your CLI, but it is used internally. * @returns {IHelpGenerator} - The help generator for the command * @param {IHelpGeneratorParms} parms - parameters to the help generator including command definition */ static getHelpGenerator(parms) { return this.mHelpGeneratorFactory.getHelpGenerator(parms); } /** * Returns the imperative API object containing various framework API methods for usage in your CLI implemenation. * @return {ImperativeApi}: The api object. */ static get api() { if (this.mApi == null) { throw new error_1.ImperativeError({ msg: "Imperative API object does not exist. The Imperative.init() promise " + "must be fullfilled before the API object can be accessed. For issuing messages " + "without the API object, use Imperative.console.", }, { logger: Imperative.console, }); } return this.mApi; } /** * Highlight text with your configured (or default) primary color * @param {string} text - the text to highlight * @returns {string} - the highlighted text */ static highlightWithPrimaryColor(text) { return TextUtils_1.TextUtils.chalk[ImperativeConfig_1.ImperativeConfig.instance.loadedConfig.primaryTextColor](text); } /** * Highlight text with your configured (or default) secondary color * @param {string} text - the text to highlight * @returns {string} - the highlighted text */ static highlightWithSecondaryColor(text) { return TextUtils_1.TextUtils.chalk[ImperativeConfig_1.ImperativeConfig.instance.loadedConfig.secondaryTextColor](text); } /** * Get log instance */ static get log() { return Logger_1.Logger.getImperativeLogger(); } /** * Load the correct {@link AppSettings} instance from values located in the * cli home folder. */ static initAppSettings() { const cliSettingsRoot = (0, path_1.join)(ImperativeConfig_1.ImperativeConfig.instance.cliHome, "settings"); const cliSettingsFile = (0, path_1.join)(cliSettingsRoot, "imperative.json"); const defaultSettings = { overrides: { CredentialManager: ImperativeConfig_1.ImperativeConfig.instance.hostPackageName } }; AppSettings_1.AppSettings.initialize(cliSettingsFile, defaultSettings); } /** * Init log object such that subsequent calls to the Logger.getImperativeLogger() (or * other similar calls), will contain all necessary categories for logging. * * TODO(Kelosky): handle level setting via global config (trace enabling and such) */ static initLogging() { let message; /** * Build logging config from imperative config */ const loggingConfig = LoggingConfigurer_1.LoggingConfigurer.configureLogger(ImperativeConfig_1.ImperativeConfig.instance.cliHome, ImperativeConfig_1.ImperativeConfig.instance.loadedConfig); /** * Set log levels from environmental variable settings */ const envSettings = EnvironmentalVariableSettings_1.EnvironmentalVariableSettings.read(ImperativeConfig_1.ImperativeConfig.instance.envVariablePrefix); if (envSettings.imperativeLogLevel.value != null && envSettings.imperativeLogLevel.value.trim().length > 0) { if (Logger_1.Logger.isValidLevel(envSettings.imperativeLogLevel.value.trim())) { // set the imperative log level based on the user's environmental variable, if any loggingConfig.log4jsConfig.categories[Logger_1.Logger.DEFAULT_IMPERATIVE_NAME].level = envSettings.imperativeLogLevel.value; this.log.info("Set imperative log level to %s from environmental variable setting '%s'", envSettings.imperativeLogLevel.value, envSettings.imperativeLogLevel.key); } else { message = "Imperative log level '" + envSettings.imperativeLogLevel.value + "' from environmental variable setting '" + envSettings.imperativeLogLevel.key + "' is not recognised. " + "Logger level is set to '" + LoggerConfigBuilder_1.LoggerConfigBuilder.getDefaultLogLevel() + "'. " + "Valid levels are " + Logger_1.Logger.DEFAULT_VALID_LOG_LEVELS.toString(); new Console_1.Console().warn(message); this.log.warn(message); } } else { this.log.warn("Environmental setting for imperative log level ('%s') was blank.", envSettings.imperativeLogLevel.key); } if (envSettings.appLogLevel.value != null && envSettings.appLogLevel.value.trim().length > 0) { if (Logger_1.Logger.isValidLevel(envSettings.appLogLevel.value.trim())) { // set the app log level based on the user's environmental variable, if any loggingConfig.log4jsConfig.categories[Logger_1.Logger.DEFAULT_APP_NAME].level = envSettings.appLogLevel.value; this.log.info("Set app log level to %s from environmental variable setting '%s'", envSettings.appLogLevel.value, envSettings.appLogLevel.key); } else { message = "Application log level '" + envSettings.appLogLevel.value + "' from environmental variable setting '" + envSettings.appLogLevel.key + "' is not recognised. " + "Logger level is set to '" + LoggerConfigBuilder_1.LoggerConfigBuilder.getDefaultLogLevel() + "'. " + "Valid levels are " + Logger_1.Logger.DEFAULT_VALID_LOG_LEVELS.toString(); new Console_1.Console().warn(message); this.log.warn(message); } } else { this.log.warn("Environmental setting for app log level ('%s') was blank.", envSettings.appLogLevel.key); } /** * Setup log4js */ Logger_1.Logger.initLogger(loggingConfig); } /** * Define to yargs for main CLI and plugins * * @param {ICommandDefinition} preparedHostCliCmdTree - The Root of the imperative host CLI * which has already prepared by ImperativeConfig.getPreparedCmdTree. */ static defineCommands(preparedHostCliCmdTree) { const commandResponseParms = { primaryTextColor: ImperativeConfig_1.ImperativeConfig.instance.loadedConfig.primaryTextColor, progressBarSpinner: ImperativeConfig_1.ImperativeConfig.instance.loadedConfig.progressBarSpinner }; this.commandLine = process.argv.slice(2).join(" "); // Configure Yargs to meet the CLI's needs new YargsConfigurer_1.YargsConfigurer(preparedHostCliCmdTree, yargs, commandResponseParms, this.mHelpGeneratorFactory, ImperativeConfig_1.ImperativeConfig.instance.loadedConfig.experimentalCommandDescription, Imperative.rootCommandName, Imperative.commandLine, ImperativeConfig_1.ImperativeConfig.instance.envVariablePrefix, // Default value for PROMPT phrase couls be handled in the EnvironmentalVariableSettings class EnvironmentalVariableSettings_1.EnvironmentalVariableSettings.read(ImperativeConfig_1.ImperativeConfig.instance.envVariablePrefix).promptPhrase.value || Constants_1.Constants.DEFAULT_PROMPT_PHRASE // allow environmental variable to override the default prompt phrase ).configure(); // Define the commands to yargs CommandYargs_1.CommandYargs.defineOptionsToYargs(yargs, preparedHostCliCmdTree.options); const definer = new YargsDefiner_1.YargsDefiner(yargs, ImperativeConfig_1.ImperativeConfig.instance.loadedConfig.primaryTextColor, Imperative.rootCommandName, Imperative.commandLine, ImperativeConfig_1.ImperativeConfig.instance.envVariablePrefix, this.mHelpGeneratorFactory, ImperativeConfig_1.ImperativeConfig.instance.loadedConfig.experimentalCommandDescription, // Default value for PROMPT phrase couls be handled in the EnvironmentalVariableSettings class EnvironmentalVariableSettings_1.EnvironmentalVariableSettings.read(ImperativeConfig_1.ImperativeConfig.instance.envVariablePrefix).promptPhrase.value || Constants_1.Constants.DEFAULT_PROMPT_PHRASE // allow environmental variable to override the default prompt phrase ); for (const child of preparedHostCliCmdTree.children) { definer.define(child, (args, response) => { if (response.success) { if (response.exitCode == null) { response.exitCode = 0; } } else { if (response.exitCode == null) { response.exitCode = Constants_1.Constants.ERROR_EXIT_CODE; } } process.exitCode = response.exitCode; }, commandResponseParms); } Imperative.mFullCommandTree = preparedHostCliCmdTree; WebHelpManager_1.WebHelpManager.instance.fullCommandTree = Imperative.mFullCommandTree; } /** * Construct the API object for return to caller of init() * @return {ImperativeApi}: The API object */ static constructApiObject() { const apiParms = { imperativeLogger: this.constructImperativeLoggerApi(), appLogger: this.constructAppLoggerApi() }; let api = new ImperativeApi_1.ImperativeApi(apiParms, ImperativeConfig_1.ImperativeConfig.instance.loadedConfig, ImperativeConfig_1.ImperativeConfig.instance.cliHome); /** * Add dynamic API methods to API object */ api = this.constructDynamicLoggersApi(api); return api; } /** * Build the Logger API object for the app using the framework * @return {Logger}: returns the app Logger API object */ static constructAppLoggerApi() { return Logger_1.Logger.getAppLogger(); } /** * Build the imperative API object for the app using the framework * @return {Logger}: returns the imperative Logger API object */ static constructImperativeLoggerApi() { return Logger_1.Logger.getImperativeLogger(); } /** * Build the default console API object for the framework * @return {Logger}: returns the default console Logger API object */ static constructConsoleApi() { if (Imperative.mConsoleLog == null) { Imperative.mConsoleLog = Logger_1.Logger.getConsoleLogger(); return Imperative.mConsoleLog; } else { return Imperative.mConsoleLog; } } static constructDynamicLoggersApi(api) { const loadedConfig = ImperativeConfig_1.ImperativeConfig.instance.loadedConfig; if (loadedConfig.logging.additionalLogging != null && loadedConfig.logging.additionalLogging.length > 0) { for (const logConfig of loadedConfig.logging.additionalLogging) { api.addAdditionalLogger(logConfig.apiName, Logger_1.Logger.getLoggerCategory(logConfig.apiName)); } } return api; } /** * Get imperative's host CLI command tree with all module globs resolved. * * @return {ICommandDefinition} The resolved command tree */ static getResolvedCmdTree(config) { return DefinitionTreeResolver_1.DefinitionTreeResolver.resolve(config.rootCommandDescription || "", config.productDisplayName, (0, path_1.dirname)(ImperativeConfig_1.ImperativeConfig.instance.callerLocation), this.log, config.definitions, config.commandModuleGlobs, config.baseProfile != null); } /** * Get imperative's host CLI command tree after final preparation. * * @param resolvedCmdTree - The imperative command tree * returned by Imperative.getResolvedCmdTree() * @param {ICommandProfileTypeConfiguration} baseProfile - An optional base profile to add to command definitions */ static getPreparedCmdTree(resolvedCmdTree, baseProfile) { let preparedCmdTree = this.addAutoGeneratedCommands(resolvedCmdTree); preparedCmdTree = CommandPreparer_1.CommandPreparer.prepare(preparedCmdTree, baseProfile); return preparedCmdTree; } /** * Append any auto generated commands to the root command document depending on configuration. * @param {ICommandDefinition} rootCommand - the root command as built so far * @returns {ICommandDefinition} - the root command with any auto generated commands appended */ static addAutoGeneratedCommands(rootCommand) { const loadedConfig = ImperativeConfig_1.ImperativeConfig.instance.loadedConfig; if ((loadedConfig.autoGenerateProfileCommands == null || loadedConfig.autoGenerateProfileCommands) && loadedConfig.profiles != null && loadedConfig.profiles.length > 0) { // Add base profile to list of profile types if it is defined const allProfiles = loadedConfig.profiles; if (loadedConfig.baseProfile != null) { allProfiles.push(loadedConfig.baseProfile); } } const authConfigs = {}; if (loadedConfig.profiles != null) { loadedConfig.profiles.forEach((profile) => { if (profile.authConfig != null) { for (const requiredOption of ["host", "port", "user", "password", "tokenType", "tokenValue"]) { ImperativeExpect_1.ImperativeExpect.toNotBeNullOrUndefined(profile.schema.properties[requiredOption], `Profile of type ${profile.type} with authConfig property must have ${requiredOption} option defined`); } authConfigs[profile.type] = profile.authConfig; } }); } if (Object.keys(authConfigs).length > 0) { rootCommand.children.push(CompleteAuthGroupBuilder_1.CompleteAuthGroupBuilder.getAuthGroup(authConfigs, this.log, loadedConfig.authGroupConfig)); } if (loadedConfig.configAutoInitCommandConfig) { const autoInit = loadedConfig.configAutoInitCommandConfig; for (const child of rootCommand.children) { if (child.name === 'config') { child.children.push(CompleteAutoInitCommandBuilder_1.CompleteAutoInitCommandBuilder.getAutoInitCommand(autoInit, this.log)); } } } return rootCommand; } } exports.Imperative = Imperative; Imperative.DEFAULT_DEBUG_FILE = (0, path_1.join)(process.cwd(), "imperative_debug.log"); //# sourceMappingURL=Imperative.js.map