Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brick を作成するための brick を作成 #120

Merged
merged 20 commits into from
Feb 7, 2024

Conversation

morikann
Copy link
Contributor

@morikann morikann commented Feb 5, 2024

概要

背景

これまで brick を作成し、それを mason.yaml に追加するには以下のコードを実行する必要がありました。

  • mason new [brick name] -o ./tools/bricks
  • mason add [brick name] --path ./tools/bricks/[brick name]

上記から分かるように、毎回 path を記載するのが面倒くさいという問題点がありました。
そのため、本 PR では brick を作成する brick を作成し、brick の作成をより簡単にしました。

brick の作成、mason.yaml への追加を行う際は以下のコードを実行します。

  • mason make brick

レビュー観点

  • 問題なく動作しているか
  • 命名は適切か
    • brick を利用する際は、mason make コマンドを利用します。今回作成したのは brick を作る brick ということで、mason make brick となるように、brick 名を "brick" にしました。

レビューレベル

  • Lv1: ぱっとみて違和感がないかチェックして Approve する
  • Lv2: 仕様レベルまで理解して、仕様通りに動くかある程度検証して Approve する
  • Lv3: 実際に環境で動作確認したうえで Approve する

レビュー優先度

  • すぐに見てもらいたい ( hotfix など ) 🚀
  • 今日中に見てもらいたい 🚗
  • 今日〜明日中で見てもらいたい 🚶
  • 数日以内で見てもらいたい 🐢

画像 / 動画

動作変更なし

動作確認手順

  1. mason make brick
  2. 作成した brick が tools/bricks に作成されているか確認
  3. 作成した brick が mason.yaml に記載されているか確認

備考

mason make brick を実行すると以下3点が聞かれ、それぞれに答えることで回答に合った brick が作成されます。

  1. 作成する brick 名は何か?-> String で回答
  2. hooks は必要か?-> Yes/No で回答
  3. brick の説明 (description) は何か?-> String で回答

また、mason make 実行時に以下のようにオプションを指定することで、プロンプトで質問されることなく brick の作成が行えます。

  • mason make brick --name [brick name] --hooks [true or false] --description [brick description]

全てのオプションに対し、デフォルト値が設定されています。そのため、brick の説明など、作成時にまだ考えていないものは答えなくても問題ありません。

import 'package:mason/mason.dart';

void run(HookContext context) {
final brickName = context.vars['brick_name'];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memo-badge
vars の取得方法は以下を参考にしました。
https://docs.brickhub.dev/hooks#-hooks-usage

environment:
mason: ">=0.1.0-dev.52 <0.1.0"

vars:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memo-badge
hooks で mason new を実行するため、mason new のオプションを受け取れるようにしました。FYI

Comment on lines +1 to +2
## What is "brick"
A brick to create a brick.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memo-badge
README では以下について記載しています。

  • 作成した "brick" とはどういう brick なのか
  • 作成した背景
  • 使い方

@morikann morikann marked this pull request as ready for review February 6, 2024 07:08
Copy link

github-actions bot commented Feb 6, 2024

Ready for review 🚀

@morikann
Copy link
Contributor Author

morikann commented Feb 6, 2024

@blendthink @Yamasaki-pan961
レビューよろしくお願いいたします🙏

Copy link
Member

@blendthink blendthink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@morikann
ご対応ありがとうございます!
一点だけコメントしましたので、ご確認お願いします 🙏

brickName,
'--path',
bricksDir + brickName,
]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits-badge
bricks にも LICENSE ファイルは含めないようにしているため、 hooks を↓のように修正お願いします 🙏

Suggested change
]);
]);
// remove LICENSE
Process.runSync('rm', [
'$bricksDir$brickName/LICENSE',
]);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ご指摘ありがとうございます!
以下で修正いたしました🙏
51dc495

Copy link
Member

@blendthink blendthink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@morikann
Copy link
Contributor Author

morikann commented Feb 7, 2024

レビューありがとうございます!
こちらマージします!

@morikann morikann merged commit 9811997 into main Feb 7, 2024
3 checks passed
@morikann morikann deleted the feature/create-brick-for-creating-brick branch February 7, 2024 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: brickを作成するためのbrickを作成
2 participants