Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
5bf9830
Merge pull request #1 from conventional-changelog/master
curly210102 Mar 14, 2021
b188de3
Merge branch 'master' of https://github.com/conventional-changelog/co…
curly210102 Mar 25, 2021
c4b0bac
Merge branch 'master' of https://github.com/conventional-changelog/co…
curly210102 Mar 28, 2021
5b60836
feat(cz-commitlint): finish basic features inspired by cz-conventiona…
curly210102 Apr 1, 2021
1d27083
test(cz-commitlint): Add Util Function Tests
curly210102 Apr 1, 2021
56f3074
Merge branch 'master' of https://github.com/conventional-changelog/co…
curly210102 Apr 7, 2021
12a596f
Merge branch 'master' into feature/cz-commitlint
curly210102 Apr 7, 2021
56a4d8b
feat(cz-commitlint): add prompt field to commitlint config file, add …
curly210102 Apr 12, 2021
6a989ff
test(cli): update 'should print config' test for add 'prompt' field
curly210102 Apr 12, 2021
20c3598
fix(cz-commitlint): fix question input start with new line, fix foote…
curly210102 Apr 12, 2021
efa47f9
docs(cz-commitlint): update commitlint doc "Guide: Use prompt"
curly210102 Apr 12, 2021
69cab32
docs(cz-commitlint): add Prompt Configuration introdution
curly210102 Apr 13, 2021
0396ab1
fix(config-conventional): update to pass ci
curly210102 Apr 13, 2021
e08e3ef
chore: update registry to default npm
curly210102 Apr 14, 2021
a53f814
fix(cz-commitlint): compatible old version @commitlint/load, remove n…
curly210102 Apr 14, 2021
e44b9e1
fix(cz-commitlint): fix load prompt config from commitlint config file
curly210102 Apr 15, 2021
db6a7b1
test(cz-commitlint): move the test files flat with source code files …
curly210102 Apr 28, 2021
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
Prev Previous commit
Next Next commit
feat(cz-commitlint): add prompt field to commitlint config file, add …
…tests for cz-commitlint

prompt field is working for prompt config, settled in commitlint config file, can be defined by shared configurations.
  • Loading branch information
curly210102 committed Apr 12, 2021
commit 56a4d8b7f30f41cee0c38247fb2dd29a8f21e743
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ lib/
package.json.lerna_backup
/*.iml
tsconfig.tsbuildinfo
coverage
98 changes: 98 additions & 0 deletions @commitlint/config-conventional/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,102 @@ module.exports = {
],
],
},
prompt: {
questions: {
type: {
description: "Select the type of change that you're committing:",
enum: {
feat: {
description: 'A new feature',
title: 'Features',
emoji: '✨',
},
fix: {
description: 'A bug fix',
title: 'Bug Fixes',
emoji: '🐛',
},
docs: {
description: 'Documentation only changes',
title: 'Documentation',
emoji: '📚',
},
style: {
description:
'Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)',
title: 'Styles',
emoji: '💎',
},
refactor: {
description:
'A code change that neither fixes a bug nor adds a feature',
title: 'Code Refactoring',
emoji: '📦',
},
perf: {
description: 'A code change that improves performance',
title: 'Performance Improvements',
emoji: '🚀',
},
test: {
description: 'Adding missing tests or correcting existing tests',
title: 'Tests',
emoji: '🚨',
},
build: {
description:
'Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)',
title: 'Builds',
emoji: '🛠',
},
ci: {
description:
'Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)',
title: 'Continuous Integrations',
emoji: '⚙️',
},
chore: {
description: "Other changes that don't modify src or test files",
title: 'Chores',
emoji: '♻️',
},
revert: {
description: 'Reverts a previous commit',
title: 'Reverts',
emoji: '🗑',
},
},
},
scope: {
description:
'What is the scope of this change (e.g. component or file name)',
},
subject: {
description: 'Write a short, imperative tense description of the change',
},
body: {
description: 'Provide a longer description of the change',
},
isBreaking: {
description: 'Are there any breaking changes?',
},
breakingBody: {
description:
'A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself',
},
breaking: {
description: 'Describe the breaking changes',
},
isIssueAffected: {
description: 'Does this change affect any open issues?',
},
issuesBody: {
description:
'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself',
},
issues: {
description: 'Add issue references (e.g. "fix #123", "re #123".)',
},
},
}
};
36 changes: 36 additions & 0 deletions @commitlint/cz-commitlint/src/Process.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {QualifiedRules, UserPromptConfig} from '@commitlint/types';
import {Inquirer} from 'inquirer';
import {
combineCommitMessage as combineBody,
getQuestions as getBodyQuestions,
} from './SectionBody';
import {
combineCommitMessage as combineFooter,
getQuestions as getFooterQuestions,
} from './SectionFooter';
import {
combineCommitMessage as combineHeader,
getQuestions as getHeaderQuestions,
} from './SectionHeader';
import {setPromptConfig} from './store/prompts';
import {setRules} from './store/rules';

export default async function (
rules: QualifiedRules,
prompts: UserPromptConfig,
inquirer: Inquirer
): Promise<string> {
setRules(rules);
setPromptConfig(prompts);
const questions = [
...getHeaderQuestions(),
...getBodyQuestions(),
...getFooterQuestions(),
];
const answers = await inquirer.prompt(questions);
const header = combineHeader(answers);
const body = combineBody(answers);
const footer = combineFooter(answers);

return [header, body, footer].filter(Boolean).join('\n');
}
Loading