commitizen / commitizen/cz-cli

Add adapters-repo hooks

Đang mở
#63 6 bình luận 0 reaction 0 người được giao Xem trên GitHub
adapter cli enhancement help / pr wanted question
Ngôn ngữ chính
JavaScript
Star
17.5k
Fork
566
Merge trung bình
8 giờ 16 phút
Pull request đã merge (30 ngày)
1

Mô tả

As an adapter author, I want to be able to have my adapter be configurable (data) and also be able to tap into hook functions (events). I want repo maintainers to be able to define paths to hooks in a similar manor to what we let adapter maintainers do in the commitizen cli-adapter relationship. In the cli-adapter relationship there is really just one hook (prompter) that runs the prompter method of the adapter. Ideally we'd have more hooks available to allow the cli-adapter-repo chain to be solid and configurable.

I would imagine that both the cli-adapter and the adapter-repo relationship need more hooks to be effective. I'm not really sure exactly what points people would want to tap into but this is something I'd love to hear more about from adapter maintainers.

Specifically, if I maintain cz-conventional-widgets, I might decide that I want someone who maintains the AwesomeWidgetBuilder repo to be able to define the following in their package.json:

```
{
config: {
commitizen: {

// HOOKS: All hooks are exports of one file, hooks is an array, with index 0 being the path
hooks: ['myfile.js', 'init', 'bootstrap'];

// -- OR --

// HOOKS: Each hook is in its own file, hooks is an object
hooks: {

// SIMPLE HOOK ITEMS: the exported bootstrap method gets run from myRepoCzSettings.js
"bootstrap": "./myRepoCzBootstrap.js",
"end": "./myRepoCzEnd.js",

// -- OR --

// ADVANCED HOOK ITEMS: an object is used and we call mySweetInitFunction in the init hook
"init": {
path: "./myCzRepoInit.js",
function: "mySweetInitFunction"
}

}
}
}
}
```

This way my adapter and any other adapters that follow my interface can make calls into the repo paths and expect to get data back from the repo.

Note that because the config paths are not scoped to a specific adapter but rather to a series of hooks, an adapter that uses a different commit style could still implement the interface and serve the repo owner. Specifically, if I use the widgetReader interface hooks then I can use either cz-conventional-changelog or cz-smart-commit without having an issue so long as the adapters follow the interface an calls certain hooks at expected times in the execution flow.

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

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng việc xem xét mối quan hệ cli-adapter hiện có và hook prompter của nó, sau đó so sánh với mối quan hệ adapter-repo được đề xuất. Làm rõ các lifecycle hooks và cấu trúc cấu hình mà maintainer cần trước khi xác định vị trí của phần mã CLI và adapter liên quan. Hoàn tất khi có một hợp đồng hook được thống nhất và biểu diễn trong package.json được hỗ trợ nhất quán xuyên suốt luồng thực thi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, node.js
Lĩnh vực
cli, tooling
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

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.