commitizen / commitizen/cz-cli

Consider using npm module name instead of relative path in adapter config generated by commitizen init

Offen
#469 6 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
17.5k
Forks
566
Ø Merge
8 Std. 16 Min.
Gemergte PRs (30 T.)
1

Beschreibung

The setup instructions [in the readme][repo-commitizen-friendly] use the module name of the adapter (i.e. `cz-conventional-changelog`), but the actual config generated by `commitizen init` uses a relative path to the module:

https://github.com/commitizen/cz-cli/blob/d5e24245dda078464d8c964f5d052bcad1da14f5/src/commitizen/adapter.js#L35-L41

According to [the readme][repo-commitizen-friendly]:

> commitizen.path is resolved via require.resolve and supports
>
> - **npm modules**
> - directories relative to process.cwd() containing an index.js file
> - file base names relative to process.cwd() with js extension
> - full relative file names
> - absolute paths.

One downside of using a relative path is that developers cannot use their global commitizen install to create a commit if they have not yet run `npm install` in the repo, because this results in an error:
```
Error: Could not resolve /Users/mickdekkers/Projects/foo/node_modules/cz-conventional-changelog.
Cannot find module '/Users/mickdekkers/Projects/foo/node_modules/cz-conventional-changelog'
```

This change should fix the issue, although I'm not sure whether it would be considered breaking:

```diff js
let commitizenAdapterConfig = {
config: {
commitizen: {
- path: `./node_modules/${adapterNpmName}`
+ path: adapterNpmName
}
}
};
```

[repo-commitizen-friendly]: https://github.com/commitizen/cz-cli#making-your-repo-commitizen-friendly

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne in src/commitizen/adapter.js an den verlinkten Zeilen, an denen commitizen init die Adapter-Konfiguration erstellt. Überprüfe, wie sich der generierte Pfad vor npm install und bei einer globalen Commitizen-Installation verhält; abgeschlossen ist es, wenn die Konfiguration den Modulnamen des Adapters verwendet und die dokumentierte Einrichtung ihn weiterhin auflösen kann.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, node.js
Bereich
cli, tooling
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
50/100

Neue Issues direkt in Ihr Postfach

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