generate-changelog icon indicating copy to clipboard operation
generate-changelog copied to clipboard

Package.json dependency

Open 1am opened this issue 6 years ago • 3 comments

Hello,

I've tried to use generate-changelog for my non nodejs project but it fails with Error: valid package.json not found. I've looked through the issues of this repository and found Fails when no version is specified in package.json #24 and I can't really understand why there's a need for package.json at all if all you need to get list of changes for parsing is git log v0.1...HEAD --pretty=format:'%H: %s' --reverse called from bash.

1am avatar Jan 31 '18 09:01 1am

Hey @1am,

When this module was first written, it was only made to support Node projects, so that's why there were a lot assumptions made about how this package would be used, including things like having a package.json to pull out the current version of that project. Since then though, we've actually started using this package for all kinds of projects, but we've had to make workarounds to get it to work (e.g. having a very minimal package.json in all of our non-Node repos) that really aren't the best.

After #25 was implemented, the package.json was no longer a hard dependency since it would just print the date instead of a semver version number. However, we didn't actually remove the requirement that a package.json needed to exist. This is a bug and should be fixed.

Long-term, I think it would be great to be able to provide a way to pass in the current version of any arbitrary package through the CLI and still apply semver version bumps that way. For example, if I have a CLI package (my-cli) that responds to a -v flag, I could use changelog -p -v $(my-cli -v) -f CHANGELOG.md. But that can be added later. First step is the package.json problem.

We'll try our best to get to it soon, but we also gladly welcome PRs if you want to help!

robinjoseph08 avatar Feb 02 '18 22:02 robinjoseph08

Hi, any updates here?

ScottBrenner avatar Mar 27 '20 22:03 ScottBrenner

I added this step before changelog and worked:

- name: Create required package.json
  run: test -f package.json || echo '{}' >package.json

owen2345 avatar May 24 '21 11:05 owen2345