From 2cd000f3b15ae93f6cdb016d45909c59268f9489 Mon Sep 17 00:00:00 2001 From: chouchouji <1305974212@qq.com> Date: Tue, 14 Jan 2025 16:55:00 +0800 Subject: [PATCH] feat: support changelog preset --- README.md | 13 ++++++++++++- README.zh-CN.md | 13 ++++++++++++- bin/index.js | 1 + src/changelog.ts | 18 ++++++++++++++++-- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fb3fb98..c9c97f9 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ npx vr publish | ----------------------------------- | -------------------------- | | -f --file \ | Specify changelog filename | | -rc --releaseCount \ | Release count | +| -p --preset \ | Specify changelog preset | #### lint-commit @@ -130,8 +131,18 @@ function release(options: ReleaseCommandOptions): Promise interface ChangelogCommandOptions { file?: string releaseCount?: number + preset?: + | 'angular' + | 'atom' + | 'codemirror' + | 'conventionalcommits' + | 'ember' + | 'eslint' + | 'express' + | 'jquery' + | 'jshint' } -function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise +function changelog({ releaseCount, file, preset }?: ChangelogCommandOptions): Promise const COMMIT_MESSAGE_RE: RegExp function isVersionCommitMessage(message: string): string | false | null diff --git a/README.zh-CN.md b/README.zh-CN.md index 37259ae..5eb8333 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -66,6 +66,7 @@ npx vr publish | ----------------------------------- | ------------------ | | -f --file \ | 指定变更日志文件名 | | -rc --releaseCount \ | 发布数量 | +| -p --preset \ | 指定变更预设 | #### lint-commit @@ -130,8 +131,18 @@ function release(options: ReleaseCommandOptions): Promise interface ChangelogCommandOptions { file?: string releaseCount?: number + preset?: + | 'angular' + | 'atom' + | 'codemirror' + | 'conventionalcommits' + | 'ember' + | 'eslint' + | 'express' + | 'jquery' + | 'jshint' } -function changelog({ releaseCount, file }?: ChangelogCommandOptions): Promise +function changelog({ releaseCount, file, preset }?: ChangelogCommandOptions): Promise const COMMIT_MESSAGE_RE: RegExp function isVersionCommitMessage(message: string): string | false | null diff --git a/bin/index.js b/bin/index.js index 1f54479..24005f1 100755 --- a/bin/index.js +++ b/bin/index.js @@ -31,6 +31,7 @@ program .command('changelog') .option('-rc --releaseCount ', 'Release count') .option('-f --file ', 'Changelog filename') + .option('-p --preset ', 'Changelog preset') .description('Generate changelog') .action((options) => changelog(options)) diff --git a/src/changelog.ts b/src/changelog.ts index 562f162..4dcd7c8 100644 --- a/src/changelog.ts +++ b/src/changelog.ts @@ -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 { +export function changelog({ + releaseCount = 0, + file = 'CHANGELOG.md', + preset = 'angular', +}: ChangelogCommandOptions = {}): Promise { const s = createSpinner('Generating changelog').start() return new Promise((resolve) => { conventionalChangelog({ - preset: 'angular', + preset, releaseCount, }) .pipe(createWriteStream(resolvePath(process.cwd(), file)))