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

Generate root changelog in fixed mode #1078

Merged
merged 2 commits into from
Oct 27, 2017

Conversation

ZauberNerd
Copy link
Contributor

Description

The integration of conventional-changelog into lerna (via the --conventional-commits flag) currently generates one CHANGELOG.md file per package.

This is fine as long as lerna is configured in "independent mode", but when using lerna in "fixed mode" it might be desirable to additionally generate a consolidated CHANGELOG.md in the root directory of the repository.
This "root changelog" contains changes for all packages, while the per package changelogs only list changes affecting their package.

Motivation and Context

Based on the discussion in #1015

How Has This Been Tested?

  • Added unit tests for changelog generation
  • Updated unit tests for publish command
  • locally tested this in a repository
  • updated integration tests, activated them, compared snapshots and deactivated them
    • they were deactivated before, because the changelog contains dates and commit sha ids that are not stable across multiple runs. I therefore deactivated these tests again until a viable solution can be found (maybe a custom snapshot serializer to modify the files beforehand and remove all unstable values from it).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

When using lerna in fixed mode it would be desireable to have lerna
generate a consolidated changelog.md file in the root directory that
contains changes for all packages.

This commit adds said feature, so that, when executing
`lerna publish --conventional-commits` it will generate one changelog
per package and also one consolidated changelog in the root of the
repository.
The changelog generation in independent mode stays the same (it
generates one changelog per package).

Fixes: lerna#1015
Copy link
Member

@evocateur evocateur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ZauberNerd!

const args = [
CHANGELOG_CLI,
"-p", "angular",
"--context", path.resolve(__dirname, "..", "lib", "ConventionalChangelogContext.js"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, awesome!

@@ -590,6 +590,21 @@ export default class PublishCommand extends Command {
changedFiles.push(packageJsonLocation);
});

if (this.options.conventionalCommits) {
if (!this.repository.isIndependent()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probably would have combined this into one compound conditional (this.options.conventionalCommits && !this.repository.isIndependent()), but I am okay with this.

// TODO: make interesting git history for meaningful snapshots
test.skip("--conventional-commits", async () => {
const cwd = await initFixture("PublishCommand/independent");
// TODO: stabilize timestamp and commit sha of changelog output
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the additions here, I hope we can stop skipping these tests soon...

@evocateur evocateur merged commit 567d05c into lerna:master Oct 27, 2017
evocateur added a commit to mitchhentges/lerna that referenced this pull request Oct 27, 2017
* master:
  Generate root changelog in fixed mode (lerna#1078)
  Republish prereleased packages during subsequent non-prerelease publish (lerna#1077)
  fix: fail when --hoist and --yarn are used together (lerna#1063)
  Improve "import" edgecases + (i18n fixes + git tweaks) (lerna#1059)
  Warn about two or more packages having the same npm package.json name (lerna#1081)
@ZauberNerd ZauberNerd deleted the root-changelog-fixed-mode branch October 28, 2017 13:23
@lock
Copy link

lock bot commented Dec 27, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants