talira

Create and reuse code templates (bricks) in Dart and Flutter projects

open sourceMITfree

Mason is a set of Dart packages and a command-line tool for creating and consuming reusable templates called bricks. A brick is a directory of mustache templates with a brick.yaml describing its variables (strings, numbers, booleans, enums, arrays and lists, with prompts and defaults); mason make generates files from it, resolving file conflicts by prompting, overwriting, skipping or appending, and bricks can run custom pre- and post-generation hook scripts. You add bricks from the BrickHub registry, a path or a git URL, search and publish them from the CLI, and use the mason package, the core generator behind the CLI, to build your own code generation tools. Its packages include mason_cli, mason, mason_api and mason_logger, the CLI's reusable logger with log levels, styles and prompts.

Problems it solves

  • generate the same boilerplate files for every new Flutter feature
  • share project templates across my team's Dart repositories
  • scaffold code from templates with variables in a Dart project

Features

  • bricks: mustache templates with typed variables and prompts in brick.yaml
  • pre- and post-generation hook scripts
  • file conflict resolution: prompt, overwrite, skip or append
  • add bricks from BrickHub, a local path or a git URL
  • search and publish bricks from the CLI
  • mason_logger: a reusable CLI logger with levels, styles and prompts

Limitations

  • A brick published to BrickHub can never be unpublished1
  • Hooks can only be written in Dart1