-
Notifications
You must be signed in to change notification settings - Fork 8
/
.cz-config.js
68 lines (59 loc) · 3.03 KB
/
.cz-config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const fs = require('fs')
const { globSync } = require('glob')
const getPackages = () => {
const ignore = [
'apps/examples/**',
'node_modules/**', '**/node_modules/**'
];
const allPackageJsonFiles = globSync('**/package.json', { ignore });
const packageNames = allPackageJsonFiles
.map((filePath) => {
const fileContent = fs.readFileSync(filePath, 'utf-8');
const fileData = JSON.parse(fileContent);
return fileData.name.replace('@justeattakeaway/', '');
})
.sort();
return packageNames;
};
const getCurrentTicketNumberFromBranch = () => {
const branchName = require('child_process').execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
const ticketNumber = branchName.match(/\d{1,7}/)?.[0];
return ticketNumber;
};
module.exports = {
// We have to provide '\u0020' to some emojis due to a spacing bug with commitizen - https://github.com/commitizen/cz-cli/issues/815
types: [
{ value: 'feat', name: '✨ feat: A new feature or functionality' },
{ value: 'fix', name: '🐛 fix: A bug fix' },
{ value: 'chore', name: '🧹 chore: Changes that affect the build system or external dependencies (e.g: typescript, webpack, eslint, package.json)' },
{ value: 'ci', name: '⚙️ \u0020ci: Changes to our CI configuration files and scripts' },
{ value: 'docs', name: '📚 docs: Documentation only changes' },
{ value: 'format', name: '💅 format: Changes that do not affect the meaning of the code (e.g: white-space, linting fixes etc)' },
{ value: 'performance', name: '🚀 performance: A code change that improves performance' },
{ value: 'refactor', name: '♻️ \u0020refactor: A code change that neither fixes a bug nor adds a feature' },
{ value: 'release', name: '📦 release: Release of version' },
{ value: 'revert', name: '⏪ revert: Revert to a commit' },
{ value: 'cosmetic', name: '🎨 cosmetic: Changes that affect the UI styling (e.g: design tokens, images, Sass and SVGs)' },
{ value: 'test', name: '✅ test: Adding missing tests' },
{ value: 'wip', name: '🚧 wip: Work in progress' },
],
scopes: [...getPackages()],
// override the messages, defaults are as follows
messages: {
type: "Select the type of change that you're committing:",
scope: 'Denote the SCOPE of this change:',
ticketNumber: `Jira ticket number (${getCurrentTicketNumberFromBranch() || '000'}):`,
subject: 'Write a SHORT, IMPERATIVE tense description of the change:',
body: '(optional) Provide a LONGER description of the change. Use "|" to break new line:',
breaking: '(optional) List any BREAKING CHANGES:',
confirmCommit: 'Are you sure you want to proceed with the commit above?',
},
allowBreakingChanges: ['feat', 'fix', 'refactor'],
allowCustomScopes: false,
skipQuestions: ['footer'],
allowTicketNumber: true,
fallbackTicketNumber: getCurrentTicketNumberFromBranch() || '000',
isTicketNumberRequired: true,
ticketNumberPrefix: 'DSW-',
ticketNumberRegExp: '\\d{1,7}',
};