commitizen / cz-cli Goto Github PK
View Code? Open in Web Editor NEWThe commitizen command line utility. #BlackLivesMatter
Home Page: http://commitizen.github.io/cz-cli/
License: MIT License
The commitizen command line utility. #BlackLivesMatter
Home Page: http://commitizen.github.io/cz-cli/
License: MIT License
When you run tests the first test that runs triggers nodemon to rerun the test suite again so the test suite never completes.
Hi,
First of all, great project!
Is it possible to pass information about a branch (or some other git information) to an custom adapter?
I find this line: https://github.com/commitizen/cz-cli/blob/master/src/cli/strategies/git-cz.js#L59 where it looks like you are passing all arguments to git
(?). Is it possible to parse the arguments and exclude cz-cli
-specific arguments and pass them to a adapter?
Example:
$ git cz --author="Name <email>" --cz-branch-name="$(git rev-parse --abbrev-ref HEAD)"
The command above should pass --author
to git commit
and --cz-branch-name
to the adapter (because the argument starts with --cz-
).
What do you think? Is this a good solution? Or is it a better way?
I've not looked at this in detail yet, but when I installed a package that had commitizen
as a devDependencies
it also appeared to install nodemon
- which is (I suspect) used for development in commitizen.
So should nodemon be moved to devDependencies
instead of dependencies
?
Why do we load a path to an adaptor and not an actual module? I like to distribute the commitizen with my pre-git module as pre-git
dependency by default. But commitizen cannot find the adaptor path
"czConfig": {
"path": "node_modules/cz-conventional-changelog"
}
This breaks between npm 2 and 3 - npm3 seems to flatten paths, while npm2 leaves the paths nested.
I believe it would be better to just require the adaptor by name, rather than use node_modules
path, or at least check if the path resolves or not.
Would be great it we could provide a way for git GUIs to inject themselves in the place of inquirer so that they could use their own GUIs to ask users for prompts. This might be a pie in the sky idea but it would be pretty freaking cool.
I installed and configured the cz-cli into a git project generated by yeoman (yeoman polymer).
Running git cz
works fine until after the last questions that lunch yeoman generator. Here is an example of the process:
$ yo polymer myApp
_-----_
| | .--------------------------.
|--(o)--| | Out of the box I include |
`---------´ | Polymer Starter Kit |
( _´U`_ ) '--------------------------'
/___A___\
| ~ |
__'.___.'__
´ ` |° ´ Y `
? Would you like to include web-component-tester? No
? Would you like to include recipe docs? No
[…]
I'm all done. Running *npm install & bower install* for you to install the required dependencies. If this fails, try running the command yourself.
[…]
$ commitizen init cz-conventional-changelog --save --save-exact
$ git add .
$ git cz
[email protected], [email protected]
Line 1 will be cropped at 100 characters. All other lines will be wrapped after 100 characters.
? Select the type of change that you're committing: chore: Changes to the build process or auxiliary tools
and libraries such as documentation generation
? Denote the scope of this change ($location, $browser, $compile, etc.):
*
? Write a short, imperative tense description of the change:
Scafold built with `yo polymer`
? Provide a longer description of the change:
Setp up the project (Polymer Starter Kit) using yeoman generator
? List any breaking changes or issues closed by this change:
_-----_
| | .--------------------------.
|--(o)--| | Out of the box I include |
`---------´ | Polymer Starter Kit |
( _´U`_ ) '--------------------------'
/___A___\
| ~ |
__'.___.'__
´ ` |° ´ Y `
Hi, just tried this and had:
Error: Cannot find module 'process'
Why are you requiring process
? It's a global module (and variable!) and should be available without the use of require
.
Right now we're using babel/register to run everything in commitizen and to get ES6 features. I'm doing this because I need to be able to require() adapters on the fly but still get the features of ES6. I'd love for most of the cli to be pre-built with babel, leaving only the adapter part to using babel/register. This would help git-cz to be faster. I've never done this before and am not even sure if it is possible. Any help would be great.
Hi!
TLDR; IRFM, ran it, then tried to run git cz
, it failed with an unfortunate but epic error,
D:\work\MyBlog\C\c2-bin>git cz
module.js:338
throw err;
^
Error: Cannot find module 'D:\work\MyBlog\C\c2-bin\node_modules\commitizen\bin\git-cz'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
The longer story
Running windows 7 with node and npm such
D:\work\MyBlog\C\c2-bin>npm -v
2.11.3
D:\work\MyBlog\C\c2-bin>node -v
v0.12.7
I have run D:\work\MyBlog\C\c2-bin>npm install -g commitizen
,
then D:\work\MyBlog\C\c2-bin>commitizen init cz-conventional-changelog --save --save-exact
Then i configured my local package.json
file to add
,"config": {
"commitizen": {
"path": "node_modules/cz-conventional-changelog"
}
}
Where did i get it wrong ?
Thanks !
D:\work\MyBlog\C\c2-bin>commitizen init cz-conventional-changelog --save --save-exact
Attempting to initialize using the npm package cz-conventional-changelog
Error: A previous adapter is already configured. Use --force to override
D:\work\MyBlog\C\c2-bin>commitizen init cz-conventional-changelog --save --save-exact --force
Attempting to initialize using the npm package cz-conventional-changelog
npm WARN using --force I sure hope you know what you are doing.
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] license should be a valid SPDX license expression
[email protected] node_modules\cz-conventional-changelog
└── [email protected]
{this.config was unexpected at this time.
D:\work\MyBlog\C\c2-bin> "C:\Users\d1m\AppData\Roaming\npm\node_modules\commitizen\node_modules\.bin\\node.exe" "C:\Users\d1m\AppData\Roaming\npm\node_modules\commitizen\node
_modules\.bin\\..\json\lib\json.js" -I -f D:\work\MyBlog\C\c2-bin\package.json -e 'if(!this.config) {this.config={};}; if(!this.config.commitizen) { this.config.commitizen={};}
; this.config.commitizen.path="./node_modules/cz-conventional-changelog"'
D:\work\MyBlog\C\c2-bin>git cz
module.js:338
throw err;
^
Error: Cannot find module 'D:\work\MyBlog\C\c2-bin\node_modules\commitizen\bin\git-cz'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
D:\work\MyBlog\C\c2-bin>
Per @killswitch and @kentcdodds in this original issue. We should be using npm's config object and not our own key. We want to be good package.json citizens after all. 👍
The main reason that this bad practice exists is that config loader originally came from jscs and thus followed their perhaps naive convention. The good news is we can easily add it and migrate to it being the default because their loader is pretty robust.
Things needed for this to happen:
commitizen init
to use the config.cz location by default to encourage new adoption.EDIT: Created a new ticket for removing czConfig in 3.0.0 per @kentcdodds
Hooray!
when i run commitizen init cz-conventional-changelog --save --save-exact
i get this output
Attempting to initialize using the npm package cz-conventional-changelog
********
WARNING: You are using czConfig in your package.json. czConfig will be deprecated in Commitizen 3.
Please use this instead:
{
"config": {
"commitizen": {
"path": "./path/to/adapter"
}
}
}
For more information, see: http://commitizen.github.io/cz-cli/
********
npm WARN install Couldn't install optional dependency: Unsupported
[email protected] /home/oussama/Desktop/IContribute
└─┬ [email protected]
└── [email protected]
the message say, Please use this instead
but the suggested config is the same in package.json, also what is the optional dependency?
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.
Is it possible to create new type(scope): title...
commit types? We're using this in tandem with clog and we have some custom commit types defined for the changelog.
There is currently no test suite for commitizen or a way for adapters to smoke test.
This is super awesome. Would it be possible to add custom prompts or something so I could use this to help me with Jira smart commits. Basically I'd like to have prompts that ask for:
This would be super awesome if we could add this.
#30 added deprecation warnings and switched defaults over to using config.commitizen in package.json. We just need to remove the deprecated code for 3.0.0 but this'll be a breaking change.
There are a set of steps that would probably be useful in troubleshooting problems with Commitizen and Adapters. Over time it would be nice to have a place for them to be documented rather than being stuck in issues.
Big fan of commitizen
here. In so much that I'm trying to use it for projects that are not part of the NPM/node/javascript ecosystem. Any git repository, that is.
I can't get that scenario to work. I've installed commitizen
, conventional-changelog
, cz-conventional-changelog
globally with -g
, but running git cz
fails (and falls back to regular git
) because the adapter is either not found, or not loaded. No surprise here I guess, since there is no package.json
file, and there won't be one in that repo. Would it be possible to provide a global configuration file, say ~/.czconfig
, that the CLI would use when all else fails?
Thanks
if file is modify or delete,it is not available
>(release +) git cz
/Users/ADoyle/.nvm/versions/node/v0.12.2/lib/node_modules/commitizen/src/cli/git-cz.js:1
(function (exports, require, module, __filename, __dirname) { import {configLo
^^^^^^
SyntaxError: Unexpected reserved word
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Module._extensions..js (module.js:478:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/ADoyle/.nvm/versions/node/v0.12.2/lib/node_modules/commitizen/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:214:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/ADoyle/.nvm/versions/node/v0.12.2/lib/node_modules/commitizen/bin/git-cz.js:3:1)
at Module._compile (module.js:460:26)
Versions:
node v0.12.2
npm 2.13.3
commitizen 2.0.1
I can not figure a way to make easily multiline description in the commitizen promt.
Do you have a clever way to do it?
Thanks.
There's no reason to fill out the prompts if there are no staged files. You can determine this with:
git diff --cached
:-)
Node is now LTS on 4. We're going to support back to 0.12 even though 0.10 should work. Moving forward we'll no longer be testing 0.10 so please use it at your own risk.
When I run commitizen init cz-conventional-changelog --save --save-exact
the cz-conventional-changelog
is added to package.json as promised, but my package.json is modified in such a way that all whitespace is gone. So there is only a very long line.
I'm not sure if this also happens with other commands.
When being prompted for information the cli and adapter information should be clearly shown.
Brainstorming:
As commitizen iterates, as a user I want to be notified when there is an adapter/cli incompatibility.
there's no point in having a 'longer description' if it is forced to be the same length as the short description.
? Write a short, imperative tense description of the change:
\`myUp\` is still false after upping
or
? Write a short, imperative tense description of the change:
`myUp` is still false after upping
They make no sense.
Sometimes, when a pre_commit hook is configured, our commit will fail. It would be helpful to have a way to pass something like --retry
so we won't need to enter the message again.
Just a heads up I am experiencing the following on WIndows 8.1 SBoudrias/Inquirer.js#266
node -v 4.0.0
cc @kentcdodds
if git cz is passed the argument -m then that message should be passed to the "short imperative tense description of the change"
How can I ENFORCE using CZ? Can I check the commit messages on Travis?
Npm's flat modules break existing commitizen functionality. In order to fix these issues there needs to be some major architectural changes in Commitizen 2 and in the adapters.
How does one use git-cz
to amend a commit message? It does not seem to be handling extra arguments.
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working directory clean
$ git-cz -a --amend
[...]
✗ Commit failed. Did you forget to 'git add' your files?
Thank you
Both gulp
and gulp-git
are required to run cz-cli, but are only listed as devDependencies
, not normal dependencies
.
KCD knows what's up. I need to go through and set up CI, CD, etc. It should be much easier w/the test suite.
https://egghead.io/series/how-to-write-an-open-source-javascript-library
This project looks very promising, thank your for this!
What shies me away as a maintainer is that I have to add another dotfile to my repository.
As the .cz.json
is mostly one line, and also json, it would be nice if commitizen could just look up a "cz" field the package.json
.
What do you think?
(Sorry if I missed the a previous discussion on this, couldn't find one.)
Need to test and add docs for --retry undocumented option that is being released in 2.7.0.
`
Linux 3.13.0-76-generic #120-Ubuntu SMP Mon Jan 18 15:58:41 UTC 2016 i686 i686 i686 GNU/Linux
#:npm install -g commitizen
#:/Project/t$ sudo commitizen init cz-conventional-changelog --save --save-exact --force/Project/SyncClient$
Attempting to initialize using the npm package cz-conventional-changelog
Error: ReferenceError: Map is not defined
#:
`
To fix this PR we need to update our mocha command needs an update to the compiler flags:
What was this: js:babel/register
Needs to be this: js:babel-core/register
I have a pre-commit hook that runs eslint. I don't see any output from eslint when that is running when using commitizen. Any idea why that is?
I've tried using node v0.10.37 (which I figured wasn't likely to work after seeing the backticks) and v0.12.2 (via nvm).. but no matter what i try I can't get git cz
to execute successfully.
error:
Potentially unhandled rejection [2] evalmachine.<anonymous>:80
commit(`${answers.type}(${answers.scope}): ${answers.subject}`.slice(0,
^
SyntaxError: Unexpected token ILLEGAL
at Object.exports.runInThisContext (vm.js:73:16)
at doEval (/Users/rai/.nvm/versions/v0.12.2/lib/node_modules/commitizen/node_modules/systemjs/dist/system.src.js:2330:10)
at __eval (/Users/rai/.nvm/versions/v0.12.2/lib/node_modules/commitizen/node_modules/systemjs/dist/system.src.js:2247:7)
at Loader.exec [as __exec] (/Users/rai/.nvm/versions/v0.12.2/lib/node_modules/commitizen/node_modules/systemjs/dist/system.src.js:339:5)
at load.metadata.execute (/Users/rai/.nvm/versions/v0.12.2/lib/node_modules/commitizen/node_modules/systemjs/dist/system.src.js:1182:16)
at linkDynamicModule (/Users/rai/.nvm/versions/v0.12.2/lib/node_modules/commitizen/node_modules/systemjs/dist/system.src.js:668:32)
at link (/Users/rai/.nvm/versions/v0.12.2/lib/node_modules/commitizen/node_modules/systemjs/dist/system.src.js:528:11)
at Object.execute (/Users/rai/.nvm/versions/v0.12.2/lib/node_modules/commitizen/node_modules/systemjs/dist/system.src.js:842:11)
at doDynamicExecute (/Users/rai/.nvm/versions/v0.12.2/lib/node_modules/commitizen/node_modules/systemjs/node_modules/es6-module-loader/dist/es6-module-loader.src.js:1938:25)
at link (/Users/rai/.nvm/versions/v0.12.2/lib/node_modules/commitizen/node_modules/systemjs/node_modules/es6-module-loader/dist/es6-module-loader.src.js:1986:24)
{
"path": "node_modules/cz-conventional-changelog/"
}
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,
We should use https://github.com/kentcdodds/validate-commit-msg in our build process.
Hi @jimthedev , Thanks for this module. The idea is really great. But I want to use a different approach to do this so I might just create another one. We could eventually merge in the future though. Will let you know once mine is done. Thanks.
We've got a great community. We should give credit to all the amazing adapters that people have contributed to.
node version 4.2.2
install the latest: npm install -g commitizen
modify and add some files then run: git cz
you get:
module.js:339
throw err;
^
Error: Cannot find module 'lodash'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Users/leonardo/.nvm/versions/v4.2.2/lib/node_modules/commitizen/dist/commitizen/adapter.js:23:15)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
I downgraded to version 2.1.0 and works fine.
cheers
Leonardo Correa
Hi, thanks for this awesome project.
I am curious, is it possible to override Denote the scope of this change ($location, $browser, $compile, etc.):
message?
Would be great to preset scopes for projects.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.