commit-pack 1.0.12 → 1.0.14
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 +24 -11
- package/lib/index.mjs +21 -15
- package/package.json +1 -1
- 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
|
|
|
@@ -119,16 +131,16 @@ try {
|
|
|
119
131
|
let huskyInitCommand = ''
|
|
120
132
|
switch (packageManager) {
|
|
121
133
|
case 'pnpm':
|
|
122
|
-
huskyInitCommand = 'pnpm husky
|
|
134
|
+
huskyInitCommand = 'pnpm exec husky init'
|
|
123
135
|
break
|
|
124
136
|
case 'yarn':
|
|
125
|
-
huskyInitCommand = 'yarn husky
|
|
137
|
+
huskyInitCommand = 'yarn dlx husky init'
|
|
126
138
|
break
|
|
127
139
|
case 'bun':
|
|
128
|
-
huskyInitCommand = 'bunx husky
|
|
140
|
+
huskyInitCommand = 'bunx husky init'
|
|
129
141
|
break
|
|
130
142
|
default:
|
|
131
|
-
huskyInitCommand = 'npx husky
|
|
143
|
+
huskyInitCommand = 'npx husky init'
|
|
132
144
|
break
|
|
133
145
|
}
|
|
134
146
|
|
|
@@ -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
|
|
@@ -107,16 +113,16 @@ try {
|
|
|
107
113
|
let huskyInitCommand = '';
|
|
108
114
|
switch (packageManager) {
|
|
109
115
|
case 'pnpm':
|
|
110
|
-
huskyInitCommand = 'pnpm husky
|
|
116
|
+
huskyInitCommand = 'pnpm exec husky init';
|
|
111
117
|
break;
|
|
112
118
|
case 'yarn':
|
|
113
|
-
huskyInitCommand = 'yarn husky
|
|
119
|
+
huskyInitCommand = 'yarn dlx husky init';
|
|
114
120
|
break;
|
|
115
121
|
case 'bun':
|
|
116
|
-
huskyInitCommand = 'bunx husky
|
|
122
|
+
huskyInitCommand = 'bunx husky init';
|
|
117
123
|
break;
|
|
118
124
|
default:
|
|
119
|
-
huskyInitCommand = 'npx husky
|
|
125
|
+
huskyInitCommand = 'npx husky init';
|
|
120
126
|
break;
|
|
121
127
|
}
|
|
122
128
|
console.log(_chalk.default.green(`执行 Husky 初始化命令:${huskyInitCommand}`));
|
|
@@ -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
|
@@ -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
|