felangel / mason

Tools which allow developers to create and consume reusable templates called bricks.
https://docs.brickhub.dev
967 stars 97 forks source link

feat: show correct msg when there is no mason.yam. #158

Closed huang12zheng closed 2 years ago

huang12zheng commented 2 years ago

Description

  1. there is no mason.yaml, and no use mason add -g
  2. mason add show a bad err message.
    # output
    mason add '/Users/huangzheng/very_good_cli/example/vscode_dart_extension/bricks/groovin_core' 
    brick not found at path /Users/huangzheng/very_good_cli/example/vscode_dart_extension/bricks/groovin_core

  3. ref code
    final bricksJson = isGlobal ? globalBricksJson : localBricksJson;
    if (bricksJson == null) {
      throw UsageException('brick not found at path $location', usage);
    ...
    Directory? get __entryPoint {
    try {
      return entryPoint;
    } catch (_) {} // <<<<<<<<<<<<<
    return null;  // <<<<<<<<<<<<<
    }
    ...
    Directory get entryPoint {
    if (_entryPoint != null) return _entryPoint!;
    final nearestMasonYaml = MasonYaml.findNearest(cwd);
    if (nearestMasonYaml == null ||
        nearestMasonYaml.parent.path == BricksJson.globalDir.path) {
      throw const MasonYamlNotFoundException();
    }
    return _entryPoint = nearestMasonYaml.parent;
    }

Requirements

felangel commented 2 years ago

Hi @huang12zheng 👋 Thanks for opening an issue!

This is working as expected because mason add requires a path to a brick not a mason.yaml. You cannot mason add a using a mason.yaml and must instead pass the path to the brick (directory where the brick.yaml exists).

Closing for now but feel free to comment with additional questions and I'm happy to continue the conversation 👍

huang12zheng commented 2 years ago

Mason add '/Users/huangzheng/very_good_cli/example/vscode_dart_extension/bricks/groovin_core'

It has brick paths.

So we're not talking about the same thing

But I don't know if that's still for now, because this is a boundary case, and I did not pay attention to this issue