chore: use cz-git commitizen adapter (#8105)

This commit is contained in:
zhengqbbb 2022-06-08 02:10:21 +08:00 committed by GitHub
parent 8413f8ea31
commit c7ecf70969
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 41 deletions

View File

@ -1,25 +1,20 @@
const {
default: getWorkspacePackages,
} = require('@pnpm/find-workspace-packages')
'use strict'
const { execSync } = require('child_process')
const fg = require('fast-glob')
async function getPackages(context) {
const ctx = context || {}
const cwd = ctx.cwd || process.cwd()
const packages = await getWorkspacePackages(cwd)
return packages
.map((pkg) => pkg.manifest.name)
.filter((name) => !!name)
.map((name) => (name.charAt(0) === '@' ? name.split('/')[1] : name))
}
const getPackages = (packagePath) =>
fg.sync('*', { cwd: packagePath, onlyDirectories: true })
const scopes = [
...getPackages('packages'),
...getPackages('internal'),
'docs',
'play',
'project',
'core',
'style',
'docs',
'ci',
'dev',
'build',
'deploy',
'other',
'typography',
@ -29,18 +24,28 @@ const scopes = [
'ssr',
]
const gitStatus = execSync('git status --porcelain || true')
.toString()
.trim()
.split('\n')
const scopeComplete = gitStatus
.find((r) => ~r.indexOf('M packages'))
?.replace(/\//g, '%%')
?.match(/packages%%((\w|-)*)/)?.[1]
const subjectComplete = gitStatus
.find((r) => ~r.indexOf('M packages/components'))
?.replace(/\//g, '%%')
?.match(/packages%%components%%((\w|-)*)/)?.[1]
module.exports = {
rules: {
/**
* type[scope]: [function] description
* ^^^^^
*/
'scope-enum': (ctx) =>
getPackages(ctx).then((packages) => [
2,
'always',
[...packages, ...scopes],
]),
'scope-enum': [2, 'always', scopes],
/**
* type[scope]: [function] description
*
@ -95,4 +100,11 @@ module.exports = {
],
],
},
prompt: {
defaultScope: scopeComplete,
customScopesAlign: !scopeComplete ? 'top' : 'bottom',
defaultSubject: subjectComplete && `[${subjectComplete}] `,
allowCustomIssuePrefixs: false,
allowEmptyIssuePrefixs: false,
},
}

View File

@ -89,10 +89,11 @@
"@vue/tsconfig": "^0.1.3",
"c8": "^7.11.3",
"chalk": "^5.0.1",
"commitizen": "^4.2.4",
"concurrently": "^7.2.1",
"consola": "^2.15.3",
"csstype": "^2.6.20",
"cz-conventional-changelog": "^3.3.0",
"cz-git": "^1.3.4",
"eslint": "^8.17.0",
"eslint-define-config": "^1.5.1",
"expect-type": "^0.13.0",
@ -123,7 +124,7 @@
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
"path": "./node_modules/cz-git"
}
},
"pnpm": {

View File

@ -40,10 +40,11 @@ importers:
async-validator: ^4.1.1
c8: ^7.11.3
chalk: ^5.0.1
commitizen: ^4.2.4
concurrently: ^7.2.1
consola: ^2.15.3
csstype: ^2.6.20
cz-conventional-changelog: ^3.3.0
cz-git: ^1.3.4
dayjs: ^1.11.3
escape-html: ^1.0.3
eslint: ^8.17.0
@ -120,10 +121,11 @@ importers:
'@vue/tsconfig': 0.1.3_@types+node@17.0.40
c8: 7.11.3
chalk: 5.0.1
commitizen: 4.2.4
concurrently: 7.2.1
consola: 2.15.3
csstype: 2.6.20
cz-conventional-changelog: 3.3.0
cz-git: 1.3.4
eslint: 8.17.0
eslint-define-config: 1.5.1
expect-type: 0.13.0
@ -4850,21 +4852,8 @@ packages:
- '@swc/wasm'
dev: true
/cz-conventional-changelog/3.3.0:
resolution: {integrity: sha512-U466fIzU5U22eES5lTNiNbZ+d8dfcHcssH4o7QsdWaCcRs/feIPCxKYSWkYBNs5mny7MvEfwpTLWjvbm94hecw==}
engines: {node: '>= 10'}
dependencies:
chalk: 2.4.2
commitizen: 4.2.4
conventional-commit-types: 3.0.0
lodash.map: 4.6.0
longest: 2.0.1
word-wrap: 1.2.3
optionalDependencies:
'@commitlint/load': 17.0.0
transitivePeerDependencies:
- '@swc/core'
- '@swc/wasm'
/cz-git/1.3.4:
resolution: {integrity: sha512-px5btT/cux7LYD4v7jB7wXtVV2l5txTnO1R9rBeevsBhgJv+kHkIPcWzRx+Fr5HR/45l/jf1sIVIYRrhPKWo6A==}
dev: true
/d/1.0.1:
@ -4962,7 +4951,7 @@ packages:
dev: false
/dedent/0.7.0:
resolution: {integrity: sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=}
resolution: {integrity: sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==}
dev: true
/deep-eql/3.0.1:
@ -9685,7 +9674,7 @@ packages:
supports-preserve-symlinks-flag: 1.0.0
/restore-cursor/2.0.0:
resolution: {integrity: sha512-6IzJLuGi4+R14vwagDHX+JrXmPVtPpn4mffDJ1UdR7/Edm87fl6yi8mMBIVvFtJaNTUvjughmW4hwLhRG7gC1Q==}
resolution: {integrity: sha1-n37ih/gv0ybU/RYpI9YhKe7g368=}
engines: {node: '>=4'}
dependencies:
onetime: 2.0.1