Options
All
  • Public
  • Public/Protected
  • All
Menu

Aggregate global and local project config files, as well as environment variables for sfdx-config.json. The resolution happens in the following bottom-up order:

  1. Environment variables (SFDX_LOG_LEVEL)
  2. Workspace settings (<workspace-root>/.sfdx/sfdx-config.json)
  3. Global settings ($HOME/.sfdx/sfdx-config.json)

Use ConfigAggregator.create to instantiate the aggregator.

example

const aggregator = await ConfigAggregator.create(); console.log(aggregator.getPropertyValue('defaultusername'));

hideconstructor

Hierarchy

  • AsyncOptionalCreatable<JsonMap>
    • ConfigAggregator

Index

Constructors

Private constructor

  • Do not directly construct instances of this class -- use {@link ConfigAggregator.resolve} instead.

    constructor

    Parameters

    • Optional options: JsonMap

    Returns ConfigAggregator

Methods

getConfig

  • getConfig(): object
  • Get the resolved config object from the local, global and environment config instances.

    Returns object

getConfigInfo

  • Get all resolved config property keys, values, locations, and paths.

    example

    console.log(aggregator.getConfigInfo()); [ { key: 'logLevel', val: 'INFO', location: 'Environment', path: '$SFDX_LOG_LEVEL'} { key: 'defaultusername', val: '', location: 'Local', path: './.sfdx/sfdx-config.json'} ]

    Returns ConfigInfo[]

getEnvVars

  • getEnvVars(): Map<string, string>
  • Get the config properties that are environment variables.

    Returns Map<string, string>

getGlobalConfig

  • Get the global config instance.

    Returns Config

getInfo

  • Get a resolved config property.

    Parameters

    • key: string

      The key of the property.

    Returns ConfigInfo

getLocalConfig

  • Get the local project config instance.

    Returns Config

getLocation

  • getLocation(key: string): Optional<LOCATIONS>
  • Gets a resolved config property location.

    For example, getLocation('logLevel') will return:

    1. LOCATIONS.GLOBAL if resolved to an environment variable.
    2. LOCATIONS.LOCAL if resolved to local project config.
    3. LOCATIONS.ENVIRONMENT if resolved to the global config.

    Parameters

    • key: string

      The key of the property.

    Returns Optional<LOCATIONS>

getPath

  • getPath(key: string): Optional<string>
  • Get a resolved file path or environment variable name of the property.

    For example, getPath('logLevel') will return:

    1. $SFDX_LOG_LEVEL if resolved to an environment variable.
    2. ./.sfdx/sfdx-config.json if resolved to the local config.
    3. ~/.sfdx/sfdx-config.json if resolved to the global config.
    4. undefined, if not resolved.

    Note: that the path returned may be the absolute path instead of relative paths such as ./ and ~/.

    Parameters

    • key: string

      The key of the property.

    Returns Optional<string>

getPropertyValue

  • getPropertyValue(key: string): string | boolean
  • Get a resolved config property.

    throws

    {SfdxError} {name: 'UnknownConfigKey'}: An attempt to get a property that's not supported.

    Parameters

    • key: string

      The key of the property.

    Returns string | boolean

init

  • init(): Promise<void>
  • Returns Promise<void>

reload

  • Re-read all property configurations from disk.

    Returns Promise<ConfigAggregator>

Static create

  • create<P, T>(this: object, options?: P): Promise<T>
  • Asynchronously constructs and initializes a new instance of a concrete subclass with the optional options.

    Type parameters

    • P

    • T: AsyncOptionalCreatable<P>

    Parameters

    • this: object
    • Optional options: P

      An options object providing initialization params to the async constructor.

    Returns Promise<T>