Skip to content

[feature] Provide a getChangelogEntry method for custom changelog generators #995

@chaance

Description

@chaance

Affected Packages

@changesets/apply-release-plan

Problem

We currently use our own changelog generator package (@remix-run/changelog-github). The workflow is pretty good overall, but because we version all of our packages in lockstep there are occasionally releases in some packages that don't have any changes, so I need to manually update those release notes prior to committing.

There are only two possible hooks into the generator: one for formatting dependency updates and another for individual changeset lines. I'd like to add a completely new changelog message for empty releases instead of having the generator insert a version heading without content.

Proposed solution

Modify the getChangelogEntry function to allow changelog generators to provide their own getChangelogEntry method.

async function generateChangesForVersionTypeMarkdown(
  obj: ChangelogLines,
  type: keyof ChangelogLines
) {
  // ...
  if (typeof changelogFuncs.getChangelogEntry === "function") {
    return changelogFuncs.getChangelogEntry(
      release,
      changelogLines,
      changelogOpts
    );
  }

  // otherwise just do what you already do, no breaking change needed
  return [
    `## ${release.newVersion}`,
    await generateChangesForVersionTypeMarkdown(changelogLines, "major"),
    await generateChangesForVersionTypeMarkdown(changelogLines, "minor"),
    await generateChangesForVersionTypeMarkdown(changelogLines, "patch"),
  ]
    .filter((line) => line)
    .join("\n");
}

If there is interest in this solution, I'd be more than happy to submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions