felangel / felangel/mason

feat: Builtin hooks for command line scripting

Đang mở
#516 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement candidate
Ngôn ngữ chính
Dart
Star
1.1k
Fork
113
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**Description**

In the original custom scripts (hooks) feature #149, the proposal to add scripts listed two really good use cases -- running `dart fix --apply` or `flutter pub get` after a block executes. I'm wondering if a hook could be baked in to the brick's config that executes command line statements before or after a brick executes.

For example, right now I believe I have to add hooks to my brick just to run `dart fix --apply`, which I do for most everything.

```dart
Future run(HookContext context) async {
final String path = context.vars['feature_name'];
var result = await Process.run('dart', ['fix', '--apply', path], runInShell: true);
context.logger.info(result.stdout.toString());
}
```

It might be convenient to be able to run these common scripts like this:

```yaml
name: my_brick

vars:
feature_name:
type: string
description: The feature name
prompt: What is the feature name?

post-scripts:
- dart fix --apply {{{feature_name}}}
- flutter pub run build_runner build --delete-conflicting-outputs
- echo "Be sure to ..."
```

**Additional Context**
Perhaps the cross platform nature of blocks might make scripts difficult to run, but I still face that if I use a hook and `Process.run()`. Not sure if the lack of cross-platform scripting is a blocker or a potential footgun.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.