standards-cli 1.0.9 → 1.0.11
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/package.json +1 -1
- package/src/commands/init.js +26 -15
- package/templates/commitlint/config.cjs +12 -3
package/package.json
CHANGED
package/src/commands/init.js
CHANGED
|
@@ -199,7 +199,10 @@ async function updatePackageJson() {
|
|
|
199
199
|
pkg.scripts.prepare = "husky";
|
|
200
200
|
console.log(' ✔ 添加 scripts.prepare = "husky"');
|
|
201
201
|
modified = true;
|
|
202
|
-
} else if (
|
|
202
|
+
} else if (
|
|
203
|
+
pkg.scripts.prepare === "husky install" ||
|
|
204
|
+
pkg.scripts.prepare === "husky init"
|
|
205
|
+
) {
|
|
203
206
|
pkg.scripts.prepare = "husky";
|
|
204
207
|
console.log(' ✔ 更新 scripts.prepare = "husky"');
|
|
205
208
|
modified = true;
|
|
@@ -242,21 +245,29 @@ async function updatePackageJson() {
|
|
|
242
245
|
console.log(" ⚠ config.commitizen.path (已存在,跳过)");
|
|
243
246
|
}
|
|
244
247
|
|
|
245
|
-
//
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
248
|
+
// 智能处理 string-width 版本兼容性
|
|
249
|
+
// string-width v5+ 是 ESM 模块,可能导致某些工具在低版本 Node.js 或 CommonJS 环境下报错
|
|
250
|
+
// 检测 Node.js 版本,< 18 时降级到 v4
|
|
251
|
+
const nodeVersion = process.version.slice(1).split(".").map(Number);
|
|
252
|
+
const needOverride = nodeVersion[0] < 18;
|
|
253
|
+
|
|
254
|
+
if (needOverride) {
|
|
255
|
+
if (!pkg.pnpm) {
|
|
256
|
+
pkg.pnpm = {};
|
|
257
|
+
}
|
|
258
|
+
if (!pkg.pnpm.overrides) {
|
|
259
|
+
pkg.pnpm.overrides = {};
|
|
260
|
+
}
|
|
261
|
+
if (!pkg.pnpm.overrides["string-width"]) {
|
|
262
|
+
pkg.pnpm.overrides["string-width"] = "^4.2.3";
|
|
263
|
+
console.log(
|
|
264
|
+
' ✔ 添加 pnpm.overrides["string-width"] = "^4.2.3" (Node.js < 18 兼容)'
|
|
265
|
+
);
|
|
266
|
+
modified = true;
|
|
267
|
+
}
|
|
258
268
|
} else {
|
|
259
|
-
|
|
269
|
+
// Node.js >= 18,不添加 override,让 pnpm 自动处理
|
|
270
|
+
console.log(" ℹ Node.js >= 18,跳过 string-width override");
|
|
260
271
|
}
|
|
261
272
|
|
|
262
273
|
if (modified) {
|
|
@@ -18,13 +18,15 @@ module.exports = {
|
|
|
18
18
|
"revert",
|
|
19
19
|
],
|
|
20
20
|
],
|
|
21
|
+
"scope-empty": [2, "never"], // 必须填写 scope
|
|
21
22
|
"subject-empty": [2, "never"],
|
|
22
23
|
"subject-max-length": [2, "always", 72],
|
|
24
|
+
"subject-case": [0], // 允许中文,不限制大小写
|
|
23
25
|
},
|
|
24
26
|
prompt: {
|
|
25
27
|
messages: {
|
|
26
28
|
type: "选择你要提交的类型:",
|
|
27
|
-
|
|
29
|
+
scope: "输入 scope (必填,如: login, auth):",
|
|
28
30
|
subject: "输入简短描述:",
|
|
29
31
|
confirmCommit: "确认提交?",
|
|
30
32
|
},
|
|
@@ -42,7 +44,14 @@ module.exports = {
|
|
|
42
44
|
{ value: "revert", name: "revert: 回滚提交" },
|
|
43
45
|
],
|
|
44
46
|
useEmoji: false,
|
|
45
|
-
skipQuestions: [
|
|
46
|
-
|
|
47
|
+
skipQuestions: [
|
|
48
|
+
"body",
|
|
49
|
+
"breaking",
|
|
50
|
+
"breakingBody",
|
|
51
|
+
"footer",
|
|
52
|
+
"footerPrefix",
|
|
53
|
+
],
|
|
54
|
+
enableMultipleScopes: false,
|
|
55
|
+
scopeEnumSeparator: ",",
|
|
47
56
|
},
|
|
48
57
|
};
|