felangel / felangel/mason

chore: What is the process for setting up a whitelist to restrict modifications by the Mason CLI for specific files?

Open
#951 2 comments 0 reactions 1 assignee Claimed by @felangel View on GitHub
chore question waiting for response
Dominant language
Dart
Stars
1.1k
Forks
113
PR merge metrics
No merged PRs in 30d

Description

**Description**

I have created a custom template using Stencil. When I include this template under the "bricks" directory and use a specific brick, it automatically modifies the Stencil template without defining the variables in the brick.yaml file. How can I prevent this from happening?

**Here is brick.yaml file content**

```
name: boilerplate_brick
description: A new brick created with the Mason CLI.

vars:
project_name:
type: string
description: Provide your project name
default: SampleProject
prompt: What is your project name?

bundle_id:
type: string
description: Provide your project bundle id
default: com.example.sampleproject
prompt: What is your project bundle id?
```


**Here is the Stencil template**
```

// swiftlint:disable all
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
{% if catalogs %}
{% set enumName %}{{param.enumName|default:"Asset"}}{% endset %}
{% set forceNamespaces %}{{param.forceProvidesNamespaces|default:"false"}}{% endset %}
{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
{% macro enumBlock assets %}
{% call casesBlock assets %}
{% endmacro %}
{% macro casesBlock assets %}
{% for asset in assets %}
{% if asset.type == "color" %}

static var {{asset.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}: UIColor {
return {{enumName}}.Colors.{{asset.name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords}}.color
}
{% elif asset.items and ( forceNamespaces == "true" or asset.isNamespaced == "true" ) %}
{% call casesBlock asset.items %}
{% elif asset.items %}
{% call casesBlock asset.items %}
{% endif %}
{% endfor %}
{% endmacro %}

import UIKit

// swiftlint:disable identifier_name line_length nesting type_body_length type_name
{{accessModifier}} extension UIColor {
{% if catalogs.count > 1 or param.forceFileNameEnum %}
{% for catalog in catalogs %}
{% call enumBlock catalog.assets %}
{% endfor %}
{% else %}
{% call enumBlock catalogs.first.assets %}
{% endif %}
}
// swiftlint:enable identifier_name line_length nesting type_body_length type_name

{% else %}
// No assets found
{% endif %}
```

**Updated the Stencil template by Mason CLI**

```
// swiftlint:disable all
// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen
{% if catalogs %}
{% set enumName %}{% endset %}
{% set forceNamespaces %}{% endset %}
{% set accessModifier %}{% if param.publicAccess %}public{% else %}internal{% endif %}{% endset %}
{% macro enumBlock assets %}
{% call casesBlock assets %}
{% endmacro %}
{% macro casesBlock assets %}
{% for asset in assets %}
{% if asset.type == "color" %}

static var : UIColor {
return .Colors..color
}
{% elif asset.items and ( forceNamespaces == "true" or asset.isNamespaced == "true" ) %}
{% call casesBlock asset.items %}
{% elif asset.items %}
{% call casesBlock asset.items %}
{% endif %}
{% endfor %}
{% endmacro %}

import UIKit

// swiftlint:disable identifier_name line_length nesting type_body_length type_name
extension UIColor {
{% if catalogs.count > 1 or param.forceFileNameEnum %}
{% for catalog in catalogs %}
{% call enumBlock catalog.assets %}
{% endfor %}
{% else %}
{% call enumBlock catalogs.first.assets %}
{% endif %}
}
// swiftlint:enable identifier_name line_length nesting type_body_length type_name

{% else %}
// No assets found
{% endif %}

```

**Requirements**
The Mason CLI should refrain from modifying the Stencil template unless the variables are defined in the brick.yaml file.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.