Skip to content

[Question] How to use conventional changelog #850

Closed

Description

@danielo515

Hello everyone.

I have a lerna monorepo using independent mode with several packages. Lerna has solved several problems we had at our company (code splitting, dependency management, logic independence, etc), but it has introduced several challenges that I was unable to solve. The most importants are:

  • changelog generation
  • releasing
  • making commits

The first one depends on the third. We were using github-changelog-generator on each repository, but it does not plays well with lerna.

What I would LOVE to do is generate a changelog for each package and maybe a global changelog with each package as a section.

Now that you have recently added support for conventional-changelog I feel that it should be possible. Several closed issues (like #665 ) makes me think that this should be possible, and people commenting about this is very excited. However, I have no clue about how to do any of the following:

  1. How to setup lerna to use conventional-changelog
  2. How can I invoke conventional-changelog through lerna
  3. How can I generate an automatic CHANGELOG file under each package directory
  4. How can I enable conventional changelog by default on lerna.json
  5. How can I scope/relate one specific commit message to the package it belongs to
  6. How can I enforce conventional-messages with some kind of commit wizard

I think that the fifth task is done automatically by lerna by using git log scoped to certain directory (not sure where I read that)

The reason I'm asking this here is because I know that lerna guys know about lerna stuff and there are plenty of people here that seems to know how to use this new feature.

Many thanks and regards

Activity

  1. gastonelhordoy commented on May 26, 2017

    @gastonelhordoy

    Hey man, hope this help.

    I'm using cz-lerna-changelog for commit wizard (6) which also detects which package was/were affected by the changes (5). Regarding commit message enforcement, I'm using husky and validate-commit-msg.

    And then for generating changelog, I started doing some tests with lerna-semantic-release but didn't complete them because of lack of time... So if you make some progress on that side share your notes!

  2. danielo515 commented on May 26, 2017

    @danielo515
    ContributorAuthor

    Thank you @gastonelhordoy

    Could you provide me some guides about how to configure cz-lerna-changelog ? I tried installing it and trying to execute, but it does not work.

  3. danielo515 commented on May 26, 2017

    @danielo515
    ContributorAuthor

    @gastonelhordoy Ok, I finally figured it out. Now I'm testing it

    I would prefer to provide commit messages per package. I noticed that cz-lerna-changelog detects what packages have changed. Is it possible to configure it to promt per package?

  4. gastonelhordoy commented on May 26, 2017

    @gastonelhordoy

    That's done with different commits, staging only things in a certain package...

  5. danielo515 commented on May 26, 2017

    @danielo515
    ContributorAuthor

    That's the kind of behavior that I want to avoid.
    Each commit (in my opinion) should be a working snapshot of the repository at certain point in time. If you commit just parts of it you will have inconsistent states when you navigate through commits. I suffered that several times. I will find easier just to use package headers...

  6. gastonelhordoy commented on May 26, 2017

    @gastonelhordoy

    Well, that's what one usually does, commit everything that makes sense to go together... but you wanted "commit messages per package"...
    Anyways... basically you need to find out how to adapt these tools to your workflow, or maybe adapt your workflow to these tools, whatever makes more sense to you use case.

  7. danielo515 commented on May 26, 2017

    @danielo515
    ContributorAuthor

    Yes, one way or the other 😄
    But then how does lerna decide which messages to include on each package changelog?

  8. gastonelhordoy commented on May 26, 2017

    @gastonelhordoy

    Read the docs:
    https://github.com/atlassian/lerna-semantic-release#lerna-semantic-release

    Basically a semantic-release that orders commits based on which package they belong to (uses data from cz-lerna-changelog) and then determines on that what the next release should be.

  9. danielo515 commented on May 31, 2017

    @danielo515
    ContributorAuthor

    Thanks again @gastonelhordoy

    However I thought this was something included in lerna itself. You have mentioned (and I really thank you for it) like 4 third party tools. I expected to need a tool for the commit wizard, and maybe for commit message validation, but I expected lerna to build the changelog files, make the automatic version bump based on git logs and that stuff.

    Also I still need answer to the following

    1. How to setup lerna to use conventional-changelog (for bump version during publish for example)
    • This is documented, my fault, just use --conventional-commits however this does not solves the last point
    1. How can I invoke conventional-changelog through lerna.
    • As far as I understand, this does not makes any sense. Just use the commit wizard or the publish modifiers
    1. How can I generate an automatic CHANGELOG file under each package directory
    • I still have doubts about this
    1. How can I enable conventional changelog by default on lerna.json
    • I suspect that I just have to put conventional-commits under the command section of lerna.json, but I'm not sure

    Thanks again

  10. evocateur commented on Jun 6, 2017

    @evocateur
    Member

    @danielo515 Sorry for the delayed response, but here's my understanding:

    • --conventional-commits is currently only enabled when you use the "independent" versioning mode, not the default "fixed" versioning (the version field of lerna.json).
    • Only per-package CHANGELOG.md files are currently updated, not the root.
    • Enabling --conventional-commits from lerna.json should look something like this:
    {
      "lerna": "2.0.0-rc.5",
      "command": {
        "publish": {
          "conventionalCommits": true
        }
      },
      "version": "independent"
    }
  11. danielo515 commented on Jun 7, 2017

    @danielo515
    ContributorAuthor

    Thanks @evocateur for your response.

    I am indeed using the independent versioning mode in all my repositories.

    Only per-package CHANGELOG.md files are currently updated, not the root.

    Then how do you build/bundle a global changelog?

    Thanks for confirming the correct format on lerna.json, I was thinking it should be like you described, but I was not sure.

    Regards

  12. danielo515 commented on Jun 7, 2017

    @danielo515
    ContributorAuthor

    Dear @gastonelhordoy which commit validator are you using with husky? The only ones that I found do not allow line breaks on the commit message (which is a must have for lerna)

    Regards

  13. danielo515 commented on Jun 14, 2017

    @danielo515
    ContributorAuthor

    @evocateur the way you suggested to include conventional commits on lerna.json is not working. It is ignored by lerna.

  14. evocateur commented on Jun 14, 2017

    @evocateur
    Member

    If you could reproduce a failing test case, that would be a great start to a pull request to fix it.

  15. enriquecaballero commented on Jul 11, 2017

    @enriquecaballero

    For some reason Lerna keeps creating a release in a changelog with the exact same release points of the previous release. Any idea why this is happening? I'm on an independent style Lerna repo.

  16. paulblyth commented on Sep 11, 2017

    @paulblyth

    I'm currently experiencing the same issue @enriquecaballero - did you resolve it?

  17. enriquecaballero commented on Sep 11, 2017

    @enriquecaballero

    @paulblyth I have not. Sometimes it happens, sometimes it doesn't ― sometimes it happens for about 5+ releases in a row and then it stops again. It's really frustrating. Does it happen on all of your packages or only some of them? It only happens on some my packages; others seem to release fine.

  18. paulblyth commented on Sep 11, 2017

    @paulblyth

    @enriquecaballero only some packages - seems to be consistently every release for me at the moment but only published a handful of times. I'm wondering if there's a commit message that keeps being picked up for some reason

  19. evocateur commented on Sep 11, 2017

    @evocateur
    Member

    Again, a focused, minimal reproduction of these problems would go a long way toward figuring out a solution. We don't even know if this is a lerna bug or a conventional-commits bug, at this point.

  20. danielo515 commented on Sep 11, 2017

    @danielo515
    ContributorAuthor

    I think the problem @paulblyth and @enriquecaballero are reporting is different from my original request, which is a request for documentation about how to use lerna with conventional changelog.
    One thing I would like to know, if how can I customize the links generation for example. By default it points to github, and I'm currently using bitbucket.

    Regards

  21. paulblyth commented on Sep 11, 2017

    @paulblyth

    Yes sorry @danielo515 I didn't mean to hijack; @evocateur I'll try and reproduce separately to the project I'm working on and I'll create a separate ticket for this

  22. alan-agius4 commented on Oct 4, 2017

    @alan-agius4
    Contributor

    @danielo515 I don't think that is possble at the moment, as lerna uses 'angular' for the convential-changelog and is hard coded and for bitbucket it needs to be 'angular-bitbucket'. https://www.npmjs.com/package/conventional-changelog-angular-bitbucket

    To be honest I have the same problem as my repo is in bitbucket

  23. stale commented on Dec 27, 2018

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  24. lock commented on Apr 3, 2019

    @lock

    This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  25. locked as resolved and limited conversation to collaborators on Apr 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions