lib/models/instrumentation.js:38
Instrumentation
An instance of this class is used for invoking the instrumentation hooks on addons.
The instrumentation types currently supported are:
- init
- build
- command
- shutdown
Method Summary
Public Methods | |
---|---|
public |
Check if npm and bower installation directories are present, and raise an error message with instructions on how to proceed. |
public |
findLCAHost(engineInstance): EngineAddon | EmberApp
This returns the LCA host for a given engine; we use the associated package info to compute this (see |
public |
getHostAddonInfo(packageInfoForLazyEngine): hostPackageInfo: PackageInfo, hostAndAncestorBundledPackageInfos: Set
This function intends to return a common host for a bundle host (lazy engine). The root package info should be the starting point (i.e., the project's package info). We do this by performing a breadth-first traversal until we find the intended lazy engine (represented as a package-info & the 1st argument passed to this function). As part of the traversal, we keep track of all paths to said engine; then, once we find the intended engine we use this to determine the nearest common host amongst all shortest paths. |
public |
instantiateAddons(parent, project, a)
Create instances of a set of "child" addons for a parent addon or project. |
Private Methods | |
---|---|
private |
_findNearestBundleHost(paths): PackageInfo, PackageInfo[]
Given a path (calculated as part of |
private |
_getBundledPackageInfos(pkgInfoToStartAt): Set
Returns a |
Public Methods
lib/models/installation-checker.js:13
public checkInstallations( )
Check if npm and bower installation directories are present, and raise an error message with instructions on how to proceed.
If some of these package managers aren't being used in the project we just ignore them. Their usage is considered by checking the presence of your manifest files: package.json for npm and bower.json for bower.
lib/models/host-info-cache.js:272
public findLCAHost(engineInstance): EngineAddon | EmberApp
This returns the LCA host for a given engine; we use the associated package info
to compute this (see getHostAddonInfo
above); this finds the lowest common ancestor
that is considered a host amongst all engines by the same name in the project. This
function is intended to replace the original behavior in ember-engines
.
For more info, see the original implementation here:
Parameters:
Name | Type | Attribute | Description |
---|---|---|---|
engineInstance | EngineAddon |
|
Return:
lib/models/host-info-cache.js:147
public
getHostAddonInfo(packageInfoForLazyEngine): hostPackageInfo: PackageInfo, hostAndAncestorBundledPackageInfos: Set
This function intends to return a common host for a bundle host (lazy engine). The root package info should be the starting point (i.e., the project's package info). We do this by performing a breadth-first traversal until we find the intended lazy engine (represented as a package-info & the 1st argument passed to this function). As part of the traversal, we keep track of all paths to said engine; then, once we find the intended engine we use this to determine the nearest common host amongst all shortest paths.
Some context:
For a given engine/bundle host, this finds the lowest common ancestor that is considered a host amongst all engines by the same name in the project.
For example, given the following package structure:
--Project--
/ \
/ \
Lazy Engine A
Addon A
|
|
Lazy Engine B
/
/
Lazy Engine A Lazy Engine C
- The LCA host for Lazy Engine A is the project
- The LCA host for Lazy Engine B is the project
- The LCA host for Lazy Engine C is Lazy Engine B
This also returns hostAndAncestorBundledPackageInfos
, which are all bundled addons above a given host:
hostAndAncestorBundledPackageInfos
for lazy engine A includes all non-lazy dependencies of its LCA host & above (in this case, just the project)hostAndAncestorBundledPackageInfos
for lazy engine B includes all non-lazy dependencies of its LCA host & above (in this case, just the project)hostAndAncestorBundledPackageInfos
for lazy engine C includes non-lazy deps of lazy engine B & non-lazy deps of the project (LCA host & above)
This is intended to mimic the behavior of ancestorHostAddons
in ember-engines
:
https://github.com/ember-engines/ember-engines/blob/master/packages/ember-engines/lib/engine-addon.js#L333
Unfortunately, we can't easily repurpose the logic in ember-engines
since the algorithm has to be different;
in ember-engines
we need access to the actual addon instance, however, this is intended to be used during
addon instantiation, so we only have access to package-info objects. In having said this, we can repurpose
the hostPackageInfo
to determine the LCA host; see below findLCAHost
.
Parameters:
Name | Type | Attribute | Description |
---|---|---|---|
packageInfoForLazyEngine | PackageInfo |
|
Return:
}
lib/models/instantiate-addons.js:12
public instantiateAddons(parent, project, a)
Create instances of a set of "child" addons for a parent addon or project.
Parameters:
Name | Type | Attribute | Description |
---|---|---|---|
parent | Object |
|
an Addon or Project that is the direct containing object of the list of children defined in addonPackages. |
project | Project |
|
the project that contains the parent (so either the addon's project if parent is an addon, or the project itself if it is a project). It is possible when constructing custom addon instances that the project will actually be undefined--various addon tests do this, for example. |
a | Object |
|
map of addon name (including scope) to an AddonInfo with the name, path and 'pkg' object for that addon's package.json). These are what is turned into addons. |
Private Methods
lib/models/host-info-cache.js:16
private _findNearestBundleHost(paths): PackageInfo, PackageInfo[]
Given a path (calculated as part of getHostAddonInfo
), return the correct
"bundle host". A bundle host is considered the project or lazy engine.
For example, given the following package structure:
--Project--
/ \
/ \
Lazy Engine A
Addon A
|
|
Lazy Engine B
/
/
Lazy Engine A Lazy Engine C
The provided paths for lazy engine A would look like:
- [Project]
- [Project, Addon A, Lazy Engine B]
For this project structure, this function would return [Project, [Project]]
Similarly, given the following project structure:
--Project--
/ \
/ \
Lazy Engine A \
/ Lazy Engine B
/ |
/ |
Lazy Engine C Lazy Engine C
The provided paths for lazy engine C would look like:
- [Project, Lazy Engine A]
- [Project, Lazy Engine B]
In this case, the host is the project and would also return [Project, [Project]]
Parameters:
Name | Type | Attribute | Description |
---|---|---|---|
paths | Array |
|
The found paths to a given bundle host |
Return:
lib/models/host-info-cache.js:93
private
_getBundledPackageInfos(pkgInfoToStartAt): Set
Returns a Set
of package-info objects that a given bundle host is
directly responsible for bundling (i.e., it excludes other bundle
hosts/lazy engines when it encounters these)
Parameters:
Name | Type | Attribute | Description |
---|---|---|---|
pkgInfoToStartAt | PackageInfo |
|