Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying latest version with Lerna monorepos #106

Closed
edmorley opened this issue Apr 13, 2019 · 6 comments
Closed

Specifying latest version with Lerna monorepos #106

edmorley opened this issue Apr 13, 2019 · 6 comments

Comments

@edmorley
Copy link

edmorley commented Apr 13, 2019

Hi!

We use Lerna with our monorepo. As such the repo root package.json does not contain a version property, and instead the packages live under packages/* thanks to Yarn's workspaces feature.

This means that we cannot pass --package to auto-changelog, otherwise we get the following error:
auto-changelog: Generating changelog…TypeError: Invalid Version: vundefined

As a workaround, we're planning on using something like this:
auto-changelog --latest-version $(jq -r .version lerna.json)

...however I was wondering whether this is something that you'd be open to auto-changelog supporting? (If only because using bash subcommands makes the package.json script not compatible with Windows.)

Possible options:

  • the --package option accepting arguments, so that we could pass --package lerna.json (since it also happens to contain a version property) or --package packages/neutrino/package.json
  • the --package option automatically falling back to other locations, if there is no version in that file (eg it could scan the workspace directories, or know to try lerna.json)
  • adding a --lerna-version option that specifically uses lerna.json

Thoughts? (I'm happy to open a PR if/when a design direction is agreed :-))

CC @eliperelman

@ljharb
Copy link
Contributor

ljharb commented Apr 13, 2019

I think you need a version in the root package.json regardless, or npm will complain too. Just set private true and there’s no risk of publishing.

@edmorley
Copy link
Author

We use yarn, which I don't think minds. That said, I'd be happy to add a version to the root file, but my understanding was that lerna does not update it, which means we have to manually sync it (or add another custom script).

@ljharb
Copy link
Contributor

ljharb commented Apr 13, 2019

You wouldn’t have to - you can leave it at 0.0.0 forever.

@edmorley
Copy link
Author

That would fix the error when running auto-changelog --package, however then the changes for the about-to-be-released version are not included in the README. (The pupose of --package or --latest-version is to be able to tell auto-changelog what the new version number is, since at that point in the release process the package and/or git tag does not exist for it to be able to infer itself.)

@cookpete
Copy link
Owner

@edmorley I've added support for --package [file] in 1.13.0. Let me know if this solves your issue.

@edmorley
Copy link
Author

That works great - thank you! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants