Skip to content

Commit

Permalink
Merge branch 'master' into feat-allow-hidding-by-subject
Browse files Browse the repository at this point in the history
  • Loading branch information
dangreen committed Aug 13, 2023
2 parents dc6d2bd + 7ec8a18 commit c55c5e4
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 17 deletions.
18 changes: 18 additions & 0 deletions packages/conventional-changelog-conventionalcommits/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'

const DEFAULT_COMMIT_TYPES = Object.freeze([
{ type: 'feat', section: 'Features' },
{ type: 'feature', section: 'Features' },
{ type: 'fix', section: 'Bug Fixes' },
{ type: 'perf', section: 'Performance Improvements' },
{ type: 'revert', section: 'Reverts' },
{ type: 'docs', section: 'Documentation', hidden: true },
{ type: 'style', section: 'Styles', hidden: true },
{ type: 'chore', section: 'Miscellaneous Chores', hidden: true },
{ type: 'refactor', section: 'Code Refactoring', hidden: true },
{ type: 'test', section: 'Tests', hidden: true },
{ type: 'build', section: 'Build System', hidden: true },
{ type: 'ci', section: 'Continuous Integration', hidden: true }
].map(Object.freeze))

exports.DEFAULT_COMMIT_TYPES = DEFAULT_COMMIT_TYPES
3 changes: 3 additions & 0 deletions packages/conventional-changelog-conventionalcommits/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

const { DEFAULT_COMMIT_TYPES } = require('./constants')
const { createParserOpts } = require('./parserOpts')
const { createWriterOpts } = require('./writerOpts')
const { createConventionalChangelogOpts } = require('./conventionalChangelog')
Expand All @@ -24,3 +25,5 @@ async function createPreset (config) {
}

module.exports = createPreset

module.exports.DEFAULT_COMMIT_TYPES = DEFAULT_COMMIT_TYPES
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { describe, it, expect } from 'vitest'
import BetterThanBefore from 'better-than-before'
import conventionalChangelogCore from 'conventional-changelog-core'
import { TestTools } from '../../../tools/test-tools'
import preset from '../'
import preset, { DEFAULT_COMMIT_TYPES } from '../'

const { setups, preparing, tearsWithJoy } = BetterThanBefore()
let testTools
Expand Down Expand Up @@ -193,6 +193,29 @@ describe('conventional-changelog-conventionalcommits', () => {
}
})

it('should handle alternative "types" configuration', async () => {
preparing(1)

for await (let chunk of conventionalChangelogCore({
cwd: testTools.cwd,
config: preset({
types: DEFAULT_COMMIT_TYPES.map((commitType) => (
commitType.type === 'chore'
? { ...commitType, hidden: false }
: commitType
))
})
})) {
chunk = chunk.toString()

expect(chunk).toContain('### Miscellaneous Chores')
expect(chunk).toContain('**deps:** upgrade example from 1 to 2')

expect(chunk).toContain('### Performance Improvements')
expect(chunk).toContain('**ngOptions:** make it faster')
}
})

it('should properly format external repository issues', async () => {
preparing(1)

Expand Down
16 changes: 2 additions & 14 deletions packages/conventional-changelog-conventionalcommits/writerOpts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const compareFunc = require('compare-func')
const { readFile } = require('fs').promises
const { resolve } = require('path')
const { DEFAULT_COMMIT_TYPES } = require('./constants')
const { addBangNotes } = require('./utils')

const releaseAsRegex = /release-as:\s*\w*@?([0-9]+\.[0-9]+\.[0-9a-z]+(-[0-9a-z.]+)?)\s*/i
Expand All @@ -15,20 +16,7 @@ const repository = '{{#if this.repository}}{{~this.repository}}{{else}}{{~@root.

async function createWriterOpts (config) {
const finalConfig = {
types: [
{ type: 'feat', section: 'Features' },
{ type: 'feature', section: 'Features' },
{ type: 'fix', section: 'Bug Fixes' },
{ type: 'perf', section: 'Performance Improvements' },
{ type: 'revert', section: 'Reverts' },
{ type: 'docs', section: 'Documentation', hidden: true },
{ type: 'style', section: 'Styles', hidden: true },
{ type: 'chore', section: 'Miscellaneous Chores', hidden: true },
{ type: 'refactor', section: 'Code Refactoring', hidden: true },
{ type: 'test', section: 'Tests', hidden: true },
{ type: 'build', section: 'Build System', hidden: true },
{ type: 'ci', section: 'Continuous Integration', hidden: true }
],
types: DEFAULT_COMMIT_TYPES,
issueUrlFormat: '{{host}}/{{owner}}/{{repository}}/issues/{{id}}',
commitUrlFormat: '{{host}}/{{owner}}/{{repository}}/commit/{{hash}}',
compareUrlFormat: '{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}',
Expand Down
3 changes: 3 additions & 0 deletions packages/conventional-recommended-bump/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ const cli = meow(`
},
tagPrefix: {
shortFlag: 't'
},
skipUnstable: {
type: 'boolean'
}
}
})
Expand Down
8 changes: 6 additions & 2 deletions packages/git-semver-tags/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const args = meow(`
--lerna parse lerna style git tags
--package <name> when listing lerna style tags, filter by a package
--tag-prefix <prefix> prefix to remove from the tags during their processing
`,
--skip-unstable if given, unstable tags will be skipped, e.g., x.x.x-alpha.1, x.x.x-rc.2`,
{
importMeta: import.meta,
booleanDefault: undefined,
Expand All @@ -26,14 +26,18 @@ const args = meow(`
},
tagPrefix: {
type: 'string'
},
skipUnstable: {
type: 'boolean'
}
}
})

gitSemverTags({
lernaTags: args.flags.lerna,
package: args.flags.package,
tagPrefix: args.flags.tagPrefix
tagPrefix: args.flags.tagPrefix,
skipUnstable: args.flags.skipUnstable
}, (err, tags) => {
if (err) {
console.error(err.toString())
Expand Down

0 comments on commit c55c5e4

Please sign in to comment.