You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to write a custom writerOpts.transform to add Jira project links to our change logs. I've tried forking the conventional-changelog/conventional-changelog-angular preset, updating the transform there, and then including my custom conventional changelog preset like so:
// writer-opts.jsconstcompareFunc=require('compare-func')module.exports={transform: (commit,context)=>{letdiscard=trueconstissues=[]commit.notes.forEach((note)=>{note.title='BREAKING CHANGES'discard=false})if(commit.type==='feat'){commit.type='Features'}elseif(commit.type==='fix'){commit.type='Bug Fixes'}elseif(commit.type==='perf'){commit.type='Performance Improvements'}elseif(commit.type==='revert'||commit.revert){commit.type='Reverts'}elseif(discard){return}elseif(commit.type==='docs'){commit.type='Documentation'}elseif(commit.type==='style'){commit.type='Styles'}elseif(commit.type==='refactor'){commit.type='Code Refactoring'}elseif(commit.type==='test'){commit.type='Tests'}elseif(commit.type==='build'){commit.type='Build System'}elseif(commit.type==='ci'){commit.type='Continuous Integration'}if(commit.scope==='*'){commit.scope=''}if(typeofcommit.hash==='string'){commit.shortHash=commit.hash.substring(0,7)}if(typeofcommit.subject==='string'){leturl=context.repository
? `${context.host}/${context.owner}/${context.repository}`
: context.repoUrlif(url){url=`${url}/issues/`// Issue URLs.commit.subject=commit.subject.replace(/#([0-9]+)/g,(_,issue)=>{issues.push(issue)return`[#${issue}](${url}${issue})`})// JIRA Ticketcommit.subject=commit.subject.replace(/([a-zA-Z]+)-(\d+)/,(match,project,number)=>{return`[${match}](https://cadence.atlassian.net/browse/${project}-${number})`})}if(context.host){// User URLs.commit.subject=commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g,(_,username)=>{if(username.includes('/')){return`@${username}`}return`[@${username}](${context.host}/${username})`})}}// remove references that already appear in the subjectcommit.references=commit.references.filter((reference)=>{if(issues.indexOf(reference.issue)===-1){returntrue}returnfalse})returncommit},groupBy: 'type',commitGroupsSort: 'title',commitsSort: ['scope','subject'],noteGroupsSort: 'title',notesSort: compareFunc,}
Neither of these approaches seem to work. Any thoughts on how best to achieve this would be much appreciated!
UPDATE
For anyone finding this, I got it working after some more experimenting. The custom preset library I made does work but I had to remove "preset": "angular" from my package.json. In case anyone is curious, pointing directly at a file containing the writerOpts.transform method did not work.
The text was updated successfully, but these errors were encountered:
I'm trying to write a custom
writerOpts.transform
to add Jira project links to our change logs. I've tried forking theconventional-changelog/conventional-changelog-angular
preset, updating the transform there, and then including my custom conventional changelog preset like so:I've also tried pulling just the transform function out into its own file and referencing it in the
writerOpts
field like so:Neither of these approaches seem to work. Any thoughts on how best to achieve this would be much appreciated!
UPDATE
For anyone finding this, I got it working after some more experimenting. The custom preset library I made does work but I had to remove
"preset": "angular"
from mypackage.json
. In case anyone is curious, pointing directly at a file containing thewriterOpts.transform
method did not work.The text was updated successfully, but these errors were encountered: