Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define Commitizen adapter when using "npx git-cz"?

I am trying to adopt a conventional commits like standard to my projects. While searching for linters and other automation tools I stumbled upon commitizen. I want to use it in my project without installing it locally neither globally using the NPX with the command npx git-cz.

  • How to define the adapter using this approach? (without installing it locally or globally)

  • What is the default adapter used by Commitizen when on NPX? (Couldn't find in their documentation)

like image 245
Felipe Cesar Assis Avatar asked Oct 16 '22 08:10

Felipe Cesar Assis


2 Answers

This is a known issue in commitizen.

If the repository is not commitizen friendly, running npx git-cz will install and use the streamich/git-cz adapter.

I think this works only because of package name collisions, and do not think you can configure a different adapter this way.

like image 143
flup Avatar answered Nov 01 '22 10:11

flup


The closest I've come to making my repository "commitizen-friendly" without a local package.json is the following --

Define a .czrc file in the repository

{
  "path": "cz-conventional-changelog",
  "maxLineWidth": 72
}

And when using npx, explicitly set the commitizen package:

npx --package cz-conventional-changelog --package commitizen -- cz

Or if your users can install commitizen globally (e.g. npm install -g commitizen cz-conventional-changelog) then this becomes

git cz

This seems to work for me. Hopefully I'm not missing something.

EDIT I did miss something. Both recommendations require the adapters to also be specified or installed. Amended the above.

like image 35
Jordan Caras Avatar answered Nov 01 '22 08:11

Jordan Caras