Class that stores information about a single package (directory tree with a package.json and other data, like and Addon or Project.) It is one of the two types of entries in a PackageInfoCache. It is only created by the PackageInfoCache.

Method Summary

Public Methods
public
addPackages(addonPackageList, packageInfoList, excludeFn)

Add to a list of child addon PackageInfos for this packageInfo.

public

Discover the child addons for this packageInfo, which corresponds to an Addon.

public

Discover the child addons for this packageInfo, which corresponds to a Project.

public
generateAddonPackages(addonPackageList, excludeFn)

Given a list of PackageInfo objects, generate the 'addonPackages' object (keyed by name, value = AddonInfo instance, for all packages marked 'valid'). This is stored in both Addon and Project instances.

public
getAddonConstructor( ): AddonConstructor

This is only supposed to be called by the addon instantiation code. Also, the assumption here is that this PackageInfo really is for an Addon, so we don't need to check each time.

public
hasErrors(true)

Indicate if there are any errors in the ErrorList for this package. Note that this does NOT indicate if there are any errors in the objects referred to by this package (e.g., internal addons or dependencies).

Protected Methods
protected
addDependencies(dependencies): Object

For each dependency in the given list, find the corresponding PackageInfo object in the cache (going up the file tree if necessary, as in the node resolution algorithm). Return a map of the dependencyName to PackageInfo object. Caller can then store it wherever they like.

protected
addError(errorType, errorData)

Given error data, add an ErrorEntry to the ErrorList for this object. This is used by the _readPackage and _readNodeModulesList methods. It should not be called otherwise.

protected
addInRepoAddon(inRepoAddonPkg):

Add a reference to an in-repo addon PackageInfo object.

protected
addInternalAddon(internalAddonPkg):

Add a reference to an internal addon PackageInfo object. "internal" addons (note: not in-repo addons) only exist in Projects, not other packages. Since the cache is loaded from 'loadProject', this can be done appropriately.

Public Methods

lib/models/package-info-cache/package-info.js:228

public addPackages(addonPackageList, packageInfoList, excludeFn)

Add to a list of child addon PackageInfos for this packageInfo.

Parameters:

Name Type Attribute Description
addonPackageList Array

the list of child addon PackageInfos being constructed from various sources in this packageInfo.

packageInfoList Array | Object

a list or map of PackageInfos being considered (e.g., pkgInfo.dependencyPackages) for inclusion in the addonPackageList.

excludeFn Function

an optional function. If passed in, each child PackageInfo will be tested against the function and only included in the package map if the function returns a truthy value.

Discover the child addons for this packageInfo, which corresponds to an Addon.

lib/models/package-info-cache/package-info.js:282

public discoverProjectAddons( )

Discover the child addons for this packageInfo, which corresponds to a Project.

lib/models/package-info-cache/package-info.js:302

public generateAddonPackages(addonPackageList, excludeFn)

Given a list of PackageInfo objects, generate the 'addonPackages' object (keyed by name, value = AddonInfo instance, for all packages marked 'valid'). This is stored in both Addon and Project instances.

Parameters:

Name Type Attribute Description
addonPackageList Array

the list of child addon PackageInfos to work from

excludeFn Function

an optional function. If passed in, each child PackageInfo will be tested against the function and only included in the package map if the function returns a truthy value.

lib/models/package-info-cache/package-info.js:363

public getAddonConstructor( ): AddonConstructor

This is only supposed to be called by the addon instantiation code. Also, the assumption here is that this PackageInfo really is for an Addon, so we don't need to check each time.

Return:

AddonConstructor

an instance of a constructor function for the Addon class whose package information is stored in this object.

Indicate if there are any errors in the ErrorList for this package. Note that this does NOT indicate if there are any errors in the objects referred to by this package (e.g., internal addons or dependencies).

Parameters:

Name Type Attribute Description
true Boolean

if there are errors in the ErrorList, else false.

Protected Methods

lib/models/package-info-cache/package-info.js:154

protected addDependencies(dependencies): Object

For each dependency in the given list, find the corresponding PackageInfo object in the cache (going up the file tree if necessary, as in the node resolution algorithm). Return a map of the dependencyName to PackageInfo object. Caller can then store it wherever they like.

Note: this is not to be called until all packages that can be have been added to the cache.

Note: this is for ALL dependencies, not just addons. To get just addons, filter the result by calling pkgInfo.isAddon().

Note: this is only intended for use from PackageInfoCache._resolveDependencies. It is not to be called directly by anything else.

Parameters:

Name Type Attribute Description
dependencies PackageInfo

value of 'dependencies' or 'devDependencies' attributes of a package.json.

Return:

Object

a JavaScript object keyed on dependency name/path with values the corresponding PackageInfo object from the cache.

lib/models/package-info-cache/package-info.js:93

protected addError(errorType, errorData)

Given error data, add an ErrorEntry to the ErrorList for this object. This is used by the _readPackage and _readNodeModulesList methods. It should not be called otherwise.

Parameters:

Name Type Attribute Description
errorType String

one of the Errors.ERROR_* constants.

errorData Object

any error data relevant to the type of error being created. See showErrors().

lib/models/package-info-cache/package-info.js:121

protected addInRepoAddon(inRepoAddonPkg):

Add a reference to an in-repo addon PackageInfo object.

Parameters:

Name Type Attribute Description
inRepoAddonPkg PackageInfo

the PackageInfo for the in-repo addon

Return:

null

lib/models/package-info-cache/package-info.js:136

protected addInternalAddon(internalAddonPkg):

Add a reference to an internal addon PackageInfo object. "internal" addons (note: not in-repo addons) only exist in Projects, not other packages. Since the cache is loaded from 'loadProject', this can be done appropriately.

Parameters:

Name Type Attribute Description
internalAddonPkg PackageInfo

the PackageInfo for the internal addon

Return:

null