felangel / mason

Tools which allow developers to create and consume reusable templates called bricks.

Home Page:https://docs.brickhub.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong path format at brick generation. Slash "/" formatted to `/`

andrespd99 opened this issue · comments

Description

I'm currently building a mason to construct codemagic.yaml files.

Our projects use flavors, so the brick asks the user the path for the main file of each flavor. Then, I map each path to the respective workflow. For instance, the main_staging.dart path is set in the staging workflow, the production main file's path in the production workflow, and so on.

The problem is that the slash / gets formatted to /. Is there a way to avoid this?

Steps:

  1. Ask the user the flavors that will be available in the CI pipeline (production, staging, development).
  2. Ask the path of each main file.
  3. Validate file paths.
  4. Create a variable for each path: {flavor}_main_path

Input: lib/main_staging.dart

for (var flavor in flavors) {
    context.vars['show_$flavor'] = true;
    context.vars['${flavor}_main_path'] = mappedFiles[flavor];
  }

Output of printing context.vars['staging_main_path']: lib/main_staging.dart

Generated result:

script: |
          flutter build appbundle --release --flavor staging --target lib/main_staging.dart

So, the path seems to be right on pre_gen, but gets corrupted in the generation. I know that blob is the Unicode for slash. Would that still be processed correctly by the server instances?

Hi @andrespd99
You can use triple mustache brackets to avoid automatically encoding the variables: {{{ my_var }}}

Thank you very much @felangel , that did the trick!