Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PluginManagementFacility

This class is the main engine for the Plugin Management Facility. The underlying class should be treated as a singleton and should be accessed via PluginManagmentFacility.instance.

Hierarchy

  • PluginManagementFacility

Index

Properties

Private Readonly impConfigPropNm

impConfigPropNm: "imperative" = "imperative"

The property name within package.json that holds the Imperative configuration object.

Private impLogger

impLogger: Logger = Logger.getImperativeLogger()

Used for internal imperative logging.

Private mAllPluginCfgProps

mAllPluginCfgProps: IPluginCfgProps[] = []

Internal reference to the set of configuration properties for all loaded plugins.

Private mPluginOverrides

mPluginOverrides: IImperativeOverrides

Internal reference to the overrides provided by plugins.

Private Readonly noPeerDependency

noPeerDependency: "-1" = "-1"

Private Readonly npmPkgNmProp

npmPkgNmProp: "name" = "name"

A set of bright dependencies used by plugins. Each item in the set contains the dependency's property name, and the the version of that dependency.

Private pluginIssues

pluginIssues: PluginIssues = PluginIssues.instance

A class with recorded issues for each plugin for which problems were detected.

Private pluginNmForUseInCallback

pluginNmForUseInCallback: string = "NoPluginNameAssigned"

The name of the plugin currently being processed. This is required by callback function requirePluginModuleCallback, whose signature is fixed, and cannot have the plugin name passed in.

Private pmfConst

pmfConst: PMFConstants = PMFConstants.instance

Used as a short-name access to PMF constants.

Private resolvedCliCmdTree

resolvedCliCmdTree: ICommandDefinition = null

The CLI command tree with module globs already resolved.

Private Readonly semver

semver: any = require("semver")

The semantic versioning module (which does not have the typing to do an 'import').

Private wasInitCalled

wasInitCalled: boolean = false

Tracker to ensure that [init]{@link PluginManagementFacility#init} was called. Most methods cannot be used unless init was called first.

Static Private mInstance

This is the variable that stores the specific instance of the PMF. Defined as static so that it can be accessed from anywhere.

Accessors

allPluginCfgProps

pluginOverrides

Static instance

Methods

addAllPluginsToHostCli

Private addCmdGrpToResolvedCliCmdTree

  • addCmdGrpToResolvedCliCmdTree(pluginName: string, cmdDefToAdd: ICommandDefinition): boolean
  • Add a new command group into the host CLI's resolved command tree. We had to wait until the host CLI was resolved, so that we could check for name conflicts. So each plugin's commands are added to the host CLI command tree after both have been resolved.

    Parameters

    • pluginName: string

      the name of the plugin to initialize

    • cmdDefToAdd: ICommandDefinition

      command definition group to to be added.

    Returns boolean

    True upon success. False upon error, and errors are recorded in pluginIssues.

Private addPluginToHostCli

Private comparePluginVersionToCli

  • comparePluginVersionToCli(pluginName: string, pluginVerPropNm: string, pluginVerVal: string, cliVerPropNm: string, cliVerVal: string): void
  • Compare the version of a plugin version property with a version property of its base CLI.

    If the versions do not intersect (according so semver rules), then a PluginIssue is recorded.

    Parameters

    • pluginName: string

      The name of the plugin.

    • pluginVerPropNm: string

      The name of the plugin property containing a version.

    • pluginVerVal: string

      value of the plugin's version.

    • cliVerPropNm: string

      The name of the base CLI property containing a version.

    • cliVerVal: string

      value of the base CLI's version.

    Returns void

Private conflictingNameOrAlias

  • Does the supplied pluginGroupNm match an existing top-level name or alias in the imperative command tree? If a conflict occurs, plugIssues.doesPluginHaveError() will return true.

    Parameters

    • pluginName: string

      The name of the plugin that we are checking.

    • pluginGroupDefinition: ICommandDefinition

      A plugin's command group definition..

    • cmdTreeDef: ICommandDefinition

      A top-level command tree definition against which we compare the supplied pluginGroupNm. It is typically the imperative command tree.

    Returns { hasConflict: boolean; message: string }

    • {hasConflict, message} - hasConflict: True when we found a conflict.
                               False when find no conflicts.
                               message: the message describing the conflict
      
    • hasConflict: boolean
    • message: string

Private formPluginRuntimePath

  • formPluginRuntimePath(pluginName: string, relativePath?: string): string
  • Form the absolute path to a runtime file for a plugin from a path name that is relative to the plugin's root directory (where its package.json lives).

    Parameters

    • pluginName: string

      The name of the plugin.

    • Default value relativePath: string = ""

      A relative path from plugin's root. Typically supplied as ./lib/blah/blah/blah. If not supplied, (or supplied as an an empty string, the result will be a path to /. If an absolute path is supplied, it is returned exactly as supplied.

    Returns string

    • The absolute path to the file.

Private getCliPkgName

  • getCliPkgName(): string

init

  • init(): void

loadAllPluginCfgProps

  • loadAllPluginCfgProps(): void
  • Loads the configuration properties of each plugin. The configuration information is used when overriding a piece of the imperative infrastructure with a plugin's capability, when validating each plugin, and when adding each plugin's commands to the CLI command tree. Errors are recorded in PluginIssues.

    Returns void

Private loadPluginCfgProps

Private removeCmdGrpFromResolvedCliCmdTree

requirePluginModuleCallback

  • requirePluginModuleCallback(relativePath: string): any
  • Require a module from a plugin using a relative path name to the module. Used as a callback function from the ConfigurationLoader to load configuration handlers.

    Parameters

    • relativePath: string

      A relative path from plugin's root. Typically supplied as ./lib/blah/blah/blah.

    Returns any

    • The content exported from the specified module.

Private validatePeerDepVersions

  • Validates that the semver range strings specified by the plugin for versions of the imperative framework and host CLI program are compatible with those specified in the host CLI.

    Both range strings come from the package.json files of the plugin and the hosting CLI. We consider the version ranges to be compatible if the two ranges intersect. This should allow npm to download one common version of core and of imperative to be owned by the base CLI and shared by the plugin.

    Any errors are recorded in PluginIssues.

    Parameters

    • pluginCfgProps: IPluginCfgProps

      The configuration properties for this plugin

    Returns void

Private validatePlugin

Private validatePluginCmdDefs

  • validatePluginCmdDefs(pluginName: string, pluginCmdDefs: ICommandDefinition[], cmdTreeDepth?: number): void
  • Validate a plugin's array of command definitions at the specified depth within the plugin's command definition tree. This is a recursive function used to navigate down through the command tree, validating as we go. If errors occur, they are recorded in PlugIssues.

    Parameters

    • pluginName: string

      The name of the plugin.

    • pluginCmdDefs: ICommandDefinition[]

      Array of plugin commands.

    • Default value cmdTreeDepth: number = 1

      The depth within the plugin command tree at which we are validating. It is used within error messages.

    Returns void

Private validatePluginProfiles

Generated using TypeDoc