From 35b86afb08d289b114927ab8a2f6a3f888bbd578 Mon Sep 17 00:00:00 2001 From: liweijie0812 <674416404@qq.com> Date: Thu, 17 Oct 2024 22:22:12 +0800 Subject: [PATCH] chore: build dist (#38) * chore: build dist * fix: CHANGELOG_REG * chore: build --- dist/index.js | 2 +- src/renderer.ts | 2 +- test/__snapshots__/generatorLog.test.ts.snap | 2 ++ test/__snapshots__/regexp.test.ts.snap | 12 ++++++++++++ test/fixtures/changelog.ts | 2 ++ test/regexp.test.ts | 4 ++-- 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index d76ac04..f3cfa74 100644 --- a/dist/index.js +++ b/dist/index.js @@ -30012,7 +30012,7 @@ const breakingLabel = ['break', 'breaking', 'breaking changes']; const featureLabel = ['feature', 'feat', 'enhancement']; const docsLabel = ['docs', 'doc', 'documentation']; const refactorLabel = ['pref', 'refactor']; -exports.CHANGELOG_REG = /-\s([A-Z]+)(?:\(([A-Z\s]*)\))?:\s(.+)/gi; +exports.CHANGELOG_REG = /-\s([A-Z]+)(?:\(([A-Z\s_-]*)\))?\s*:\s(.+)/gi; exports.PULL_NUMBER_REG = /in\shttps:\/\/github\.com\/.+\/pull\/(\d+)/g; exports.SKIP_CHANGELOG_REG = /\[x\] 本条 PR 不需要纳入 changelog/i; function getPullNumbers(body) { diff --git a/src/renderer.ts b/src/renderer.ts index 577ec55..f403c08 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -8,7 +8,7 @@ const featureLabel = ['feature', 'feat', 'enhancement'] const docsLabel = ['docs', 'doc', 'documentation'] const refactorLabel = ['pref', 'refactor'] -export const CHANGELOG_REG = /-\s([A-Z]+)(?:\(([A-Z\s]*)\))?\s*:\s(.+)/gi +export const CHANGELOG_REG = /-\s([A-Z]+)(?:\(([A-Z\s_-]*)\))?\s*:\s(.+)/gi export const PULL_NUMBER_REG = /in\shttps:\/\/github\.com\/.+\/pull\/(\d+)/g export const SKIP_CHANGELOG_REG = /\[x\] 本条 PR 不需要纳入 changelog/i export function getPullNumbers(body: string) { diff --git a/test/__snapshots__/generatorLog.test.ts.snap b/test/__snapshots__/generatorLog.test.ts.snap index d1719ed..aab02f6 100644 --- a/test/__snapshots__/generatorLog.test.ts.snap +++ b/test/__snapshots__/generatorLog.test.ts.snap @@ -17,6 +17,8 @@ exports[`generatorLog > : generatorLogStart 1`] = ` - \`A\`: a bug fix label in fix @liweijie0812 ([#29](https://github.com/TDesignOteam/tdesign-changelog-action/pull/29)) - \`A\`: a bug fix label in hotfix @liweijie0812 ([#29](https://github.com/TDesignOteam/tdesign-changelog-action/pull/29)) - \`A\`: a bug fix label in bug @liweijie0812 ([#29](https://github.com/TDesignOteam/tdesign-changelog-action/pull/29)) +- \`CHANGELOG_REG\`: 修复日志冒号前面有空格正则匹配不到 @liweijie0812 ([#29](https://github.com/TDesignOteam/tdesign-changelog-action/pull/29)) +- \`test-test\`: test-test @liweijie0812 ([#29](https://github.com/TDesignOteam/tdesign-changelog-action/pull/29)) ### 📈 Performance - \`I\`: a refactor label in refactor @liweijie0812 ([#29](https://github.com/TDesignOteam/tdesign-changelog-action/pull/29)) ### 📝 Documentation diff --git a/test/__snapshots__/regexp.test.ts.snap b/test/__snapshots__/regexp.test.ts.snap index 2b619b5..397139c 100644 --- a/test/__snapshots__/regexp.test.ts.snap +++ b/test/__snapshots__/regexp.test.ts.snap @@ -98,6 +98,18 @@ exports[`regexp > : CHANGELOG_REG 1`] = ` undefined, "test label in test", ], + [ + "- fix(CHANGELOG_REG): 修复日志冒号前面有空格正则匹配不到", + "fix", + "CHANGELOG_REG", + "修复日志冒号前面有空格正则匹配不到", + ], + [ + "- fix(test-test): test-test", + "fix", + "test-test", + "test-test", + ], ] `; diff --git a/test/fixtures/changelog.ts b/test/fixtures/changelog.ts index 990330b..0ec780f 100644 --- a/test/fixtures/changelog.ts +++ b/test/fixtures/changelog.ts @@ -15,6 +15,8 @@ export const changelog = ` - refactor(I): a refactor label in refactor - test(J) : test label in test - test : test label in test +- fix(CHANGELOG_REG): 修复日志冒号前面有空格正则匹配不到 +- fix(test-test): test-test ` export default changelog diff --git a/test/regexp.test.ts b/test/regexp.test.ts index 2fc4988..5f1ad88 100644 --- a/test/regexp.test.ts +++ b/test/regexp.test.ts @@ -6,11 +6,11 @@ import releaseNotes from './fixtures/release-notes' describe('regexp', () => { it(': CHANGELOG_REG', () => { const records = changelog.matchAll(/-\s/g) - expect([...records].length).toBe(16) + expect([...records].length).toBe(18) const result = changelog.matchAll(CHANGELOG_REG) const arr = [...result] - expect(arr.length).toBe(16) + expect(arr.length).toBe(18) expect(arr).toMatchSnapshot() })