Mason Setup

Scaffold your Vyuh project quickly with Mason bricks

If you are part of an Enterprise Plan, you would have received access to the bricks repository that allows you to quickly setup a Vyuh project. This guide shows you how to setup Mason and scaffold your project.

Mason is a tool that uses a template and generates the files needed for your projects. By using simple parameters such as a name, title and other details of your project, mason can scaffold the initial project structure quickly.

This is possible with bricks. A brick is a template that can be expanded by Mason to generate the final file or project structure. Let's setup mason and configure it to use the bricks from Vyuh.

1. Add Mason

The first step is to activate the mason_cli package globally. This gives you access to the mason command that can be used to generate the initial structure. Run this command in your terminal:

dart pub global activate mason_cli

In the folder where you plan to build your mono-repo project for the Vyuh Application, run the following:

mason init

The above command should have created a mason.yaml file in that folder.

Replace the contents of mason.yaml with below:

# Register bricks which can be consumed via the Mason CLI.
# Run "mason get" to install all registered bricks.
# To learn more, visit https://docs.brickhub.dev.
bricks:
  vyuh_init:
    git:
      url: https://github.com/vyuh-tech/bricks
      path: vyuh_init
  vyuh_feature:
    git:
      url: https://github.com/vyuh-tech/bricks
      path: vyuh_feature
  vyuh_feature_sanity_schema:
    git:
      url: https://github.com/vyuh-tech/bricks
      path: vyuh_feature_sanity_schema

Next, in the same folder, run the following command to fetch all the bricks:

mason get

3. Create your project with Mason

It is finally time to scaffold our project. We can use the vyuh_init brick and create the project:

mason make vyuh_init

This will generate the complete project structure that is essential to build the Vyuh App. For more details about what this project structure looks like, refer to the guide on Typical Project Structure.

Explore other bricks

In addition to the vyuh_init brick, there are also bricks for:

  • vyuh_feature: scaffolds a single Vyuh feature package in Flutter

  • vyuh_feature_sanity_schema: scaffolds a single schema package in TypeScript for working with the Sanity CMS.

The process to use them is similar to the one used before. For example, to scaffold a new Feature package, you can run the following command:

mason make vyuh_feature

Custom output folder

By default Mason generates the files in the folder where you run the command. To create it inside a specific folder, you could pass in the -o flag with the relative directory. This is particularly useful when generating features.

For example, to generate the feature package inside the ./features folder of your root project directory, you would run the following:

mason make vyuh_feature -o features

Summary

This guide showed you the steps to setup mason on your system and use it to generate various parts of the Vyuh Application. Currently, there is support for creating a new Vyuh App, a Vyuh Feature package for Flutter and a Vyuh schema package for Sanity CMS.

There will be more added in the future to accommodate other aspects of developing Vyuh Apps.

Last updated

Logo

Copyright Šī¸ 2024, Vyuh Technologies Pvt. Ltd.