conventional-changelog / conventional-changelog-config-spec

a spec describing the config options supported by conventional-config for upstream tooling

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add scope in types

felipecrs opened this issue · comments

I would like to define a custom scope in types, such as:

"types": [
  { "type": "build", "scope": "deps", "section": "Dependencies Upgrade" } 
]

So I could select which commits would be part of the changelog (I don't want to include all the build type commits, only the ones matching the scope deps).

So I could use with @semantic-release/commit-analyzer:

    [
      "@semantic-release/commit-analyzer",
      {
        releaseRules: [
          {
            type: "build",
            scope: "deps",
            release: "patch",
          },
        ],
      },
    ],

This feature was released in the conventionalcommits preset through conventional-changelog/conventional-changelog#669, despite not included in the schema yet.

Author of the conventionalcommits preset PR here, I wasn't aware there was a specification. I can create a PR to add it to the schema and specification if you want?

Actually, I'm not a maintainer of this repository. But I believe it would be good since semantic-release points this specification as the reference for configuration.

https://github.com/semantic-release/release-notes-generator#options
image

This is how people know how to use it, I guess.

Specifying a scope with a type seems to be working now, though it should be noted somewhere that the order of types[] matters. I had to put the scope-specific types first, for example:

types: [
  {
    type: 'feat',
    scope: 'specific-scope',
    section: 'Specific Features'
  },
  {
    type: 'feat',
    section: 'Features'
  }
]

However, with type being required I can't hide a commit based on just scope. For example, I wanted to set up a "no-release" scope to be excluded completely from the release notes and changelog, not just excluded from triggering a release.

I had followed the example here but like this:

  "plugins": [
    ["@semantic-release/commit-analyzer", {
      "preset": "conventionalcommits",
      "presetConfig": {
        types: [...]
      },
      "releaseRules": [
        {"scope": "no-release", "release": false}
      ]
    }],
   [ '@semantic-release/release-notes-generator',  {
      "preset": "conventionalcommits",
      "presetConfig": {
        types: [...]
      }
    }]
  ]

So what I have to do currently is loop through all the types and specify scope: 'no-release' and hidden: true first, then the set all the types section etc without the scope. Ideally I'd like to do this:

types: [
  {
    scope: 'no-release',
    hidden: true
  },
  {
    type: 'feat',
    section: 'Features'
  },
  ...
]

Is there a way to support that? And let me know if I should open a new issue.