Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage in non-node projects? #102

Open
bigeagle opened this issue Jan 8, 2016 · 10 comments
Open

Usage in non-node projects? #102

bigeagle opened this issue Jan 8, 2016 · 10 comments

Comments

@bigeagle
Copy link

bigeagle commented Jan 8, 2016

Hi,
I'm happy to meet this tool. While running

commitizen init cz-conventional-changelog --save --save-exact

I got package.json Not Found, but you know, git is a generic version control system and has been applied to many non-node projects, so any suggestions of using this in non-node projects?

Cheers,

@jimthedev
Copy link
Member

Hmm good question. The init command needs to be improved to support this scenario. It is not currently a use-case that our tests cover. It certainly could be.

For now, as a manual workaround, you need to create an empty or boilerplate package.json in the root of your non-node project. If you want to do this using the cli then you can do something like npm init --yes followed by commitizen init cz-conventional-changelog --save --save-exact. The first command creates a boilerplate package.json and the second initializes commitizen.

I do expect that init will be rewritten as soon as I have some more time to devote to this project. I would be willing to help on an PRs that people want to contribute to improve the init command.

Please note that you can still use the rest of commitizen on non-node projects once you get the package.json created. This is just a limitation of the current init command.

@adoyle-h
Copy link

adoyle-h commented Apr 7, 2016

Maybe creating a czfile in the root of project is better, just like gulpfile.js. The cz-cli could read both the config.commitizen from package.json and the content of czfile.

@nmaggioni
Copy link

I'm seconding this, commitizen is the perfect fit for many non-Node projects as well.

@jimthedev
Copy link
Member

@adoyle-h You can use a .czrc file.

@rochdev
Copy link

rochdev commented Nov 29, 2016

.czrc file doesn't seem to work in the project root though. Even for node projects I would rather not pollute my package.json

@freemo
Copy link

freemo commented Jun 18, 2017

+1 (x100) :)

This feature worked 6 months ago, somehow however in the last 6 months this feature disappeared. I use the following versions and because it still had this feature I could run commitizen without needing a package.json file.

npm install -g commitizen@2.8.6 cz-customizable@4.0.0

with those versions all I needed was a local .cz.json.js and .cz-config.js file in the root of the project, no unsightly package.json, and it all works great. All my projects have been halted on that version waiting for this features to come back, we may have to drop commitizen soon if that doesnt happen.

@husseinraoouf
Copy link

+1

@jimthedev
Copy link
Member

Hey all. Haven't forgotten about you. We did remove the ability to use a .czrc file because our adapters are node-based and thus you have a node project even if your project isn't actually a node project. I am trying to learn more about what we can do to

A) have a sane config loading strategy
B) support you all

Any chance you all can just create a package.json file with only the information we need. What are the downsides of this?

Thanks for helping me to understand more!

@andriyor
Copy link

You can use https://github.com/Woile/commitizen

@kerwanp
Copy link

kerwanp commented Sep 27, 2023

To use commitizen without installing the commitizen in the repository or by using npm install -g commitizen (for some developers global dependencies binaries are not in their path. You can use npx --package=commitizen cz which will run the cz binary of the commitizen package.

With the following .czrc at the root of the project:

{
  "path": "cz-conventional-changelog"
}

It works perfectly.


If you are looking to use commitizen with husky you can use the following hook:

#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

exec < /dev/tty && npx --package=commitizen cz --hook || true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants