Skip to content

Commit

Permalink
feat: support changelog preset (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
chouchouji authored Jan 14, 2025
1 parent 54d5124 commit 9daf25c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ npx vr publish
| ----------------------------------- | -------------------------- |
| -f --file \<filename\> | Specify changelog filename |
| -rc --releaseCount \<releaseCount\> | Release count |
| -p --preset \<preset\> | Specify changelog preset |

#### lint-commit

Expand Down Expand Up @@ -130,8 +131,18 @@ function release(options: ReleaseCommandOptions): Promise<void>
interface ChangelogCommandOptions {
file?: string
releaseCount?: number
preset?:
| 'angular'
| 'atom'
| 'codemirror'
| 'conventionalcommits'
| 'ember'
| 'eslint'
| 'express'
| 'jquery'
| 'jshint'
}
function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>
function changelog({ releaseCount, file, preset }?: ChangelogCommandOptions): Promise<void>

const COMMIT_MESSAGE_RE: RegExp
function isVersionCommitMessage(message: string): string | false | null
Expand Down
13 changes: 12 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ npx vr publish
| ----------------------------------- | ------------------ |
| -f --file \<filename\> | 指定变更日志文件名 |
| -rc --releaseCount \<releaseCount\> | 发布数量 |
| -p --preset \<preset\> | 指定变更预设 |

#### lint-commit

Expand Down Expand Up @@ -130,8 +131,18 @@ function release(options: ReleaseCommandOptions): Promise<void>
interface ChangelogCommandOptions {
file?: string
releaseCount?: number
preset?:
| 'angular'
| 'atom'
| 'codemirror'
| 'conventionalcommits'
| 'ember'
| 'eslint'
| 'express'
| 'jquery'
| 'jshint'
}
function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise<void>
function changelog({ releaseCount, file, preset }?: ChangelogCommandOptions): Promise<void>

const COMMIT_MESSAGE_RE: RegExp
function isVersionCommitMessage(message: string): string | false | null
Expand Down
1 change: 1 addition & 0 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ program
.command('changelog')
.option('-rc --releaseCount <releaseCount>', 'Release count')
.option('-f --file <file>', 'Changelog filename')
.option('-p --preset <preset>', 'Changelog preset')
.description('Generate changelog')
.action((options) => changelog(options))

Expand Down
18 changes: 16 additions & 2 deletions src/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,28 @@ const { createWriteStream } = fse
export interface ChangelogCommandOptions {
file?: string
releaseCount?: number
preset?:
| 'angular'
| 'atom'
| 'codemirror'
| 'conventionalcommits'
| 'ember'
| 'eslint'
| 'express'
| 'jquery'
| 'jshint'
}

export function changelog({ releaseCount = 0, file = 'CHANGELOG.md' }: ChangelogCommandOptions = {}): Promise<void> {
export function changelog({
releaseCount = 0,
file = 'CHANGELOG.md',
preset = 'angular',
}: ChangelogCommandOptions = {}): Promise<void> {
const s = createSpinner('Generating changelog').start()

return new Promise((resolve) => {
conventionalChangelog({
preset: 'angular',
preset,
releaseCount,
})
.pipe(createWriteStream(resolvePath(process.cwd(), file)))
Expand Down

0 comments on commit 9daf25c

Please sign in to comment.