generated from effector/razzle-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
.cz-config.js
73 lines (67 loc) · 2.49 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
69
70
71
72
73
const glob = require('glob');
// prettier-ignore
const types = [
{ value: "feat", name: "feat", description: "A new feature" },
{ value: "fix", name: "fix", description: "A bug fix" },
{ value: "docs", name: "docs", description: "Documentation only changes" },
{ value: "style", name: "style", description: "Changes that do not affect the meaning of the code", },
{ value: "chore", name: "chore", description: "Changes to the build process or auxiliary tools", },
{ value: "config", name: "config", description: "Changes in configuration files. Add new or remove old." },
{ value: "refactor", name: "refactor", description: "A code change that neither fixes a bug nor adds a feature", },
{ value: "perf", name: "perf", description: "A code change that improves performance" },
{ value: "test", name: "test", description: "Adding missing tests" },
{ value: "revert", name: "revert", description: "Revert to a commit" },
{ value: "wip", name: "wip", description: "Work in progress" },
]
module.exports = {
types: types.map(beautify),
scopes: [].concat(
'app',
globMap('src/*/', (path) => path.replace(/src\//, '')).filter(
exclude(['features', 'ui', 'lib', 'app']),
),
'features',
globMap('src/features/*/', (path) => path.replace('src/', '')),
'ui',
globMap('src/ui/*/', (path) => path.replace(/^src\//, '')),
'lib',
globMap('src/lib/*/', (path) => path.replace(/^src\//, '')),
'pages',
globMap('src/pages/*/', (path) => path.replace(/^src\//, '')),
),
allowCustomScopes: true,
allowBreakingChanges: ['feat', 'fix', 'revert'],
askForBreakingChangeFirst: true,
};
function beautify({ value, name, description }) {
return {
value,
name: `${name.padEnd(12, ' ')} ${description}`,
};
}
/**
* @param {string} pattern
* @param {(path: string) => string} fn
*/
function globMap(pattern, fn) {
return glob
.sync(pattern)
.map(fn || ((path) => path))
.map((path) => path.replace(/\/$/, ''));
}
/**
* Check `path` to not include substring in `variants`
* @param {string[]} variants
* @return {(path: string) => boolean}
*/
function exclude(variants) {
return (path) => variants.every((variant) => !path.includes(variant));
}
/**
* Check `path` to include substring of one of `variants`
* @param {string[]} variants
* @return {(path: string) => boolean}
*/
function include(variants) {
return (path) => variants.some((variant) => path.includes(variant));
}