@build-tracker/build
Install
Build
Construct a new build by passing it both the build's BuildMeta
and array of Artifact
s:
Useful Methods
The following is a short selection of useful methods provided by the Build
class.
Build.toJson()
Returns a JSON representation of the Build.
get Build.meta(): BuildMeta
Get a JSON representation of the full metadata of a Build.
get Build.timestamp(): Date
Get a Date
representation of the timestamp from the BuildMeta
getMetaValue(key: string): string
Get the string value of a build meta entry.
getMetaUrl(key: string): string | undefined
Get the URL value of a build meta entry. If one was not provided, this will return undefined
.
getSum(artifactNames: Array<string>): ArtifactSizes
Returns an object listing the total sum of the sizes for every key available in ArtifactSizes
per the requested array of artifact names.
Example
Get the sum of a specific list of artifacts:
getTotals(artifactFilters?: Array<RegExp>): ArtifactSizes
Returns an object listing the total sum of the sizes for every key available in ArtifactSizes
for all artifacts in a Build.
If the first argument is provided, any artifact name that matches one of the regular expressions in the array will not be included in the sum total.
Filter Example
To filter out any artifact that matches i18n/.*
except for the i18n/en
artifact:
Types
BuildMeta
Build meta includes useful information for identifying the build in your system. This information is visible in the web application's interface.
BuildMetaItem: string | { value: string; url: string }
Any build meta item (other than timestamp
) can either be a string value
or an object containing a string value
and a string url
.
If a url
is included, the web application will link the value
to the url
.
Artifact
Every build artifact consists of a name
, unique hash
of the file for each build, and an object of keyed sizes
.
ArtifactSizes
Artifacts can have any number of keyed sizes. The defaults provided by the cli are stat
, gzip
, and brotli
.