TargetProvider

Buildpack/BuildBus

Buildpack/BuildBus~TargetProvider ⇐ Trackable

Handles interactions between a BuildBus and an “extension” package participating in the BuildBus declare/intercept lifecycle.

The targets object used by declare and intercept functions is a TargetProvider. Each extension receives its own TargetProvider, which provides methods for declaring its own targets, intercepting its own targets, and intercepting the targets of other extensions.

Kind: inner class of Buildpack/BuildBus
Extends: Trackable

new TargetProvider(bus, dep, getExternalTargets)

Creates an instance of TargetProvider.

Param Type Description
bus BuildBus | function BuildBus using this TargetProvider, or, when testing, a logging function.
dep Object The package which owns this TargetProvider.
dep.name string Name of the package which owns this.
getExternalTargets getExternalTargets Function this TargetProvider will use to retrieve external packages when they are requested with .of(). Should usually be a delegate to BuildBus’s getExternalTargets()

targetProvider.name : string

Kind: instance property of TargetProvider

targetProvider.own : Object.<string, Target>

The targets this package has declared in the declare phase.

Kind: instance property of TargetProvider

targetProvider.phase : string

The phase currently being executed. Either declare or intercept.

Kind: instance property of TargetProvider

targetProvider.declare(declarations)

Call this function in the declare phase to register targets that this package and other packages can intercept.

Kind: instance method of TargetProvider

Param Type Description
declarations Object.<string, Target> An object whose keys are the names of targets to declare, and whose properties are newly constructed Targets.

targetProvider.of(depName) ⇒ Object.<string, Target>

Call this function in the intercept phase to get the targets of other packages, which can then be intercepted by calling .tap() methods on them.

Kind: instance method of TargetProvider
Returns: Object.<string, Target> - - An object whose keys are the names of the requested package’s targets, and whose values are the target objects.

Param Type Description
depName string The package whose targets you want to retrieve.

TargetProvider~toJSON()

Kind: inner method of TargetProvider

Buildpack/BuildBus~getExternalTargets ⇒ TargetProvider

Respond to a request from a TargetProvider to retrieve a different(external) TargetProvider.

This callback pattern helps to loosely couple TargetProviders so they are more testable.

Kind: inner typedef of Buildpack/BuildBus
Returns: TargetProvider - TargetProvider for the requested targets.

Param Type Description
requestor TargetProvider TargetProvider making the request.
requested string External targets being requested.

For implementation details View Source.