commit-pack 1.0.11 → 1.0.13
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/bin/index.mjs +20 -7
- package/lib/index.mjs +17 -11
- package/package.json +2 -2
- package/setup-script/commitlintrc.sh +2 -3
- package/setup-script/cz-config.sh +42 -0
- package/setup-script/czrc.sh +1 -46
package/bin/index.mjs
CHANGED
|
@@ -103,15 +103,27 @@ if (dependenciesToInstall.length > 0) {
|
|
|
103
103
|
console.log(chalk.yellow('所有开发依赖已安装,无需安装'))
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
let isGitRepo = false
|
|
107
|
+
|
|
108
108
|
try {
|
|
109
|
-
//
|
|
110
|
-
execSync('git rev-parse --
|
|
109
|
+
// 获取 Git 仓库的顶级目录
|
|
110
|
+
const gitTopLevel = execSync('git rev-parse --show-toplevel', { cwd: projectRoot })
|
|
111
|
+
.toString()
|
|
112
|
+
.trim()
|
|
113
|
+
// 比较顶级目录与当前项目目录
|
|
114
|
+
if (path.resolve(gitTopLevel) === path.resolve(projectRoot)) {
|
|
115
|
+
isGitRepo = true
|
|
116
|
+
} else {
|
|
117
|
+
isGitRepo = false
|
|
118
|
+
}
|
|
119
|
+
} catch {
|
|
120
|
+
isGitRepo = false
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (isGitRepo) {
|
|
111
124
|
console.log(chalk.yellow('当前已是一个 Git 仓库'))
|
|
112
|
-
}
|
|
113
|
-
console.
|
|
114
|
-
// 初始化 Git 仓库
|
|
125
|
+
} else {
|
|
126
|
+
console.log(chalk.red('未检测到 Git 仓库,正在初始化...'))
|
|
115
127
|
execSync('git init', { stdio: 'inherit', cwd: projectRoot })
|
|
116
128
|
}
|
|
117
129
|
|
|
@@ -144,6 +156,7 @@ try {
|
|
|
144
156
|
'eslint.sh',
|
|
145
157
|
'czrc.sh',
|
|
146
158
|
'husky.sh',
|
|
159
|
+
'cz-config.sh',
|
|
147
160
|
'commitlintrc.sh'
|
|
148
161
|
]
|
|
149
162
|
|
package/lib/index.mjs
CHANGED
|
@@ -84,19 +84,25 @@ if (dependenciesToInstall.length > 0) {
|
|
|
84
84
|
} else {
|
|
85
85
|
console.log(_chalk.default.yellow('所有开发依赖已安装,无需安装'));
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
// 初始化 Git 仓库
|
|
89
|
-
console.log(_chalk.default.green('初始化 Git 仓库'));
|
|
87
|
+
let isGitRepo = false;
|
|
90
88
|
try {
|
|
91
|
-
//
|
|
92
|
-
(0, _child_process.execSync)('git rev-parse --
|
|
93
|
-
stdio: 'ignore',
|
|
89
|
+
// 获取 Git 仓库的顶级目录
|
|
90
|
+
const gitTopLevel = (0, _child_process.execSync)('git rev-parse --show-toplevel', {
|
|
94
91
|
cwd: projectRoot
|
|
95
|
-
});
|
|
92
|
+
}).toString().trim();
|
|
93
|
+
// 比较顶级目录与当前项目目录
|
|
94
|
+
if (_path.default.resolve(gitTopLevel) === _path.default.resolve(projectRoot)) {
|
|
95
|
+
isGitRepo = true;
|
|
96
|
+
} else {
|
|
97
|
+
isGitRepo = false;
|
|
98
|
+
}
|
|
99
|
+
} catch {
|
|
100
|
+
isGitRepo = false;
|
|
101
|
+
}
|
|
102
|
+
if (isGitRepo) {
|
|
96
103
|
console.log(_chalk.default.yellow('当前已是一个 Git 仓库'));
|
|
97
|
-
}
|
|
98
|
-
console.
|
|
99
|
-
// 初始化 Git 仓库
|
|
104
|
+
} else {
|
|
105
|
+
console.log(_chalk.default.red('未检测到 Git 仓库,正在初始化...'));
|
|
100
106
|
(0, _child_process.execSync)('git init', {
|
|
101
107
|
stdio: 'inherit',
|
|
102
108
|
cwd: projectRoot
|
|
@@ -128,7 +134,7 @@ console.log(_chalk.default.green(`执行 Husky 初始化命令:${huskyInitComm
|
|
|
128
134
|
// 执行 setup-script 中的所有文件
|
|
129
135
|
console.log(_chalk.default.green('执行 setup-script 中的所有文件'));
|
|
130
136
|
try {
|
|
131
|
-
const setupScripts = ['prettier.sh', 'lintstagedrc.sh', 'eslint.sh', 'czrc.sh', 'husky.sh', 'commitlintrc.sh'];
|
|
137
|
+
const setupScripts = ['prettier.sh', 'lintstagedrc.sh', 'eslint.sh', 'czrc.sh', 'husky.sh', 'cz-config.sh', 'commitlintrc.sh'];
|
|
132
138
|
for (const script of setupScripts) {
|
|
133
139
|
const scriptPath = _path.default.join(_dirname, '..', 'setup-script', script);
|
|
134
140
|
console.log(_chalk.default.green(`执行脚本:${scriptPath}`));
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commit-pack",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "A setup package to automatly check project's style and commit configuration",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"commit-pack": "bin/index.mjs"
|
|
7
|
+
"commit-pack-init": "bin/index.mjs"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"bin/",
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
cat > .cz-config.js << 'EOF'
|
|
2
|
+
module.exports = {
|
|
3
|
+
types: [
|
|
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相关修改' }
|
|
16
|
+
],
|
|
17
|
+
|
|
18
|
+
scopes: [
|
|
19
|
+
{ name: 'components' },
|
|
20
|
+
{ name: 'page' },
|
|
21
|
+
{ name: 'css' },
|
|
22
|
+
{ name: 'api' },
|
|
23
|
+
{ name: 'README.md' },
|
|
24
|
+
{ name: 'custom' }
|
|
25
|
+
],
|
|
26
|
+
|
|
27
|
+
messages: {
|
|
28
|
+
type: '请选择提交类型(必填)',
|
|
29
|
+
scope: '请选择文件修改范围(必填):',
|
|
30
|
+
customScope: '请输入自定义文件修改范围(必填)',
|
|
31
|
+
subject: '请简要描述提交(必填)',
|
|
32
|
+
body: '请输入详细描述(可选)',
|
|
33
|
+
breaking: '列出任何破坏性更改(可选)',
|
|
34
|
+
footer: '请输入要关闭的issue(可选)',
|
|
35
|
+
confirmCommit: '确定提交吗?'
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
allowCustomScopes: true,
|
|
39
|
+
allowBreakingChanges: ['✨ feat', '🐛 fix'],
|
|
40
|
+
subjectLimit: 49
|
|
41
|
+
}
|
|
42
|
+
EOF
|
package/setup-script/czrc.sh
CHANGED
|
@@ -2,49 +2,4 @@ echo '
|
|
|
2
2
|
{
|
|
3
3
|
"path": "cz-customizable"
|
|
4
4
|
}
|
|
5
|
-
' > .czrc
|
|
6
|
-
|
|
7
|
-
echo '
|
|
8
|
-
module.exports = {
|
|
9
|
-
types: [
|
|
10
|
-
{ value: '✨ feat', name: ' ✨ feat: 新功能' },
|
|
11
|
-
{ value: '🐛 fix', name: ' 🐛 fix: 修复bug' },
|
|
12
|
-
{ value: '🎉 init', name: ' 🎉 init: 初始化' },
|
|
13
|
-
{ value: '✏️ docs', name: ' ✏️ docs: 文档变更' },
|
|
14
|
-
{ value: '💄 style', name: ' 💄 style: 更改样式' },
|
|
15
|
-
{ value: '♻️ refactor', name: ' ♻️ refactor: 重构' },
|
|
16
|
-
{ value: '⚡️ perf', name: ' ⚡️ perf: 性能优化' },
|
|
17
|
-
{ value: '✅ test', name: ' ✅ test: 测试' },
|
|
18
|
-
{ value: '⏪️ revert', name: ' ⏪️ revert: 回退' },
|
|
19
|
-
{ value: '📦 build', name: ' 📦 build: 打包' },
|
|
20
|
-
{ value: '🚀 chore', name: ' 🚀 chore: 构建/工程依赖/工具' },
|
|
21
|
-
{ value: '👷 ci', name: ' 👷 ci: CI related changes' }
|
|
22
|
-
],
|
|
23
|
-
|
|
24
|
-
scopes: [
|
|
25
|
-
{ name: 'components' },
|
|
26
|
-
{ name: 'page' },
|
|
27
|
-
{ name: 'css' },
|
|
28
|
-
{ name: 'api' },
|
|
29
|
-
{ name: 'README.md' },
|
|
30
|
-
{ name: 'custom' }
|
|
31
|
-
],
|
|
32
|
-
|
|
33
|
-
messages: {
|
|
34
|
-
type: '请选择提交类型(必填)',
|
|
35
|
-
scope: '请选择文件修改范围(必填):',
|
|
36
|
-
customScope: '请输自定义文件修改范围(必填)',
|
|
37
|
-
subject: '请简要描述提交(必填)',
|
|
38
|
-
body: '请输入详细描述(可选)',
|
|
39
|
-
breaking: '列出任何breaking changes(可选)',
|
|
40
|
-
footer: '请输入要关闭的issue(可选)',
|
|
41
|
-
confirmCommit: '确定提交吗'
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
allowCustomScopes: true,
|
|
45
|
-
allowBreakingChanges: ['✨ feat', '🐛 fix'],
|
|
46
|
-
subjectLimit: 49
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
' > .cz-config.js
|
|
5
|
+
' > .czrc
|