mason library

A Dart template generator which helps teams generate files quickly and consistently.

Get started at https://github.com/felangel/mason 🧱

Classes

AnsiCode
Standard ANSI escape code for customizing terminal text output.
AnsiCodeType
The type of code represented by AnsiCode.
Brick
Metadata for a brick template including the name and location.
BrickEnvironment
An object representing the environment for a given brick.
BrickLocation
Contains metadata for the location of a reusable brick template.
BricksJson
A local cache for mason bricks.
BrickVariableProperties
An object representing a brick variable.
BrickYaml
Brick yaml file which contains metadata required to create a MasonGenerator from a brick template.
CachedBrick
A cached brick is an object which includes a resolved brick (strict location) and the local path of the brick.
DirectoryGeneratorTarget
A GeneratorTarget based on a provided Directory.
ExitCode
Exit code constants.
GeneratedFile
A file generated by a Generator which includes the file path and status.
GeneratorHooks
Scripts that run automatically whenever a particular event occurs in a Generator.
GeneratorTarget
A target for a Generator. This class knows how to create files given a path and contents.
GitPath
Path to templates in git.
HookContext
A reference to core mason APIs to be used within hooks.
Logger
A basic Logger which wraps stdio and applies various styles.
LogTheme
A theme object which contains styles for all log message types.
MasonBundle
A bundled version of a mason template.
MasonBundledFile
A bundled file which is included as part of a a MasonBundle.
MasonGenerator
A MasonGenerator which extends Generator and exposes the ability to create a Generator from a Brick.
MasonLockJson
Mason lock file which contains locked brick locations.
MasonYaml
Brick yaml file which contains metadata required to create a MasonGenerator from a brick template.
Progress
A class that can be used to display progress information to the user.
ProgressAnimation
An object which contains configuration for the animation of a Progress instance.
ProgressOptions
An object containing configuration for a Progress instance.
TemplateFile
This class represents a file in a generator template. The contents should be text and may contain mustache variables that can be substituted ({{myVar}}).
Version
A parsed semantic version number.
VersionConstraint
A VersionConstraint is a predicate that can determine whether a given version is valid or not.
VersionRange
Constrains versions to a fall within a given range.
Yaml
Yaml Utiilities

Extensions

RenderTemplate
Given a String with mustache templates, and a Map of String key / value pairs, substitute all instances of {{key}} for value.
StringCaseExtensions
Built-in String casing extensions.

Constants

backgroundBlack → const AnsiCode
Background black
backgroundBlue → const AnsiCode
Background blue
backgroundColors → const List<AnsiCode>
All of the AnsiCode values that represent AnsiCodeType.background.
backgroundCyan → const AnsiCode
Background cyan
backgroundDarkGray → const AnsiCode
Background dark gray
backgroundDefault → const AnsiCode
Background default
backgroundGreen → const AnsiCode
Background green
backgroundLightBlue → const AnsiCode
Background light blue
backgroundLightCyan → const AnsiCode
Background light cyan
backgroundLightGray → const AnsiCode
Background light gray
backgroundLightGreen → const AnsiCode
Background light green
backgroundLightMagenta → const AnsiCode
Background light magenta
backgroundLightRed → const AnsiCode
Background light red
backgroundLightYellow → const AnsiCode
Background light yellow
backgroundMagenta → const AnsiCode
Background magenta
backgroundRed → const AnsiCode
Background red
backgroundWhite → const AnsiCode
Background white
backgroundYellow → const AnsiCode
Background yellow
black → const AnsiCode
Foreground black
blue → const AnsiCode
Foreground blue
cyan → const AnsiCode
Foreground cyan
darkGray → const AnsiCode
Foreground dark gray
defaultForeground → const AnsiCode
Foreground default
foregroundColors → const List<AnsiCode>
All of the AnsiCode values that represent AnsiCodeType.foreground.
green → const AnsiCode
Foreground green
lightBlue → const AnsiCode
Foreground blue
lightCyan → const AnsiCode
Foreground cyan
lightGray → const AnsiCode
Foreground light gray
lightGreen → const AnsiCode
Foreground light green
lightMagenta → const AnsiCode
Foreground magenta
lightRed → const AnsiCode
Foreground light red
lightYellow → const AnsiCode
Foreground yellow
magenta → const AnsiCode
Foreground magenta
packageVersion → const String
red → const AnsiCode
Foreground red
resetAll → const AnsiCode
Reset values
Reset Blink
resetBold → const AnsiCode
Reset Bold NOTE: bold is weird. The reset code seems to be 22 sometimes – not 21 See https://gitlab.com/gnachman/iterm2/issues/3208
resetDim → const AnsiCode
Reset Dim
resetItalic → const AnsiCode
Reset Italic
resetReverse → const AnsiCode
Reset Reverse
resetUnderlined → const AnsiCode
Reset Underlined
blink
styleBold → const AnsiCode
bold
styleDim → const AnsiCode
dim
styleItalic → const AnsiCode
italic
styleReverse → const AnsiCode
reverse
styles → const List<AnsiCode>
All of the AnsiCode values that represent AnsiCodeType.style.
styleUnderlined → const AnsiCode
underlined
white → const AnsiCode
Foreground white
yellow → const AnsiCode
Foreground yellow

Properties

ansiOutputEnabled bool
Whether formatted ANSI output is enabled for AnsiCode.wrap.
no setter

Functions

canonicalize(String path) String
Canonicalizes path.
createBundle(Directory brick) MasonBundle
Generates a MasonBundle from the provided brick directory.
isBrickCompatibleWithMason(BrickYaml brickYaml) bool
Returns whether the current brickYaml is compatible with the current version of mason.
Wraps uri with an escape sequence so it's recognized as a hyperlink. An optional message can be used in place of the uri. If no message is provided, the text content will be the full uri.
overrideAnsiOutput<T>(bool enableAnsiOutput, T body()) → T
Allows overriding ansiOutputEnabled to enableAnsiOutput for the code run within body.
unpackBundle(MasonBundle bundle, Directory target) → void
Unpack the bundle in the target directory.

Enums

BrickVariableType
The type of brick variable.
FileConflictResolution
File conflict resolution strategies used during the generation process.
GeneratedFileStatus
The status of a generated file.
Level
Indicates the desired logging level.
OverwriteRule
The overwrite rule when generating code and a conflict occurs.

Typedefs

LogStyle = String? Function(String? message)
Type definition for a function which accepts a log message and returns a styled version of that message.

Exceptions / Errors

BrickNotFoundException
Thrown when a brick registered in the mason.yaml cannot be found locally.
MasonException
An exception thrown by an internal mason command.