commitizen / commitizen/cz-cli

Add adapters-repo hooks

オープン
#63 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る
adapter cli enhancement help / pr wanted question
主要言語
JavaScript
スター
17.5k
フォーク
566
平均マージ
8時間 16分
マージ済み PR(30日)
1

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず既存の cli-adapter 関係とその prompter フックを確認し、次に提案されている adapter-repo 関係と比較します。関連する CLI と adapter のコードを探す前に、メンテナーが必要とする lifecycle hooks と設定構造を明確にします。合意されたフック契約と package.json 表現が定まり、実行フロー全体で一貫してサポートされれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, node.js
領域
cli, tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。