Options
All
  • Public
  • Public/Protected
  • All
Menu

The Config class provides facilities for reading and writing team configuration files. It is used by Imperative to perform low-level operations on a team configuration. The intent is that consumer apps will not typically use the Config class, since end-users are expected to write team configuration files by directly editing them in an editor like VSCode.

Hierarchy

  • Config

Index

Constructors

Private constructor

Properties

mActive

mActive: { global: boolean; user: boolean }

Currently active layer whose properties will be manipulated

internal

Type declaration

  • global: boolean
  • user: boolean

Private mApi

mApi: { layers: ConfigLayers; plugins: ConfigPlugins; profiles: ConfigProfiles; secure: ConfigSecure }

Cached version of Config APIs

Type declaration

mApp

mApp: string

App name used in config filenames (e.g., my_cli.config.json) It could be an absolute path, we recommend always using the getter method

internal

mHomeDir

mHomeDir: string

Directory where global config files are located. Defaults to ~/.appName.

internal

mLayers

mLayers: IConfigLayer[]

List to store each of the config layers enumerated in layers enum

internal

mProjectDir

mProjectDir: string | false

Directory where project config files are located. Defaults to working directory.

internal

mSecure

mSecure: IConfigSecure

Secure properties object stored in credential vault

internal

mVault

mVault: IConfigVault

Vault object with methods for loading and saving secure credentials

internal

Optional opts

Options to control how Config class behaves

Static Private Readonly END_OF_TEAM_CONFIG

END_OF_TEAM_CONFIG: ".config.json" = ".config.json"

The trailing portion of a shared config file name

Static Private Readonly END_OF_USER_CONFIG

END_OF_USER_CONFIG: ".config.user.json" = ".config.user.json"

The trailing portion of a user-specific config file name

Accessors

api

appName

  • get appName(): string

configName

  • get configName(): string

exists

  • get exists(): boolean

layers

mProperties

  • List of properties across all config layers. Returns the original object, not a clone, so use with caution. This is used in internal code because cloning a JSONC object is slow.

    internal

    Returns IConfig

maskedProperties

paths

  • get paths(): string[]

properties

schemaName

  • get schemaName(): string

userConfigName

  • get userConfigName(): string

Methods

delete

  • delete(propertyPath: string, opts?: { secure?: boolean }): void
  • Unset value of a property in the active config layer.

    Parameters

    • propertyPath: string

      Property path

    • Optional opts: { secure?: boolean }

      Include secure: false to preserve property in secure array

      • Optional secure?: boolean

    Returns void

findLayer

  • Find the layer with the specified user and global properties.

    internal

    Parameters

    • user: boolean

      True specifies that you want the user layer.

    • global: boolean

      True specifies that you want the layer at the global level.

    Returns IConfigLayer

    The desired layer object. Null if no layer matches.

formMainConfigPathNm

  • formMainConfigPathNm(options: any): string
  • Form the path name of the team config file to display in messages. Always return the team name (not the user name). If the a team configuration is active, return the full path to the config file.

    Parameters

    • options: any

      a map containing option properties. Currently, the only property supported is a boolean named addPath. {addPath: true | false}

    Returns string

    The path (if requested) and file name of the team config file.

getSchemaInfo

layerActive

layerExists

  • layerExists(inDir: string, user?: boolean): boolean

layerMerge

Private layerPath

  • layerPath(layer: Layers): string
  • Get absolute file path for a config layer. For project config files, We search up from our current directory and ignore the Zowe hone directory (in case our current directory is under Zowe home.). For global config files we only retrieve config files from the Zowe home directory.

    internal

    Parameters

    • layer: Layers

      Enum value for config layer

    Returns string

layerProfiles

reload

save

  • save(allLayers?: boolean): Promise<void>

set

  • set(propertyPath: string, value: any, opts?: { parseString?: boolean; secure?: boolean }): void
  • Set value of a property in the active config layer. TODO: more validation

    Parameters

    • propertyPath: string

      Property path

    • value: any

      Property value

    • Optional opts: { parseString?: boolean; secure?: boolean }

      Optional parameters to change behavior

      • parseString - If true, strings will be converted to a more specific
                    type like boolean or number when possible
        
      • secure - If true, the property will be stored securely.
               If false, the property will be stored in plain text.
        
      • Optional parseString?: boolean
      • Optional secure?: boolean

    Returns void

setSchema

  • setSchema(schema: string | object): void
  • Set the $schema value at the top of the config JSONC. Also save the schema to disk if an object is provided.

    Parameters

    • schema: string | object

      The URI of JSON schema, or a schema object to use

    Returns void

Static empty

Static load

  • Load config files from disk and secure properties from vault.

    throws

    An ImperativeError if the configuration does not load successfully

    Parameters

    • app: string

      App name used in config filenames (e.g., my_cli.config.json)

    • Optional opts: IConfigOpts

      Options to control how Config class behaves

    Returns Promise<Config>

Static search

  • search(file: string, opts?: { ignoreDirs?: string[]; startDir?: string }): string
  • Search up the directory tree for the directory containing the specified config file.

    Parameters

    • file: string

      Contains the name of the desired config file

    • Optional opts: { ignoreDirs?: string[]; startDir?: string }
      • Optional ignoreDirs?: string[]

        Contains an array of directory names to be ignored (skipped) during the search.

      • Optional startDir?: string

        Contains the name of the directory where the search should be started. Defaults to working directory.

    Returns string

    The full path name to config file or null if not found.

Generated using TypeDoc