Targets
This service is in charge of loading and managing the project targets information.
Constructor Summary
Public Constructor | ||
public |
constructor(dotEnvUtils: DotEnvUtils, events: Events, environmentUtils: EnvironmentUtils, packageInfo: Object, pathUtils: PathUtils, projectConfiguration: ProjectConfigurationSettings, rootRequire: RootRequire, utils: Utils) |
Member Summary
Public Members | ||
public |
The default type a target will be if it doesn't have a |
|
public |
A local reference for the |
|
public |
A local reference for the |
|
public |
A local reference for the |
|
public |
The information of the project's |
|
public |
A local reference for the |
|
public |
All the project settings. |
|
public |
A local reference for the |
|
public |
A dictionary that will be filled with the targets information. |
|
public |
A simple regular expression to validate a target type. |
|
public |
A local reference for the |
Method Summary
Public Methods | ||
public |
findTargetForFile(file: string): Target Find a target by a given filepath. |
|
public |
getBrowserTargetConfiguration(target: Target): Object Gets an 'App Configuration' for a browser target. |
|
public |
getDefaultTarget(type: string): Target Returns the target with the name of project (specified on the |
|
public |
getFilesToCopy(target: Target, buildType: string): Array Gets a list with the information for the files the target needs to copy during the bundling process. |
|
public |
Get a target information by its name. |
|
public |
getTargets(): Object Get all the registered targets information on a dictionary that uses their names as keys. |
|
public |
loadTargetDotEnvFile(target: Target, buildType: string, inject: boolean): Object Loads the environment file(s) for a target and, if specified, inject their variables. |
|
public |
Loads and build the target information. |
|
public |
targetExists(name: string): boolean Validate whether a target exists or not. |
Public Constructors
public constructor(dotEnvUtils: DotEnvUtils, events: Events, environmentUtils: EnvironmentUtils, packageInfo: Object, pathUtils: PathUtils, projectConfiguration: ProjectConfigurationSettings, rootRequire: RootRequire, utils: Utils) source
Params:
Name | Type | Attribute | Description |
dotEnvUtils | DotEnvUtils | To read files with environment variables for the targets and inject them. |
|
events | Events | Used to reduce a target information after loading it. |
|
environmentUtils | EnvironmentUtils | To send to the configuration service used by the browser targets. |
|
packageInfo | Object | The project's |
|
pathUtils | PathUtils | Used to build the targets paths. |
|
projectConfiguration | ProjectConfigurationSettings | To read the targets and their templates. |
|
rootRequire | RootRequire | To send to the configuration service used by the browser targets. |
|
utils | Utils | To replace plaholders on the targets paths. |
Public Members
public defaultType: string source
The default type a target will be if it doesn't have a type
property.
public environmentUtils: EnvironmentUtils source
A local reference for the environmentUtils
service.
Public Methods
public findTargetForFile(file: string): Target source
Find a target by a given filepath.
Params:
Name | Type | Attribute | Description |
file | string | The path of the file that should match with a target path. |
Throw:
If no target is found. |
public getBrowserTargetConfiguration(target: Target): Object source
Gets an 'App Configuration' for a browser target. This is a utility projext provides for browser targets as they can't load configuration files dynamically, so on the building process, projext uses this service to load the configuration and then injects it on the target bundle.
Params:
Name | Type | Attribute | Description |
target | Target | The target information. |
Return:
Object |
Throw:
If the given target is not a browser target. |
public getDefaultTarget(type: string): Target source
Returns the target with the name of project (specified on the package.json
) and if there's
no target with that name, then the first one, using a list of the targets name on alphabetical
order.
Params:
Name | Type | Attribute | Description |
type | string |
|
A specific target type, |
public getFilesToCopy(target: Target, buildType: string): Array source
Gets a list with the information for the files the target needs to copy during the
bundling process.
This method uses the target-copy-files
reducer event, which receives the list of files to
copy, the target information and the build type; it expects an updated list on return.
The reducer event can be used to inject a TargetExtraFileTransform function.
public getTarget(name: string): Target source
Get a target information by its name.
Params:
Name | Type | Attribute | Description |
name | string | The target name. |
Throw:
If there's no target with the given name. |
public getTargets(): Object source
Get all the registered targets information on a dictionary that uses their names as keys.
public loadTargetDotEnvFile(target: Target, buildType: string, inject: boolean): Object source
Loads the environment file(s) for a target and, if specified, inject their variables.
This method uses the target-environment-variables
reducer event, which receives the
dictionary with the variables for the target, the target information and the build type; it
expects an updated dictionary of variables in return.
Params:
Name | Type | Attribute | Description |
target | Target | The target information. |
|
buildType | string |
|
The type of bundle projext is generating or the environment a Node target is being executed for. |
inject | boolean |
|
Whether or not to inject the variables after loading them. |
public loadTargets() source
Loads and build the target information.
This method emits the reducer event target-load
with the information of a loaded target and
expects an object with a target information on return.