Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support changelog preset #28

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading