Browse Source

chore: use `czg` commitizen adapter (#5750)

pull/5766/head
zhengqbbb 2 years ago committed by GitHub
parent
commit
d94fe1c0b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      package.json
  2. 25
      scripts/commitizen.js

7
package.json

@ -149,6 +149,7 @@
"cross-env": "^7.0.0",
"css-loader": "^5.0.0",
"css-minimizer-webpack-plugin": "^3.0.0",
"cz-git": "^1.3.8",
"date-fns": "^2.24.0",
"diacritics": "^1.3.0",
"docsearch.js": "^2.6.3",
@ -298,5 +299,11 @@
"tags": "vetur/tags.json",
"attributes": "vetur/attributes.json"
},
"config": {
"commitizen": {
"path": "node_modules/cz-git",
"czConfig": "./scripts/commitizen.js"
}
},
"web-types": "vetur/web-types.json"
}

25
scripts/commitizen.js

@ -0,0 +1,25 @@
'use strict';
const { execSync } = require('child_process');
const fg = require('fast-glob');
const components = fg.sync('*', { cwd: 'components', onlyDirectories: true });
// precomputed scope
const scopeComplete = execSync('git status --porcelain || true')
.toString()
.trim()
.split('\n')
.find(r => ~r.indexOf('M '))
?.replace(/(\/)/g, '%%')
?.match(/components%%((\w|-)*)/)?.[1];
/** @type {import('cz-git').CommitizenGitOptions} */
module.exports = {
scopes: ['site', 'util', 'script', 'tool', ...components],
scopeFilters: ['__tests__', '_util'],
customScopesAlign: !scopeComplete ? 'top' : 'bottom',
defaultScope: scopeComplete,
maxHeaderLength: 100,
allowEmptyIssuePrefixs: false,
allowCustomIssuePrefixs: false,
};
Loading…
Cancel
Save