frinyvonnick / gitmoji-changelog

A changelog generator for gitmoji 😜
https://www.npmjs.com/package/gitmoji-changelog
MIT License
390 stars 49 forks source link

Install error "TypeError: Cannot read property 'version' of null" #159

Closed robbyrussell closed 4 years ago

robbyrussell commented 4 years ago

Thought I'd give this a whirl and hit a bug via npx version 6.4.1

$ npx gitmoji-changelog
▶  start     gitmoji-changelog v2.0.1
ℹ  info      init ./CHANGELOG.md
ℹ  info      use preset node
✖  error     TypeError: Cannot read property 'version' of null
    at getChangelog (/Users/robbyrussell/.npm/_npx/81174/lib/node_modules/gitmoji-changelog/src/cli.js:98:68)
    at <anonymous>

I was able to install via npm, though. Thought I might report this should it pop up for others.

frinyvonnick commented 4 years ago

Thank you for reporting this issue @robbyrussell 🙏

This error is functionnal I need to improve error handling. The node preset returned null because it couldn't find a package.json file in your project folder or it is empty. Is it the case? If not did you use it on an open source project so I could reproduce the issue?

robbyrussell commented 4 years ago

@frinyvonnick Oh, I was about to test it out on Oh My Zsh, which does not have a package.json.

https://github.com/ohmyzsh/ohmyzsh/

I suppose that's my bad for not understanding that it needed to be used on a Node-friendly project

frinyvonnick commented 4 years ago

Not at all, this information is missing from the usage section. That's a good catch. gitmoji-changelog has a preset system since 2.0.0 to enable supporting more projects that Node.js ones. Someone asked for a generic preset using a configuration file in issue #157. I will close the both issue as soon as the preset is made.

frinyvonnick commented 4 years ago

@robbyrussell I fixed the error messages and created a generic preset. You can test it with the canary version.

Here is how to use the generic preset:

  1. Create a file .gitmoji-changelogrc at the project root with the following content
{
  "project": {
    "name": "ohmyzsh",
    "description": "A delightful community-driven (with nearly 1,500 contributors) framework for managing your zsh configuration",
    "version": "1.0.0"
  }
}
  1. Call gitmoji-changelog with the preset option set to generic
npx gitmoji-changelog@canary --preset generic

I tested it on ohmyzsh. It works 😄

I'll publish it as soon as possible.