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

feat(release)!: rewrite ChangelogRenderer to a class API and remove deprecated config #28229

Merged
merged 3 commits into from
Oct 2, 2024

Conversation

JamesHenry
Copy link
Collaborator

@JamesHenry JamesHenry commented Oct 1, 2024

BREAKING CHANGE

In Nx v19, implementing a custom changelog renderer would involve a lot of work on the user side. They would need to create an additional function making every property available in its declaration and then call the underlying default one and customize the final string (or reimplement the whole thing).

E.g.

const changelogRenderer = async ({
  projectGraph,
  commits,
  releaseVersion,
  project,
  entryWhenNoChanges,
  changelogRenderOptions,
  repoSlug,
  conventionalCommitsConfig,
  changes,
}) => {
  const defaultChangelog = await defaultChangelogRenderer({
    projectGraph,
    commits,
    releaseVersion,
    project,
    entryWhenNoChanges,
    changelogRenderOptions,
    repoSlug,
    conventionalCommitsConfig,
    changes,
  });

  // ...Do custom stuff and return final string...
};

module.exports = changelogRenderer;

In Nx v20, changelog renderer are classes. The DefaultChangelogRenderer can therefore easily and granularly be extended and customized, and the config does not need to be redeclared on the user side at all. We will improve things even further in this area, but this breaking change is an important stepping stone.

E.g. for manipulating the final string equivalent to the previous example:

module.exports = class CustomChangelogRenderer extends (
  DefaultChangelogRenderer
) {
  async render() {
    const defaultChangelogEntry = await super.render();
    // ...Do custom stuff and return final string...
  }
};

E.g. for customizing just how titles get rendered:

class CustomChangelogRenderer extends DefaultChangelogRenderer {
  renderVersionTitle(): string {
    return 'Custom Version Title';
  }
}

Copy link

vercel bot commented Oct 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Oct 2, 2024 5:49pm

@JamesHenry JamesHenry changed the title feat(release)!: ChangelogRenderer has migrated to a class API and remove deprecated config feat(release)!: rewrite ChangelogRenderer to a class API and remove deprecated config Oct 2, 2024
Copy link

github-actions bot commented Oct 2, 2024

🐳 We have a release for that!

This PR has a release associated with it. You can try it out using this command:

npx create-nx-workspace@0.0.0-pr-28229-afe192c my-workspace

Or just copy this version and use it in your own command:

0.0.0-pr-28229-afe192c
Release details 📑
Published version 0.0.0-pr-28229-afe192c
Triggered by @JamesHenry
Branch changelog-renderer-api-change
Commit afe192c
Workflow run 11141916110

To request a new release for this pull request, mention someone from the Nx team or the @nrwl/nx-pipelines-reviewers.

@JamesHenry JamesHenry force-pushed the changelog-renderer-api-change branch from c19e12f to 56e3e54 Compare October 2, 2024 14:00
@JamesHenry JamesHenry marked this pull request as ready for review October 2, 2024 18:03
@JamesHenry JamesHenry requested a review from a team as a code owner October 2, 2024 18:03
@JamesHenry JamesHenry merged commit 2c0994a into master Oct 2, 2024
6 checks passed
@JamesHenry JamesHenry deleted the changelog-renderer-api-change branch October 2, 2024 18:20
Copy link

github-actions bot commented Oct 8, 2024

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 8, 2024
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.

2 participants