semantic-release / release-notes-generator

:clipboard: semantic-release plugin to generate changelog content with conventional-changelog
MIT License
298 stars 47 forks source link

TypeError: Method Date.prototype.toString called on incompatible receiver [object Date] #675

Open ethanneff opened 2 weeks ago

ethanneff commented 2 weeks ago

I got this error

[5:40:14 PM] [semantic-release] › ✘  Failed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[5:40:14 PM] [semantic-release] › ✘  An error occurred while running semantic-release: TypeError: Method Date.prototype.toString called on incompatible receiver [object Date]
    at Proxy.toString (<anonymous>)
    at [Symbol.toPrimitive] (<anonymous>)
    at new Date (<anonymous>)
    at Object.formatDate (file:///home/runner/work/mobile/mobile/node_modules/conventional-changelog-writer/dist/utils.js:8:12)
    at defaultCommitTransform (file:///home/runner/work/mobile/mobile/node_modules/conventional-changelog-writer/dist/options.js:23:23)
    at transformCommit (file:///home/runner/work/mobile/mobile/node_modules/conventional-changelog-writer/dist/commit.js:29:23)
    at write (file:///home/runner/work/mobile/mobile/node_modules/conventional-changelog-writer/dist/writers.js:39:28)
    at async nextAsync (node:internal/streams/from:182:33) {
  pluginName: '@semantic-release/release-notes-generator'
}
TypeError: Method Date.prototype.toString called on incompatible receiver [object Date]
    at Proxy.toString (<anonymous>)
    at [Symbol.toPrimitive] (<anonymous>)
    at new Date (<anonymous>)
    at Object.formatDate (file:///home/runner/work/mobile/mobile/node_modules/conventional-changelog-writer/dist/utils.js:8:12)
    at defaultCommitTransform (file:///home/runner/work/mobile/mobile/node_modules/conventional-changelog-writer/dist/options.js:23:23)
    at transformCommit (file:///home/runner/work/mobile/mobile/node_modules/conventional-changelog-writer/dist/commit.js:29:23)
    at write (file:///home/runner/work/mobile/mobile/node_modules/conventional-changelog-writer/dist/writers.js:39:28)
    at async nextAsync (node:internal/streams/from:182:33) {
  pluginName: '@semantic-release/release-notes-generator'
}error Command failed with exit code 1.

when upgrading:

my release config looks like this

module.exports = {
  branches: ['main'],
  plugins: [
    [
      '@semantic-release/commit-analyzer',
      {
        releaseRules: [
          { type: 'refactor', release: 'patch' },
          { type: 'docs', scope: 'README', release: 'patch' },
          { type: 'test', release: 'patch' },
          { type: 'style', release: 'patch' },
          { type: 'perf', release: 'patch' },
          { type: 'ci', release: 'patch' },
          { type: 'build', release: 'patch' },
          { type: 'chore', release: 'patch' },
          { type: 'no-release', release: false },
        ],
        parserOpts: {
          noteKeywords: ['BREAKING CHANGE', 'BREAKING CHANGES', 'BREAKING'],
        },
      },
    ],
    [
      '@semantic-release/release-notes-generator',
      {
        preset: 'conventionalcommits',
        presetConfig: {
          types: [
            { type: 'feat', section: ':sparkles: Features', hidden: false },
            { type: 'fix', section: ':bug: Fixes', hidden: false },
            { type: 'docs', section: ':memo: Documentation', hidden: false },
            { type: 'style', section: ':barber: Code-style', hidden: false },
            { type: 'refactor', section: ':zap: Refactor', hidden: false },
            {
              type: 'perf',
              section: ':fast_forward: Performance',
              hidden: false,
            },
            {
              type: 'test',
              section: ':white_check_mark: Tests',
              hidden: false,
            },
            { type: 'ci', section: ':repeat: CI', hidden: false },
            { type: 'chore', section: ':repeat: Chore', hidden: false },
          ],
        },
      },
    ],
    ['@semantic-release/npm', { npmPublish: false }],
    ['@semantic-release/github', { successComment: false, failComment: false }],
    [
      '@semantic-release/changelog',
      { changelogFile: '.github/CHANGELOG.md', changelogTitle: '# Changelog' },
    ],
    [
      '@semantic-release/git',
      {
        assets: ['.github/CHANGELOG.md', 'package.json'],
        message: 'chore(release): ${nextRelease.version} [skip ci]',
      },
    ],
  ],
};
travi commented 2 weeks ago

What version of semantic-release are you running? You likely need to upgrade that as well.

Also, you should not need to install the release-notes-generator separately since it is a dependency of semantic-release. You likely have multiple versions installed. Your safest option is to let semantic-release just use the one it includes as a dependency

ethanneff commented 2 weeks ago

So I reverted the package version to get it working again. These are the dependencies I have installed:

    "semantic-release": "23.0.8",
    "@semantic-release/changelog": "6.0.3",
    "@semantic-release/commit-analyzer": "12.0.0",
    "@semantic-release/git": "10.0.1",
    "@semantic-release/github": "10.0.6",
    "@semantic-release/npm": "12.0.1",
    "@semantic-release/release-notes-generator": "13.0.0",

I thought I should have each individually installed based on the docs:

Thaddeus-Mallow commented 2 weeks ago

I am running into the same error using these versions

            semantic-release@24.0.0
            @semantic-release/commit-analyzer@13.0.0
            @semantic-release/release-notes-generator@14.0.0
            @semantic-release/github@10.0.6
            @semantic-release/changelog@6.0.3
            @semantic-release/git@10.0.1
            conventional-changelog-conventionalcommits@7.0.2
Thaddeus-Mallow commented 2 weeks ago

It does work if I also upgrade conventional-changelog-conventionalcommits to version 8. So I am good :D

jasonschroeder-sfdc commented 2 weeks ago

Looks like https://github.com/conventional-changelog/commitlint/pull/4069 will help us 🤞 which bumps conventional-changelog-conventionalcommits to v8