commitizen / cz-cli

The commitizen command line utility. #BlackLivesMatter
http://commitizen.github.io/cz-cli/
MIT License
16.7k stars 547 forks source link

It doesn't work in a yeoman generated project #128

Open jorgecasar opened 8 years ago

jorgecasar commented 8 years ago

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
cz-cli@2.5.0, cz-conventional-changelog@1.1.5

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 ` 
jimthedev commented 8 years ago

I have not tried using this this a yeoman generator yet. Did you make sure to CD into the directory with the project? You don't show it in the steps above so I just want to make sure.

jorgecasar commented 8 years ago

Yes, I'm in the project folder. Yeoman must be executed in a empty folder and it becomes the root folder.

All the command showed in the example was executed in the root of the project.

jimthedev commented 8 years ago

@jorgecasar Were you able to find anything more about why this was happening? I don't have the bandwidth to investigate further but am curious as to why that would happen.

jorgecasar commented 8 years ago

@jimthedev I don't know how it happens. I spent some time reading yeoman generator for Polymer and cz-cli code but I couldn't find anything. I will try with other generator to discard options.

The full process to reproduce the error is:

$ npm install -g yo
$ npm install -g generator-polymer
$ mkdir -p my-project && cd $_
$ yo polymer
$ commitizen init cz-conventional-changelog --save --save-exact
$ git add .
$ git cz

And after answer all the cz questions it start the yeoman script instead of cz one.

jimthedev commented 8 years ago

Try the following change in your process (note I added just one line, git init):

$ npm install -g yo
$ npm install -g generator-polymer
$ mkdir -p my-project && cd $_
$ yo polymer

$ git init

$ commitizen init cz-conventional-changelog --save --save-exact
$ git add .
$ git cz

Looks like yeoman doesn't actually initialize a git repo for you so you probably need to do it yourself using git init as I showed above.

jimthedev commented 8 years ago

cc @jorgecasar

jorgecasar commented 8 years ago

HI,

It seems that the question prompt callback it isn't called. Instead of the cz script it calls again the yeoman question prompt callback.

https://github.com/commitizen/cz-conventional-changelog/blob/55f72b9dea9dd3938ef0810cbc9dec54a4d13e34/index.js#L80-L102

jimthedev commented 8 years ago

Hi,

Could you upload this all in a zip or post a link to a repo? I am using the steps you provided and as long as I run git init properly in the process I am unable to reproduce.