@soybeanjs/cli 1.0.19 → 1.1.1
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/dist/index.cjs +107 -46
- package/dist/index.d.cts +2 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.js +107 -46
- package/package.json +15 -14
package/dist/index.cjs
CHANGED
|
@@ -37,13 +37,12 @@ module.exports = __toCommonJS(src_exports);
|
|
|
37
37
|
var import_cac = __toESM(require("cac"), 1);
|
|
38
38
|
|
|
39
39
|
// package.json
|
|
40
|
-
var version = "1.
|
|
40
|
+
var version = "1.1.1";
|
|
41
41
|
|
|
42
42
|
// src/command/git-commit.ts
|
|
43
43
|
var import_node_path = __toESM(require("path"), 1);
|
|
44
44
|
var import_node_fs = require("fs");
|
|
45
45
|
var import_enquirer = require("enquirer");
|
|
46
|
-
var import_kolorist = require("kolorist");
|
|
47
46
|
|
|
48
47
|
// src/shared/index.ts
|
|
49
48
|
async function execCommand(cmd, args, options) {
|
|
@@ -52,8 +51,90 @@ async function execCommand(cmd, args, options) {
|
|
|
52
51
|
return res?.stdout?.trim() || "";
|
|
53
52
|
}
|
|
54
53
|
|
|
54
|
+
// src/locales/index.ts
|
|
55
|
+
var import_kolorist = require("kolorist");
|
|
56
|
+
var locales = {
|
|
57
|
+
"zh-cn": {
|
|
58
|
+
gitCommitMessages: {
|
|
59
|
+
types: "\u8BF7\u9009\u62E9\u63D0\u4EA4\u7C7B\u578B",
|
|
60
|
+
scopes: "\u8BF7\u9009\u62E9\u63D0\u4EA4\u8303\u56F4",
|
|
61
|
+
description: `\u8BF7\u8F93\u5165\u63CF\u8FF0\u4FE1\u606F\uFF08${(0, import_kolorist.yellow)("!")}\u5F00\u5934\u8868\u793A\u7834\u574F\u6027\u6539\u52A8`
|
|
62
|
+
},
|
|
63
|
+
gitCommitTypes: [
|
|
64
|
+
["feat", "\u65B0\u529F\u80FD"],
|
|
65
|
+
["fix", "\u4FEE\u590DBug"],
|
|
66
|
+
["docs", "\u53EA\u6D89\u53CA\u6587\u6863\u66F4\u65B0"],
|
|
67
|
+
["style", "\u4FEE\u6539\u4EE3\u7801\u98CE\u683C\uFF0C\u4E0D\u5F71\u54CD\u4EE3\u7801\u542B\u4E49\u7684\u53D8\u66F4"],
|
|
68
|
+
["refactor", "\u4EE3\u7801\u91CD\u6784\uFF0C\u65E2\u4E0D\u4FEE\u590D bug \u4E5F\u4E0D\u6DFB\u52A0\u529F\u80FD\u7684\u4EE3\u7801\u53D8\u66F4"],
|
|
69
|
+
["perf", "\u53EF\u63D0\u9AD8\u6027\u80FD\u7684\u4EE3\u7801\u66F4\u6539"],
|
|
70
|
+
["optimize", "\u4F18\u5316\u4EE3\u7801\u8D28\u91CF\u7684\u4EE3\u7801\u66F4\u6539"],
|
|
71
|
+
["test", "\u6DFB\u52A0\u7F3A\u5931\u7684\u6D4B\u8BD5\u6216\u66F4\u6B63\u73B0\u6709\u6D4B\u8BD5"],
|
|
72
|
+
["build", "\u5F71\u54CD\u6784\u5EFA\u7CFB\u7EDF\u6216\u5916\u90E8\u4F9D\u8D56\u9879\u7684\u66F4\u6539"],
|
|
73
|
+
["ci", "\u5BF9 CI \u914D\u7F6E\u6587\u4EF6\u548C\u811A\u672C\u7684\u66F4\u6539"],
|
|
74
|
+
["chore", "\u6CA1\u6709\u4FEE\u6539src\u6216\u6D4B\u8BD5\u6587\u4EF6\u7684\u5176\u4ED6\u53D8\u66F4"],
|
|
75
|
+
["revert", "\u8FD8\u539F\u5148\u524D\u7684\u63D0\u4EA4"]
|
|
76
|
+
],
|
|
77
|
+
gitCommitScopes: [
|
|
78
|
+
["projects", "\u9879\u76EE"],
|
|
79
|
+
["packages", "\u5305"],
|
|
80
|
+
["components", "\u7EC4\u4EF6"],
|
|
81
|
+
["hooks", "\u94A9\u5B50\u51FD\u6570"],
|
|
82
|
+
["utils", "\u5DE5\u5177\u51FD\u6570"],
|
|
83
|
+
["types", "TS\u7C7B\u578B\u58F0\u660E"],
|
|
84
|
+
["styles", "\u4EE3\u7801\u98CE\u683C"],
|
|
85
|
+
["deps", "\u9879\u76EE\u4F9D\u8D56"],
|
|
86
|
+
["release", "\u53D1\u5E03\u9879\u76EE\u65B0\u7248\u672C"],
|
|
87
|
+
["other", "\u5176\u4ED6\u7684\u53D8\u66F4"]
|
|
88
|
+
],
|
|
89
|
+
gitCommitVerify: `${(0, import_kolorist.bgRed)(" \u9519\u8BEF ")} ${(0, import_kolorist.red)("git \u63D0\u4EA4\u4FE1\u606F\u5FC5\u987B\u7B26\u5408 Conventional Commits \u6807\u51C6!")}
|
|
90
|
+
|
|
91
|
+
${(0, import_kolorist.green)(
|
|
92
|
+
"\u63A8\u8350\u4F7F\u7528\u547D\u4EE4 `pnpm commit` \u751F\u6210\u7B26\u5408 Conventional Commits \u6807\u51C6\u7684\u63D0\u4EA4\u4FE1\u606F\u3002\n\u83B7\u53D6\u6709\u5173 Conventional Commits \u7684\u66F4\u591A\u4FE1\u606F\uFF0C\u8BF7\u8BBF\u95EE\u6B64\u94FE\u63A5: https://conventionalcommits.org"
|
|
93
|
+
)}`
|
|
94
|
+
},
|
|
95
|
+
"en-us": {
|
|
96
|
+
gitCommitMessages: {
|
|
97
|
+
types: "Please select a type",
|
|
98
|
+
scopes: "Please select a scope",
|
|
99
|
+
description: `Please enter a description (add prefix ${(0, import_kolorist.yellow)("!")} to indicate breaking change)`
|
|
100
|
+
},
|
|
101
|
+
gitCommitTypes: [
|
|
102
|
+
["feat", "A new feature"],
|
|
103
|
+
["fix", "A bug fix"],
|
|
104
|
+
["docs", "Documentation only changes"],
|
|
105
|
+
["style", "Changes that do not affect the meaning of the code"],
|
|
106
|
+
["refactor", "A code change that neither fixes a bug nor adds a feature"],
|
|
107
|
+
["perf", "A code change that improves performance"],
|
|
108
|
+
["optimize", "A code change that optimizes code quality"],
|
|
109
|
+
["test", "Adding missing tests or correcting existing tests"],
|
|
110
|
+
["build", "Changes that affect the build system or external dependencies"],
|
|
111
|
+
["ci", "Changes to our CI configuration files and scripts"],
|
|
112
|
+
["chore", "Other changes that don't modify src or test files"],
|
|
113
|
+
["revert", "Reverts a previous commit"]
|
|
114
|
+
],
|
|
115
|
+
gitCommitScopes: [
|
|
116
|
+
["projects", "project"],
|
|
117
|
+
["packages", "packages"],
|
|
118
|
+
["components", "components"],
|
|
119
|
+
["hooks", "hook functions"],
|
|
120
|
+
["utils", "utils functions"],
|
|
121
|
+
["types", "TS declaration"],
|
|
122
|
+
["styles", "style"],
|
|
123
|
+
["deps", "project dependencies"],
|
|
124
|
+
["release", "release project"],
|
|
125
|
+
["other", "other changes"]
|
|
126
|
+
],
|
|
127
|
+
gitCommitVerify: `${(0, import_kolorist.bgRed)(" ERROR ")} ${(0, import_kolorist.red)("git commit message must match the Conventional Commits standard!")}
|
|
128
|
+
|
|
129
|
+
${(0, import_kolorist.green)(
|
|
130
|
+
"Recommended to use the command `pnpm commit` to generate Conventional Commits compliant commit information.\nGet more info about Conventional Commits, follow this link: https://conventionalcommits.org"
|
|
131
|
+
)}`
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
55
135
|
// src/command/git-commit.ts
|
|
56
|
-
async function gitCommit(
|
|
136
|
+
async function gitCommit(lang = "en-us") {
|
|
137
|
+
const { gitCommitMessages, gitCommitTypes, gitCommitScopes } = locales[lang];
|
|
57
138
|
const typesChoices = gitCommitTypes.map(([value, msg]) => {
|
|
58
139
|
const nameWithSuffix = `${value}:`;
|
|
59
140
|
const message = `${nameWithSuffix.padEnd(12)}${msg}`;
|
|
@@ -70,19 +151,19 @@ async function gitCommit(gitCommitTypes, gitCommitScopes) {
|
|
|
70
151
|
{
|
|
71
152
|
name: "types",
|
|
72
153
|
type: "select",
|
|
73
|
-
message:
|
|
154
|
+
message: gitCommitMessages.types,
|
|
74
155
|
choices: typesChoices
|
|
75
156
|
},
|
|
76
157
|
{
|
|
77
158
|
name: "scopes",
|
|
78
159
|
type: "select",
|
|
79
|
-
message:
|
|
160
|
+
message: gitCommitMessages.scopes,
|
|
80
161
|
choices: scopesChoices
|
|
81
162
|
},
|
|
82
163
|
{
|
|
83
164
|
name: "description",
|
|
84
165
|
type: "text",
|
|
85
|
-
message:
|
|
166
|
+
message: gitCommitMessages.description
|
|
86
167
|
}
|
|
87
168
|
]);
|
|
88
169
|
const breaking = result.description.startsWith("!") ? "!" : "";
|
|
@@ -90,19 +171,15 @@ async function gitCommit(gitCommitTypes, gitCommitScopes) {
|
|
|
90
171
|
const commitMsg = `${result.types}(${result.scopes})${breaking}: ${description}`;
|
|
91
172
|
await execCommand("git", ["commit", "-m", commitMsg], { stdio: "inherit" });
|
|
92
173
|
}
|
|
93
|
-
async function gitCommitVerify() {
|
|
174
|
+
async function gitCommitVerify(lang = "en-us", ignores = []) {
|
|
94
175
|
const gitPath = await execCommand("git", ["rev-parse", "--show-toplevel"]);
|
|
95
176
|
const gitMsgPath = import_node_path.default.join(gitPath, ".git", "COMMIT_EDITMSG");
|
|
96
177
|
const commitMsg = (0, import_node_fs.readFileSync)(gitMsgPath, "utf8").trim();
|
|
178
|
+
if (ignores.some((regExp) => regExp.test(commitMsg))) return;
|
|
97
179
|
const REG_EXP = /(?<type>[a-z]+)(?:\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)/i;
|
|
98
180
|
if (!REG_EXP.test(commitMsg)) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
${(0, import_kolorist.green)(
|
|
103
|
-
"Recommended to use the command `pnpm commit` to generate Conventional Commits compliant commit information.\nGet more info about Conventional Commits, follow this link: https://conventionalcommits.org"
|
|
104
|
-
)}`
|
|
105
|
-
);
|
|
181
|
+
const errorMsg = locales[lang].gitCommitVerify;
|
|
182
|
+
throw new Error(errorMsg);
|
|
106
183
|
}
|
|
107
184
|
}
|
|
108
185
|
|
|
@@ -153,34 +230,18 @@ var defaultOptions = {
|
|
|
153
230
|
"**/node_modules",
|
|
154
231
|
"!node_modules/**"
|
|
155
232
|
],
|
|
156
|
-
gitCommitTypes: [
|
|
157
|
-
["feat", "A new feature"],
|
|
158
|
-
["fix", "A bug fix"],
|
|
159
|
-
["docs", "Documentation only changes"],
|
|
160
|
-
["style", "Changes that do not affect the meaning of the code"],
|
|
161
|
-
["refactor", "A code change that neither fixes a bug nor adds a feature"],
|
|
162
|
-
["perf", "A code change that improves performance"],
|
|
163
|
-
["optimize", "A code change that optimizes code quality"],
|
|
164
|
-
["test", "Adding missing tests or correcting existing tests"],
|
|
165
|
-
["build", "Changes that affect the build system or external dependencies"],
|
|
166
|
-
["ci", "Changes to our CI configuration files and scripts"],
|
|
167
|
-
["chore", "Other changes that don't modify src or test files"],
|
|
168
|
-
["revert", "Reverts a previous commit"]
|
|
169
|
-
],
|
|
170
|
-
gitCommitScopes: [
|
|
171
|
-
["projects", "project"],
|
|
172
|
-
["packages", "packages"],
|
|
173
|
-
["components", "components"],
|
|
174
|
-
["hooks", "hook functions"],
|
|
175
|
-
["utils", "utils functions"],
|
|
176
|
-
["types", "TS declaration"],
|
|
177
|
-
["styles", "style"],
|
|
178
|
-
["deps", "project dependencies"],
|
|
179
|
-
["release", "release project"],
|
|
180
|
-
["other", "other changes"]
|
|
181
|
-
],
|
|
182
233
|
ncuCommandArgs: ["--deep", "-u"],
|
|
183
|
-
changelogOptions: {}
|
|
234
|
+
changelogOptions: {},
|
|
235
|
+
gitCommitVerifyIgnores: [
|
|
236
|
+
/^((Merge pull request)|(Merge (.*?) into (.*?)|(Merge branch (.*?)))(?:\r?\n)*$)/m,
|
|
237
|
+
/^(Merge tag (.*?))(?:\r?\n)*$/m,
|
|
238
|
+
/^(R|r)evert (.*)/,
|
|
239
|
+
/^(amend|fixup|squash)!/,
|
|
240
|
+
/^(Merged (.*?)(in|into) (.*)|Merged PR (.*): (.*))/,
|
|
241
|
+
/^Merge remote-tracking branch(\s*)(.*)/,
|
|
242
|
+
/^Automatic merge(.*)/,
|
|
243
|
+
/^Auto-merged (.*?) into (.*)/
|
|
244
|
+
]
|
|
184
245
|
};
|
|
185
246
|
async function loadCliOptions(overrides, cwd = import_node_process.default.cwd()) {
|
|
186
247
|
const { config } = await (0, import_c12.loadConfig)({
|
|
@@ -203,7 +264,7 @@ async function setupCli() {
|
|
|
203
264
|
).option("-p, --push", "Indicates whether to push the git commit and tag").option("-t, --total", "Generate changelog by total tags").option(
|
|
204
265
|
"-c, --cleanupDir <dir>",
|
|
205
266
|
'The glob pattern of dirs to cleanup, If not set, it will use the default value, Multiple values use "," to separate them'
|
|
206
|
-
).help();
|
|
267
|
+
).option("-l, --lang <lang>", "display lang of cli", { default: "en-us", type: [String] }).help();
|
|
207
268
|
const commands = {
|
|
208
269
|
cleanup: {
|
|
209
270
|
desc: "delete dirs: node_modules, dist, etc.",
|
|
@@ -230,14 +291,14 @@ async function setupCli() {
|
|
|
230
291
|
},
|
|
231
292
|
"git-commit": {
|
|
232
293
|
desc: "git commit, generate commit message which match Conventional Commits standard",
|
|
233
|
-
action: async () => {
|
|
234
|
-
await gitCommit(
|
|
294
|
+
action: async (args) => {
|
|
295
|
+
await gitCommit(args?.lang);
|
|
235
296
|
}
|
|
236
297
|
},
|
|
237
298
|
"git-commit-verify": {
|
|
238
299
|
desc: "verify git commit message, make sure it match Conventional Commits standard",
|
|
239
|
-
action: async () => {
|
|
240
|
-
await gitCommitVerify();
|
|
300
|
+
action: async (args) => {
|
|
301
|
+
await gitCommitVerify(args?.lang, cliOptions.gitCommitVerifyIgnores);
|
|
241
302
|
}
|
|
242
303
|
},
|
|
243
304
|
changelog: {
|
package/dist/index.d.cts
CHANGED
|
@@ -15,10 +15,6 @@ interface CliOption {
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
cleanupDirs: string[];
|
|
18
|
-
/** Git commit types */
|
|
19
|
-
gitCommitTypes: [string, string][];
|
|
20
|
-
/** Git commit scopes */
|
|
21
|
-
gitCommitScopes: [string, string][];
|
|
22
18
|
/**
|
|
23
19
|
* Npm-check-updates command args
|
|
24
20
|
*
|
|
@@ -31,6 +27,8 @@ interface CliOption {
|
|
|
31
27
|
* @link https://github.com/soybeanjs/changelog
|
|
32
28
|
*/
|
|
33
29
|
changelogOptions: Partial<ChangelogOption>;
|
|
30
|
+
/** The ignore pattern list of git commit verify */
|
|
31
|
+
gitCommitVerifyIgnores: RegExp[];
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
declare function defineConfig(config?: Partial<CliOption>): Partial<CliOption> | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -15,10 +15,6 @@ interface CliOption {
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
cleanupDirs: string[];
|
|
18
|
-
/** Git commit types */
|
|
19
|
-
gitCommitTypes: [string, string][];
|
|
20
|
-
/** Git commit scopes */
|
|
21
|
-
gitCommitScopes: [string, string][];
|
|
22
18
|
/**
|
|
23
19
|
* Npm-check-updates command args
|
|
24
20
|
*
|
|
@@ -31,6 +27,8 @@ interface CliOption {
|
|
|
31
27
|
* @link https://github.com/soybeanjs/changelog
|
|
32
28
|
*/
|
|
33
29
|
changelogOptions: Partial<ChangelogOption>;
|
|
30
|
+
/** The ignore pattern list of git commit verify */
|
|
31
|
+
gitCommitVerifyIgnores: RegExp[];
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
declare function defineConfig(config?: Partial<CliOption>): Partial<CliOption> | undefined;
|
package/dist/index.js
CHANGED
|
@@ -4,13 +4,12 @@
|
|
|
4
4
|
import cac from "cac";
|
|
5
5
|
|
|
6
6
|
// package.json
|
|
7
|
-
var version = "1.
|
|
7
|
+
var version = "1.1.1";
|
|
8
8
|
|
|
9
9
|
// src/command/git-commit.ts
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { readFileSync } from "node:fs";
|
|
12
12
|
import { prompt } from "enquirer";
|
|
13
|
-
import { bgRed, green, red, yellow } from "kolorist";
|
|
14
13
|
|
|
15
14
|
// src/shared/index.ts
|
|
16
15
|
async function execCommand(cmd, args, options) {
|
|
@@ -19,8 +18,90 @@ async function execCommand(cmd, args, options) {
|
|
|
19
18
|
return res?.stdout?.trim() || "";
|
|
20
19
|
}
|
|
21
20
|
|
|
21
|
+
// src/locales/index.ts
|
|
22
|
+
import { bgRed, green, red, yellow } from "kolorist";
|
|
23
|
+
var locales = {
|
|
24
|
+
"zh-cn": {
|
|
25
|
+
gitCommitMessages: {
|
|
26
|
+
types: "\u8BF7\u9009\u62E9\u63D0\u4EA4\u7C7B\u578B",
|
|
27
|
+
scopes: "\u8BF7\u9009\u62E9\u63D0\u4EA4\u8303\u56F4",
|
|
28
|
+
description: `\u8BF7\u8F93\u5165\u63CF\u8FF0\u4FE1\u606F\uFF08${yellow("!")}\u5F00\u5934\u8868\u793A\u7834\u574F\u6027\u6539\u52A8`
|
|
29
|
+
},
|
|
30
|
+
gitCommitTypes: [
|
|
31
|
+
["feat", "\u65B0\u529F\u80FD"],
|
|
32
|
+
["fix", "\u4FEE\u590DBug"],
|
|
33
|
+
["docs", "\u53EA\u6D89\u53CA\u6587\u6863\u66F4\u65B0"],
|
|
34
|
+
["style", "\u4FEE\u6539\u4EE3\u7801\u98CE\u683C\uFF0C\u4E0D\u5F71\u54CD\u4EE3\u7801\u542B\u4E49\u7684\u53D8\u66F4"],
|
|
35
|
+
["refactor", "\u4EE3\u7801\u91CD\u6784\uFF0C\u65E2\u4E0D\u4FEE\u590D bug \u4E5F\u4E0D\u6DFB\u52A0\u529F\u80FD\u7684\u4EE3\u7801\u53D8\u66F4"],
|
|
36
|
+
["perf", "\u53EF\u63D0\u9AD8\u6027\u80FD\u7684\u4EE3\u7801\u66F4\u6539"],
|
|
37
|
+
["optimize", "\u4F18\u5316\u4EE3\u7801\u8D28\u91CF\u7684\u4EE3\u7801\u66F4\u6539"],
|
|
38
|
+
["test", "\u6DFB\u52A0\u7F3A\u5931\u7684\u6D4B\u8BD5\u6216\u66F4\u6B63\u73B0\u6709\u6D4B\u8BD5"],
|
|
39
|
+
["build", "\u5F71\u54CD\u6784\u5EFA\u7CFB\u7EDF\u6216\u5916\u90E8\u4F9D\u8D56\u9879\u7684\u66F4\u6539"],
|
|
40
|
+
["ci", "\u5BF9 CI \u914D\u7F6E\u6587\u4EF6\u548C\u811A\u672C\u7684\u66F4\u6539"],
|
|
41
|
+
["chore", "\u6CA1\u6709\u4FEE\u6539src\u6216\u6D4B\u8BD5\u6587\u4EF6\u7684\u5176\u4ED6\u53D8\u66F4"],
|
|
42
|
+
["revert", "\u8FD8\u539F\u5148\u524D\u7684\u63D0\u4EA4"]
|
|
43
|
+
],
|
|
44
|
+
gitCommitScopes: [
|
|
45
|
+
["projects", "\u9879\u76EE"],
|
|
46
|
+
["packages", "\u5305"],
|
|
47
|
+
["components", "\u7EC4\u4EF6"],
|
|
48
|
+
["hooks", "\u94A9\u5B50\u51FD\u6570"],
|
|
49
|
+
["utils", "\u5DE5\u5177\u51FD\u6570"],
|
|
50
|
+
["types", "TS\u7C7B\u578B\u58F0\u660E"],
|
|
51
|
+
["styles", "\u4EE3\u7801\u98CE\u683C"],
|
|
52
|
+
["deps", "\u9879\u76EE\u4F9D\u8D56"],
|
|
53
|
+
["release", "\u53D1\u5E03\u9879\u76EE\u65B0\u7248\u672C"],
|
|
54
|
+
["other", "\u5176\u4ED6\u7684\u53D8\u66F4"]
|
|
55
|
+
],
|
|
56
|
+
gitCommitVerify: `${bgRed(" \u9519\u8BEF ")} ${red("git \u63D0\u4EA4\u4FE1\u606F\u5FC5\u987B\u7B26\u5408 Conventional Commits \u6807\u51C6!")}
|
|
57
|
+
|
|
58
|
+
${green(
|
|
59
|
+
"\u63A8\u8350\u4F7F\u7528\u547D\u4EE4 `pnpm commit` \u751F\u6210\u7B26\u5408 Conventional Commits \u6807\u51C6\u7684\u63D0\u4EA4\u4FE1\u606F\u3002\n\u83B7\u53D6\u6709\u5173 Conventional Commits \u7684\u66F4\u591A\u4FE1\u606F\uFF0C\u8BF7\u8BBF\u95EE\u6B64\u94FE\u63A5: https://conventionalcommits.org"
|
|
60
|
+
)}`
|
|
61
|
+
},
|
|
62
|
+
"en-us": {
|
|
63
|
+
gitCommitMessages: {
|
|
64
|
+
types: "Please select a type",
|
|
65
|
+
scopes: "Please select a scope",
|
|
66
|
+
description: `Please enter a description (add prefix ${yellow("!")} to indicate breaking change)`
|
|
67
|
+
},
|
|
68
|
+
gitCommitTypes: [
|
|
69
|
+
["feat", "A new feature"],
|
|
70
|
+
["fix", "A bug fix"],
|
|
71
|
+
["docs", "Documentation only changes"],
|
|
72
|
+
["style", "Changes that do not affect the meaning of the code"],
|
|
73
|
+
["refactor", "A code change that neither fixes a bug nor adds a feature"],
|
|
74
|
+
["perf", "A code change that improves performance"],
|
|
75
|
+
["optimize", "A code change that optimizes code quality"],
|
|
76
|
+
["test", "Adding missing tests or correcting existing tests"],
|
|
77
|
+
["build", "Changes that affect the build system or external dependencies"],
|
|
78
|
+
["ci", "Changes to our CI configuration files and scripts"],
|
|
79
|
+
["chore", "Other changes that don't modify src or test files"],
|
|
80
|
+
["revert", "Reverts a previous commit"]
|
|
81
|
+
],
|
|
82
|
+
gitCommitScopes: [
|
|
83
|
+
["projects", "project"],
|
|
84
|
+
["packages", "packages"],
|
|
85
|
+
["components", "components"],
|
|
86
|
+
["hooks", "hook functions"],
|
|
87
|
+
["utils", "utils functions"],
|
|
88
|
+
["types", "TS declaration"],
|
|
89
|
+
["styles", "style"],
|
|
90
|
+
["deps", "project dependencies"],
|
|
91
|
+
["release", "release project"],
|
|
92
|
+
["other", "other changes"]
|
|
93
|
+
],
|
|
94
|
+
gitCommitVerify: `${bgRed(" ERROR ")} ${red("git commit message must match the Conventional Commits standard!")}
|
|
95
|
+
|
|
96
|
+
${green(
|
|
97
|
+
"Recommended to use the command `pnpm commit` to generate Conventional Commits compliant commit information.\nGet more info about Conventional Commits, follow this link: https://conventionalcommits.org"
|
|
98
|
+
)}`
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
22
102
|
// src/command/git-commit.ts
|
|
23
|
-
async function gitCommit(
|
|
103
|
+
async function gitCommit(lang = "en-us") {
|
|
104
|
+
const { gitCommitMessages, gitCommitTypes, gitCommitScopes } = locales[lang];
|
|
24
105
|
const typesChoices = gitCommitTypes.map(([value, msg]) => {
|
|
25
106
|
const nameWithSuffix = `${value}:`;
|
|
26
107
|
const message = `${nameWithSuffix.padEnd(12)}${msg}`;
|
|
@@ -37,19 +118,19 @@ async function gitCommit(gitCommitTypes, gitCommitScopes) {
|
|
|
37
118
|
{
|
|
38
119
|
name: "types",
|
|
39
120
|
type: "select",
|
|
40
|
-
message:
|
|
121
|
+
message: gitCommitMessages.types,
|
|
41
122
|
choices: typesChoices
|
|
42
123
|
},
|
|
43
124
|
{
|
|
44
125
|
name: "scopes",
|
|
45
126
|
type: "select",
|
|
46
|
-
message:
|
|
127
|
+
message: gitCommitMessages.scopes,
|
|
47
128
|
choices: scopesChoices
|
|
48
129
|
},
|
|
49
130
|
{
|
|
50
131
|
name: "description",
|
|
51
132
|
type: "text",
|
|
52
|
-
message:
|
|
133
|
+
message: gitCommitMessages.description
|
|
53
134
|
}
|
|
54
135
|
]);
|
|
55
136
|
const breaking = result.description.startsWith("!") ? "!" : "";
|
|
@@ -57,19 +138,15 @@ async function gitCommit(gitCommitTypes, gitCommitScopes) {
|
|
|
57
138
|
const commitMsg = `${result.types}(${result.scopes})${breaking}: ${description}`;
|
|
58
139
|
await execCommand("git", ["commit", "-m", commitMsg], { stdio: "inherit" });
|
|
59
140
|
}
|
|
60
|
-
async function gitCommitVerify() {
|
|
141
|
+
async function gitCommitVerify(lang = "en-us", ignores = []) {
|
|
61
142
|
const gitPath = await execCommand("git", ["rev-parse", "--show-toplevel"]);
|
|
62
143
|
const gitMsgPath = path.join(gitPath, ".git", "COMMIT_EDITMSG");
|
|
63
144
|
const commitMsg = readFileSync(gitMsgPath, "utf8").trim();
|
|
145
|
+
if (ignores.some((regExp) => regExp.test(commitMsg))) return;
|
|
64
146
|
const REG_EXP = /(?<type>[a-z]+)(?:\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)/i;
|
|
65
147
|
if (!REG_EXP.test(commitMsg)) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
${green(
|
|
70
|
-
"Recommended to use the command `pnpm commit` to generate Conventional Commits compliant commit information.\nGet more info about Conventional Commits, follow this link: https://conventionalcommits.org"
|
|
71
|
-
)}`
|
|
72
|
-
);
|
|
148
|
+
const errorMsg = locales[lang].gitCommitVerify;
|
|
149
|
+
throw new Error(errorMsg);
|
|
73
150
|
}
|
|
74
151
|
}
|
|
75
152
|
|
|
@@ -120,34 +197,18 @@ var defaultOptions = {
|
|
|
120
197
|
"**/node_modules",
|
|
121
198
|
"!node_modules/**"
|
|
122
199
|
],
|
|
123
|
-
gitCommitTypes: [
|
|
124
|
-
["feat", "A new feature"],
|
|
125
|
-
["fix", "A bug fix"],
|
|
126
|
-
["docs", "Documentation only changes"],
|
|
127
|
-
["style", "Changes that do not affect the meaning of the code"],
|
|
128
|
-
["refactor", "A code change that neither fixes a bug nor adds a feature"],
|
|
129
|
-
["perf", "A code change that improves performance"],
|
|
130
|
-
["optimize", "A code change that optimizes code quality"],
|
|
131
|
-
["test", "Adding missing tests or correcting existing tests"],
|
|
132
|
-
["build", "Changes that affect the build system or external dependencies"],
|
|
133
|
-
["ci", "Changes to our CI configuration files and scripts"],
|
|
134
|
-
["chore", "Other changes that don't modify src or test files"],
|
|
135
|
-
["revert", "Reverts a previous commit"]
|
|
136
|
-
],
|
|
137
|
-
gitCommitScopes: [
|
|
138
|
-
["projects", "project"],
|
|
139
|
-
["packages", "packages"],
|
|
140
|
-
["components", "components"],
|
|
141
|
-
["hooks", "hook functions"],
|
|
142
|
-
["utils", "utils functions"],
|
|
143
|
-
["types", "TS declaration"],
|
|
144
|
-
["styles", "style"],
|
|
145
|
-
["deps", "project dependencies"],
|
|
146
|
-
["release", "release project"],
|
|
147
|
-
["other", "other changes"]
|
|
148
|
-
],
|
|
149
200
|
ncuCommandArgs: ["--deep", "-u"],
|
|
150
|
-
changelogOptions: {}
|
|
201
|
+
changelogOptions: {},
|
|
202
|
+
gitCommitVerifyIgnores: [
|
|
203
|
+
/^((Merge pull request)|(Merge (.*?) into (.*?)|(Merge branch (.*?)))(?:\r?\n)*$)/m,
|
|
204
|
+
/^(Merge tag (.*?))(?:\r?\n)*$/m,
|
|
205
|
+
/^(R|r)evert (.*)/,
|
|
206
|
+
/^(amend|fixup|squash)!/,
|
|
207
|
+
/^(Merged (.*?)(in|into) (.*)|Merged PR (.*): (.*))/,
|
|
208
|
+
/^Merge remote-tracking branch(\s*)(.*)/,
|
|
209
|
+
/^Automatic merge(.*)/,
|
|
210
|
+
/^Auto-merged (.*?) into (.*)/
|
|
211
|
+
]
|
|
151
212
|
};
|
|
152
213
|
async function loadCliOptions(overrides, cwd = process.cwd()) {
|
|
153
214
|
const { config } = await loadConfig({
|
|
@@ -170,7 +231,7 @@ async function setupCli() {
|
|
|
170
231
|
).option("-p, --push", "Indicates whether to push the git commit and tag").option("-t, --total", "Generate changelog by total tags").option(
|
|
171
232
|
"-c, --cleanupDir <dir>",
|
|
172
233
|
'The glob pattern of dirs to cleanup, If not set, it will use the default value, Multiple values use "," to separate them'
|
|
173
|
-
).help();
|
|
234
|
+
).option("-l, --lang <lang>", "display lang of cli", { default: "en-us", type: [String] }).help();
|
|
174
235
|
const commands = {
|
|
175
236
|
cleanup: {
|
|
176
237
|
desc: "delete dirs: node_modules, dist, etc.",
|
|
@@ -197,14 +258,14 @@ async function setupCli() {
|
|
|
197
258
|
},
|
|
198
259
|
"git-commit": {
|
|
199
260
|
desc: "git commit, generate commit message which match Conventional Commits standard",
|
|
200
|
-
action: async () => {
|
|
201
|
-
await gitCommit(
|
|
261
|
+
action: async (args) => {
|
|
262
|
+
await gitCommit(args?.lang);
|
|
202
263
|
}
|
|
203
264
|
},
|
|
204
265
|
"git-commit-verify": {
|
|
205
266
|
desc: "verify git commit message, make sure it match Conventional Commits standard",
|
|
206
|
-
action: async () => {
|
|
207
|
-
await gitCommitVerify();
|
|
267
|
+
action: async (args) => {
|
|
268
|
+
await gitCommitVerify(args?.lang, cliOptions.gitCommitVerifyIgnores);
|
|
208
269
|
}
|
|
209
270
|
},
|
|
210
271
|
changelog: {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soybeanjs/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"description": "SoybeanJS's command line tools",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Soybean",
|
|
@@ -38,28 +38,28 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@soybeanjs/changelog": "0.3.24",
|
|
41
|
-
"bumpp": "9.
|
|
42
|
-
"c12": "1.
|
|
41
|
+
"bumpp": "9.5.2",
|
|
42
|
+
"c12": "1.11.2",
|
|
43
43
|
"cac": "6.7.14",
|
|
44
44
|
"consola": "3.2.3",
|
|
45
45
|
"enquirer": "2.4.1",
|
|
46
|
-
"execa": "9.
|
|
46
|
+
"execa": "9.3.1",
|
|
47
47
|
"kolorist": "1.8.0",
|
|
48
|
-
"npm-check-updates": "
|
|
49
|
-
"rimraf": "
|
|
48
|
+
"npm-check-updates": "17.1.1",
|
|
49
|
+
"rimraf": "6.0.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@soybeanjs/cli": "link:",
|
|
53
|
-
"@soybeanjs/eslint-config": "1.
|
|
54
|
-
"@types/node": "
|
|
55
|
-
"eslint": "9.
|
|
56
|
-
"eslint-plugin-vue": "9.
|
|
53
|
+
"@soybeanjs/eslint-config": "1.4.1",
|
|
54
|
+
"@types/node": "22.5.4",
|
|
55
|
+
"eslint": "9.10.0",
|
|
56
|
+
"eslint-plugin-vue": "9.28.0",
|
|
57
57
|
"fast-glob": "3.3.2",
|
|
58
|
-
"lint-staged": "15.2.
|
|
58
|
+
"lint-staged": "15.2.10",
|
|
59
59
|
"simple-git-hooks": "2.11.1",
|
|
60
|
-
"tsup": "8.
|
|
61
|
-
"tsx": "4.
|
|
62
|
-
"typescript": "5.4
|
|
60
|
+
"tsup": "8.2.4",
|
|
61
|
+
"tsx": "4.19.0",
|
|
62
|
+
"typescript": "5.5.4",
|
|
63
63
|
"vue-eslint-parser": "9.4.3"
|
|
64
64
|
},
|
|
65
65
|
"simple-git-hooks": {
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"build-pkg": "pnpm -r --filter='./packages/*' run build",
|
|
75
75
|
"cleanup": "soy cleanup",
|
|
76
76
|
"commit": "soy git-commit",
|
|
77
|
+
"commit:zh": "soy git-commit -l=zh-cn",
|
|
77
78
|
"lint": "eslint . --fix",
|
|
78
79
|
"publish-pkg": "pnpm -r publish --access public",
|
|
79
80
|
"release": "soy release -e 'pnpm release-execute'",
|