Skip to content

Commit d94fe1c

Browse files
authored
chore: use czg commitizen adapter (#5750)
1 parent 4c0f6f5 commit d94fe1c

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

package.json

+7
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
"cross-env": "^7.0.0",
150150
"css-loader": "^5.0.0",
151151
"css-minimizer-webpack-plugin": "^3.0.0",
152+
"cz-git": "^1.3.8",
152153
"date-fns": "^2.24.0",
153154
"diacritics": "^1.3.0",
154155
"docsearch.js": "^2.6.3",
@@ -298,5 +299,11 @@
298299
"tags": "vetur/tags.json",
299300
"attributes": "vetur/attributes.json"
300301
},
302+
"config": {
303+
"commitizen": {
304+
"path": "node_modules/cz-git",
305+
"czConfig": "./scripts/commitizen.js"
306+
}
307+
},
301308
"web-types": "vetur/web-types.json"
302309
}

scripts/commitizen.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
3+
const { execSync } = require('child_process');
4+
const fg = require('fast-glob');
5+
6+
const components = fg.sync('*', { cwd: 'components', onlyDirectories: true });
7+
// precomputed scope
8+
const scopeComplete = execSync('git status --porcelain || true')
9+
.toString()
10+
.trim()
11+
.split('\n')
12+
.find(r => ~r.indexOf('M '))
13+
?.replace(/(\/)/g, '%%')
14+
?.match(/components%%((\w|-)*)/)?.[1];
15+
16+
/** @type {import('cz-git').CommitizenGitOptions} */
17+
module.exports = {
18+
scopes: ['site', 'util', 'script', 'tool', ...components],
19+
scopeFilters: ['__tests__', '_util'],
20+
customScopesAlign: !scopeComplete ? 'top' : 'bottom',
21+
defaultScope: scopeComplete,
22+
maxHeaderLength: 100,
23+
allowEmptyIssuePrefixs: false,
24+
allowCustomIssuePrefixs: false,
25+
};

0 commit comments

Comments
 (0)