@itcase/config 1.6.45 → 1.6.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commitlint/commitizenAdapter.js +123 -0
- package/commitlint/commitlintCommon.js +34 -0
- package/commitlint/commitlintCreateConfig.js +40 -0
- package/commitlint/commitlintProject.js +11 -14
- package/commitlint/commitlintRelease.js +11 -14
- package/commitlint/index.js +14 -3
- package/package.json +9 -9
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Commitizen adapter: type → scope → subScope (optional) → subject.
|
|
3
|
+
* Settings from commitlintProject.js; SCOPES from project commitlint.config.mjs.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import path from 'path'
|
|
7
|
+
import { pathToFileURL } from 'url'
|
|
8
|
+
|
|
9
|
+
const SUB_SCOPE_MESSAGE = 'Select sub-scope (optional):'
|
|
10
|
+
const SUBJECT_REQUIRED = 'Subject is required'
|
|
11
|
+
|
|
12
|
+
function buildScope(scope, subScope) {
|
|
13
|
+
if (!scope) return ''
|
|
14
|
+
if (!subScope) return scope
|
|
15
|
+
return `${scope} / ${subScope}`
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function toChoices(values) {
|
|
19
|
+
return values.map((value) => ({ name: value, value }))
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function buildTypeChoices(types, typeEnum) {
|
|
23
|
+
return types.map((value) => {
|
|
24
|
+
const meta = typeEnum?.[value]
|
|
25
|
+
const name = meta
|
|
26
|
+
? [meta.emoji, value, meta.description].filter(Boolean).join(': ')
|
|
27
|
+
: value
|
|
28
|
+
return { name, value }
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function loadConfig() {
|
|
33
|
+
const [{ default: load }, { commitlintProject }] = await Promise.all([
|
|
34
|
+
import('@commitlint/load'),
|
|
35
|
+
import('./commitlintProject.js'),
|
|
36
|
+
])
|
|
37
|
+
|
|
38
|
+
const { prompt: promptOverrides, rules } = await load()
|
|
39
|
+
|
|
40
|
+
const configPath = path.resolve(process.cwd(), 'commitlint.config.mjs')
|
|
41
|
+
const configModule = await import(pathToFileURL(configPath).href)
|
|
42
|
+
const SCOPES = configModule.default?.SCOPES || {}
|
|
43
|
+
|
|
44
|
+
return { commitlintProject, promptOverrides, rules, SCOPES }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function prompter(inquirer, commit) {
|
|
48
|
+
;(async () => {
|
|
49
|
+
try {
|
|
50
|
+
const { commitlintProject, promptOverrides, rules, SCOPES } =
|
|
51
|
+
await loadConfig()
|
|
52
|
+
|
|
53
|
+
const q = commitlintProject.prompt.questions
|
|
54
|
+
const over = promptOverrides?.questions
|
|
55
|
+
|
|
56
|
+
const scopeEnum = rules['scope-enum']?.[2]
|
|
57
|
+
const types =
|
|
58
|
+
rules['type-enum']?.[2] ?? commitlintProject.rules['type-enum'][2]
|
|
59
|
+
const typeEnum = over?.type?.enum ?? q.type.enum
|
|
60
|
+
const typeChoices = buildTypeChoices(types, typeEnum)
|
|
61
|
+
|
|
62
|
+
const baseScopes = Array.isArray(scopeEnum)
|
|
63
|
+
? scopeEnum.filter((s) => !s.includes(' / '))
|
|
64
|
+
: Object.keys(SCOPES)
|
|
65
|
+
const scopeList = baseScopes.length > 0 ? baseScopes : Object.keys(SCOPES)
|
|
66
|
+
|
|
67
|
+
const messages = {
|
|
68
|
+
type: over?.type?.description ?? q.type.description,
|
|
69
|
+
scope: over?.scope?.description ?? q.scope.description,
|
|
70
|
+
subject: over?.subject?.description ?? q.subject.description,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const answers = await inquirer.prompt([
|
|
74
|
+
{
|
|
75
|
+
type: 'list',
|
|
76
|
+
name: 'type',
|
|
77
|
+
message: messages.type,
|
|
78
|
+
choices: typeChoices,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
type: 'list',
|
|
82
|
+
name: 'scope',
|
|
83
|
+
message: messages.scope,
|
|
84
|
+
choices: toChoices(scopeList),
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
type: 'list',
|
|
88
|
+
name: 'subScope',
|
|
89
|
+
message: SUB_SCOPE_MESSAGE,
|
|
90
|
+
choices: function (answers) {
|
|
91
|
+
const subs = SCOPES[answers.scope] || []
|
|
92
|
+
return [
|
|
93
|
+
...toChoices(subs),
|
|
94
|
+
new inquirer.Separator(),
|
|
95
|
+
{ name: 'None', value: '' },
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
when: function (answers) {
|
|
99
|
+
const subs = SCOPES[answers.scope]
|
|
100
|
+
return answers.scope && subs?.length > 0
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
type: 'input',
|
|
105
|
+
name: 'subject',
|
|
106
|
+
message: messages.subject,
|
|
107
|
+
validate: (input) => (input?.trim() ? true : SUBJECT_REQUIRED),
|
|
108
|
+
},
|
|
109
|
+
])
|
|
110
|
+
|
|
111
|
+
const scope = buildScope(answers.scope, answers.subScope)
|
|
112
|
+
const header = scope
|
|
113
|
+
? `${answers.type}(${scope}): ${answers.subject.trim()}`
|
|
114
|
+
: `${answers.type}: ${answers.subject.trim()}`
|
|
115
|
+
commit(header)
|
|
116
|
+
} catch (err) {
|
|
117
|
+
console.error(err)
|
|
118
|
+
process.exit(1)
|
|
119
|
+
}
|
|
120
|
+
})()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export { prompter }
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared commitlint config: rules and prompt texts used by commitlintProject and commitlintRelease.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export const parserPreset = 'conventional-changelog-conventionalcommits'
|
|
6
|
+
|
|
7
|
+
export const defaultIgnores = true
|
|
8
|
+
|
|
9
|
+
export const commonRules = {
|
|
10
|
+
'body-empty': [1, 'always'],
|
|
11
|
+
'footer-empty': [1, 'always'],
|
|
12
|
+
'scope-empty': [2, 'never'],
|
|
13
|
+
'subject-case': [2, 'always', ['lower-case', 'sentence-case', 'start-case']],
|
|
14
|
+
'subject-empty': [2, 'never'],
|
|
15
|
+
'type-empty': [2, 'never'],
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const promptSubjectDescription =
|
|
19
|
+
'Write a short, imperative tense description of the change'
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Builds flat scope-enum list from SCOPES: base scopes + "scope / subScope".
|
|
23
|
+
* @param {Record<string, string[]>} scopeSubscopes
|
|
24
|
+
* @returns {string[]}
|
|
25
|
+
*/
|
|
26
|
+
export function buildScopeEnum(scopeSubscopes) {
|
|
27
|
+
const base = Object.keys(scopeSubscopes)
|
|
28
|
+
return [
|
|
29
|
+
...base,
|
|
30
|
+
...base.flatMap((scope) =>
|
|
31
|
+
(scopeSubscopes[scope] || []).map((sub) => `${scope} / ${sub}`),
|
|
32
|
+
),
|
|
33
|
+
]
|
|
34
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory: commitlint config with scope-enum from SCOPES.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { buildScopeEnum } from './commitlintCommon.js'
|
|
6
|
+
import { commitlintProject } from './commitlintProject.js'
|
|
7
|
+
import { commitlintRelease } from './commitlintRelease.js'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {object} baseConfig
|
|
11
|
+
* @param {Record<string, string[]>} scopes
|
|
12
|
+
* @returns {object}
|
|
13
|
+
*/
|
|
14
|
+
function createConfig(baseConfig, scopes) {
|
|
15
|
+
const scopeEnum = buildScopeEnum(scopes)
|
|
16
|
+
return {
|
|
17
|
+
...baseConfig,
|
|
18
|
+
rules: {
|
|
19
|
+
...baseConfig.rules,
|
|
20
|
+
'scope-enum': [2, 'always', scopeEnum],
|
|
21
|
+
},
|
|
22
|
+
SCOPES: scopes,
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {Record<string, string[]>} scopes
|
|
28
|
+
* @returns {object}
|
|
29
|
+
*/
|
|
30
|
+
export function createCommitlintProjectConfig(scopes) {
|
|
31
|
+
return createConfig(commitlintProject, scopes)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {Record<string, string[]>} scopes
|
|
36
|
+
* @returns {object}
|
|
37
|
+
*/
|
|
38
|
+
export function createCommitlintReleaseConfig(scopes) {
|
|
39
|
+
return createConfig(commitlintRelease, scopes)
|
|
40
|
+
}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
/* eslint-disable perfectionist/sort-objects */
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
commonRules,
|
|
5
|
+
defaultIgnores,
|
|
6
|
+
parserPreset,
|
|
7
|
+
promptSubjectDescription,
|
|
8
|
+
} from './commitlintCommon.js'
|
|
9
|
+
|
|
3
10
|
const commitlintProject = {
|
|
4
|
-
parserPreset
|
|
11
|
+
parserPreset,
|
|
5
12
|
ignores: [
|
|
6
13
|
(commit) => /^Merge branch/.test(commit),
|
|
7
14
|
(commit) => /^Merge pull request/.test(commit),
|
|
8
15
|
],
|
|
9
16
|
rules: {
|
|
17
|
+
...commonRules,
|
|
10
18
|
'type-case': [2, 'always', 'lower-case'],
|
|
11
|
-
'type-empty': [2, 'never'],
|
|
12
19
|
'type-enum': [
|
|
13
20
|
2,
|
|
14
21
|
'always',
|
|
@@ -24,18 +31,9 @@ const commitlintProject = {
|
|
|
24
31
|
'other',
|
|
25
32
|
],
|
|
26
33
|
],
|
|
27
|
-
'body-empty': [1, 'always'],
|
|
28
|
-
'subject-case': [
|
|
29
|
-
2,
|
|
30
|
-
'always',
|
|
31
|
-
['lower-case', 'sentence-case', 'start-case'],
|
|
32
|
-
],
|
|
33
|
-
'subject-empty': [2, 'never'],
|
|
34
|
-
'footer-empty': [1, 'always'],
|
|
35
|
-
'scope-empty': [2, 'never'],
|
|
36
34
|
'scope-enum': [2, 'always', ['PLEASE', 'SET', 'SCOPE-ENUM']],
|
|
37
35
|
},
|
|
38
|
-
defaultIgnores
|
|
36
|
+
defaultIgnores,
|
|
39
37
|
prompt: {
|
|
40
38
|
settings: {
|
|
41
39
|
enableMultipleScopes: true,
|
|
@@ -96,8 +94,7 @@ const commitlintProject = {
|
|
|
96
94
|
description: 'What is the scope of this change',
|
|
97
95
|
},
|
|
98
96
|
subject: {
|
|
99
|
-
description:
|
|
100
|
-
'Write a short, imperative tense description of the change',
|
|
97
|
+
description: promptSubjectDescription,
|
|
101
98
|
},
|
|
102
99
|
},
|
|
103
100
|
},
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
/* eslint-disable perfectionist/sort-objects */
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
commonRules,
|
|
5
|
+
defaultIgnores,
|
|
6
|
+
parserPreset,
|
|
7
|
+
promptSubjectDescription,
|
|
8
|
+
} from './commitlintCommon.js'
|
|
9
|
+
|
|
3
10
|
const commitlintRelease = {
|
|
4
|
-
parserPreset
|
|
11
|
+
parserPreset,
|
|
5
12
|
extends: ['@commitlint/config-conventional'],
|
|
6
13
|
rules: {
|
|
14
|
+
...commonRules,
|
|
7
15
|
'type-case': [0],
|
|
8
|
-
'body-empty': [1, 'always'],
|
|
9
|
-
'subject-empty': [2, 'never'],
|
|
10
|
-
'subject-case': [
|
|
11
|
-
2,
|
|
12
|
-
'always',
|
|
13
|
-
['lower-case', 'sentence-case', 'start-case'],
|
|
14
|
-
],
|
|
15
|
-
'type-empty': [2, 'never'],
|
|
16
|
-
'scope-empty': [2, 'never'],
|
|
17
|
-
'footer-empty': [1, 'always'],
|
|
18
16
|
'type-enum': [2, 'always', ['patch', 'minor', 'major']],
|
|
19
17
|
},
|
|
20
|
-
defaultIgnores
|
|
18
|
+
defaultIgnores,
|
|
21
19
|
prompt: {
|
|
22
20
|
settings: {},
|
|
23
21
|
questions: {
|
|
@@ -43,8 +41,7 @@ const commitlintRelease = {
|
|
|
43
41
|
},
|
|
44
42
|
},
|
|
45
43
|
subject: {
|
|
46
|
-
description:
|
|
47
|
-
'Write a short, imperative tense description of the change',
|
|
44
|
+
description: promptSubjectDescription,
|
|
48
45
|
},
|
|
49
46
|
},
|
|
50
47
|
},
|
package/commitlint/index.js
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export {
|
|
2
|
+
buildScopeEnum,
|
|
3
|
+
commonRules,
|
|
4
|
+
defaultIgnores,
|
|
5
|
+
parserPreset,
|
|
6
|
+
promptSubjectDescription,
|
|
7
|
+
} from './commitlintCommon.js'
|
|
3
8
|
|
|
4
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
createCommitlintProjectConfig,
|
|
11
|
+
createCommitlintReleaseConfig,
|
|
12
|
+
} from './commitlintCreateConfig.js'
|
|
13
|
+
|
|
14
|
+
export { commitlintProject } from './commitlintProject.js'
|
|
15
|
+
export { commitlintRelease } from './commitlintRelease.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itcase/config",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.46",
|
|
4
4
|
"author": "ITCase",
|
|
5
5
|
"description": "ITCase Config",
|
|
6
6
|
"engines": {
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
"@lerna-lite/list": "^4.11.0",
|
|
37
37
|
"@lerna-lite/run": "^4.11.1",
|
|
38
38
|
"@lerna-lite/watch": "^4.11.0",
|
|
39
|
-
"semantic-release-lerna": "^2.
|
|
39
|
+
"semantic-release-lerna": "^2.17.0",
|
|
40
40
|
"chokidar-cli": "^3.0.0",
|
|
41
|
-
"@commitlint/cli": "^20.
|
|
42
|
-
"@commitlint/config-conventional": "^20.
|
|
43
|
-
"@commitlint/cz-commitlint": "^20.
|
|
41
|
+
"@commitlint/cli": "^20.4.1",
|
|
42
|
+
"@commitlint/config-conventional": "^20.4.1",
|
|
43
|
+
"@commitlint/cz-commitlint": "^20.4.1",
|
|
44
44
|
"@lehoczky/postcss-fluid": "^1.0.3",
|
|
45
45
|
"@semantic-release/changelog": "^6.0.3",
|
|
46
46
|
"@semantic-release/git": "^10.0.1",
|
|
47
47
|
"@semantic-release/release-notes-generator": "14.1.0",
|
|
48
48
|
"@svgr/webpack": "^8.1.0",
|
|
49
|
-
"autoprefixer": "^10.4.
|
|
49
|
+
"autoprefixer": "^10.4.24",
|
|
50
50
|
"commitizen": "^4.3.1",
|
|
51
51
|
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
52
52
|
"cssnano": "^7.1.2",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"postcss-nested-ancestors": "^3.0.0",
|
|
77
77
|
"postcss-normalize": "^13.0.1",
|
|
78
78
|
"postcss-prepend-imports": "^1.0.1",
|
|
79
|
-
"postcss-preset-env": "^11.1.
|
|
79
|
+
"postcss-preset-env": "^11.1.3",
|
|
80
80
|
"postcss-pxtorem": "^6.1.0",
|
|
81
81
|
"postcss-sort-media-queries": "^5.2.0",
|
|
82
82
|
"postcss-unit": "^0.0.3",
|
|
@@ -99,13 +99,13 @@
|
|
|
99
99
|
"postcss-urlrewrite": "^0.3.0"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
|
-
"@itcase/lint": "^1.1.
|
|
102
|
+
"@itcase/lint": "^1.1.95",
|
|
103
103
|
"eslint": "^9.39.2",
|
|
104
104
|
"husky": "^9.1.7",
|
|
105
105
|
"inquirer": "^13.2.2",
|
|
106
106
|
"lint-staged": "^16.2.7",
|
|
107
107
|
"prettier": "^3.8.1",
|
|
108
|
-
"stylelint": "^17.
|
|
108
|
+
"stylelint": "^17.1.1",
|
|
109
109
|
"typescript": "^5.9.3"
|
|
110
110
|
}
|
|
111
111
|
}
|