commitizen / commitizen/cz-cli

Add adapters-repo hooks

Offen
#63 6 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
adapter cli enhancement help / pr wanted question
Vorherrschende Sprache
JavaScript
Sterne
17.5k
Forks
566
Ø Merge
8 Std. 16 Min.
Gemergte PRs (30 T.)
1

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit der Überprüfung der bestehenden cli-adapter-Beziehung und ihres prompter-Hooks und vergleiche sie anschließend mit der vorgeschlagenen adapter-repo-Beziehung. Kläre, welche Lifecycle-Hooks und welche Konfigurationsstruktur Maintainer benötigen, bevor du den relevanten CLI- und Adapter-Code suchst. Als abgeschlossen gilt die Aufgabe, wenn ein vereinbarter Hook-Vertrag und eine package.json-Darstellung feststehen und konsistent durch den Ausführungsablauf unterstützt werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, node.js
Bereich
cli, tooling
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.