Class: Environment

Environment()

An Environment instance holds all metadata about the environment, such as whether it is experimental, available to the public, or if the environment includes both electron and recorder modules. You can use the Environment instance to add/remove modules, get the version lists for a module, and more.

Constructor

new Environment()

Source:

Methods

addModule(module) → {Environment}

Add a module and perform a type safety check to prevent corrupt additions.

Parameters:
Name Type Description
module
Source:
Returns:
Type
Environment

addUserId(userId) → {Environment}

Adds a user ID to the array of user IDs.

Parameters:
Name Type Description
userId string

The user ID to add.

Source:
Returns:

The current instance.

Type
Environment

getDescription() → {*}

Returns the description field, empty by default but modifiable via the build panel / build server API.

Source:
Returns:
Type
*

getLabel() → {string}

Return the human readable environment label.

Source:
Returns:
Type
string

getModules() → {Array.<string>}

Return the supported modules.

Source:
Returns:
Type
Array.<string>

getOrigin() → {string}

Return the origin branch hash (if any).

Source:
Returns:
Type
string

getParent() → {*}

Get the Environment value property for this environment's parent.

Source:
Returns:
Type
*

getTarget() → {string}

Return the target storage path (if any).

Source:
Returns:
Type
string

getUserIds() → {Array}

Returns the user IDs array.

Source:
Returns:

An array of user IDs.

Type
Array

getValue() → {string}

Return the environment value.

Source:
Returns:
Type
string

(async) getVersionList(module, url, fetchOpts) → {Promise.<VersionList>}

Return the VersionList from this environment for the specified app module.

Parameters:
Name Type Description
module
url
fetchOpts
Source:
Returns:
Type
Promise.<VersionList>

hasTarget() → {boolean}

Return true if the Environment has a target override to control the storage path.

Source:
Returns:
Type
boolean

includesModule(module) → {boolean}

Return true if the environment has a VersionList for the specified module.

This is used to determine if the app should download both electron and recorder updates for each environment. Some environments don't need a recorder branch, in which case it can default to sandbox in most cases.

Parameters:
Name Type Description
module
Source:
Returns:
Type
boolean

isExperimental() → {boolean}

Return true if the Environment is experimental. This is true for all feature-based dynamic environments & static sandboxes.

Source:
Returns:
Type
boolean

isPublic() → {boolean}

Return true if the Environment is publicly accessible.

Environments like sandbox, and any non-static branches should essentially never be public.

Source:
Returns:
Type
boolean

isStatic() → {boolean}

Return true if the Environment is static. A static environment is immutable -- it will never be deleted by webhooks and they are not deployed based on feature branches.

A non-static environment should be seen as ephemeral -- it will be deleted when the correlating PR is closed or merged.

Source:
Returns:
Type
boolean

isUserIdAllowed(userId) → {boolean}

Checks if a given user ID is allowed. Use loose comparison for string vs int id.

Parameters:
Name Type Description
userId string

The user ID to check.

Source:
Returns:

true if the user ID is allowed, false otherwise.

Type
boolean

removeModule(module) → {Environment}

Remove a module from the Environment.

Parameters:
Name Type Description
module
Source:
Returns:
Type
Environment

removeUserId(userId) → {Environment}

Removes a user ID from the array of user IDs.

Parameters:
Name Type Description
userId string

The user ID to remove.

Source:
Returns:

The current instance.

Type
Environment

setDescription(description) → {Environment}

Set the description for the environment.

Parameters:
Name Type Description
description
Source:
Returns:
Type
Environment

setExperimental(experimental) → {Environment}

Set an Environment's experimental state to on/off (true/false). If an environment is experimental, it will behave like a sandbox environment.

Parameters:
Name Type Description
experimental
Source:
Returns:
Type
Environment

setPublic(isPublic) → {Environment}

Set an Environment's public state. Cannot set a public environment to non-public.

Non-public builds should never be discoverable or distributed to end-users for stability and confidentiality purposes.

Parameters:
Name Type Description
isPublic
Source:
Returns:
Type
Environment

setStatic(isStatic) → {Environment}

Set an Environment's static state.

Static environments will never be removed or unpublished by CI/CD. They will only be continuously updated.

Non-static environments will be treated as dynamic/ephemeral, and clients should expect such behavior.

Parameters:
Name Type Description
isStatic
Source:
Returns:
Type
Environment

setUserIds(userIds) → {Environment}

Sets the array of user IDs.

Parameters:
Name Type Description
userIds Array

An array of user IDs.

Source:
Returns:

The current instance.

Type
Environment

toJson() → {Object}

Convert to a parsed JSON object.

Source:
Returns:
Type
Object