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

preset.types stopped working in v9 and v10 #110

Open
oluwatobiss opened this issue Jan 17, 2025 · 6 comments
Open

preset.types stopped working in v9 and v10 #110

oluwatobiss opened this issue Jan 17, 2025 · 6 comments

Comments

@oluwatobiss
Copy link
Contributor

After updating to v9 and 10, the generated changelog no longer follows the type and section specified in the preset.types configuration.

Steps to reproduce

  1. Install v8.0.2
npm install --save-dev @release-it/[email protected]
  1. Specify some custom preset types
"plugins": {
  "@release-it/conventional-changelog": {
    "infile": "CHANGELOG.md",
    "preset": {
      "name": "conventionalcommits",
      "types": [
        { "type": "chore", "section": "🏠 Conventional Changelog Maintenance 🪛" }
      ]
    }
  }
}
  1. Stage and commit the update using a chore commit type
git add -A && git commit -m "chore: v8.0.2 preset.types test"
  1. Run a release
  2. Checking the generated changelog will show the chore commit with the specified 🏠 Conventional Changelog Maintenance 🪛 section heading.
  3. Update to any release between v9.0.0 and v10.0.0
  4. Stage and commit again using a chore commit type
git add -A && git commit -m "chore: 10.0.0 preset.types test"
  1. Execute a new release
  2. The generated changelog will show the latest commit as a plain chore: 10.0.0 preset.types test text. In other words, it will ignore the preset.types configuration and use the git log message format.

Expected behaviour

The latest version should allow using the preset.types configuration to specify the commit message type and section text to show in the generated CHANGELOGs.

Actual behavior

The latest version ignores the preset.types configuration and uses the git log commit format.

Example changelog

@nongyehong
Copy link

I updated v10 today and found this problem.😕

@De-Santa
Copy link

I think in new versions options are not passed to
https://github.com/conventional-changelog/conventional-changelog/blob/master/packages/conventional-recommended-bump

With this options

    "@release-it/conventional-changelog": {
      infile: "CHANGELOG.md",
      header: "# Changelog\n\n",
      parserOpts: {
        headerPattern: /^(GG-\d+|GG-NOTASK)\s+\((\w+)\):\s+(.*)$/,
        headerCorrespondence: ["task", "type", "message"], // Corresponding fields
      },
      preset:  "conventionalcommits",

I see next output when debugging

Image

1. commits param at whatBump function seems to ignore regexp redefined in headerPattern and uses regexp from preset
2. commits param at writerOpts.transform seems to be ok and parsed correctly

As for 8.0.2 version all working as expected.
Image

This is commits param at whatBump it's identical to commit at writerOpts.transform

Spend whole weekends to figure things out. Thanks for that issue, it got me on right path.

Waiting for fix

@webpro
Copy link
Contributor

webpro commented Jan 20, 2025

This release-it plugin is mostly a wrapper around the conventional-recommended-bump and conventional-changelog packages. It mostly passes on configuration options to the various external functions:

For conventional-recommended-bump:

const bumper = new Bumper();
if (options.preset) await bumper.loadPreset(options.preset).preset;
if (options.tagOpts) bumper.tag(options.tagOpts);
if (options.commitsOpts) bumper.commits(options.commitsOpts, options.parserOpts);
async function getWhatBump() {
if (options.whatBump === false) {
return () => ({ releaseType: null });
} else if (typeof options.whatBump === 'function') {
return options.whatBump;
}
const bumperPreset = await bumper.preset;
if (bumperPreset === null) return () => ({ releaseType: null });
return bumperPreset.whatBump || bumperPreset.recommendedBumpOpts.whatBump;
}
const recommendation = await bumper.bump(await getWhatBump());

For conventional-changelog generation:

const { context, gitRawCommitsOpts, parserOpts, writerOpts, ...options } = mergedOptions;
const mergedContext = Object.assign({ version, previousTag, currentTag }, context);
const mergedGitRawCommitsOpts = Object.assign({ debug, from: previousTag }, gitRawCommitsOpts);
this.debug('conventionalChangelog', {
options,
context: mergedContext,
gitRawCommitsOpts: mergedGitRawCommitsOpts,
parserOpts,
writerOpts
});
return conventionalChangelog(options, mergedContext, mergedGitRawCommitsOpts, parserOpts, writerOpts);

Would be great if someone could fix this up in an actual real-world scenario (because I don't use this plugin myself).

@chris-dura
Copy link

chris-dura commented Jan 24, 2025

@De-Santa -- It might be unrelated, but I was also experiencing a separate issue that seemed like the script wasn't properly loading the preset.

I dug in and I've decided there's some sort of dependency resolution weirdness happening in my project, where [email protected] was getting installed in node_modules; however, I believe @release-it/conventional-changelog@v10 depends on conventional-changelog@^v6, which depends on conventional-changelog-conventionalcommits@^v8

Once I explicitly ran npm install conventional-changelog-conventionalcommits@8 to add it to my package.json, it started working for me as expected.

I don't know if this will fix your particular issue with preset.types...

@Ankit1598
Copy link

@oluwatobiss @De-Santa sorry for the ping, but did you figure out any solution or temp fix for this?

@oluwatobiss
Copy link
Contributor Author

@oluwatobiss @De-Santa sorry for the ping, but did you figure out any solution or temp fix for this?

No.

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

6 participants