Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grumpy_bricks

Hook-driven Mason bricks and shared generation logic for Grumpy projects.

Available Bricks

  • unit
  • module
  • service
  • datasource
  • guard
  • middleware
  • screen
  • component
  • repository
  • model

Installation

Install Mason CLI if needed:

dart pub global activate mason_cli

To use the bricks from this repository, create a mason.yaml with the following contents:

bricks:
  unit:
    git:
      url: https://github.com/necodeIT/grumpy_bricks
      path: bricks/grumpy_unit
  module:
    git:
      url: https://github.com/necodeIT/grumpy_bricks
      path: bricks/grumpy_module
  service:
    git:
      url: https://github.com/necodeIT/grumpy_bricks
      path: bricks/grumpy_service
  datasource:
    git:
      url: https://github.com/necodeIT/grumpy_bricks
      path: bricks/grumpy_datasource
  guard:
    git:
      url: https://github.com/necodeIT/grumpy_bricks
      path: bricks/grumpy_guard
  middleware:
    git:
      url: https://github.com/necodeIT/grumpy_bricks
      path: bricks/grumpy_middleware
  screen:
    git:
      url: https://github.com/necodeIT/grumpy_bricks
      path: bricks/grumpy_screen
  component:
    git:
      url: https://github.com/necodeIT/grumpy_bricks
      path: bricks/grumpy_component
  repository:
    git:
      url: https://github.com/necodeIT/grumpy_bricks
      path: bricks/grumpy_repository
  model:
    git:
      url: https://github.com/necodeIT/grumpy_bricks
      path: bricks/grumpy_model

Then fetch the bricks:

mason get

Each brick is pulled from the GitHub repository and resolved from its directory within the repo.

Usage

Generate a brick by name and pass the required name variable:

mason make screen --name login

All bricks use the shared Grumpy generation hooks included in this repository.

grumpy.yaml

Generation defaults can be applied globally, per unit kind, and per subtype.

defaults:
  all:
    imports:
      - import 'package:collection/collection.dart';
    mixins: []

  model:
    imports: []
    mixins: []
    extends_model: true
    fields: {}

  component:
    imports: []
    mixins: []

  query_component:
    imports: []
    mixins:
      - StatefulQueryLoader
      - StatefulQueryError
    query_result_type: auto

  repository:
    imports: []
    mixins: []
    repo_mixins: []

discovery:
  prefer_project_types: true
  infer_config_type: true
  infer_query_component_repo: true
  infer_query_component_result_type: true
  infer_repository_query_item_type: true
  prefer_existing_directories: true

Notes:

  • defaults.all applies to every generated file.
  • defaults.<unit> applies to the full unit kind such as model or repository.
  • defaults.<subtype> applies to subtypes such as query_component.
  • imports and mixins are merged in this order: built-in defaults, all, unit, subtype, explicit vars.
  • Models default to fields: {} and no implicit id field is generated.
  • The full field-level reference lives in grumpy_context/grumpy.schema.json.

Query Components

Query components no longer ask for a type by default. They generate a typedef based on the base name:

typedef UserProfileQueryResult = void;

class UserProfileComponent extends QueryComponent<UserProfileQueryResult> {
  const UserProfileComponent({super.key});

  @override
  Future<UserProfileQueryResult> query(QueryHooks use) async {}
}

When you generate a query component interactively, the query-mixin dialog now shows one combined list with source labels, for example:

  • StatefulQueryLoader [framework: grumpy_flutter]
  • DefaultErrorBuilder [project: lib/src/app/utils/query_component_utils.dart]
  • SomeConfiguredMixin [config: defaults.query_component.mixins]

About

Mason bricks for grumpy projects

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages