commit-pack 1.0.14 → 1.0.16
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/README.md +45 -144
- package/bin/index.mjs +11 -0
- package/lib/index.mjs +11 -0
- package/package.json +1 -1
- package/setup-script/cz-config.sh +12 -12
- package/setup-script/prettier.sh +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# auto-commit
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
3
|
+
## 1. 概述
|
|
4
4
|
|
|
5
5
|
Eslint 代码质量
|
|
6
6
|
|
|
@@ -20,56 +20,44 @@ commitizen 自动化脚本生成 commit message
|
|
|
20
20
|
|
|
21
21
|
vscode 插件
|
|
22
22
|
|
|
23
|
-
## 2.
|
|
23
|
+
## 2. 快速入门
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
</br>
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
pnpm add -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
|
|
27
|
+
### 🚀 安装
|
|
29
28
|
```
|
|
30
|
-
|
|
31
|
-
==.eslintrc==
|
|
32
|
-
|
|
33
|
-
```json
|
|
34
|
-
{
|
|
35
|
-
// 表示这是根配置文件,ESLint 不会在父目录中查找其他配置文件。
|
|
36
|
-
"root": true,
|
|
37
|
-
// 指定要使用的解析器,这里是 TypeScript 的解析器。
|
|
38
|
-
"parser": "@typescript-eslint/parser",
|
|
39
|
-
"extends": [
|
|
40
|
-
// 扩展 ESLint 推荐的规则。
|
|
41
|
-
"eslint:recommended",
|
|
42
|
-
// 扩展 @typescript-eslint/eslint-plugin 推荐的规则。
|
|
43
|
-
"plugin:@typescript-eslint/recommended",
|
|
44
|
-
// 扩展 @typescript-eslint/eslint-plugin 推荐的规则,禁用与 eslint:recommended 冲突的规则。
|
|
45
|
-
"plugin:@typescript-eslint/eslint-recommended"
|
|
46
|
-
],
|
|
47
|
-
// 指定要使用的插件,这里是 @typescript-eslint 插件。
|
|
48
|
-
"plugins": ["@typescript-eslint"]
|
|
49
|
-
}
|
|
29
|
+
pnpm add -D commit-pack@latest
|
|
50
30
|
```
|
|
31
|
+
```
|
|
32
|
+
bun add -d commit-pack@latest
|
|
33
|
+
```
|
|
34
|
+
```
|
|
35
|
+
npm i -D commit-pack@latest
|
|
36
|
+
```
|
|
37
|
+
```
|
|
38
|
+
yarn add -D commit-pack@latest
|
|
39
|
+
```
|
|
40
|
+
</br>
|
|
51
41
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
### 🍀 初始化
|
|
43
|
+
```
|
|
44
|
+
pnpm exec commit-pack-init
|
|
45
|
+
```
|
|
46
|
+
```
|
|
47
|
+
bux commit-pack-init
|
|
48
|
+
```
|
|
49
|
+
```
|
|
50
|
+
npx commit-pack-init
|
|
51
|
+
```
|
|
52
|
+
```
|
|
53
|
+
yarn dlx commit-pack-init
|
|
58
54
|
```
|
|
59
55
|
|
|
60
|
-
脚本
|
|
61
56
|
|
|
62
|
-
```json
|
|
63
|
-
"lint": "eslint ./ --ext .ts,.tsx,.json --max-warnings=0",
|
|
64
|
-
```
|
|
65
57
|
|
|
66
|
-
### 🍀 prettier
|
|
67
58
|
|
|
68
|
-
```sh
|
|
69
|
-
pnpm add -D prettier
|
|
70
|
-
```
|
|
71
59
|
|
|
72
|
-
|
|
60
|
+
**.prettierrc**
|
|
73
61
|
|
|
74
62
|
```json
|
|
75
63
|
{
|
|
@@ -85,54 +73,44 @@ pnpm add -D prettier
|
|
|
85
73
|
}
|
|
86
74
|
```
|
|
87
75
|
|
|
88
|
-
==.prettierrcignore==
|
|
89
|
-
|
|
90
|
-
```json
|
|
91
|
-
node_modules/
|
|
92
|
-
|
|
93
|
-
README.md
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
脚本
|
|
97
76
|
|
|
98
|
-
```json
|
|
99
|
-
"format": "prettier --config .prettierrc '.' --write"
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### 🍀 eslint-config-prettier && eslint-plugin-prettier
|
|
103
77
|
|
|
104
|
-
|
|
105
|
-
pnpm add -D eslint-config-prettier eslint-plugin-prettier
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
==.eslintrc==
|
|
78
|
+
**.eslintrc**
|
|
109
79
|
|
|
110
80
|
````json
|
|
111
81
|
{
|
|
112
|
-
//
|
|
82
|
+
// 这是根配置文件,ESLint 不会在父目录中查找其他配置文件。
|
|
113
83
|
"root": true,
|
|
84
|
+
|
|
114
85
|
// 指定要使用的解析器,这里是 TypeScript 的解析器。
|
|
115
86
|
"parser": "@typescript-eslint/parser",
|
|
87
|
+
|
|
116
88
|
"extends": [
|
|
117
|
-
// 扩展 ESLint
|
|
89
|
+
// 扩展 ESLint 推荐的规则
|
|
118
90
|
"eslint:recommended",
|
|
119
|
-
|
|
91
|
+
|
|
92
|
+
// 扩展 @typescript-eslint/eslint-plugin 推荐规则
|
|
120
93
|
"plugin:@typescript-eslint/recommended",
|
|
121
|
-
|
|
94
|
+
|
|
95
|
+
// 扩展 @typescript-eslint/eslint-plugin 推荐的规则,禁用与 eslint:recommended 冲突的规则
|
|
122
96
|
"plugin:@typescript-eslint/eslint-recommended",
|
|
123
|
-
|
|
97
|
+
|
|
98
|
+
// 扩展 Prettier 配置以禁用可能与 Prettier 冲突的 ESLint 规则 即 eslint-config-prettier 确保放在最后
|
|
124
99
|
"prettier"
|
|
125
100
|
],
|
|
126
|
-
|
|
101
|
+
|
|
127
102
|
"plugins": [
|
|
128
103
|
"@typescript-eslint",
|
|
129
104
|
"prettier"
|
|
130
105
|
],
|
|
106
|
+
|
|
131
107
|
"rules": {
|
|
132
108
|
// 将 Prettier 格式化强制为 ESLint 错误。
|
|
133
109
|
"prettier/prettier": "error",
|
|
110
|
+
|
|
134
111
|
// 禁用强制在箭头函数体周围使用大括号的规则。
|
|
135
112
|
"arrow-body-style": "off",
|
|
113
|
+
|
|
136
114
|
// 禁用强制为回调使用箭头函数的规则。
|
|
137
115
|
"prefer-arrow-callback": "off"
|
|
138
116
|
}
|
|
@@ -140,55 +118,8 @@ pnpm add -D eslint-config-prettier eslint-plugin-prettier
|
|
|
140
118
|
```
|
|
141
119
|
````
|
|
142
120
|
|
|
143
|
-
### 🍀 husky
|
|
144
|
-
|
|
145
|
-
```sh
|
|
146
|
-
pnpm add -D husky
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
```sh
|
|
150
|
-
pnpm exec husky init
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
脚本
|
|
154
|
-
|
|
155
|
-
```
|
|
156
|
-
"prepare": "husky install"
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
==.husky/pre-commit==
|
|
160
|
-
|
|
161
|
-
```
|
|
162
|
-
pnpm run lint
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### 🍀 int-staged
|
|
166
|
-
|
|
167
|
-
```sh
|
|
168
|
-
pnpm add -D lint-staged
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
==.lintstagedrc==
|
|
172
121
|
|
|
173
|
-
|
|
174
|
-
{
|
|
175
|
-
"*.{js,jsx,ts,tsx}": ["eslint --fix", "prettier --write"]
|
|
176
|
-
}
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
==更改 .husky/pre-commit==
|
|
180
|
-
|
|
181
|
-
```
|
|
182
|
-
npx lint-staged
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### 🍀 commitlint
|
|
186
|
-
|
|
187
|
-
```sh
|
|
188
|
-
pnpm add -D @commitlint/cli @commitlint/config-conventional
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
==.commitlintrc.json==
|
|
122
|
+
**.commitlintrc.json**
|
|
192
123
|
|
|
193
124
|
```json
|
|
194
125
|
{
|
|
@@ -223,27 +154,7 @@ npx lint-staged
|
|
|
223
154
|
}
|
|
224
155
|
```
|
|
225
156
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
```sh
|
|
229
|
-
echo 'npx --no -- commitlint --edit "$1"' > .husky/commit-msg
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### 🍀 commitizen
|
|
233
|
-
|
|
234
|
-
```sh
|
|
235
|
-
pnpm add -D commitizen@4.2.4 commitlint-config-cz cz-customizabl cz-custom
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
==.czrc==
|
|
239
|
-
|
|
240
|
-
```json
|
|
241
|
-
{
|
|
242
|
-
"path": "cz-customizable"
|
|
243
|
-
}
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
==.cz-config.js==
|
|
157
|
+
**.cz-config.js**
|
|
247
158
|
|
|
248
159
|
```js
|
|
249
160
|
module.exports = {
|
|
@@ -287,13 +198,3 @@ module.exports = {
|
|
|
287
198
|
subjectLimit: 49,
|
|
288
199
|
};
|
|
289
200
|
```
|
|
290
|
-
|
|
291
|
-
==package.json==
|
|
292
|
-
|
|
293
|
-
```json
|
|
294
|
-
"config": {
|
|
295
|
-
"commitizen": {
|
|
296
|
-
"path": "node_modules/cz-customizable"
|
|
297
|
-
}
|
|
298
|
-
},
|
|
299
|
-
```
|
package/bin/index.mjs
CHANGED
|
@@ -37,6 +37,13 @@ console.log(chalk.green(`检测到使用的包管理器:${packageManager}`))
|
|
|
37
37
|
const packageJsonPath = path.join(projectRoot, 'package.json')
|
|
38
38
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
|
|
39
39
|
|
|
40
|
+
// 检查是否已经初始化过
|
|
41
|
+
const initFlagPath = path.join(projectRoot, '.commit-pack-init')
|
|
42
|
+
if (fs.existsSync(initFlagPath)) {
|
|
43
|
+
console.log(chalk.yellow('已检测到初始化标志文件,跳过初始化'))
|
|
44
|
+
process.exit(0)
|
|
45
|
+
}
|
|
46
|
+
|
|
40
47
|
// 确保 devDependencies 存在
|
|
41
48
|
if (!packageJson.devDependencies) {
|
|
42
49
|
packageJson.devDependencies = {}
|
|
@@ -214,3 +221,7 @@ if (modified) {
|
|
|
214
221
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8')
|
|
215
222
|
console.log(chalk.green('已更新 package.json'))
|
|
216
223
|
}
|
|
224
|
+
|
|
225
|
+
// 创建初始化标志文件
|
|
226
|
+
fs.writeFileSync(initFlagPath, 'initialized', 'utf8')
|
|
227
|
+
console.log(chalk.green('已创建初始化标志文件'))
|
package/lib/index.mjs
CHANGED
|
@@ -35,6 +35,13 @@ console.log(_chalk.default.green(`检测到使用的包管理器:${packageMana
|
|
|
35
35
|
const packageJsonPath = _path.default.join(projectRoot, 'package.json');
|
|
36
36
|
const packageJson = JSON.parse(_fs.default.readFileSync(packageJsonPath, 'utf8'));
|
|
37
37
|
|
|
38
|
+
// 检查是否已经初始化过
|
|
39
|
+
const initFlagPath = _path.default.join(projectRoot, '.commit-pack-init');
|
|
40
|
+
if (_fs.default.existsSync(initFlagPath)) {
|
|
41
|
+
console.log(_chalk.default.yellow('已检测到初始化标志文件,跳过初始化'));
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
|
|
38
45
|
// 确保 devDependencies 存在
|
|
39
46
|
if (!packageJson.devDependencies) {
|
|
40
47
|
packageJson.devDependencies = {};
|
|
@@ -188,3 +195,7 @@ if (modified) {
|
|
|
188
195
|
_fs.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), 'utf8');
|
|
189
196
|
console.log(_chalk.default.green('已更新 package.json'));
|
|
190
197
|
}
|
|
198
|
+
|
|
199
|
+
// 创建初始化标志文件
|
|
200
|
+
_fs.default.writeFileSync(initFlagPath, 'initialized', 'utf8');
|
|
201
|
+
console.log(_chalk.default.green('已创建初始化标志文件'));
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
cat > .cz-config.js << 'EOF'
|
|
2
2
|
module.exports = {
|
|
3
3
|
types: [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
{ value: '✨ feat', name: ' ✨ feat: 新功能' },
|
|
5
|
+
{ value: '🐛 fix', name: ' 🐛 fix: 修复bug' },
|
|
6
|
+
{ value: '🎉 init', name: ' 🎉 init: 初始化' },
|
|
7
|
+
{ value: '📗 docs', name: ' 📗 docs: 文档变更' },
|
|
8
|
+
{ value: '🌈 style', name: ' 🌈 style: 更改样式' },
|
|
9
|
+
{ value: '🍀 refactor', name: ' 🍀 refactor: 重构' },
|
|
10
|
+
{ value: '🔥 perf', name: ' 🔥 perf: 性能优化' },
|
|
11
|
+
{ value: '✅ test', name: ' ✅ test: 测试' },
|
|
12
|
+
{ value: '⏪️ revert', name: ' ⏪️ revert: 回退' },
|
|
13
|
+
{ value: '📦 build', name: ' 📦 build: 打包' },
|
|
14
|
+
{ value: '🚀 chore', name: ' 🚀 chore: 构建/工程依赖/工具' },
|
|
15
|
+
{ value: '👷 ci', name: ' 👷 ci: CI related changes' }
|
|
16
16
|
],
|
|
17
17
|
|
|
18
18
|
scopes: [
|