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's header option not being passed through? #33

Closed
matatk opened this issue Aug 28, 2021 · 5 comments
Closed

Preset's header option not being passed through? #33

matatk opened this issue Aug 28, 2021 · 5 comments

Comments

@matatk
Copy link

matatk commented Aug 28, 2021

Thanks for this helpful plugin :-). I think I've set the header option for the preset in the correct place, but no (<h1>) header is written to the changelog file. This happens regardless of whether this is the first release (with no changelog already) or whether there has already been a release.

{
  "git": {
    "commitMessage": "chore(release): ${version}"
  },
  "github": {
    "release": true
  },
  "npm": {
    "publish": false
  },
  "plugins": {
    "@release-it/conventional-changelog": {
      "infile": "CHANGELOG.md",
      "preset": {
        "header": "Changelog",
        "name": "conventionalcommits",
        "types": [
          {
            "section": "Features",
            "type": "feat"
          },
          {
            "section": "Bug fixes",
            "type": "fix"
          },
          {
            "section": "Documentation",
            "type": "docs"
          },
          {
            "section": "Styles",
            "type": "style"
          },
          {
            "section": "Code refactoring",
            "type": "refactor"
          },
          {
            "section": "Performance improvements",
            "type": "perf"
          },
          {
            "section": "Tests",
            "type": "test"
          },
          {
            "section": "Builds",
            "type": "build"
          },
          {
            "section": "Continuous integrations",
            "type": "ci"
          },
          {
            "section": "Chores",
            "type": "chore"
          },
          {
            "section": "Reverts",
            "type": "revert"
          }
        ]
      },
      "writerOpts": {
        "headerPartial": "## {{#if @root.linkCompare~}} [{{version}}]({{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}) {{~else}} {{~version}} {{~/if}} {{~#if title}} \"{{title}}\" {{~/if}} {{~#if date}} ({{date}}) {{/if}}\n"
      }
    }
  }
}
@webpro
Copy link
Contributor

webpro commented Oct 7, 2021

Assuming you're using the latest version of the plugin? Please use DEBUG=release-it:* release-it [...] for a better understanding of what's going on and what eventually gets passed to the underlying dependency.

@matatk
Copy link
Author

matatk commented Oct 16, 2021

Hi @webpro. I am running version 14.11.6 of release-it and version 3.3.0 of the plugin (the latest). Thanks for the debug command line. I found some interesting stuff, in that it does appear that the plugin is receiving and passing the option along. First, here's where it picks up the config:

  release-it:plugins {
  release-it:plugins   namespace: 'conventional-changelog',
  release-it:plugins   options: {
  release-it:plugins     infile: 'CHANGELOG.md',
  release-it:plugins     preset: {
  release-it:plugins       header: 'Changelog',
  release-it:plugins       name: 'conventionalcommits',
  release-it:plugins       types: [Array]
  release-it:plugins     },
  release-it:plugins     writerOpts: {
  release-it:plugins       headerPartial: '## {{#if @root.linkCompare~}} [{{version}}]({{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}) {{~else}} {{~version}} {{~/if}} {{~#if title}} "{{title}}" {{~/if}} {{~#if date}} ({{date}}) {{/if}}\n'
  release-it:plugins     },
  release-it:plugins     tagPrefix: ''
  release-it:plugins   }
  release-it:plugins } +0ms

Later, it still has that header setting:

  release-it:conventional-changelog {
  release-it:conventional-changelog   increment: undefined,
  release-it:conventional-changelog   latestVersion: '2.10.1',
  release-it:conventional-changelog   isPreRelease: false,
  release-it:conventional-changelog   preReleaseId: undefined
  release-it:conventional-changelog } +0ms
  release-it:conventional-changelog conventionalRecommendedBump {
  options: {
    infile: 'CHANGELOG.md',
    preset: {
      header: 'Changelog',
      name: 'conventionalcommits',
      types: [Array]
    },
    writerOpts: {
      headerPartial: '## {{#if @root.linkCompare~}} [{{version}}]({{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}) {{~else}} {{~version}} {{~/if}} {{~#if title}} "{{title}}" {{~/if}} {{~#if date}} ({{date}}) {{/if}}\n'
    },
    tagPrefix: ''
  }
} +0ms
  release-it:conventional-changelog {
  release-it:conventional-changelog   err: null,
  release-it:conventional-changelog   result: {
  release-it:conventional-changelog     level: 2,
  release-it:conventional-changelog     reason: 'There are 0 BREAKING CHANGES and 0 features',
  release-it:conventional-changelog     releaseType: 'patch'
  release-it:conventional-changelog   }
  release-it:conventional-changelog } +39ms
  release-it:conventional-changelog conventionalChangelog {
  options: {
    releaseCount: 1,
    infile: 'CHANGELOG.md',
    preset: {
      header: 'Changelog',
      name: 'conventionalcommits',
      types: [Array],
      issuePrefixes: [Array],
      issueUrlFormat: '{{host}}/{{owner}}/{{repository}}/issues/{{id}}',
      commitUrlFormat: '{{host}}/{{owner}}/{{repository}}/commit/{{hash}}',
      compareUrlFormat: '{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}',
      userUrlFormat: '{{host}}/{{user}}'
    },
    tagPrefix: ''
  },
  context: { version: '2.10.2', previousTag: '2.10.1', currentTag: '2.10.2' },
  gitRawCommitsOpts: {
    debug: [Function: debug] {
      namespace: 'release-it:conventional-changelog',
      useColors: true,
      color: 32,
      extend: [Function: extend],
      destroy: [Function: deprecated],
      enabled: [Getter/Setter],
      inspectOpts: [Object],
      diff: 1,
      prev: 1634408217932,
      curr: 1634408217933
    }
  },
  parserOpts: undefined,
  writerOpts: {
    headerPartial: '## {{#if @root.linkCompare~}} [{{version}}]({{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}) {{~else}} {{~version}} {{~/if}} {{~#if title}} "{{title}}" {{~/if}} {{~#if date}} ({{date}}) {{/if}}\n'
  }
} +1ms
  release-it:conventional-changelog Your git-log command is:
  release-it:conventional-changelog git log --format=%B%n-hash-%n%H%n-gitTags-%nNaN%n-committerDate-%n%ci%n------------------------ >8 ------------------------ 2.10.1 --no-merges
  release-it:conventional-changelog Your git-log command is:
  release-it:conventional-changelog git log --format=%B%n-hash-%n%H%n-gitTags-%nNaN%n-committerDate-%n%ci%n------------------------ >8 ------------------------ 2.10.1..HEAD --no-merges

But the generated changelog still doesn't have the header prepended to it:

  release-it:config {
  release-it:config   name: 'landmarks',
  release-it:config   latestVersion: '2.10.1',
  release-it:config   version: '2.10.2',
  release-it:config   changelog: '## [2.10.2](https://github.com/matatk/landmarks/compare/2.10.1...2.10.2) (2021-10-16) \n' +
  release-it:config     '\n' +
  release-it:config     '\n' +
  release-it:config     '### Builds\n' +
  release-it:config     '\n' +
  release-it:config     '* **Changelog:** Try release-it ([8e3cc78](https://github.com/matatk/landmarks/commit/8e3cc7864a9bfd637b52470d0f73c14762332666))\n' +
  release-it:config     '* Improve reviewer info script ([#456](https://github.com/matatk/landmarks/issues/456)) ([086041d](https://github.com/matatk/landmarks/commit/086041d79a812d88eaa7d6ed6bab7f538742f4ab))'
  release-it:config } +112ms

@lpreterite
Copy link
Contributor

I have the same problem.

This plug-in just inserts the changlog produced by the conventional-changelog into the file. For example, after setting the header configuration and taking effect, the effect obtained is not ideal.

like this:

# Changelog

This document lists breaking changes for each major release.

See the GitHub Releases page for detailed changelogs:
[https://github.com/release-it/release-it/releases](https://github.com/release-it/release-it/releases)

## v14

- Removed `global` property from plugins. Use `this.config[key]` instead.
- Removed deprecated `npm.access` option. Set this in `package.json` instead.

# Changelog

This document lists breaking changes for each major release.

See the GitHub Releases page for detailed changelogs:
[https://github.com/release-it/release-it/releases](https://github.com/release-it/release-it/releases)

## v13

- Dropped support for Node v8
- Dropped support for GitLab v11.6 and lower.
- Deprecated `scripts` are removed (in favor of [hooks](https://github.com/release-it/release-it#hooks)).
- Removed deprecated `--non-interactive` (`-n`) argument. Use `--ci` instead.
- Removed old `%s` and `[REV_RANGE]` syntax in command substitutions. Use `${version}` and `${latestTag}` instead.

You can see me here for details: #18

@webpro
Copy link
Contributor

webpro commented Apr 15, 2022

This is now fixed, right? With a single page header as documented.

@webpro webpro closed this as completed Apr 15, 2022
@matatk
Copy link
Author

matatk commented Sep 1, 2022

Hi @webpro. I'm still experiencing this problem, with the current version 5.1.0 of this plugin (and version 15.4.1 of release-it). I've tried setting header to both "Changelog" and "# Changelog" but neither appears at the top of the file.

Update: Yes, this is working for me as documented; thanks!

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

3 participants