leoforfree / cz-customizable

A standalone commit message helper or customizable commitizen adapter for https://github.com/commitizen/cz-cli
MIT License
604 stars 201 forks source link

[bug] - Breaks as Commitizen plugin and standalone using custom/example config with error referencing missing `choices` parameter #204

Open ontoneio opened 2 years ago

ontoneio commented 2 years ago

Bug Repro URL : https://github.com/ontoneio/cz-choices-bug

Dependency info

Brief

Steps taken

I followed instructions from this config instruction in Configuration (Shared between options 1,2 and 3) which results in below output when run from script prepare-commit in the package.json.

 *  Executing task: yarn run prepare-commit 

yarn run v1.22.19
$ cz -e
cz-cli@4.2.5, cz-customizable@6.9.1

>>> Using cz-customizable config specified in your package.json:  /home/vscode/projects/opensource/bugs/cz-choices-bug/tools/.cz-config.js
All lines except first will be wrapped after 100 characters.
You must provide a `choices` parameter <----------------------------------- ERROR APPEARS HERE
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

 *  The terminal process "/usr/bin/bash '-c', 'yarn run prepare-commit'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

as well as using the instructions from Option 2 - cz-customizable in standalone mode which results in below output when run from script commit in the package.json.

yarn run v1.22.19
$ ./node_modules/cz-customizable/standalone.js
cz-customizable standalone version
>>> Using cz-customizable config specified in your package.json:  /home/vscode/projects/opensource/bugs/cz-choices-bug/tools/.cz-config.js
All lines except first will be wrapped after 100 characters.
/home/vscode/projects/opensource/bugs/cz-choices-bug/node_modules/inquirer/lib/prompts/base.js:80
    throw new Error('You must provide a `' + name + '` parameter');
          ^

Error: You must provide a `choices` parameter <--- ERROR with reference to `choices` in standalone mode
    at ListPrompt.throwParamError (/home/vscode/projects/opensource/bugs/cz-choices-bug/node_modules/inquirer/lib/prompts/base.js:80:11)
    at new ListPrompt (/home/vscode/projects/opensource/bugs/cz-choices-bug/node_modules/inquirer/lib/prompts/list.js:21:12)
    at PromptUI.fetchAnswer (/home/vscode/projects/opensource/bugs/cz-choices-bug/node_modules/inquirer/lib/ui/prompt.js:103:25)
    at doInnerSub (/home/vscode/projects/opensource/bugs/cz-choices-bug/node_modules/rxjs/dist/cjs/internal/operators/mergeInternals.js:22:31)
    at outerNext (/home/vscode/projects/opensource/bugs/cz-choices-bug/node_modules/rxjs/dist/cjs/internal/operators/mergeInternals.js:17:70)
    at OperatorSubscriber._this._next (/home/vscode/projects/opensource/bugs/cz-choices-bug/node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:33:21)
    at OperatorSubscriber.Subscriber.next (/home/vscode/projects/opensource/bugs/cz-choices-bug/node_modules/rxjs/dist/cjs/internal/Subscriber.js:51:18)
    at /home/vscode/projects/opensource/bugs/cz-choices-bug/node_modules/rxjs/dist/cjs/internal/operators/mergeInternals.js:28:28
    at OperatorSubscriber._this._next (/home/vscode/projects/opensource/bugs/cz-choices-bug/node_modules/rxjs/dist/cjs/internal/operators/OperatorSubscriber.js:33:21)
    at OperatorSubscriber.Subscriber.next (/home/vscode/projects/opensource/bugs/cz-choices-bug/node_modules/rxjs/dist/cjs/internal/Subscriber.js:51:18)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

 *  The terminal process "/usr/bin/bash '-c', 'yarn run commit'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

Reproduction

  1. Clone repo git clone https://github.com/ontoneio/cz-choices-bug
  2. Make changes to index.js files located in apps/app1|app2
  3. Run yarn both scripts from root level package.json a. prepare-commit assumes cz-customizable is a commitizen plugin b. commit assumes cz-customizable is a standalone plugin
  4. Expect to see menu prompt for building commit messages.
  5. Errors out in both scripts. Note any references to choices parameter in both scripts.
ontoneio commented 2 years ago

Be happy to jump in and help debug this if your open to it @leonardoanalista. Bit of a blocker for me, so I can spend some time.

Also thank you for the assembling this great library. Saving me a ton of trouble in for other things.