commitizen / commitizen/cz-cli
Consider using npm module name instead of relative path in adapter config generated by commitizen init
- Lingua principale
- JavaScript
- Stelle
- 17.5k
- Fork
- 566
- Merge medio
- 8h 16m
- PR unite (30g)
- 1
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia in src/commitizen/adapter.js, alle righe collegate in cui commitizen init crea la configurazione dell’adapter. Verifica come si comporta il percorso generato prima di npm install e con un’installazione globale di Commitizen; il lavoro è completato quando la configurazione usa il nome del modulo dell’adapter e la configurazione documentata continua a risolverlo.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, node.js
- Ambito
- cli, tooling
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 50/100